diff options
author | JaceCearK1 <JaceCearK1@users.noreply.github.com> | 2017-07-01 21:04:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-01 21:04:18 +0200 |
commit | 0dd804a99e5455a0eac8ff6ed87d9de16c7380b7 (patch) | |
tree | 7b3567978b63ee6548a7b945e075ea8ba37bef51 /src | |
parent | f1344efd2aff92292f58f7323bd9297a38fe9b02 (diff) | |
parent | 8d82578d3a101b06f9d2ced31738021007c4e533 (diff) |
Merge pull request #1 from pret/master
Update fork to match main fork.
Diffstat (limited to 'src')
165 files changed, 115234 insertions, 13558 deletions
diff --git a/src/agb_flash.c b/src/agb_flash.c index 34fb4e84a..340d469a7 100644 --- a/src/agb_flash.c +++ b/src/agb_flash.c @@ -217,7 +217,7 @@ u32 VerifyFlashSector(u16 sectorNum, u8 *src) tgt = FLASH_BASE + (sectorNum << gFlash->sector.shift); size = gFlash->sector.size; - return verifyFlashSector_Core(src, tgt, size); + return verifyFlashSector_Core(src, tgt, size); // return 0 if verified. } u32 VerifyFlashSectorNBytes(u16 sectorNum, u8 *src, u32 n) @@ -256,12 +256,12 @@ u32 VerifyFlashSectorNBytes(u16 sectorNum, u8 *src, u32 n) return verifyFlashSector_Core(src, tgt, n); } -u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src) +u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src) // 3rd is unused { u8 i; u32 result; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) // 3 attempts { result = ProgramFlashSector(sectorNum, src); if (result != 0) @@ -272,7 +272,7 @@ u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src) break; } - return result; + return result; // return 0 if verified and programmed. } u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, u8 *src, u32 n) diff --git a/src/bard_music.c b/src/bard_music.c new file mode 100644 index 000000000..a31568475 --- /dev/null +++ b/src/bard_music.c @@ -0,0 +1,97 @@ +#include "global.h" +#include "easy_chat.h" + +struct BardSound +{ + u8 pad_00[48]; +}; + +struct UnkBard +{ + /*0x00*/ u8 var00; + /*0x01*/ s8 var01; + /*0x02*/ u16 var02; + /*0x04*/ u16 var04; + /*0x06*/ u16 var06; +}; + +struct UnkBard3 +{ + /*0x00*/ u16 var00; + /*0x02*/ u16 var02; + /*0x04*/ s16 var04; + /*0x06*/ u16 var06; +}; + +struct UnkBard2 +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u8 var02; + /*0x03*/ u8 var03; + /*0x04*/ u16 var04; + u8 pad06[4]; + /*0x0A*/ u16 var0A; + u8 pad0C[12]; + /*0x18*/ struct UnkBard3 var18[6]; +}; + +extern struct BardSound *gBardMusicTable[]; +extern s16 *gUnknown_08417068[]; +extern u32 gUnknown_084170F4[]; + +static s16 sub_814A2B8(u32 arg0, u32 arg1) +{ + return gUnknown_08417068[arg0][arg1]; +} + +#if ENGLISH +struct BardSound *sub_814A2D0(u16 arg0, u16 arg1) +{ + struct BardSound *sounds = gBardMusicTable[arg0]; + + return &sounds[arg1]; +} +#elif GERMAN +struct BardSound *sub_814A2D0(u16 arg0, u16 arg1) +{ + u32 index; + struct BardSound *sounds; + + sounds = gBardMusicTable[arg0]; + index = de_sub_80EB748(arg0, arg1); + + return &sounds[index]; +} +#endif + +s32 sub_814A2EC(struct UnkBard2 *dest, struct UnkBard *src, u16 arg2) +{ + s32 i; + s32 j; + s32 thirty; + + for (i = 0; i < 6; i++) + { + dest->var18[i].var00 = src[i].var00; + if (src[i].var00 != 0xFF) + { + s32 r1 = src[i].var01 +gUnknown_084170F4[src[i].var00]; + + dest->var18[i].var02 = r1; + dest->var18[i].var06 = src[i].var04; + dest->var04 += r1; + } + } + + for (j = 0, thirty = 30; j < i; j++) + dest->var18[j].var04 = sub_814A2B8(thirty + arg2, j); + + dest->var00++; + dest->var01 = 0; + dest->var02 = 0; + dest->var03 = 0; + dest->var0A = 0; + + //warning: no return statement in function returning non-void +} diff --git a/src/battle_2.c b/src/battle_2.c new file mode 100644 index 000000000..2b13fc45d --- /dev/null +++ b/src/battle_2.c @@ -0,0 +1,2466 @@ +#include "global.h" +#include "abilities.h" +#include "battle.h" +#include "battle_interface.h" +#include "battle_setup.h" +#include "data2.h" +#include "item.h" +#include "link.h" +#include "main.h" +#include "name_string_util.h" +#include "palette.h" +#include "party_menu.h" +#include "pokeball.h" +#include "pokedex.h" +#include "pokemon.h" +#include "rng.h" +#include "rom3.h" +#include "rom_8077ABC.h" +#include "rom_8094928.h" +#include "songs.h" +#include "sound.h" +#include "species.h" +#include "sprite.h" +#include "task.h" +#include "text.h" +#include "trig.h" +#include "unknown_task.h" +#include "util.h" + +struct UnknownStruct6 +{ + u16 unk0[0xA0]; + u8 fillerA0[0x640]; + u16 unk780[0xA0]; +}; + +struct UnknownStruct7 +{ + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; +}; + +struct UnknownStruct8 +{ + u8 unk0[7]; + u8 unk7; + u8 unk8[18]; + u8 unk1A; +}; + +struct UnknownPokemonStruct2 +{ + /*0x00*/ u16 species; + /*0x02*/ u16 heldItem; + /*0x04*/ u8 nickname[11]; + /*0x0F*/ u8 level; + /*0x10*/ u16 hp; + /*0x12*/ u16 maxhp; + /*0x14*/ u32 status; + /*0x18*/ u32 personality; + /*0x1C*/ u8 gender; + /*0x1D*/ u8 language; +}; + +struct UnknownStruct12 +{ + u32 unk0; + u8 filler4[0x54]; +}; + +struct UnknownStruct13 +{ + u32 unk0_0:1; + u32 unk0_1:1; + u32 unk0_2:1; + u32 unk0_3:1; + u32 unk0_4:1; + u32 unk0_5:1; + u32 unk0_6:1; + u32 unk0_7:1; + u32 unk1_0:1; + u32 unk1_1:1; + u32 unk1_2:1; + u32 unk1_3:2; + u32 unk1_5:1; + u32 unk1_6:1; + u32 unk1_7:1; + u32 unk2_0:1; + u32 unk2_1:1; + u32 unk2_2:1; + u32 unk2_3:1; + u8 filler4[12]; +}; + +extern const u16 gUnknown_08D004E0[]; +extern const struct MonCoords gCastformFrontSpriteCoords[]; + +extern u8 ewram[]; +#define ewram0 (*(struct UnknownStruct7 *)(ewram + 0x0)) +#define ewram4 (*(struct UnknownStruct8 *)(ewram + 0x4)) +#define ewram16000 (ewram[0x16000]) +#define ewram16001 (ewram[0x16001]) +#define ewram16002 (ewram[0x16002]) +#define ewram16003 (ewram[0x16003]) +#define ewram1600C (ewram[0x1600C]) +#define ewram1600E (ewram[0x1600E]) +#define ewram1601B (ewram[0x1601B]) +#define ewram16020 ((u8 *)(ewram + 0x16020)) +#define ewram16056 (ewram[0x16056]) +#define ewram16058 (ewram[0x16058]) +#define ewram16059 (ewram[0x16059]) +#define ewram16078 (ewram[0x16078]) +#define ewram16084 (ewram[0x16084]) +#define ewram16086 (ewram[0x16086]) +#define ewram16087 (ewram[0x16087]) +#define ewram16088 (ewram[0x16088]) +#define ewram16089 (ewram[0x16089]) +#define ewram160A1 (ewram[0x160A1]) +#define ewram160A6 (ewram[0x160A6]) +#define ewram160AC ((u8 *)(ewram + 0x160AC)) +#define ewram160BC ((u16 *)(ewram + 0x160BC)) // hp +#define ewram160C8 (ewram[0x160C8]) +#define ewram160C9 (ewram[0x160C9]) +#define ewram160CB (ewram[0x160CB]) +#define ewram160CC ((u8 *)(ewram + 0x160CC)) +#define ewram160E6 (ewram[0x160E6]) +#define ewram160E8 ((u8 *)(ewram + 0x160E8)) +#define ewram160F0 ((u8 *)(ewram + 0x160F0)) +#define ewram160F9 (ewram[0x160F9]) +#define ewram16100 ((u8 *)(ewram + 0x16100)) +#define ewram16108 ((u8 *)(ewram + 0x16108)) +#define ewram16110 (ewram[0x16110]) +#define ewram16111 (ewram[0x16111]) +#define ewram16113 (ewram[0x16113]) +#define ewram17100 ((u32 *)(ewram + 0x17100)) +#define ewram17130 (ewram[0x17130]) +#define ewram17160 (ewram[0x17160]) +#define ewram1D000 ((struct Pokemon *)(ewram + 0x1D000)) + +extern struct UnknownPokemonStruct2 gUnknown_02023A00[]; +extern u8 gBattleBufferB[][0x200]; +extern u8 gActiveBank; +extern u32 gBattleExecBuffer; +extern u8 gNoOfAllBanks; +extern u16 gBattlePartyID[]; +extern u8 gFightStateTracker; +extern u8 gTurnOrder[]; +extern struct UnknownStruct12 gUnknown_02024AD0[]; +extern u8 gObjectBankIDs[]; +extern u16 gCurrentMove; +extern u8 gLastUsedAbility; +extern u8 gStringBank; +extern u8 gAbsentBankFlags; +extern u8 gMultiHitCounter; +extern u8 gActionForBanks[]; +extern u16 gUnknown_02024C2C[]; +extern u16 gLastUsedMove[]; +extern u16 gMoveHitWith[]; +extern u16 gUnknown_02024C44[]; +extern u16 gUnknown_02024C4C[]; +extern u16 gLockedMove[]; +extern u8 gUnknown_02024C5C[]; +extern u16 gChosenMovesByBanks[]; +extern u32 gHitMarker; +extern u8 gUnknown_02024C70[]; +extern u16 gSideAffecting[]; +extern u8 gSideTimer[][12]; +extern u32 gStatuses3[]; +//extern u8 gDisableStructs[][0x1C]; +extern u16 gPauseCounterBattle; +extern u16 gPaydayMoney; +extern u16 gRandomTurnNumber; +extern u8 gBattleCommunication[]; +extern u8 gUnknown_02024D1F[]; // I don't actually know what type this is. +extern u8 gBattleOutcome; +extern struct UnknownStruct13 gProtectStructs[]; +extern u8 gWishFutureKnock[]; +extern u16 gUnknown_02024DE8; +extern u8 gActionSelectionCursor[]; +extern u8 gMoveSelectionCursor[]; +extern u8 gUnknown_02038470[]; +extern u16 gUnknown_030041B0; +extern u16 gUnknown_030041B4; +extern u16 gUnknown_030041B8; +extern struct Window gUnknown_030041D0; +extern u16 gUnknown_03004200; +extern struct Window gUnknown_03004210; +extern u16 gUnknown_03004244; +extern struct Window gUnknown_03004250; +extern u16 gUnknown_03004240; +extern u16 gUnknown_03004280; +extern u32 gUnknown_03004284; +extern u16 gUnknown_03004288; +extern u16 gUnknown_030042A0; +extern u16 gUnknown_030042A4; +extern u16 gUnknown_030042C0; +extern u16 gUnknown_030042C4; +extern MainCallback gPreBattleCallback1; +extern void (*gBattleMainFunc)(void); +extern struct Struct30042E0 gBattleResults; +extern u8 gLeveledUpInBattle; +extern void (*gBattleBankFunc[])(void); +extern u8 gHealthboxIDs[]; +extern struct UnknownStruct6 gUnknown_03004DE0; +//extern u16 gUnknown_03004DE0[][0xA0]; // possibly? +extern u16 gBattleTypeFlags; +extern s8 gBattleTerrain; // I'm not sure if this is supposed to be s8 or u8. Regardless, it must have the same type as the return value of GetBattleTerrain. +extern u8 gReservedSpritePaletteCount; +extern u16 gTrainerBattleOpponent; +extern struct BattleEnigmaBerry gEnigmaBerries[]; +extern u16 gBlockRecvBuffer[MAX_LINK_PLAYERS][BLOCK_BUFFER_SIZE / 2]; +extern u8 gBattleMonForms[]; +extern u8 gBankAttacker; +extern u8 gBankTarget; +extern u16 gBattleWeather; +extern u32 gBattleMoveDamage; +extern struct BattlePokemon gBattleMons[]; +extern u8 gBattleMoveFlags; + + +void sub_800E7C4(void) +{ + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + sub_800B858(); + SetMainCallback2(sub_800F104); + gBattleCommunication[0] = 0; + } + else + { + InitBattle(); + } +} + +void InitBattle(void) +{ + s32 i; + + SetHBlankCallback(NULL); + SetVBlankCallback(NULL); + + CpuFill32(0, (void *)VRAM, VRAM_SIZE); + + REG_MOSAIC = 0; + REG_WIN0H = 0xF0; + REG_WIN0V = 0x5051; + REG_WININ = 0; + REG_WINOUT = 0; + gUnknown_030042C4 = 0xF0; + gUnknown_03004240 = 0x5051; + dp12_8087EA4(); + + for (i = 0; i < 80; i++) + { + gUnknown_03004DE0.unk0[i] = 0xF0; + gUnknown_03004DE0.unk780[i] = 0xF0; + } + for (i = 80; i < 160; i++) + { + asm(""::"r"(i)); // Needed to stop the compiler from optimizing out the loop counter + gUnknown_03004DE0.unk0[i] = 0xFF10; + gUnknown_03004DE0.unk780[i] = 0xFF10; + } + sub_80895F8(gUnknown_081F9674.unk0, gUnknown_081F9674.unk4, gUnknown_081F9674.unk8); + SetUpWindowConfig(&gWindowConfig_81E6C58); + ResetPaletteFade(); + gUnknown_030042A4 = 0; + gUnknown_030042A0 = 0; + gUnknown_030042C0 = 0; + gUnknown_030041B4 = 0; + gUnknown_03004288 = 0; + gUnknown_03004280 = 0; + gUnknown_030041B0 = 0; + gUnknown_030041B8 = 0; + gBattleTerrain = GetBattleTerrain(); + InitWindowFromConfig(&gUnknown_03004210, &gWindowConfig_81E6C58); + InitWindowFromConfig(&gUnknown_030041D0, &gWindowConfig_81E71D0); + InitWindowFromConfig(&gUnknown_03004250, &gWindowConfig_81E71EC); + sub_800D6D4(); + sub_800DAB8(); + ResetSpriteData(); + ResetTasks(); + sub_800E23C(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 4; + SetVBlankCallback(sub_800FCFC); + setup_poochyena_battle(); + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + SetMainCallback2(sub_800F298); + else + SetMainCallback2(sub_800EC9C); + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) + { + CreateNPCTrainerParty(gEnemyParty, gTrainerBattleOpponent); + SetWildMonHeldItem(); + } + gMain.inBattle = TRUE; + for (i = 0; i < 6; i++) + AdjustFriendship(&gPlayerParty[i], 3); + gBattleCommunication[0] = 0; +} + +void sub_800E9EC(void) +{ + u16 r6 = 0; + u16 species; + u16 hp; + u32 status; + s32 i; + + for (i = 0; i < 6; i++) + { + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + hp = GetMonData(&gPlayerParty[i], MON_DATA_HP); + status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); + + if (species == 0) + continue; + if (species != SPECIES_EGG && hp != 0 && status == 0) + r6 |= 1 << i * 2; + + if (species == 0) + continue; + if (hp != 0 && (species == SPECIES_EGG || status != 0)) + r6 |= 2 << i * 2; + + if (species == 0) + continue; + if (species != SPECIES_EGG && hp == 0) + r6 |= 3 << i * 2; + } + ewram0.unk2 = r6; + ewram0.unk3 = r6 >> 8; +} + +void sub_800EAAC(void) +{ + s32 i; + struct UnknownStruct8 *_ewram4 = &ewram4; + + for (i = 0; i < 7; i++) + _ewram4->unk0[i] = gSaveBlock1.enigmaBerry.berry.name[i]; + for (i = 0; i < 18; i++) + _ewram4->unk8[i] = gSaveBlock1.enigmaBerry.itemEffect[i]; + _ewram4->unk7 = gSaveBlock1.enigmaBerry.holdEffect; + _ewram4->unk1A = gSaveBlock1.enigmaBerry.holdEffectParam; +} + +void sub_800EB08(void) +{ + s32 i; + s32 j; + + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) + { + for (i = 0; i < 7; i++) + { + gEnigmaBerries[0].name[i] = gSaveBlock1.enigmaBerry.berry.name[i]; + gEnigmaBerries[2].name[i] = gSaveBlock1.enigmaBerry.berry.name[i]; + } + for (i = 0; i < 18; i++) + { + gEnigmaBerries[0].itemEffect[i] = gSaveBlock1.enigmaBerry.itemEffect[i]; + gEnigmaBerries[2].itemEffect[i] = gSaveBlock1.enigmaBerry.itemEffect[i]; + } + gEnigmaBerries[0].holdEffect = gSaveBlock1.enigmaBerry.holdEffect; + gEnigmaBerries[2].holdEffect = gSaveBlock1.enigmaBerry.holdEffect; + gEnigmaBerries[0].holdEffectParam = gSaveBlock1.enigmaBerry.holdEffectParam; + gEnigmaBerries[2].holdEffectParam = gSaveBlock1.enigmaBerry.holdEffectParam; + } + else + { + s32 numPlayers; + struct BattleEnigmaBerry *src; + u8 r4; + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + numPlayers = 4; + else + numPlayers = 2; + for (i = 0; i < numPlayers; i++) + { + src = (struct BattleEnigmaBerry *)(gBlockRecvBuffer[i] + 2); + r4 = gLinkPlayers[i].lp_field_18; + + for (j = 0; j < 7; j++) + gEnigmaBerries[r4].name[j] = src->name[j]; + for (j = 0; j < 18; j++) + gEnigmaBerries[r4].itemEffect[j] = src->itemEffect[j]; + gEnigmaBerries[r4].holdEffect = src->holdEffect; + gEnigmaBerries[r4].holdEffectParam = src->holdEffectParam; + } + } +} + +void shedinja_something(struct Pokemon *pkmn) +{ + u8 nickname[POKEMON_NAME_LENGTH + 1]; + u8 language = 1; + + if (GetMonData(pkmn, MON_DATA_SPECIES) == SPECIES_SHEDINJA + && GetMonData(pkmn, MON_DATA_LANGUAGE) != language) + { + GetMonData(pkmn, MON_DATA_NICKNAME, nickname); + if (StringCompareWithoutExtCtrlCodes(nickname, gUnknown_081F96C8) == 0) + SetMonData(pkmn, MON_DATA_LANGUAGE, &language); + } +} + +void sub_800EC9C(void) +{ + u8 playerId; + u8 enemyId; + + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + playerId = GetMultiplayerId(); + ewram160CB = playerId; + enemyId = playerId ^ 1; + + switch (gBattleCommunication[0]) + { + case 0: + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + if (gReceivedRemoteLinkPlayers != 0 && sub_8007ECC()) + { + ewram0.unk0 = 1; + ewram0.unk1 = 1; + sub_800E9EC(); + sub_800EAAC(); + SendBlock(bitmask_all_link_players_but_self(), &ewram0, 32); + gBattleCommunication[0] = 1; + } + } + else + { + gBattleTypeFlags |= BATTLE_TYPE_WILD; + gBattleCommunication[0] = 8; + sub_800EB08(); + } + break; + case 1: + if ((GetBlockReceivedStatus() & 3) == 3) + { + s32 id; + u8 taskId; + + ResetBlockReceivedFlags(); + id = 0; + if (gBlockRecvBuffer[0][0] == 0x100) + { + if (playerId == 0) + gBattleTypeFlags |= 12; + else + gBattleTypeFlags |= 8; + id++; + } + if (id == 0) + { + if (gBlockRecvBuffer[0][0] == gBlockRecvBuffer[1][0]) + { + if (playerId == 0) + gBattleTypeFlags |= 12; + else + gBattleTypeFlags |= 8; + id++; + } + if (id == 0) + { + while (id < 2) + { + if (gBlockRecvBuffer[id][0] > 0x0101 && id != playerId) + break; + id++; + } + if (id == 2) + gBattleTypeFlags |= 12; + else + gBattleTypeFlags |= 8; + } + } + sub_800EB08(); + taskId = CreateTask(sub_800DE30, 0); + gTasks[taskId].data[1] = 0x10E; + gTasks[taskId].data[2] = 0x5A; + gTasks[taskId].data[5] = 0; + gTasks[taskId].data[3] = ewram0.unk2 | (ewram0.unk3 << 8); + gTasks[taskId].data[4] = gBlockRecvBuffer[enemyId][1]; + gBattleCommunication[0]++; + } + break; + case 2: + if (sub_8007ECC()) + { + SendBlock(bitmask_all_link_players_but_self(), gPlayerParty, sizeof(*gPlayerParty) * 2); + gBattleCommunication[0]++; + } + break; + case 3: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + memcpy(gEnemyParty, gBlockRecvBuffer[enemyId], sizeof(*gEnemyParty) * 2); + gBattleCommunication[0]++; + } + break; + case 4: + if (sub_8007ECC()) + { + SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 2, sizeof(*gPlayerParty) * 2); + gBattleCommunication[0]++; + } + break; + case 5: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + memcpy(gEnemyParty + 2, gBlockRecvBuffer[enemyId], sizeof(*gEnemyParty) * 2); + gBattleCommunication[0]++; + } + break; + case 6: + if (sub_8007ECC()) + { + SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 4, sizeof(*gPlayerParty) * 2); + gBattleCommunication[0]++; + } + break; + case 7: + if ((GetBlockReceivedStatus() & 3) == 3) + { + ResetBlockReceivedFlags(); + memcpy(gEnemyParty + 4, gBlockRecvBuffer[enemyId], sizeof(*gEnemyParty) * 2); + shedinja_something(&gEnemyParty[0]); + shedinja_something(&gEnemyParty[1]); + shedinja_something(&gEnemyParty[2]); + shedinja_something(&gEnemyParty[3]); + shedinja_something(&gEnemyParty[4]); + shedinja_something(&gEnemyParty[5]); + gBattleCommunication[0]++; + } + break; + case 8: + sub_800B950(); + gBattleCommunication[0]++; + gBattleCommunication[1] = 0; + gBattleCommunication[2] = 0; + break; + case 9: + if (battle_load_something(gUnknown_02024D1F, gUnknown_02024D1F + 1) != 0) + { + gPreBattleCallback1 = gMain.callback1; + gMain.callback1 = sub_8010824; + SetMainCallback2(sub_800F808); + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + gTrainerBattleOpponent = 0x800; + gBattleTypeFlags |= BATTLE_TYPE_20; + } + } + break; + } +} + +void sub_800F02C(void) +{ + s32 i; + + for (i = 0; i < 3; i++) + { + u8 *nickname = gUnknown_02023A00[i].nickname; + + gUnknown_02023A00[i].species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES); + gUnknown_02023A00[i].heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + GetMonData(&gPlayerParty[i], MON_DATA_NICKNAME, nickname); + gUnknown_02023A00[i].level = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); + gUnknown_02023A00[i].hp = GetMonData(&gPlayerParty[i], MON_DATA_HP); + gUnknown_02023A00[i].maxhp = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP); + gUnknown_02023A00[i].status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); + gUnknown_02023A00[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); + gUnknown_02023A00[i].gender = GetMonGender(&gPlayerParty[i]); + StripExtCtrlCodes(nickname); + gUnknown_02023A00[i].language = GetMonData(&gPlayerParty[i], MON_DATA_LANGUAGE); + if (gUnknown_02023A00[i].language != 1) + PadNameString(nickname, 0); + } + memcpy(ewram, gUnknown_02023A00, 0x60); +} + +void sub_800F104(void) +{ + u8 playerId; + MainCallback *pSavedCallback; + u16 *pSavedBattleTypeFlags; + + playerId = GetMultiplayerId(); + ewram160CB = playerId; + // Seriously, Game Freak? + pSavedCallback = (MainCallback *)(ewram + 0x160C4); + pSavedBattleTypeFlags = (u16 *)(ewram + 0x160C2); + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + + switch (gBattleCommunication[0]) + { + case 0: + if (gReceivedRemoteLinkPlayers != 0 && sub_8007ECC()) + { + sub_800F02C(); + SendBlock(bitmask_all_link_players_but_self(), ewram, 0x60); + gBattleCommunication[0]++; + } + break; + case 1: + if ((GetBlockReceivedStatus() & 0xF) == 0xF) + { + s32 i; + + ResetBlockReceivedFlags(); + for (i = 0; i < 4; i++) + { + if (i != playerId) + { + if ((!(gLinkPlayers[i].lp_field_18 & 1) && !(gLinkPlayers[playerId].lp_field_18 & 1)) + || ((gLinkPlayers[i].lp_field_18 & 1) && (gLinkPlayers[playerId].lp_field_18 & 1))) + memcpy(gUnknown_02023A00, gBlockRecvBuffer[i], 0x60); + } + } + gBattleCommunication[0]++; + *pSavedCallback = gMain.savedCallback; + *pSavedBattleTypeFlags = gBattleTypeFlags; + gMain.savedCallback = sub_800F104; + OpenPartyMenu(5, 0); + } + break; + case 2: + if (!gPaletteFade.active) + { + gBattleCommunication[0] = 3; + sub_800832C(); + } + break; + case 3: + if (gReceivedRemoteLinkPlayers == 0) + { + gBattleTypeFlags = *pSavedBattleTypeFlags; + gMain.savedCallback = *pSavedCallback; + SetMainCallback2(InitBattle); + } + break; + } +} + +void sub_800F298(void) +{ + u8 playerId; + s32 id; + + playerId = GetMultiplayerId(); + ewram160CB = playerId; + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + switch (gBattleCommunication[0]) + { + case 0: + if (gReceivedRemoteLinkPlayers != 0 && sub_8007ECC()) + { + ewram0.unk0 = 1; + ewram0.unk1 = 1; + sub_800E9EC(); + sub_800EAAC(); + SendBlock(bitmask_all_link_players_but_self(), ewram, 0x20); + gBattleCommunication[0]++; + } + break; + case 1: + if ((GetBlockReceivedStatus() & 0xF) == 0xF) + { + u8 taskId; + + ResetBlockReceivedFlags(); + id = 0; + if (gBlockRecvBuffer[0][0] == 0x100) + { + if (playerId == 0) + gBattleTypeFlags |= 12; + else + gBattleTypeFlags |= 8; + id++; + } + if (id == 0) + { + s32 i; + + for (i = 0; i < MAX_LINK_PLAYERS; i++) + { + if (gBlockRecvBuffer[0][0] != gBlockRecvBuffer[i][0]) + break; + } + if (i == MAX_LINK_PLAYERS) + { + if (playerId == 0) + gBattleTypeFlags |= 12; + else + gBattleTypeFlags |= 8; + id++; + } + if (id == 0) + { + while (id < MAX_LINK_PLAYERS) + { + if (gBlockRecvBuffer[id][0] == 0x0101 && id != playerId) + if (id < playerId) + break; + if (gBlockRecvBuffer[id][0] > 0x0101 && id != playerId) + break; + id++; + } + if (id == MAX_LINK_PLAYERS) + gBattleTypeFlags |= 12; + else + gBattleTypeFlags |= 8; + } + } + sub_800EB08(); + memcpy(ewram1D000, gPlayerParty, sizeof(struct Pokemon) * 3); + taskId = CreateTask(sub_800DE30, 0); + gTasks[taskId].data[1] = 0x10E; + gTasks[taskId].data[2] = 0x5A; + gTasks[taskId].data[5] = 0; + gTasks[taskId].data[3] = 0; + gTasks[taskId].data[4] = 0; + for (id = 0; id < MAX_LINK_PLAYERS; id++) + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + gTasks[taskId].data[3] |= gBlockRecvBuffer[id][1] & 0x3F; + break; + case 1: + gTasks[taskId].data[4] |= gBlockRecvBuffer[id][1] & 0x3F; + break; + case 2: + gTasks[taskId].data[3] |= (gBlockRecvBuffer[id][1] & 0x3F) << 6; + break; + case 3: + gTasks[taskId].data[4] |= (gBlockRecvBuffer[id][1] & 0x3F) << 6; + break; + } + } + ZeroPlayerPartyMons(); + ZeroEnemyPartyMons(); + gBattleCommunication[0]++; + goto step_2; + } + break; + case 2: + step_2: + if (sub_8007ECC()) + { + SendBlock(bitmask_all_link_players_but_self(), ewram1D000, sizeof(struct Pokemon) * 2); + gBattleCommunication[0]++; + } + break; + case 3: + if ((GetBlockReceivedStatus() & 0xF) == 0xF) + { + ResetBlockReceivedFlags(); + for (id = 0; id < MAX_LINK_PLAYERS; id++) + { + if (id == playerId) + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gPlayerParty, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + case 1: + case 2: + memcpy(gPlayerParty + 3, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + } + } + else + { + if ((!(gLinkPlayers[id].lp_field_18 & 1) && !(gLinkPlayers[playerId].lp_field_18 & 1)) + || ((gLinkPlayers[id].lp_field_18 & 1) && (gLinkPlayers[playerId].lp_field_18 & 1))) + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gPlayerParty, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + case 1: + case 2: + memcpy(gPlayerParty + 3, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + } + } + else + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gEnemyParty, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + case 1: + case 2: + memcpy(gEnemyParty + 3, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + break; + } + } + } + } + gBattleCommunication[0]++; + } + break; + case 4: + if (sub_8007ECC()) + { + SendBlock(bitmask_all_link_players_but_self(), ewram1D000 + 2, sizeof(struct Pokemon)); + gBattleCommunication[0]++; + } + break; + case 5: + if ((GetBlockReceivedStatus() & 0xF) == 0xF) + { + ResetBlockReceivedFlags(); + for (id = 0; id < MAX_LINK_PLAYERS; id++) + { + if (id == playerId) + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gPlayerParty + 2, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + case 1: + case 2: + memcpy(gPlayerParty + 5, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + } + } + else + { + if ((!(gLinkPlayers[id].lp_field_18 & 1) && !(gLinkPlayers[playerId].lp_field_18 & 1)) + || ((gLinkPlayers[id].lp_field_18 & 1) && (gLinkPlayers[playerId].lp_field_18 & 1))) + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gPlayerParty + 2, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + case 1: + case 2: + memcpy(gPlayerParty + 5, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + } + } + else + { + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + memcpy(gEnemyParty + 2, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + case 1: + case 2: + memcpy(gEnemyParty + 5, gBlockRecvBuffer[id], sizeof(struct Pokemon)); + break; + } + } + } + } + + shedinja_something(&gPlayerParty[0]); + shedinja_something(&gPlayerParty[1]); + shedinja_something(&gPlayerParty[2]); + shedinja_something(&gPlayerParty[3]); + shedinja_something(&gPlayerParty[4]); + shedinja_something(&gPlayerParty[5]); + + shedinja_something(&gEnemyParty[0]); + shedinja_something(&gEnemyParty[1]); + shedinja_something(&gEnemyParty[2]); + shedinja_something(&gEnemyParty[3]); + shedinja_something(&gEnemyParty[4]); + shedinja_something(&gEnemyParty[5]); + + gBattleCommunication[0]++; + } + break; + case 6: + sub_800B950(); + gBattleCommunication[0]++; + gBattleCommunication[1] = 0; + gBattleCommunication[2] = 0; + break; + case 7: + if (battle_load_something(gUnknown_02024D1F, gUnknown_02024D1F + 1) != 0) + { + gPreBattleCallback1 = gMain.callback1; + gMain.callback1 = sub_8010824; + SetMainCallback2(sub_800F808); + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + gTrainerBattleOpponent = 0x800; + gBattleTypeFlags |= BATTLE_TYPE_20; + } + } + break; + } +} + +void sub_800F808(void) +{ + AnimateSprites(); + BuildOamBuffer(); + sub_800374C(&gUnknown_03004210); + UpdatePaletteFade(); + RunTasks(); +} + +void sub_800F828(struct Sprite *sprite) +{ + sprite->data0 = 0; + sprite->callback = sub_800F838; +} + +void sub_800F838(struct Sprite *sprite) +{ + u16 *arr = (u16 *)ewram; + + switch (sprite->data0) + { + case 0: + sprite->data0++; + sprite->data1 = 0; + sprite->data2 = 0x281; + sprite->data3 = 0; + sprite->data4 = 1; + // fall through + case 1: + sprite->data4--; + if (sprite->data4 == 0) + { + s32 i; + s32 r2; + s32 r0; + + sprite->data4 = 2; + r2 = sprite->data1 + sprite->data3 * 32; + r0 = sprite->data2 - sprite->data3 * 32; + for (i = 0; i < 29; i += 2) + { + arr[r2 + i] = 0x3D; + arr[r0 + i] = 0x3D; + } + sprite->data3++; + if (sprite->data3 == 21) + { + sprite->data0++; + sprite->data1 = 32; + } + } + break; + case 2: + sprite->data1--; + if (sprite->data1 == 20) + SetMainCallback2(sub_800E7C4); + break; + } +} + +u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum) +{ + u32 nameHash = 0; + s32 i; + + if (trainerNum == 0x400) + return 0; + + if ((gBattleTypeFlags & 0x908) == 8) + { + ZeroEnemyPartyMons(); + for (i = 0; i < gTrainers[trainerNum].partySize; i++) + { + u32 personalityValue; + s32 j; + u8 fixedIV; + + if (gTrainers[trainerNum].doubleBattle == TRUE) + personalityValue = 0x80; + else if (gTrainers[trainerNum].encounterMusic_gender & 0x80) + personalityValue = 0x78; + else + personalityValue = 0x88; + + for (j = 0; gTrainers[trainerNum].trainerName[j] != 0xFF; j++) + nameHash += gTrainers[trainerNum].trainerName[j]; + + switch (gTrainers[trainerNum].partyFlags) + { + case 0: + { + struct TrainerPartyMember0 *partyData = gTrainers[trainerNum].party; + + for (j = 0; gSpeciesNames[partyData[i].species][j] != 0xFF; j++) + nameHash += gSpeciesNames[partyData[i].species][j]; + personalityValue += nameHash << 8; + fixedIV = partyData[i].iv * 31 / 255; + CreateMon(&party[i], partyData[i].species, partyData[i].level, fixedIV, TRUE, personalityValue, 2, 0); + break; + } + case 1: + { + struct TrainerPartyMember1 *partyData = gTrainers[trainerNum].party; + + for (j = 0; gSpeciesNames[partyData[i].species][j] != 0xFF; j++) + nameHash += gSpeciesNames[partyData[i].species][j]; + personalityValue += nameHash << 8; + fixedIV = partyData[i].iv * 31 / 255; + CreateMon(&party[i], partyData[i].species, partyData[i].level, fixedIV, TRUE, personalityValue, 2, 0); + + for (j = 0; j < 4; j++) + { + SetMonData(&party[i], MON_DATA_MOVE1 + j, (u8 *)&partyData[i].moves[j]); + SetMonData(&party[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp); + } + break; + } + case 2: + { + struct TrainerPartyMember2 *partyData = gTrainers[trainerNum].party; + + for (j = 0; gSpeciesNames[partyData[i].species][j] != 0xFF; j++) + nameHash += gSpeciesNames[partyData[i].species][j]; + personalityValue += nameHash << 8; + fixedIV = partyData[i].iv * 31 / 255; + CreateMon(&party[i], partyData[i].species, partyData[i].level, fixedIV, TRUE, personalityValue, 2, 0); + + SetMonData(&party[i], MON_DATA_HELD_ITEM, (u8 *)&partyData[i].heldItem); + break; + } + case 3: + { + struct TrainerPartyMember3 *partyData = gTrainers[trainerNum].party; + + for (j = 0; gSpeciesNames[partyData[i].species][j] != 0xFF; j++) + nameHash += gSpeciesNames[partyData[i].species][j]; + personalityValue += nameHash << 8; + fixedIV = partyData[i].iv * 31 / 255; + CreateMon(&party[i], partyData[i].species, partyData[i].level, fixedIV, TRUE, personalityValue, 2, 0); + + SetMonData(&party[i], MON_DATA_HELD_ITEM, (u8 *)&partyData[i].heldItem); + for (j = 0; j < 4; j++) + { + SetMonData(&party[i], MON_DATA_MOVE1 + j, (u8 *)&partyData[i].moves[j]); + SetMonData(&party[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp); + } + break; + } + } + } + gBattleTypeFlags |= gTrainers[trainerNum].doubleBattle; + } + return gTrainers[trainerNum].partySize; +} + +void sub_800FCD4(void) +{ + if (REG_VCOUNT < 0xA0 && REG_VCOUNT >= 0x6F ) + REG_BG0CNT = 0x9800; +} + +void sub_800FCFC(void) +{ + Random(); // unused return value + REG_BG0HOFS = gUnknown_030042A4; + REG_BG0VOFS = gUnknown_030042A0; + REG_BG1HOFS = gUnknown_030042C0; + REG_BG1VOFS = gUnknown_030041B4; + REG_BG2HOFS = gUnknown_03004288; + REG_BG2VOFS = gUnknown_03004280; + REG_BG3HOFS = gUnknown_030041B0; + REG_BG3VOFS = gUnknown_030041B8; + REG_WIN0H = gUnknown_030042C4; + REG_WIN0V = gUnknown_03004240; + REG_WIN1H = gUnknown_03004200; + REG_WIN1V = gUnknown_03004244; + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); + sub_8089668(); +} + +void nullsub_36(struct Sprite *sprite) +{ +} + +void sub_800FDB0(struct Sprite *sprite) +{ + if (sprite->data0 != 0) + sprite->pos1.x = sprite->data1 + ((sprite->data2 & 0xFF00) >> 8); + else + sprite->pos1.x = sprite->data1 - ((sprite->data2 & 0xFF00) >> 8); + sprite->data2 += 0x180; + if (sprite->affineAnimEnded) + { + FreeSpriteTilesByTag(0x2710); + FreeSpritePaletteByTag(0x2710); + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + } +} + +void sub_800FE20(struct Sprite *sprite) +{ + StartSpriteAffineAnim(sprite, 1); + sprite->callback = sub_800FDB0; + PlaySE(SE_BT_START); +} + +void sub_800FE40(u8 taskId) +{ + struct Pokemon *sp4 = NULL; + struct Pokemon *sp8 = NULL; + u8 r2 = ewram160CB; + u32 r7; + s32 i; + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + switch (gLinkPlayers[r2].lp_field_18) + { + case 0: + case 2: + sp4 = gPlayerParty; + sp8 = gEnemyParty; + break; + case 1: + case 3: + sp4 = gEnemyParty; + sp8 = gPlayerParty; + break; + } + } + else + { + sp4 = gPlayerParty; + sp8 = gEnemyParty; + } + + r7 = 0; + for (i = 0; i < 6; i++) + { + u16 species = GetMonData(&sp4[i], MON_DATA_SPECIES2); + u16 hp = GetMonData(&sp4[i], MON_DATA_HP); + u32 status = GetMonData(&sp4[i], MON_DATA_STATUS); + + if (species == 0) + continue; + if (species != SPECIES_EGG && hp != 0 && status == 0) + r7 |= 1 << i * 2; + + if (species == 0) + continue; + if (hp != 0 && (species == SPECIES_EGG || status != 0)) + r7 |= 2 << i * 2; + + if (species == 0) + continue; + if (species != SPECIES_EGG && hp == 0) + r7 |= 3 << i * 2; + } + gTasks[taskId].data[3] = r7; + + r7 = 0; + for (i = 0; i < 6; i++) + { + u16 species = GetMonData(&sp8[i], MON_DATA_SPECIES2); + u16 hp = GetMonData(&sp8[i], MON_DATA_HP); + u32 status = GetMonData(&sp8[i], MON_DATA_STATUS); + + if (species == 0) + continue; + if (species != SPECIES_EGG && hp != 0 && status == 0) + r7 |= 1 << i * 2; + + if (species == 0) + continue; + if (hp != 0 && (species == SPECIES_EGG || status != 0)) + r7 |= 2 << i * 2; + + if (species == 0) + continue; + if (species != SPECIES_EGG && hp == 0) + r7 |= 3 << i * 2; + } + gTasks[taskId].data[4] = r7; +} + +void c2_8011A1C(void) +{ + s32 i; + u8 taskId; + + SetHBlankCallback(NULL); + SetVBlankCallback(NULL); + CpuFill32(0, (void *)VRAM, VRAM_SIZE); + REG_MOSAIC = 0; + REG_WIN0H = 0xF0; + REG_WIN0V = 0x5051; + REG_WININ = 0; + REG_WINOUT = 0; + gUnknown_030042C4 = 0xF0; + gUnknown_03004240 = 0x5051; + dp12_8087EA4(); + + for (i = 0; i < 80; i++) + { + gUnknown_03004DE0.unk0[i] = 0xF0; + gUnknown_03004DE0.unk780[i] = 0xF0; + } + for (i = 80; i < 160; i++) + { + asm(""::"r"(i)); // Needed to stop the compiler from optimizing out the loop counter + gUnknown_03004DE0.unk0[i] = 0xFF10; + gUnknown_03004DE0.unk780[i] = 0xFF10; + } + SetUpWindowConfig(&gWindowConfig_81E6C58); + ResetPaletteFade(); + gUnknown_030042A4 = 0; + gUnknown_030042A0 = 0; + gUnknown_030042C0 = 0; + gUnknown_030041B4 = 0; + gUnknown_03004288 = 0; + gUnknown_03004280 = 0; + gUnknown_030041B0 = 0; + gUnknown_030041B8 = 0; + + InitWindowFromConfig(&gUnknown_03004210, &gWindowConfig_81E6C58); + InitWindowFromConfig(&gUnknown_030041D0, &gWindowConfig_81E71D0); + InitWindowFromConfig(&gUnknown_03004250, &gWindowConfig_81E71EC); + sub_800D6D4(); + LoadCompressedPalette(gUnknown_08D004E0, 0, 64); + sub_800D74C(); + ResetSpriteData(); + ResetTasks(); + sub_800E23C(); + REG_WINOUT = 0x37; + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 4; + SetVBlankCallback(sub_800FCFC); + taskId = CreateTask(sub_800DE30, 0); + gTasks[taskId].data[1] = 0x10E; + gTasks[taskId].data[2] = 0x5A; + gTasks[taskId].data[5] = 1; + sub_800FE40(taskId); + SetMainCallback2(sub_80101B8); + gBattleCommunication[0] = 0; +} + +void sub_80101B8(void) +{ + c2_081284E0(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); + RunTasks(); +} + +void c2_081284E0(void) +{ + switch (gBattleCommunication[0]) + { + case 0: + gBattleCommunication[1] = 0xFF; + gBattleCommunication[0]++; + break; + case 1: + gBattleCommunication[1]--; + if (gBattleCommunication[1] == 0) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gBattleCommunication[0]++; + } + break; + case 2: + if (!gPaletteFade.active) + SetMainCallback2(gMain.savedCallback); + break; + } +} + +void oac_poke_opponent(struct Sprite *sprite) +{ + sprite->callback = sub_8010278; + StartSpriteAnimIfDifferent(sprite, 0); + BeginNormalPaletteFade(0x00020000, 0, 10, 10, 0x3DEF); +} + +void sub_8010278(struct Sprite *sprite) +{ + if ((gUnknown_02024DE8 & 1) == 0) + { + sprite->pos2.x += 2; + if (sprite->pos2.x == 0) + { + sprite->callback = sub_80102AC; + PlayCry1(sprite->data2, 25); + } + } +} + +void sub_80102AC(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + sub_804777C(sprite->data0); + sub_8043DFC(gHealthboxIDs[sprite->data0]); + sprite->callback = nullsub_37; + StartSpriteAnimIfDifferent(sprite, 0); + BeginNormalPaletteFade(0x00020000, 0, 10, 0, 0x3DEF); + } +} + +void nullsub_37(struct Sprite *sprite) +{ +} + +void unref_sub_801030C(struct Sprite *sprite) +{ + sprite->data3 = 6; + sprite->data4 = 1; + sprite->callback = sub_8010320; +} + +void sub_8010320(struct Sprite *sprite) +{ + sprite->data4--; + if (sprite->data4 == 0) + { + sprite->data4 = 8; + sprite->invisible ^= 1; + sprite->data3--; + if (sprite->data3 == 0) + { + sprite->invisible = FALSE; + sprite->callback = nullsub_37; + gUnknown_03004284 = 0; + } + } +} + +void sub_8010384(struct Sprite *sprite) +{ + u8 r6 = sprite->data0; + u16 species; + u8 yOffset; + + if (ewram17800[r6].unk2 != 0) + species = ewram17800[r6].unk2; + else + species = sprite->data2; + + GetMonData(&gEnemyParty[gBattlePartyID[r6]], MON_DATA_PERSONALITY); // Unused return value + + if (species == SPECIES_UNOWN) + { + u32 personalityValue = GetMonData(&gEnemyParty[gBattlePartyID[r6]], MON_DATA_PERSONALITY); + u16 unownForm = ((((personalityValue & 0x3000000) >> 18) | ((personalityValue & 0x30000) >> 12) | ((personalityValue & 0x300) >> 6) | (personalityValue & 3)) % 0x1C); + u16 unownSpecies; + + if (unownForm == 0) + unownSpecies = SPECIES_UNOWN; // Use the A Unown form + else + unownSpecies = NUM_SPECIES + unownForm; // Use one of the other Unown letters + + yOffset = gMonFrontPicCoords[unownSpecies].y_offset; + } + else if (species == SPECIES_CASTFORM) + { + yOffset = gCastformFrontSpriteCoords[gBattleMonForms[r6]].y_offset; + } + else if (species > NUM_SPECIES) + { + yOffset = gMonFrontPicCoords[SPECIES_NONE].y_offset; + } + else + { + yOffset = gMonFrontPicCoords[species].y_offset; + } + + sprite->data3 = 8 - yOffset / 8; + sprite->data4 = 1; + sprite->callback = sub_8010494; +} + +void sub_8010494(struct Sprite *sprite) +{ + s32 i; + + sprite->data4--; + if (sprite->data4 == 0) + { + sprite->data4 = 2; + sprite->pos2.y += 8; + sprite->data3--; + if (sprite->data3 < 0) + { + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + } + else + { + u8 *dst = (u8 *)gUnknown_081FAF4C[GetBankIdentity(sprite->data0)] + (gBattleMonForms[sprite->data0] << 11) + (sprite->data3 << 8); + + for (i = 0; i < 0x100; i++) + *(dst++) = 0; + StartSpriteAnim(sprite, gBattleMonForms[sprite->data0]); + } + } +} + +void sub_8010520(struct Sprite *sprite) +{ + sprite->data3 = 8; + sprite->data4 = sprite->invisible; + sprite->callback = sub_801053C; +} + +void sub_801053C(struct Sprite *sprite) +{ + sprite->data3--; + if (sprite->data3 == 0) + { + sprite->invisible ^= 1; + sprite->data3 = 8; + } +} + +void sub_8010574(struct Sprite *sprite) +{ + sprite->invisible = sprite->data4; + sprite->data4 = FALSE; + sprite->callback = nullsub_37; +} + +void sub_80105A0(struct Sprite *sprite) +{ + sprite->callback = oac_poke_ally_; +} + +void oac_poke_ally_(struct Sprite *sprite) +{ + if ((gUnknown_02024DE8 & 1) == 0) + { + sprite->pos2.x -= 2; + if (sprite->pos2.x == 0) + { + sprite->callback = nullsub_86; + sprite->data1 = 0; + } + } +} + +void sub_80105DC(struct Sprite *sprite) +{ + sprite->callback = nullsub_86; +} + +void nullsub_86(struct Sprite *sprite) +{ +} + +void sub_80105EC(struct Sprite *sprite) +{ + if ((gUnknown_02024DE8 & 1) == 0) + { + sprite->pos2.x += sprite->data1; + sprite->pos2.y += sprite->data2; + } +} + +void dp11b_obj_instanciate(u8 a, u8 b, s8 c, s8 d) +{ + u8 spriteId; + u8 r7; + + if (b) + { + if (ewram17810[a].unk0_1) + return; + } + else + { + if (ewram17810[a].unk0_2) + return; + } + + spriteId = CreateInvisibleSpriteWithCallback(objc_dp11b_pingpong); + if (b == TRUE) + { + r7 = gHealthboxIDs[a]; + ewram17810[a].unk2 = spriteId; + ewram17810[a].unk0_1 = 1; + gSprites[spriteId].data0 = 0x80; + } + else + { + r7 = gObjectBankIDs[a]; + ewram17810[a].unk3 = spriteId; + ewram17810[a].unk0_2 = 1; + gSprites[spriteId].data0 = 0xC0; + } + gSprites[spriteId].data1 = c; + gSprites[spriteId].data2 = d; + gSprites[spriteId].data3 = r7; + gSprites[spriteId].data4 = b; + gSprites[r7].pos2.x = 0; + gSprites[r7].pos2.y = 0; +} + +void dp11b_obj_free(u8 a, u8 b) +{ + u8 r4; + + if (b == TRUE) + { + if (!ewram17810[a].unk0_1) + return; + r4 = gSprites[ewram17810[a].unk2].data3; + DestroySprite(&gSprites[ewram17810[a].unk2]); + ewram17810[a].unk0_1 = 0; + } + else + { + if (!ewram17810[a].unk0_2) + return; + r4 = gSprites[ewram17810[a].unk3].data3; + DestroySprite(&gSprites[ewram17810[a].unk3]); + ewram17810[a].unk0_2 = 0; + } + gSprites[r4].pos2.x = 0; + gSprites[r4].pos2.y = 0; +} + +void objc_dp11b_pingpong(struct Sprite *sprite) +{ + u8 spriteId = sprite->data3; + s32 var; + + if (sprite->data4 == 1) + var = sprite->data0; + else + var = sprite->data0; + + gSprites[spriteId].pos2.y = Sin(var, sprite->data2) + sprite->data2; + sprite->data0 = (sprite->data0 + sprite->data1) & 0xFF; +} + +void nullsub_41(void) +{ +} + +void sub_8010800(void) +{ + sub_8010874(); + gBattleCommunication[1] = 0; + gBattleMainFunc = bc_8012FAC; +} + +void sub_8010824(void) +{ + gBattleMainFunc(); + gActiveBank = 0; + + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + gBattleBankFunc[gActiveBank](); +} + +void sub_8010874(void) +{ + s32 i; + s32 j; + u8 *r4; + + TurnValuesCleanUp(0); + SpecialStatusesClear(); + + for (i = 0; i < 4; i++) + { + gStatuses3[i] = 0; + + r4 = (u8 *)&gDisableStructs[i]; + for (j = 0; j < (u32)0x1C; j++) + r4[j] = 0; + + gDisableStructs[i].unk16 = 2; + gUnknown_02024C70[i] = 0; + gLastUsedMove[i] = 0; + gMoveHitWith[i] = 0; + gUnknown_02024C44[i] = 0; + gUnknown_02024C4C[i] = 0; + gUnknown_02024C5C[i] = 0xFF; + gLockedMove[i] = 0; + gUnknown_02024C2C[i] = 0; + ewram17100[i] = 0; + } + + for (i = 0; i < 2; i++) + { + gSideAffecting[i] = 0; + + r4 = (u8 *)&gSideTimer[i]; + for (j = 0; j < (u32)12; j++) + r4[j] = 0; + } + + gBankAttacker = 0; + gBankTarget = 0; + gBattleWeather = 0; + + r4 = (u8 *)&gWishFutureKnock; + for (i = 0; i < (u32)0x2C; i++) + r4[i] = 0; + + gHitMarker = 0; + if ((gBattleTypeFlags & 2) == 0 && gSaveBlock2.optionsBattleSceneOff == TRUE) + gHitMarker = 0x80; + ewram16084 = gSaveBlock2.optionsBattleStyle; + gMultiHitCounter = 0; + gBattleOutcome = 0; + gBattleExecBuffer = 0; + gPaydayMoney = 0; + ewram17130 = 0; + ewram17160 = 0; + for (i = 0; i < 8; i++) + gBattleCommunication[i] = 0; + gPauseCounterBattle = 0; + gBattleMoveDamage = 0; + gUnknown_02024DE8 = 0; + ewram16002 = 0; + ewram160A1 = 0; + gLeveledUpInBattle = 0; + gAbsentBankFlags = 0; + ewram16078 = 0; + ewram16086 = 0; + ewram16087 = 0; + ewram16089 = gBaseStats[GetMonData(&gEnemyParty[0], MON_DATA_SPECIES)].catchRate * 100 / 1275; + ewram16088 = 3; + ewram1601B = 0; + ewram16056 = 1; + + for (i = 0; i < 8; i++) + { + ewram[i + 0x160AC] = 0; + ewram[i + 0x160CC] = 0; + ewram[i + 0x160E8] = 0; + ewram[i + 0x160F0] = 0; + ewram[i + 0x16100] = 0; + ewram[i + 0x16108] = 0; + } + + ewram160C8 = 6; + ewram160C9 = 6; + ewram16113 = 0; + for (i = 0; i < 11; i++) + gBattleResults.unk36[i] = 0; + gBattleResults.unk13 = 0; + gBattleResults.unk0 = 0; + gBattleResults.unk1 = 0; + gBattleResults.unk2 = 0; + gBattleResults.unk3 = 0; + gBattleResults.unk4 = 0; + gBattleResults.unk5_0 = 0; + gBattleResults.unk5_1 = 0; + gBattleResults.unk20 = 0; + gBattleResults.unk22 = 0; + gBattleResults.unk24 = 0; + gBattleResults.unk6 = 0; + gBattleResults.unk26 = 0; + gBattleResults.unk28 = 0; + for (i = 0; i < 10; i++) + { + gBattleResults.unk8[i] = 0; + gBattleResults.unk14[i] = 0; + gBattleResults.unk2A[i] = 0; + } +} + +void sub_8010B88(void) +{ + struct UnkBattleStruct4 sp0 = gDisableStructs[gActiveBank]; + s32 i; + u8 *ptr; + u32 *ptr2; + + if (gBattleMoves[gCurrentMove].effect != 0x7F) + { + for (i = 0; i < 8; i++) + gBattleMons[gActiveBank].statStages[i] = 6; + for (i = 0; i < gNoOfAllBanks; i++) + { + struct UnknownStruct12 *sp20 = &gUnknown_02024AD0[i]; + + if ((sp20->unk0 & 0x04000000) && gDisableStructs[i].unk14 == gActiveBank) + sp20->unk0 &= ~0x04000000; + if ((gStatuses3[i] & 0x18) && gDisableStructs[i].unk15 == gActiveBank) + { + gStatuses3[i] &= ~0x18; + gDisableStructs[i].unk15 = 0; + } + } + } + if (gBattleMoves[gCurrentMove].effect == 0x7F) + { + gBattleMons[gActiveBank].status2 &= 0x15100007; + gStatuses3[gActiveBank] &= 0x3043F; + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (GetBankSide(gActiveBank) != GetBankSide(i) + && (gStatuses3[i] & 0x18) != 0 + && (gDisableStructs[i].unk15 == gActiveBank)) + { + gStatuses3[i] &= ~0x18; + gStatuses3[i] |= 0x10; + } + } + } + else + { + gBattleMons[gActiveBank].status2 = 0; + gStatuses3[gActiveBank] = 0; + } + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gUnknown_02024AD0[i].unk0 & (gBitTable[gActiveBank] << 16)) + gUnknown_02024AD0[i].unk0 &= ~(gBitTable[gActiveBank] << 16); + if ((gUnknown_02024AD0[i].unk0 & 0xE000) && ewram[0x16020 + i] == gActiveBank) + gUnknown_02024AD0[i].unk0 &= ~0xE000; + } + + gActionSelectionCursor[gActiveBank] = 0; + gMoveSelectionCursor[gActiveBank] = 0; + + ptr = (u8 *)&gDisableStructs[gActiveBank]; + for (i = 0; i < (u32)0x1C; i++) + ptr[i] = 0; + + if (gBattleMoves[gCurrentMove].effect == 0x7F) + { + gDisableStructs[gActiveBank].unkA = sp0.unkA; + gDisableStructs[gActiveBank].unk15 = sp0.unk15; + gDisableStructs[gActiveBank].unkF_0 = sp0.unkF_0; + gDisableStructs[gActiveBank].unkF_4 = sp0.unkF_4; + } + + gDisableStructs[gActiveBank].unk16 = 2; + gLastUsedMove[gActiveBank] = 0; + gMoveHitWith[gActiveBank] = 0; + gUnknown_02024C44[gActiveBank] = 0; + gUnknown_02024C4C[gActiveBank] = 0; + gUnknown_02024C2C[gActiveBank] = 0; + gUnknown_02024C5C[gActiveBank] = 0xFF; + + ewram[0x160AC + gActiveBank * 2 + 0] = 0; + ewram[0x160AC + gActiveBank * 2 + 1] = 0; + ewram[0x16100 + gActiveBank * 4 + 0] = 0; + ewram[0x16100 + gActiveBank * 4 + 1] = 0; + ewram[0x16100 + gActiveBank * 4 + 2] = 0; + ewram[0x16100 + gActiveBank * 4 + 3] = 0; + ewram[0x160E8 + gActiveBank * 2 + 0] = 0; + ewram[0x160E8 + gActiveBank * 2 + 1] = 0; + + ptr2 = (u32 *)(ewram + 0x17100); + ptr2[gActiveBank] = 0; + + gCurrentMove = 0; +} + +void UndoEffectsAfterFainting(void) +{ + s32 i; + u8 *ptr; + u32 *ptr2; + + for (i = 0; i < 8; i++) + gBattleMons[gActiveBank].statStages[i] = 6; + gBattleMons[gActiveBank].status2 = 0; + gStatuses3[gActiveBank] = 0; + for (i = 0; i < gNoOfAllBanks; i++) + { + if ((gBattleMons[i].status2 & 0x4000000) && gDisableStructs[i].unk14 == gActiveBank) + gBattleMons[i].status2 &= ~0x4000000; + if (gBattleMons[i].status2 & (gBitTable[gActiveBank] << 16)) + gBattleMons[i].status2 &= ~(gBitTable[gActiveBank] << 16); + if ((gBattleMons[i].status2 & 0xE000) && ewram[0x16020 + i] == gActiveBank) + gBattleMons[i].status2 &= ~0xE000; + } + gActionSelectionCursor[gActiveBank] = 0; + gMoveSelectionCursor[gActiveBank] = 0; + + ptr = (u8 *)&gDisableStructs[gActiveBank]; + for (i = 0; i < (u32)0x1C; i++) + ptr[i] = 0; + gProtectStructs[gActiveBank].unk0_0 = 0; + gProtectStructs[gActiveBank].unk0_1 = 0; + gProtectStructs[gActiveBank].unk0_2 = 0; + gProtectStructs[gActiveBank].unk0_3 = 0; + gProtectStructs[gActiveBank].unk0_4 = 0; + gProtectStructs[gActiveBank].unk0_5 = 0; + gProtectStructs[gActiveBank].unk0_6 = 0; + gProtectStructs[gActiveBank].unk0_7 = 0; + gProtectStructs[gActiveBank].unk1_0 = 0; + gProtectStructs[gActiveBank].unk1_1 = 0; + gProtectStructs[gActiveBank].unk1_2 = 0; + gProtectStructs[gActiveBank].unk1_3 = 0; + gProtectStructs[gActiveBank].unk1_5 = 0; + gProtectStructs[gActiveBank].unk1_6 = 0; + gProtectStructs[gActiveBank].unk1_7 = 0; + gProtectStructs[gActiveBank].unk2_0 = 0; + gProtectStructs[gActiveBank].unk2_1 = 0; + gProtectStructs[gActiveBank].unk2_2 = 0; + gProtectStructs[gActiveBank].unk2_3 = 0; + + gDisableStructs[gActiveBank].unk16 = 2; + gLastUsedMove[gActiveBank] = 0; + gMoveHitWith[gActiveBank] = 0; + gUnknown_02024C44[gActiveBank] = 0; + gUnknown_02024C4C[gActiveBank] = 0; + gUnknown_02024C2C[gActiveBank] = 0; + gUnknown_02024C5C[gActiveBank] = 0xFF; + + ewram[0x160E8 + gActiveBank * 2 + 0] = 0; + ewram[0x160E8 + gActiveBank * 2 + 1] = 0; + ewram[0x160AC + gActiveBank * 2 + 0] = 0; + ewram[0x160AC + gActiveBank * 2 + 1] = 0; + ewram[0x16100 + gActiveBank * 4 + 0] = 0; + ewram[0x16100 + gActiveBank * 4 + 1] = 0; + ewram[0x16100 + gActiveBank * 4 + 2] = 0; + ewram[0x16100 + gActiveBank * 4 + 3] = 0; + + ptr2 = (u32 *)(ewram + 0x17100); + ptr2[gActiveBank] = 0; + + gBattleMons[gActiveBank].type1 = gBaseStats[gBattleMons[gActiveBank].species].type1; + gBattleMons[gActiveBank].type2 = gBaseStats[gBattleMons[gActiveBank].species].type2; +} + +void bc_8012FAC(void) +{ + switch (gBattleCommunication[0]) + { + case 0: + gActiveBank = gBattleCommunication[1]; + EmitGetAttributes(0, 0, 0); + MarkBufferBankForExecution(gActiveBank); + gBattleCommunication[0]++; + break; + case 1: + if (gBattleExecBuffer == 0) + { + gBattleCommunication[1]++; + if (gBattleCommunication[1] == gNoOfAllBanks) + gBattleMainFunc = bc_load_battlefield; + else + gBattleCommunication[0] = 0; + } + break; + } +} + +void bc_load_battlefield(void) +{ + if (gBattleExecBuffer == 0) + { + gActiveBank = GetBankByPlayerAI(0); + EmitBattleIntroSlide(0, gBattleTerrain); + MarkBufferBankForExecution(gActiveBank); + gBattleMainFunc = sub_8011384; + gBattleCommunication[0] = 0; + gBattleCommunication[1] = 0; + } +} + +void sub_8011384(void) +{ + u8 *ptr; + s32 i; + + if (gBattleExecBuffer == 0) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) + && GetBankSide(gActiveBank) == 0) + { + ptr = (u8 *)&gBattleMons[gActiveBank]; + for (i = 0; i < (u32)0x58; i++) + ptr[i] = 0; + } + else + { + u8 r0; + + ptr = (u8 *)&gBattleMons[gActiveBank]; + for (i = 0; i < (u32)0x58; i++) + ptr[i] = gBattleBufferB[gActiveBank][4 + i]; + + gBattleMons[gActiveBank].type1 = gBaseStats[gBattleMons[gActiveBank].species].type1; + gBattleMons[gActiveBank].type2 = gBaseStats[gBattleMons[gActiveBank].species].type2; + gBattleMons[gActiveBank].ability = GetAbilityBySpecies(gBattleMons[gActiveBank].species, gBattleMons[gActiveBank].altAbility); + r0 = GetBankSide(gActiveBank); + ewram160BC[r0] = gBattleMons[gActiveBank].hp; + for (i = 0; i < 8; i++) + gBattleMons[gActiveBank].statStages[i] = 6; + gBattleMons[gActiveBank].status2 = 0; + } + + if (GetBankIdentity(gActiveBank) == 0) + { + dp01_build_cmdbuf_x07_7_7_7(0); + MarkBufferBankForExecution(gActiveBank); + } + + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) + { + if (GetBankIdentity(gActiveBank) == 1) + { + dp01_build_cmdbuf_x07_7_7_7(0); + MarkBufferBankForExecution(gActiveBank); + } + if (GetBankSide(gActiveBank) == 1 + && !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_LINK))) + GetNationalPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBank].species), 2); + } + else + { + if (GetBankSide(gActiveBank) == 1 + && !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_LINK))) + { + GetNationalPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBank].species), 2); + dp01_build_cmdbuf_x04_4_4_4(0); + MarkBufferBankForExecution(gActiveBank); + } + } + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + if (GetBankIdentity(gActiveBank) == 2 + || GetBankIdentity(gActiveBank) == 3) + { + dp01_build_cmdbuf_x07_7_7_7(0); + MarkBufferBankForExecution(gActiveBank); + } + } + } + gBattleMainFunc = bc_801333C; + } +} + +void bc_801333C(void) +{ + s32 i; + + if (gBattleExecBuffer == 0) + { + struct + { + u16 hp; + u32 status; + } sp0[6]; + + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) + { + for (i = 0; i < 6; i++) + { + if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == 0 + || GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) + { + sp0[i].hp = 0xFFFF; + sp0[i].status = 0; + } + else + { + sp0[i].hp = GetMonData(&gEnemyParty[i], MON_DATA_HP); + sp0[i].status = GetMonData(&gEnemyParty[i], MON_DATA_STATUS); + } + } + gActiveBank = GetBankByPlayerAI(1); + dp01_build_cmdbuf_x30_TODO(0, (u8 *)sp0, 0x80); + MarkBufferBankForExecution(gActiveBank); + + for (i = 0; i < 6; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == 0 + || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) + { + sp0[i].hp = 0xFFFF; + sp0[i].status = 0; + } + else + { + sp0[i].hp = GetMonData(&gPlayerParty[i], MON_DATA_HP); + sp0[i].status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); + } + } + gActiveBank = GetBankByPlayerAI(0); + dp01_build_cmdbuf_x30_TODO(0, (u8 *)sp0, 0x80); + MarkBufferBankForExecution(gActiveBank); + + gBattleMainFunc = bc_battle_begin_message; + } + else + { + // The array gets set here, but nothing is ever done with it. + // Likely unfinished code. + + for (i = 0; i < 6; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == 0 + || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) + { + sp0[i].hp = 0xFFFF; + sp0[i].status = 0; + } + else + { + sp0[i].hp = GetMonData(&gPlayerParty[i], MON_DATA_HP); + sp0[i].status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); + } + } + + gBattleMainFunc = bc_8013568; + } + } +} + +void bc_battle_begin_message(void) +{ + if (gBattleExecBuffer == 0) + { + gActiveBank = GetBankByPlayerAI(1); + PrepareStringBattle(0, gActiveBank); + gBattleMainFunc = sub_8011800; + } +} + +void bc_8013568(void) +{ + if (gBattleExecBuffer == 0) + { + gBattleMainFunc = sub_8011970; + PrepareStringBattle(0, 0); + } +} + +void sub_8011800(void) +{ + if (gBattleExecBuffer == 0) + { + PrepareStringBattle(1, GetBankByPlayerAI(1)); + gBattleMainFunc = sub_8011834; + } +} + +void sub_8011834(void) +{ + if (gBattleExecBuffer == 0) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankIdentity(gActiveBank) == 1) + { + dp01_build_cmdbuf_x2F_2F_2F_2F(0); + MarkBufferBankForExecution(gActiveBank); + } + if ((gBattleTypeFlags & BATTLE_TYPE_MULTI) + && GetBankIdentity(gActiveBank) == 3) + { + dp01_build_cmdbuf_x2F_2F_2F_2F(0); + MarkBufferBankForExecution(gActiveBank); + } + } + gBattleMainFunc = bc_801362C; + } +} + +void bc_801362C(void) +{ + if (gBattleExecBuffer == 0) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankSide(gActiveBank) == 1 + && !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_LINK))) + GetNationalPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBank].species), 2); + } + gBattleMainFunc = sub_8011970; + } +} + +void unref_sub_8011950(void) +{ + if (gBattleExecBuffer == 0) + gBattleMainFunc = sub_8011970; +} + +void sub_8011970(void) +{ + if (gBattleExecBuffer == 0) + { + if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) + PrepareStringBattle(1, GetBankByPlayerAI(0)); + gBattleMainFunc = sub_80119B4; + } +} + +void sub_80119B4(void) +{ + if (gBattleExecBuffer == 0) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankIdentity(gActiveBank) == 0) + { + dp01_build_cmdbuf_x2F_2F_2F_2F(0); + MarkBufferBankForExecution(gActiveBank); + } + if ((gBattleTypeFlags & BATTLE_TYPE_MULTI) + && GetBankIdentity(gActiveBank) == 2) + { + dp01_build_cmdbuf_x2F_2F_2F_2F(0); + MarkBufferBankForExecution(gActiveBank); + } + } + ewram16058 = 0; + ewram160F9 = 0; + ewram160E6 = 0; + gBattleMainFunc = BattleBeginFirstTurn; + } +} + +void unref_sub_8011A68(void) +{ + if (gBattleExecBuffer == 0) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (GetBankSide(gActiveBank) == 0) + { + sub_800C704(0, gBattlePartyID[gActiveBank], 0); + MarkBufferBankForExecution(gActiveBank); + } + } + ewram16058 = 0; + ewram160F9 = 0; + ewram160E6 = 0; + gBattleMainFunc = BattleBeginFirstTurn; + } +} + +void BattleBeginFirstTurn(void) +{ + s32 i; + s32 j; + u8 r9 = 0; + + if (gBattleExecBuffer == 0) + { + if (ewram16058 == 0) + { + for (i = 0; i < gNoOfAllBanks; i++) + gTurnOrder[i] = i; + for (i = 0; i < gNoOfAllBanks - 1; i++) + { + for (j = i + 1; j < gNoOfAllBanks; j++) + { + if (b_first_side(gTurnOrder[i], gTurnOrder[j], 1) != 0) + sub_8012FBC(i, j); + } + } + } + if (ewram160E6 == 0 && AbilityBattleEffects(0, 0, 0, 0xFF, 0) != 0) + { + ewram160E6 = 1; + return; + } + while (ewram16058 < gNoOfAllBanks) + { + if (AbilityBattleEffects(0, gTurnOrder[ewram16058], 0, 0, 0) != 0) + r9++; + ewram16058++; + if (r9 != 0) + return; + } + if (AbilityBattleEffects(9, 0, 0, 0, 0) != 0) + return; + if (AbilityBattleEffects(11, 0, 0, 0, 0) != 0) + return; + while (ewram160F9 < gNoOfAllBanks) + { + if (sub_801A02C(0, gTurnOrder[ewram160F9], 0) != 0) + r9++; + ewram160F9++; + if (r9 != 0) + return; + } + // Absolutely pointless for-loop that somehow doesn't get optimized out + for (i = 0; i < gNoOfAllBanks; i++) + ; + for (i = 0; i < 4; i++) + { + ewram[0x16068 + i] = 6; + gActionForBanks[i] = 0xFF; + gChosenMovesByBanks[i] = 0; + } + TurnValuesCleanUp(0); + SpecialStatusesClear(); + ewram160A6 = gAbsentBankFlags; + gBattleMainFunc = sub_8012324; + sub_80156DC(); + for (i = 0; i < 8; i++) + gBattleCommunication[i] = 0; + for (i = 0; i < gNoOfAllBanks; i++) + gBattleMons[i].status2 &= ~8; + ewram16000 = 0; + ewram16001 = 0; + ewram16110 = 0; + ewram16111 = 0; + ewram1600C = 0; + ewram16059 = 0; + ewram1600E = 0; + gBattleMoveFlags = 0; + gRandomTurnNumber = Random(); + } +} + +void bc_8013B1C(void) +{ + s32 i; + + if (gBattleExecBuffer == 0) + { + gBattleMainFunc = BattleTurnPassed; + for (i = 0; i < 8; i++) + gBattleCommunication[i] = 0; + for (i = 0; i < gNoOfAllBanks; i++) + { + gBattleMons[i].status2 &= ~8; + if ((gBattleMons[i].status1 & 7) && (gBattleMons[i].status2 & 0x1000)) + CancelMultiTurnMoves(i); + } + ewram16000 = 0; + ewram16001 = 0; + ewram16110 = 0; + ewram16111 = 0; + ewram1600E = 0; + gBattleMoveFlags = 0; + } +} + +void BattleTurnPassed(void) +{ + s32 i; + + TurnValuesCleanUp(1); + if (gBattleOutcome == 0) + { + if (UpdateTurnCounters() != 0) + return; + if (TurnBasedEffects() != 0) + return; + } + if (sub_80173A4() != 0) + return; + ewram16059 = 0; + if (sub_80170DC() != 0) + return; + TurnValuesCleanUp(0); + gHitMarker &= ~0x200; + gHitMarker &= ~0x80000; + gHitMarker &= ~0x400000; + gHitMarker &= ~0x100000; + ewram16002 = 0; + ewram160A1 = 0; + ewram1600C = 0; + gBattleMoveDamage = 0; + gBattleMoveFlags = 0; + for (i = 0; i < 5; i++) + gBattleCommunication[i] = 0; + if (gBattleOutcome != 0) + { + gFightStateTracker = 12; + gBattleMainFunc = sub_80138F0; + return; + } + if (gBattleResults.unk13 < 0xFF) + gBattleResults.unk13++; + for (i = 0; i < gNoOfAllBanks; i++) + { + gActionForBanks[i] = 0xFF; + gChosenMovesByBanks[i] = 0; + } + for (i = 0; i < 4; i++) + ewram[0x16068 + i] = 6; + ewram160A6 = gAbsentBankFlags; + gBattleMainFunc = sub_8012324; + gRandomTurnNumber = Random(); +} + +u8 CanRunFromBattle(void) +{ + u8 r2; + u8 r6; + s32 i; + + if (gBattleMons[gActiveBank].item == 0xAF) + r2 = gEnigmaBerries[gActiveBank].holdEffect; + else + r2 = ItemId_GetHoldEffect(gBattleMons[gActiveBank].item); + gStringBank = gActiveBank; + if (r2 == 0x25) + return 0; + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + return 0; + if (gBattleMons[gActiveBank].ability == ABILITY_RUN_AWAY) + return 0; + r6 = GetBankSide(gActiveBank); + for (i = 0; i < gNoOfAllBanks; i++) + { + if (r6 != GetBankSide(i) + && gBattleMons[i].ability == 0x17) + { + ewram16003 = i; + gLastUsedAbility = gBattleMons[i].ability; + gBattleCommunication[5] = 2; + return 2; + } + if (r6 != GetBankSide(i) + && gBattleMons[gActiveBank].ability != ABILITY_LEVITATE + && gBattleMons[gActiveBank].type1 != 2 + && gBattleMons[gActiveBank].type2 != 2 + && gBattleMons[i].ability == 0x47) + { + ewram16003 = i; + gLastUsedAbility = gBattleMons[i].ability; + gBattleCommunication[5] = 2; + return 2; + } + } + i = AbilityBattleEffects(15, gActiveBank, 0x2A, 0, 0); + if (i != 0 && (gBattleMons[gActiveBank].type1 == 8 || gBattleMons[gActiveBank].type2 == 8)) + { + ewram16003 = i - 1; + gLastUsedAbility = gBattleMons[i - 1].ability; + gBattleCommunication[5] = 2; + return 2; + } + if ((gBattleMons[gActiveBank].status2 & 0x0400E000) || (gStatuses3[gActiveBank] & 0x400)) + { + gBattleCommunication[5] = 0; + return 1; + } + if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE) + { + gBattleCommunication[5] = 1; + return 1; + } + return 0; +} + +void sub_8012258(u8 a) +{ + s32 i; + u8 r4; + u8 r1; + + for (i = 0; i < 3; i++) + gUnknown_02038470[i] = ewram[0x1606C + i + a * 3]; + r4 = pokemon_order_func(gBattlePartyID[a]); + r1 = pokemon_order_func(ewram[0x16068 + a]); + sub_8094C98(r4, r1); + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + for (i = 0; i < 3; i++) + { + ewram[0x1606C + i + a * 3] = gUnknown_02038470[i]; + ewram[0x1606C + i + (a ^ 2) * 3] = gUnknown_02038470[i]; + } + } + else + { + for (i = 0; i < 3; i++) + { + ewram[0x1606C + i + a * 3] = gUnknown_02038470[i]; + } + } +} + +/* +void sub_8012324(void) +{ + u8 r5; + + gBattleCommunication[4] = 0; + // inverted loop + //_0801234C + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + r5 = GetBankIdentity(gActiveBank); + switch (gBattleCommunication[gActiveBank]) + { + case 0: + ewram[0x016068 + gActiveBank] = 6; + if (!(gBattleTypeFlags & 0x40) + && (r5 & 2) + && !(ewram160A6 & gBitTable[GetBankByPlayerAI(r5 ^ 2)]) + && gBattleCommunication[GetBankByPlayerAI(r5)] != 4) + break; + //_080123F8 + if (ewram160A6 & gBitTable[gActiveBank]) + { + gActionForBanks[gActiveBank] = 13; + if (!(gBattleTypeFlags & 0x40)) + gBattleCommunication[gActiveBank] = 4; + //_08012454 + else + gBattleCommunication[gActiveBank] = 3; + break; + } + //_08012468 + if ((gBattleMons[gActiveBank].status2 & 0x1000) + || (gBattleMons[gActiveBank].status2 & 0x10000000)) + { + gActionForBanks[gActiveBank] = 0; + gBattleCommunication[gActiveBank] = 3; + } + else + { + dp01_build_cmdbuf_x12_a_bb(0, gActionForBanks[0], gBattleBufferB[0][1] | (gBattleBufferB[0][2] << 8)); + MarkBufferBankForExecution(gActiveBank); + gBattleCommunication[gActiveBank]++; + } + break; + case 1: + } + } +} +*/ diff --git a/src/battle_6.c b/src/battle_6.c new file mode 100644 index 000000000..9ea3f240a --- /dev/null +++ b/src/battle_6.c @@ -0,0 +1,1507 @@ +#include "global.h" +#include "battle.h" +#include "battle_interface.h" +#include "battle_message.h" +#include "data2.h" +#include "menu_cursor.h" +#include "palette.h" +#include "pokemon.h" +#include "rom3.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "string_util.h" +#include "task.h" +#include "text.h" +#include "util.h" + +//Possibly PokemonSubstruct1 +struct UnknownStruct3 +{ + u16 moves[4]; + u8 pp[4]; + u8 ppBonuses; +}; + +extern u16 gUnknown_030042A4; +extern u16 gUnknown_030042A0; + +extern struct Window gUnknown_03004210; + +extern void (*gBattleBankFunc[])(void); + +extern u8 gActiveBank; +extern u8 gActionSelectionCursor[]; +extern u8 gDisplayedStringBattle[]; +extern u8 gMoveSelectionCursor[]; +extern u8 gBattleBufferA[][0x200]; +extern u8 gBankInMenu; +extern u16 gBattlePartyID[]; +extern u8 gHealthboxIDs[]; +extern u8 gDoingBattleAnim; +extern u8 gObjectBankIDs[]; +extern u16 gBattleTypeFlags; +extern u8 gBattleOutcome; +extern void (*gAnimScriptCallback)(void); +extern bool8 gAnimScriptActive; +extern u16 gMovePowerMoveAnim; +extern u32 gMoveDmgMoveAnim; +extern u8 gHappinessMoveAnim; +extern u16 gWeatherMoveAnim; +extern u32 *gDisableStructMoveAnim; +extern u32 gPID_perBank[]; +extern u8 gBattleMonForms[]; +extern u16 gUnknown_02024DE8; +extern u8 gUnknown_02024E68[]; +extern struct SpriteTemplate gUnknown_02024E8C; +extern u8 gUnknown_0202F7C4; +extern u8 gUnknown_02038470[]; +extern u16 gUnknown_030041B0; +extern u16 gUnknown_030041B4; +extern u16 gUnknown_030041B8; +extern u16 gUnknown_03004280; +extern u16 gUnknown_03004288; +extern u16 gUnknown_030042A4; +extern u16 gUnknown_030042C0; +extern u8 gUnknown_03004344; +extern u8 gUnknown_0300434C[]; + +extern const u8 gUnknown_08400CA8[]; +extern const u8 gUnknown_08400CF3[]; +extern const u8 gUnknown_08400D38[]; + +#if ENGLISH +#define SUB_803037C_TILE_DATA_OFFSET 440 +#elif GERMAN +#define SUB_803037C_TILE_DATA_OFFSET 444 +#endif + +extern void sub_802C68C(void); +extern void sub_802E1B0(void); +extern void sub_802E3B4(); +extern void sub_802E220(); +extern void sub_802E2D4(); +extern void sub_802E004(void); +extern void sub_802DF30(void); +extern void sub_80325B8(void); +extern void PlayerBufferExecCompleted(void); +extern void bx_t1_healthbar_update(void); +extern void nullsub_91(void); +extern void sub_802D924(u8); +extern void sub_802E434(void); +extern bool8 mplay_80342A4(u8); +extern void move_anim_start_t2_for_situation(); +extern void bx_blink_t1(void); +extern void sub_8047858(); +extern u8 GetBankSide(u8); +extern void sub_80E43C0(); +extern void oamt_add_pos2_onto_pos1(); +extern void sub_8078B34(struct Sprite *); +extern void oamt_set_x3A_32(); +extern void sub_80318FC(); +extern bool8 IsDoubleBattle(void); +extern void sub_802D500(void); +extern void dp11b_obj_free(); +extern bool8 sub_8078874(u8); +extern bool8 move_anim_start_t3(); +extern void sub_802E460(void); +extern void b_link_standby_message(void); +extern void sub_802D18C(void); +extern void sub_802DF18(void); +extern void BufferStringBattle(); +extern void sub_80326EC(); +extern void ExecuteMoveAnim(); +extern void sub_8031F24(void); +extern void sub_80324BC(); +extern u8 sub_8031720(); +extern void bx_wait_t1(void); +extern u8 GetBankByPlayerAI(u8); +extern void sub_802DE10(void); +extern void sub_80105EC(struct Sprite *); +extern void sub_802D274(void); +extern void sub_802D23C(void); +extern u8 GetBankIdentity(u8); +extern void sub_8031AF4(); +extern void sub_80313A0(struct Sprite *); +extern void sub_802D204(void); +extern u8 sub_8079E90(); +extern void sub_802DEAC(void); +extern void sub_80312F0(struct Sprite *); +extern u8 sub_8077ABC(); +extern u8 sub_8077F68(); +extern u8 sub_8046400(); +extern void sub_802D798(void); +extern void bx_0802E404(void); + +u32 dp01_getattr_by_ch1_for_player_pokemon_(u8, u8 *); +void dp01_setattr_by_ch1_for_player_pokemon(u8); +void sub_802F934(u8, u8); +void sub_802FB2C(void); +void sub_8030190(void); +void sub_80304A8(void); +void sub_8030E38(struct Sprite *); +void task05_08033660(u8); +void sub_8031064(void); + +void PlayerHandleGetAttributes(void) +{ + u8 unkData[0x100]; + u32 offset = 0; + u8 r4; + s32 i; + + if (gBattleBufferA[gActiveBank][2] == 0) + { + offset += dp01_getattr_by_ch1_for_player_pokemon_(gBattlePartyID[gActiveBank], unkData); + } + else + { + r4 = gBattleBufferA[gActiveBank][2]; + for (i = 0; i < 6; i++) + { + if (r4 & 1) + offset += dp01_getattr_by_ch1_for_player_pokemon_(i, unkData + offset); + r4 >>= 1; + } + } + dp01_build_cmdbuf_x1D_1D_numargs_varargs(1, offset, unkData); + PlayerBufferExecCompleted(); +} + +// Duplicate of dp01_getattr_by_ch1_for_player_pokemon +u32 dp01_getattr_by_ch1_for_player_pokemon_(u8 a, u8 *buffer) +{ + struct BattlePokemon battlePokemon; + struct UnknownStruct3 moveData; + u8 nickname[20]; + u8 *src; + s16 data16; + u32 data32; + s32 size = 0; + + switch (gBattleBufferA[gActiveBank][1]) + { + case 0: + battlePokemon.species = GetMonData(&gPlayerParty[a], MON_DATA_SPECIES); + battlePokemon.item = GetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM); + for (size = 0; size < 4; size++) + { + battlePokemon.moves[size] = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + size); + battlePokemon.pp[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); + } + battlePokemon.ppBonuses = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); + battlePokemon.friendship = GetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP); + battlePokemon.experience = GetMonData(&gPlayerParty[a], MON_DATA_EXP); + battlePokemon.hpIV = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); + battlePokemon.attackIV = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); + battlePokemon.defenseIV = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); + battlePokemon.speedIV = GetMonData(&gPlayerParty[a], MON_DATA_SPD_IV); + battlePokemon.spAttackIV = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); + battlePokemon.spDefenseIV = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); + battlePokemon.personality = GetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY); + battlePokemon.status1 = GetMonData(&gPlayerParty[a], MON_DATA_STATUS); + battlePokemon.level = GetMonData(&gPlayerParty[a], MON_DATA_LEVEL); + battlePokemon.hp = GetMonData(&gPlayerParty[a], MON_DATA_HP); + battlePokemon.maxHP = GetMonData(&gPlayerParty[a], MON_DATA_MAX_HP); + battlePokemon.attack = GetMonData(&gPlayerParty[a], MON_DATA_ATK); + battlePokemon.defense = GetMonData(&gPlayerParty[a], MON_DATA_DEF); + battlePokemon.speed = GetMonData(&gPlayerParty[a], MON_DATA_SPD); + battlePokemon.spAttack = GetMonData(&gPlayerParty[a], MON_DATA_SPATK); + battlePokemon.spDefense = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF); + battlePokemon.isEgg = GetMonData(&gPlayerParty[a], MON_DATA_IS_EGG); + battlePokemon.altAbility = GetMonData(&gPlayerParty[a], MON_DATA_ALT_ABILITY); + battlePokemon.otId = GetMonData(&gPlayerParty[a], MON_DATA_OT_ID); + GetMonData(&gPlayerParty[a], MON_DATA_NICKNAME, nickname); + StringCopy10(battlePokemon.nickname, nickname); + GetMonData(&gPlayerParty[a], MON_DATA_OT_NAME, battlePokemon.otName); + src = (u8 *)&battlePokemon; + for (size = 0; size < sizeof(battlePokemon); size++) + buffer[size] = src[size]; + break; + case 1: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPECIES); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 2: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 3: + for (size = 0; size < 4; size++) + { + moveData.moves[size] = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + size); + moveData.pp[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); + } + moveData.ppBonuses = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); + src = (u8 *)&moveData; + for (size = 0; size < sizeof(moveData); size++) + buffer[size] = src[size]; + break; + case 4: + case 5: + case 6: + case 7: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - 4); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 8: + for (size = 0; size < 4; size++) + buffer[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); + buffer[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); + size++; + break; + case 9: + case 10: + case 11: + case 12: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - 9); + size = 1; + break; + case 17: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_OT_ID); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + size = 3; + break; + case 18: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_EXP); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + size = 3; + break; + case 19: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_EV); + size = 1; + break; + case 20: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_EV); + size = 1; + break; + case 21: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_EV); + size = 1; + break; + case 22: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPD_EV); + size = 1; + break; + case 23: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_EV); + size = 1; + break; + case 24: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_EV); + size = 1; + break; + case 25: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP); + size = 1; + break; + case 26: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_POKERUS); + size = 1; + break; + case 27: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_LOCATION); + size = 1; + break; + case 28: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_LEVEL); + size = 1; + break; + case 29: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_GAME); + size = 1; + break; + case 30: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_POKEBALL); + size = 1; + break; + case 31: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); + buffer[1] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); + buffer[2] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); + buffer[3] = GetMonData(&gPlayerParty[a], MON_DATA_SPD_IV); + buffer[4] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); + buffer[5] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); + size = 6; + break; + case 32: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); + size = 1; + break; + case 33: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); + size = 1; + break; + case 34: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); + size = 1; + break; + case 35: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPD_IV); + size = 1; + break; + case 36: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); + size = 1; + break; + case 37: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); + size = 1; + break; + case 38: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + buffer[3] = (data32 & 0xFF000000) >> 24; + size = 4; + break; + case 39: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_CHECKSUM); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 40: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_STATUS); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + buffer[3] = (data32 & 0xFF000000) >> 24; + size = 4; + break; + case 41: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_LEVEL); + size = 1; + break; + case 42: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_HP); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 43: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_MAX_HP); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 44: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_ATK); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 45: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_DEF); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 46: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPD); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 47: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPATK); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 48: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 49: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_COOL); + size = 1; + break; + case 50: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_BEAUTY); + size = 1; + break; + case 51: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_CUTE); + size = 1; + break; + case 52: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SMART); + size = 1; + break; + case 53: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_TOUGH); + size = 1; + break; + case 54: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SHEEN); + size = 1; + break; + case 55: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_COOL_RIBBON); + size = 1; + break; + case 56: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_BEAUTY_RIBBON); + size = 1; + break; + case 57: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_CUTE_RIBBON); + size = 1; + break; + case 58: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SMART_RIBBON); + size = 1; + break; + case 59: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_TOUGH_RIBBON); + size = 1; + break; + } + return size; +} + +void sub_802ECF0(void) +{ + struct BattlePokemon battleMon; // I think this is a BattlePokemon + u8 *src = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; + u8 *dst = (u8 *)&battleMon + gBattleBufferA[gActiveBank][1]; + u8 i; + + for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) + dst[i] = src[i]; + dp01_build_cmdbuf_x1D_1D_numargs_varargs(1, gBattleBufferA[gActiveBank][2], dst); + PlayerBufferExecCompleted(); +} + +void PlayerHandleSetAttributes(void) +{ + u8 r4; + u8 i; + + if (gBattleBufferA[gActiveBank][2] == 0) + { + dp01_setattr_by_ch1_for_player_pokemon(gBattlePartyID[gActiveBank]); + } + else + { + r4 = gBattleBufferA[gActiveBank][2]; + for (i = 0; i < 6; i++) + { + if (r4 & 1) + dp01_setattr_by_ch1_for_player_pokemon(i); + r4 >>= 1; + } + } + PlayerBufferExecCompleted(); +} + +// Duplicate of sub_811EC68 +void dp01_setattr_by_ch1_for_player_pokemon(u8 a) +{ + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; + struct UnknownStruct3 *moveData = (struct UnknownStruct3 *)&gBattleBufferA[gActiveBank][3]; + s32 i; + + switch (gBattleBufferA[gActiveBank][1]) + { + case 0: + { + u8 iv; + + SetMonData(&gPlayerParty[a], MON_DATA_SPECIES, (u8 *)&battlePokemon->species); + SetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM, (u8 *)&battlePokemon->item); + for (i = 0; i < 4; i++) + { + SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + i, (u8 *)&battlePokemon->moves[i]); + SetMonData(&gPlayerParty[a], MON_DATA_PP1 + i, (u8 *)&battlePokemon->pp[i]); + } + SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, (u8 *)&battlePokemon->ppBonuses); + SetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP, (u8 *)&battlePokemon->friendship); + SetMonData(&gPlayerParty[a], MON_DATA_EXP, (u8 *)&battlePokemon->experience); + iv = battlePokemon->hpIV; + SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, (u8 *)&iv); + iv = battlePokemon->attackIV; + SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, (u8 *)&iv); + iv = battlePokemon->defenseIV; + SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, (u8 *)&iv); + iv = battlePokemon->speedIV; + SetMonData(&gPlayerParty[a], MON_DATA_SPD_IV, (u8 *)&iv); + iv = battlePokemon->spAttackIV; + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, (u8 *)&iv); + iv = battlePokemon->spDefenseIV; + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, (u8 *)&iv); + SetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY, (u8 *)&battlePokemon->personality); + SetMonData(&gPlayerParty[a], MON_DATA_STATUS, (u8 *)&battlePokemon->status1); + SetMonData(&gPlayerParty[a], MON_DATA_LEVEL, (u8 *)&battlePokemon->level); + SetMonData(&gPlayerParty[a], MON_DATA_HP, (u8 *)&battlePokemon->hp); + SetMonData(&gPlayerParty[a], MON_DATA_MAX_HP, (u8 *)&battlePokemon->maxHP); + SetMonData(&gPlayerParty[a], MON_DATA_ATK, (u8 *)&battlePokemon->attack); + SetMonData(&gPlayerParty[a], MON_DATA_DEF, (u8 *)&battlePokemon->defense); + SetMonData(&gPlayerParty[a], MON_DATA_SPD, (u8 *)&battlePokemon->speed); + SetMonData(&gPlayerParty[a], MON_DATA_SPATK, (u8 *)&battlePokemon->spAttack); + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF, (u8 *)&battlePokemon->spDefense); + } + break; + case 1: + SetMonData(&gPlayerParty[a], MON_DATA_SPECIES, &gBattleBufferA[gActiveBank][3]); + break; + case 2: + SetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBank][3]); + break; + case 3: + for (i = 0; i < 4; i++) + { + SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + i, (u8 *)&moveData->moves[i]); + SetMonData(&gPlayerParty[a], MON_DATA_PP1 + i, (u8 *)&moveData->pp[i]); + } + SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, &moveData->ppBonuses); + break; + case 4: + case 5: + case 6: + case 7: + SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - 4, &gBattleBufferA[gActiveBank][3]); + break; + case 8: + SetMonData(&gPlayerParty[a], MON_DATA_PP1, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[a], MON_DATA_PP2, &gBattleBufferA[gActiveBank][4]); + SetMonData(&gPlayerParty[a], MON_DATA_PP3, &gBattleBufferA[gActiveBank][5]); + SetMonData(&gPlayerParty[a], MON_DATA_PP4, &gBattleBufferA[gActiveBank][6]); + SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBank][7]); + break; + case 9: + case 10: + case 11: + case 12: + SetMonData(&gPlayerParty[a], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - 9, &gBattleBufferA[gActiveBank][3]); + break; + case 17: + SetMonData(&gPlayerParty[a], MON_DATA_OT_ID, &gBattleBufferA[gActiveBank][3]); + break; + case 18: + SetMonData(&gPlayerParty[a], MON_DATA_EXP, &gBattleBufferA[gActiveBank][3]); + break; + case 19: + SetMonData(&gPlayerParty[a], MON_DATA_HP_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 20: + SetMonData(&gPlayerParty[a], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 21: + SetMonData(&gPlayerParty[a], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 22: + SetMonData(&gPlayerParty[a], MON_DATA_SPD_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 23: + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 24: + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 25: + SetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBank][3]); + break; + case 26: + SetMonData(&gPlayerParty[a], MON_DATA_POKERUS, &gBattleBufferA[gActiveBank][3]); + break; + case 27: + SetMonData(&gPlayerParty[a], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBank][3]); + break; + case 28: + SetMonData(&gPlayerParty[a], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBank][3]); + break; + case 29: + SetMonData(&gPlayerParty[a], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBank][3]); + break; + case 30: + SetMonData(&gPlayerParty[a], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBank][3]); + break; + case 31: + SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][4]); + SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][5]); + SetMonData(&gPlayerParty[a], MON_DATA_SPD_IV, &gBattleBufferA[gActiveBank][6]); + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][7]); + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][8]); + break; + case 32: + SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 33: + SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 34: + SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 35: + SetMonData(&gPlayerParty[a], MON_DATA_SPD_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 36: + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 37: + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 38: + SetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBank][3]); + break; + case 39: + SetMonData(&gPlayerParty[a], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBank][3]); + break; + case 40: + SetMonData(&gPlayerParty[a], MON_DATA_STATUS, &gBattleBufferA[gActiveBank][3]); + break; + case 41: + SetMonData(&gPlayerParty[a], MON_DATA_LEVEL, &gBattleBufferA[gActiveBank][3]); + break; + case 42: + SetMonData(&gPlayerParty[a], MON_DATA_HP, &gBattleBufferA[gActiveBank][3]); + break; + case 43: + SetMonData(&gPlayerParty[a], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBank][3]); + break; + case 44: + SetMonData(&gPlayerParty[a], MON_DATA_ATK, &gBattleBufferA[gActiveBank][3]); + break; + case 45: + SetMonData(&gPlayerParty[a], MON_DATA_DEF, &gBattleBufferA[gActiveBank][3]); + break; + case 46: + SetMonData(&gPlayerParty[a], MON_DATA_SPD, &gBattleBufferA[gActiveBank][3]); + break; + case 47: + SetMonData(&gPlayerParty[a], MON_DATA_SPATK, &gBattleBufferA[gActiveBank][3]); + break; + case 48: + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF, &gBattleBufferA[gActiveBank][3]); + break; + case 49: + SetMonData(&gPlayerParty[a], MON_DATA_COOL, &gBattleBufferA[gActiveBank][3]); + break; + case 50: + SetMonData(&gPlayerParty[a], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBank][3]); + break; + case 51: + SetMonData(&gPlayerParty[a], MON_DATA_CUTE, &gBattleBufferA[gActiveBank][3]); + break; + case 52: + SetMonData(&gPlayerParty[a], MON_DATA_SMART, &gBattleBufferA[gActiveBank][3]); + break; + case 53: + SetMonData(&gPlayerParty[a], MON_DATA_TOUGH, &gBattleBufferA[gActiveBank][3]); + break; + case 54: + SetMonData(&gPlayerParty[a], MON_DATA_SHEEN, &gBattleBufferA[gActiveBank][3]); + break; + case 55: + SetMonData(&gPlayerParty[a], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 56: + SetMonData(&gPlayerParty[a], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 57: + SetMonData(&gPlayerParty[a], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 58: + SetMonData(&gPlayerParty[a], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 59: + SetMonData(&gPlayerParty[a], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + } + sub_80324F8(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); +} + +void sub_802F7CC(void) +{ + u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; + u8 i; + + for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) + dst[i] = gBattleBufferA[gActiveBank][3 + i]; + PlayerBufferExecCompleted(); +} + +void PlayerHandleLoadPokeSprite(void) +{ + sub_80318FC(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + gSprites[gObjectBankIDs[gActiveBank]].oam.paletteNum = gActiveBank; + gBattleBankFunc[gActiveBank] = bx_0802E404; +} + +void PlayerHandleSendOutPoke(void) +{ + sub_8032AA8(gActiveBank, gBattleBufferA[gActiveBank][2]); + gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1]; + sub_80318FC(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + gActionSelectionCursor[gActiveBank] = 0; + gMoveSelectionCursor[gActiveBank] = 0; + sub_802F934(gActiveBank, gBattleBufferA[gActiveBank][2]); + gBattleBankFunc[gActiveBank] = sub_802D798; +} + +void sub_802F934(u8 bank, u8 b) +{ + u16 species; + + sub_8032AA8(bank, b); + gBattlePartyID[bank] = gBattleBufferA[bank][1]; + species = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); + gUnknown_0300434C[bank] = CreateInvisibleSpriteWithCallback(sub_80312F0); + GetMonSpriteTemplate_803C56C(species, GetBankIdentity(bank)); + gObjectBankIDs[bank] = CreateSprite( + &gUnknown_02024E8C, + sub_8077ABC(bank, 2), + sub_8077F68(bank), + sub_8079E90(bank)); + gSprites[gUnknown_0300434C[bank]].data1 = gObjectBankIDs[bank]; + gSprites[gObjectBankIDs[bank]].data0 = bank; + gSprites[gObjectBankIDs[bank]].data2 = species; + gSprites[gObjectBankIDs[bank]].oam.paletteNum = bank; + StartSpriteAnim(&gSprites[gObjectBankIDs[bank]], gBattleMonForms[bank]); + gSprites[gObjectBankIDs[bank]].invisible = TRUE; + gSprites[gObjectBankIDs[bank]].callback = SpriteCallbackDummy; + gSprites[gUnknown_0300434C[bank]].data0 = sub_8046400(0, 0xFF); +} + +void PlayerHandleReturnPokeToBall(void) +{ + if (gBattleBufferA[gActiveBank][1] == 0) + { + ewram17810[gActiveBank].unk4 = 0; + gBattleBankFunc[gActiveBank] = sub_802FB2C; + } + else + { + FreeSpriteOamMatrix(&gSprites[gObjectBankIDs[gActiveBank]]); + DestroySprite(&gSprites[gObjectBankIDs[gActiveBank]]); + sub_8043DB0(gHealthboxIDs[gActiveBank]); + PlayerBufferExecCompleted(); + } +} + +void sub_802FB2C(void) +{ + switch (ewram17810[gActiveBank].unk4) + { + case 0: + if (ewram17800[gActiveBank].unk0_2) + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 5); + ewram17810[gActiveBank].unk4 = 1; + break; + case 1: + if (!ewram17810[gActiveBank].unk0_6) + { + ewram17810[gActiveBank].unk4 = 0; + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 1); + gBattleBankFunc[gActiveBank] = sub_802DEAC; + } + } +} + +void PlayerHandleTrainerThrow(void) +{ + s16 r7; + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + if (GetBankIdentity(gActiveBank) & 2) + r7 = 16; + else + r7 = -16; + } + else + { + r7 = 0; + } + sub_8031AF4(gSaveBlock2.playerGender, gActiveBank); + GetMonSpriteTemplate_803C5A0(gSaveBlock2.playerGender, GetBankIdentity(gActiveBank)); + gObjectBankIDs[gActiveBank] = CreateSprite( + &gUnknown_02024E8C, + r7 + 80, + (8 - gTrainerBackPicCoords[gSaveBlock2.playerGender].coords) * 4 + 80, + sub_8079E90(gActiveBank)); + gSprites[gObjectBankIDs[gActiveBank]].oam.paletteNum = gActiveBank; + gSprites[gObjectBankIDs[gActiveBank]].pos2.x = 240; + gSprites[gObjectBankIDs[gActiveBank]].data0 = -2; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_80313A0; + gBattleBankFunc[gActiveBank] = sub_802D204; +} + +void PlayerHandleTrainerSlide(void) +{ + sub_8031AF4(gSaveBlock2.playerGender, gActiveBank); + GetMonSpriteTemplate_803C5A0(gSaveBlock2.playerGender, GetBankIdentity(gActiveBank)); + gObjectBankIDs[gActiveBank] = CreateSprite( + &gUnknown_02024E8C, + 80, + (8 - gTrainerBackPicCoords[gSaveBlock2.playerGender].coords) * 4 + 80, + 30); + gSprites[gObjectBankIDs[gActiveBank]].oam.paletteNum = gActiveBank; + gSprites[gObjectBankIDs[gActiveBank]].pos2.x = -96; + gSprites[gObjectBankIDs[gActiveBank]].data0 = 2; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_80313A0; + gBattleBankFunc[gActiveBank] = sub_802D23C; +} + +void PlayerHandleTrainerSlideBack(void) +{ + oamt_add_pos2_onto_pos1(&gSprites[gObjectBankIDs[gActiveBank]]); + gSprites[gObjectBankIDs[gActiveBank]].data0 = 50; + gSprites[gObjectBankIDs[gActiveBank]].data2 = -40; + gSprites[gObjectBankIDs[gActiveBank]].data4 = gSprites[gObjectBankIDs[gActiveBank]].pos1.y; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_8078B34; + oamt_set_x3A_32(&gSprites[gObjectBankIDs[gActiveBank]], SpriteCallbackDummy); + StartSpriteAnim(&gSprites[gObjectBankIDs[gActiveBank]], 1); + gBattleBankFunc[gActiveBank] = sub_802D274; +} + +void sub_802FE7C(void) +{ + if (ewram17810[gActiveBank].unk4 == 0) + { + if (ewram17800[gActiveBank].unk0_2) + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 5); + ewram17810[gActiveBank].unk4++; + } + else + { + if (ewram17810[gActiveBank].unk0_6 == 0) + { + ewram17810[gActiveBank].unk4 = 0; + sub_80324F8(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + PlaySE12WithPanning(SE_POKE_DEAD, -64); + gSprites[gObjectBankIDs[gActiveBank]].data1 = 0; + gSprites[gObjectBankIDs[gActiveBank]].data2 = 5; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_80105EC; + gBattleBankFunc[gActiveBank] = sub_802DE10; + } + } +} + +void sub_802FF60(void) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 2, 0, 16, 0); + PlayerBufferExecCompleted(); +} + +void sub_802FF80(void) +{ + ewram17840.unk8 = 4; + gDoingBattleAnim = 1; + move_anim_start_t4(gActiveBank, gActiveBank, GetBankByPlayerAI(1), 3); + gBattleBankFunc[gActiveBank] = bx_wait_t1; +} + +void PlayerHandleBallThrow(void) +{ + u8 var = gBattleBufferA[gActiveBank][1]; + + ewram17840.unk8 = var; + gDoingBattleAnim = 1; + move_anim_start_t4(gActiveBank, gActiveBank, GetBankByPlayerAI(1), 3); + gBattleBankFunc[gActiveBank] = bx_wait_t1; +} + +void PlayerHandlePuase(void) +{ + u8 var = gBattleBufferA[gActiveBank][1]; + + // WTF is this?? + while (var != 0) + var--; + + PlayerBufferExecCompleted(); +} + +void PlayerHandleMoveAnimation(void) +{ + if (!mplay_80342A4(gActiveBank)) + { + u16 r0 = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + + gUnknown_0202F7C4 = gBattleBufferA[gActiveBank][3]; + gMovePowerMoveAnim = gBattleBufferA[gActiveBank][4] | (gBattleBufferA[gActiveBank][5] << 8); + gMoveDmgMoveAnim = gBattleBufferA[gActiveBank][6] | (gBattleBufferA[gActiveBank][7] << 8) | (gBattleBufferA[gActiveBank][8] << 16) | (gBattleBufferA[gActiveBank][9] << 24); + gHappinessMoveAnim = gBattleBufferA[gActiveBank][10]; + gWeatherMoveAnim = gBattleBufferA[gActiveBank][12] | (gBattleBufferA[gActiveBank][13] << 8); + gDisableStructMoveAnim = (u32 *)&gBattleBufferA[gActiveBank][16]; + gPID_perBank[gActiveBank] = *gDisableStructMoveAnim; + if (sub_8031720(r0, gUnknown_0202F7C4) != 0) + { + // Dead code. sub_8031720 always returns 0. + PlayerBufferExecCompleted(); + } + else + { + ewram17810[gActiveBank].unk4 = 0; + gBattleBankFunc[gActiveBank] = sub_8030190; + } + } +} + +void sub_8030190(void) +{ + u16 r4 = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + u8 r7 = gBattleBufferA[gActiveBank][11]; + + switch (ewram17810[gActiveBank].unk4) + { + case 0: + if (ewram17800[gActiveBank].unk0_2 == 1 && ewram17800[gActiveBank].unk0_3 == 0) + { + ewram17800[gActiveBank].unk0_3 = 1; + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 5); + } + ewram17810[gActiveBank].unk4 = 1; + break; + case 1: + if (ewram17810[gActiveBank].unk0_6 == 0) + { + sub_80326EC(0); + ExecuteMoveAnim(r4); + ewram17810[gActiveBank].unk4 = 2; + } + break; + case 2: + gAnimScriptCallback(); + if (!gAnimScriptActive) + { + sub_80326EC(1); + if (ewram17800[gActiveBank].unk0_2 == 1 && r7 < 2) + { + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 6); + ewram17800[gActiveBank].unk0_3 = 0; + } + ewram17810[gActiveBank].unk4 = 3; + } + break; + case 3: + if (ewram17810[gActiveBank].unk0_6 == 0) + { + sub_8031F24(); + sub_80324BC(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + ewram17810[gActiveBank].unk4 = 0; + PlayerBufferExecCompleted(); + } + break; + } +} + +void PlayerHandlePrintString(void) +{ + gUnknown_030042A4 = 0; + gUnknown_030042A0 = 0; + BufferStringBattle(*(u16 *)&gBattleBufferA[gActiveBank][2]); + sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 0x90, 2, 15); + gBattleBankFunc[gActiveBank] = sub_802DF18; +} + +void PlayerHandlePrintStringPlayerOnly(void) +{ + if (GetBankSide(gActiveBank) == 0) + PlayerHandlePrintString(); + else + PlayerBufferExecCompleted(); +} + +void sub_803037C(void) +{ + int r4; + + gUnknown_030042A4 = 0; + gUnknown_030042A0 = 160; + FillWindowRect(&gUnknown_03004210, 10, 2, 15, 27, 18); + FillWindowRect(&gUnknown_03004210, 10, 2, 35, 16, 38); + + gBattleBankFunc[gActiveBank] = sub_802C098; + + InitWindow(&gUnknown_03004210, gUnknown_08400CF3, 400, 18, 35); + sub_8002F44(&gUnknown_03004210); + sub_814A5C0(0, 0xFFFF, 12, 11679, 0); + + for (r4 = 0; r4 < 4; r4++) + nullsub_8(r4); + + sub_802E3E4(gActionSelectionCursor[gActiveBank], 0); + + StrCpyDecodeToDisplayedStringBattle((u8 *) gUnknown_08400CA8); + InitWindow(&gUnknown_03004210, gDisplayedStringBattle, SUB_803037C_TILE_DATA_OFFSET, 2, 35); + sub_8002F44(&gUnknown_03004210); +} + +void nullsub_42() +{ +} + +void sub_8030468(void) +{ + sub_814A5C0(0, 0xFFFF, 12, 0x2D9F, 0); + sub_80304A8(); + gBattleBankFunc[gActiveBank] = sub_802C68C; +} + +void sub_80304A8(void) +{ + gUnknown_030042A4 = 0; + gUnknown_030042A0 = 320; + sub_802E1B0(); + gUnknown_03004344 = 0xFF; + sub_802E3B4(gMoveSelectionCursor[gActiveBank], 0); + if (gBattleBufferA[gActiveBank][2] != 1) + { + InitWindow(&gUnknown_03004210, gUnknown_08400D38, 656, 23, 55); + sub_8002F44(&gUnknown_03004210); + } + sub_802E220(); + sub_802E2D4(); +} + +void PlayerHandleOpenBag(void) +{ + s32 i; + + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gBattleBankFunc[gActiveBank] = sub_802E004; + gBankInMenu = gActiveBank; + for (i = 0; i < 3; i++) + gUnknown_02038470[i] = gBattleBufferA[gActiveBank][1 + i]; +} + +void sub_8030594(void) +{ + s32 i; + + gUnknown_0300434C[gActiveBank] = CreateTask(TaskDummy, 0xFF); + gTasks[gUnknown_0300434C[gActiveBank]].data[0] = gBattleBufferA[gActiveBank][1] & 0xF; + ewram[0x16054] = gBattleBufferA[gActiveBank][1] >> 4; + ewram[0x1609D] = gBattleBufferA[gActiveBank][2]; + ewram[0x160C0] = gBattleBufferA[gActiveBank][3]; + for (i = 0; i < 3; i++) + gUnknown_02038470[i] = gBattleBufferA[gActiveBank][4 + i]; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gBattleBankFunc[gActiveBank] = sub_802DF30; + gBankInMenu = gActiveBank; +} + +void sub_8030674(void) +{ + sub_80325B8(); + BeginNormalPaletteFade(0xFFFFFFFF, 2, 0, 16, 0); + PlayerBufferExecCompleted(); +} + +void PlayerHandleHealthBarUpdate(void) +{ + s16 r7; + + load_gfxc_health_bar(0); + r7 = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + if (r7 != 0x7FFF) + { + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + + sub_8043D84(gActiveBank, gHealthboxIDs[gActiveBank], maxHP, curHP, r7); + } + else + { + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + + sub_8043D84(gActiveBank, gHealthboxIDs[gActiveBank], maxHP, 0, r7); + sub_80440EC(gHealthboxIDs[gActiveBank], 0, 0); + } + gBattleBankFunc[gActiveBank] = bx_t1_healthbar_update; +} + +void PlayerHandleExpBarUpdate(void) +{ + u8 r7 = gBattleBufferA[gActiveBank][1]; + + if (GetMonData(&gPlayerParty[r7], MON_DATA_LEVEL) >= 100) + { + PlayerBufferExecCompleted(); + } + else + { + u16 r4; + u8 taskId; + + load_gfxc_health_bar(1); + GetMonData(&gPlayerParty[r7], MON_DATA_SPECIES); // unused return value + r4 = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + taskId = CreateTask(sub_802D924, 10); + gTasks[taskId].data[0] = r7; + gTasks[taskId].data[1] = r4; + gTasks[taskId].data[2] = gActiveBank; + gBattleBankFunc[gActiveBank] = nullsub_91; + } +} + +void PlayerHandleStatusIconUpdate(void) +{ + if (!mplay_80342A4(gActiveBank)) + { + sub_8045A5C(gHealthboxIDs[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], 9); + ewram17810[gActiveBank].unk0_4 = 0; + gBattleBankFunc[gActiveBank] = sub_802E434; + } +} + +void PlayerHandleStatusAnimation(void) +{ + if (!mplay_80342A4(gActiveBank)) + { + move_anim_start_t2_for_situation( + gBattleBufferA[gActiveBank][1], + gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); + gBattleBankFunc[gActiveBank] = sub_802E434; + } +} + +void PlayerHandleStatusXor(void) +{ + u8 val = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_STATUS) ^ gBattleBufferA[gActiveBank][1]; + + SetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_STATUS, &val); + PlayerBufferExecCompleted(); +} + +void sub_803097C(void) +{ + PlayerBufferExecCompleted(); +} + +void PlayerHandleDMATransfer(void) +{ + u32 val1 = gBattleBufferA[gActiveBank][1] + | (gBattleBufferA[gActiveBank][2] << 8) + | (gBattleBufferA[gActiveBank][3] << 16) + | (gBattleBufferA[gActiveBank][4] << 24); + u16 val2 = gBattleBufferA[gActiveBank][5] | (gBattleBufferA[gActiveBank][6] << 8); + + const u8 *src = &gBattleBufferA[gActiveBank][7]; + u8 *dst = (u8 *)val1; + u32 size = val2; + + while (1) + { + if (size <= 0x1000) + { + DmaCopy16(3, src, dst, size); + break; + } + DmaCopy16(3, src, dst, 0x1000); + src += 0x1000; + dst += 0x1000; + size -= 0x1000; + } + PlayerBufferExecCompleted(); +} + +void sub_8030A3C(void) +{ + PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayerBufferExecCompleted(); +} + +void sub_8030A6C(void) +{ + PlayerBufferExecCompleted(); +} + +void sub_8030A78(void) +{ + dp01_build_cmdbuf_x21_a_bb(1, 0, 0); + PlayerBufferExecCompleted(); +} + +void sub_8030A8C(void) +{ + dp01_build_cmdbuf_x22_a_three_bytes(1, 0, 0); + PlayerBufferExecCompleted(); +} + +void sub_8030AA0(void) +{ + dp01_build_cmdbuf_x23_aa_0(1, 0); + PlayerBufferExecCompleted(); +} + +void sub_8030AB4(void) +{ + dp01_build_cmdbuf_x24_aa_0(1, 0); + PlayerBufferExecCompleted(); +} + +void sub_8030AC8(void) +{ + gUnknown_020238C8.unk0_0 = 0; + PlayerBufferExecCompleted(); +} + +void sub_8030AE4(void) +{ + gUnknown_020238C8.unk0_0 = gBattleBufferA[gActiveBank][1]; + PlayerBufferExecCompleted(); +} + +void sub_8030B1C(void) +{ + gUnknown_020238C8.unk0_7 = 0; + PlayerBufferExecCompleted(); +} + +void sub_8030B34(void) +{ + gUnknown_020238C8.unk0_7 ^= 1; + PlayerBufferExecCompleted(); +} + +void PlayerHandleHitAnimation(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].invisible == TRUE) + { + PlayerBufferExecCompleted(); + } + else + { + gDoingBattleAnim = 1; + gSprites[gObjectBankIDs[gActiveBank]].data1 = 0; + sub_8047858(gActiveBank); + gBattleBankFunc[gActiveBank] = bx_blink_t1; + } +} + +void sub_8030BCC(void) +{ + PlayerBufferExecCompleted(); +} + +void PlayerHandleEffectivenessSound(void) +{ + s8 pan; + + if (GetBankSide(gActiveBank) == 0) + pan = -64; + else + pan = 63; + PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan); + PlayerBufferExecCompleted(); +} + +void sub_8030C1C(void) +{ + PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayerBufferExecCompleted(); +} + +void PlayerHandleFaintingCry(void) +{ + u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + + PlayCry3(species, -25, 5); + PlayerBufferExecCompleted(); +} + +void PlayerHandleIntroSlide(void) +{ + sub_80E43C0(gBattleBufferA[gActiveBank][1]); + gUnknown_02024DE8 |= 1; + PlayerBufferExecCompleted(); +} + +void PlayerHandleTrainerBallThrow(void) +{ + u8 paletteNum; + u8 taskId; + + oamt_add_pos2_onto_pos1(&gSprites[gObjectBankIDs[gActiveBank]]); + gSprites[gObjectBankIDs[gActiveBank]].data0 = 50; + gSprites[gObjectBankIDs[gActiveBank]].data2 = -40; + gSprites[gObjectBankIDs[gActiveBank]].data4 = gSprites[gObjectBankIDs[gActiveBank]].pos1.y; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_8078B34; + gSprites[gObjectBankIDs[gActiveBank]].data5 = gActiveBank; + oamt_set_x3A_32(&gSprites[gObjectBankIDs[gActiveBank]], sub_8030E38); + StartSpriteAnim(&gSprites[gObjectBankIDs[gActiveBank]], 1); + paletteNum = AllocSpritePalette(0xD6F8); + LoadCompressedPalette(gTrainerBackPicPaletteTable[gSaveBlock2.playerGender].data, 0x100 + paletteNum * 16, 32); + gSprites[gObjectBankIDs[gActiveBank]].oam.paletteNum = paletteNum; + taskId = CreateTask(task05_08033660, 5); + gTasks[taskId].data[0] = gActiveBank; + if (ewram17810[gActiveBank].unk0_0) + gTasks[gUnknown_02024E68[gActiveBank]].func = sub_8044CA0; + ewram17810[4].unk9 |= 1; + gBattleBankFunc[gActiveBank] = nullsub_91; +} + +void sub_8030E38(struct Sprite *sprite) +{ + u8 r4 = sprite->data5; + + FreeSpriteOamMatrix(sprite); + FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum)); + DestroySprite(sprite); + sub_80318FC(&gPlayerParty[gBattlePartyID[r4]], r4); + StartSpriteAnim(&gSprites[gObjectBankIDs[r4]], 0); +} + +void task05_08033660(u8 taskId) +{ + if (gTasks[taskId].data[1] < 31) + { + gTasks[taskId].data[1]++; + } + else + { + u8 savedActiveBank = gActiveBank; + + gActiveBank = gTasks[taskId].data[0]; + if (!IsDoubleBattle() || (gBattleTypeFlags & 0x40)) + { + gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; + sub_802F934(gActiveBank, 0); + } + else + { + gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; + sub_802F934(gActiveBank, 0); + gActiveBank ^= 2; + gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; + sub_80318FC(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + sub_802F934(gActiveBank, 0); + gActiveBank ^= 2; + } + gBattleBankFunc[gActiveBank] = sub_802D500; + gActiveBank = savedActiveBank; + DestroyTask(taskId); + } +} + +void sub_8030FAC(void) +{ + if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == 0) + { + PlayerBufferExecCompleted(); + } + else + { + ewram17810[gActiveBank].unk0_0 = 1; + gUnknown_02024E68[gActiveBank] = sub_8044804(gActiveBank, (struct BattleInterfaceStruct2 *)&gBattleBufferA[gActiveBank][4], gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2]); + ewram17810[gActiveBank].unk5 = 0; + if (gBattleBufferA[gActiveBank][2] != 0) + ewram17810[gActiveBank].unk5 = 0x5D; + gBattleBankFunc[gActiveBank] = sub_8031064; + } +} + +void sub_8031064(void) +{ + if (ewram17810[gActiveBank].unk5++ > 0x5C) + { + ewram17810[gActiveBank].unk5 = 0; + PlayerBufferExecCompleted(); + } +} + +void sub_80310A4(void) +{ + if (ewram17810[gActiveBank].unk0_0) + gTasks[gUnknown_02024E68[gActiveBank]].func = sub_8044CA0; + PlayerBufferExecCompleted(); +} + +void sub_80310F0(void) +{ + dp11b_obj_free(gActiveBank, 1); + dp11b_obj_free(gActiveBank, 0); + PlayerBufferExecCompleted(); +} + +void PlayerHandleSpriteInvisibility(void) +{ + if (sub_8078874(gActiveBank)) + { + gSprites[gObjectBankIDs[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; + sub_8031F88(gActiveBank); + } + PlayerBufferExecCompleted(); +} + +void PlayerHandleBattleAnimation(void) +{ + if (!mplay_80342A4(gActiveBank)) + { + u8 val2 = gBattleBufferA[gActiveBank][1]; + u16 val = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + + if (move_anim_start_t3(gActiveBank, gActiveBank, gActiveBank, val2, val)) + PlayerBufferExecCompleted(); + else + gBattleBankFunc[gActiveBank] = sub_802E460; + } +} + +void PlayerHandleLinkStandbyMsg(void) +{ + switch (gBattleBufferA[gActiveBank][1]) + { + case 0: + b_link_standby_message(); + // fall through + case 1: + dp11b_obj_free(gActiveBank, 1); + dp11b_obj_free(gActiveBank, 0); + break; + case 2: + b_link_standby_message(); + break; + } + PlayerBufferExecCompleted(); +} + +void PlayerHandleResetActionMoveSelection(void) +{ + switch (gBattleBufferA[gActiveBank][1]) + { + case 0: + gActionSelectionCursor[gActiveBank] = 0; + gMoveSelectionCursor[gActiveBank] = 0; + break; + case 1: + gActionSelectionCursor[gActiveBank] = 0; + break; + case 2: + gMoveSelectionCursor[gActiveBank] = 0; + break; + } + PlayerBufferExecCompleted(); +} + +void sub_80312A0(void) +{ + gBattleOutcome = gBattleBufferA[gActiveBank][1]; + FadeOutMapMusic(5); + BeginFastPaletteFade(3); + PlayerBufferExecCompleted(); + gBattleBankFunc[gActiveBank] = sub_802D18C; +} + +void nullsub_43(void) +{ +} diff --git a/src/battle_7.c b/src/battle_7.c new file mode 100644 index 000000000..a93237608 --- /dev/null +++ b/src/battle_7.c @@ -0,0 +1,1235 @@ +#include "global.h" +#include "battle.h" +#include "battle_anim.h" +#include "battle_interface.h" +#include "blend_palette.h" +#include "data2.h" +#include "decompress.h" +#include "main.h" +#include "m4a.h" +#include "palette.h" +#include "pokemon.h" +#include "rom_8077ABC.h" +#include "rom_8094928.h" +#include "songs.h" +#include "sound.h" +#include "species.h" +#include "sprite.h" +#include "task.h" +#include "text.h" +#include "gba/m4a_internal.h" + +struct Struct2019348 +{ + u8 filler0[2]; + u16 unk2; + u8 filler4[4]; + u32 unk8; + u32 unkC; + u32 unk10; +}; + +extern u8 gBattleBufferA[][0x200]; +extern u8 gActiveBank; +extern u32 gBattleExecBuffer; +extern u8 gNoOfAllBanks; +extern u16 gBattlePartyID[]; +extern u8 gBanksBySide[]; +extern u8 gObjectBankIDs[]; +extern u16 gUnknown_02024DE8; +extern u8 gDoingBattleAnim; +extern u32 gPID_perBank[]; +extern struct Window gUnknown_03004210; +extern void (*gBattleBankFunc[])(void); +extern u8 gHealthboxIDs[]; +extern u8 gUnknown_0300434C[]; +extern struct MusicPlayerInfo gMPlay_SE1; +extern struct MusicPlayerInfo gMPlay_SE2; +extern struct MusicPlayerInfo gMPlay_BGM; +extern u32 gBitTable[]; +extern u16 gBattleTypeFlags; +extern u8 gBattleMonForms[]; +extern u8 gBattleAnimPlayerMonIndex; +extern u8 gBattleAnimEnemyMonIndex; +extern void (*gAnimScriptCallback)(void); +extern u8 gAnimScriptActive; +extern const u8 *const gBattleAnims_Unknown1[]; +extern const u8 *const gBattleAnims_Unknown2[]; +extern const struct CompressedSpriteSheet gTrainerFrontPicTable[]; +extern const struct MonCoords gTrainerFrontPicCoords[]; +extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[]; +extern const u8 gSubstituteDollTilemap[]; +extern const u8 gSubstituteDollGfx[]; +extern const u8 gSubstituteDollPal[]; +extern const struct CompressedSpriteSheet gUnknown_081FAF24; +extern const struct SpriteTemplate gSpriteTemplate_81FAF34; +extern void (*const gOpponentBufferCommands[])(void); +extern const struct CompressedSpriteSheet gUnknown_0820A47C; +extern const struct CompressedSpriteSheet gUnknown_0820A484; +extern const struct CompressedSpriteSheet gUnknown_0820A48C[]; +extern const struct CompressedSpriteSheet gUnknown_0820A49C[]; +extern const struct CompressedSpriteSheet gUnknown_0820A4AC; +extern const struct CompressedSpriteSheet gUnknown_0820A4B4[]; +extern const struct SpritePalette gUnknown_0820A4D4[]; +extern const u8 gUnknown_08D09C48[]; + +#define ewram19348 (*(struct Struct2019348 *)(ewram + 0x19348)) + +extern void c3_0802FDF4(u8); +extern void sub_80440EC(); +extern void sub_804777C(); +extern void sub_8141828(); +extern u8 sub_8077ABC(); +extern u8 sub_8078874(u8); +extern u8 sub_8077F68(u8); +extern u8 sub_8077F7C(u8); +extern void sub_8094958(void); +extern void sub_80105DC(struct Sprite *); +extern void move_anim_start_t2(); + +void sub_80315E8(u8); +u8 sub_803163C(u8); +void sub_80316CC(u8); +void sub_8031F0C(void); +void refresh_graphics_maybe(u8, u8, u8); +void sub_80324E0(u8 a); +void sub_80327CC(void); +void sub_8032978(struct Sprite *); +void sub_80328A4(struct Sprite *); +void OpponentBufferRunCommand(void); +void sub_80332D0(void); +void OpponentBufferExecCompleted(void); + +void sub_80312F0(struct Sprite *sprite) +{ + u8 spriteId = sprite->data1; + + if (gSprites[spriteId].affineAnimEnded && !gSprites[spriteId].invisible) + { + if (gSprites[spriteId].animPaused) + gSprites[spriteId].animPaused = FALSE; + else if (gSprites[spriteId].animEnded) + { + gSprites[spriteId].callback = sub_80105DC; + StartSpriteAffineAnim(&gSprites[spriteId], 0); + sprite->callback = SpriteCallbackDummy; + } + } +} + +void unref_sub_8031364(struct Sprite *sprite, bool8 stupid) +{ + sprite->animPaused = TRUE; + sprite->callback = SpriteCallbackDummy; + if (!stupid) + StartSpriteAffineAnim(sprite, 1); + else + StartSpriteAffineAnim(sprite, 1); + AnimateSprite(sprite); +} + +void sub_80313A0(struct Sprite *sprite) +{ + if (!(gUnknown_02024DE8 & 1)) + { + sprite->pos2.x += sprite->data0; + if (sprite->pos2.x == 0) + sprite->callback = SpriteCallbackDummy; + } +} + +void move_anim_start_t2_for_situation(u8 a, u32 b) +{ + ewram17810[gActiveBank].unk0_4 = 1; + if (a == 0) + { + if (b == 0x20) + move_anim_start_t2(gActiveBank, 6); + else if (b == 8 || (b & 0x80)) + move_anim_start_t2(gActiveBank, 0); + else if (b == 0x10) + move_anim_start_t2(gActiveBank, 2); + else if (b & 7) + move_anim_start_t2(gActiveBank, 4); + else if (b == 0x40) + move_anim_start_t2(gActiveBank, 5); + else + ewram17810[gActiveBank].unk0_4 = 0; + } + else + { + if (b & 0x000F0000) + move_anim_start_t2(gActiveBank, 3); + else if (b & 7) + move_anim_start_t2(gActiveBank, 1); + else if (b & 0x10000000) + move_anim_start_t2(gActiveBank, 7); + else if (b & 0x08000000) + move_anim_start_t2(gActiveBank, 8); + else if (b & 0x0000E000) + move_anim_start_t2(gActiveBank, 9); + else + ewram17810[gActiveBank].unk0_4 = 0; + } +} + +bool8 move_anim_start_t3(u8 a, u8 b, u8 c, u8 d, u16 e) +{ + u8 taskId; + + if (d == 0 && (e & 0x80)) + { + gBattleMonForms[a] = e & 0x7F; + return TRUE; + } + if (ewram17800[a].unk0_2 && sub_803163C(d) == 0) + return TRUE; + if (ewram17800[a].unk0_2 && d == 2 && gSprites[gObjectBankIDs[a]].invisible) + { + refresh_graphics_maybe(a, 1, gObjectBankIDs[a]); + sub_80324E0(a); + return TRUE; + } + gBattleAnimPlayerMonIndex = b; + gBattleAnimEnemyMonIndex = c; + ewram17840.unk0 = e; + DoMoveAnim(gBattleAnims_Unknown1, d, 0); + taskId = CreateTask(sub_80315E8, 10); + gTasks[taskId].data[0] = a; + ewram17810[gTasks[taskId].data[0]].unk0_5 = 1; + return FALSE; +} + +void sub_80315E8(u8 taskId) +{ + gAnimScriptCallback(); + if (!gAnimScriptActive) + { + ewram17810[gTasks[taskId].data[0]].unk0_5 = 0; + DestroyTask(taskId); + } +} + +u8 sub_803163C(u8 a) +{ + switch (a) + { + case 2: + case 10: + case 11: + case 12: + case 13: + case 17: + return 1; + default: + return 0; + } +} + +void move_anim_start_t4(u8 a, u8 b, u8 c, u8 d) +{ + u8 taskId; + + gBattleAnimPlayerMonIndex = b; + gBattleAnimEnemyMonIndex = c; + DoMoveAnim(gBattleAnims_Unknown2, d, 0); + taskId = CreateTask(sub_80316CC, 10); + gTasks[taskId].data[0] = a; + ewram17810[gTasks[taskId].data[0]].unk0_6 = 1; +} + +void sub_80316CC(u8 taskId) +{ + gAnimScriptCallback(); + if (!gAnimScriptActive) + { + ewram17810[gTasks[taskId].data[0]].unk0_6 = 0; + DestroyTask(taskId); + } +} + +u8 sub_8031720(int unused1, int unused2) +{ + return 0; +} + +bool8 mplay_80342A4(u8 a) +{ + u8 zero = 0; + + if (IsSEPlaying()) + { + ewram17810[a].unk8++; + if (ewram17810[gActiveBank].unk8 < 30) + return TRUE; + m4aMPlayStop(&gMPlay_SE1); + m4aMPlayStop(&gMPlay_SE2); + } + if (zero == 0) + { + ewram17810[a].unk8 = 0; + return FALSE; + } + return TRUE; +} + +void sub_8031794(struct Pokemon *pkmn, u8 b) +{ + u32 personalityValue; + u16 species; + u32 r7; + u32 otId; + u8 var; + u16 paletteOffset; + const u8 *lzPaletteData; + + personalityValue = GetMonData(pkmn, MON_DATA_PERSONALITY); + if (ewram17800[b].unk2 == 0) + { + species = GetMonData(pkmn, MON_DATA_SPECIES); + r7 = personalityValue; + } + else + { + species = ewram17800[b].unk2; + r7 = gPID_perBank[b]; + } + otId = GetMonData(pkmn, MON_DATA_OT_ID); + var = GetBankIdentity(b); + HandleLoadSpecialPokePic( + &gMonFrontPicTable[species], + gMonFrontPicCoords[species].coords, + gMonFrontPicCoords[species].y_offset, + 0x02000000, + gUnknown_081FAF4C[var], + species, + r7); + paletteOffset = 0x100 + b * 16; + if (ewram17800[b].unk2 == 0) + lzPaletteData = pokemon_get_pal(pkmn); + else + lzPaletteData = species_and_otid_get_pal(species, otId, personalityValue); + sub_800D238(lzPaletteData, ewram); + LoadPalette(ewram, paletteOffset, 0x20); + LoadPalette(ewram, 0x80 + b * 16, 0x20); + if (species == SPECIES_CASTFORM) + { + paletteOffset = 0x100 + b * 16; + sub_800D238(lzPaletteData, ewram + 0x16400); + LoadPalette(ewram + 0x16400 + gBattleMonForms[b] * 32, paletteOffset, 0x20); + } + if (ewram17800[b].unk2 != 0) + { + BlendPalette(paletteOffset, 16, 6, 0x7FFF); + CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); + } +} + +void sub_80318FC(struct Pokemon *pkmn, u8 b) +{ + u32 personalityValue; + u16 species; + u32 r7; + u32 otId; + u8 var; + u16 paletteOffset; + const u8 *lzPaletteData; + + personalityValue = GetMonData(pkmn, MON_DATA_PERSONALITY); + if (ewram17800[b].unk2 == 0) + { + species = GetMonData(pkmn, MON_DATA_SPECIES); + r7 = personalityValue; + } + else + { + species = ewram17800[b].unk2; + r7 = gPID_perBank[b]; + } + otId = GetMonData(pkmn, MON_DATA_OT_ID); + var = GetBankIdentity(b); + HandleLoadSpecialPokePic( + &gMonBackPicTable[species], + gMonBackPicCoords[species].coords, + gMonBackPicCoords[species].y_offset, + 0x02000000, + gUnknown_081FAF4C[var], + species, + r7); + paletteOffset = 0x100 + b * 16; + if (ewram17800[b].unk2 == 0) + lzPaletteData = pokemon_get_pal(pkmn); + else + lzPaletteData = species_and_otid_get_pal(species, otId, personalityValue); + sub_800D238(lzPaletteData, ewram); + LoadPalette(ewram, paletteOffset, 0x20); + LoadPalette(ewram, 0x80 + b * 16, 0x20); + if (species == SPECIES_CASTFORM) + { + paletteOffset = 0x100 + b * 16; + sub_800D238(lzPaletteData, ewram + 0x16400); + LoadPalette(ewram + 0x16400 + gBattleMonForms[b] * 32, paletteOffset, 0x20); + } + if (ewram17800[b].unk2 != 0) + { + BlendPalette(paletteOffset, 16, 6, 0x7FFF); + CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); + } +} + +void unref_sub_8031A64(void) +{ +} + +void nullsub_9(u16 unused) +{ +} + +void sub_8031A6C(u16 a, u8 b) +{ + u8 status; + struct CompressedSpriteSheet spriteSheet; + + status = GetBankIdentity(b); + DecompressPicFromTable_2( + &gTrainerFrontPicTable[a], + gTrainerFrontPicCoords[a].coords, + gTrainerFrontPicCoords[a].y_offset, + (void *)0x02000000, + gUnknown_081FAF4C[status], + 0); + spriteSheet.data = gUnknown_081FAF4C[status]; + spriteSheet.size = gTrainerFrontPicTable[a].size; + spriteSheet.tag = gTrainerFrontPicTable[a].tag; + LoadCompressedObjectPic(&spriteSheet); + LoadCompressedObjectPalette(&gTrainerFrontPicPaletteTable[a]); +} + +void sub_8031AF4(u16 a, u8 b) +{ + u8 status; + + status = GetBankIdentity(b); + DecompressPicFromTable_2( + &gTrainerBackPicTable[a], + gTrainerBackPicCoords[a].coords, + gTrainerBackPicCoords[a].y_offset, + (void *)0x02000000, + gUnknown_081FAF4C[status], + 0); + LoadCompressedPalette(gTrainerBackPicPaletteTable[a].data, 0x100 + b * 16, 32); +} + +void nullsub_10(int unused) +{ +} + +void sub_8031B74(u16 a) +{ + FreeSpritePaletteByTag(gTrainerFrontPicPaletteTable[a].tag); + FreeSpriteTilesByTag(gTrainerFrontPicTable[a].tag); +} + +void unref_sub_8031BA0(void) +{ + u8 count; + u8 i; + + LoadSpritePalette(&gUnknown_0820A4D4[0]); + LoadSpritePalette(&gUnknown_0820A4D4[1]); + if (!IsDoubleBattle()) + { + LoadCompressedObjectPic(&gUnknown_0820A47C); + LoadCompressedObjectPic(&gUnknown_0820A484); + count = 2; + } + else + { + LoadCompressedObjectPic(&gUnknown_0820A48C[0]); + LoadCompressedObjectPic(&gUnknown_0820A48C[1]); + LoadCompressedObjectPic(&gUnknown_0820A49C[0]); + LoadCompressedObjectPic(&gUnknown_0820A49C[1]); + count = 4; + } + for (i = 0; i < count; i++) + LoadCompressedObjectPic(&gUnknown_0820A4B4[gBanksBySide[i]]); +} + +bool8 sub_8031C30(u8 a) +{ + bool8 retVal = FALSE; + + if (a != 0) + { + if (a == 1) + { + LoadSpritePalette(&gUnknown_0820A4D4[0]); + LoadSpritePalette(&gUnknown_0820A4D4[1]); + } + else if (!IsDoubleBattle()) + { + if (a == 2) + { + if (gBattleTypeFlags & 0x80) + LoadCompressedObjectPic(&gUnknown_0820A4AC); + else + LoadCompressedObjectPic(&gUnknown_0820A47C); + } + else if (a == 3) + LoadCompressedObjectPic(&gUnknown_0820A484); + else if (a == 4) + LoadCompressedObjectPic(&gUnknown_0820A4B4[gBanksBySide[0]]); + else if (a == 5) + LoadCompressedObjectPic(&gUnknown_0820A4B4[gBanksBySide[1]]); + else + retVal = TRUE; + } + else + { + if (a == 2) + LoadCompressedObjectPic(&gUnknown_0820A48C[0]); + else if (a == 3) + LoadCompressedObjectPic(&gUnknown_0820A48C[1]); + else if (a == 4) + LoadCompressedObjectPic(&gUnknown_0820A49C[0]); + else if (a == 5) + LoadCompressedObjectPic(&gUnknown_0820A49C[1]); + else if (a == 6) + LoadCompressedObjectPic(&gUnknown_0820A4B4[gBanksBySide[0]]); + else if (a == 7) + LoadCompressedObjectPic(&gUnknown_0820A4B4[gBanksBySide[1]]); + else if (a == 8) + LoadCompressedObjectPic(&gUnknown_0820A4B4[gBanksBySide[2]]); + else if (a == 9) + LoadCompressedObjectPic(&gUnknown_0820A4B4[gBanksBySide[3]]); + else + retVal = TRUE; + } + } + return retVal; +} + +void load_gfxc_health_bar(void) +{ + sub_800D238(gUnknown_08D09C48, (void *)0x02000000); +} + +u8 battle_load_something(u8 *pState, u8 *b) +{ + bool8 retVal = FALSE; + + switch (*pState) + { + case 0: + sub_8031F0C(); + (*pState)++; + break; + case 1: + if (sub_8031C30(*b) == 0) + { + (*b)++; + } + else + { + *b = 0; + (*pState)++; + } + break; + case 2: + (*pState)++; + break; + case 3: + if ((gBattleTypeFlags & 0x80) && *b == 0) + gHealthboxIDs[*b] = battle_make_oam_safari_battle(); + else + gHealthboxIDs[*b] = battle_make_oam_normal_battle(*b); + (*b)++; + if (*b == gNoOfAllBanks) + { + *b = 0; + (*pState)++; + } + break; + case 4: + sub_8043F44(*b); + if (gBanksBySide[*b] <= 1) + nullsub_11(gHealthboxIDs[*b], 0); + else + nullsub_11(gHealthboxIDs[*b], 1); + (*b)++; + if (*b == gNoOfAllBanks) + { + *b = 0; + (*pState)++; + } + break; + case 5: + if (GetBankSide(*b) == 0) + { + if (!(gBattleTypeFlags & 0x80)) + sub_8045A5C(gHealthboxIDs[*b], &gPlayerParty[gBattlePartyID[*b]], 0); + } + else + { + sub_8045A5C(gHealthboxIDs[*b], &gEnemyParty[gBattlePartyID[*b]], 0); + } + sub_8043DB0(gHealthboxIDs[*b]); + (*b)++; + if (*b == gNoOfAllBanks) + { + *b = 0; + (*pState)++; + } + break; + case 6: + sub_80327CC(); + sub_8094958(); + retVal = TRUE; + break; + } + return retVal; +} + +void sub_8031EE8(void) +{ + memset(ewram17810, 0, 0x30); + memset(&ewram17840, 0, 0x10); +} + +void sub_8031F0C(void) +{ + sub_8031EE8(); + memset(ewram17800, 0, 0x10); +} + +void sub_8031F24(void) +{ + s32 i; + + for (i = 0; i < gNoOfAllBanks; i++) + ewram17800[i].unk0_0 = gSprites[gObjectBankIDs[i]].invisible; +} + +void sub_8031F88(u8 a) +{ + ewram17800[a].unk0_0 = gSprites[gObjectBankIDs[a]].invisible; +} + +void sub_8031FC4(u8 a, u8 b, bool8 c) +{ + u16 paletteOffset; + u16 species; + u32 personalityValue; + u32 otId; + u8 r10; + const u8 *lzPaletteData; + + if (c) + { + StartSpriteAnim(&gSprites[gObjectBankIDs[a]], ewram17840.unk0); + paletteOffset = 0x100 + a * 16; + LoadPalette(ewram + 0x16400 + ewram17840.unk0 * 32, paletteOffset, 32); + gBattleMonForms[a] = ewram17840.unk0; + if (ewram17800[a].unk2 != 0) + { + BlendPalette(paletteOffset, 16, 6, 0x7FFF); + CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); + } + gSprites[gObjectBankIDs[a]].pos1.y = sub_8077F68(a); + } + else + { + const void *src; + void *dst; + + if (IsContest()) + { + r10 = 0; + species = ewram19348.unk2; + personalityValue = ewram19348.unk8; + otId = ewram19348.unkC; + HandleLoadSpecialPokePic( + &gMonBackPicTable[species], + gMonBackPicCoords[species].coords, + gMonBackPicCoords[species].y_offset, + 0x02000000, + gUnknown_081FAF4C[0], + species, + ewram19348.unk10); + } + else + { + r10 = GetBankIdentity(a); + if (GetBankSide(b) == 1) + species = GetMonData(&gEnemyParty[gBattlePartyID[b]], MON_DATA_SPECIES); + else + species = GetMonData(&gPlayerParty[gBattlePartyID[b]], MON_DATA_SPECIES); + if (GetBankSide(a) == 0) + { + personalityValue = GetMonData(&gPlayerParty[gBattlePartyID[a]], MON_DATA_PERSONALITY); + otId = GetMonData(&gPlayerParty[gBattlePartyID[a]], MON_DATA_OT_ID); + HandleLoadSpecialPokePic( + &gMonBackPicTable[species], + gMonBackPicCoords[species].coords, + gMonBackPicCoords[species].y_offset, + 0x02000000, + gUnknown_081FAF4C[r10], + species, + gPID_perBank[a]); + } + else + { + personalityValue = GetMonData(&gEnemyParty[gBattlePartyID[a]], MON_DATA_PERSONALITY); + otId = GetMonData(&gEnemyParty[gBattlePartyID[a]], MON_DATA_OT_ID); + HandleLoadSpecialPokePic( + &gMonFrontPicTable[species], + gMonFrontPicCoords[species].coords, + gMonFrontPicCoords[species].y_offset, + 0x02000000, + gUnknown_081FAF4C[r10], + species, + gPID_perBank[a]); + } + } + src = gUnknown_081FAF4C[r10]; + dst = (void *)(VRAM + 0x10000 + gSprites[gObjectBankIDs[a]].oam.tileNum * 32); + DmaCopy32(3, src, dst, 0x800); + paletteOffset = 0x100 + a * 16; + lzPaletteData = species_and_otid_get_pal(species, otId, personalityValue); + sub_800D238(lzPaletteData, ewram); + LoadPalette(ewram, paletteOffset, 32); + if (species == SPECIES_CASTFORM) + { + u16 *paletteSrc = (u16 *)(ewram + 0x16400); + + sub_800D238(lzPaletteData, paletteSrc); + LoadPalette(paletteSrc + gBattleMonForms[b] * 16, paletteOffset, 32); + } + BlendPalette(paletteOffset, 16, 6, 0x7FFF); + CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); + if (!IsContest()) + { + ewram17800[a].unk2 = species; + gBattleMonForms[a] = gBattleMonForms[b]; + } + gSprites[gObjectBankIDs[a]].pos1.y = sub_8077F68(a); + StartSpriteAnim(&gSprites[gObjectBankIDs[a]], gBattleMonForms[a]); + } +} + +void sub_8032350(u8 a, u8 b) +{ + u8 r4; + u16 foo; + const u8 *gSubstituteDollPal_; + void *src; + s32 i; + + if (b == 0) + { + if (IsContest()) + r4 = 0; + else + r4 = GetBankIdentity(a); + if (IsContest()) + LZDecompressVram(gSubstituteDollTilemap, gUnknown_081FAF4C[r4]); + else if (GetBankSide(a) != 0) + LZDecompressVram(gSubstituteDollGfx, gUnknown_081FAF4C[r4]); + else + LZDecompressVram(gSubstituteDollTilemap, gUnknown_081FAF4C[r4]); + // There is probably a way to do this without all the temp variables, but I couldn't figure it out. + foo = a * 16; + gSubstituteDollPal_ = gSubstituteDollPal; + src = gUnknown_081FAF4C[r4]; + for (i = 0; i < 3; i++) + DmaCopy32(3, src, src + i * 0x800 + 0x800, 0x800); + LoadCompressedPalette(gSubstituteDollPal_, 0x100 + foo, 32); + } + else + { + if (!IsContest()) + { + if (GetBankSide(a) != 0) + sub_8031794(&gEnemyParty[gBattlePartyID[a]], a); + else + sub_80318FC(&gPlayerParty[gBattlePartyID[a]], a); + } + } +} + +void refresh_graphics_maybe(u8 a, u8 b, u8 spriteId) +{ + sub_8032350(a, b); + StartSpriteAnim(&gSprites[spriteId], gBattleMonForms[a]); + if (b == 0) + gSprites[spriteId].pos1.y = sub_8077F7C(a); + else + gSprites[spriteId].pos1.y = sub_8077F68(a); +} + +void sub_80324BC(u8 a, u16 b) +{ + if (b == 0xA4) + ewram17800[a].unk0_2 = 1; +} + +void sub_80324E0(u8 a) +{ + ewram17800[a].unk0_2 = 0; +} + +void sub_80324F8(struct Pokemon *pkmn, u8 b) +{ + u16 hp = GetMonData(pkmn, MON_DATA_HP); + u16 maxHP = GetMonData(pkmn, MON_DATA_MAX_HP); + + if (GetHPBarLevel(hp, maxHP) == 1) + { + if (!ewram17800[b].unk0_1) + { + if (!ewram17800[b ^ 2].unk0_1) + PlaySE(SE_HINSI); + ewram17800[b].unk0_1 = 1; + } + } + else + { + ewram17800[b].unk0_1 = 0; + if (!IsDoubleBattle()) + { + m4aSongNumStop(SE_HINSI); + return; + } + if (IsDoubleBattle() && !ewram17800[b ^ 2].unk0_1) + { + m4aSongNumStop(SE_HINSI); + return; + } + } +} + +void sub_80325B8(void) +{ + u8 r4 = GetBankByPlayerAI(0); + + ewram17800[r4].unk0_1 = 0; + if (IsDoubleBattle()) + ewram17800[r4 ^ 2].unk0_1 = 0; + m4aSongNumStop(SE_HINSI); +} + +u8 unref_sub_8032604(struct Pokemon *pkmn) +{ + u16 hp = GetMonData(pkmn, MON_DATA_HP); + u16 maxHP = GetMonData(pkmn, MON_DATA_MAX_HP); + + return GetHPBarLevel(hp, maxHP); +} + +void sub_8032638(void) +{ + if (gMain.inBattle) + { + u8 r8 = GetBankByPlayerAI(0); + u8 r9 = GetBankByPlayerAI(2); + u8 r4 = pokemon_order_func(gBattlePartyID[r8]); + u8 r5 = pokemon_order_func(gBattlePartyID[r9]); + + if (GetMonData(&gPlayerParty[r4], MON_DATA_HP) != 0) + sub_80324F8(&gPlayerParty[r4], r8); + if (IsDoubleBattle()) + { + if (GetMonData(&gPlayerParty[r5], MON_DATA_HP) != 0) + sub_80324F8(&gPlayerParty[r5], r9); + } + } +} + +void sub_80326EC(u8 a) +{ + s32 i; + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (sub_8078874(i) != 0) + { + gSprites[gObjectBankIDs[i]].oam.affineMode = a; + if (a == 0) + { + ewram17810[i].unk6 = gSprites[gObjectBankIDs[i]].oam.matrixNum; + gSprites[gObjectBankIDs[i]].oam.matrixNum = 0; + } + else + { + gSprites[gObjectBankIDs[i]].oam.matrixNum = ewram17810[i].unk6; + } + } + } +} + +void sub_80327CC(void) +{ + u8 r5; + + LoadCompressedObjectPic(&gUnknown_081FAF24); + r5 = GetBankByPlayerAI(1); + ewram17810[r5].unk7 = CreateSprite(&gSpriteTemplate_81FAF34, sub_8077ABC(r5, 0), sub_8077ABC(r5, 1) + 32, 0xC8); + gSprites[ewram17810[r5].unk7].data0 = r5; + if (IsDoubleBattle()) + { + r5 = GetBankByPlayerAI(3); + ewram17810[r5].unk7 = CreateSprite(&gSpriteTemplate_81FAF34, sub_8077ABC(r5, 0), sub_8077ABC(r5, 1) + 32, 0xC8); + gSprites[ewram17810[r5].unk7].data0 = r5; + } +} + +void sub_80328A4(struct Sprite *sprite) +{ + bool8 invisible = FALSE; + u8 r4 = sprite->data0; + struct Sprite *r7 = &gSprites[gObjectBankIDs[r4]]; + + if (!r7->inUse || sub_8078874(r4) == 0) + { + sprite->callback = sub_8032978; + return; + } + if (gAnimScriptActive || r7->invisible) + invisible = TRUE; + else if (ewram17800[r4].unk2 != 0 && gEnemyMonElevation[ewram17800[r4].unk2] == 0) + invisible = TRUE; + if (ewram17800[r4].unk0_2) + invisible = TRUE; + sprite->pos1.x = r7->pos1.x; + sprite->pos2.x = r7->pos2.x; + sprite->invisible = invisible; +} + +void sub_8032978(struct Sprite *sprite) +{ + sprite->invisible = TRUE; +} + +void sub_8032984(u8 a, u16 b) +{ + if (GetBankSide(a) != 0) + { + if (ewram17800[a].unk2 != 0) + b = ewram17800[a].unk2; + if (gEnemyMonElevation[b] != 0) + gSprites[ewram17810[a].unk7].callback = sub_80328A4; + else + gSprites[ewram17810[a].unk7].callback = sub_8032978; + } +} + +void sub_8032A08(u8 a) +{ + gSprites[ewram17810[a].unk7].callback = sub_8032978; +} + +void sub_8032A38(void) +{ + u16 *ptr = (u16 *)(VRAM + 0x240); + s32 i; + s32 j; + + for (i = 0; i < 9; i++) + { + for (j = 0; j < 16; j++) + { + if (!(*ptr & 0xF000)) + *ptr |= 0xF000; + if (!(*ptr & 0x0F00)) + *ptr |= 0x0F00; + if (!(*ptr & 0x00F0)) + *ptr |= 0x00F0; + if (!(*ptr & 0x000F)) + *ptr |= 0x000F; + ptr++; + } + } +} + +void sub_8032AA8(u8 a, u8 b) +{ + ewram17800[a].unk2 = 0; + gBattleMonForms[a] = 0; + if (b == 0) + sub_80324E0(a); +} + +void nullsub_45(void) +{ +} + +void SetBankFuncToOpponentBufferRunCommand(void) +{ + gBattleBankFunc[gActiveBank] = OpponentBufferRunCommand; +} + +void OpponentBufferRunCommand(void) +{ + if (gBattleExecBuffer & gBitTable[gActiveBank]) + { + if (gBattleBufferA[gActiveBank][0] <= 0x38) + gOpponentBufferCommands[gBattleBufferA[gActiveBank][0]](); + else + OpponentBufferExecCompleted(); + } +} + +void sub_8032B4C(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].callback == SpriteCallbackDummy) + OpponentBufferExecCompleted(); +} + +// Duplicate of sub_8032B4C +void sub_8032B84(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].callback == SpriteCallbackDummy) + OpponentBufferExecCompleted(); +} + +void sub_8032BBC(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].callback == SpriteCallbackDummy) + { + sub_8031B74(gSprites[gObjectBankIDs[gActiveBank]].oam.affineParam); + gSprites[gObjectBankIDs[gActiveBank]].oam.tileNum = gSprites[gObjectBankIDs[gActiveBank]].data5; + FreeSpriteOamMatrix(&gSprites[gObjectBankIDs[gActiveBank]]); + DestroySprite(&gSprites[gObjectBankIDs[gActiveBank]]); + OpponentBufferExecCompleted(); + } +} + +void sub_8032C4C(void) +{ + if ((--ewram17810[gActiveBank].unk9) == 0xFF) + { + ewram17810[gActiveBank].unk9 = 0; + OpponentBufferExecCompleted(); + } +} + +void sub_8032C88(void) +{ + bool8 r6 = FALSE; + + if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) + { + if (gSprites[gHealthboxIDs[gActiveBank]].callback == SpriteCallbackDummy) + r6 = TRUE; + } + else + { + if (gSprites[gHealthboxIDs[gActiveBank]].callback == SpriteCallbackDummy + && gSprites[gHealthboxIDs[gActiveBank ^ 2]].callback == SpriteCallbackDummy) + r6 = TRUE; + } + if (IsCryPlayingOrClearCrySongs()) + r6 = FALSE; + + if (r6 && ewram17810[gActiveBank].unk1_0 && ewram17810[gActiveBank ^ 2].unk1_0) + { + ewram17810[gActiveBank].unk0_7 = 0; + ewram17810[gActiveBank].unk1_0 = 0; + ewram17810[gActiveBank ^ 2].unk0_7 = 0; + ewram17810[gActiveBank ^ 2].unk1_0 = 0; + FreeSpriteTilesByTag(0x27F9); + FreeSpritePaletteByTag(0x27F9); + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + m4aMPlayContinue(&gMPlay_BGM); + else + m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 256); + ewram17810[gActiveBank].unk9 = 3; + gBattleBankFunc[gActiveBank] = sub_8032C4C; + } +} + +void sub_8032E2C(void) +{ + if (!ewram17810[gActiveBank].unk0_3 && !ewram17810[gActiveBank].unk0_7) + sub_8141828(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); + if (!ewram17810[gActiveBank ^ 2].unk0_3 && !ewram17810[gActiveBank ^ 2].unk0_7) + sub_8141828(gActiveBank ^ 2, &gEnemyParty[gBattlePartyID[gActiveBank ^ 2]]); + if (!ewram17810[gActiveBank].unk0_3 && !ewram17810[gActiveBank ^ 2].unk0_3) + { + if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) + { + DestroySprite(&gSprites[gUnknown_0300434C[gActiveBank ^ 2]]); + sub_8045A5C( + gHealthboxIDs[gActiveBank ^ 2], + &gEnemyParty[gBattlePartyID[gActiveBank ^ 2]], + 0); + sub_804777C(gActiveBank ^ 2); + sub_8043DFC(gHealthboxIDs[gActiveBank ^ 2]); + sub_8032984( + gActiveBank ^ 2, + GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank ^ 2]], MON_DATA_SPECIES)); + } + DestroySprite(&gSprites[gUnknown_0300434C[gActiveBank]]); + sub_8045A5C( + gHealthboxIDs[gActiveBank], + &gEnemyParty[gBattlePartyID[gActiveBank]], + 0); + sub_804777C(gActiveBank); + sub_8043DFC(gHealthboxIDs[gActiveBank]); + sub_8032984( + gActiveBank, + GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); + + ewram17840.unk9_0 = 0; + gBattleBankFunc[gActiveBank] = sub_8032C88; + } +} + +void sub_8033018(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].animEnded == TRUE + && gSprites[gObjectBankIDs[gActiveBank]].pos2.x == 0) + { + if (!ewram17810[gActiveBank].unk0_7) + { + sub_8141828(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); + return; + } + if (ewram17810[gActiveBank].unk1_0) + { + ewram17810[gActiveBank].unk0_7 = 0; + ewram17810[gActiveBank].unk1_0 = 0; + FreeSpriteTilesByTag(0x27F9); + FreeSpritePaletteByTag(0x27F9); + OpponentBufferExecCompleted(); + return; + } + } +} + +void sub_80330C8(void) +{ + s16 r4 = sub_8045C78(gActiveBank, gHealthboxIDs[gActiveBank], 0, 0); + + sub_8043DFC(gHealthboxIDs[gActiveBank]); + if (r4 != -1) + sub_80440EC(gHealthboxIDs[gActiveBank], r4, 0); + else + OpponentBufferExecCompleted(); +} + +void sub_803311C(void) +{ + if (!gSprites[gObjectBankIDs[gActiveBank]].inUse) + { + sub_8043DB0(gHealthboxIDs[gActiveBank]); + OpponentBufferExecCompleted(); + } +} + +void sub_8033160(void) +{ + if (!ewram17810[gActiveBank].unk0_6) + { + FreeSpriteOamMatrix(&gSprites[gObjectBankIDs[gActiveBank]]); + DestroySprite(&gSprites[gObjectBankIDs[gActiveBank]]); + sub_8032A08(gActiveBank); + sub_8043DB0(gHealthboxIDs[gActiveBank]); + OpponentBufferExecCompleted(); + } +} + +void sub_80331D0(void) +{ + if (gUnknown_03004210.state == 0) + OpponentBufferExecCompleted(); +} + +void bx_blink_t7(void) +{ + u8 spriteId = gObjectBankIDs[gActiveBank]; + + if (gSprites[spriteId].data1 == 32) + { + gSprites[spriteId].data1 = 0; + gSprites[spriteId].invisible = FALSE; + gDoingBattleAnim = 0; + OpponentBufferExecCompleted(); + } + else + { + if (((u16)gSprites[spriteId].data1 % 4) == 0) + gSprites[spriteId].invisible ^= 1; + gSprites[spriteId].data1++; + } +} + +void sub_8033264(void) +{ + if (gSprites[gHealthboxIDs[gActiveBank]].callback == SpriteCallbackDummy) + { + if (ewram17800[gActiveBank].unk0_2) + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 6); + gBattleBankFunc[gActiveBank] = sub_80332D0; + } +} + +void sub_80332D0(void) +{ + if (!ewram17810[gActiveBank].unk0_6) + { + CreateTask(c3_0802FDF4, 10); + OpponentBufferExecCompleted(); + } +} + +void sub_8033308(void) +{ + if (ewram17810[gActiveBank].unk1_0) + { + ewram17810[gActiveBank].unk0_7 = 0; + ewram17810[gActiveBank].unk1_0 = 0; + FreeSpriteTilesByTag(0x27F9); + FreeSpritePaletteByTag(0x27F9); + StartSpriteAnim(&gSprites[gObjectBankIDs[gActiveBank]], 0); + sub_8045A5C( + gHealthboxIDs[gActiveBank], + &gEnemyParty[gBattlePartyID[gActiveBank]], + 0); + sub_804777C(gActiveBank); + sub_8043DFC(gHealthboxIDs[gActiveBank]); + sub_8031F88(gActiveBank); + gBattleBankFunc[gActiveBank] = sub_8033264; + } +} + +void sub_80333D4(void) +{ + if (!ewram17810[gActiveBank].unk0_3 && !ewram17810[gActiveBank].unk0_7) + sub_8141828(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); + if (gSprites[gUnknown_0300434C[gActiveBank]].callback == SpriteCallbackDummy + && !ewram17810[gActiveBank].unk0_3) + { + DestroySprite(&gSprites[gUnknown_0300434C[gActiveBank]]); + sub_8032984(gActiveBank, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); + gBattleBankFunc[gActiveBank] = sub_8033308; + } +} + +void sub_8033494(void) +{ + if (!ewram17810[gActiveBank].unk0_4) + OpponentBufferExecCompleted(); +} + +void sub_80334C0(void) +{ + if (!ewram17810[gActiveBank].unk0_5) + OpponentBufferExecCompleted(); +} + +void OpponentBufferExecCompleted(void) +{ + gBattleBankFunc[gActiveBank] = OpponentBufferRunCommand; + gBattleExecBuffer &= ~gBitTable[gActiveBank]; +} diff --git a/src/battle_811DA74.c b/src/battle_811DA74.c new file mode 100644 index 000000000..42c700844 --- /dev/null +++ b/src/battle_811DA74.c @@ -0,0 +1,1605 @@ +#include "global.h" +#include "battle.h" +#include "battle_interface.h" +#include "data2.h" +#include "battle_811DA74.h" +#include "battle_anim_813F0F4.h" +#include "link.h" +#include "m4a.h" +#include "main.h" +#include "palette.h" +#include "pokeball.h" +#include "pokemon.h" +#include "rom3.h" +#include "rom_8077ABC.h" +#include "sound.h" +#include "songs.h" +#include "sprite.h" +#include "string_util.h" +#include "task.h" +#include "text.h" +#include "util.h" + +struct UnknownStruct1 +{ + u8 unk0; + u8 unk1; + u8 unk2[0x1FE]; +}; + +//Possibly PokemonSubstruct1 +struct UnknownStruct3 +{ + u16 moves[4]; + u8 pp[4]; + u8 ppBonuses; +}; + +extern u16 gBattleTypeFlags; +extern u8 gDisplayedStringBattle[]; +extern u8 gBattleBufferA[][0x200]; +extern u8 gActiveBank; +extern u32 gBattleExecBuffer; +extern u16 gBattlePartyID[]; +extern u8 gObjectBankIDs[]; +extern u8 gBattleOutcome; +extern u16 gUnknown_02024DE8; +extern u8 gUnknown_02024E68[]; +extern u8 gDoingBattleAnim; +extern u32 gPID_perBank[]; +extern struct SpriteTemplate gUnknown_02024E8C; +extern u32 *gDisableStructMoveAnim; +extern u32 gMoveDmgMoveAnim; +extern u16 gMovePowerMoveAnim; +extern u8 gHappinessMoveAnim; +extern u16 gWeatherMoveAnim; +extern u8 gUnknown_0202F7C4; +extern struct Window gUnknown_03004210; +extern u16 gUnknown_030042A0; +extern u16 gUnknown_030042A4; +extern MainCallback gPreBattleCallback1; +extern void (*gBattleBankFunc[])(void); +extern u8 gHealthboxIDs[]; +extern u8 gUnknown_0300434C[]; +extern u8 gBattleMonForms[]; +extern u8 gAnimScriptActive; +extern void (*gAnimScriptCallback)(void); +extern void (*const gLinkPartnerBufferCommands[])(void); + +extern u8 move_anim_start_t3(); +extern u8 sub_8078874(); +extern void sub_8044CA0(u8); +extern void sub_8030E38(struct Sprite *); +extern void sub_80E43C0(); +extern void sub_8047858(); +extern void move_anim_start_t2_for_situation(); +extern void load_gfxc_health_bar(); +extern void sub_8043D84(); +extern void BufferStringBattle(); +extern void sub_8031F24(void); +extern void sub_80326EC(); +extern void ExecuteMoveAnim(); +extern void sub_80324BC(); +extern u8 sub_8031720(); +extern u8 mplay_80342A4(); +extern void oamt_add_pos2_onto_pos1(); +extern void oamt_set_x3A_32(); +extern void sub_8078B34(struct Sprite *); +extern void sub_80105EC(struct Sprite *); +extern s32 sub_803FC34(u16); +extern void sub_8031AF4(); +extern void sub_80313A0(struct Sprite *); +extern u8 sub_8046400(); +extern void sub_80312F0(struct Sprite *); +extern u8 CreateInvisibleSpriteWithCallback(); +extern void sub_80318FC(); +extern u8 sub_8077ABC(); +extern u8 sub_8077F68(); +extern u8 sub_8079E90(); +extern void nullsub_10(); +extern void sub_8045A5C(); +extern void sub_804777C(); +extern void sub_8043DFC(); +//extern s16 sub_8045C78(); +extern void sub_80440EC(); +extern void sub_80324F8(); +extern void nullsub_9(u16); +extern void sub_8043DB0(); +extern void move_anim_start_t4(); +extern void c3_0802FDF4(u8); +extern void sub_8031F88(); +extern void sub_8141828(); +extern void c2_8011A1C(void); + +void LinkPartnerBufferRunCommand(void); +void sub_811E0A0(void); +void LinkPartnerBufferExecCompleted(void); +u32 dp01_getattr_by_ch1_for_player_pokemon(u8 a, u8 *b); +void sub_811EC68(u8); +void sub_811F864(u8, u8); +void sub_811FA5C(void); +void sub_811FF30(void); +void sub_812071C(u8); +void sub_81208E0(void); + + +void nullsub_74(void) +{ +} + +void SetBankFuncToLinkPartnerBufferRunCommand(void) +{ + gBattleBankFunc[gActiveBank] = LinkPartnerBufferRunCommand; +} + +void LinkPartnerBufferRunCommand(void) +{ + if (gBattleExecBuffer & gBitTable[gActiveBank]) + { + if (gBattleBufferA[gActiveBank][0] <= 0x38) + gLinkPartnerBufferCommands[gBattleBufferA[gActiveBank][0]](); + else + LinkPartnerBufferExecCompleted(); + } +} + +void sub_811DAE4(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].callback == SpriteCallbackDummy) + LinkPartnerBufferExecCompleted(); +} + +void sub_811DB1C(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].callback == SpriteCallbackDummy) + { + nullsub_10(0); + FreeSpriteOamMatrix(&gSprites[gObjectBankIDs[gActiveBank]]); + DestroySprite(&gSprites[gObjectBankIDs[gActiveBank]]); + LinkPartnerBufferExecCompleted(); + } +} + +void sub_811DB84(void) +{ + if ((--ewram17810[gActiveBank].unk9) == 0xFF) + { + ewram17810[gActiveBank].unk9 = 0; + LinkPartnerBufferExecCompleted(); + } +} + +void sub_811DBC0(void) +{ + bool8 r6 = FALSE; + + if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & 0x40))) + { + if (gSprites[gHealthboxIDs[gActiveBank]].callback == SpriteCallbackDummy) + r6 = TRUE; + } + else + { + if (gSprites[gHealthboxIDs[gActiveBank]].callback == SpriteCallbackDummy + && gSprites[gHealthboxIDs[gActiveBank ^ 2]].callback == SpriteCallbackDummy) + r6 = TRUE; + } + if (IsCryPlayingOrClearCrySongs()) + r6 = FALSE; + if (r6) + { + ewram17810[gActiveBank].unk9 = 3; + gBattleBankFunc[gActiveBank] = sub_811DB84; + } +} + +void sub_811DCA0(void) +{ + u8 r2; + + if (!ewram17810[gActiveBank].unk0_3) + { + // I couldn't get it to work as a bitfield here + r2 = *((u8 *)&ewram17810[gActiveBank ^ 2]) & 8; + if (!r2 && (++ewram17810[gActiveBank].unk9) != 1) + { + ewram17810[gActiveBank].unk9 = r2; + if (IsDoubleBattle() && !(gBattleTypeFlags & 0x40)) + { + DestroySprite(&gSprites[gUnknown_0300434C[gActiveBank ^ 2]]); + sub_8045A5C(gHealthboxIDs[gActiveBank ^ 2], &gPlayerParty[gBattlePartyID[gActiveBank ^ 2]], 0); + sub_804777C(gActiveBank ^ 2); + sub_8043DFC(gHealthboxIDs[gActiveBank ^ 2]); + } + DestroySprite(&gSprites[gUnknown_0300434C[gActiveBank]]); + sub_8045A5C(gHealthboxIDs[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], 0); + sub_804777C(gActiveBank); + sub_8043DFC(gHealthboxIDs[gActiveBank]); + (s8)ewram17810[4].unk9 &= ~1; + gBattleBankFunc[gActiveBank] = sub_811DBC0; + } + } +} + +void sub_811DDE8(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].animEnded + && gSprites[gObjectBankIDs[gActiveBank]].pos2.x == 0) + LinkPartnerBufferExecCompleted(); +} + +void bx_t3_healthbar_update(void) +{ + s16 r4; + + r4 = sub_8045C78(gActiveBank, gHealthboxIDs[gActiveBank], 0, 0); + sub_8043DFC(gHealthboxIDs[gActiveBank]); + if (r4 != -1) + { + sub_80440EC(gHealthboxIDs[gActiveBank], r4, 0); + } + else + { + sub_80324F8(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + LinkPartnerBufferExecCompleted(); + } +} + +void sub_811DE98(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].pos1.y + gSprites[gObjectBankIDs[gActiveBank]].pos2.y > 160) + { + nullsub_9(GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); + FreeOamMatrix(gSprites[gObjectBankIDs[gActiveBank]].oam.matrixNum); + DestroySprite(&gSprites[gObjectBankIDs[gActiveBank]]); + sub_8043DB0(gHealthboxIDs[gActiveBank]); + LinkPartnerBufferExecCompleted(); + } +} + +void sub_811DF34(void) +{ + if (!ewram17810[gActiveBank].unk0_6) + { + FreeSpriteOamMatrix(&gSprites[gObjectBankIDs[gActiveBank]]); + DestroySprite(&gSprites[gObjectBankIDs[gActiveBank]]); + sub_8043DB0(gHealthboxIDs[gActiveBank]); + LinkPartnerBufferExecCompleted(); + } +} + +void sub_811DFA0(void) +{ + if (gUnknown_03004210.state == 0) + LinkPartnerBufferExecCompleted(); +} + +void bx_blink_t3(void) +{ + u8 spriteId = gObjectBankIDs[gActiveBank]; + if (gSprites[spriteId].data1 == 32) + { + gSprites[spriteId].data1 = 0; + gSprites[spriteId].invisible = FALSE; + gDoingBattleAnim = 0; + LinkPartnerBufferExecCompleted(); + } + else + { + if ((gSprites[spriteId].data1 % 4) == 0) + { + gSprites[spriteId].invisible ^= 1; + } + gSprites[spriteId].data1++; + } +} + +void sub_811E034(void) +{ + if (gSprites[gHealthboxIDs[gActiveBank]].callback == SpriteCallbackDummy) + { + if (ewram17800[gActiveBank].unk0_2) + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 6); + gBattleBankFunc[gActiveBank] = sub_811E0A0; + } +} + +void sub_811E0A0(void) +{ + if (!ewram17810[gActiveBank].unk0_6) + LinkPartnerBufferExecCompleted(); +} + +void sub_811E0CC(void) +{ + if (ewram17810[gActiveBank].unk1_0) + { + ewram17810[gActiveBank].unk0_7 = 0; + ewram17810[gActiveBank].unk1_0 = 0; + FreeSpriteTilesByTag(0x27F9); + FreeSpritePaletteByTag(0x27F9); + CreateTask(c3_0802FDF4, 10); + sub_80324F8(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + StartSpriteAnim(&gSprites[gObjectBankIDs[gActiveBank]], 0); + sub_8045A5C(gHealthboxIDs[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], 0); + sub_804777C(gActiveBank); + sub_8043DFC(gHealthboxIDs[gActiveBank]); + sub_8031F88(gActiveBank); + gBattleBankFunc[gActiveBank] = sub_811E034; + } +} + +void sub_811E1BC(void) +{ + if (!ewram17810[gActiveBank].unk0_3 && !ewram17810[gActiveBank].unk0_7) + sub_8141828(gActiveBank, &gPlayerParty[gBattlePartyID[gActiveBank]]); + if (gSprites[gUnknown_0300434C[gActiveBank]].callback == SpriteCallbackDummy + && !ewram17810[gActiveBank].unk0_3) + { + DestroySprite(&gSprites[gUnknown_0300434C[gActiveBank]]); + gBattleBankFunc[gActiveBank] = sub_811E0CC; + } +} + +void sub_811E258(void) +{ + if (gReceivedRemoteLinkPlayers == 0) + { + m4aSongNumStop(0x5A); + gMain.inBattle = FALSE; + gMain.callback1 = gPreBattleCallback1; + SetMainCallback2(c2_8011A1C); + } +} + +void sub_811E29C(void) +{ + if (!gPaletteFade.active) + { + if (gBattleTypeFlags & 2) + { + sub_800832C(); + gBattleBankFunc[gActiveBank] = sub_811E258; + } + else + { + m4aSongNumStop(0x5A); + gMain.inBattle = FALSE; + gMain.callback1 = gPreBattleCallback1; + SetMainCallback2(gMain.savedCallback); + } + } +} + +void LinkPartnerBufferExecCompleted(void) +{ + u8 multiplayerId; + + gBattleBankFunc[gActiveBank] = LinkPartnerBufferRunCommand; + if (gBattleTypeFlags & 2) + { + multiplayerId = GetMultiplayerId(); + dp01_prepare_buffer_wireless_probably(2, 4, &multiplayerId); + gBattleBufferA[gActiveBank][0] = 0x38; + } + else + { + gBattleExecBuffer &= ~gBitTable[gActiveBank]; + } +} + +void sub_811E38C(void) +{ + if (!ewram17810[gActiveBank].unk0_4) + LinkPartnerBufferExecCompleted(); +} + +void sub_811E3B8(void) +{ + if (!ewram17810[gActiveBank].unk0_5) + LinkPartnerBufferExecCompleted(); +} + +void LinkPartnerHandleGetAttributes(void) +{ + u8 unk[256]; + int r6 = 0; + s32 i; + + if (gBattleBufferA[gActiveBank][2] == 0) + { + r6 = dp01_getattr_by_ch1_for_player_pokemon(gBattlePartyID[gActiveBank], unk); + } + else + { + u8 r4 = gBattleBufferA[gActiveBank][2]; + + for (i = 0; i < 6; i++) + { + if (r4 & 1) + r6 += dp01_getattr_by_ch1_for_player_pokemon(i, unk + r6); + r4 >>= 1; + } + } + dp01_build_cmdbuf_x1D_1D_numargs_varargs(1, r6, unk); + LinkPartnerBufferExecCompleted(); +} + +// Duplicate of dp01_getattr_by_ch1_for_player_pokemon_ +u32 dp01_getattr_by_ch1_for_player_pokemon(u8 a, u8 *buffer) +{ + struct BattlePokemon battlePokemon; + struct UnknownStruct3 moveData; + u8 nickname[20]; + u8 *src; + s16 data16; + u32 data32; + s32 size = 0; + + switch (gBattleBufferA[gActiveBank][1]) + { + case 0: + battlePokemon.species = GetMonData(&gPlayerParty[a], MON_DATA_SPECIES); + battlePokemon.item = GetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM); + for (size = 0; size < 4; size++) + { + battlePokemon.moves[size] = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + size); + battlePokemon.pp[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); + } + battlePokemon.ppBonuses = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); + battlePokemon.friendship = GetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP); + battlePokemon.experience = GetMonData(&gPlayerParty[a], MON_DATA_EXP); + battlePokemon.hpIV = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); + battlePokemon.attackIV = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); + battlePokemon.defenseIV = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); + battlePokemon.speedIV = GetMonData(&gPlayerParty[a], MON_DATA_SPD_IV); + battlePokemon.spAttackIV = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); + battlePokemon.spDefenseIV = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); + battlePokemon.personality = GetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY); + battlePokemon.status1 = GetMonData(&gPlayerParty[a], MON_DATA_STATUS); + battlePokemon.level = GetMonData(&gPlayerParty[a], MON_DATA_LEVEL); + battlePokemon.hp = GetMonData(&gPlayerParty[a], MON_DATA_HP); + battlePokemon.maxHP = GetMonData(&gPlayerParty[a], MON_DATA_MAX_HP); + battlePokemon.attack = GetMonData(&gPlayerParty[a], MON_DATA_ATK); + battlePokemon.defense = GetMonData(&gPlayerParty[a], MON_DATA_DEF); + battlePokemon.speed = GetMonData(&gPlayerParty[a], MON_DATA_SPD); + battlePokemon.spAttack = GetMonData(&gPlayerParty[a], MON_DATA_SPATK); + battlePokemon.spDefense = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF); + battlePokemon.isEgg = GetMonData(&gPlayerParty[a], MON_DATA_IS_EGG); + battlePokemon.altAbility = GetMonData(&gPlayerParty[a], MON_DATA_ALT_ABILITY); + battlePokemon.otId = GetMonData(&gPlayerParty[a], MON_DATA_OT_ID); + GetMonData(&gPlayerParty[a], MON_DATA_NICKNAME, nickname); + StringCopy10(battlePokemon.nickname, nickname); + GetMonData(&gPlayerParty[a], MON_DATA_OT_NAME, battlePokemon.otName); + src = (u8 *)&battlePokemon; + for (size = 0; size < sizeof(battlePokemon); size++) + buffer[size] = src[size]; + break; + case 1: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPECIES); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 2: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 3: + for (size = 0; size < 4; size++) + { + moveData.moves[size] = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + size); + moveData.pp[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); + } + moveData.ppBonuses = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); + src = (u8 *)&moveData; + for (size = 0; size < sizeof(moveData); size++) + buffer[size] = src[size]; + break; + case 4: + case 5: + case 6: + case 7: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - 4); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 8: + for (size = 0; size < 4; size++) + buffer[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); + buffer[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); + size++; + break; + case 9: + case 10: + case 11: + case 12: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - 9); + size = 1; + break; + case 17: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_OT_ID); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + size = 3; + break; + case 18: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_EXP); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + size = 3; + break; + case 19: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_EV); + size = 1; + break; + case 20: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_EV); + size = 1; + break; + case 21: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_EV); + size = 1; + break; + case 22: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPD_EV); + size = 1; + break; + case 23: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_EV); + size = 1; + break; + case 24: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_EV); + size = 1; + break; + case 25: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP); + size = 1; + break; + case 26: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_POKERUS); + size = 1; + break; + case 27: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_LOCATION); + size = 1; + break; + case 28: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_LEVEL); + size = 1; + break; + case 29: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_GAME); + size = 1; + break; + case 30: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_POKEBALL); + size = 1; + break; + case 31: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); + buffer[1] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); + buffer[2] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); + buffer[3] = GetMonData(&gPlayerParty[a], MON_DATA_SPD_IV); + buffer[4] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); + buffer[5] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); + size = 6; + break; + case 32: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); + size = 1; + break; + case 33: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); + size = 1; + break; + case 34: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); + size = 1; + break; + case 35: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPD_IV); + size = 1; + break; + case 36: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); + size = 1; + break; + case 37: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); + size = 1; + break; + case 38: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + buffer[3] = (data32 & 0xFF000000) >> 24; + size = 4; + break; + case 39: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_CHECKSUM); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 40: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_STATUS); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + buffer[3] = (data32 & 0xFF000000) >> 24; + size = 4; + break; + case 41: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_LEVEL); + size = 1; + break; + case 42: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_HP); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 43: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_MAX_HP); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 44: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_ATK); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 45: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_DEF); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 46: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPD); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 47: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPATK); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 48: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 49: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_COOL); + size = 1; + break; + case 50: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_BEAUTY); + size = 1; + break; + case 51: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_CUTE); + size = 1; + break; + case 52: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SMART); + size = 1; + break; + case 53: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_TOUGH); + size = 1; + break; + case 54: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SHEEN); + size = 1; + break; + case 55: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_COOL_RIBBON); + size = 1; + break; + case 56: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_BEAUTY_RIBBON); + size = 1; + break; + case 57: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_CUTE_RIBBON); + size = 1; + break; + case 58: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SMART_RIBBON); + size = 1; + break; + case 59: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_TOUGH_RIBBON); + size = 1; + break; + } + return size; +} + +void sub_811EC04(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void LinkPartnerHandleSetAttributes(void) +{ + u8 i; + u8 r4; + + if (gBattleBufferA[gActiveBank][2] == 0) + { + sub_811EC68(gBattlePartyID[gActiveBank]); + } + else + { + r4 = gBattleBufferA[gActiveBank][2]; + for (i = 0; i < 6; i++) + { + if (r4 & 1) + sub_811EC68(i); + r4 >>= 1; + } + } + LinkPartnerBufferExecCompleted(); +} + +// Duplicate of dp01_setattr_by_ch1_for_player_pokemon +void sub_811EC68(u8 a) +{ + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; + struct UnknownStruct3 *moveData = (struct UnknownStruct3 *)&gBattleBufferA[gActiveBank][3]; + s32 i; + + switch (gBattleBufferA[gActiveBank][1]) + { + case 0: + { + u8 iv; + + SetMonData(&gPlayerParty[a], MON_DATA_SPECIES, (u8 *)&battlePokemon->species); + SetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM, (u8 *)&battlePokemon->item); + for (i = 0; i < 4; i++) + { + SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + i, (u8 *)&battlePokemon->moves[i]); + SetMonData(&gPlayerParty[a], MON_DATA_PP1 + i, (u8 *)&battlePokemon->pp[i]); + } + SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, (u8 *)&battlePokemon->ppBonuses); + SetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP, (u8 *)&battlePokemon->friendship); + SetMonData(&gPlayerParty[a], MON_DATA_EXP, (u8 *)&battlePokemon->experience); + iv = battlePokemon->hpIV; + SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, (u8 *)&iv); + iv = battlePokemon->attackIV; + SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, (u8 *)&iv); + iv = battlePokemon->defenseIV; + SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, (u8 *)&iv); + iv = battlePokemon->speedIV; + SetMonData(&gPlayerParty[a], MON_DATA_SPD_IV, (u8 *)&iv); + iv = battlePokemon->spAttackIV; + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, (u8 *)&iv); + iv = battlePokemon->spDefenseIV; + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, (u8 *)&iv); + SetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY, (u8 *)&battlePokemon->personality); + SetMonData(&gPlayerParty[a], MON_DATA_STATUS, (u8 *)&battlePokemon->status1); + SetMonData(&gPlayerParty[a], MON_DATA_LEVEL, (u8 *)&battlePokemon->level); + SetMonData(&gPlayerParty[a], MON_DATA_HP, (u8 *)&battlePokemon->hp); + SetMonData(&gPlayerParty[a], MON_DATA_MAX_HP, (u8 *)&battlePokemon->maxHP); + SetMonData(&gPlayerParty[a], MON_DATA_ATK, (u8 *)&battlePokemon->attack); + SetMonData(&gPlayerParty[a], MON_DATA_DEF, (u8 *)&battlePokemon->defense); + SetMonData(&gPlayerParty[a], MON_DATA_SPD, (u8 *)&battlePokemon->speed); + SetMonData(&gPlayerParty[a], MON_DATA_SPATK, (u8 *)&battlePokemon->spAttack); + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF, (u8 *)&battlePokemon->spDefense); + } + break; + case 1: + SetMonData(&gPlayerParty[a], MON_DATA_SPECIES, &gBattleBufferA[gActiveBank][3]); + break; + case 2: + SetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBank][3]); + break; + case 3: + for (i = 0; i < 4; i++) + { + SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + i, (u8 *)&moveData->moves[i]); + SetMonData(&gPlayerParty[a], MON_DATA_PP1 + i, (u8 *)&moveData->pp[i]); + } + SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, &moveData->ppBonuses); + break; + case 4: + case 5: + case 6: + case 7: + SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - 4, &gBattleBufferA[gActiveBank][3]); + break; + case 8: + SetMonData(&gPlayerParty[a], MON_DATA_PP1, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[a], MON_DATA_PP2, &gBattleBufferA[gActiveBank][4]); + SetMonData(&gPlayerParty[a], MON_DATA_PP3, &gBattleBufferA[gActiveBank][5]); + SetMonData(&gPlayerParty[a], MON_DATA_PP4, &gBattleBufferA[gActiveBank][6]); + SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBank][7]); + break; + case 9: + case 10: + case 11: + case 12: + SetMonData(&gPlayerParty[a], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - 9, &gBattleBufferA[gActiveBank][3]); + break; + case 17: + SetMonData(&gPlayerParty[a], MON_DATA_OT_ID, &gBattleBufferA[gActiveBank][3]); + break; + case 18: + SetMonData(&gPlayerParty[a], MON_DATA_EXP, &gBattleBufferA[gActiveBank][3]); + break; + case 19: + SetMonData(&gPlayerParty[a], MON_DATA_HP_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 20: + SetMonData(&gPlayerParty[a], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 21: + SetMonData(&gPlayerParty[a], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 22: + SetMonData(&gPlayerParty[a], MON_DATA_SPD_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 23: + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 24: + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 25: + SetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBank][3]); + break; + case 26: + SetMonData(&gPlayerParty[a], MON_DATA_POKERUS, &gBattleBufferA[gActiveBank][3]); + break; + case 27: + SetMonData(&gPlayerParty[a], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBank][3]); + break; + case 28: + SetMonData(&gPlayerParty[a], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBank][3]); + break; + case 29: + SetMonData(&gPlayerParty[a], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBank][3]); + break; + case 30: + SetMonData(&gPlayerParty[a], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBank][3]); + break; + case 31: + SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][4]); + SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][5]); + SetMonData(&gPlayerParty[a], MON_DATA_SPD_IV, &gBattleBufferA[gActiveBank][6]); + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][7]); + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][8]); + break; + case 32: + SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 33: + SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 34: + SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 35: + SetMonData(&gPlayerParty[a], MON_DATA_SPD_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 36: + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 37: + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 38: + SetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBank][3]); + break; + case 39: + SetMonData(&gPlayerParty[a], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBank][3]); + break; + case 40: + SetMonData(&gPlayerParty[a], MON_DATA_STATUS, &gBattleBufferA[gActiveBank][3]); + break; + case 41: + SetMonData(&gPlayerParty[a], MON_DATA_LEVEL, &gBattleBufferA[gActiveBank][3]); + break; + case 42: + SetMonData(&gPlayerParty[a], MON_DATA_HP, &gBattleBufferA[gActiveBank][3]); + break; + case 43: + SetMonData(&gPlayerParty[a], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBank][3]); + break; + case 44: + SetMonData(&gPlayerParty[a], MON_DATA_ATK, &gBattleBufferA[gActiveBank][3]); + break; + case 45: + SetMonData(&gPlayerParty[a], MON_DATA_DEF, &gBattleBufferA[gActiveBank][3]); + break; + case 46: + SetMonData(&gPlayerParty[a], MON_DATA_SPD, &gBattleBufferA[gActiveBank][3]); + break; + case 47: + SetMonData(&gPlayerParty[a], MON_DATA_SPATK, &gBattleBufferA[gActiveBank][3]); + break; + case 48: + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF, &gBattleBufferA[gActiveBank][3]); + break; + case 49: + SetMonData(&gPlayerParty[a], MON_DATA_COOL, &gBattleBufferA[gActiveBank][3]); + break; + case 50: + SetMonData(&gPlayerParty[a], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBank][3]); + break; + case 51: + SetMonData(&gPlayerParty[a], MON_DATA_CUTE, &gBattleBufferA[gActiveBank][3]); + break; + case 52: + SetMonData(&gPlayerParty[a], MON_DATA_SMART, &gBattleBufferA[gActiveBank][3]); + break; + case 53: + SetMonData(&gPlayerParty[a], MON_DATA_TOUGH, &gBattleBufferA[gActiveBank][3]); + break; + case 54: + SetMonData(&gPlayerParty[a], MON_DATA_SHEEN, &gBattleBufferA[gActiveBank][3]); + break; + case 55: + SetMonData(&gPlayerParty[a], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 56: + SetMonData(&gPlayerParty[a], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 57: + SetMonData(&gPlayerParty[a], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 58: + SetMonData(&gPlayerParty[a], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 59: + SetMonData(&gPlayerParty[a], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + } + sub_80324F8(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); +} + +void sub_811F664(void) +{ + u8 *dst; + u8 i; + + dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; + for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) + dst[i] = gBattleBufferA[gActiveBank][3 + i]; + LinkPartnerBufferExecCompleted(); +} + +void sub_811F6D8(void) +{ + sub_80318FC(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + GetMonSpriteTemplate_803C56C( + GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES), + GetBankIdentity(gActiveBank)); + gObjectBankIDs[gActiveBank] = CreateSprite( + &gUnknown_02024E8C, + sub_8077ABC(gActiveBank, 2), + sub_8077F68(gActiveBank), + sub_8079E90(gActiveBank)); + gSprites[gObjectBankIDs[gActiveBank]].pos2.x = -240; + gSprites[gObjectBankIDs[gActiveBank]].data0 = gActiveBank; + gSprites[gObjectBankIDs[gActiveBank]].oam.paletteNum = gActiveBank; + StartSpriteAnim(&gSprites[gObjectBankIDs[gActiveBank]], gBattleMonForms[gActiveBank]); + gBattleBankFunc[gActiveBank] = sub_811DDE8; +} + +void sub_811F7F4(void) +{ + sub_8032AA8(gActiveBank, gBattleBufferA[gActiveBank][2]); + gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1]; + sub_80318FC(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + sub_811F864(gActiveBank, gBattleBufferA[gActiveBank][2]); + gBattleBankFunc[gActiveBank] = sub_811E1BC; +} + +void sub_811F864(u8 a, u8 b) +{ + u16 species; + + sub_8032AA8(a, b); + gBattlePartyID[a] = gBattleBufferA[a][1]; + species = GetMonData(&gPlayerParty[gBattlePartyID[a]], MON_DATA_SPECIES); + gUnknown_0300434C[a] = CreateInvisibleSpriteWithCallback(sub_80312F0); + GetMonSpriteTemplate_803C56C(species, GetBankIdentity(a)); + gObjectBankIDs[a] = CreateSprite( + &gUnknown_02024E8C, + sub_8077ABC(a, 2), + sub_8077F68(a), + sub_8079E90(a)); + gSprites[gUnknown_0300434C[a]].data1 = gObjectBankIDs[a]; + gSprites[gObjectBankIDs[a]].data0 = a; + gSprites[gObjectBankIDs[a]].data2 = species; + gSprites[gObjectBankIDs[a]].oam.paletteNum = a; + StartSpriteAnim(&gSprites[gObjectBankIDs[a]], gBattleMonForms[a]); + gSprites[gObjectBankIDs[a]].invisible = TRUE; + gSprites[gObjectBankIDs[a]].callback = SpriteCallbackDummy; + gSprites[gUnknown_0300434C[a]].data0 = sub_8046400(0, 0xFF); +} + +void sub_811F9D0(void) +{ + if (gBattleBufferA[gActiveBank][1] == 0) + { + ewram17810[gActiveBank].unk4 = 0; + gBattleBankFunc[gActiveBank] = sub_811FA5C; + } + else + { + FreeSpriteOamMatrix(&gSprites[gObjectBankIDs[gActiveBank]]); + DestroySprite(&gSprites[gObjectBankIDs[gActiveBank]]); + sub_8043DB0(gHealthboxIDs[gActiveBank]); + LinkPartnerBufferExecCompleted(); + } +} + +void sub_811FA5C(void) +{ + switch (ewram17810[gActiveBank].unk4) + { + case 0: + if (ewram17800[gActiveBank].unk0_2) + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 5); + ewram17810[gActiveBank].unk4 = 1; + break; + case 1: + if (!ewram17810[gActiveBank].unk0_6) + { + ewram17810[gActiveBank].unk4 = 0; + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 1); + gBattleBankFunc[gActiveBank] = sub_811DF34; + } + break; + } +} + +void sub_811FAE4(void) +{ + s16 xOffset; + u32 gender; + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + if (GetBankIdentity(gActiveBank) & 2) + xOffset = 16; + else + xOffset = -16; + gender = gLinkPlayers[sub_803FC34(gActiveBank)].gender; + } + else + { + xOffset = 0; + gender = gLinkPlayers[GetMultiplayerId() ^ 1].gender; + } + sub_8031AF4(gender, gActiveBank); + GetMonSpriteTemplate_803C5A0(gender, GetBankIdentity(gActiveBank)); + gObjectBankIDs[gActiveBank] = CreateSprite( + &gUnknown_02024E8C, + 80 + xOffset, 80 + 4 * (8 - gTrainerBackPicCoords[gender].coords), + sub_8079E90(gActiveBank)); + gSprites[gObjectBankIDs[gActiveBank]].oam.paletteNum = gActiveBank; + gSprites[gObjectBankIDs[gActiveBank]].pos2.x = 240; + gSprites[gObjectBankIDs[gActiveBank]].data0 = -2; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_80313A0; + gBattleBankFunc[gActiveBank] = sub_811DAE4; +} + +void sub_811FC30(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_811FC3C(void) +{ + oamt_add_pos2_onto_pos1(&gSprites[gObjectBankIDs[gActiveBank]]); + gSprites[gObjectBankIDs[gActiveBank]].data0 = 35; + gSprites[gObjectBankIDs[gActiveBank]].data2 = -40; + gSprites[gObjectBankIDs[gActiveBank]].data4 = gSprites[gObjectBankIDs[gActiveBank]].pos1.y; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_8078B34; + oamt_set_x3A_32(&gSprites[gObjectBankIDs[gActiveBank]], SpriteCallbackDummy); + gBattleBankFunc[gActiveBank] = sub_811DB1C; +} + +void sub_811FCE8(void) +{ + if (ewram17810[gActiveBank].unk4 == 0) + { + if (ewram17800[gActiveBank].unk0_2) + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 5); + ewram17810[gActiveBank].unk4++; + } + else if (!ewram17810[gActiveBank].unk0_6) + { + ewram17810[gActiveBank].unk4 = 0; + sub_80324F8(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + PlaySE12WithPanning(SE_POKE_DEAD, -64); + gSprites[gObjectBankIDs[gActiveBank]].data1 = 0; + gSprites[gObjectBankIDs[gActiveBank]].data2 = 5; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_80105EC; + gBattleBankFunc[gActiveBank] = sub_811DE98; + } +} + +void sub_811FDCC(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_811FDD8(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_811FDE4(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_811FDF0(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_811FDFC(void) +{ + if (mplay_80342A4(gActiveBank) == 0) + { + u32 r0 = gBattleBufferA[gActiveBank][1] + | (gBattleBufferA[gActiveBank][2] << 8); + + gUnknown_0202F7C4 = gBattleBufferA[gActiveBank][3]; + gMovePowerMoveAnim = gBattleBufferA[gActiveBank][4] + | (gBattleBufferA[gActiveBank][5] << 8); + gMoveDmgMoveAnim = gBattleBufferA[gActiveBank][6] + | (gBattleBufferA[gActiveBank][7] << 8) + | (gBattleBufferA[gActiveBank][8] << 16) + | (gBattleBufferA[gActiveBank][9] << 24); + gHappinessMoveAnim = gBattleBufferA[gActiveBank][10]; + gWeatherMoveAnim = gBattleBufferA[gActiveBank][12] + | (gBattleBufferA[gActiveBank][13] << 8); + gDisableStructMoveAnim = (u32 *)&gBattleBufferA[gActiveBank][16]; + gPID_perBank[gActiveBank] = *gDisableStructMoveAnim; + + if (sub_8031720(r0, gUnknown_0202F7C4) != 0) + LinkPartnerBufferExecCompleted(); + else + { + ewram17810[gActiveBank].unk4 = 0; + gBattleBankFunc[gActiveBank] = sub_811FF30; + } + } +} + +void sub_811FF30(void) +{ + u16 r4 = gBattleBufferA[gActiveBank][1] + | (gBattleBufferA[gActiveBank][2] << 8); + u8 r7 = gBattleBufferA[gActiveBank][11]; + + switch (ewram17810[gActiveBank].unk4) + { + case 0: + if (ewram17800[gActiveBank].unk0_2 && !ewram17800[gActiveBank].unk0_3) + { + ewram17800[gActiveBank].unk0_3 = 1; + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 5); + } + ewram17810[gActiveBank].unk4 = 1; + break; + case 1: + if (!ewram17810[gActiveBank].unk0_6) + { + sub_80326EC(0); + ExecuteMoveAnim(r4); + ewram17810[gActiveBank].unk4 = 2; + } + break; + case 2: + gAnimScriptCallback(); + if (!gAnimScriptActive) + { + sub_80326EC(1); + if ((ewram17800[gActiveBank].unk0_2) && r7 <= 1) + { + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 6); + ewram17800[gActiveBank].unk0_3 = 0; + } + ewram17810[gActiveBank].unk4 = 3; + } + break; + case 3: + if (!ewram17810[gActiveBank].unk0_6) + { + sub_8031F24(); + sub_80324BC( + gActiveBank, + gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + ewram17810[gActiveBank].unk4 = 0; + LinkPartnerBufferExecCompleted(); + } + break; + } +} + +void sub_8120094(void) +{ + gUnknown_030042A4 = 0; + gUnknown_030042A0 = 0; + BufferStringBattle(*(u16 *)&gBattleBufferA[gActiveBank][2]); + sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + gBattleBankFunc[gActiveBank] = sub_811DFA0; +} + +void sub_81200F8(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120104(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120110(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_812011C(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120128(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120134(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120140(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void LinkPartnerHandleHealthBarUpdate(void) +{ + s16 r7; + + load_gfxc_health_bar(0); + r7 = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + if (r7 != 0x7FFF) + { + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 hp = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + + sub_8043D84(gActiveBank, gHealthboxIDs[gActiveBank], maxHP, hp, r7); + } + else + { + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + + sub_8043D84(gActiveBank, gHealthboxIDs[gActiveBank], maxHP, 0, r7); + } + gBattleBankFunc[gActiveBank] = bx_t3_healthbar_update; +} + +void LinkPartnerHandleExpBarUpdate(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void LinkPartnerHandleStatusIconUpdate(void) +{ + if (mplay_80342A4(gActiveBank) == 0) + { + sub_8045A5C(gHealthboxIDs[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], 9); + ewram17810[gActiveBank].unk0_4 = 0; + gBattleBankFunc[gActiveBank] = sub_811E38C; + } +} + +void LinkPartnerHandleStatusAnimation(void) +{ + if (mplay_80342A4(gActiveBank) == 0) + { + move_anim_start_t2_for_situation( + gBattleBufferA[gActiveBank][1], + gBattleBufferA[gActiveBank][2] + | (gBattleBufferA[gActiveBank][3] << 8) + | (gBattleBufferA[gActiveBank][4] << 16) + | (gBattleBufferA[gActiveBank][5] << 24)); + gBattleBankFunc[gActiveBank] = sub_811E38C; + } +} + +void sub_8120324(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120330(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_812033C(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120348(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120354(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120360(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_812036C(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120378(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120384(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120390(void) +{ + gUnknown_020238C8.unk0_0 = 0; + LinkPartnerBufferExecCompleted(); +} + +void sub_81203AC(void) +{ + gUnknown_020238C8.unk0_0 = gBattleBufferA[gActiveBank][1]; + LinkPartnerBufferExecCompleted(); +} + +void sub_81203E4(void) +{ + gUnknown_020238C8.unk0_7 = 0; + LinkPartnerBufferExecCompleted(); +} + +void sub_81203FC(void) +{ + gUnknown_020238C8.unk0_7 ^= 1; + LinkPartnerBufferExecCompleted(); +} + +void LinkPartnerHandleHitAnimation(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].invisible == TRUE) + LinkPartnerBufferExecCompleted(); + else + { + gDoingBattleAnim = 1; + gSprites[gObjectBankIDs[gActiveBank]].data1 = 0; + sub_8047858(gActiveBank); + gBattleBankFunc[gActiveBank] = bx_blink_t3; + } +} + +void sub_8120494(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void LinkPartnerHandleEffectivenessSound(void) +{ + s8 pan; + + if (GetBankSide(gActiveBank) == 0) + pan = -64; + else + pan = 63; + PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan); + LinkPartnerBufferExecCompleted(); +} + +void sub_81204E4(void) +{ + PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + LinkPartnerBufferExecCompleted(); +} + +void LinkPartnerHandleFaintingCry(void) +{ + PlayCry3( + GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES), + -25, 5); + LinkPartnerBufferExecCompleted(); +} + +void dp01t_2E_3_battle_intro(void) +{ + sub_80E43C0(gBattleBufferA[gActiveBank][1]); + gUnknown_02024DE8 |= 1; + LinkPartnerBufferExecCompleted(); +} + +void sub_8120588(void) +{ + u8 r4; + u8 taskId; + + oamt_add_pos2_onto_pos1(&gSprites[gObjectBankIDs[gActiveBank]]); + gSprites[gObjectBankIDs[gActiveBank]].data0 = 50; + gSprites[gObjectBankIDs[gActiveBank]].data2 = -40; + gSprites[gObjectBankIDs[gActiveBank]].data4 = gSprites[gObjectBankIDs[gActiveBank]].pos1.y; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_8078B34; + gSprites[gObjectBankIDs[gActiveBank]].data5 = gActiveBank; + oamt_set_x3A_32(&gSprites[gObjectBankIDs[gActiveBank]], sub_8030E38); + StartSpriteAnim(&gSprites[gObjectBankIDs[gActiveBank]], 1); + r4 = AllocSpritePalette(0xD6F9); + LoadCompressedPalette( + gTrainerBackPicPaletteTable[gLinkPlayers[sub_803FC34(gActiveBank)].gender].data, + 0x100 + r4 * 16, 0x20); + gSprites[gObjectBankIDs[gActiveBank]].oam.paletteNum = r4; + taskId = CreateTask(sub_812071C, 5); + gTasks[taskId].data[0] = gActiveBank; + if (ewram17810[gActiveBank].unk0_0) + gTasks[gUnknown_02024E68[gActiveBank]].func = sub_8044CA0; + ewram17840.unk9_0 = 1; + gBattleBankFunc[gActiveBank] = nullsub_74; +} + +void sub_812071C(u8 taskId) +{ + u8 r9; + + if (gTasks[taskId].data[1] < 24) + { + gTasks[taskId].data[1]++; + return; + } + + r9 = gActiveBank; + gActiveBank = gTasks[taskId].data[0]; + if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) + { + gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; + sub_811F864(gActiveBank, 0); + } + else + { + gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; + sub_811F864(gActiveBank, 0); + gActiveBank ^= 2; + gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; + sub_80318FC(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + sub_811F864(gActiveBank, 0); + gActiveBank ^= 2; + } + gBattleBankFunc[gActiveBank] = sub_811DCA0; + gActiveBank = r9; + DestroyTask(taskId); +} + +void dp01t_30_3_80EB11C(void) +{ + if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == 0) + { + LinkPartnerBufferExecCompleted(); + return; + } + + ewram17810[gActiveBank].unk0_0 = 1; + gUnknown_02024E68[gActiveBank] = sub_8044804( + gActiveBank, + (struct BattleInterfaceStruct2 *)&gBattleBufferA[gActiveBank][4], + gBattleBufferA[gActiveBank][1], + gBattleBufferA[gActiveBank][2]); + ewram17810[gActiveBank].unk5 = 0; + if (gBattleBufferA[gActiveBank][2] != 0) + ewram17810[gActiveBank].unk5 = 0x5D; + gBattleBankFunc[gActiveBank] = sub_81208E0; +} + +void sub_81208E0(void) +{ + if (ewram17810[gActiveBank].unk5++ >= 93) + { + ewram17810[gActiveBank].unk5 = 0; + LinkPartnerBufferExecCompleted(); + } +} + +void sub_8120920(void) +{ + if (ewram17810[gActiveBank].unk0_0) + gTasks[gUnknown_02024E68[gActiveBank]].func = sub_8044CA0; + LinkPartnerBufferExecCompleted(); +} + +void sub_812096C(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120978(void) +{ + if (sub_8078874(gActiveBank) != 0) + { + gSprites[gObjectBankIDs[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; + sub_8031F88(gActiveBank); + } + LinkPartnerBufferExecCompleted(); +} + +void sub_81209D8(void) +{ + if (mplay_80342A4(gActiveBank) == 0) + { + u8 r3 = gBattleBufferA[gActiveBank][1]; + u16 r4 = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + u8 var = gActiveBank; + + if (move_anim_start_t3(var, var, var, r3, r4) != 0) + LinkPartnerBufferExecCompleted(); + else + gBattleBankFunc[gActiveBank] = sub_811E3B8; + } +} + +void sub_8120A40(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120A4C(void) +{ + LinkPartnerBufferExecCompleted(); +} + +void sub_8120A58(void) +{ + gBattleOutcome = gBattleBufferA[gActiveBank][1]; + FadeOutMapMusic(5); + BeginFastPaletteFade(3); + LinkPartnerBufferExecCompleted(); + gBattleBankFunc[gActiveBank] = sub_811E29C; +} + +void nullsub_75(void) +{ +} diff --git a/src/battle_ai.c b/src/battle_ai.c index d11e4a118..fabe0b61d 100644 --- a/src/battle_ai.c +++ b/src/battle_ai.c @@ -1,1592 +1,2145 @@ #include "global.h" +#include "battle_ai.h" +#include "abilities.h" #include "battle.h" -#include "asm.h" +#include "battle_move_effects.h" +#include "data2.h" +#include "item.h" +#include "moves.h" #include "pokemon.h" #include "rng.h" - -#define AIScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24) -#define AIScriptRead16(ptr) ((ptr)[0] | (ptr)[1] << 8) -#define AIScriptRead8(ptr) ((ptr)[0]) -#define AIScriptReadPtr(ptr) (u8*) AIScriptRead32(ptr) - -/* -this file is a mess. I stopped part way because it starts to involve a huge struct that begins at 0x2000000 and goes -all the way to at least 0x2016800, in addition to extremely hard functions that I can't seem to get right. I am leaving this file -as it currently is until someone bothers to document this huge struct. -*/ - -extern u16 gUnknown_020239F8; -extern u8 gUnknown_02024A60; -extern u8 gUnknown_02024C07; -extern u8 gUnknown_02024C08; -extern u8 gUnknown_02024C0C; -extern u16 gUnknown_02024DEC; -extern u8 gUnknown_02024C68; -extern u32 gUnknown_02024BEC; -extern u8 gUnknown_0201601C; -extern u8 gUnknown_0201601F; -extern u16 gUnknown_02024BE6; -extern u8 gCritMultiplier; -extern u16 gUnknown_02024C34[]; +#include "rom_8077ABC.h" +#include "species.h" +#include "util.h" + +extern u16 gBattleTypeFlags; +extern u16 gBattleWeather; +extern u8 gActiveBank; +extern u8 gBattlePartyID[][2]; +extern u16 gCurrentMove; +extern int gBattleMoveDamage; +extern u8 gBankAttacker; +extern u8 gBankTarget; +extern u8 gAbsentBankFlags; +extern u8 gBattleMoveFlags; +extern u16 gDynamicBasePower; +extern u16 gLastUsedMove[]; extern u32 gUnknown_02024ACC[]; -extern u32 gUnknown_02024C98[]; -extern u16 gUnknown_02024C7A[]; +extern u32 gStatuses3[]; +extern u16 gSideAffecting[]; +extern struct BattlePokemon gBattleMons[]; extern struct BattlePokemon gUnknown_02024A8C[]; -extern u8 gUnknown_030042E0[]; -extern u8 *gAIScriptPtr; +extern u8 gBattleResults[]; +extern u8 gCritMultiplier; extern u16 gTrainerBattleOpponent; -extern u32 gBitTable[]; extern u8 *BattleAIs[]; -extern struct Trainer gTrainers[]; -extern struct BattlePokemon gBattleMons[]; -extern struct BattleMove gBattleMoves[]; -extern struct BaseStats gBaseStats[]; -extern void (*gBattleAICmdTable[])(void); - -struct UnknownStruct1 -{ -/* 0x00 */ u16 unk0[2][8]; -/* 0x20 */ u8 unk20[2]; -/* 0x22 */ u8 unk22[2]; -/* 0x24 */ u16 items[4]; -/* 0x2C */ u8 unk8; -}; -struct UnknownStruct2 /* 0x2016800 */ -{ -/* 0x00 */ u8 unk0; -/* 0x01 */ u8 moveConsidered; -/* 0x02 */ u16 unk2; -/* 0x04 */ s8 score[4]; // score? -/* 0x08 */ u32 unk8; -/* 0x0C */ u32 aiFlags; -/* 0x10 */ u8 unk10; -/* 0x11 */ u8 unk11; -/* 0x12 */ u8 filler12[6]; -/* 0x18 */ u8 unk18[4]; -}; - -struct UnknownStruct3 -{ - u8 filler0[0x20]; - u8 unk20; -}; +/* +gAIScriptPtr is a pointer to the next battle AI cmd command to read. +when a command finishes processing, gAIScriptPtr is incremented by +the number of bytes that the current command had reserved for arguments +in order to read the next command correctly. refer to battle_ai_scripts.s for the +AI scripts. +*/ +extern u8 *gAIScriptPtr; -struct SmallBattleStruct1 -{ - u8 unk1; - u8 unk2; - u8 unk3; - u8 unk4; +static void BattleAICmd_if_random_less_than(void); +static void BattleAICmd_if_random_greater_than(void); +static void BattleAICmd_if_random_equal(void); +static void BattleAICmd_if_random_not_equal(void); +static void BattleAICmd_score(void); +static void BattleAICmd_if_hp_less_than(void); +static void BattleAICmd_if_hp_more_than(void); +static void BattleAICmd_if_hp_equal(void); +static void BattleAICmd_if_hp_not_equal(void); +static void BattleAICmd_if_status(void); +static void BattleAICmd_if_not_status(void); +static void BattleAICmd_if_status2(void); +static void BattleAICmd_if_not_status2(void); +static void BattleAICmd_if_status3(void); +static void BattleAICmd_if_not_status3(void); +static void BattleAICmd_if_status4(void); +static void BattleAICmd_if_not_status4(void); +static void BattleAICmd_if_less_than(void); +static void BattleAICmd_if_more_than(void); +static void BattleAICmd_if_equal(void); +static void BattleAICmd_if_not_equal(void); +static void BattleAICmd_if_less_than_32(void); +static void BattleAICmd_if_more_than_32(void); +static void BattleAICmd_if_equal_32(void); +static void BattleAICmd_if_not_equal_32(void); +static void BattleAICmd_if_move(void); +static void BattleAICmd_if_not_move(void); +static void BattleAICmd_if_in_bytes(void); +static void BattleAICmd_if_not_in_bytes(void); +static void BattleAICmd_if_in_words(void); +static void BattleAICmd_if_not_in_words(void); +static void BattleAICmd_if_user_can_damage(void); +static void BattleAICmd_if_user_cant_damage(void); +static void BattleAICmd_get_turn_count(void); +static void BattleAICmd_get_type(void); +static void BattleAICmd_get_move_power(void); +static void BattleAICmd_is_most_powerful_move(void); +static void BattleAICmd_get_move(void); +static void BattleAICmd_if_arg_equal(void); +static void BattleAICmd_if_arg_not_equal(void); +static void BattleAICmd_if_would_go_first(void); +static void BattleAICmd_if_would_not_go_first(void); +static void BattleAICmd_nullsub_2A(void); +static void BattleAICmd_nullsub_2B(void); +static void BattleAICmd_count_alive_pokemon(void); +static void BattleAICmd_get_considered_move(void); +static void BattleAICmd_get_considered_move_effect(void); +static void BattleAICmd_get_ability(void); +static void BattleAICmd_get_highest_possible_damage(void); +static void BattleAICmd_if_damage_bonus(void); +static void BattleAICmd_nullsub_32(void); +static void BattleAICmd_nullsub_33(void); +static void BattleAICmd_if_status_in_party(void); +static void BattleAICmd_if_status_not_in_party(void); +static void BattleAICmd_get_weather(void); +static void BattleAICmd_if_effect(void); +static void BattleAICmd_if_not_effect(void); +static void BattleAICmd_if_stat_level_less_than(void); +static void BattleAICmd_if_stat_level_more_than(void); +static void BattleAICmd_if_stat_level_equal(void); +static void BattleAICmd_if_stat_level_not_equal(void); +static void BattleAICmd_if_can_faint(void); +static void BattleAICmd_if_cant_faint(void); +static void BattleAICmd_if_has_move(void); +static void BattleAICmd_if_dont_have_move(void); +static void BattleAICmd_if_move_effect(void); +static void BattleAICmd_if_not_move_effect(void); +static void BattleAICmd_if_last_move_did_damage(void); +static void BattleAICmd_if_encored(void); +static void BattleAICmd_flee(void); +static void BattleAICmd_if_random_100(void); +static void BattleAICmd_watch(void); +static void BattleAICmd_get_hold_effect(void); +static void BattleAICmd_get_gender(void); +static void BattleAICmd_is_first_turn(void); +static void BattleAICmd_get_stockpile_count(void); +static void BattleAICmd_is_double_battle(void); +static void BattleAICmd_get_item(void); +static void BattleAICmd_get_move_type_from_result(void); +static void BattleAICmd_get_move_power_from_result(void); +static void BattleAICmd_get_move_effect_from_result(void); +static void BattleAICmd_get_protect_count(void); +static void BattleAICmd_nullsub_52(void); +static void BattleAICmd_nullsub_53(void); +static void BattleAICmd_nullsub_54(void); +static void BattleAICmd_nullsub_55(void); +static void BattleAICmd_nullsub_56(void); +static void BattleAICmd_nullsub_57(void); +static void BattleAICmd_call(void); +static void BattleAICmd_jump(void); +static void BattleAICmd_end(void); +static void BattleAICmd_if_level_compare(void); +static void BattleAICmd_if_taunted(void); +static void BattleAICmd_if_not_taunted(void); + +typedef void (*BattleAICmdFunc)(void); + +static const BattleAICmdFunc sBattleAICmdTable[] = +{ + BattleAICmd_if_random_less_than, + BattleAICmd_if_random_greater_than, + BattleAICmd_if_random_equal, + BattleAICmd_if_random_not_equal, + BattleAICmd_score, + BattleAICmd_if_hp_less_than, + BattleAICmd_if_hp_more_than, + BattleAICmd_if_hp_equal, + BattleAICmd_if_hp_not_equal, + BattleAICmd_if_status, + BattleAICmd_if_not_status, + BattleAICmd_if_status2, + BattleAICmd_if_not_status2, + BattleAICmd_if_status3, + BattleAICmd_if_not_status3, + BattleAICmd_if_status4, + BattleAICmd_if_not_status4, + BattleAICmd_if_less_than, + BattleAICmd_if_more_than, + BattleAICmd_if_equal, + BattleAICmd_if_not_equal, + BattleAICmd_if_less_than_32, + BattleAICmd_if_more_than_32, + BattleAICmd_if_equal_32, + BattleAICmd_if_not_equal_32, + BattleAICmd_if_move, + BattleAICmd_if_not_move, + BattleAICmd_if_in_bytes, + BattleAICmd_if_not_in_bytes, + BattleAICmd_if_in_words, + BattleAICmd_if_not_in_words, + BattleAICmd_if_user_can_damage, + BattleAICmd_if_user_cant_damage, + BattleAICmd_get_turn_count, + BattleAICmd_get_type, + BattleAICmd_get_move_power, + BattleAICmd_is_most_powerful_move, + BattleAICmd_get_move, + BattleAICmd_if_arg_equal, + BattleAICmd_if_arg_not_equal, + BattleAICmd_if_would_go_first, + BattleAICmd_if_would_not_go_first, + BattleAICmd_nullsub_2A, + BattleAICmd_nullsub_2B, + BattleAICmd_count_alive_pokemon, + BattleAICmd_get_considered_move, + BattleAICmd_get_considered_move_effect, + BattleAICmd_get_ability, + BattleAICmd_get_highest_possible_damage, + BattleAICmd_if_damage_bonus, + BattleAICmd_nullsub_32, + BattleAICmd_nullsub_33, + BattleAICmd_if_status_in_party, + BattleAICmd_if_status_not_in_party, + BattleAICmd_get_weather, + BattleAICmd_if_effect, + BattleAICmd_if_not_effect, + BattleAICmd_if_stat_level_less_than, + BattleAICmd_if_stat_level_more_than, + BattleAICmd_if_stat_level_equal, + BattleAICmd_if_stat_level_not_equal, + BattleAICmd_if_can_faint, + BattleAICmd_if_cant_faint, + BattleAICmd_if_has_move, + BattleAICmd_if_dont_have_move, + BattleAICmd_if_move_effect, + BattleAICmd_if_not_move_effect, + BattleAICmd_if_last_move_did_damage, + BattleAICmd_if_encored, + BattleAICmd_flee, + BattleAICmd_if_random_100, + BattleAICmd_watch, + BattleAICmd_get_hold_effect, + BattleAICmd_get_gender, + BattleAICmd_is_first_turn, + BattleAICmd_get_stockpile_count, + BattleAICmd_is_double_battle, + BattleAICmd_get_item, + BattleAICmd_get_move_type_from_result, + BattleAICmd_get_move_power_from_result, + BattleAICmd_get_move_effect_from_result, + BattleAICmd_get_protect_count, + BattleAICmd_nullsub_52, + BattleAICmd_nullsub_53, + BattleAICmd_nullsub_54, + BattleAICmd_nullsub_55, + BattleAICmd_nullsub_56, + BattleAICmd_nullsub_57, + BattleAICmd_call, + BattleAICmd_jump, + BattleAICmd_end, + BattleAICmd_if_level_compare, + BattleAICmd_if_taunted, + BattleAICmd_if_not_taunted, }; -// move to battle.h before PR. -struct BattleStruct /* 0x2000000 */ -{ - u8 filler0[0x1601C]; - struct SmallBattleStruct1 unk; +#ifdef NONMATCHING +static +#endif +const u16 sDiscouragedPowerfulMoveEffects[] = +{ + EFFECT_EXPLOSION, + EFFECT_DREAM_EATER, + EFFECT_RAZOR_WIND, + EFFECT_SKY_ATTACK, + EFFECT_RECHARGE, + EFFECT_SKULL_BASH, + EFFECT_SOLARBEAM, + EFFECT_SPIT_UP, + EFFECT_FOCUS_PUNCH, + EFFECT_SUPERPOWER, + EFFECT_ERUPTION, + EFFECT_OVERHEAT, + 0xFFFF }; -extern struct BattleStruct unk_2000000; -extern struct UnknownStruct2 unk_2016800; -extern struct UnknownStruct1 unk_2016A00; -extern struct UnknownStruct3 unk_2016C00; - -void sub_810715C(void); -void sub_8107374(void); -void sub_810745C(void); - -void sub_81070D4(void) +// if the AI is a Link battle, safari, battle tower, or ereader, it will ignore considering item uses. +void BattleAI_HandleItemUseBeforeAISetup(void) { s32 i; - u8 *data = (u8 *)&unk_2016A00; - - for(i = 0; (u32)i < 48; i++) + u8 *data = (u8 *)UNK_2016A00_STRUCT; + + for (i = 0; (u32)i < sizeof(struct UnkBattleStruct1); i++) data[i] = 0; - if((gUnknown_020239F8 & 8) && gTrainerBattleOpponent != 0x400 && !(gUnknown_020239F8 & 0x982)) + + if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER) + && gTrainerBattleOpponent != 0x400 + && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_SAFARI | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_EREADER_TRAINER))) { - for(i = 0; i < 4; i++) + for (i = 0; i < MAX_TRAINER_ITEMS; i++) { - if(gTrainers[gTrainerBattleOpponent].items[i] != 0) + if (gTrainers[gTrainerBattleOpponent].items[i] != 0) { - unk_2016A00.items[unk_2016A00.unk8] = gTrainers[gTrainerBattleOpponent].items[i]; - unk_2016A00.unk8++; + UNK_2016A00_STRUCT->items[UNK_2016A00_STRUCT->numOfItems] = gTrainers[gTrainerBattleOpponent].items[i]; + UNK_2016A00_STRUCT->numOfItems++; } } } - sub_810715C(); + + BattleAI_SetupAIData(); } -void sub_810715C(void) +void BattleAI_SetupAIData(void) { s32 i; - u8 *data = (u8 *)&unk_2016800; + u8 *data = (u8 *)AI_THINKING_STRUCT; u8 r7; - - for(i = 0; (u32)i < 28; i++) + + // clear AI data and set default move score to 100. strange that they didn't use memset here. + for (i = 0; (u32)i < sizeof(struct AI_ThinkingStruct); i++) data[i] = 0; - for(i = 0; i < 4; i++) - unk_2016800.score[i] = 100; - r7 = sub_8015A98(gUnknown_02024A60, 0, 0xFF); - for(i = 0; i < 4; i++) + for (i = 0; i < MAX_MON_MOVES; i++) + AI_THINKING_STRUCT->score[i] = 100; + + r7 = sub_8015A98(gActiveBank, 0, 0xFF); + + // probably sets up the moves to consider and ignores non-valid moves such as NO_MOVE or glitch moves. + for (i = 0; i < MAX_MON_MOVES; i++) { - u16 rand; - - if(gBitTable[i] & r7) - unk_2016800.score[i] = 0; - rand = Random(); - unk_2016800.unk18[i] = 100 - (rand & 0xF); + if (gBitTable[i] & r7) + AI_THINKING_STRUCT->score[i] = 0; + + AI_THINKING_STRUCT->simulatedRNG[i] = 100 - (Random() % 16); } - unk_2016C00.unk20 = 0; - gUnknown_02024C07 = gUnknown_02024A60; - - if(gUnknown_020239F8 & 1) + + // clear AI stack. + AI_STACK->size = 0; + gBankAttacker = gActiveBank; + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - gUnknown_02024C08 = Random() & 2; - - if(gUnknown_02024C0C & gBitTable[gUnknown_02024C08]) - gUnknown_02024C08 ^= 2; + gBankTarget = Random() & 2; // just pick somebody to target. + + if (gAbsentBankFlags & gBitTable[gBankTarget]) + gBankTarget ^= 2; } else - gUnknown_02024C08 = gUnknown_02024A60 ^ 1; - - if(gUnknown_020239F8 & 0x80) - unk_2016800.aiFlags = 0x40000000; - else if(gUnknown_020239F8 & 0x400) - unk_2016800.aiFlags = 0x20000000; - else if(gUnknown_020239F8 & 0x10) - unk_2016800.aiFlags = 0x80000000; - else - unk_2016800.aiFlags = gTrainers[gTrainerBattleOpponent].aiFlags; + gBankTarget = gActiveBank ^ 1; + + // special AI flag cases. + if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) + AI_THINKING_STRUCT->aiFlags = 0x40000000; + else if (gBattleTypeFlags & BATTLE_TYPE_ROAMER) + AI_THINKING_STRUCT->aiFlags = 0x20000000; + else if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE) + AI_THINKING_STRUCT->aiFlags = 0x80000000; +#ifdef GERMAN + else if (gBattleTypeFlags & 0x900 || gTrainerBattleOpponent == 0x400) + AI_THINKING_STRUCT->aiFlags = 7; +#endif + else // otherwise, just set aiFlags to whatever flags the trainer has set in their data. + AI_THINKING_STRUCT->aiFlags = gTrainers[gTrainerBattleOpponent].aiFlags; } -u8 sub_81072A8(void) +u8 BattleAI_GetAIActionToUse(void) { - u8 arr1[4]; - u8 arr2[4]; - u8 r5; + u8 currentMoveArray[MAX_MON_MOVES]; + u8 consideredMoveArray[MAX_MON_MOVES]; + u8 numOfBestMoves; s32 i; - + sub_810745C(); - while(unk_2016800.aiFlags != 0) + while (AI_THINKING_STRUCT->aiFlags != 0) { - if(unk_2016800.aiFlags & 1) + if (AI_THINKING_STRUCT->aiFlags & 1) { - unk_2016800.unk0 = 0; - sub_8107374(); + AI_THINKING_STRUCT->aiState = AIState_SettingUp; + BattleAI_DoAIProcessing(); } - unk_2016800.aiFlags >>= 1; - unk_2016800.unk11++; - unk_2016800.moveConsidered = 0; + AI_THINKING_STRUCT->aiFlags >>= 1; + AI_THINKING_STRUCT->aiLogicId++; + AI_THINKING_STRUCT->movesetIndex = 0; } - if(unk_2016800.unk10 & 2) + + // special flee or watch cases for safari. + if (AI_THINKING_STRUCT->aiAction & (AI_ACTION_FLEE)) // flee return 4; - if(unk_2016800.unk10 & 4) + if (AI_THINKING_STRUCT->aiAction & (AI_ACTION_WATCH)) // watch return 5; - r5 = 1; - arr1[0] = unk_2016800.score[0]; - arr2[0] = 0; - for(i = 1; i < 4; i++) + + numOfBestMoves = 1; + currentMoveArray[0] = AI_THINKING_STRUCT->score[0]; + consideredMoveArray[0] = 0; + + for (i = 1; i < MAX_MON_MOVES; i++) { - if(arr1[0] < (s8)unk_2016800.score[i]) + if (currentMoveArray[0] < AI_THINKING_STRUCT->score[i]) { - r5 = 1; - arr1[0] = unk_2016800.score[i]; - arr2[0] = i; + numOfBestMoves = 1; + currentMoveArray[0] = AI_THINKING_STRUCT->score[i]; + consideredMoveArray[0] = i; } - if(arr1[0] == (s8)unk_2016800.score[i]) + if (currentMoveArray[0] == AI_THINKING_STRUCT->score[i]) { - arr1[r5] = unk_2016800.score[i]; - arr2[r5++] = i; + currentMoveArray[numOfBestMoves] = AI_THINKING_STRUCT->score[i]; + consideredMoveArray[numOfBestMoves++] = i; } } - return arr2[Random() % r5]; + + return consideredMoveArray[Random() % numOfBestMoves]; // break any ties that exist. } -void sub_8107374(void) +void BattleAI_DoAIProcessing(void) { - while(unk_2016800.unk0 != 2) + while (AI_THINKING_STRUCT->aiState != AIState_FinishedProcessing) { - switch(unk_2016800.unk0) + switch (AI_THINKING_STRUCT->aiState) { - case 3: //Needed to match. + case AIState_DoNotProcess: //Needed to match. break; - case 0: - gAIScriptPtr = BattleAIs[unk_2016800.unk11]; - if(gBattleMons[gUnknown_02024C07].pp[unk_2016800.moveConsidered] == 0) + case AIState_SettingUp: + gAIScriptPtr = BattleAIs[AI_THINKING_STRUCT->aiLogicId]; // set the AI ptr. + if (gBattleMons[gBankAttacker].pp[AI_THINKING_STRUCT->movesetIndex] == 0) { - unk_2016800.unk2 = 0; + AI_THINKING_STRUCT->moveConsidered = MOVE_NONE; // don't consider a move you have 0 PP for, idiot. } else { - unk_2016800.unk2 = gBattleMons[gUnknown_02024C07].moves[unk_2016800.moveConsidered]; + AI_THINKING_STRUCT->moveConsidered = gBattleMons[gBankAttacker].moves[AI_THINKING_STRUCT->movesetIndex]; } - unk_2016800.unk0++; + AI_THINKING_STRUCT->aiState++; break; - case 1: - if(unk_2016800.unk2 != 0) - gBattleAICmdTable[*(u8 *)gAIScriptPtr](); //weird... + case AIState_Processing: + if (AI_THINKING_STRUCT->moveConsidered != MOVE_NONE) + sBattleAICmdTable[*(u8 *)gAIScriptPtr](); // run AI command. else { - unk_2016800.score[unk_2016800.moveConsidered] = 0; - unk_2016800.unk10 |= 1; + AI_THINKING_STRUCT->score[AI_THINKING_STRUCT->movesetIndex] = 0; // definitely do not consider any move that has 0 PP. + AI_THINKING_STRUCT->aiAction |= AI_ACTION_DONE; } - if(unk_2016800.unk10 & 1) + if (AI_THINKING_STRUCT->aiAction & AI_ACTION_DONE) { - unk_2016800.moveConsidered++; - if(unk_2016800.moveConsidered < 4 && !(unk_2016800.unk10 & 8)) - unk_2016800.unk0 = 0; + AI_THINKING_STRUCT->movesetIndex++; + if (AI_THINKING_STRUCT->movesetIndex < MAX_MON_MOVES && (AI_THINKING_STRUCT->aiAction & AI_ACTION_DO_NOT_ATTACK) == 0) + AI_THINKING_STRUCT->aiState = AIState_SettingUp; // as long as their are more moves to process, keep setting this to setup state. else - unk_2016800.unk0++; - unk_2016800.unk10 &= 0xFE; + AI_THINKING_STRUCT->aiState++; // done processing. + AI_THINKING_STRUCT->aiAction &= (AI_ACTION_FLEE | AI_ACTION_WATCH | AI_ACTION_DO_NOT_ATTACK | + AI_ACTION_UNK5 | AI_ACTION_UNK6 | AI_ACTION_UNK7 | AI_ACTION_UNK8); // disable AI_ACTION_DONE. } break; } } } -#ifdef NONMATCHING void sub_810745C(void) { s32 i; - - for(i = 0; i < 8; i++) + + for (i = 0; i < 8; i++) { - if(unk_2016A00.unk0[gUnknown_02024C08 / 2][i] == 0) + if (UNK_2016A00_STRUCT->movesUsed[gBankTarget >> 1][i] == 0) { - //gUnknown_02024C34[gUnknown_02024C08] += 0; - unk_2016A00.unk0[gUnknown_02024C08 / 2][i] = gUnknown_02024C34[gUnknown_02024C08]; + UNK_2016A00_STRUCT->movesUsed[gBankTarget >> 1][i] = gLastUsedMove[gBankTarget]; return; } } } -#else -__attribute__((naked)) -void sub_810745C(void) -{ - asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - movs r2, 0\n\ - ldr r3, _08107488 @ =gUnknown_02024C08\n\ - ldr r5, _0810748C @ =0x02016a00\n\ - ldr r6, _08107490 @ =gUnknown_02024C34\n\ - adds r4, r3, 0\n\ -_08107468:\n\ - lsls r0, r2, 1\n\ - ldrb r1, [r4]\n\ - lsrs r1, 1\n\ - lsls r1, 4\n\ - adds r0, r1\n\ - adds r1, r0, r5\n\ - ldrh r0, [r1]\n\ - cmp r0, 0\n\ - bne _08107494\n\ - ldrb r0, [r3]\n\ - lsls r0, 1\n\ - adds r0, r6\n\ - ldrh r0, [r0]\n\ - strh r0, [r1]\n\ - b _0810749A\n\ - .align 2, 0\n\ -_08107488: .4byte gUnknown_02024C08\n\ -_0810748C: .4byte 0x02016a00\n\ -_08107490: .4byte gUnknown_02024C34\n\ -_08107494:\n\ - adds r2, 0x1\n\ - cmp r2, 0x7\n\ - ble _08107468\n\ -_0810749A:\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided"); -} -#endif void unref_sub_81074A0(u8 a) { s32 i; - - for(i = 0; i < 8; i++) - unk_2016A00.unk0[a / 2][i] = 0; + + for (i = 0; i < 8; i++) + UNK_2016A00_STRUCT->movesUsed[a / 2][i] = 0; } void sub_81074C4(u8 a, u8 b) { - if(battle_side_get_owner(a) == 0) - unk_2016A00.unk20[battle_get_per_side_status(a) & 1] = b; + if (GetBankSide(a) == 0) + UNK_2016A00_STRUCT->unk20[GetBankIdentity(a) & 1] = b; } void sub_81074F8(u8 a, u8 b) { - if(battle_side_get_owner(a) == 0) - unk_2016A00.unk22[battle_get_per_side_status(a) & 1] = b; + if (GetBankSide(a) == 0) + UNK_2016A00_STRUCT->unk22[GetBankIdentity(a) & 1] = b; } -void BattleAICmd_if_random(void) +static void BattleAICmd_if_random_less_than(void) { - u16 random = Random(); - - if (!(random % 256 >= gAIScriptPtr[1])) // roll a random value. is it less than the parameter of the if_random call? (96 on if_random 80 will return true) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + if (Random() % 256 < gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; } -void BattleAICmd_if_not_random(void) +static void BattleAICmd_if_random_greater_than(void) { - u16 random = Random(); - - if (!(random % 256 <= gAIScriptPtr[1])) // roll a random value. is it greater than the parameter of the if_random call? (96 on if_random 80 will return true) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + if (Random() % 256 > gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; } -void BattleAICmd_if_random_1(void) // if RNG Value equal to +static void BattleAICmd_if_random_equal(void) { - u16 random = Random(); - - if (random % 256 == gAIScriptPtr[1]) // roll a random value. is it greater than the parameter of the if_random call? (96 on if_random 80 will return true) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + if (Random() % 256 == gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; } -void BattleAICmd_if_not_random_1(void) // if RNG value not equal to +static void BattleAICmd_if_random_not_equal(void) { - u16 random = Random(); - - if (random % 256 != gAIScriptPtr[1]) // roll a random value. is it greater than the parameter of the if_random call? (96 on if_random 80 will return true) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + if (Random() % 256 != gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; } -void BattleAICmd_score(void) +static void BattleAICmd_score(void) { - unk_2016800.score[unk_2016800.moveConsidered] += gAIScriptPtr[1]; // add the result to the array of the move consider's score. - - if(unk_2016800.score[unk_2016800.moveConsidered] < 0) // if the score is negative, flatten it to 0. - unk_2016800.score[unk_2016800.moveConsidered] = 0; + AI_THINKING_STRUCT->score[AI_THINKING_STRUCT->movesetIndex] += gAIScriptPtr[1]; // add the result to the array of the move consider's score. + + if (AI_THINKING_STRUCT->score[AI_THINKING_STRUCT->movesetIndex] < 0) // if the score is negative, flatten it to 0. + AI_THINKING_STRUCT->score[AI_THINKING_STRUCT->movesetIndex] = 0; - gAIScriptPtr += 2; // AI return. + gAIScriptPtr += 2; // AI return. } -void BattleAICmd_if_hp_less_than(void) +static void BattleAICmd_if_hp_less_than(void) { - u16 var; - - if ( gAIScriptPtr[1] == 1 ) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - if ((u32)(100 * gBattleMons[var].hp / gBattleMons[var].maxHP) < gAIScriptPtr[2]) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); - else - gAIScriptPtr += 7; + u16 index; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) < gAIScriptPtr[2]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); + else + gAIScriptPtr += 7; } -void BattleAICmd_if_hp_more_than(void) +static void BattleAICmd_if_hp_more_than(void) { - u16 var; - - if ( gAIScriptPtr[1] == 1 ) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - if ((u32)(100 * gBattleMons[var].hp / gBattleMons[var].maxHP) > gAIScriptPtr[2]) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); - else - gAIScriptPtr += 7; -} - -void BattleAICmd_if_hp_equal(void) + u16 index; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) > gAIScriptPtr[2]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); + else + gAIScriptPtr += 7; +} + +static void BattleAICmd_if_hp_equal(void) { - u16 var; - - if ( gAIScriptPtr[1] == 1 ) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - if ((u32)(100 * gBattleMons[var].hp / gBattleMons[var].maxHP) == gAIScriptPtr[2]) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); - else - gAIScriptPtr += 7; -} - -void BattleAICmd_if_hp_not_equal(void) -{ - u16 var; - - if ( gAIScriptPtr[1] == 1 ) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - if ((u32)(100 * gBattleMons[var].hp / gBattleMons[var].maxHP) != gAIScriptPtr[2]) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); - else - gAIScriptPtr += 7; -} - -void BattleAICmd_if_status(void) -{ - u16 var; - u32 temp; - - if ( gAIScriptPtr[1] == 1 ) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - temp = AIScriptRead32(gAIScriptPtr + 2); - - if (gBattleMons[var].status1 & temp) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); - else - gAIScriptPtr += 10; -} - -void BattleAICmd_if_not_status(void) -{ - u16 var; - u32 temp; - - if ( gAIScriptPtr[1] == 1 ) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - temp = AIScriptRead32(gAIScriptPtr + 2); - - if (!(gBattleMons[var].status1 & temp)) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); - else - gAIScriptPtr += 10; -} - -void BattleAICmd_if_status2(void) -{ - u8 var; - u32 temp; - - if ( gAIScriptPtr[1] == 1 ) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - temp = AIScriptRead32(gAIScriptPtr + 2); - - if (gBattleMons[var].status2 & temp) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); - else - gAIScriptPtr += 10; -} - -void BattleAICmd_if_not_status2(void) -{ - u8 var; - u32 temp; - - if ( gAIScriptPtr[1] == 1 ) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - temp = AIScriptRead32(gAIScriptPtr + 2); - - if (!(gBattleMons[var].status2 & temp)) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); - else - gAIScriptPtr += 10; -} - -void BattleAICmd_if_status3(void) -{ - u8 var; - u32 temp; - - if ( gAIScriptPtr[1] == 1 ) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - temp = AIScriptRead32(gAIScriptPtr + 2); - - if ( gUnknown_02024C98[var] & temp ) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); - else - gAIScriptPtr += 10; -} - -void BattleAICmd_if_not_status3(void) -{ - u8 var; - u32 temp; - - if ( gAIScriptPtr[1] == 1 ) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - temp = AIScriptRead32(gAIScriptPtr + 2); - - if (!(gUnknown_02024C98[var] & temp)) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); - else - gAIScriptPtr += 10; -} - -void BattleAICmd_if_status4(void) + u16 index; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) == gAIScriptPtr[2]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); + else + gAIScriptPtr += 7; +} + +static void BattleAICmd_if_hp_not_equal(void) +{ + u16 index; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) != gAIScriptPtr[2]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); + else + gAIScriptPtr += 7; +} + +static void BattleAICmd_if_status(void) +{ + u16 index; + u32 arg; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + arg = AIScriptRead32(gAIScriptPtr + 2); + + if ((gBattleMons[index].status1 & arg) != 0) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); + else + gAIScriptPtr += 10; +} + +static void BattleAICmd_if_not_status(void) +{ + u16 index; + u32 arg; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + arg = AIScriptRead32(gAIScriptPtr + 2); + + if ((gBattleMons[index].status1 & arg) == 0) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); + else + gAIScriptPtr += 10; +} + +static void BattleAICmd_if_status2(void) +{ + u16 index; + u32 arg; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + arg = AIScriptRead32(gAIScriptPtr + 2); + + if ((gBattleMons[index].status2 & arg) != 0) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); + else + gAIScriptPtr += 10; +} + +static void BattleAICmd_if_not_status2(void) +{ + u16 index; + u32 arg; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + arg = AIScriptRead32(gAIScriptPtr + 2); + + if ((gBattleMons[index].status2 & arg) == 0) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); + else + gAIScriptPtr += 10; +} + +static void BattleAICmd_if_status3(void) { - u8 var; - u32 temp; - u32 temp2; - - if ( gAIScriptPtr[1] == 1 ) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - temp = battle_get_per_side_status(var) & 1; - temp2 = AIScriptRead32(gAIScriptPtr + 2); - - if ( gUnknown_02024C7A[temp] & temp2 ) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); - else - gAIScriptPtr += 10; + u16 index; + u32 arg; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + arg = AIScriptRead32(gAIScriptPtr + 2); + + if ((gStatuses3[index] & arg) != 0) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); + else + gAIScriptPtr += 10; } -void BattleAICmd_if_not_status4(void) +static void BattleAICmd_if_not_status3(void) { - u8 var; - u32 temp; - u32 temp2; - - if (gAIScriptPtr[1] == 1) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - - temp = battle_get_per_side_status(var) & 1; - temp2 = AIScriptRead32(gAIScriptPtr + 2); - - if (!(gUnknown_02024C7A[temp] & temp2)) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); - else - gAIScriptPtr += 10; + u16 index; + u32 arg; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + arg = AIScriptRead32(gAIScriptPtr + 2); + + if ((gStatuses3[index] & arg) == 0) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); + else + gAIScriptPtr += 10; } -void BattleAICmd_if_less_than(void) +static void BattleAICmd_if_status4(void) { - if (unk_2016800.unk8 < gAIScriptPtr[1]) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + u16 index; + u32 arg1, arg2; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + arg1 = GetBankIdentity(index) & 1; + arg2 = AIScriptRead32(gAIScriptPtr + 2); + + if ((gSideAffecting[arg1] & arg2) != 0) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); + else + gAIScriptPtr += 10; } -void BattleAICmd_if_more_than(void) +static void BattleAICmd_if_not_status4(void) { - if (unk_2016800.unk8 > gAIScriptPtr[1]) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + u16 index; + u32 arg1, arg2; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + arg1 = GetBankIdentity(index) & 1; + arg2 = AIScriptRead32(gAIScriptPtr + 2); + + if ((gSideAffecting[arg1] & arg2) == 0) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); + else + gAIScriptPtr += 10; } -void BattleAICmd_if_equal(void) +static void BattleAICmd_if_less_than(void) { - if (unk_2016800.unk8 == gAIScriptPtr[1]) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + if (AI_THINKING_STRUCT->funcResult < gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; } -void BattleAICmd_if_not_equal(void) +static void BattleAICmd_if_more_than(void) { - if (unk_2016800.unk8 != gAIScriptPtr[1]) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + if (AI_THINKING_STRUCT->funcResult > gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; } -void BattleAICmd_if_less_than_32(void) +static void BattleAICmd_if_equal(void) { - u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); + if (AI_THINKING_STRUCT->funcResult == gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; +} - if (unk_2016800.unk8 < *temp) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); - else - gAIScriptPtr += 9; +static void BattleAICmd_if_not_equal(void) +{ + if (AI_THINKING_STRUCT->funcResult != gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; } -void BattleAICmd_if_more_than_32(void) +static void BattleAICmd_if_less_than_32(void) { - u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); + u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); - if (unk_2016800.unk8 > *temp) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); - else - gAIScriptPtr += 9; + if (AI_THINKING_STRUCT->funcResult < *temp) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); + else + gAIScriptPtr += 9; } -void BattleAICmd_if_equal_32(void) +static void BattleAICmd_if_more_than_32(void) { - u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); + u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); - if (unk_2016800.unk8 == *temp) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); - else - gAIScriptPtr += 9; + if (AI_THINKING_STRUCT->funcResult > *temp) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); + else + gAIScriptPtr += 9; } -void BattleAICmd_if_not_equal_32(void) +static void BattleAICmd_if_equal_32(void) { - u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); + u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); - if (unk_2016800.unk8 != *temp) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); - else - gAIScriptPtr += 9; + if (AI_THINKING_STRUCT->funcResult == *temp) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); + else + gAIScriptPtr += 9; } -void BattleAICmd_if_move(void) +static void BattleAICmd_if_not_equal_32(void) { - u16 move = AIScriptRead16(gAIScriptPtr + 1); + u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); - if (unk_2016800.unk2 == move) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); - else - gAIScriptPtr += 7; + if (AI_THINKING_STRUCT->funcResult != *temp) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); + else + gAIScriptPtr += 9; } -void BattleAICmd_if_not_move(void) +static void BattleAICmd_if_move(void) { - u16 move = AIScriptRead16(gAIScriptPtr + 1); + u16 move = AIScriptRead16(gAIScriptPtr + 1); - if (unk_2016800.unk2 != move) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); - else - gAIScriptPtr += 7; + if (AI_THINKING_STRUCT->moveConsidered == move) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); + else + gAIScriptPtr += 7; } -void BattleAICmd_if_in_bytes(void) +static void BattleAICmd_if_not_move(void) +{ + u16 move = AIScriptRead16(gAIScriptPtr + 1); + + if (AI_THINKING_STRUCT->moveConsidered != move) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); + else + gAIScriptPtr += 7; +} + +static void BattleAICmd_if_in_bytes(void) { u8 *ptr = AIScriptReadPtr(gAIScriptPtr + 1); - - while(*ptr != 0xFF) - { - if(unk_2016800.unk8 == *ptr) - { - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); - return; - } - ptr++; - } - gAIScriptPtr += 9; + + while (*ptr != 0xFF) + { + if (AI_THINKING_STRUCT->funcResult == *ptr) + { + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); + return; + } + ptr++; + } + gAIScriptPtr += 9; } -void BattleAICmd_if_not_in_bytes(void) +static void BattleAICmd_if_not_in_bytes(void) { u8 *ptr = AIScriptReadPtr(gAIScriptPtr + 1); - - while(*ptr != 0xFF) - { - if(unk_2016800.unk8 == *ptr) - { - gAIScriptPtr += 9; - return; - } - ptr++; - } - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); + + while (*ptr != 0xFF) + { + if (AI_THINKING_STRUCT->funcResult == *ptr) + { + gAIScriptPtr += 9; + return; + } + ptr++; + } + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); } -void BattleAICmd_if_in_words(void) +static void BattleAICmd_if_in_words(void) { u16 *ptr = (u16 *)AIScriptReadPtr(gAIScriptPtr + 1); - - while(*ptr != 0xFFFF) - { - if(unk_2016800.unk8 == *ptr) - { - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); - return; - } - ptr++; - } - gAIScriptPtr += 9; + + while (*ptr != 0xFFFF) + { + if (AI_THINKING_STRUCT->funcResult == *ptr) + { + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); + return; + } + ptr++; + } + gAIScriptPtr += 9; } -void BattleAICmd_if_not_in_words(void) +static void BattleAICmd_if_not_in_words(void) { u16 *ptr = (u16 *)AIScriptReadPtr(gAIScriptPtr + 1); - - while(*ptr != 0xFFFF) - { - if(unk_2016800.unk8 == *ptr) - { - gAIScriptPtr += 9; - return; - } - ptr++; - } - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); -} - -void BattleAICmd_if_user_can_damage(void) -{ - s32 i; - - for(i = 0; i < 4; i++) - { - if (gBattleMons[gUnknown_02024C07].moves[i] != 0 - && gBattleMoves[gBattleMons[gUnknown_02024C07].moves[i]].power != 0) - break; - } - if(i == 4) - gAIScriptPtr += 5; - else - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); -} - -void BattleAICmd_if_user_cant_damage(void) -{ - s32 i; - - for(i = 0; i < 4; i++) - { - if (gBattleMons[gUnknown_02024C07].moves[i] != 0 - && gBattleMoves[gBattleMons[gUnknown_02024C07].moves[i]].power != 0) - break; - } - if(i != 4) - gAIScriptPtr += 5; - else - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); -} - -void BattleAICmd_unk_21(void) -{ - unk_2016800.unk8 = gUnknown_030042E0[19]; - gAIScriptPtr += 1; -} - -void BattleAICmd_get_type(void) -{ - u8 typeVar = gAIScriptPtr[1]; - - switch(typeVar) - { - case 1: - unk_2016800.unk8 = gBattleMons[gUnknown_02024C07].type1; - break; - case 0: - unk_2016800.unk8 = gBattleMons[gUnknown_02024C08].type1; - break; - case 3: - unk_2016800.unk8 = gBattleMons[gUnknown_02024C07].type2; - break; - case 2: - unk_2016800.unk8 = gBattleMons[gUnknown_02024C08].type2; - break; - case 4: - unk_2016800.unk8 = gBattleMoves[unk_2016800.unk2].type; - break; - } - gAIScriptPtr += 2; -} - -void BattleAICmd_unk_23(void) -{ - unk_2016800.unk8 = gBattleMoves[unk_2016800.unk2].power; - gAIScriptPtr += 1; + + while (*ptr != 0xFFFF) + { + if (AI_THINKING_STRUCT->funcResult == *ptr) + { + gAIScriptPtr += 9; + return; + } + ptr++; + } + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); +} + +static void BattleAICmd_if_user_can_damage(void) +{ + s32 i; + + for (i = 0; i < MAX_MON_MOVES; i++) + { + if (gBattleMons[gBankAttacker].moves[i] != 0 + && gBattleMoves[gBattleMons[gBankAttacker].moves[i]].power != 0) + break; + } + if (i == MAX_MON_MOVES) + gAIScriptPtr += 5; + else + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); } +static void BattleAICmd_if_user_cant_damage(void) +{ + s32 i; + + for (i = 0; i < MAX_MON_MOVES; i++) + { + if (gBattleMons[gBankAttacker].moves[i] != 0 + && gBattleMoves[gBattleMons[gBankAttacker].moves[i]].power != 0) + break; + } + if (i != MAX_MON_MOVES) + gAIScriptPtr += 5; + else + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); +} + +static void BattleAICmd_get_turn_count(void) +{ + AI_THINKING_STRUCT->funcResult = gBattleResults[19]; + gAIScriptPtr += 1; +} + +static void BattleAICmd_get_type(void) +{ + switch (gAIScriptPtr[1]) + { + case 1: // player primary type + AI_THINKING_STRUCT->funcResult = gBattleMons[gBankAttacker].type1; + break; + case 0: // enemy primary type + AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type1; + break; + case 3: // player secondary type + AI_THINKING_STRUCT->funcResult = gBattleMons[gBankAttacker].type2; + break; + case 2: // enemy secondary type + AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type2; + break; + case 4: // type of move being pointed to + AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type; + break; + } + gAIScriptPtr += 2; +} + +static void BattleAICmd_get_move_power(void) +{ + AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power; + gAIScriptPtr += 1; +} + +#ifdef NONMATCHING +static void BattleAICmd_is_most_powerful_move(void) +{ + int i, j; + s32 damages[MAX_MON_MOVES]; + + for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++) + if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect == sDiscouragedPowerfulMoveEffects[i]) + break; + + if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power > 1 + && sDiscouragedPowerfulMoveEffects[i] == 0xFFFF) + { + gDynamicBasePower = 0; + unk_2000000[0x1601C] = 0; // why is this a manual array? + unk_2000000[0x1601F] = 1; + gBattleMoveFlags = 0; + gCritMultiplier = 1; + + for (i = 0; i < MAX_MON_MOVES; i++) + { + for (j = 0; sDiscouragedPowerfulMoveEffects[j] != 0xFFFF; j++) + { // _08108276 + if (gBattleMoves[gBattleMons[gBankAttacker].moves[i]].effect == sDiscouragedPowerfulMoveEffects[j]) + break; + } + + // _081082BA + if (gBattleMons[gBankAttacker].moves[i] + && sDiscouragedPowerfulMoveEffects[j] == 0xFFFF + && gBattleMoves[gBattleMons[gBankAttacker].moves[i]].power > 1) + { + gCurrentMove = gBattleMons[gBankAttacker].moves[i]; + sub_801CAF8(gBankAttacker, gBankTarget); + move_effectiveness_something(gCurrentMove, gBankAttacker, gBankTarget); + damages[i] = (gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[i]) / 100; + + if (damages[i] == 0) // moves always do at least 1 damage. + damages[i] = 1; + } + else + { + damages[i] = 0; + } + } + + for (i = 0; i < MAX_MON_MOVES; i++) + if (damages[i] > damages[AI_THINKING_STRUCT->movesetIndex]) + break; + + if (i == MAX_MON_MOVES) + AI_THINKING_STRUCT->funcResult = 2; + else + AI_THINKING_STRUCT->funcResult = 1; + } + else + { + AI_THINKING_STRUCT->funcResult = 0; + } + + gAIScriptPtr += 1; +} +#else __attribute__((naked)) -void BattleAICmd_unk_24(void) -{ - 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, 0x14\n\ - movs r3, 0\n\ - ldr r0, _08108328 @ =gUnknown_083F62BC\n\ - ldrh r1, [r0]\n\ - ldr r4, _0810832C @ =0x0000ffff\n\ - ldr r6, _08108330 @ =gBattleMoves\n\ - ldr r5, _08108334 @ =0x02016800\n\ - cmp r1, r4\n\ - beq _0810822E\n\ - ldrh r1, [r5, 0x2]\n\ - lsls r0, r1, 1\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r0, r6\n\ - ldrb r2, [r0]\n\ - ldr r1, _08108328 @ =gUnknown_083F62BC\n\ +static void BattleAICmd_is_most_powerful_move(void) +{ + 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, 0x14\n\ + movs r3, 0\n\ + ldr r0, _08108328 @ =sDiscouragedPowerfulMoveEffects\n\ + ldrh r1, [r0]\n\ + ldr r4, _0810832C @ =0x0000ffff\n\ + ldr r6, _08108330 @ =gBattleMoves\n\ + ldr r5, _08108334 @ =0x02016800\n\ + cmp r1, r4\n\ + beq _0810822E\n\ + ldrh r1, [r5, 0x2]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r6\n\ + ldrb r2, [r0]\n\ + ldr r1, _08108328 @ =sDiscouragedPowerfulMoveEffects\n\ _0810821E:\n\ - ldrh r0, [r1]\n\ - cmp r2, r0\n\ - beq _0810822E\n\ - adds r1, 0x2\n\ - adds r3, 0x1\n\ - ldrh r0, [r1]\n\ - cmp r0, r4\n\ - bne _0810821E\n\ + ldrh r0, [r1]\n\ + cmp r2, r0\n\ + beq _0810822E\n\ + adds r1, 0x2\n\ + adds r3, 0x1\n\ + ldrh r0, [r1]\n\ + cmp r0, r4\n\ + bne _0810821E\n\ _0810822E:\n\ - ldrh r0, [r5, 0x2]\n\ - lsls r1, r0, 1\n\ - adds r1, r0\n\ - lsls r1, 2\n\ - adds r1, r6\n\ - ldrb r0, [r1, 0x1]\n\ - cmp r0, 0x1\n\ - bhi _08108240\n\ - b _081083B2\n\ + ldrh r0, [r5, 0x2]\n\ + lsls r1, r0, 1\n\ + adds r1, r0\n\ + lsls r1, 2\n\ + adds r1, r6\n\ + ldrb r0, [r1, 0x1]\n\ + cmp r0, 0x1\n\ + bhi _08108240\n\ + b _081083B2\n\ _08108240:\n\ - lsls r0, r3, 1\n\ - ldr r1, _08108328 @ =gUnknown_083F62BC\n\ - adds r0, r1\n\ - ldrh r3, [r0]\n\ - ldr r0, _0810832C @ =0x0000ffff\n\ - cmp r3, r0\n\ - beq _08108250\n\ - b _081083B2\n\ + lsls r0, r3, 1\n\ + ldr r1, _08108328 @ =sDiscouragedPowerfulMoveEffects\n\ + adds r0, r1\n\ + ldrh r3, [r0]\n\ + ldr r0, _0810832C @ =0x0000ffff\n\ + cmp r3, r0\n\ + beq _08108250\n\ + b _081083B2\n\ _08108250:\n\ - ldr r0, _08108338 @ =gUnknown_02024DEC\n\ - movs r1, 0\n\ - strh r1, [r0]\n\ - ldr r2, _0810833C @ =0xfffff81c\n\ - adds r0, r5, r2\n\ - strb r1, [r0]\n\ - adds r2, 0x3\n\ - adds r0, r5, r2\n\ - movs r2, 0x1\n\ - strb r2, [r0]\n\ - ldr r0, _08108340 @ =gUnknown_02024C68\n\ - strb r1, [r0]\n\ - ldr r0, _08108344 @ =gCritMultiplier\n\ - strb r2, [r0]\n\ - movs r6, 0\n\ - mov r9, r3\n\ - ldr r0, _08108328 @ =gUnknown_083F62BC\n\ - ldrh r0, [r0]\n\ - str r0, [sp, 0x10]\n\ + ldr r0, _08108338 @ =gDynamicBasePower\n\ + movs r1, 0\n\ + strh r1, [r0]\n\ + ldr r2, _0810833C @ =0xfffff81c\n\ + adds r0, r5, r2\n\ + strb r1, [r0]\n\ + adds r2, 0x3\n\ + adds r0, r5, r2\n\ + movs r2, 0x1\n\ + strb r2, [r0]\n\ + ldr r0, _08108340 @ =gBattleMoveFlags\n\ + strb r1, [r0]\n\ + ldr r0, _08108344 @ =gCritMultiplier\n\ + strb r2, [r0]\n\ + movs r6, 0\n\ + mov r9, r3\n\ + ldr r0, _08108328 @ =sDiscouragedPowerfulMoveEffects\n\ + ldrh r0, [r0]\n\ + str r0, [sp, 0x10]\n\ _08108276:\n\ - movs r3, 0\n\ - ldr r5, _08108348 @ =gBattleMons\n\ - lsls r4, r6, 1\n\ - ldr r7, _0810834C @ =gUnknown_02024C07\n\ - lsls r1, r6, 2\n\ - mov r8, r1\n\ - adds r2, r6, 0x1\n\ - mov r10, r2\n\ - ldr r0, [sp, 0x10]\n\ - cmp r0, r9\n\ - beq _081082BA\n\ - ldr r2, _08108330 @ =gBattleMoves\n\ - ldrb r1, [r7]\n\ - movs r0, 0x58\n\ - muls r0, r1\n\ - adds r0, r4, r0\n\ - adds r1, r5, 0\n\ - adds r1, 0xC\n\ - adds r0, r1\n\ - ldrh r1, [r0]\n\ - lsls r0, r1, 1\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r0, r2\n\ - ldrb r2, [r0]\n\ - ldr r1, _08108328 @ =gUnknown_083F62BC\n\ + movs r3, 0\n\ + ldr r5, _08108348 @ =gBattleMons\n\ + lsls r4, r6, 1\n\ + ldr r7, _0810834C @ =gBankAttacker\n\ + lsls r1, r6, 2\n\ + mov r8, r1\n\ + adds r2, r6, 0x1\n\ + mov r10, r2\n\ + ldr r0, [sp, 0x10]\n\ + cmp r0, r9\n\ + beq _081082BA\n\ + ldr r2, _08108330 @ =gBattleMoves\n\ + ldrb r1, [r7]\n\ + movs r0, 0x58\n\ + muls r0, r1\n\ + adds r0, r4, r0\n\ + adds r1, r5, 0\n\ + adds r1, 0xC\n\ + adds r0, r1\n\ + ldrh r1, [r0]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r2\n\ + ldrb r2, [r0]\n\ + ldr r1, _08108328 @ =sDiscouragedPowerfulMoveEffects\n\ _081082AA:\n\ - ldrh r0, [r1]\n\ - cmp r2, r0\n\ - beq _081082BA\n\ - adds r1, 0x2\n\ - adds r3, 0x1\n\ - ldrh r0, [r1]\n\ - cmp r0, r9\n\ - bne _081082AA\n\ + ldrh r0, [r1]\n\ + cmp r2, r0\n\ + beq _081082BA\n\ + adds r1, 0x2\n\ + adds r3, 0x1\n\ + ldrh r0, [r1]\n\ + cmp r0, r9\n\ + bne _081082AA\n\ _081082BA:\n\ - ldrb r1, [r7]\n\ - movs r0, 0x58\n\ - muls r0, r1\n\ - adds r0, r4, r0\n\ - adds r1, r5, 0\n\ - adds r1, 0xC\n\ - adds r1, r0, r1\n\ - ldrh r0, [r1]\n\ - cmp r0, 0\n\ - beq _0810835C\n\ - lsls r0, r3, 1\n\ - ldr r2, _08108328 @ =gUnknown_083F62BC\n\ - adds r0, r2\n\ - ldrh r0, [r0]\n\ - cmp r0, r9\n\ - bne _0810835C\n\ - ldr r0, _08108330 @ =gBattleMoves\n\ - ldrh r2, [r1]\n\ - lsls r1, r2, 1\n\ - adds r1, r2\n\ - lsls r1, 2\n\ - adds r1, r0\n\ - ldrb r0, [r1, 0x1]\n\ - cmp r0, 0x1\n\ - bls _0810835C\n\ - ldr r5, _08108350 @ =gUnknown_02024BE6\n\ - strh r2, [r5]\n\ - ldrb r0, [r7]\n\ - ldr r4, _08108354 @ =gUnknown_02024C08\n\ - ldrb r1, [r4]\n\ - bl sub_801CAF8\n\ - ldrh r0, [r5]\n\ - ldrb r1, [r7]\n\ - ldrb r2, [r4]\n\ - bl move_effectiveness_something\n\ - mov r4, sp\n\ - add r4, r8\n\ - ldr r2, _08108358 @ =gUnknown_02024BEC\n\ - ldr r0, _08108334 @ =0x02016800\n\ - adds r0, 0x18\n\ - adds r0, r6, r0\n\ - ldrb r1, [r0]\n\ - ldr r0, [r2]\n\ - muls r0, r1\n\ - movs r1, 0x64\n\ - bl __divsi3\n\ - str r0, [r4]\n\ - cmp r0, 0\n\ - bne _08108364\n\ - movs r0, 0x1\n\ - str r0, [r4]\n\ - b _08108364\n\ - .align 2, 0\n\ -_08108328: .4byte gUnknown_083F62BC\n\ + ldrb r1, [r7]\n\ + movs r0, 0x58\n\ + muls r0, r1\n\ + adds r0, r4, r0\n\ + adds r1, r5, 0\n\ + adds r1, 0xC\n\ + adds r1, r0, r1\n\ + ldrh r0, [r1]\n\ + cmp r0, 0\n\ + beq _0810835C\n\ + lsls r0, r3, 1\n\ + ldr r2, _08108328 @ =sDiscouragedPowerfulMoveEffects\n\ + adds r0, r2\n\ + ldrh r0, [r0]\n\ + cmp r0, r9\n\ + bne _0810835C\n\ + ldr r0, _08108330 @ =gBattleMoves\n\ + ldrh r2, [r1]\n\ + lsls r1, r2, 1\n\ + adds r1, r2\n\ + lsls r1, 2\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x1]\n\ + cmp r0, 0x1\n\ + bls _0810835C\n\ + ldr r5, _08108350 @ =gCurrentMove\n\ + strh r2, [r5]\n\ + ldrb r0, [r7]\n\ + ldr r4, _08108354 @ =gBankTarget\n\ + ldrb r1, [r4]\n\ + bl sub_801CAF8\n\ + ldrh r0, [r5]\n\ + ldrb r1, [r7]\n\ + ldrb r2, [r4]\n\ + bl move_effectiveness_something\n\ + mov r4, sp\n\ + add r4, r8\n\ + ldr r2, _08108358 @ =gBattleMoveDamage\n\ + ldr r0, _08108334 @ =0x02016800\n\ + adds r0, 0x18\n\ + adds r0, r6, r0\n\ + ldrb r1, [r0]\n\ + ldr r0, [r2]\n\ + muls r0, r1\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + str r0, [r4]\n\ + cmp r0, 0\n\ + bne _08108364\n\ + movs r0, 0x1\n\ + str r0, [r4]\n\ + b _08108364\n\ + .align 2, 0\n\ +_08108328: .4byte sDiscouragedPowerfulMoveEffects\n\ _0810832C: .4byte 0x0000ffff\n\ _08108330: .4byte gBattleMoves\n\ _08108334: .4byte 0x02016800\n\ -_08108338: .4byte gUnknown_02024DEC\n\ +_08108338: .4byte gDynamicBasePower\n\ _0810833C: .4byte 0xfffff81c\n\ -_08108340: .4byte gUnknown_02024C68\n\ +_08108340: .4byte gBattleMoveFlags\n\ _08108344: .4byte gCritMultiplier\n\ _08108348: .4byte gBattleMons\n\ -_0810834C: .4byte gUnknown_02024C07\n\ -_08108350: .4byte gUnknown_02024BE6\n\ -_08108354: .4byte gUnknown_02024C08\n\ -_08108358: .4byte gUnknown_02024BEC\n\ +_0810834C: .4byte gBankAttacker\n\ +_08108350: .4byte gCurrentMove\n\ +_08108354: .4byte gBankTarget\n\ +_08108358: .4byte gBattleMoveDamage\n\ _0810835C:\n\ - mov r1, sp\n\ - add r1, r8\n\ - movs r0, 0\n\ - str r0, [r1]\n\ + mov r1, sp\n\ + add r1, r8\n\ + movs r0, 0\n\ + str r0, [r1]\n\ _08108364:\n\ - mov r6, r10\n\ - cmp r6, 0x3\n\ - ble _08108276\n\ - movs r6, 0\n\ - ldr r1, _081083A4 @ =0x02016800\n\ - ldrb r0, [r1, 0x1]\n\ - lsls r0, 2\n\ - add r0, sp\n\ - ldr r2, [sp]\n\ - ldr r0, [r0]\n\ - adds r5, r1, 0\n\ - ldr r4, _081083A8 @ =gAIScriptPtr\n\ - cmp r2, r0\n\ - bgt _0810839A\n\ - adds r3, r5, 0\n\ - mov r2, sp\n\ + mov r6, r10\n\ + cmp r6, 0x3\n\ + ble _08108276\n\ + movs r6, 0\n\ + ldr r1, _081083A4 @ =0x02016800\n\ + ldrb r0, [r1, 0x1]\n\ + lsls r0, 2\n\ + add r0, sp\n\ + ldr r2, [sp]\n\ + ldr r0, [r0]\n\ + adds r5, r1, 0\n\ + ldr r4, _081083A8 @ =gAIScriptPtr\n\ + cmp r2, r0\n\ + bgt _0810839A\n\ + adds r3, r5, 0\n\ + mov r2, sp\n\ _08108384:\n\ - adds r2, 0x4\n\ - adds r6, 0x1\n\ - cmp r6, 0x3\n\ - bgt _0810839A\n\ - ldrb r0, [r3, 0x1]\n\ - lsls r0, 2\n\ - add r0, sp\n\ - ldr r1, [r2]\n\ - ldr r0, [r0]\n\ - cmp r1, r0\n\ - ble _08108384\n\ + adds r2, 0x4\n\ + adds r6, 0x1\n\ + cmp r6, 0x3\n\ + bgt _0810839A\n\ + ldrb r0, [r3, 0x1]\n\ + lsls r0, 2\n\ + add r0, sp\n\ + ldr r1, [r2]\n\ + ldr r0, [r0]\n\ + cmp r1, r0\n\ + ble _08108384\n\ _0810839A:\n\ - cmp r6, 0x4\n\ - bne _081083AC\n\ - movs r0, 0x2\n\ - str r0, [r5, 0x8]\n\ - b _081083B8\n\ - .align 2, 0\n\ + cmp r6, 0x4\n\ + bne _081083AC\n\ + movs r0, 0x2\n\ + str r0, [r5, 0x8]\n\ + b _081083B8\n\ + .align 2, 0\n\ _081083A4: .4byte 0x02016800\n\ _081083A8: .4byte gAIScriptPtr\n\ _081083AC:\n\ - movs r0, 0x1\n\ - str r0, [r5, 0x8]\n\ - b _081083B8\n\ + movs r0, 0x1\n\ + str r0, [r5, 0x8]\n\ + b _081083B8\n\ _081083B2:\n\ - movs r0, 0\n\ - str r0, [r5, 0x8]\n\ - ldr r4, _081083D0 @ =gAIScriptPtr\n\ + movs r0, 0\n\ + str r0, [r5, 0x8]\n\ + ldr r4, _081083D0 @ =gAIScriptPtr\n\ _081083B8:\n\ - ldr r0, [r4]\n\ - adds r0, 0x1\n\ - str r0, [r4]\n\ - add sp, 0x14\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\ - .align 2, 0\n\ + ldr r0, [r4]\n\ + adds r0, 0x1\n\ + str r0, [r4]\n\ + add sp, 0x14\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\ + .align 2, 0\n\ _081083D0: .4byte gAIScriptPtr\n\ - .syntax divided\n"); + .syntax divided\n"); } +#endif // NONMATCHING -void BattleAICmd_get_move(void) +static void BattleAICmd_get_move(void) { - if ( gAIScriptPtr[1] == 1 ) - unk_2016800.unk8 = gUnknown_02024C34[gUnknown_02024C07]; - else - unk_2016800.unk8 = gUnknown_02024C34[gUnknown_02024C08]; + if (gAIScriptPtr[1] == USER) + AI_THINKING_STRUCT->funcResult = gLastUsedMove[gBankAttacker]; + else + AI_THINKING_STRUCT->funcResult = gLastUsedMove[gBankTarget]; - gAIScriptPtr += 2; + gAIScriptPtr += 2; } -void BattleAICmd_if_type(void) +static void BattleAICmd_if_arg_equal(void) { - if ( gAIScriptPtr[1] == unk_2016800.unk8 ) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + if (gAIScriptPtr[1] == AI_THINKING_STRUCT->funcResult) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; } -void BattleAICmd_unk_27(void) // if_not_type +static void BattleAICmd_if_arg_not_equal(void) { - if ( gAIScriptPtr[1] != unk_2016800.unk8 ) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + if (gAIScriptPtr[1] != AI_THINKING_STRUCT->funcResult) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; } -void BattleAICmd_if_would_go_first(void) +static void BattleAICmd_if_would_go_first(void) { - if ( b_first_side(gUnknown_02024C07, gUnknown_02024C08, 1) == gAIScriptPtr[1] ) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + if (b_first_side(gBankAttacker, gBankTarget, 1) == gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; } -void BattleAICmd_if_would_not_go_first(void) +static void BattleAICmd_if_would_not_go_first(void) { - if ( b_first_side(gUnknown_02024C07, gUnknown_02024C08, 1) != gAIScriptPtr[1] ) - gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); - else - gAIScriptPtr += 6; + if (b_first_side(gBankAttacker, gBankTarget, 1) != gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; } -void BattleAICmd_unk_2A(void) -{} +static void BattleAICmd_nullsub_2A(void) +{ +} -void BattleAICmd_unk_2B(void) -{} +static void BattleAICmd_nullsub_2B(void) +{ +} -__attribute__((naked)) -void BattleAICmd_count_alive_pokemon(void) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r9\n\ - mov r6, r8\n\ - push {r6,r7}\n\ - ldr r1, _08108550 @ =0x02016800\n\ - movs r0, 0\n\ - str r0, [r1, 0x8]\n\ - ldr r0, _08108554 @ =gAIScriptPtr\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x1]\n\ - cmp r0, 0x1\n\ - bne _0810855C\n\ - ldr r0, _08108558 @ =gUnknown_02024C07\n\ - b _0810855E\n\ - .align 2, 0\n\ -_08108550: .4byte 0x02016800\n\ -_08108554: .4byte gAIScriptPtr\n\ -_08108558: .4byte gUnknown_02024C07\n\ -_0810855C:\n\ - ldr r0, _081085A8 @ =gUnknown_02024C08\n\ -_0810855E:\n\ - ldrb r5, [r0]\n\ - adds r0, r5, 0\n\ - bl battle_side_get_owner\n\ - lsls r0, 24\n\ - ldr r1, _081085AC @ =gEnemyParty\n\ - mov r9, r1\n\ - cmp r0, 0\n\ - bne _08108574\n\ - ldr r0, _081085B0 @ =gPlayerParty\n\ - mov r9, r0\n\ -_08108574:\n\ - ldr r0, _081085B4 @ =gUnknown_020239F8\n\ - ldrh r1, [r0]\n\ - movs r0, 0x1\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _081085BC\n\ - ldr r4, _081085B8 @ =gUnknown_02024A6A\n\ - lsls r0, r5, 1\n\ - adds r0, r4\n\ - ldrb r0, [r0]\n\ - mov r8, r0\n\ - adds r0, r5, 0\n\ - bl battle_get_per_side_status\n\ - movs r1, 0x2\n\ - eors r0, r1\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - bl battle_get_side_with_given_state\n\ - lsls r0, 24\n\ - lsrs r0, 23\n\ - adds r0, r4\n\ - ldrb r6, [r0]\n\ - b _081085C6\n\ - .align 2, 0\n\ -_081085A8: .4byte gUnknown_02024C08\n\ -_081085AC: .4byte gEnemyParty\n\ -_081085B0: .4byte gPlayerParty\n\ -_081085B4: .4byte gUnknown_020239F8\n\ -_081085B8: .4byte gUnknown_02024A6A\n\ -_081085BC:\n\ - ldr r1, _08108624 @ =gUnknown_02024A6A\n\ - lsls r0, r5, 1\n\ - adds r0, r1\n\ - ldrb r6, [r0]\n\ - mov r8, r6\n\ -_081085C6:\n\ - movs r5, 0\n\ - ldr r7, _08108628 @ =0x02016800\n\ -_081085CA:\n\ - cmp r5, r8\n\ - beq _08108608\n\ - cmp r5, r6\n\ - beq _08108608\n\ - movs r0, 0x64\n\ - muls r0, r5\n\ - mov r1, r9\n\ - adds r4, r1, r0\n\ - adds r0, r4, 0\n\ - movs r1, 0x39\n\ - bl GetMonData\n\ - cmp r0, 0\n\ - beq _08108608\n\ - adds r0, r4, 0\n\ - movs r1, 0x41\n\ - bl GetMonData\n\ - cmp r0, 0\n\ - beq _08108608\n\ - adds r0, r4, 0\n\ - movs r1, 0x41\n\ - bl GetMonData\n\ - movs r1, 0xCE\n\ - lsls r1, 1\n\ - cmp r0, r1\n\ - beq _08108608\n\ - ldr r0, [r7, 0x8]\n\ - adds r0, 0x1\n\ - str r0, [r7, 0x8]\n\ -_08108608:\n\ - adds r5, 0x1\n\ - cmp r5, 0x5\n\ - ble _081085CA\n\ - ldr r1, _0810862C @ =gAIScriptPtr\n\ - ldr r0, [r1]\n\ - adds r0, 0x2\n\ - str r0, [r1]\n\ - pop {r3,r4}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_08108624: .4byte gUnknown_02024A6A\n\ -_08108628: .4byte 0x02016800\n\ -_0810862C: .4byte gAIScriptPtr\n\ - .syntax divided"); -} - -void BattleAICmd_unk_2D(void) -{ - unk_2016800.unk8 = unk_2016800.unk2; - gAIScriptPtr += 1; -} - -void BattleAICmd_unk_2E(void) -{ - unk_2016800.unk8 = gBattleMoves[unk_2016800.unk2].effect; - gAIScriptPtr += 1; -} - -void BattleAICmd_get_ability(void) -{ - u8 var; - - if(gAIScriptPtr[1] == 1) - var = gUnknown_02024C07; - else - var = gUnknown_02024C08; - if(battle_side_get_owner(var) == 0) +static void BattleAICmd_count_alive_pokemon(void) +{ + struct Pokemon *party; + int i; + u8 index; + u8 var, var2; + + AI_THINKING_STRUCT->funcResult = 0; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + if (GetBankSide(index) == 0) + party = gPlayerParty; + else + party = gEnemyParty; + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + u32 status; + var = gBattlePartyID[index][0]; + status = GetBankIdentity(index) ^ 2; + var2 = gBattlePartyID[GetBankByPlayerAI(status)][0]; + } + else { - //register u8 unk asm("r1") = battle_get_per_side_status(var) & 1; - u16 unk = battle_get_per_side_status(var) & 1; + var = gBattlePartyID[index][0]; + var2 = gBattlePartyID[index][0]; + } - if(unk_2016A00.unk20[unk] != 0) + for (i = 0; i < 6; i++) + { + if (i != var && i != var2 + && GetMonData(&party[i], MON_DATA_HP) != 0 + && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) { - ((struct UnknownStruct2 *)((u8 *)&unk_2016A00 - 512))->unk8 = unk_2016A00.unk20[unk]; + AI_THINKING_STRUCT->funcResult++; + } + } + + gAIScriptPtr += 2; +} + +static void BattleAICmd_get_considered_move(void) +{ + AI_THINKING_STRUCT->funcResult = AI_THINKING_STRUCT->moveConsidered; + gAIScriptPtr += 1; +} + +static void BattleAICmd_get_considered_move_effect(void) +{ + AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect; + gAIScriptPtr += 1; +} + +static void BattleAICmd_get_ability(void) +{ + u8 index; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + if (GetBankSide(index) == TARGET) + { + u16 unk = GetBankIdentity(index) & 1; + + if (UNK_2016A00_STRUCT->unk20[unk] != 0) + { + AI_THINKING_STRUCT->funcResult = UNK_2016A00_STRUCT->unk20[unk]; gAIScriptPtr += 2; return; } - //_081086C8 - if(gBattleMons[var].ability == 0x17 || gBattleMons[var].ability == 0x2A || gBattleMons[var].ability == 0x47) + + // abilities that prevent fleeing. + if (gBattleMons[index].ability == ABILITY_SHADOW_TAG + || gBattleMons[index].ability == ABILITY_MAGNET_PULL + || gBattleMons[index].ability == ABILITY_ARENA_TRAP) { - //_081086E4 - unk_2016800.unk8 = gBattleMons[var].ability; + AI_THINKING_STRUCT->funcResult = gBattleMons[index].ability; gAIScriptPtr += 2; return; } - //_081086FC - if(gBaseStats[gBattleMons[var].species].ability1 != 0) + + if (gBaseStats[gBattleMons[index].species].ability1 != ABILITY_NONE) { - if(gBaseStats[gBattleMons[var].species].ability2 != 0) + if (gBaseStats[gBattleMons[index].species].ability2 != ABILITY_NONE) { - if(Random() & 1) + // AI has no knowledge of opponent, so it guesses which ability. + if (Random() % 2) { - ((struct UnknownStruct2 *)((u8 *)&unk_2016A00 - 512))->unk8 = gBaseStats[gBattleMons[var].species].ability1; - gAIScriptPtr += 2; - return; + AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability1; } - //_0810873C else { - ((struct UnknownStruct2 *)((u8 *)&unk_2016A00 - 512))->unk8 = gBaseStats[gBattleMons[var].species].ability2; - gAIScriptPtr += 2; - return; + AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability2; } } - //_08108754 else { - ((struct UnknownStruct2 *)((u8 *)&unk_2016A00 - 512))->unk8 = gBaseStats[gBattleMons[var].species].ability1; - gAIScriptPtr += 2; - return; + AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability1; // it's definitely ability 1. } } - //_08108764 else { - ((struct UnknownStruct2 *)((u8 *)&unk_2016A00 - 512))->unk8 = gBaseStats[gBattleMons[var].species].ability2; - gAIScriptPtr += 2; + AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability. + } + } + else + { + // The AI knows its own ability. + AI_THINKING_STRUCT->funcResult = gBattleMons[index].ability; + } + gAIScriptPtr += 2; +} + +static void BattleAICmd_get_highest_possible_damage(void) +{ + s32 i; + + gDynamicBasePower = 0; + BATTLE_STRUCT->unk.unk1 = 0; + BATTLE_STRUCT->unk.unk4 = 1; + gBattleMoveFlags = 0; + gCritMultiplier = 1; + AI_THINKING_STRUCT->funcResult = 0; + + for (i = 0; i < MAX_MON_MOVES; i++) + { + gBattleMoveDamage = 40; + gCurrentMove = gBattleMons[gBankAttacker].moves[i]; + + if (gCurrentMove) + { + move_effectiveness_something(gCurrentMove, gBankAttacker, gBankTarget); + + // reduce by 1/3. + if (gBattleMoveDamage == 120) + gBattleMoveDamage = 80; + if (gBattleMoveDamage == 240) + gBattleMoveDamage = 160; + if (gBattleMoveDamage == 30) + gBattleMoveDamage = 20; + if (gBattleMoveDamage == 15) + gBattleMoveDamage = 10; + + if (gBattleMoveFlags & 8) // if it's a status move, it wont do anything. + gBattleMoveDamage = 0; + + if (AI_THINKING_STRUCT->funcResult < gBattleMoveDamage) + AI_THINKING_STRUCT->funcResult = gBattleMoveDamage; + } + } + gAIScriptPtr += 1; +} + +static void BattleAICmd_if_damage_bonus(void) +{ + u8 damageVar; + + gDynamicBasePower = 0; + BATTLE_STRUCT->unk.unk1 = 0; + BATTLE_STRUCT->unk.unk4 = 1; + gBattleMoveFlags = 0; + gCritMultiplier = 1; + + gBattleMoveDamage = 40; + gCurrentMove = AI_THINKING_STRUCT->moveConsidered; + + move_effectiveness_something(gCurrentMove, gBankAttacker, gBankTarget); + + if (gBattleMoveDamage == 120) + gBattleMoveDamage = 80; + if (gBattleMoveDamage == 240) + gBattleMoveDamage = 160; + if (gBattleMoveDamage == 30) + gBattleMoveDamage = 20; + if (gBattleMoveDamage == 15) + gBattleMoveDamage = 10; + + if (gBattleMoveFlags & 8) + gBattleMoveDamage = 0; + + // store gBattleMoveDamage in a u8 variable because gAIScriptPtr[1] is a u8. + damageVar = gBattleMoveDamage; + + if (damageVar == gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; +} + +static void BattleAICmd_nullsub_32(void) +{ +} + +static void BattleAICmd_nullsub_33(void) +{ +} + +static void BattleAICmd_if_status_in_party(void) +{ + struct Pokemon *party; + struct Pokemon *partyPtr; + int i; + u32 statusToCompareTo; + + // for whatever reason, game freak put the party pointer into 2 variables instead of 1. it's possible at some point the switch encompassed the whole function and used each respective variable creating largely duplicate code. + switch (gAIScriptPtr[1]) + { + case 1: + party = partyPtr = gEnemyParty; + break; + default: + party = partyPtr = gPlayerParty; + break; + } + + statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2); + + for (i = 0; i < 6; i++) + { + u16 species = GetMonData(&party[i], MON_DATA_SPECIES); + u16 hp = GetMonData(&party[i], MON_DATA_HP); + u32 status = GetMonData(&party[i], MON_DATA_STATUS); + + if (species != SPECIES_NONE && species != SPECIES_EGG && hp != 0 && status == statusToCompareTo) + { + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); // WHAT. why is this being merged into the above switch + return; + } + } + + gAIScriptPtr += 10; +} + +// bugged, doesnt return properly. also unused +static void BattleAICmd_if_status_not_in_party(void) +{ + struct Pokemon *party; + struct Pokemon *partyPtr; + int i; + u32 statusToCompareTo; + + switch (gAIScriptPtr[1]) + { + case 1: + party = partyPtr = gEnemyParty; + break; + default: + party = partyPtr = gPlayerParty; + break; + } + + statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2); + + for (i = 0; i < 6; i++) + { + u16 species = GetMonData(&party[i], MON_DATA_SPECIES); + u16 hp = GetMonData(&party[i], MON_DATA_HP); + u32 status = GetMonData(&party[i], MON_DATA_STATUS); + + // everytime the status is found, the AI's logic jumps further and further past its intended destination. this results in a broken AI macro and is probably why it is unused. + if (species != SPECIES_NONE && species != SPECIES_EGG && hp != 0 && status == statusToCompareTo) + gAIScriptPtr += 10; // doesnt return? + } + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); +} + +static void BattleAICmd_get_weather(void) +{ + if (gBattleWeather & 7) + AI_THINKING_STRUCT->funcResult = WEATHER_RAIN; + if (gBattleWeather & 0x18) + AI_THINKING_STRUCT->funcResult = WEATHER_SANDSTORM; + if (gBattleWeather & 0x60) + AI_THINKING_STRUCT->funcResult = WEATHER_SUN; + if (gBattleWeather & 0x80) + AI_THINKING_STRUCT->funcResult = WEATHER_HAIL; + + gAIScriptPtr += 1; +} + +static void BattleAICmd_if_effect(void) +{ + if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect == gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; +} + +static void BattleAICmd_if_not_effect(void) +{ + if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect != gAIScriptPtr[1]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + else + gAIScriptPtr += 6; +} + +static void BattleAICmd_if_stat_level_less_than(void) +{ + u32 party; + + if (gAIScriptPtr[1] == USER) + party = gBankAttacker; + else + party = gBankTarget; + + if (gBattleMons[party].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); + else + gAIScriptPtr += 8; +} + +static void BattleAICmd_if_stat_level_more_than(void) +{ + u32 party; + + if (gAIScriptPtr[1] == USER) + party = gBankAttacker; + else + party = gBankTarget; + + if (gBattleMons[party].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); + else + gAIScriptPtr += 8; +} + +static void BattleAICmd_if_stat_level_equal(void) +{ + u32 party; + + if (gAIScriptPtr[1] == USER) + party = gBankAttacker; + else + party = gBankTarget; + + if (gBattleMons[party].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); + else + gAIScriptPtr += 8; +} + +static void BattleAICmd_if_stat_level_not_equal(void) +{ + u32 party; + + if (gAIScriptPtr[1] == USER) + party = gBankAttacker; + else + party = gBankTarget; + + if (gBattleMons[party].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3]) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); + else + gAIScriptPtr += 8; +} + +static void BattleAICmd_if_can_faint(void) +{ + if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power < 2) + { + gAIScriptPtr += 5; + return; + } + + gDynamicBasePower = 0; + BATTLE_STRUCT->unk.unk1 = 0; + BATTLE_STRUCT->unk.unk4 = 1; + gBattleMoveFlags = 0; + gCritMultiplier = 1; + gCurrentMove = AI_THINKING_STRUCT->moveConsidered; + sub_801CAF8(gBankAttacker, gBankTarget); + move_effectiveness_something(gCurrentMove, gBankAttacker, gBankTarget); + + gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100; + + // moves always do at least 1 damage. + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + + if (gBattleMons[gBankTarget].hp <= gBattleMoveDamage) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); + else + gAIScriptPtr += 5; +} + +static void BattleAICmd_if_cant_faint(void) +{ + if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power < 2) + { + gAIScriptPtr += 5; + return; + } + + gDynamicBasePower = 0; + BATTLE_STRUCT->unk.unk1 = 0; + BATTLE_STRUCT->unk.unk4 = 1; + gBattleMoveFlags = 0; + gCritMultiplier = 1; + gCurrentMove = AI_THINKING_STRUCT->moveConsidered; + sub_801CAF8(gBankAttacker, gBankTarget); + move_effectiveness_something(gCurrentMove, gBankAttacker, gBankTarget); + + gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100; + + // this macro is missing the damage 0 = 1 assumption. + + if (gBattleMons[gBankTarget].hp > gBattleMoveDamage) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); + else + gAIScriptPtr += 5; +} + +static void BattleAICmd_if_has_move(void) +{ + int i; + u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2); + + switch (gAIScriptPtr[1]) + { + case 1: + case 3: + for (i = 0; i < MAX_MON_MOVES; i++) + { + if (gBattleMons[gBankAttacker].moves[i] == *temp_ptr) + break; + } + if (i == MAX_MON_MOVES) + gAIScriptPtr += 8; + else + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); + break; + case 0: + case 2: + for (i = 0; i < 8; i++) + { + if (UNK_2016A00_STRUCT->movesUsed[gBankTarget >> 1][i] == *temp_ptr) + break; + } + if (i == 8) + gAIScriptPtr += 8; + else + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); + break; + } +} + +static void BattleAICmd_if_dont_have_move(void) +{ + int i; + u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2); + + switch (gAIScriptPtr[1]) + { + case 1: + case 3: + for (i = 0; i < MAX_MON_MOVES; i++) + { + if (gBattleMons[gBankAttacker].moves[i] == *temp_ptr) + break; + } + if (i != MAX_MON_MOVES) + gAIScriptPtr += 8; + else + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); + break; + case 0: + case 2: + for (i = 0; i < 8; i++) + { + if (UNK_2016A00_STRUCT->movesUsed[gBankTarget >> 1][i] == *temp_ptr) + break; + } + if (i != 8) + gAIScriptPtr += 8; + else + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); + break; + } +} + +static void BattleAICmd_if_move_effect(void) +{ + int i; + + switch (gAIScriptPtr[1]) + { + case 1: + case 3: + for (i = 0; i < MAX_MON_MOVES; i++) + { + if (gBattleMons[gBankAttacker].moves[i] != 0 && gBattleMoves[gBattleMons[gBankAttacker].moves[i]].effect == gAIScriptPtr[2]) + break; + } + if (i != MAX_MON_MOVES) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); + else + gAIScriptPtr += 7; + break; + case 0: + case 2: + for (i = 0; i < 8; i++) + { + if (gBattleMons[gBankAttacker].moves[i] != 0 && gBattleMoves[UNK_2016A00_STRUCT->movesUsed[gBankTarget >> 1][i]].effect == gAIScriptPtr[2]) + break; + } + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); + } +} + +static void BattleAICmd_if_not_move_effect(void) +{ + int i; + + switch (gAIScriptPtr[1]) + { + case 1: + case 3: + for (i = 0; i < MAX_MON_MOVES; i++) + { + if (gBattleMons[gBankAttacker].moves[i] != 0 && gBattleMoves[gBattleMons[gBankAttacker].moves[i]].effect == gAIScriptPtr[2]) + break; + } + if (i != MAX_MON_MOVES) + gAIScriptPtr += 7; + else + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); + break; + case 0: + case 2: + for (i = 0; i < 8; i++) + { + if (UNK_2016A00_STRUCT->movesUsed[gBankTarget >> 1][i] != 0 && gBattleMoves[UNK_2016A00_STRUCT->movesUsed[gBankTarget >> 1][i]].effect == gAIScriptPtr[2]) + break; + } + gAIScriptPtr += 7; + } +} + +static void BattleAICmd_if_last_move_did_damage(void) +{ + u8 index; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + if (gAIScriptPtr[2] == 0) + { + if (gDisableStructs[index].unk4 == 0) + { + gAIScriptPtr += 7; + return; + } + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); + return; + } + else if (gAIScriptPtr[2] != 1) // ignore the macro if its not 0 or 1. + { + gAIScriptPtr += 7; + return; + } + else if (gDisableStructs[index].unk6 != 0) + { + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); + return; + } + gAIScriptPtr += 7; +} + +static void BattleAICmd_if_encored(void) +{ + switch (gAIScriptPtr[1]) + { + case 0: // _08109348 + if (gDisableStructs[gActiveBank].unk4 == AI_THINKING_STRUCT->moveConsidered) + { + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + return; + } + gAIScriptPtr += 6; + return; + case 1: // _08109370 + if (gDisableStructs[gActiveBank].unk6 == AI_THINKING_STRUCT->moveConsidered) + { + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); return; } + gAIScriptPtr += 6; + return; + default: + gAIScriptPtr += 6; + return; + } +} + +static void BattleAICmd_flee(void) +{ + AI_THINKING_STRUCT->aiAction |= (AI_ACTION_DONE | AI_ACTION_FLEE | AI_ACTION_DO_NOT_ATTACK); // what matters is AI_ACTION_FLEE being enabled. +} + +static void BattleAICmd_if_random_100(void) +{ + u8 safariFleeRate = BATTLE_STRUCT->safariFleeRate * 5; // safari flee rate, from 0-20 + + if ((u8)(Random() % 100) < safariFleeRate) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); + else + gAIScriptPtr += 5; +} + +static void BattleAICmd_watch(void) +{ + AI_THINKING_STRUCT->aiAction |= (AI_ACTION_DONE | AI_ACTION_WATCH | AI_ACTION_DO_NOT_ATTACK); // what matters is AI_ACTION_WATCH being enabled. +} + +static void BattleAICmd_get_hold_effect(void) +{ + u8 index; + u16 status; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + if (GetBankSide(index) == 0) + { + status = (GetBankIdentity(index) & 1); + AI_THINKING_STRUCT->funcResult = UNK_2016A00_STRUCT->unk22[status]; } - //_08108774 - unk_2016800.unk8 = gBattleMons[var].ability; + else + AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[index].item); + + gAIScriptPtr += 2; +} + +static void BattleAICmd_get_gender(void) +{ + u8 index; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[index].species, gBattleMons[index].personality); + gAIScriptPtr += 2; } -// this should probably be in battle.h after this file is fully decompiled. -extern struct +static void BattleAICmd_is_first_turn(void) { - u8 unknownStuff[0x16000]; - struct + u8 index; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + AI_THINKING_STRUCT->funcResult = gDisableStructs[index].unk16; + + gAIScriptPtr += 2; +} + +static void BattleAICmd_get_stockpile_count(void) +{ + u8 index; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + AI_THINKING_STRUCT->funcResult = gDisableStructs[index].unk9; + + gAIScriptPtr += 2; +} + +static void BattleAICmd_is_double_battle(void) +{ + AI_THINKING_STRUCT->funcResult = gBattleTypeFlags & BATTLE_TYPE_DOUBLE; + + gAIScriptPtr += 1; +} + +static void BattleAICmd_get_item(void) +{ + u8 index; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + // this hack and a half matches. whatever. i dont care. someone else fix this mess later. PS: still cant fix this. + AI_THINKING_STRUCT->funcResult = ewram[0x160CC + (index * 2)]; + + gAIScriptPtr += 2; +} + +static void BattleAICmd_get_move_type_from_result(void) +{ + AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->funcResult].type; + + gAIScriptPtr += 1; +} + +static void BattleAICmd_get_move_power_from_result(void) +{ + AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->funcResult].power; + + gAIScriptPtr += 1; +} + +static void BattleAICmd_get_move_effect_from_result(void) +{ + AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->funcResult].effect; + + gAIScriptPtr += 1; +} + +static void BattleAICmd_get_protect_count(void) +{ + u8 index; + + if (gAIScriptPtr[1] == USER) + index = gBankAttacker; + else + index = gBankTarget; + + AI_THINKING_STRUCT->funcResult = gDisableStructs[index].unk8; + + gAIScriptPtr += 2; +} + +static void BattleAICmd_nullsub_52(void) +{ +} + +static void BattleAICmd_nullsub_53(void) +{ +} + +static void BattleAICmd_nullsub_54(void) +{ +} + +static void BattleAICmd_nullsub_55(void) +{ +} + +static void BattleAICmd_nullsub_56(void) +{ +} + +static void BattleAICmd_nullsub_57(void) +{ +} + +static void BattleAICmd_call(void) +{ + AIStackPushVar(gAIScriptPtr + 5); + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); +} + +static void BattleAICmd_jump(void) +{ + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); +} + +static void BattleAICmd_end(void) +{ + if (AIStackPop() == FALSE) + AI_THINKING_STRUCT->aiAction |= AI_ACTION_DONE; +} + +static void BattleAICmd_if_level_compare(void) +{ + switch (gAIScriptPtr[1]) { - u8 filler0[0x1C]; - u8 unk1C; - u8 filler1D[2]; - u8 unk1F; - u8 filler16020[0x7E0]; - } unk_2016000; - struct UnknownStruct2 unk_2016800; -} ewram; //0x02000000 + case 0: // greater than + if (gBattleMons[gBankAttacker].level > gBattleMons[gBankTarget].level) + { + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + return; + } + gAIScriptPtr += 6; + return; + case 1: // less than + if (gBattleMons[gBankAttacker].level < gBattleMons[gBankTarget].level) + { + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + return; + } + gAIScriptPtr += 6; + return; + case 2: // equal + if (gBattleMons[gBankAttacker].level == gBattleMons[gBankTarget].level) + { + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); + return; + } + gAIScriptPtr += 6; + return; + } +} -#ifdef NONMATCHING -void BattleAICmd_unk_30(void) -{ - s32 loopCounter; - - gUnknown_02024DEC = 0; - ewram.unk_2016000.unk1C = 0; - ewram.unk_2016000.unk1F = 1; - gUnknown_02024C68 = 0; - gCritMultiplier = 1; - ewram.unk_2016800.unk8 = 0; - - for(loopCounter = 0; loopCounter <= 3; loopCounter++) - { - gUnknown_02024BEC = 40; - gUnknown_02024BE6 = gBattleMons[gUnknown_02024C07].moves[loopCounter]; - - if (gUnknown_02024BE6) - { - move_effectiveness_something(gUnknown_02024BE6, gUnknown_02024C07, gUnknown_02024C08); - - // reduce by 1/3. - if (gUnknown_02024BEC == 120) - gUnknown_02024BEC = 80; - if(gUnknown_02024BEC == 240) - gUnknown_02024BEC = 160; - if(gUnknown_02024BEC == 30) - gUnknown_02024BEC = 20; - if(gUnknown_02024BEC == 15) - gUnknown_02024BEC = 10; - - if(gUnknown_02024C68 & 8) - gUnknown_02024BEC = 0; - - if (ewram.unk_2016800.unk8 < gUnknown_02024BEC) - ewram.unk_2016800.unk8 = gUnknown_02024BEC; - } - } - gAIScriptPtr += 1; +static void BattleAICmd_if_taunted(void) +{ + if (gDisableStructs[gBankTarget].taunt != 0) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); + else + gAIScriptPtr += 5; } -#else -__attribute__((naked)) -void BattleAICmd_unk_30(void) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - ldr r0, _0810885C @ =gUnknown_02024DEC\n\ - movs r2, 0\n\ - strh r2, [r0]\n\ - ldr r1, _08108860 @ =0x02000000\n\ - ldr r3, _08108864 @ =0x0001601c\n\ - adds r0, r1, r3\n\ - movs r4, 0\n\ - strb r2, [r0]\n\ - adds r3, 0x3\n\ - adds r0, r1, r3\n\ - movs r3, 0x1\n\ - strb r3, [r0]\n\ - ldr r0, _08108868 @ =gUnknown_02024C68\n\ - strb r2, [r0]\n\ - ldr r0, _0810886C @ =gCritMultiplier\n\ - strb r3, [r0]\n\ - movs r0, 0xB4\n\ - lsls r0, 9\n\ - adds r1, r0\n\ - str r4, [r1, 0x8]\n\ - movs r5, 0\n\ - ldr r4, _08108870 @ =gUnknown_02024BEC\n\ - ldr r7, _08108874 @ =gUnknown_02024BE6\n\ - ldr r3, _08108878 @ =gUnknown_02024A8C\n\ - mov r8, r3\n\ - ldr r6, _0810887C @ =gUnknown_02024C07\n\ -_081087DA:\n\ - movs r0, 0x28\n\ - str r0, [r4]\n\ - lsls r1, r5, 1\n\ - ldrb r2, [r6]\n\ - movs r0, 0x58\n\ - muls r0, r2\n\ - adds r1, r0\n\ - add r1, r8\n\ - ldrh r0, [r1]\n\ - strh r0, [r7]\n\ - lsls r0, 16\n\ - cmp r0, 0\n\ - beq _08108844\n\ - ldrh r0, [r7]\n\ - ldrb r1, [r6]\n\ - ldr r2, _08108880 @ =gUnknown_02024C08\n\ - ldrb r2, [r2]\n\ - bl move_effectiveness_something\n\ - ldr r0, [r4]\n\ - cmp r0, 0x78\n\ - bne _0810880A\n\ - movs r0, 0x50\n\ - str r0, [r4]\n\ -_0810880A:\n\ - ldr r0, [r4]\n\ - cmp r0, 0xF0\n\ - bne _08108814\n\ - movs r0, 0xA0\n\ - str r0, [r4]\n\ -_08108814:\n\ - ldr r0, [r4]\n\ - cmp r0, 0x1E\n\ - bne _0810881E\n\ - movs r0, 0x14\n\ - str r0, [r4]\n\ -_0810881E:\n\ - ldr r0, [r4]\n\ - cmp r0, 0xF\n\ - bne _08108828\n\ - movs r0, 0xA\n\ - str r0, [r4]\n\ -_08108828:\n\ - ldr r0, _08108868 @ =gUnknown_02024C68\n\ - ldrb r1, [r0]\n\ - movs r0, 0x8\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _08108838\n\ - movs r0, 0\n\ - str r0, [r4]\n\ -_08108838:\n\ - ldr r2, _08108884 @ =0x02016800\n\ - ldr r0, [r2, 0x8]\n\ - ldr r1, [r4]\n\ - cmp r0, r1\n\ - bcs _08108844\n\ - str r1, [r2, 0x8]\n\ -_08108844:\n\ - adds r5, 0x1\n\ - cmp r5, 0x3\n\ - ble _081087DA\n\ - ldr r1, _08108888 @ =gAIScriptPtr\n\ - ldr r0, [r1]\n\ - adds r0, 0x1\n\ - str r0, [r1]\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_0810885C: .4byte gUnknown_02024DEC\n\ -_08108860: .4byte 0x02000000\n\ -_08108864: .4byte 0x0001601c\n\ -_08108868: .4byte gUnknown_02024C68\n\ -_0810886C: .4byte gCritMultiplier\n\ -_08108870: .4byte gUnknown_02024BEC\n\ -_08108874: .4byte gUnknown_02024BE6\n\ -_08108878: .4byte gUnknown_02024A8C\n\ -_0810887C: .4byte gUnknown_02024C07\n\ -_08108880: .4byte gUnknown_02024C08\n\ -_08108884: .4byte 0x02016800\n\ -_08108888: .4byte gAIScriptPtr\n\ - .syntax divided\n"); + +static void BattleAICmd_if_not_taunted(void) +{ + if (gDisableStructs[gBankTarget].taunt == 0) + gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); + else + gAIScriptPtr += 5; } -#endif -// same function as above but no for loop. -__attribute__((naked)) -void BattleAICmd_if_damage_bonus(void) -{ - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - ldr r0, _08108928 @ =gUnknown_02024DEC\n\ - movs r1, 0\n\ - strh r1, [r0]\n\ - ldr r2, _0810892C @ =0x02000000\n\ - ldr r3, _08108930 @ =0x0001601c\n\ - adds r0, r2, r3\n\ - strb r1, [r0]\n\ - adds r3, 0x3\n\ - adds r0, r2, r3\n\ - movs r3, 0x1\n\ - strb r3, [r0]\n\ - ldr r5, _08108934 @ =gUnknown_02024C68\n\ - strb r1, [r5]\n\ - ldr r0, _08108938 @ =gCritMultiplier\n\ - strb r3, [r0]\n\ - ldr r4, _0810893C @ =gUnknown_02024BEC\n\ - movs r0, 0x28\n\ - str r0, [r4]\n\ - ldr r1, _08108940 @ =gUnknown_02024BE6\n\ - movs r0, 0xB4\n\ - lsls r0, 9\n\ - adds r2, r0\n\ - ldrh r0, [r2, 0x2]\n\ - strh r0, [r1]\n\ - ldrh r0, [r1]\n\ - ldr r1, _08108944 @ =gUnknown_02024C07\n\ - ldrb r1, [r1]\n\ - ldr r2, _08108948 @ =gUnknown_02024C08\n\ - ldrb r2, [r2]\n\ - bl move_effectiveness_something\n\ - ldr r0, [r4]\n\ - cmp r0, 0x78\n\ - bne _081088D6\n\ - movs r0, 0x50\n\ - str r0, [r4]\n\ -_081088D6:\n\ - ldr r0, [r4]\n\ - cmp r0, 0xF0\n\ - bne _081088E0\n\ - movs r0, 0xA0\n\ - str r0, [r4]\n\ -_081088E0:\n\ - ldr r0, [r4]\n\ - cmp r0, 0x1E\n\ - bne _081088EA\n\ - movs r0, 0x14\n\ - str r0, [r4]\n\ -_081088EA:\n\ - ldr r0, [r4]\n\ - cmp r0, 0xF\n\ - bne _081088F4\n\ - movs r0, 0xA\n\ - str r0, [r4]\n\ -_081088F4:\n\ - ldrb r1, [r5]\n\ - movs r0, 0x8\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _08108902\n\ - movs r0, 0\n\ - str r0, [r4]\n\ -_08108902:\n\ - ldrb r0, [r4]\n\ - ldr r3, _0810894C @ =gAIScriptPtr\n\ - ldr r2, [r3]\n\ - ldrb r1, [r2, 0x1]\n\ - cmp r0, r1\n\ - bne _08108950\n\ - ldrb r1, [r2, 0x2]\n\ - ldrb r0, [r2, 0x3]\n\ - lsls r0, 8\n\ - orrs r1, r0\n\ - ldrb r0, [r2, 0x4]\n\ - lsls r0, 16\n\ - orrs r1, r0\n\ - ldrb r0, [r2, 0x5]\n\ - lsls r0, 24\n\ - orrs r1, r0\n\ - str r1, [r3]\n\ - b _08108954\n\ - .align 2, 0\n\ -_08108928: .4byte gUnknown_02024DEC\n\ -_0810892C: .4byte 0x02000000\n\ -_08108930: .4byte 0x0001601c\n\ -_08108934: .4byte gUnknown_02024C68\n\ -_08108938: .4byte gCritMultiplier\n\ -_0810893C: .4byte gUnknown_02024BEC\n\ -_08108940: .4byte gUnknown_02024BE6\n\ -_08108944: .4byte gUnknown_02024C07\n\ -_08108948: .4byte gUnknown_02024C08\n\ -_0810894C: .4byte gAIScriptPtr\n\ -_08108950:\n\ - adds r0, r2, 0x6\n\ - str r0, [r3]\n\ -_08108954:\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided\n"); -} - -void BattleAICmd_unk_32(void) -{} - -void BattleAICmd_unk_33(void) -{} +void AIStackPushVar(u8 *var) +{ + AI_STACK->ptr[AI_STACK->size++] = var; +} + +// unused +void AIStackPushAIPtr(void) +{ + AI_STACK->ptr[AI_STACK->size++] = gAIScriptPtr; +} + +bool8 AIStackPop(void) +{ + if (AI_STACK->size != 0) + { + --AI_STACK->size; + gAIScriptPtr = AI_STACK->ptr[AI_STACK->size]; + return TRUE; + } + else + return FALSE; +} diff --git a/src/battle_anim.c b/src/battle_anim.c new file mode 100644 index 000000000..55ede1788 --- /dev/null +++ b/src/battle_anim.c @@ -0,0 +1,2268 @@ +#include "global.h" +#include "battle_anim.h" +#include "battle.h" +#include "battle_anim_80CA710.h" +#include "battle_interface.h" +#include "contest.h" +#include "decompress.h" +#include "m4a.h" +#include "main.h" +#include "palette.h" +#include "rom_8077ABC.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" + +// sprites start at 10000 and thus must be subtracted of 10000 to account for the true index. +#define GET_TRUE_SPRITE_INDEX(i) (i - 10000) + +extern u8 unk_2000000[]; +extern u16 gBattlePartyID[4]; +extern u8 gObjectBankIDs[]; +extern u8 gBankAttacker; +extern u8 gBankTarget; +EWRAM_DATA const u8 *gBattleAnimScriptPtr = NULL; +EWRAM_DATA const u8 *gBattleAnimScriptRetAddr = NULL; +EWRAM_DATA void (*gAnimScriptCallback)(void) = NULL; +EWRAM_DATA s8 gAnimFramesToWait = 0; +EWRAM_DATA u8 gAnimScriptActive = FALSE; +EWRAM_DATA u8 gAnimVisualTaskCount = 0; +EWRAM_DATA u8 gAnimSoundTaskCount = 0; +EWRAM_DATA u32 gDisableStructMoveAnim = 0; +EWRAM_DATA u32 gMoveDmgMoveAnim = 0; +EWRAM_DATA u16 gMovePowerMoveAnim = 0; +EWRAM_DATA u8 gHappinessMoveAnim = 0; +EWRAM_DATA u16 gWeatherMoveAnim = 0; +EWRAM_DATA u8 gMonAnimTaskIdArray[2] = {0}; +EWRAM_DATA u8 gUnknown_0202F7C4 = 0; +EWRAM_DATA u8 gUnknown_0202F7C5 = 0; +EWRAM_DATA u16 gAnimMoveIndex = 0; // set but unused. +EWRAM_DATA u8 gBattleAnimPlayerMonIndex = 0; +EWRAM_DATA u8 gBattleAnimEnemyMonIndex = 0; +EWRAM_DATA u16 gUnknown_0202F7CA[4] = {0}; +EWRAM_DATA u8 gUnknown_0202F7D2 = 0; +extern u16 gUnknown_030041B4; +extern u16 gUnknown_03004200; +extern u16 gUnknown_03004240; +extern u16 gUnknown_03004244; +extern u16 gUnknown_03004280; +extern u16 gUnknown_03004288; +extern u16 gUnknown_030042C0; +extern u16 gUnknown_030042C4; +extern u16 gSoundAnimFramesToWait; +extern u16 gAnimSpriteIndexArray[8]; +extern s16 gBattleAnimArgs[8]; +extern struct MusicPlayerInfo gMPlay_BGM; +extern struct MusicPlayerInfo gMPlay_SE1; +extern struct MusicPlayerInfo gMPlay_SE2; + +extern const u16 gUnknown_081C7160[]; +extern const u8 *const gBattleAnims_Moves[]; +extern const struct CompressedSpriteSheet gBattleAnimPicTable[]; +extern const struct CompressedSpritePalette gBattleAnimPaletteTable[]; +extern const struct BattleAnimBackground gBattleAnimBackgroundTable[]; + +static void RunAnimScriptCommand(void); +static void ScriptCmd_loadsprite(void); +static void ScriptCmd_unloadsprite(void); +static void ScriptCmd_sprite(void); +static void ScriptCmd_createtask(void); +static void ScriptCmd_delay(void); +static void ScriptCmd_waitforvisualfinish(void); +static void ScriptCmd_hang1(void); +static void ScriptCmd_hang2(void); +static void ScriptCmd_end(void); +static void ScriptCmd_playse(void); +static void ScriptCmd_monbg(void); +static void sub_8076380(void); +static void task_pA_ma0A_obj_to_bg_pal(u8); +static void ScriptCmd_clearmonbg(void); +static void sub_807672C(u8); +static void ScriptCmd_monbg_22(void); +static void ScriptCmd_clearmonbg_23(void); +static void sub_80769A4(u8); +static void ScriptCmd_setalpha(void); +static void ScriptCmd_setbldcnt(void); +static void ScriptCmd_blendoff(void); +static void ScriptCmd_call(void); +static void ScriptCmd_return(void); +static void ScriptCmd_setvar(void); +static void ScriptCmd_ifelse(void); +static void ScriptCmd_jumpif(void); +static void ScriptCmd_jump(void); +static void ScriptCmd_fadetobg(void); +static void ScriptCmd_fadetobg_25(void); +static void task_p5_load_battle_screen_elements(u8); +static void sub_8076DB8(u16); +static void dp01t_11_3_message_for_player_only(void); +static void ScriptCmd_restorebg(void); +static void ScriptCmd_waitbgfadeout(void); +static void ScriptCmd_waitbgfadein(void); +static void ScriptCmd_changebg(void); +static void ScriptCmd_panse_19(void); +static void ScriptCmd_setpan(void); +static void ScriptCmd_panse_1B(void); +static void c3_08073CEC(u8); +static void ScriptCmd_panse_26(void); +static void ScriptCmd_panse_27(void); +static void ScriptCmd_panse_1C(void); +static void sub_80774FC(u8); +static void ScriptCmd_panse_1D(void); +static void sub_80775CC(u8); +static void ScriptCmd_createtask_1F(void); +static void ScriptCmd_waitsound(void); +static void ScriptCmd_jumpvareq(void); +static void ScriptCmd_jumpunkcond(void); +static void ScriptCmd_monbgprio_28(void); +static void ScriptCmd_monbgprio_29(void); +static void ScriptCmd_monbgprio_2A(void); +static void ScriptCmd_invisible(void); +static void ScriptCmd_visible(void); +static void ScriptCmd_doublebattle_2D(void); +static void ScriptCmd_doublebattle_2E(void); +static void ScriptCmd_stopsound(void); + +static void (*const sScriptCmdTable[])(void) = { + ScriptCmd_loadsprite, + ScriptCmd_unloadsprite, + ScriptCmd_sprite, + ScriptCmd_createtask, + ScriptCmd_delay, + ScriptCmd_waitforvisualfinish, + ScriptCmd_hang1, + ScriptCmd_hang2, + ScriptCmd_end, + ScriptCmd_playse, + ScriptCmd_monbg, + ScriptCmd_clearmonbg, + ScriptCmd_setalpha, + ScriptCmd_blendoff, + ScriptCmd_call, + ScriptCmd_return, + ScriptCmd_setvar, + ScriptCmd_ifelse, + ScriptCmd_jumpif, + ScriptCmd_jump, + ScriptCmd_fadetobg, + ScriptCmd_restorebg, + ScriptCmd_waitbgfadeout, + ScriptCmd_waitbgfadein, + ScriptCmd_changebg, + ScriptCmd_panse_19, + ScriptCmd_setpan, + ScriptCmd_panse_1B, + ScriptCmd_panse_1C, + ScriptCmd_panse_1D, + ScriptCmd_setbldcnt, + ScriptCmd_createtask_1F, + ScriptCmd_waitsound, + ScriptCmd_jumpvareq, + ScriptCmd_monbg_22, + ScriptCmd_clearmonbg_23, + ScriptCmd_jumpunkcond, + ScriptCmd_fadetobg_25, + ScriptCmd_panse_26, + ScriptCmd_panse_27, + ScriptCmd_monbgprio_28, + ScriptCmd_monbgprio_29, + ScriptCmd_monbgprio_2A, + ScriptCmd_invisible, + ScriptCmd_visible, + ScriptCmd_doublebattle_2D, + ScriptCmd_doublebattle_2E, + ScriptCmd_stopsound, +}; + +void battle_anim_clear_some_data(void) +{ + s32 i; + + gAnimFramesToWait = 0; + gAnimScriptActive = FALSE; + gAnimVisualTaskCount = 0; + gAnimSoundTaskCount = 0; + gDisableStructMoveAnim = 0; + gMoveDmgMoveAnim = 0; + gMovePowerMoveAnim = 0; + gHappinessMoveAnim = 0; + + // clear index array. + for (i = 0; i < 8; i++) + gAnimSpriteIndexArray[i] |= 0xFFFF; + + // clear anim args. + for (i = 0; i < 8; i++) + gBattleAnimArgs[i] = 0; + + gMonAnimTaskIdArray[0] = 0xFF; + gMonAnimTaskIdArray[1] = 0xFF; + gUnknown_0202F7C4 = 0; + gUnknown_0202F7C5 = 0; + gAnimMoveIndex = 0; + gBattleAnimPlayerMonIndex = 0; + gBattleAnimEnemyMonIndex = 0; + gUnknown_0202F7D2 = 0; +} + +void ExecuteMoveAnim(u16 move) +{ + gBattleAnimPlayerMonIndex = gBankAttacker; + gBattleAnimEnemyMonIndex = gBankTarget; + DoMoveAnim(gBattleAnims_Moves, move, 1); +} + +void DoMoveAnim(const u8 *const moveAnims[], u16 move, u8 c) +{ + s32 i; + + if (IsContest() == 0) + { + sub_8079E24(); + sub_8043EB4(0); + for (i = 0; i < 4; i++) + { + if (GetBankSide(i) != 0) + gUnknown_0202F7CA[i] = GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_SPECIES); + else + gUnknown_0202F7CA[i] = GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_SPECIES); + } + } + else + { + for (i = 0; i < 4; i++) + gUnknown_0202F7CA[i] = EWRAM_19348; + } + + if (c == 0) + gAnimMoveIndex = 0; + else + gAnimMoveIndex = move; + + for (i = 0; i < 8; i++) + gBattleAnimArgs[i] = 0; + + gMonAnimTaskIdArray[0] = 0xFF; + gMonAnimTaskIdArray[1] = 0xFF; + gBattleAnimScriptPtr = moveAnims[move]; + gAnimScriptActive = TRUE; + gAnimFramesToWait = 0; + gAnimScriptCallback = RunAnimScriptCommand; + + for (i = 0; i < 8; i++) + gAnimSpriteIndexArray[i] |= 0xFFFF; + + if (c != 0) + { + for (i = 0; gUnknown_081C7160[i] != 0xFFFF; i++) + { + if (move == gUnknown_081C7160[i]) + { + m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 128); + break; + } + } + } + + gUnknown_030042C4 = 0; + gUnknown_03004240 = 0; + gUnknown_03004200 = 0; + gUnknown_03004244 = 0; +} + +void move_anim_8072740(struct Sprite *sprite) +{ + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + gAnimVisualTaskCount--; +} + +void DestroyAnimVisualTask(u8 taskId) +{ + DestroyTask(taskId); + gAnimVisualTaskCount--; +} + +void DestroyAnimSoundTask(u8 taskId) +{ + DestroyTask(taskId); + gAnimSoundTaskCount--; +} + +static void AddSpriteIndex(u16 index) +{ + s32 i; + + for (i = 0; i < 8; i++) + { + if (gAnimSpriteIndexArray[i] == 0xFFFF) + { + gAnimSpriteIndexArray[i] = index; + return; + } + } +} + +static void ClearSpriteIndex(u16 index) +{ + s32 i; + + for (i = 0; i < 8; i++) + { + if (gAnimSpriteIndexArray[i] == index) + { + gAnimSpriteIndexArray[i] |= 0xFFFF; + return; + } + } +} + +static void WaitAnimFrameCount(void) +{ + if (gAnimFramesToWait <= 0) + { + gAnimScriptCallback = RunAnimScriptCommand; + gAnimFramesToWait = 0; + } + else + { + gAnimFramesToWait--; + } +} + +static void RunAnimScriptCommand(void) +{ + do + { + sScriptCmdTable[SCRIPT_READ_8(gBattleAnimScriptPtr)](); + } while (gAnimFramesToWait == 0 && gAnimScriptActive != FALSE); +} + +static void ScriptCmd_loadsprite(void) +{ + u16 index; + + gBattleAnimScriptPtr++; + index = SCRIPT_READ_16(gBattleAnimScriptPtr); + LoadCompressedObjectPic(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)]); + LoadCompressedObjectPalette(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(index)]); + gBattleAnimScriptPtr += 2; + AddSpriteIndex(GET_TRUE_SPRITE_INDEX(index)); + gAnimFramesToWait = 1; + gAnimScriptCallback = WaitAnimFrameCount; +} + +static void ScriptCmd_unloadsprite(void) +{ + u16 index; + + gBattleAnimScriptPtr++; + index = SCRIPT_READ_16(gBattleAnimScriptPtr); + FreeSpriteTilesByTag(gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)].tag); + FreeSpritePaletteByTag(gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)].tag); + gBattleAnimScriptPtr += 2; + ClearSpriteIndex(GET_TRUE_SPRITE_INDEX(index)); +} + +#ifdef NONMATCHING +static void ScriptCmd_sprite(void) +{ + s32 i; + struct SpriteTemplate *r7; + u8 r4; + u8 r0; + u8 _r0; + u16 r6; + u8 r2; + s8 r1; + + gBattleAnimScriptPtr++; + r7 = (struct SpriteTemplate *)(SCRIPT_READ_32(gBattleAnimScriptPtr)); + gBattleAnimScriptPtr += 4; + r4 = SCRIPT_READ_8(gBattleAnimScriptPtr); + gBattleAnimScriptPtr++; + r0 = SCRIPT_READ_8(gBattleAnimScriptPtr); + gBattleAnimScriptPtr++; + for (i = 0; i < r0; i++) + { + gBattleAnimArgs[i] = SCRIPT_READ_16(gBattleAnimScriptPtr); + gBattleAnimScriptPtr += 2; + } + if (r4 & 0x80) + { + r4 ^= 0x80; + if (r4 > 0x3F) + r4 -= 0x40; + else + r4 = -r4; + _r0 = sub_8079E90(gBattleAnimEnemyMonIndex); + r1 = r4; + + } + else + { + //_08075B44 + if (r4 > 0x3F) + r4 -= 0x40; + else + r4 = -r4; + _r0 = sub_8079E90(gBattleAnimPlayerMonIndex); + r1 = r4; + } + r6 = _r0 + r1; + if ((s16)r6 < 3) + r6 = 3; + + r4 = sub_8077ABC(gBattleAnimEnemyMonIndex, 2); + r2 = sub_8077ABC(gBattleAnimEnemyMonIndex, 3); + CreateSpriteAndAnimate(r7, r4, r2, r6); + gAnimVisualTaskCount++; +} +#else +__attribute__((naked)) +static void ScriptCmd_sprite(void) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + ldr r5, _08075B2C @ =gBattleAnimScriptPtr\n\ + ldr r1, [r5]\n\ + adds r3, r1, 0x1\n\ + str r3, [r5]\n\ + ldrb r2, [r1, 0x1]\n\ + ldrb r0, [r3, 0x1]\n\ + lsls r0, 8\n\ + adds r2, r0\n\ + ldrb r0, [r3, 0x2]\n\ + lsls r0, 16\n\ + adds r2, r0\n\ + ldrb r0, [r3, 0x3]\n\ + lsls r0, 24\n\ + adds r7, r2, r0\n\ + adds r0, r1, 0x5\n\ + str r0, [r5]\n\ + ldrb r4, [r1, 0x5]\n\ + adds r0, r1, 0x6\n\ + str r0, [r5]\n\ + ldrb r0, [r1, 0x6]\n\ + adds r1, 0x7\n\ + str r1, [r5]\n\ + cmp r0, 0\n\ + beq _08075B14\n\ + adds r6, r5, 0\n\ + ldr r5, _08075B30 @ =gBattleAnimArgs\n\ + adds r3, r0, 0\n\ +_08075AFC:\n\ + ldr r2, [r6]\n\ + ldrb r1, [r2]\n\ + ldrb r0, [r2, 0x1]\n\ + lsls r0, 8\n\ + orrs r1, r0\n\ + strh r1, [r5]\n\ + adds r2, 0x2\n\ + str r2, [r6]\n\ + adds r5, 0x2\n\ + subs r3, 0x1\n\ + cmp r3, 0\n\ + bne _08075AFC\n\ +_08075B14:\n\ + movs r0, 0x80\n\ + ands r0, r4\n\ + cmp r0, 0\n\ + beq _08075B44\n\ + movs r0, 0x80\n\ + eors r4, r0\n\ + cmp r4, 0x3F\n\ + bls _08075B34\n\ + adds r0, r4, 0\n\ + subs r0, 0x40\n\ + b _08075B36\n\ + .align 2, 0\n\ +_08075B2C: .4byte gBattleAnimScriptPtr\n\ +_08075B30: .4byte gBattleAnimArgs\n\ +_08075B34:\n\ + negs r0, r4\n\ +_08075B36:\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + ldr r0, _08075B40 @ =gBattleAnimEnemyMonIndex\n\ + b _08075B56\n\ + .align 2, 0\n\ +_08075B40: .4byte gBattleAnimEnemyMonIndex\n\ +_08075B44:\n\ + cmp r4, 0x3F\n\ + bls _08075B4E\n\ + adds r0, r4, 0\n\ + subs r0, 0x40\n\ + b _08075B50\n\ +_08075B4E:\n\ + negs r0, r4\n\ +_08075B50:\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + ldr r0, _08075BAC @ =gBattleAnimPlayerMonIndex\n\ +_08075B56:\n\ + ldrb r0, [r0]\n\ + bl sub_8079E90\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + lsls r1, r4, 24\n\ + asrs r1, 24\n\ + adds r0, r1\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ + lsls r0, r6, 16\n\ + asrs r0, 16\n\ + cmp r0, 0x2\n\ + bgt _08075B74\n\ + movs r6, 0x3\n\ +_08075B74:\n\ + ldr r5, _08075BB0 @ =gBattleAnimEnemyMonIndex\n\ + ldrb r0, [r5]\n\ + movs r1, 0x2\n\ + bl sub_8077ABC\n\ + adds r4, r0, 0\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + ldrb r0, [r5]\n\ + movs r1, 0x3\n\ + bl sub_8077ABC\n\ + adds r2, r0, 0\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + lsls r3, r6, 24\n\ + lsrs r3, 24\n\ + adds r0, r7, 0\n\ + adds r1, r4, 0\n\ + bl CreateSpriteAndAnimate\n\ + ldr r1, _08075BB4 @ =gAnimVisualTaskCount\n\ + ldrb r0, [r1]\n\ + adds r0, 0x1\n\ + strb r0, [r1]\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_08075BAC: .4byte gBattleAnimPlayerMonIndex\n\ +_08075BB0: .4byte gBattleAnimEnemyMonIndex\n\ +_08075BB4: .4byte gAnimVisualTaskCount\n\ + .syntax divided\n"); +} +#endif + +static void ScriptCmd_createtask(void) +{ + TaskFunc taskFunc; + u8 taskPriority; + u8 taskId; + u8 numArgs; + s32 i; + + gBattleAnimScriptPtr++; + taskFunc = (TaskFunc)SCRIPT_READ_32(gBattleAnimScriptPtr); + gBattleAnimScriptPtr += 4; + taskPriority = SCRIPT_READ_8(gBattleAnimScriptPtr); + gBattleAnimScriptPtr++; + numArgs = SCRIPT_READ_8(gBattleAnimScriptPtr); + gBattleAnimScriptPtr++; + + for (i = 0; i < numArgs; i++) + { + gBattleAnimArgs[i] = SCRIPT_READ_16(gBattleAnimScriptPtr); + gBattleAnimScriptPtr += 2; + } + + taskId = CreateTask(taskFunc, taskPriority); + taskFunc(taskId); + gAnimVisualTaskCount++; +} + +static void ScriptCmd_delay(void) +{ + gBattleAnimScriptPtr++; + gAnimFramesToWait = SCRIPT_READ_8(gBattleAnimScriptPtr); + if (gAnimFramesToWait == 0) + gAnimFramesToWait = -1; + gBattleAnimScriptPtr++; + gAnimScriptCallback = WaitAnimFrameCount; +} + +// wait for visual tasks to finish. +static void ScriptCmd_waitforvisualfinish(void) +{ + if (gAnimVisualTaskCount == 0) + { + gBattleAnimScriptPtr++; + gAnimFramesToWait = 0; + } + else + { + gAnimFramesToWait = 1; + } +} + +static void ScriptCmd_hang1(void) +{ +} + +static void ScriptCmd_hang2(void) +{ +} + +static void ScriptCmd_end(void) +{ + s32 i; + bool32 continuousAnim = FALSE; + + // keep waiting as long as there is animations to be done. + if (gAnimVisualTaskCount != 0 || gAnimSoundTaskCount != 0 + || gMonAnimTaskIdArray[0] != 0xFF || gMonAnimTaskIdArray[1] != 0xFF) + { + gSoundAnimFramesToWait = 0; + gAnimFramesToWait = 1; + return; + } + + // finish the sound effects. + if (IsSEPlaying()) + { + if (++gSoundAnimFramesToWait <= 90) // wait 90 frames, then halt the sound effect. + { + gAnimFramesToWait = 1; + return; + } + else + { + m4aMPlayStop(&gMPlay_SE1); + m4aMPlayStop(&gMPlay_SE2); + } + } + + // the SE has halted, so set the SE Frame Counter to 0 and continue. + gSoundAnimFramesToWait = 0; + + for (i = 0; i < 8; i++) + { + if (gAnimSpriteIndexArray[i] != 0xFFFF) + { + FreeSpriteTilesByTag(gBattleAnimPicTable[gAnimSpriteIndexArray[i]].tag); + FreeSpritePaletteByTag(gBattleAnimPicTable[gAnimSpriteIndexArray[i]].tag); + gAnimSpriteIndexArray[i] |= 0xFFFF; // set terminator. + } + } + + if (continuousAnim == FALSE) // may have been used for debug? + { + m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 256); + if (IsContest() == 0) + { + sub_8079E24(); + sub_8043EB4(1); + } + gAnimScriptActive = FALSE; + } +} + +static void ScriptCmd_playse(void) +{ + gBattleAnimScriptPtr++; + PlaySE(SCRIPT_READ_16(gBattleAnimScriptPtr)); + gBattleAnimScriptPtr += 2; +} + +static void ScriptCmd_monbg(void) +{ + u8 r6; + u8 r5; + u8 r0; + u8 r7; + u16 r4; + u8 taskId; + + gBattleAnimScriptPtr++; + r6 = SCRIPT_READ_8(gBattleAnimScriptPtr); + if (r6 == 0) + r6 = 2; + else if (r6 == 1) + r6 = 3; + if (r6 == 0 || r6 == 2) + r5 = gBattleAnimPlayerMonIndex; + else + r5 = gBattleAnimEnemyMonIndex; + if (b_side_obj__get_some_boolean(r5)) + { + r0 = GetBankIdentity(r5); + r0 += 0xFF; + if (r0 <= 1 || IsContest() != 0) + r7 = 0; + else + r7 = 1; + sub_8076034(r5, r7); + r4 = gObjectBankIDs[r5]; + taskId = CreateTask(task_pA_ma0A_obj_to_bg_pal, 10); + gTasks[taskId].data[0] = r4; + gTasks[taskId].data[1] = gSprites[r4].pos1.x + gSprites[r4].pos2.x; + gTasks[taskId].data[2] = gSprites[r4].pos1.y + gSprites[r4].pos2.y; + if (r7 == 0) + { + gTasks[taskId].data[3] = gUnknown_030042C0; + gTasks[taskId].data[4] = gUnknown_030041B4; + } + else + { + gTasks[taskId].data[3] = gUnknown_03004288; + gTasks[taskId].data[4] = gUnknown_03004280; + } + gTasks[taskId].data[5] = r7; + gTasks[taskId].data[6] = r5; + gMonAnimTaskIdArray[0] = taskId; + + } + r5 ^= 2; + if (r6 > 1 && b_side_obj__get_some_boolean(r5)) + { + r0 = GetBankIdentity(r5); + r0 += 0xFF; + if (r0 <= 1 || IsContest() != 0) + r7 = 0; + else + r7 = 1; + sub_8076034(r5, r7); + r4 = gObjectBankIDs[r5]; + taskId = CreateTask(task_pA_ma0A_obj_to_bg_pal, 10); + gTasks[taskId].data[0] = r4; + gTasks[taskId].data[1] = gSprites[r4].pos1.x + gSprites[r4].pos2.x; + gTasks[taskId].data[2] = gSprites[r4].pos1.y + gSprites[r4].pos2.y; + if (r7 == 0) + { + gTasks[taskId].data[3] = gUnknown_030042C0; + gTasks[taskId].data[4] = gUnknown_030041B4; + } + else + { + gTasks[taskId].data[3] = gUnknown_03004288; + gTasks[taskId].data[4] = gUnknown_03004280; + } + gTasks[taskId].data[5] = r7; + gTasks[taskId].data[6] = r5; + gMonAnimTaskIdArray[1] = taskId; + } + gBattleAnimScriptPtr++; +} + +#ifdef NONMATCHING +bool8 b_side_obj__get_some_boolean(u8 a) +{ + if (IsContest() != 0) + { + if (a == gBattleAnimPlayerMonIndex) + return TRUE; + else + return FALSE; + } + if (sub_8078874(a) == 0) + return FALSE; + if (IsContest() != 0) + return TRUE; // this line wont ever be reached. + if ((EWRAM_17800[a].unk0 & 1) == 0) + return TRUE; + if (gSprites[gObjectBankIDs[a]].invisible) + return FALSE; + return TRUE; +} +#else +__attribute__((naked)) +bool8 b_side_obj__get_some_boolean(u8 a) +{ + asm(".syntax unified\n\ + push {r4,r5,lr}\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + adds r5, r4, 0\n\ + bl IsContest\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _08075FDC\n\ + ldr r0, _08075FD8 @ =gBattleAnimPlayerMonIndex\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + beq _0807601C\n\ + b _0807602C\n\ + .align 2, 0\n\ +_08075FD8: .4byte gBattleAnimPlayerMonIndex\n\ +_08075FDC:\n\ + adds r0, r4, 0\n\ + bl sub_8078874\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0807602C\n\ + bl IsContest\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _0807601C\n\ + lsls r0, r5, 2\n\ + ldr r1, _08076020 @ =0x02017800\n\ + adds r0, r1\n\ + ldrb r1, [r0]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0807601C\n\ + ldr r2, _08076024 @ =gSprites\n\ + ldr r0, _08076028 @ =gObjectBankIDs\n\ + adds r0, r5, r0\n\ + ldrb r1, [r0]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r2\n\ + adds r0, 0x3E\n\ + ldrb r0, [r0]\n\ + lsls r0, 29\n\ + cmp r0, 0\n\ + blt _0807602C\n\ +_0807601C:\n\ + movs r0, 0x1\n\ + b _0807602E\n\ + .align 2, 0\n\ +_08076020: .4byte 0x02017800\n\ +_08076024: .4byte gSprites\n\ +_08076028: .4byte gObjectBankIDs\n\ +_0807602C:\n\ + movs r0, 0\n\ +_0807602E:\n\ + pop {r4,r5}\n\ + pop {r1}\n\ + bx r1\n\ + .syntax divided\n"); +} +#endif + +void sub_8076034(u8 a, u8 b) +{ + volatile u8 pointlessZero; + u16 *addr2; + u8 spriteId; + + if (b == 0) + { + struct UnknownStruct2 s; + u8 *addr; + u32 size; + u8 r2; + u16 *addr3; + + sub_8078914(&s); + addr = s.unk0; + size = 0x2000; + while (1) + { + DmaFill32(3, 0, addr, 0x1000); + addr += 0x1000; + size -= 0x1000; + if (size <= 0x1000) + { + DmaFill32(3, 0, addr, size); + break; + } + } + pointlessZero = 0; + pointlessZero = 0; + addr2 = (void *)s.unk4; + DmaFill16(3, 0xFF, addr2, 0x1000); + + REG_BG1CNT_BITFIELD.priority = 2; + REG_BG1CNT_BITFIELD.screenSize = 1; + REG_BG1CNT_BITFIELD.areaOverflowMode = 0; + + spriteId = gObjectBankIDs[a]; + gUnknown_030042C0 = -(gSprites[spriteId].pos1.x + gSprites[spriteId].pos2.x) + 32; + if (IsContest() != 0 && sub_80AEB1C(EWRAM_19348) != 0) + gUnknown_030042C0--; + gUnknown_030041B4 = -(gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y) + 32; + gSprites[gObjectBankIDs[a]].invisible = TRUE; + + REG_BG1HOFS = gUnknown_030042C0; + REG_BG1VOFS = gUnknown_030041B4; + + LoadPalette(gPlttBufferUnfaded + 0x100 + a * 16, s.unk8 * 16, 32); + addr3 = (u16 *)PLTT + s.unk8 * 16; + DmaCopy32(3, gPlttBufferUnfaded + 0x100 + a * 16, addr3, 32); + + if (IsContest() != 0) + r2 = 0; + else + r2 = GetBankIdentity(a); + sub_80E4EF8(0, 0, r2, s.unk8, (u32)s.unk0, (((s32)s.unk4 - VRAM) / 2048), REG_BG1CNT_BITFIELD.charBaseBlock); + if (IsContest() != 0) + sub_8076380(); + } + else + { + u8 *addr; + u32 size; + u16 *addr3; + + addr = (void *)(VRAM + 0x6000); + size = 0x2000; + while (1) + { + DmaFill32(3, 0, addr, 0x1000); + addr += 0x1000; + size -= 0x1000; + if (size <= 0x1000) + { + DmaFill32(3, 0, addr, size); + break; + } + } + pointlessZero = 0; + pointlessZero = 0; + addr2 = (void *)(VRAM + 0xF000); + DmaFill32(3, 0, addr2, 0x800); + + REG_BG2CNT_BITFIELD.priority = 2; + REG_BG2CNT_BITFIELD.screenSize = 1; + REG_BG2CNT_BITFIELD.areaOverflowMode = 0; + + spriteId = gObjectBankIDs[a]; + gUnknown_03004288 = -(gSprites[spriteId].pos1.x + gSprites[spriteId].pos2.x) + 32; + gUnknown_03004280 = -(gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y) + 32; + gSprites[gObjectBankIDs[a]].invisible = TRUE; + + REG_BG2HOFS = gUnknown_03004288; + REG_BG2VOFS = gUnknown_03004280; + + LoadPalette(gPlttBufferUnfaded + 0x100 + a * 16, 0x90, 32); + addr3 = (void *)(PLTT + 0x120); + DmaCopy32(3, gPlttBufferUnfaded + 0x100 + a * 16, addr3, 32); + + sub_80E4EF8(0, 0, GetBankIdentity(a), 9, 0x6000, 0x1E, REG_BG2CNT_BITFIELD.charBaseBlock); + } +} + +static void sub_8076380(void) +{ + int i; + int j; + struct UnknownStruct2 s; + u16 *ptr; + + if (sub_80AEB1C(EWRAM_19348) != 0) + { + sub_8078914(&s); + ptr = s.unk4; + for (i = 0; i < 8; i++) + { + for (j = 0; j < 4; j++) + { + u16 temp = ptr[j + i * 32]; + + ptr[j + i * 32] = ptr[7 - j + i * 32]; + ptr[7 - j + i * 32] = temp; + } + } + for (i = 0; i < 8; i++) + { + for (j = 0; j < 8; j++) + ptr[j + i * 32] ^= 0x400; + } + } +} + +void sub_80763FC(u16 a, u16 *b, u32 c, u8 d) +{ + u8 i; + u8 j; + u32 r9; + + if (d == 0) + r9 = 32; + else + r9 = 64; + a <<= 12; + for (i = 0; i < r9; i++) + { + for (j = 0; j < 32; j++) + b[j + i * 32] = ((b[j + i * 32] & 0xFFF) | a) + c; + } +} + +void sub_8076464(u8 a) +{ + u8 *addr; + u32 size; + volatile u8 pointlessZero; + struct UnknownStruct2 s; + + sub_8078914(&s); + if (a == 0 || IsContest() != 0) + { + u16 *addr2; + + addr = s.unk0; + size = 0x2000; + while (1) + { + DmaFill32(3, 0, addr, 0x1000); + addr += 0x1000; + size -= 0x1000; + if (size <= 0x1000) + { + DmaFill32(3, 0, addr, size); + break; + } + } + pointlessZero = 0; + pointlessZero = 0; + addr2 = s.unk4; + DmaFill32(3, 0, addr2, 0x800); + gUnknown_030042C0 = 0; + gUnknown_030041B4 = 0; + } + else + { + u16 *addr2; + + addr = (void *)(VRAM + 0x6000); + size = 0x2000; + while (1) + { + DmaFill32(3, 0, addr, 0x1000); + addr += 0x1000; + size -= 0x1000; + if (size <= 0x1000) + { + DmaFill32(3, 0, addr, size); + break; + } + } + pointlessZero = 0; + pointlessZero = 0; + addr2 = (void *)(VRAM + 0xF000); + DmaFill32(3, 0, addr2, 0x800); + gUnknown_03004288 = 0; + gUnknown_03004280 = 0; + } +} + +static void task_pA_ma0A_obj_to_bg_pal(u8 taskId) +{ + u8 r4; + u8 r6; + s16 r3; + s16 r2; + struct UnknownStruct2 s; + + r4 = gTasks[taskId].data[0]; + r6 = gTasks[taskId].data[6]; + sub_8078914(&s); + r3 = gTasks[taskId].data[1] - (gSprites[r4].pos1.x + gSprites[r4].pos2.x); + r2 = gTasks[taskId].data[2] - (gSprites[r4].pos1.y + gSprites[r4].pos2.y); + if (gTasks[taskId].data[5] == 0) + { + u16 *src; + u16 *dst; + + gUnknown_030042C0 = r3 + gTasks[taskId].data[3]; + gUnknown_030041B4 = r2 + gTasks[taskId].data[4]; + src = gPlttBufferFaded + 0x100 + r6 * 16; + dst = gPlttBufferFaded + 0x100 + s.unk8 * 16 - 256; + DmaCopy32(3, src, dst, 32); + } + else + { + u16 *src; + u16 *dst; + + gUnknown_03004288 = r3 + gTasks[taskId].data[3]; + gUnknown_03004280 = r2 + gTasks[taskId].data[4]; + src = gPlttBufferFaded + 0x100 + r6 * 16; + dst = gPlttBufferFaded + 0x100 - 112; + DmaCopy32(3, src, dst, 32); + } +} + +static void ScriptCmd_clearmonbg(void) +{ + u8 r4; + u8 r5; + u8 taskId; + + gBattleAnimScriptPtr++; + r4 = SCRIPT_READ_8(gBattleAnimScriptPtr); + if (r4 == 0) + r4 = 2; + else if (r4 == 1) + r4 = 3; + if (r4 == 0 || r4 == 2) + r5 = gBattleAnimPlayerMonIndex; + else + r5 = gBattleAnimEnemyMonIndex; + if (gMonAnimTaskIdArray[0] != 0xFF) + gSprites[gObjectBankIDs[r5]].invisible = FALSE; + if (r4 > 1 && gMonAnimTaskIdArray[1] != 0xFF) + gSprites[gObjectBankIDs[r5 ^ 2]].invisible = FALSE; + else + r4 = 0; + taskId = CreateTask(sub_807672C, 5); + gTasks[taskId].data[0] = r4; + gTasks[taskId].data[2] = r5; + gBattleAnimScriptPtr++; +} + +static void sub_807672C(u8 taskId) +{ + u8 var; + u8 r4; + + gTasks[taskId].data[1]++; + if (gTasks[taskId].data[1] != 1) + { + var = GetBankIdentity(gTasks[taskId].data[2]); + var += 0xFF; + if (var <= 1 || IsContest() != 0) + r4 = 0; + else + r4 = 1; + if (gMonAnimTaskIdArray[0] != 0xFF) + { + sub_8076464(r4); + DestroyTask(gMonAnimTaskIdArray[0]); + gMonAnimTaskIdArray[0] = 0xFF; + } + if (gTasks[taskId].data[0] > 1) + { + sub_8076464(r4 ^ 1); + DestroyTask(gMonAnimTaskIdArray[1]); + gMonAnimTaskIdArray[1] = 0xFF; + } + DestroyTask(taskId); + } +} + +static void ScriptCmd_monbg_22(void) +{ + u8 r5; + u8 r4; + u8 r0; + u8 r1; + + gBattleAnimScriptPtr++; + r5 = SCRIPT_READ_8(gBattleAnimScriptPtr); + if (r5 == 0) + r5 = 2; + else if (r5 == 1) + r5 = 3; + if (r5 == 0 || r5 == 2) + r4 = gBattleAnimPlayerMonIndex; + else + r4 = gBattleAnimEnemyMonIndex; + if (b_side_obj__get_some_boolean(r4)) + { + r0 = GetBankIdentity(r4); + r0 += 0xFF; + if (r0 <= 1 || IsContest() != 0) + r1 = 0; + else + r1 = 1; + sub_8076034(r4, r1); + gSprites[gObjectBankIDs[r4]].invisible = FALSE; + } + r4 ^= 2; + if (r5 > 1 && b_side_obj__get_some_boolean(r4)) + { + r0 = GetBankIdentity(r4); + r0 += 0xFF; + if (r0 <= 1 || IsContest() != 0) + r1 = 0; + else + r1 = 1; + sub_8076034(r4, r1); + gSprites[gObjectBankIDs[r4]].invisible = FALSE; + } + gBattleAnimScriptPtr++; +} + +static void ScriptCmd_clearmonbg_23(void) +{ + u8 r5; + u8 r6; + u8 taskId; + + gBattleAnimScriptPtr++; + r5 = SCRIPT_READ_8(gBattleAnimScriptPtr); + if (r5 == 0) + r5 = 2; + else if (r5 == 1) + r5 = 3; + if (r5 == 0 || r5 == 2) + r6 = gBattleAnimPlayerMonIndex; + else + r6 = gBattleAnimEnemyMonIndex; + if (b_side_obj__get_some_boolean(r6)) + gSprites[gObjectBankIDs[r6]].invisible = FALSE; + if (r5 > 1 && b_side_obj__get_some_boolean(r6 ^ 2)) + gSprites[gObjectBankIDs[r6 ^ 2]].invisible = FALSE; + else + r5 = 0; + taskId = CreateTask(sub_80769A4, 5); + gTasks[taskId].data[0] = r5; + gTasks[taskId].data[2] = r6; + gBattleAnimScriptPtr++; +} + +static void sub_80769A4(u8 taskId) +{ + u8 r0; + u8 r4; + u8 r5; + + gTasks[taskId].data[1]++; + if (gTasks[taskId].data[1] != 1) + { + r4 = gTasks[taskId].data[2]; + r0 = GetBankIdentity(r4); + r0 += 0xFF; + if (r0 <= 1 || IsContest() != 0) + r5 = 0; + else + r5 = 1; + if (b_side_obj__get_some_boolean(r4)) + sub_8076464(r5); + if (gTasks[taskId].data[0] > 1 && b_side_obj__get_some_boolean(r4 ^ 2)) + sub_8076464(r5 ^ 1); + DestroyTask(taskId); + } +} + +static void ScriptCmd_setalpha(void) +{ + u16 r3; + u16 r1; + + gBattleAnimScriptPtr++; + r3 = *(gBattleAnimScriptPtr++); + r1 = *(gBattleAnimScriptPtr++) << 8; + REG_BLDCNT = 0x3F40; + REG_BLDALPHA = r3 | r1; +} + +static void ScriptCmd_setbldcnt(void) +{ + u16 r3; + u16 r1; + + gBattleAnimScriptPtr++; + r3 = *(gBattleAnimScriptPtr++); + r1 = *(gBattleAnimScriptPtr++) << 8; + REG_BLDCNT = r3 | r1; +} + +static void ScriptCmd_blendoff(void) +{ + gBattleAnimScriptPtr++; + REG_BLDCNT = 0; + REG_BLDALPHA = 0; +} + +static void ScriptCmd_call(void) +{ + u32 addr; + + gBattleAnimScriptPtr++; + gBattleAnimScriptRetAddr = gBattleAnimScriptPtr + 4; + addr = SCRIPT_READ_32(gBattleAnimScriptPtr); + gBattleAnimScriptPtr = (u8 *)addr; +} + +static void ScriptCmd_return(void) +{ + gBattleAnimScriptPtr = gBattleAnimScriptRetAddr; +} + +static void ScriptCmd_setvar(void) +{ + const u8 *addr = gBattleAnimScriptPtr; + u16 r4; + u8 r2; + + gBattleAnimScriptPtr++; + r2 = SCRIPT_READ_8(gBattleAnimScriptPtr); + gBattleAnimScriptPtr++; + r4 = SCRIPT_READ_16(gBattleAnimScriptPtr); + gBattleAnimScriptPtr = addr + 4; + gBattleAnimArgs[r2] = r4; +} + +static void ScriptCmd_ifelse(void) +{ + u32 addr; + + gBattleAnimScriptPtr++; + if (gUnknown_0202F7C4 & 1) + gBattleAnimScriptPtr += 4; + addr = SCRIPT_READ_32(gBattleAnimScriptPtr); + gBattleAnimScriptPtr = (u8 *)addr; +} + +static void ScriptCmd_jumpif(void) +{ + u8 r1; + u32 addr; + + gBattleAnimScriptPtr++; + r1 = SCRIPT_READ_8(gBattleAnimScriptPtr); + gBattleAnimScriptPtr++; + if (r1 == gUnknown_0202F7C4) + { + addr = SCRIPT_READ_32(gBattleAnimScriptPtr); + gBattleAnimScriptPtr = (u8 *)addr; + } + else + { + gBattleAnimScriptPtr += 4; + } +} + +static void ScriptCmd_jump(void) +{ + u32 addr; + + gBattleAnimScriptPtr++; + addr = SCRIPT_READ_32(gBattleAnimScriptPtr); + gBattleAnimScriptPtr = (u8 *)addr; +} + +// Uses of this function that rely on a TRUE return are expecting inBattle to not be ticked as defined in contest behavior. As a result, if misused, this function cannot reliably discern between field and contest status and could result in undefined behavior. +bool8 IsContest(void) +{ + if (!gMain.inBattle) + return TRUE; + else + return FALSE; +} + +static void ScriptCmd_fadetobg(void) +{ + u8 r4; + u8 taskId; + + gBattleAnimScriptPtr++; + r4 = SCRIPT_READ_8(gBattleAnimScriptPtr); + gBattleAnimScriptPtr++; + taskId = CreateTask(task_p5_load_battle_screen_elements, 5); + gTasks[taskId].data[0] = r4; + gUnknown_0202F7C5 = 1; +} + +static void ScriptCmd_fadetobg_25(void) +{ + u8 r8; + u8 r7; + u8 r6; + u8 taskId; + + gBattleAnimScriptPtr++; + r8 = gBattleAnimScriptPtr[0]; + r7 = gBattleAnimScriptPtr[1]; + r6 = gBattleAnimScriptPtr[2]; + gBattleAnimScriptPtr += 3; + taskId = CreateTask(task_p5_load_battle_screen_elements, 5); + if (IsContest() != 0) + gTasks[taskId].data[0] = r6; + else if (GetBankSide(gBattleAnimEnemyMonIndex) == 0) + gTasks[taskId].data[0] = r7; + else + gTasks[taskId].data[0] = r8; + gUnknown_0202F7C5 = 1; +} + +static void task_p5_load_battle_screen_elements(u8 taskId) +{ + if (gTasks[taskId].data[10] == 0) + { + BeginHardwarePaletteFade(0xE8, 0, 0, 16, 0); + gTasks[taskId].data[10]++; + return; + } + if (gPaletteFade.active) + return; + if (gTasks[taskId].data[10] == 1) + { + gTasks[taskId].data[10]++; + gUnknown_0202F7C5 = 2; + } + else if (gTasks[taskId].data[10] == 2) + { + s16 data0 = (u16)gTasks[taskId].data[0]; + + if (data0 == -1) + dp01t_11_3_message_for_player_only(); + else + sub_8076DB8(data0); + BeginHardwarePaletteFade(0xE8, 0, 16, 0, 1); + gTasks[taskId].data[10]++; + return; + } + if (gPaletteFade.active) + return; + if (gTasks[taskId].data[10] == 3) + { + DestroyTask(taskId); + gUnknown_0202F7C5 = 0; + } +} + +static void sub_8076DB8(u16 a) +{ + if (IsContest()) + { + void *tilemap = gBattleAnimBackgroundTable[a].tilemap; + void *dmaSrc; + void *dmaDest; + + sub_800D238(tilemap, IsContest() ? EWRAM_14800 : EWRAM_18000); + sub_80763FC(sub_80789BC(), IsContest() ? EWRAM_14800 : EWRAM_18000, 0x100, 0); + dmaSrc = IsContest() ? EWRAM_14800 : EWRAM_18000; + dmaDest = (void *)(VRAM + 0xD000); + DmaCopy32(3, dmaSrc, dmaDest, 0x800); + LZDecompressVram(gBattleAnimBackgroundTable[a].image, (void *)(VRAM + 0x2000)); + LoadCompressedPalette(gBattleAnimBackgroundTable[a].palette, sub_80789BC() * 16, 32); + } + else + { + LZDecompressVram(gBattleAnimBackgroundTable[a].tilemap, (void *)(VRAM + 0xD000)); + LZDecompressVram(gBattleAnimBackgroundTable[a].image, (void *)(VRAM + 0x8000)); + LoadCompressedPalette(gBattleAnimBackgroundTable[a].palette, 32, 32); + } +} + +static void dp01t_11_3_message_for_player_only(void) +{ + if (IsContest()) + sub_80AB2AC(); + else + sub_800D7B8(); +} + +static void ScriptCmd_restorebg(void) +{ + u8 taskId; + + gBattleAnimScriptPtr++; + taskId = CreateTask(task_p5_load_battle_screen_elements, 5); + gTasks[taskId].data[0] = 0xFFFF; + gUnknown_0202F7C5 = 1; +} + +static void ScriptCmd_waitbgfadeout(void) +{ + if (gUnknown_0202F7C5 == 2) + { + gBattleAnimScriptPtr++; + gAnimFramesToWait = 0; + } + else + { + gAnimFramesToWait = 1; + } +} + +static void ScriptCmd_waitbgfadein(void) +{ + if (gUnknown_0202F7C5 == 0) + { + gBattleAnimScriptPtr++; + gAnimFramesToWait = 0; + } + else + { + gAnimFramesToWait = 1; + } +} + +static void ScriptCmd_changebg(void) +{ + gBattleAnimScriptPtr++; + sub_8076DB8(SCRIPT_READ_8(gBattleAnimScriptPtr)); + gBattleAnimScriptPtr++; +} + +//Weird control flow +/* +s8 sub_8076F98(s8 a) +{ + if (!IsContest() && (EWRAM_17810[gBattleAnimPlayerMonIndex].unk0 & 0x10)) + { + a = GetBankSide(gBattleAnimPlayerMonIndex) ? 0xC0 : 0x3F; + } + //_08076FDC + else + { + if (IsContest()) + { + if (gBattleAnimPlayerMonIndex == gBattleAnimEnemyMonIndex && gBattleAnimPlayerMonIndex == 2 + && a == 0x3F) + { + //jump to _0807707A + if (a < -0x40) + a = 0xC0; + return a; + } + } + //_08077004 + else + { + if (GetBankSide(gBattleAnimPlayerMonIndex) == 0) + { + if (GetBankSide(gBattleAnimEnemyMonIndex) == 0) + } + //_08077042 + else + { + + } + //_0807706C + } + } + //_0807706E +} +*/ +__attribute__((naked)) +s8 sub_8076F98(s8 a) +{ + asm(".syntax unified\n\ + push {r4,lr}\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + bl IsContest\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _08076FDC\n\ + ldr r0, _08076FD4 @ =gBattleAnimPlayerMonIndex\n\ + ldrb r2, [r0]\n\ + lsls r0, r2, 1\n\ + adds r0, r2\n\ + lsls r0, 2\n\ + ldr r1, _08076FD8 @ =0x02017810\n\ + adds r0, r1\n\ + ldrb r1, [r0]\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08076FDC\n\ + adds r0, r2, 0\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + movs r4, 0xC0\n\ + cmp r0, 0\n\ + beq _0807706E\n\ + movs r4, 0x3F\n\ + b _0807706E\n\ + .align 2, 0\n\ +_08076FD4: .4byte gBattleAnimPlayerMonIndex\n\ +_08076FD8: .4byte 0x02017810\n\ +_08076FDC:\n\ + bl IsContest\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _08077004\n\ + ldr r0, _08076FFC @ =gBattleAnimPlayerMonIndex\n\ + ldr r1, _08077000 @ =gBattleAnimEnemyMonIndex\n\ + ldrb r0, [r0]\n\ + ldrb r1, [r1]\n\ + cmp r0, r1\n\ + bne _08077068\n\ + cmp r0, 0x2\n\ + bne _08077068\n\ + cmp r4, 0x3F\n\ + beq _0807707A\n\ + b _08077068\n\ + .align 2, 0\n\ +_08076FFC: .4byte gBattleAnimPlayerMonIndex\n\ +_08077000: .4byte gBattleAnimEnemyMonIndex\n\ +_08077004:\n\ + ldr r0, _0807702C @ =gBattleAnimPlayerMonIndex\n\ + ldrb r0, [r0]\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _08077042\n\ + ldr r0, _08077030 @ =gBattleAnimEnemyMonIndex\n\ + ldrb r0, [r0]\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _0807706E\n\ + lsls r0, r4, 24\n\ + asrs r1, r0, 24\n\ + cmp r1, 0x3F\n\ + bne _08077034\n\ + movs r4, 0xC0\n\ + b _0807706E\n\ + .align 2, 0\n\ +_0807702C: .4byte gBattleAnimPlayerMonIndex\n\ +_08077030: .4byte gBattleAnimEnemyMonIndex\n\ +_08077034:\n\ + movs r0, 0x40\n\ + negs r0, r0\n\ + cmp r1, r0\n\ + beq _0807706E\n\ + negs r0, r1\n\ + lsls r0, 24\n\ + b _0807706C\n\ +_08077042:\n\ + ldr r0, _08077064 @ =gBattleAnimEnemyMonIndex\n\ + ldrb r0, [r0]\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + bne _08077068\n\ + lsls r0, r4, 24\n\ + asrs r0, 24\n\ + movs r1, 0x40\n\ + negs r1, r1\n\ + cmp r0, r1\n\ + bne _0807706E\n\ + movs r4, 0x3F\n\ + b _0807706E\n\ + .align 2, 0\n\ +_08077064: .4byte gBattleAnimEnemyMonIndex\n\ +_08077068:\n\ + lsls r0, r4, 24\n\ + negs r0, r0\n\ +_0807706C:\n\ + lsrs r4, r0, 24\n\ +_0807706E:\n\ + lsls r0, r4, 24\n\ + asrs r0, 24\n\ + cmp r0, 0x3F\n\ + ble _0807707A\n\ + movs r4, 0x3F\n\ + b _08077088\n\ +_0807707A:\n\ + lsls r0, r4, 24\n\ + asrs r0, 24\n\ + movs r1, 0x40\n\ + negs r1, r1\n\ + cmp r0, r1\n\ + bge _08077088\n\ + movs r4, 0xC0\n\ +_08077088:\n\ + lsls r0, r4, 24\n\ + asrs r0, 24\n\ + pop {r4}\n\ + pop {r1}\n\ + bx r1\n\ + .syntax divided\n"); +} + +s8 sub_8077094(s8 a) +{ + if (!IsContest() && (EWRAM_17810[gBattleAnimPlayerMonIndex].unk0 & 0x10)) + { + if (GetBankSide(gBattleAnimPlayerMonIndex) != 0) + a = 0x3F; + else + a = 0xC0; + } + else + { + if (GetBankSide(gBattleAnimPlayerMonIndex) != 0 || IsContest() != 0) + a = -a; + } + return a; +} + +s16 sub_8077104(s16 a) +{ + s16 var = a; + + if (var > 63) + var = 63; + else if (var < -64) + var = -64; + return var; +} + +s16 sub_807712C(s16 a, s16 b, s16 c) +{ + u16 var; + + if (a < b) + var = ((c < 0) ? -c : c); + else if (a > b) + var = -((c < 0) ? -c : c); + else + var = 0; + return var; +} + +static void ScriptCmd_panse_19(void) +{ + u16 r4; + s8 r0; + + gBattleAnimScriptPtr++; + r4 = SCRIPT_READ_16(gBattleAnimScriptPtr); + r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); + PlaySE12WithPanning(r4, sub_8076F98(r0)); + gBattleAnimScriptPtr += 3; +} + +static void ScriptCmd_setpan(void) +{ + s8 r0; + + gBattleAnimScriptPtr++; + r0 = SCRIPT_READ_8(gBattleAnimScriptPtr); + SE12PanpotControl(sub_8076F98(r0)); + gBattleAnimScriptPtr++; +} + +static void ScriptCmd_panse_1B(void) +{ + u16 songNum; + s8 r0; + s8 r4; + s8 r6; + u8 r7; + s8 panning; + s8 r8; + u8 taskId; + + gBattleAnimScriptPtr++; + songNum = SCRIPT_READ_16(gBattleAnimScriptPtr); + r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); + r4 = SCRIPT_READ_8(gBattleAnimScriptPtr + 3); + r6 = SCRIPT_READ_8(gBattleAnimScriptPtr + 4); + r7 = SCRIPT_READ_8(gBattleAnimScriptPtr + 5); + panning = sub_8076F98(r0); + r8 = sub_8076F98(r4); + r4 = sub_807712C(panning, r8, r6); + taskId = CreateTask(c3_08073CEC, 1); + gTasks[taskId].data[0] = panning; + gTasks[taskId].data[1] = r8; + gTasks[taskId].data[2] = r4; + gTasks[taskId].data[3] = r7; + gTasks[taskId].data[4] = panning; + PlaySE12WithPanning(songNum, panning); + gAnimSoundTaskCount++; + gBattleAnimScriptPtr += 6; +} + +#ifdef NONMATCHING +static void c3_08073CEC(u8 taskId) +{ + u16 r7 = 0; + s16 r0; + s16 r6; + s16 r3; + s16 r4; + int foo; + + r0 = gTasks[taskId].data[8]; + gTasks[taskId].data[8]++; + if (r0 >= gTasks[taskId].data[3]) + { + gTasks[taskId].data[8] = r7; + r6 = gTasks[taskId].data[0]; + r3 = gTasks[taskId].data[1]; + foo = gTasks[taskId].data[4] + gTasks[taskId].data[2]; + r4 = foo; + gTasks[taskId].data[4] = r4; + if (gTasks[taskId].data[2] == 0) + { + r4 = r3; + DestroyTask(taskId); + gAnimSoundTaskCount--; + } + //_080772D8 + else + { + if (r6 < r3) + { + if (r4 < r3) + goto check; + DestroyTask(taskId); + gAnimSoundTaskCount--; + } + else + { + if (r4 <= r3) + r7 = 1; + check: + if (r7 != 0) + { + DestroyTask(taskId); + gAnimSoundTaskCount--; + } + } + } + //_080772F8 + SE12PanpotControl(r4); + } + //_08077314 +} +#else +__attribute__((naked)) +static void c3_08073CEC(u8 taskId) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + movs r7, 0\n\ + ldr r1, _080772D4 @ =gTasks\n\ + lsls r0, r5, 2\n\ + adds r0, r5\n\ + lsls r0, 3\n\ + adds r2, r0, r1\n\ + ldrh r0, [r2, 0x18]\n\ + adds r1, r0, 0x1\n\ + strh r1, [r2, 0x18]\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + movs r3, 0xE\n\ + ldrsh r1, [r2, r3]\n\ + cmp r0, r1\n\ + blt _08077314\n\ + strh r7, [r2, 0x18]\n\ + ldrh r6, [r2, 0x8]\n\ + ldrh r3, [r2, 0xA]\n\ + movs r4, 0x10\n\ + ldrsh r0, [r2, r4]\n\ + movs r4, 0xC\n\ + ldrsh r1, [r2, r4]\n\ + adds r0, r1\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + strh r4, [r2, 0x10]\n\ + cmp r1, 0\n\ + bne _080772D8\n\ + lsls r2, r3, 16\n\ + b _080772FC\n\ + .align 2, 0\n\ +_080772D4: .4byte gTasks\n\ +_080772D8:\n\ + lsls r1, r6, 16\n\ + lsls r0, r3, 16\n\ + asrs r3, r0, 16\n\ + adds r2, r0, 0\n\ + cmp r1, r2\n\ + bge _080772EE\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + cmp r0, r3\n\ + blt _080772F8\n\ + b _080772FC\n\ +_080772EE:\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + cmp r0, r3\n\ + bgt _080772F8\n\ + movs r7, 0x1\n\ +_080772F8:\n\ + cmp r7, 0\n\ + beq _0807730C\n\ +_080772FC:\n\ + lsrs r4, r2, 16\n\ + adds r0, r5, 0\n\ + bl DestroyTask\n\ + ldr r1, _0807731C @ =gAnimSoundTaskCount\n\ + ldrb r0, [r1]\n\ + subs r0, 0x1\n\ + strb r0, [r1]\n\ +_0807730C:\n\ + lsls r0, r4, 24\n\ + asrs r0, 24\n\ + bl SE12PanpotControl\n\ +_08077314:\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_0807731C: .4byte gAnimSoundTaskCount\n\ + .syntax divided\n"); +} +#endif + +static void ScriptCmd_panse_26(void) +{ + u16 r8; + s8 r4; + s8 r5; + s8 r6; + u8 r10; + u8 taskId; + + gBattleAnimScriptPtr++; + r8 = SCRIPT_READ_16(gBattleAnimScriptPtr); + r4 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); + r5 = SCRIPT_READ_8(gBattleAnimScriptPtr + 3); + r6 = SCRIPT_READ_8(gBattleAnimScriptPtr + 4); + r10 = SCRIPT_READ_8(gBattleAnimScriptPtr + 5); + taskId = CreateTask(c3_08073CEC, 1); + gTasks[taskId].data[0] = r4; + gTasks[taskId].data[1] = r5; + gTasks[taskId].data[2] = r6; + gTasks[taskId].data[3] = r10; + gTasks[taskId].data[4] = r4; + PlaySE12WithPanning(r8, r4); + gAnimSoundTaskCount++; + gBattleAnimScriptPtr += 6; +} + +static void ScriptCmd_panse_27(void) +{ + u16 r9; + u8 r4; + u8 r8; + u8 r7; + u8 r0; + s8 r6; + s8 r5; + s8 r4_2; + u8 taskId; + + gBattleAnimScriptPtr++; + r9 = SCRIPT_READ_16(gBattleAnimScriptPtr); + r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); + r4 = SCRIPT_READ_8(gBattleAnimScriptPtr + 3); + r8 = SCRIPT_READ_8(gBattleAnimScriptPtr + 4); + r7 = SCRIPT_READ_8(gBattleAnimScriptPtr + 5); + r6 = sub_8077094(r0); + r5 = sub_8077094(r4); + r4_2 = sub_8077094(r8); + taskId = CreateTask(c3_08073CEC, 1); + gTasks[taskId].data[0] = r6; + gTasks[taskId].data[1] = r5; + gTasks[taskId].data[2] = r4_2; + gTasks[taskId].data[3] = r7; + gTasks[taskId].data[4] = r6; + PlaySE12WithPanning(r9, r6); + gAnimSoundTaskCount++; + gBattleAnimScriptPtr += 6; +} + +static void ScriptCmd_panse_1C(void) +{ + u16 r5; + u8 r0; + u8 r8; + u8 r9; + s8 r4; + u8 taskId; + + gBattleAnimScriptPtr++; + r5 = SCRIPT_READ_16(gBattleAnimScriptPtr); + r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); + r8 = SCRIPT_READ_8(gBattleAnimScriptPtr + 3); + r9 = SCRIPT_READ_8(gBattleAnimScriptPtr + 4); + r4 = sub_8076F98(r0); + taskId = CreateTask(sub_80774FC, 1); + gTasks[taskId].data[0] = r5; + gTasks[taskId].data[1] = r4; + gTasks[taskId].data[2] = r8; + gTasks[taskId].data[3] = r9; + gTasks[taskId].data[8] = r8; + gTasks[taskId].func(taskId); + gAnimSoundTaskCount++; + gBattleAnimScriptPtr += 5; +} + +static void sub_80774FC(u8 taskId) +{ + s16 data8; + u16 r0; + s8 r1; + u8 r4; + + data8 = gTasks[taskId].data[8]; + gTasks[taskId].data[8]++; + if (data8 >= gTasks[taskId].data[2]) + { + gTasks[taskId].data[8] = 0; + r0 = gTasks[taskId].data[0]; + r1 = gTasks[taskId].data[1]; + gTasks[taskId].data[3]--; + r4 = gTasks[taskId].data[3]; + PlaySE12WithPanning(r0, r1); + if (r4 == 0) + { + DestroyTask(taskId); + gAnimSoundTaskCount--; + } + } +} + +static void ScriptCmd_panse_1D(void) +{ + u16 r5; + u8 r0; + u8 r8; + s8 r4; + u8 taskId; + + gBattleAnimScriptPtr++; + r5 = SCRIPT_READ_16(gBattleAnimScriptPtr); + r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); + r8 = SCRIPT_READ_8(gBattleAnimScriptPtr + 3); + r4 = sub_8076F98(r0); + taskId = CreateTask(sub_80775CC, 1); + gTasks[taskId].data[0] = r5; + gTasks[taskId].data[1] = r4; + gTasks[taskId].data[2] = r8; + gAnimSoundTaskCount++; + gBattleAnimScriptPtr += 4; +} + +static void sub_80775CC(u8 taskId) +{ + s16 r0; + + r0 = gTasks[taskId].data[2]; + gTasks[taskId].data[2]--; + if (r0 <= 0) + { + PlaySE12WithPanning(gTasks[taskId].data[0], gTasks[taskId].data[1]); + DestroyTask(taskId); + gAnimSoundTaskCount--; + } +} + +static void ScriptCmd_createtask_1F(void) +{ + TaskFunc func; + u8 numArgs; + int i; + u8 taskId; + + gBattleAnimScriptPtr++; + func = (TaskFunc)SCRIPT_READ_32(gBattleAnimScriptPtr); + gBattleAnimScriptPtr += 4; + numArgs = SCRIPT_READ_8(gBattleAnimScriptPtr); + gBattleAnimScriptPtr++; + for (i = 0; i < numArgs; i++) + { + gBattleAnimArgs[i] = SCRIPT_READ_16(gBattleAnimScriptPtr); + gBattleAnimScriptPtr += 2; + } + taskId = CreateTask(func, 1); + func(taskId); + gAnimSoundTaskCount++; +} + +static void ScriptCmd_waitsound(void) +{ + if (gAnimSoundTaskCount != 0) + { + gSoundAnimFramesToWait = 0; + gAnimFramesToWait = 1; + } + else if (IsSEPlaying()) + { + if (++gSoundAnimFramesToWait > 90) + { + m4aMPlayStop(&gMPlay_SE1); + m4aMPlayStop(&gMPlay_SE2); + gSoundAnimFramesToWait = 0; + } + else + { + gAnimFramesToWait = 1; + } + } + else + { + gSoundAnimFramesToWait = 0; + gBattleAnimScriptPtr++; + gAnimFramesToWait = 0; + } +} + +static void ScriptCmd_jumpvareq(void) +{ + u8 r2; + s16 r1; + u8 *addr; + + gBattleAnimScriptPtr++; + r2 = SCRIPT_READ_8(gBattleAnimScriptPtr); + r1 = SCRIPT_READ_16(gBattleAnimScriptPtr + 1); + if (r1 == gBattleAnimArgs[r2]) + { + addr = (u8 *)SCRIPT_READ_32(gBattleAnimScriptPtr + 3); + gBattleAnimScriptPtr = addr; + } + else + { + gBattleAnimScriptPtr += 7; + } +} + +static void ScriptCmd_jumpunkcond(void) +{ + u8 *addr; + + gBattleAnimScriptPtr++; + if (IsContest()) + { + addr = (u8 *)SCRIPT_READ_32(gBattleAnimScriptPtr); + gBattleAnimScriptPtr = addr; + } + else + { + gBattleAnimScriptPtr += 4; + } +} + +static void ScriptCmd_monbgprio_28(void) +{ + u8 r2; + u8 r0; + u8 r4; + + r2 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); + gBattleAnimScriptPtr += 2; + if (r2 != 0) + r0 = gBattleAnimEnemyMonIndex; + else + r0 = gBattleAnimPlayerMonIndex; + r4 = GetBankIdentity(r0); + if (!IsContest() && (r4 == 0 || r4 == 3)) + { + REG_BG1CNT_BITFIELD.priority = 1; + REG_BG2CNT_BITFIELD.priority = 2; + } +} + +static void ScriptCmd_monbgprio_29(void) +{ + gBattleAnimScriptPtr++; + if (!IsContest()) + { + REG_BG1CNT_BITFIELD.priority = 1; + REG_BG2CNT_BITFIELD.priority = 2; + } +} + +static void ScriptCmd_monbgprio_2A(void) +{ + u8 r6; + u8 r4; + u8 r0; + + r6 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); + gBattleAnimScriptPtr += 2; + if (GetBankSide(gBattleAnimPlayerMonIndex) != GetBankSide(gBattleAnimEnemyMonIndex)) + { + if (r6 != 0) + r0 = gBattleAnimEnemyMonIndex; + else + r0 = gBattleAnimPlayerMonIndex; + r4 = GetBankIdentity(r0); + if (!IsContest() && (r4 == 0 || r4 == 3)) + { + REG_BG1CNT_BITFIELD.priority = 1; + REG_BG2CNT_BITFIELD.priority = 2; + } + } +} + +static void ScriptCmd_invisible(void) +{ + u8 r0; + u8 spriteId; + + r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); + spriteId = obj_id_for_side_relative_to_move(r0); + if (spriteId != 0xFF) + { + gSprites[spriteId].invisible = TRUE; + } + gBattleAnimScriptPtr += 2; +} + +static void ScriptCmd_visible(void) +{ + u8 r0; + u8 spriteId; + + r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); + spriteId = obj_id_for_side_relative_to_move(r0); + if (spriteId != 0xFF) + { + gSprites[spriteId].invisible = FALSE; + } + gBattleAnimScriptPtr += 2; +} + +static void ScriptCmd_doublebattle_2D(void) +{ + u8 r7; + u8 r4; + u8 spriteId; + + r7 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); + gBattleAnimScriptPtr += 2; + if (!IsContest() && IsDoubleBattle() + && GetBankSide(gBattleAnimPlayerMonIndex) == GetBankSide(gBattleAnimEnemyMonIndex)) + { + if (r7 == 0) + { + r4 = GetBankIdentity_permutated(gBattleAnimPlayerMonIndex); + spriteId = obj_id_for_side_relative_to_move(0); + } + else + { + r4 = GetBankIdentity_permutated(gBattleAnimEnemyMonIndex); + spriteId = obj_id_for_side_relative_to_move(1); + } + if (spriteId != 0xFF) + { + gSprites[spriteId].invisible = FALSE; + if (r4 == 2) + gSprites[spriteId].oam.priority = 3; + if (r4 == 1) + sub_8076464(0); + else + sub_8076464(1); + } + } +} + +static void ScriptCmd_doublebattle_2E(void) +{ + u8 r7; + u8 r4; + u8 spriteId; + + r7 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); + gBattleAnimScriptPtr += 2; + if (!IsContest() && IsDoubleBattle() + && GetBankSide(gBattleAnimPlayerMonIndex) == GetBankSide(gBattleAnimEnemyMonIndex)) + { + if (r7 == 0) + { + r4 = GetBankIdentity_permutated(gBattleAnimPlayerMonIndex); + spriteId = obj_id_for_side_relative_to_move(0); + } + else + { + r4 = GetBankIdentity_permutated(gBattleAnimEnemyMonIndex); + spriteId = obj_id_for_side_relative_to_move(1); + } + if (spriteId != 0xFF && r4 == 2) + { + gSprites[spriteId].oam.priority = 2; + } + } +} + +static void ScriptCmd_stopsound(void) +{ + m4aMPlayStop(&gMPlay_SE1); + m4aMPlayStop(&gMPlay_SE2); + gBattleAnimScriptPtr++; +} diff --git a/src/battle_anim_80A7E7C.c b/src/battle_anim_80A7E7C.c new file mode 100644 index 000000000..34c11a352 --- /dev/null +++ b/src/battle_anim_80A7E7C.c @@ -0,0 +1,941 @@ +#include "global.h" +#include "battle_anim.h" +#include "rom_8077ABC.h" +#include "sprite.h" +#include "task.h" +#include "trig.h" + +#define TASK gTasks[task] +#define SPRITE gSprites[TASK.data[0]] + +extern s16 gBattleAnimArgs[8]; + +extern u8 gObjectBankIDs[]; +extern s32 gMoveDmgMoveAnim; +extern u16 gMovePowerMoveAnim; +extern u8 gBattleAnimPlayerMonIndex; +extern u8 gBattleAnimEnemyMonIndex; + +static void sub_80A7EF0(u8 task); +static void sub_80A808C(u8 task); +static void sub_80A81D8(u8 task); +static void sub_80A8374(u8 task); +static void sub_80A8488(u8 task); +static void sub_80A85A4(struct Sprite *sprite); +void sub_80A8614(struct Sprite* sprite); +static void sub_80A86F4(struct Sprite *sprite); +static void sub_80A88F0(struct Sprite *sprite); +static void sub_80A89B4(u8 task); +static void sub_80A8A18(u8 task); +static void sub_80A8C0C(u8 task); +static void sub_80A8D8C(u8 task); +void sub_80A8FD8(u8 task); +static void sub_80A913C(u8 taskId); + +void sub_80A7E7C(u8 task) +{ + u8 sprite; + sprite = obj_id_for_side_relative_to_move(gBattleAnimArgs[0]); + if (sprite == 0xff) + { + DestroyAnimVisualTask(task); + return; + } + gSprites[sprite].pos2.x = gBattleAnimArgs[1]; + gSprites[sprite].pos2.y = gBattleAnimArgs[2]; + TASK.data[0] = sprite; + TASK.data[1] = gBattleAnimArgs[3]; + TASK.data[2] = gBattleAnimArgs[4]; + TASK.data[3] = gBattleAnimArgs[4]; + TASK.data[4] = gBattleAnimArgs[1]; + TASK.data[5] = gBattleAnimArgs[2]; + TASK.func = sub_80A7EF0; + sub_80A7EF0(task); +} + +static void sub_80A7EF0(u8 task) +{ + if (TASK.data[3] == 0) + { + if (SPRITE.pos2.x == 0) + { + SPRITE.pos2.x = TASK.data[4]; + } + else + { + SPRITE.pos2.x = 0; + } + if (SPRITE.pos2.y == 0) + { + SPRITE.pos2.y = TASK.data[5]; + } + else + { + SPRITE.pos2.y = 0; + } + TASK.data[3] = TASK.data[2]; + if (--TASK.data[1] == 0) + { + SPRITE.pos2.x = 0; + SPRITE.pos2.y = 0; + DestroyAnimVisualTask(task); + return; + } + } + else + { + TASK.data[3]--; + } +} + + +void sub_80A7FA0(u8 task) +{ + u8 sprite; + bool8 r6; + u8 side; + r6 = 0; + if (gBattleAnimArgs[0] < 4) + { + sprite = obj_id_for_side_relative_to_move(gBattleAnimArgs[0]); + if (sprite == 0xff) + { + DestroyAnimVisualTask(task); + return; + } + } + else if (gBattleAnimArgs[0] != 8) + { + switch (gBattleAnimArgs[0]) + { + case 4: + side = GetBankByPlayerAI(0); + break; + case 5: + side = GetBankByPlayerAI(2); + break; + case 6: + side = GetBankByPlayerAI(1); + break; + case 7: + default: + side = GetBankByPlayerAI(3); + break; + } + if (b_side_obj__get_some_boolean(side) == FALSE) + { + r6 = 1; + } + sprite = gObjectBankIDs[side]; + } + else + { + sprite = gObjectBankIDs[gBattleAnimPlayerMonIndex]; + } + if (r6) + { + DestroyAnimVisualTask(task); + return; + } + gSprites[sprite].pos2.x = gBattleAnimArgs[1]; + gSprites[sprite].pos2.y = gBattleAnimArgs[2]; + TASK.data[0] = sprite; + TASK.data[1] = gBattleAnimArgs[3]; + TASK.data[2] = gBattleAnimArgs[4]; + TASK.data[3] = gBattleAnimArgs[4]; + TASK.data[4] = gBattleAnimArgs[1]; + TASK.data[5] = gBattleAnimArgs[2]; + TASK.func = sub_80A808C; + sub_80A808C(task); +} + +static void sub_80A808C(u8 task) +{ + if (TASK.data[3] == 0) + { + if (SPRITE.pos2.x == TASK.data[4]) + { + SPRITE.pos2.x = -TASK.data[4]; + } + else + { + SPRITE.pos2.x = TASK.data[4]; + } + if (SPRITE.pos2.y == TASK.data[5]) + { + SPRITE.pos2.y = -TASK.data[5]; + } + else + { + SPRITE.pos2.y = TASK.data[5]; + } + TASK.data[3] = TASK.data[2]; + if (--TASK.data[1] == 0) + { + SPRITE.pos2.x = 0; + SPRITE.pos2.y = 0; + DestroyAnimVisualTask(task); + return; + } + } + else + { + TASK.data[3]--; + } +} + +void sub_80A8154(u8 task) +{ + u8 sprite; + sprite = obj_id_for_side_relative_to_move(gBattleAnimArgs[0]); + if (sprite == 0xff) + { + DestroyAnimVisualTask(task); + return; + } + gSprites[sprite].pos2.x += gBattleAnimArgs[1]; + gSprites[sprite].pos2.y += gBattleAnimArgs[2]; + TASK.data[0] = sprite; + TASK.data[1] = 0; + TASK.data[2] = gBattleAnimArgs[3]; + TASK.data[3] = 0; + TASK.data[4] = gBattleAnimArgs[4]; + TASK.data[5] = gBattleAnimArgs[1] * 2; + TASK.data[6] = gBattleAnimArgs[2] * 2; + TASK.func = sub_80A81D8; + sub_80A81D8(task); +} + +static void sub_80A81D8(u8 task) +{ + if (TASK.data[3] == 0) + { + if (TASK.data[1] & 1) + { + SPRITE.pos2.x += TASK.data[5]; + SPRITE.pos2.y += TASK.data[6]; + } + else + { + SPRITE.pos2.x -= TASK.data[5]; + SPRITE.pos2.y -= TASK.data[6]; + } + TASK.data[3] = TASK.data[4]; + if (++TASK.data[1] >= TASK.data[2]) + { + if (TASK.data[1] & 1) + { + SPRITE.pos2.x += TASK.data[5] / 2; + SPRITE.pos2.y += TASK.data[6] / 2; + } + else + { + SPRITE.pos2.x -= TASK.data[5] / 2; + SPRITE.pos2.y -= TASK.data[6] / 2; + } + DestroyAnimVisualTask(task); + return; + } + } + else + { + TASK.data[3]--; + } +} + +void sub_80A8314(u8 task) +{ + u8 sprite = obj_id_for_side_relative_to_move(gBattleAnimArgs[0]); + gSprites[sprite].pos2.x = gBattleAnimArgs[1]; + TASK.data[0] = sprite; + TASK.data[1] = gBattleAnimArgs[1]; + TASK.data[2] = gBattleAnimArgs[2]; + TASK.data[3] = gBattleAnimArgs[3]; + TASK.data[4] = gBattleAnimArgs[4]; + TASK.func = sub_80A8374; + sub_80A8374(task); +} + +static void sub_80A8374(u8 task) +{ + s16 x; + u8 sprite; + sprite = TASK.data[0]; + x = TASK.data[1]; + if (TASK.data[2] == TASK.data[8]++) + { + TASK.data[8] = 0; + if (gSprites[sprite].pos2.x == x) + { + x = -x; + } + gSprites[sprite].pos2.x += x; + } + TASK.data[1] = x; + TASK.data[9] += TASK.data[3]; + gSprites[sprite].pos2.y = TASK.data[9] >> 8; + if (--TASK.data[4] == 0) + { + DestroyAnimVisualTask(task); + return; + } +} + +void sub_80A8408(u8 task) +{ + u8 i; + u8 sprite; + u8 v1; + v1 = 1; + sprite = obj_id_for_side_relative_to_move(gBattleAnimArgs[0]); + if (gBattleAnimArgs[4] > 5) + { + gBattleAnimArgs[4] = 5; + } + for (i = 0; i < gBattleAnimArgs[4]; i++) + { + v1 <<= 1; + } + TASK.data[0] = sprite; + TASK.data[1] = gBattleAnimArgs[1]; + TASK.data[2] = gBattleAnimArgs[2]; + TASK.data[3] = gBattleAnimArgs[3]; + TASK.data[4] = v1; + TASK.func = sub_80A8488; + sub_80A8488(task); +} + +static void sub_80A8488(u8 task) +{ + u8 sprite; + sprite = TASK.data[0]; + gSprites[sprite].pos2.x = Sin(TASK.data[5], TASK.data[1]); + gSprites[sprite].pos2.y = -Cos(TASK.data[5], TASK.data[2]); + gSprites[sprite].pos2.y += TASK.data[2]; + TASK.data[5] += TASK.data[4]; + TASK.data[5] &= 0xff; + if (TASK.data[5] == 0) + { + TASK.data[3]--; + } + if (TASK.data[3] == 0) + { + gSprites[sprite].pos2.x = 0; + gSprites[sprite].pos2.y = 0; + DestroyAnimVisualTask(task); + return; + } +} + +void sub_80A8500(u8 task) +{ + if (GetBankSide(gBattleAnimPlayerMonIndex)) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + } + sub_80A8408(task); +} + +void sub_80A8530(struct Sprite *sprite) +{ + sprite->invisible = TRUE; + if (GetBankSide(gBattleAnimPlayerMonIndex)) + { + sprite->data1 = -gBattleAnimArgs[1]; + } + else + { + sprite->data1 = gBattleAnimArgs[1]; + } + sprite->data0 = gBattleAnimArgs[0]; + sprite->data2 = 0; + sprite->data3 = gObjectBankIDs[gBattleAnimPlayerMonIndex]; + sprite->data4 = gBattleAnimArgs[0]; + oamt_set_x3A_32(sprite, sub_80A85A4); + sprite->callback = sub_8078458; +} + +static void sub_80A85A4(struct Sprite *sprite) +{ + sprite->data0 = sprite->data4; + sprite->data1 = -sprite->data1; + sprite->callback = sub_8078458; + oamt_set_x3A_32(sprite, move_anim_8072740); +} + +void sub_80A85C8(struct Sprite *sprite) +{ + u8 spriteId; + sprite->invisible = TRUE; + spriteId = obj_id_for_side_relative_to_move(gBattleAnimArgs[2]); + sprite->data0 = gBattleAnimArgs[0]; + sprite->data1 = 0; + sprite->data2 = gBattleAnimArgs[1]; + sprite->data3 = spriteId; + sprite->data4 = gBattleAnimArgs[0]; + oamt_set_x3A_32(sprite, sub_80A8614); + sprite->callback = sub_8078458; +} + +void sub_80A8614(struct Sprite *sprite) +{ + sprite->data0 = sprite->data4; + sprite->data2 = -sprite->data2; + sprite->callback = sub_8078458; + oamt_set_x3A_32(sprite, move_anim_8072740); +} + +void sub_80A8638(struct Sprite *sprite) +{ + int something; + int spriteId; + if (!gBattleAnimArgs[0]) + { + spriteId = gObjectBankIDs[gBattleAnimPlayerMonIndex]; + } + else + { + spriteId = gObjectBankIDs[gBattleAnimEnemyMonIndex]; + } + sprite->data0 = gBattleAnimArgs[2]; + sprite->data1 = gSprites[spriteId].pos1.x + gSprites[spriteId].pos2.x; + sprite->data2 = gSprites[spriteId].pos1.x; + sprite->data3 = gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y; + sprite->data4 = gSprites[spriteId].pos1.y; + something = 0; + sub_8078A5C(sprite); + sprite->data3 = something; + sprite->data4 = something; + sprite->data5 = gSprites[spriteId].pos2.x; + sprite->data6 = gSprites[spriteId].pos2.y; + sprite->invisible = TRUE; + if (gBattleAnimArgs[1] == 1) + { + sprite->data2 = something; + } + else if (gBattleAnimArgs[1] == 2) + { + sprite->data1 = something; + } + sprite->data7 = gBattleAnimArgs[1]; + sprite->data7 |= spriteId << 8; + sprite->callback = sub_80A86F4; +} + +static void sub_80A86F4(struct Sprite *sprite) +{ + s8 spriteId; + u8 lo; + struct Sprite *sprite2; + lo = sprite->data7 & 0xff; + spriteId = sprite->data7 >> 8; + sprite2 = &gSprites[spriteId]; + if (sprite->data0 == 0) + { + if (lo < 2) + { + sprite2->pos2.x = 0; + } + if (lo == 2 || lo == 0) + { + sprite2->pos2.y = 0; + } + move_anim_8072740(sprite); + } + else + { + sprite->data0--; + sprite->data3 += sprite->data1; + sprite->data4 += sprite->data2; + sprite2->pos2.x = (s8)(sprite->data3 >> 8) + sprite->data5; + sprite2->pos2.y = (s8)(sprite->data4 >> 8) + sprite->data6; + } +} + +void sub_80A8764(struct Sprite *sprite) +{ + u8 v1; + u8 spriteId; + if (!gBattleAnimArgs[0]) + { + v1 = gBattleAnimPlayerMonIndex; + } + else + { + v1 = gBattleAnimEnemyMonIndex; + } + spriteId = gObjectBankIDs[v1]; + if (GetBankSide(v1)) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + if (gBattleAnimArgs[3] == 1) + { + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + } + } + sprite->data0 = gBattleAnimArgs[4]; + sprite->data1 = gSprites[spriteId].pos1.x; + sprite->data2 = gSprites[spriteId].pos1.x + gBattleAnimArgs[1]; + sprite->data3 = gSprites[spriteId].pos1.y; + sprite->data4 = gSprites[spriteId].pos1.y + gBattleAnimArgs[2]; + sub_8078A5C(sprite); + sprite->data3 = 0; + sprite->data4 = 0; + sprite->data5 = spriteId; + sprite->invisible = TRUE; + oamt_set_x3A_32(sprite, move_anim_8072740); + sprite->callback = sub_80784A8; +} + +void sub_80A8818(struct Sprite *sprite) +{ + u8 spriteId; + u8 v1; + sprite->invisible = TRUE; + if (!gBattleAnimArgs[0]) + { + v1 = gBattleAnimPlayerMonIndex; + } + else + { + v1 = gBattleAnimEnemyMonIndex; + } + spriteId = gObjectBankIDs[v1]; + if (GetBankSide(v1)) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + if (gBattleAnimArgs[3] == 1) + { + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + } + } + sprite->data0 = gBattleAnimArgs[4]; + sprite->data1 = gSprites[spriteId].pos1.x + gSprites[spriteId].pos2.x; + sprite->data2 = sprite->data1 + gBattleAnimArgs[1]; + sprite->data3 = gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y; + sprite->data4 = sprite->data3 + gBattleAnimArgs[2]; + sub_8078A5C(sprite); + sprite->data3 = gSprites[spriteId].pos2.x << 8; + sprite->data4 = gSprites[spriteId].pos2.y << 8; + sprite->data5 = spriteId; + sprite->data6 = gBattleAnimArgs[5]; + if (!gBattleAnimArgs[5]) + { + oamt_set_x3A_32(sprite, move_anim_8072740); + } + else + { + oamt_set_x3A_32(sprite, sub_80A88F0); + } + sprite->callback = sub_80784A8; +} + + +static void sub_80A88F0(struct Sprite *sprite) +{ + gSprites[sprite->data5].pos2.x = 0; + gSprites[sprite->data5].pos2.y = 0; + move_anim_8072740(sprite); +} + +void sub_80A8920(u8 task) +{ + s16 r7; + r7 = 0x8000 / gBattleAnimArgs[3]; + if (GetBankSide(gBattleAnimPlayerMonIndex)) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + gBattleAnimArgs[5] = -gBattleAnimArgs[5]; + } + TASK.data[0] = obj_id_for_side_relative_to_move(gBattleAnimArgs[0]); + TASK.data[1] = (gBattleAnimArgs[1] << 8) / gBattleAnimArgs[3]; + TASK.data[2] = gBattleAnimArgs[2]; + TASK.data[3] = gBattleAnimArgs[3]; + TASK.data[4] = gBattleAnimArgs[4]; + TASK.data[5] = (gBattleAnimArgs[5] << 8) / gBattleAnimArgs[6]; + TASK.data[6] = gBattleAnimArgs[6]; + TASK.data[7] = r7; + TASK.func = sub_80A89B4; +} + +static void sub_80A89B4(u8 task) +{ + u8 spriteId; + spriteId = TASK.data[0]; + TASK.data[11] += TASK.data[1]; + gSprites[spriteId].pos2.x = TASK.data[11] >> 8; + gSprites[spriteId].pos2.y = Sin((u8)(TASK.data[10] >> 8), TASK.data[2]); + TASK.data[10] += TASK.data[7]; + if (--TASK.data[3] == 0) + { + TASK.func = sub_80A8A18; + } +} + +static void sub_80A8A18(u8 task) +{ + u8 spriteId; + if (TASK.data[4] > 0) + { + TASK.data[4]--; + } + else + { + spriteId = TASK.data[0]; + TASK.data[12] += TASK.data[5]; + gSprites[spriteId].pos2.x = (TASK.data[12] >> 8) + (TASK.data[11] >> 8); + if (--TASK.data[6] == 0) + { + DestroyAnimVisualTask(task); + return; + } + } +} + +static void sub_80A8B3C(u8 task); + +void sub_80A8A80(u8 task) +{ + u8 spriteId; + switch (gBattleAnimArgs[0]) + { + case 0: + case 1: + spriteId = obj_id_for_side_relative_to_move(gBattleAnimArgs[0]); + break; + case 2: + if (!b_side_obj__get_some_boolean(gBattleAnimPlayerMonIndex ^ 2)) + { + DestroyAnimVisualTask(task); + return; + } + spriteId = gObjectBankIDs[gBattleAnimPlayerMonIndex ^ 2]; + break; + case 3: + if (!b_side_obj__get_some_boolean(gBattleAnimEnemyMonIndex ^ 2)) + { + DestroyAnimVisualTask(task); + return; + } + spriteId = gObjectBankIDs[gBattleAnimEnemyMonIndex ^ 2]; + break; + default: + DestroyAnimVisualTask(task); + return; + } + TASK.data[0] = spriteId; + if (GetBankSide(gBattleAnimEnemyMonIndex)) + { + TASK.data[1] = gBattleAnimArgs[1]; + } + else + { + TASK.data[1] = -gBattleAnimArgs[1]; + } + TASK.func = sub_80A8B3C; +} + +static void sub_80A8B3C(u8 task) +{ + u8 spriteId = TASK.data[0]; + gSprites[spriteId].pos2.x += TASK.data[1]; + if (gSprites[spriteId].pos2.x + gSprites[spriteId].pos1.x + 0x20 > 0x130u) + { + DestroyAnimVisualTask(task); + return; + } +} + +void sub_80A8B88(u8 task) +{ + u8 spriteId; + if (GetBankSide(gBattleAnimPlayerMonIndex)) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + } + spriteId = obj_id_for_side_relative_to_move(gBattleAnimArgs[4]); + TASK.data[0] = gBattleAnimArgs[0]; + TASK.data[1] = gBattleAnimArgs[1]; + TASK.data[2] = gBattleAnimArgs[2]; + TASK.data[3] = gBattleAnimArgs[3]; + TASK.data[4] = spriteId; + if (gBattleAnimArgs[4] == 0) + { + TASK.data[5] = gBattleAnimPlayerMonIndex; + } + else + { + TASK.data[5] = gBattleAnimEnemyMonIndex; + } + TASK.data[12] = 1; + TASK.func = sub_80A8C0C; +} + +static void sub_80A8C0C(u8 task) +{ + s16 y; + u8 spriteId; + int index; + u16 val; + spriteId = TASK.data[4]; + val = TASK.data[10] + TASK.data[2]; + TASK.data[10] = val; + index = val >> 8; + y = Sin(index, TASK.data[1]); + if (TASK.data[0] == 0) + { + gSprites[spriteId].pos2.x = y; + } + else + { + if (GetBankSide(TASK.data[5]) == 0) + { + gSprites[spriteId].pos2.y = (y >= 0) ? y : -y; + } + else + { + gSprites[spriteId].pos2.y = (y >= 0) ? -y : y; + } + } + if (((index >= 0x80u) && (TASK.data[11] == 0) && (TASK.data[12] == 1)) + || ((index < 0x7fu) && (TASK.data[11] == 1) && (TASK.data[12] == 0))) + { + TASK.data[11] ^= 1; + TASK.data[12] ^= 1; + if (--TASK.data[3] == 0) + { + gSprites[spriteId].pos2.x = 0; + gSprites[spriteId].pos2.y = 0; + DestroyAnimVisualTask(task); + return; + } + } +} + +void sub_80A8D34(u8 task) +{ + u8 spriteId; + spriteId = obj_id_for_side_relative_to_move(gBattleAnimArgs[3]); + sub_8078E70(spriteId, gBattleAnimArgs[4]); + TASK.data[0] = gBattleAnimArgs[0]; + TASK.data[1] = gBattleAnimArgs[1]; + TASK.data[2] = gBattleAnimArgs[2]; + TASK.data[3] = gBattleAnimArgs[2]; + TASK.data[4] = spriteId; + TASK.data[10] = 0x100; + TASK.data[11] = 0x100; + TASK.func = sub_80A8D8C; +} + +static void sub_80A8D8C(u8 task) +{ + u8 spriteId; + TASK.data[10] += TASK.data[0]; + TASK.data[11] += TASK.data[1]; + spriteId = TASK.data[4]; + obj_id_set_rotscale(spriteId, TASK.data[10], TASK.data[11], 0); + if (--TASK.data[2] == 0) + { + if (TASK.data[3] > 0) + { + TASK.data[0] = -TASK.data[0]; + TASK.data[1] = -TASK.data[1]; + TASK.data[2] = TASK.data[3]; + TASK.data[3] = 0; + } + else + { + sub_8078F40(spriteId); + DestroyAnimVisualTask(task); + return; + } + } +} + +void sub_80A8E04(u8 task) +{ + u8 spriteId; + spriteId = obj_id_for_side_relative_to_move(gBattleAnimArgs[2]); + sub_8078E70(spriteId, 0); + TASK.data[1] = 0; + TASK.data[2] = gBattleAnimArgs[0]; + if (gBattleAnimArgs[3] != 1) + { + TASK.data[3] = 0; + } + else + { + TASK.data[3] = gBattleAnimArgs[0] * gBattleAnimArgs[1]; + } + TASK.data[4] = gBattleAnimArgs[1]; + TASK.data[5] = spriteId; + TASK.data[6] = gBattleAnimArgs[3]; + if (IsContest()) + { + TASK.data[7] = 1; + } + else + { + if (gBattleAnimArgs[2] == 0) + { + TASK.data[7] = !GetBankSide(gBattleAnimPlayerMonIndex); + } + else + { + TASK.data[7] = !GetBankSide(gBattleAnimEnemyMonIndex); + } + } + if (TASK.data[7]) + { + if (!IsContest()) + { + TASK.data[3] *= -1; + TASK.data[4] *= -1; + } + } + TASK.func = sub_80A8FD8; +} + +void sub_80A8EFC(u8 task) +{ + u8 spriteId; + spriteId = obj_id_for_side_relative_to_move(gBattleAnimArgs[2]); + sub_8078E70(spriteId, 0); + TASK.data[1] = 0; + TASK.data[2] = gBattleAnimArgs[0]; + if (gBattleAnimArgs[2] == 0) + { + if (GetBankSide(gBattleAnimPlayerMonIndex)) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + } + } + else + { + if (GetBankSide(gBattleAnimEnemyMonIndex)) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + } + } + if (gBattleAnimArgs[3] != 1) + { + TASK.data[3] = 0; + } + else + { + TASK.data[3] = gBattleAnimArgs[0] * gBattleAnimArgs[1]; + } + TASK.data[4] = gBattleAnimArgs[1]; + TASK.data[5] = spriteId; + TASK.data[6] = gBattleAnimArgs[3]; + TASK.data[7] = 1; + TASK.data[3] *= -1; + TASK.data[4] *= -1; + TASK.func = sub_80A8FD8; +} + +void sub_80A8FD8(u8 task) +{ + TASK.data[3] += TASK.data[4]; + obj_id_set_rotscale(TASK.data[5], 0x100, 0x100, TASK.data[3]); + if (TASK.data[7]) + { + sub_8078F9C(TASK.data[5]); + } + if (++TASK.data[1] >= TASK.data[2]) + { + switch (TASK.data[6]) + { + case 1: + sub_8078F40(TASK.data[5]); + case 0: + default: + DestroyAnimVisualTask(task); + return; + case 2: + TASK.data[1] = 0; + TASK.data[4] *= -1; + TASK.data[6] = 1; + break; + } + } +} + +void sub_80A9058(u8 task) +{ + if (!gBattleAnimArgs[0]) + { + TASK.data[15] = gMovePowerMoveAnim / 12; + if (TASK.data[15] < 1) + { + TASK.data[15] = 1; + } + if (TASK.data[15] > 16) + { + TASK.data[15] = 16; + } + } + else + { + TASK.data[15] = gMoveDmgMoveAnim / 12; + if (TASK.data[15] < 1) + { + TASK.data[15] = 1; + } + if (TASK.data[15] > 16) + { + TASK.data[15] = 16; + } + } + TASK.data[14] = TASK.data[15] / 2; + TASK.data[13] = TASK.data[14] + (TASK.data[15] & 1); + TASK.data[12] = 0; + TASK.data[10] = gBattleAnimArgs[3]; + TASK.data[11] = gBattleAnimArgs[4]; + TASK.data[7] = obj_id_for_side_relative_to_move(1); + TASK.data[8] = gSprites[TASK.data[7]].pos2.x; + TASK.data[9] = gSprites[TASK.data[7]].pos2.y; + TASK.data[0] = 0; + TASK.data[1] = gBattleAnimArgs[1]; + TASK.data[2] = gBattleAnimArgs[2]; + TASK.func = sub_80A913C; +} + +static void sub_80A913C(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + if (++task->data[0] > task->data[1]) + { + task->data[0] = 0; + task->data[12] = (task->data[12] + 1) & 1; + if (task->data[10]) + { + if (task->data[12]) + { + gSprites[task->data[7]].pos2.x = task->data[8] + task->data[13]; + } + else + { + gSprites[task->data[7]].pos2.x = task->data[8] - task->data[14]; + } + } + if (task->data[11]) + { + if (task->data[12]) + { + gSprites[task->data[7]].pos2.y = task->data[15]; + } + else + { + gSprites[task->data[7]].pos2.y = 0; + } + } + if (!--task->data[2]) + { + gSprites[task->data[7]].pos2.x = 0; + gSprites[task->data[7]].pos2.y = 0; + DestroyAnimVisualTask(taskId); + return; + } + } +} diff --git a/src/battle_anim_81258BC.c b/src/battle_anim_81258BC.c new file mode 100644 index 000000000..5bdbb4946 --- /dev/null +++ b/src/battle_anim_81258BC.c @@ -0,0 +1,50 @@ +#include "global.h" +#include "battle_anim_81258BC.h" +#include "battle.h" +#include "battle_message.h" +#include "menu_cursor.h" +#include "text.h" + +extern struct Window gUnknown_03004210; +extern u8 gDisplayedStringBattle[]; +extern u8 gActionSelectionCursor[]; + +extern const u8 gUnknown_08400CBB[]; +extern u8 gActiveBank; +extern const u8 gUnknown_08400D15[]; + +extern void *gBattleBankFunc[]; +extern u16 gUnknown_030042A0; +extern u16 gUnknown_030042A4; + +#if ENGLISH +#define SUB_812BB10_TILE_DATA_OFFSET 440 +#elif GERMAN +#define SUB_812BB10_TILE_DATA_OFFSET 444 +#endif + +void sub_812BB10(void) { + int i; + + gUnknown_030042A4 = 0; + gUnknown_030042A0 = 160; + gUnknown_03004210.paletteNum = 0; + FillWindowRect_DefaultPalette(&gUnknown_03004210, 10, 2, 15, 27, 18); + FillWindowRect_DefaultPalette(&gUnknown_03004210, 10, 2, 35, 16, 36); + gBattleBankFunc[gActiveBank] = bx_battle_menu_t6_2; + + InitWindow(&gUnknown_03004210, gUnknown_08400D15, 400, 18, 35); + sub_8002F44(&gUnknown_03004210); + sub_814A5C0(0, 0xFFFF, 12, 11679, 0); + + for (i = 0; i < 4; i++) + { + nullsub_8(i); + } + + sub_802E3E4(gActionSelectionCursor[gActiveBank], 0); + StrCpyDecodeToDisplayedStringBattle((u8 *) gUnknown_08400CBB); + + InitWindow(&gUnknown_03004210, gDisplayedStringBattle, SUB_812BB10_TILE_DATA_OFFSET, 2, 35); + sub_8002F44(&gUnknown_03004210); +}
\ No newline at end of file diff --git a/src/battle_anim_8137220.c b/src/battle_anim_8137220.c new file mode 100644 index 000000000..42d6cb8da --- /dev/null +++ b/src/battle_anim_8137220.c @@ -0,0 +1,1486 @@ +#include "global.h" +#include "battle.h" +#include "battle_interface.h" +#include "battle_message.h" +#include "data2.h" +#include "link.h" +#include "main.h" +#include "menu_cursor.h" +#include "palette.h" +#include "pokemon.h" +#include "rom3.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "string_util.h" +#include "task.h" +#include "text.h" +#include "util.h" + +//Possibly PokemonSubstruct1 +struct UnknownStruct3 +{ + u16 moves[4]; + u8 pp[4]; + u8 ppBonuses; +}; + +extern u8 gActiveBank; +extern void (*gBattleBankFunc[])(void); +extern u32 gBattleExecBuffer; +extern void (*gWallyBufferCommands[])(void); +extern u8 gBattleBufferA[][0x200]; +extern u8 gObjectBankIDs[]; +extern MainCallback gPreBattleCallback1; +extern bool8 gDoingBattleAnim; +extern u16 gScriptItemId; +extern u16 gBattlePartyID[]; +extern u8 gHealthboxIDs[]; +extern u16 gBattleTypeFlags; +extern u16 gMovePowerMoveAnim; +extern u32 gMoveDmgMoveAnim; +extern u8 gHappinessMoveAnim; +extern u16 gWeatherMoveAnim; +extern u32 *gDisableStructMoveAnim; +extern u32 gPID_perBank[]; +extern void (*gAnimScriptCallback)(void); +extern bool8 gAnimScriptActive; +extern u8 gDisplayedStringBattle[]; +extern u8 gBankInMenu; +extern u8 gBattleMonForms[]; +extern u8 gBattleOutcome; +extern u16 gUnknown_02024DE8; +extern u8 gUnknown_02024E68[]; +extern struct SpriteTemplate gUnknown_02024E8C; +extern u8 gUnknown_0202F7C4; +extern struct Window gUnknown_03004210; +extern u16 gUnknown_030042A0; +extern u16 gUnknown_030042A4; +extern u8 gUnknown_0300434C[]; +extern const u8 gUnknown_08400CCC[]; +extern const u8 gUnknown_08400CF3[]; + +// TODO: include rom3.h when my other PR gets merged +extern void dp01_build_cmdbuf_x21_a_bb(u8, u8, u16); +extern void dp01_build_cmdbuf_x23_aa_0(u8, u16); + +extern void nullsub_14(void); +extern void PrepareBagForWallyTutorial(void); +extern void sub_8141828(); +extern void sub_8045A5C(); +extern void sub_804777C(); +extern void sub_8043DFC(); +extern bool8 IsDoubleBattle(void); +extern void c3_0802FDF4(u8); +extern void sub_802ECF0(void); +extern void sub_8031AF4(); +extern u8 GetBankIdentity(u8); +extern void sub_80313A0(struct Sprite *); +extern u8 GetBankByPlayerAI(u8); +extern u8 sub_8031720(); +extern void ExecuteMoveAnim(); +extern void sub_80326EC(); +extern void sub_8031F24(void); +extern void sub_80324BC(); +extern void BufferStringBattle(); +extern u8 GetBankSide(u8); +extern void sub_80304A8(void); +extern void sub_8047858(); +extern void sub_80E43C0(); +extern void oamt_add_pos2_onto_pos1(); +extern void sub_8078B34(struct Sprite *); +extern void sub_8030E38(struct Sprite *); +extern void oamt_set_x3A_32(); +extern u8 sub_8046400(); +extern u8 sub_8077ABC(); +extern u8 sub_8077F68(); +extern u8 sub_8079E90(); +extern void sub_80312F0(struct Sprite *); +extern bool8 move_anim_start_t3(); + +void WallyBufferRunCommand(void); +void sub_81374FC(void); +void sub_81376B8(void); +void WallyBufferExecCompleted(void); +u32 sub_8137A84(u8, u8 *); +void sub_8138294(u8); +void sub_81390D0(void); +void sub_8139A2C(u8); + +void unref_sub_8137220(void) +{ +} + +void SetBankFuncToWallyBufferRunCommand(void) +{ + gBattleBankFunc[gActiveBank] = WallyBufferRunCommand; + ewram[0x160A8] = 0; + ewram[0x160A9] = 0; + ewram[0x160AA] = 0; + ewram[0x160AB] = 0; +} + +void WallyBufferRunCommand(void) +{ + if (gBattleExecBuffer & gBitTable[gActiveBank]) + { + if (gBattleBufferA[gActiveBank][0] < 0x39) + gWallyBufferCommands[gBattleBufferA[gActiveBank][0]](); + else + WallyBufferExecCompleted(); + } +} + +void sub_81372BC(void) +{ + u8 r4; + + switch (ewram[0x160A8]) + { + case 0: + ewram[0x160AA] = 64; + ewram[0x160A8]++; + // fall through + case 1: + r4 = --ewram[0x160AA]; + if (r4 == 0) + { + PlaySE(SE_SELECT); + dp01_build_cmdbuf_x21_a_bb(1, 0, 0); + WallyBufferExecCompleted(); + ewram[0x160A8]++; + ewram[0x160A9] = r4; + ewram[0x160AA] = 64; + } + break; + case 2: + r4 = --ewram[0x160AA]; + if (r4 == 0) + { + PlaySE(SE_SELECT); + dp01_build_cmdbuf_x21_a_bb(1, 0, 0); + WallyBufferExecCompleted(); + ewram[0x160A8]++; + ewram[0x160A9] = r4; + ewram[0x160AA] = 64; + } + break; + case 3: + r4 = --ewram[0x160AA]; + if (r4 == 0) + { + dp01_build_cmdbuf_x21_a_bb(1, 9, 0); + WallyBufferExecCompleted(); + ewram[0x160A8]++; + ewram[0x160A9] = r4; + ewram[0x160AA] = 64; + } + break; + case 4: + if (--ewram[0x160AA] == 0) + { + PlaySE(SE_SELECT); + nullsub_8(0); + sub_802E3E4(1, 0); + ewram[0x160AA] = 64; + ewram[0x160A8]++; + } + break; + case 5: + if (--ewram[0x160AA] == 0) + { + PlaySE(SE_SELECT); + DestroyMenuCursor(); + dp01_build_cmdbuf_x21_a_bb(1, 1, 0); + WallyBufferExecCompleted(); + } + break; + } +} + +void sub_813741C(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].callback == SpriteCallbackDummy) + WallyBufferExecCompleted(); +} + +void sub_8137454(void) +{ + if (gUnknown_03004210.state == 0) + WallyBufferExecCompleted(); +} + +void sub_813746C(void) +{ + if (!gPaletteFade.active) + { + gMain.inBattle = FALSE; + gMain.callback1 = gPreBattleCallback1; + SetMainCallback2(gMain.savedCallback); + } +} + +void bx_wait_t5(void) +{ + if (!gDoingBattleAnim) + WallyBufferExecCompleted(); +} + +void sub_81374C4(void) +{ + if (!gPaletteFade.active) + { + gBattleBankFunc[gActiveBank] = sub_81374FC; + nullsub_14(); + PrepareBagForWallyTutorial(); + } +} + +void sub_81374FC(void) +{ + if (gMain.callback2 == sub_800F808 + && !gPaletteFade.active) + { + dp01_build_cmdbuf_x23_aa_0(1, gScriptItemId); + WallyBufferExecCompleted(); + } +} + +void sub_8137538(void) +{ + if (!ewram17810[gActiveBank].unk0_3 && !ewram17810[gActiveBank].unk0_7) + sub_8141828(gActiveBank, &gPlayerParty[gBattlePartyID[gActiveBank]]); + + if (!ewram17810[gActiveBank ^ 2].unk0_3 && !ewram17810[gActiveBank ^ 2].unk0_7) + sub_8141828(gActiveBank ^ 2, &gPlayerParty[gBattlePartyID[gActiveBank ^ 2]]); + + if (!ewram17810[gActiveBank].unk0_3 && !ewram17810[gActiveBank ^ 2].unk0_3) + { + if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) + { + DestroySprite(&gSprites[gUnknown_0300434C[gActiveBank ^ 2]]); + sub_8045A5C(gHealthboxIDs[gActiveBank ^ 2], &gPlayerParty[gBattlePartyID[gActiveBank ^ 2]], 0); + sub_804777C(gActiveBank ^ 2); + sub_8043DFC(gHealthboxIDs[gActiveBank ^ 2]); + } + DestroySprite(&gSprites[gUnknown_0300434C[gActiveBank]]); + sub_8045A5C(gHealthboxIDs[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], 0); + sub_804777C(gActiveBank); + sub_8043DFC(gHealthboxIDs[gActiveBank]); + ewram17840.unk9_0 = 0; + gBattleBankFunc[gActiveBank] = sub_81376B8; + } +} + +void sub_81376B8(void) +{ + bool8 r4 = FALSE; + + if (gSprites[gHealthboxIDs[gActiveBank]].callback == SpriteCallbackDummy) + r4 = TRUE; + if (r4 && ewram17810[gActiveBank].unk1_0 && ewram17810[gActiveBank ^ 2].unk1_0) + { + ewram17810[gActiveBank].unk0_7 = 0; + ewram17810[gActiveBank].unk1_0 = 0; + ewram17810[gActiveBank ^ 2].unk0_7 = 0; + ewram17810[gActiveBank ^ 2].unk1_0 = 0; + FreeSpriteTilesByTag(0x27F9); + FreeSpritePaletteByTag(0x27F9); + CreateTask(c3_0802FDF4, 10); + sub_80324F8(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + WallyBufferExecCompleted(); + } +} + +void sub_81377B0(void) +{ + s16 r4; + + r4 = sub_8045C78(gActiveBank, gHealthboxIDs[gActiveBank], 0, 0); + sub_8043DFC(gHealthboxIDs[gActiveBank]); + if (r4 != -1) + { + sub_80440EC(gHealthboxIDs[gActiveBank], r4, 0); + } + else + { + sub_80324F8(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + WallyBufferExecCompleted(); + } +} + +void bx_blink_t5(void) +{ + u8 spriteId = gObjectBankIDs[gActiveBank]; + + if (gSprites[spriteId].data1 == 32) + { + gSprites[spriteId].data1 = 0; + gSprites[spriteId].invisible = FALSE; + gDoingBattleAnim = FALSE; + WallyBufferExecCompleted(); + } + else + { + if (((u16)gSprites[spriteId].data1 % 4) == 0) + gSprites[spriteId].invisible ^= 1; + gSprites[spriteId].data1++; + } +} + +void sub_813789C(void) +{ + if (!ewram17810[gActiveBank].unk0_6) + { + FreeSpriteOamMatrix(&gSprites[gObjectBankIDs[gActiveBank]]); + DestroySprite(&gSprites[gObjectBankIDs[gActiveBank]]); + sub_8043DB0(gHealthboxIDs[gActiveBank]); + WallyBufferExecCompleted(); + } +} + +// Duplicate of sub_813741C +void sub_8137908(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].callback == SpriteCallbackDummy) + WallyBufferExecCompleted(); +} + +void sub_8137940(void) +{ + if (!ewram17810[gActiveBank].unk0_5) + WallyBufferExecCompleted(); +} + +void WallyBufferExecCompleted(void) +{ + gBattleBankFunc[gActiveBank] = WallyBufferRunCommand; + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + u8 multiplayerId = GetMultiplayerId(); + + dp01_prepare_buffer_wireless_probably(2, 4, &multiplayerId); + gBattleBufferA[gActiveBank][0] = 0x38; + } + else + { + gBattleExecBuffer &= ~gBitTable[gActiveBank]; + } +} + +void unref_sub_81379E4(void) +{ + if (!ewram17810[gActiveBank].unk0_4) + WallyBufferExecCompleted(); +} + +void dp01t_00_5_getattr(void) +{ + u8 arr[0x100]; + u32 r6 = 0; + u8 r4; + s32 i; + + if (gBattleBufferA[gActiveBank][2] == 0) + { + r6 = sub_8137A84(gBattlePartyID[gActiveBank], arr); + } + else + { + r4 = gBattleBufferA[gActiveBank][2]; + for (i = 0; i < 6; i++) + { + if (r4 & 1) + r6 += sub_8137A84(i, arr + r6); + r4 >>= 1; + } + } + dp01_build_cmdbuf_x1D_1D_numargs_varargs(1, r6, arr); + WallyBufferExecCompleted(); +} + +u32 sub_8137A84(u8 a, u8 *buffer) +{ + struct BattlePokemon battlePokemon; + struct UnknownStruct3 moveData; + u8 nickname[20]; + u8 *src; + s16 data16; + u32 data32; + s32 size = 0; + + switch (gBattleBufferA[gActiveBank][1]) + { + case 0: + battlePokemon.species = GetMonData(&gPlayerParty[a], MON_DATA_SPECIES); + battlePokemon.item = GetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM); + for (size = 0; size < 4; size++) + { + battlePokemon.moves[size] = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + size); + battlePokemon.pp[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); + } + battlePokemon.ppBonuses = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); + battlePokemon.friendship = GetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP); + battlePokemon.experience = GetMonData(&gPlayerParty[a], MON_DATA_EXP); + battlePokemon.hpIV = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); + battlePokemon.attackIV = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); + battlePokemon.defenseIV = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); + battlePokemon.speedIV = GetMonData(&gPlayerParty[a], MON_DATA_SPD_IV); + battlePokemon.spAttackIV = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); + battlePokemon.spDefenseIV = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); + battlePokemon.personality = GetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY); + battlePokemon.status1 = GetMonData(&gPlayerParty[a], MON_DATA_STATUS); + battlePokemon.level = GetMonData(&gPlayerParty[a], MON_DATA_LEVEL); + battlePokemon.hp = GetMonData(&gPlayerParty[a], MON_DATA_HP); + battlePokemon.maxHP = GetMonData(&gPlayerParty[a], MON_DATA_MAX_HP); + battlePokemon.attack = GetMonData(&gPlayerParty[a], MON_DATA_ATK); + battlePokemon.defense = GetMonData(&gPlayerParty[a], MON_DATA_DEF); + battlePokemon.speed = GetMonData(&gPlayerParty[a], MON_DATA_SPD); + battlePokemon.spAttack = GetMonData(&gPlayerParty[a], MON_DATA_SPATK); + battlePokemon.spDefense = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF); + battlePokemon.isEgg = GetMonData(&gPlayerParty[a], MON_DATA_IS_EGG); + battlePokemon.altAbility = GetMonData(&gPlayerParty[a], MON_DATA_ALT_ABILITY); + battlePokemon.otId = GetMonData(&gPlayerParty[a], MON_DATA_OT_ID); + GetMonData(&gPlayerParty[a], MON_DATA_NICKNAME, nickname); + StringCopy10(battlePokemon.nickname, nickname); + GetMonData(&gPlayerParty[a], MON_DATA_OT_NAME, battlePokemon.otName); + src = (u8 *)&battlePokemon; + for (size = 0; size < sizeof(battlePokemon); size++) + buffer[size] = src[size]; + break; + case 1: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPECIES); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 2: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 3: + for (size = 0; size < 4; size++) + { + moveData.moves[size] = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + size); + moveData.pp[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); + } + moveData.ppBonuses = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); + src = (u8 *)&moveData; + for (size = 0; size < sizeof(moveData); size++) + buffer[size] = src[size]; + break; + case 4: + case 5: + case 6: + case 7: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - 4); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 8: + for (size = 0; size < 4; size++) + buffer[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); + buffer[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); + size++; + break; + case 9: + case 10: + case 11: + case 12: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - 9); + size = 1; + break; + case 17: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_OT_ID); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + size = 3; + break; + case 18: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_EXP); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + size = 3; + break; + case 19: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_EV); + size = 1; + break; + case 20: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_EV); + size = 1; + break; + case 21: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_EV); + size = 1; + break; + case 22: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPD_EV); + size = 1; + break; + case 23: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_EV); + size = 1; + break; + case 24: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_EV); + size = 1; + break; + case 25: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP); + size = 1; + break; + case 26: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_POKERUS); + size = 1; + break; + case 27: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_LOCATION); + size = 1; + break; + case 28: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_LEVEL); + size = 1; + break; + case 29: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_GAME); + size = 1; + break; + case 30: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_POKEBALL); + size = 1; + break; + case 31: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); + buffer[1] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); + buffer[2] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); + buffer[3] = GetMonData(&gPlayerParty[a], MON_DATA_SPD_IV); + buffer[4] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); + buffer[5] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); + size = 6; + break; + case 32: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); + size = 1; + break; + case 33: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); + size = 1; + break; + case 34: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); + size = 1; + break; + case 35: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPD_IV); + size = 1; + break; + case 36: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); + size = 1; + break; + case 37: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); + size = 1; + break; + case 38: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + buffer[3] = (data32 & 0xFF000000) >> 24; + size = 4; + break; + case 39: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_CHECKSUM); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 40: + data32 = GetMonData(&gPlayerParty[a], MON_DATA_STATUS); + buffer[0] = (data32 & 0x000000FF); + buffer[1] = (data32 & 0x0000FF00) >> 8; + buffer[2] = (data32 & 0x00FF0000) >> 16; + buffer[3] = (data32 & 0xFF000000) >> 24; + size = 4; + break; + case 41: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_LEVEL); + size = 1; + break; + case 42: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_HP); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 43: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_MAX_HP); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 44: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_ATK); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 45: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_DEF); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 46: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPD); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 47: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPATK); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 48: + data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF); + buffer[0] = data16; + buffer[1] = data16 >> 8; + size = 2; + break; + case 49: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_COOL); + size = 1; + break; + case 50: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_BEAUTY); + size = 1; + break; + case 51: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_CUTE); + size = 1; + break; + case 52: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SMART); + size = 1; + break; + case 53: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_TOUGH); + size = 1; + break; + case 54: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SHEEN); + size = 1; + break; + case 55: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_COOL_RIBBON); + size = 1; + break; + case 56: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_BEAUTY_RIBBON); + size = 1; + break; + case 57: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_CUTE_RIBBON); + size = 1; + break; + case 58: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SMART_RIBBON); + size = 1; + break; + case 59: + buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_TOUGH_RIBBON); + size = 1; + break; + } + return size; +} + +void sub_8138230(void) +{ + sub_802ECF0(); +} + +void sub_813823C(void) +{ + u8 r4; + u8 i; + + if (gBattleBufferA[gActiveBank][2] == 0) + { + sub_8138294(gBattlePartyID[gActiveBank]); + } + else + { + r4 = gBattleBufferA[gActiveBank][2]; + for (i = 0; i < 6; i++) + { + if (r4 & 1) + sub_8138294(i); + r4 >>= 1; + } + } + WallyBufferExecCompleted(); +} + +void sub_8138294(u8 a) +{ + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; + struct UnknownStruct3 *moveData = (struct UnknownStruct3 *)&gBattleBufferA[gActiveBank][3]; + s32 i; + + switch (gBattleBufferA[gActiveBank][1]) + { + case 0: + { + u8 iv; + + SetMonData(&gPlayerParty[a], MON_DATA_SPECIES, (u8 *)&battlePokemon->species); + SetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM, (u8 *)&battlePokemon->item); + for (i = 0; i < 4; i++) + { + SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + i, (u8 *)&battlePokemon->moves[i]); + SetMonData(&gPlayerParty[a], MON_DATA_PP1 + i, (u8 *)&battlePokemon->pp[i]); + } + SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, (u8 *)&battlePokemon->ppBonuses); + SetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP, (u8 *)&battlePokemon->friendship); + SetMonData(&gPlayerParty[a], MON_DATA_EXP, (u8 *)&battlePokemon->experience); + iv = battlePokemon->hpIV; + SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, (u8 *)&iv); + iv = battlePokemon->attackIV; + SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, (u8 *)&iv); + iv = battlePokemon->defenseIV; + SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, (u8 *)&iv); + iv = battlePokemon->speedIV; + SetMonData(&gPlayerParty[a], MON_DATA_SPD_IV, (u8 *)&iv); + iv = battlePokemon->spAttackIV; + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, (u8 *)&iv); + iv = battlePokemon->spDefenseIV; + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, (u8 *)&iv); + SetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY, (u8 *)&battlePokemon->personality); + SetMonData(&gPlayerParty[a], MON_DATA_STATUS, (u8 *)&battlePokemon->status1); + SetMonData(&gPlayerParty[a], MON_DATA_LEVEL, (u8 *)&battlePokemon->level); + SetMonData(&gPlayerParty[a], MON_DATA_HP, (u8 *)&battlePokemon->hp); + SetMonData(&gPlayerParty[a], MON_DATA_MAX_HP, (u8 *)&battlePokemon->maxHP); + SetMonData(&gPlayerParty[a], MON_DATA_ATK, (u8 *)&battlePokemon->attack); + SetMonData(&gPlayerParty[a], MON_DATA_DEF, (u8 *)&battlePokemon->defense); + SetMonData(&gPlayerParty[a], MON_DATA_SPD, (u8 *)&battlePokemon->speed); + SetMonData(&gPlayerParty[a], MON_DATA_SPATK, (u8 *)&battlePokemon->spAttack); + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF, (u8 *)&battlePokemon->spDefense); + } + break; + case 1: + SetMonData(&gPlayerParty[a], MON_DATA_SPECIES, &gBattleBufferA[gActiveBank][3]); + break; + case 2: + SetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBank][3]); + break; + case 3: + for (i = 0; i < 4; i++) + { + SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + i, (u8 *)&moveData->moves[i]); + SetMonData(&gPlayerParty[a], MON_DATA_PP1 + i, (u8 *)&moveData->pp[i]); + } + SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, &moveData->ppBonuses); + break; + case 4: + case 5: + case 6: + case 7: + SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - 4, &gBattleBufferA[gActiveBank][3]); + break; + case 8: + SetMonData(&gPlayerParty[a], MON_DATA_PP1, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[a], MON_DATA_PP2, &gBattleBufferA[gActiveBank][4]); + SetMonData(&gPlayerParty[a], MON_DATA_PP3, &gBattleBufferA[gActiveBank][5]); + SetMonData(&gPlayerParty[a], MON_DATA_PP4, &gBattleBufferA[gActiveBank][6]); + SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBank][7]); + break; + case 9: + case 10: + case 11: + case 12: + SetMonData(&gPlayerParty[a], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - 9, &gBattleBufferA[gActiveBank][3]); + break; + case 17: + SetMonData(&gPlayerParty[a], MON_DATA_OT_ID, &gBattleBufferA[gActiveBank][3]); + break; + case 18: + SetMonData(&gPlayerParty[a], MON_DATA_EXP, &gBattleBufferA[gActiveBank][3]); + break; + case 19: + SetMonData(&gPlayerParty[a], MON_DATA_HP_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 20: + SetMonData(&gPlayerParty[a], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 21: + SetMonData(&gPlayerParty[a], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 22: + SetMonData(&gPlayerParty[a], MON_DATA_SPD_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 23: + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 24: + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBank][3]); + break; + case 25: + SetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBank][3]); + break; + case 26: + SetMonData(&gPlayerParty[a], MON_DATA_POKERUS, &gBattleBufferA[gActiveBank][3]); + break; + case 27: + SetMonData(&gPlayerParty[a], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBank][3]); + break; + case 28: + SetMonData(&gPlayerParty[a], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBank][3]); + break; + case 29: + SetMonData(&gPlayerParty[a], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBank][3]); + break; + case 30: + SetMonData(&gPlayerParty[a], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBank][3]); + break; + case 31: + SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][4]); + SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][5]); + SetMonData(&gPlayerParty[a], MON_DATA_SPD_IV, &gBattleBufferA[gActiveBank][6]); + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][7]); + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][8]); + break; + case 32: + SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 33: + SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 34: + SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 35: + SetMonData(&gPlayerParty[a], MON_DATA_SPD_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 36: + SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 37: + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][3]); + break; + case 38: + SetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBank][3]); + break; + case 39: + SetMonData(&gPlayerParty[a], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBank][3]); + break; + case 40: + SetMonData(&gPlayerParty[a], MON_DATA_STATUS, &gBattleBufferA[gActiveBank][3]); + break; + case 41: + SetMonData(&gPlayerParty[a], MON_DATA_LEVEL, &gBattleBufferA[gActiveBank][3]); + break; + case 42: + SetMonData(&gPlayerParty[a], MON_DATA_HP, &gBattleBufferA[gActiveBank][3]); + break; + case 43: + SetMonData(&gPlayerParty[a], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBank][3]); + break; + case 44: + SetMonData(&gPlayerParty[a], MON_DATA_ATK, &gBattleBufferA[gActiveBank][3]); + break; + case 45: + SetMonData(&gPlayerParty[a], MON_DATA_DEF, &gBattleBufferA[gActiveBank][3]); + break; + case 46: + SetMonData(&gPlayerParty[a], MON_DATA_SPD, &gBattleBufferA[gActiveBank][3]); + break; + case 47: + SetMonData(&gPlayerParty[a], MON_DATA_SPATK, &gBattleBufferA[gActiveBank][3]); + break; + case 48: + SetMonData(&gPlayerParty[a], MON_DATA_SPDEF, &gBattleBufferA[gActiveBank][3]); + break; + case 49: + SetMonData(&gPlayerParty[a], MON_DATA_COOL, &gBattleBufferA[gActiveBank][3]); + break; + case 50: + SetMonData(&gPlayerParty[a], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBank][3]); + break; + case 51: + SetMonData(&gPlayerParty[a], MON_DATA_CUTE, &gBattleBufferA[gActiveBank][3]); + break; + case 52: + SetMonData(&gPlayerParty[a], MON_DATA_SMART, &gBattleBufferA[gActiveBank][3]); + break; + case 53: + SetMonData(&gPlayerParty[a], MON_DATA_TOUGH, &gBattleBufferA[gActiveBank][3]); + break; + case 54: + SetMonData(&gPlayerParty[a], MON_DATA_SHEEN, &gBattleBufferA[gActiveBank][3]); + break; + case 55: + SetMonData(&gPlayerParty[a], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 56: + SetMonData(&gPlayerParty[a], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 57: + SetMonData(&gPlayerParty[a], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 58: + SetMonData(&gPlayerParty[a], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + case 59: + SetMonData(&gPlayerParty[a], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBank][3]); + break; + } + sub_80324F8(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); +} + +void sub_8138C90(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8138C9C(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8138CA8(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8138CB4(void) +{ + if (gBattleBufferA[gActiveBank][1] == 0) + { + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 1); + gBattleBankFunc[gActiveBank] = sub_813789C; + } + else + { + FreeSpriteOamMatrix(&gSprites[gObjectBankIDs[gActiveBank]]); + DestroySprite(&gSprites[gObjectBankIDs[gActiveBank]]); + sub_8043DB0(gHealthboxIDs[gActiveBank]); + WallyBufferExecCompleted(); + } +} + +void sub_8138D38(void) +{ + sub_8031AF4(2, gActiveBank); + GetMonSpriteTemplate_803C5A0(2, GetBankIdentity(gActiveBank)); + gObjectBankIDs[gActiveBank] = CreateSprite( + &gUnknown_02024E8C, + 80, 80 + 4 * (8 - gTrainerBackPicCoords[2].coords), + 30); + gSprites[gObjectBankIDs[gActiveBank]].oam.paletteNum = gActiveBank; + gSprites[gObjectBankIDs[gActiveBank]].pos2.x = 240; + gSprites[gObjectBankIDs[gActiveBank]].data0 = -2; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_80313A0; + gBattleBankFunc[gActiveBank] = sub_813741C; +} + +void sub_8138E04(void) +{ + sub_8031AF4(2, gActiveBank); + GetMonSpriteTemplate_803C5A0(2, GetBankIdentity(gActiveBank)); + gObjectBankIDs[gActiveBank] = CreateSprite( + &gUnknown_02024E8C, + 80, 80 + 4 * (8 - gTrainerBackPicCoords[2].coords), + 30); + gSprites[gObjectBankIDs[gActiveBank]].oam.paletteNum = gActiveBank; + gSprites[gObjectBankIDs[gActiveBank]].pos2.x = -96; + gSprites[gObjectBankIDs[gActiveBank]].data0 = 2; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_80313A0; + gBattleBankFunc[gActiveBank] = sub_8137908; +} + +void sub_8138ED0(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8138EDC(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8138EE8(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8138EF4(void) +{ + ewram17840.unk8 = 4; + gDoingBattleAnim = TRUE; + move_anim_start_t4(gActiveBank, gActiveBank, GetBankByPlayerAI(1), 4); + gBattleBankFunc[gActiveBank] = bx_wait_t5; +} + +void sub_8138F44(void) +{ + u8 val = gBattleBufferA[gActiveBank][1]; + + ewram17840.unk8 = val; + gDoingBattleAnim = TRUE; + move_anim_start_t4(gActiveBank, gActiveBank, GetBankByPlayerAI(1), 4); + gBattleBankFunc[gActiveBank] = bx_wait_t5; +} + +void sub_8138FA0(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8138FAC(void) +{ + u16 r0 = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + + gUnknown_0202F7C4 = gBattleBufferA[gActiveBank][3]; + gMovePowerMoveAnim = gBattleBufferA[gActiveBank][4] | (gBattleBufferA[gActiveBank][5] << 8); + gMoveDmgMoveAnim = gBattleBufferA[gActiveBank][6] | (gBattleBufferA[gActiveBank][7] << 8) | (gBattleBufferA[gActiveBank][8] << 16) | (gBattleBufferA[gActiveBank][9] << 24); + gHappinessMoveAnim = gBattleBufferA[gActiveBank][10]; + gWeatherMoveAnim = gBattleBufferA[gActiveBank][12] | (gBattleBufferA[gActiveBank][13] << 8); + gDisableStructMoveAnim = (u32 *)&gBattleBufferA[gActiveBank][16]; + gPID_perBank[gActiveBank] = *gDisableStructMoveAnim; + if (sub_8031720(r0, gUnknown_0202F7C4) != 0) + { + // Dead code. sub_8031720 always returns 0. + WallyBufferExecCompleted(); + } + else + { + ewram17810[gActiveBank].unk4 = 0; + gBattleBankFunc[gActiveBank] = sub_81390D0; + } +} + +void sub_81390D0(void) +{ + u16 r4 = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + +#ifndef NONMATCHING + asm("":::"r6"); +#endif + + switch (ewram17810[gActiveBank].unk4) + { + case 0: + if (ewram17800[gActiveBank].unk0_2 == 1) + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 5); + ewram17810[gActiveBank].unk4 = 1; + break; + case 1: + if (ewram17810[gActiveBank].unk0_6 == 0) + { + sub_80326EC(0); + ExecuteMoveAnim(r4); + ewram17810[gActiveBank].unk4 = 2; + } + break; + case 2: + gAnimScriptCallback(); + if (!gAnimScriptActive) + { + sub_80326EC(1); + if (ewram17800[gActiveBank].unk0_2 == 1) + move_anim_start_t4(gActiveBank, gActiveBank, gActiveBank, 6); + ewram17810[gActiveBank].unk4 = 3; + } + break; + case 3: + if (ewram17810[gActiveBank].unk0_6 == 0) + { + sub_8031F24(); + sub_80324BC(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + ewram17810[gActiveBank].unk4 = 0; + WallyBufferExecCompleted(); + } + break; + } +} + +void sub_8139208(void) +{ + u16 *ptr; + + gUnknown_030042A4 = 0; + gUnknown_030042A0 = 0; + ptr = (u16 *)&gBattleBufferA[gActiveBank][2]; + if (*ptr == 2) + DestroyMenuCursor(); + BufferStringBattle(*ptr); + sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 0x90, 2, 15); + gBattleBankFunc[gActiveBank] = sub_8137454; +} + +void dp01t_11_5_message_for_player_only(void) +{ + if (GetBankSide(gActiveBank) == 0) + sub_8139208(); + else + WallyBufferExecCompleted(); +} + +void sub_8139298(void) +{ + s32 i; + + gUnknown_030042A4 = 0; + gUnknown_030042A0 = 160; + gUnknown_03004210.paletteNum = 0; + FillWindowRect_DefaultPalette(&gUnknown_03004210, 10, 2, 15, 27, 18); + FillWindowRect_DefaultPalette(&gUnknown_03004210, 10, 2, 35, 16, 36); + gBattleBankFunc[gActiveBank] = sub_81372BC; + InitWindow(&gUnknown_03004210, gUnknown_08400CF3, 400, 18, 35); + sub_8002F44(&gUnknown_03004210); + sub_814A5C0(0, 0xFFFF, 12, 0x2D9F, 0); + for (i = 0; i < 4; i++) + nullsub_8(i); + sub_802E3E4(0, 0); + StrCpyDecodeToDisplayedStringBattle(gUnknown_08400CCC); +#ifdef ENGLISH + InitWindow(&gUnknown_03004210, gDisplayedStringBattle, 440, 2, 35); +#else + InitWindow(&gUnknown_03004210, gDisplayedStringBattle, 444, 2, 35); +#endif + sub_8002F44(&gUnknown_03004210); +} + +void sub_8139378(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139384(void) +{ + switch (ewram[0x160A9]) + { + case 0: + sub_80304A8(); + ewram[0x160A9]++; + ewram[0x160AB] = 80; + // fall through + case 1: + ewram[0x160AB]--; + if (ewram[0x160AB] == 0) + { + DestroyMenuCursor(); + PlaySE(SE_SELECT); + dp01_build_cmdbuf_x21_a_bb(1, 10, 256); + WallyBufferExecCompleted(); + } + break; + } +} + +void sub_81393EC(void) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gBattleBankFunc[gActiveBank] = sub_81374C4; + gBankInMenu = gActiveBank; +} + +void sub_813942C(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139438(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139444(void) +{ + s16 r7; + + load_gfxc_health_bar(0); + r7 = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + if (r7 != 0x7FFF) + { + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + + sub_8043D84(gActiveBank, gHealthboxIDs[gActiveBank], maxHP, curHP, r7); + } + else + { + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + + sub_8043D84(gActiveBank, gHealthboxIDs[gActiveBank], maxHP, 0, r7); + sub_80440EC(gHealthboxIDs[gActiveBank], 0, 0); + } + gBattleBankFunc[gActiveBank] = sub_81377B0; +} + +void sub_8139544(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139550(void) +{ + WallyBufferExecCompleted(); +} + +void sub_813955C(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139568(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139574(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139580(void) +{ + WallyBufferExecCompleted(); +} + +void sub_813958C(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139598(void) +{ + WallyBufferExecCompleted(); +} + +void sub_81395A4(void) +{ + WallyBufferExecCompleted(); +} + +void sub_81395B0(void) +{ + WallyBufferExecCompleted(); +} + +void sub_81395BC(void) +{ + WallyBufferExecCompleted(); +} + +void sub_81395C8(void) +{ + WallyBufferExecCompleted(); +} + +void sub_81395D4(void) +{ + WallyBufferExecCompleted(); +} + +void sub_81395E0(void) +{ + WallyBufferExecCompleted(); +} + +void sub_81395EC(void) +{ + WallyBufferExecCompleted(); +} + +void sub_81395F8(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139604(void) +{ + if (gSprites[gObjectBankIDs[gActiveBank]].invisible == TRUE) + { + WallyBufferExecCompleted(); + } + else + { + gDoingBattleAnim = 1; + gSprites[gObjectBankIDs[gActiveBank]].data1 = 0; + sub_8047858(gActiveBank); + gBattleBankFunc[gActiveBank] = bx_blink_t5; + } +} + +void sub_8139674(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139680(void) +{ + PlaySE(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + WallyBufferExecCompleted(); +} + +void sub_81396B0(void) +{ + PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + WallyBufferExecCompleted(); +} + +void sub_81396E0(void) +{ + PlayCry1(GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES), 25); + WallyBufferExecCompleted(); +} + +void dp01t_2E_5_battle_intro(void) +{ + sub_80E43C0(gBattleBufferA[gActiveBank][1]); + gUnknown_02024DE8 |= 1; + WallyBufferExecCompleted(); +} + +void sub_8139750(void) +{ + u8 paletteNum; + u8 taskId; + + oamt_add_pos2_onto_pos1(&gSprites[gObjectBankIDs[gActiveBank]]); + gSprites[gObjectBankIDs[gActiveBank]].data0 = 50; + gSprites[gObjectBankIDs[gActiveBank]].data2 = -40; + gSprites[gObjectBankIDs[gActiveBank]].data4 = gSprites[gObjectBankIDs[gActiveBank]].pos1.y; + gSprites[gObjectBankIDs[gActiveBank]].callback = sub_8078B34; + gSprites[gObjectBankIDs[gActiveBank]].data5 = gActiveBank; + oamt_set_x3A_32(&gSprites[gObjectBankIDs[gActiveBank]], sub_8030E38); + StartSpriteAnim(&gSprites[gObjectBankIDs[gActiveBank]], 1); + paletteNum = AllocSpritePalette(0xD6F8); + LoadCompressedPalette(gTrainerBackPicPaletteTable[2].data, 0x100 + paletteNum * 16, 32); + gSprites[gObjectBankIDs[gActiveBank]].oam.paletteNum = paletteNum; + taskId = CreateTask(sub_8139A2C, 5); + gTasks[taskId].data[0] = gActiveBank; + if (ewram17810[gActiveBank].unk0_0) + gTasks[gUnknown_02024E68[gActiveBank]].func = sub_8044CA0; + ewram17810[4].unk9 |= 1; + gBattleBankFunc[gActiveBank] = nullsub_91; +} + +void sub_81398BC(u8 bank) +{ + u16 species; + + ewram17800[bank].unk2 = 0; + gBattlePartyID[bank] = gBattleBufferA[bank][1]; + species = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); + gUnknown_0300434C[bank] = CreateInvisibleSpriteWithCallback(sub_80312F0); + GetMonSpriteTemplate_803C56C(species, GetBankIdentity(bank)); + gObjectBankIDs[bank] = CreateSprite( + &gUnknown_02024E8C, + sub_8077ABC(bank, 2), + sub_8077F68(bank), + sub_8079E90(bank)); + gSprites[gUnknown_0300434C[bank]].data1 = gObjectBankIDs[bank]; + gSprites[gObjectBankIDs[bank]].data0 = bank; + gSprites[gObjectBankIDs[bank]].data2 = species; + gSprites[gObjectBankIDs[bank]].oam.paletteNum = bank; + StartSpriteAnim(&gSprites[gObjectBankIDs[bank]], gBattleMonForms[bank]); + gSprites[gObjectBankIDs[bank]].invisible = TRUE; + gSprites[gObjectBankIDs[bank]].callback = SpriteCallbackDummy; + gSprites[gUnknown_0300434C[bank]].data0 = sub_8046400(0, 0xFF); +} + +void sub_8139A2C(u8 taskId) +{ + if (gTasks[taskId].data[1] < 31) + { + gTasks[taskId].data[1]++; + } + else + { + u8 savedActiveBank = gActiveBank; + + gActiveBank = gTasks[taskId].data[0]; + gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; + sub_81398BC(gActiveBank); + gBattleBankFunc[gActiveBank] = sub_8137538; + gActiveBank = savedActiveBank; + DestroyTask(taskId); + } +} + +void sub_8139AA0(void) +{ + if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == 0) + { + WallyBufferExecCompleted(); + } + else + { + ewram17810[gActiveBank].unk0_0 = 1; + gUnknown_02024E68[gActiveBank] = sub_8044804(gActiveBank, (struct BattleInterfaceStruct2 *)&gBattleBufferA[gActiveBank][4], gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2]); + WallyBufferExecCompleted(); + } +} + +void sub_8139B20(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139B2C(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139B38(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139B44(void) +{ + u8 val2 = gBattleBufferA[gActiveBank][1]; + u16 val = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + + if (move_anim_start_t3(gActiveBank, gActiveBank, gActiveBank, val2, val)) + WallyBufferExecCompleted(); + else + gBattleBankFunc[gActiveBank] = sub_8137940; +} + +void sub_8139BA0(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139BAC(void) +{ + WallyBufferExecCompleted(); +} + +void sub_8139BB8(void) +{ + gBattleOutcome = gBattleBufferA[gActiveBank][1]; + FadeOutMapMusic(5); + BeginFastPaletteFade(3); + WallyBufferExecCompleted(); + if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_WILD)) + gBattleBankFunc[gActiveBank] = sub_813746C; +} + +void nullsub_80(void) +{ +} diff --git a/src/battle_interface.c b/src/battle_interface.c new file mode 100644 index 000000000..246bda62b --- /dev/null +++ b/src/battle_interface.c @@ -0,0 +1,3049 @@ +#include "global.h" +#include "battle.h" +#include "battle_interface.h" +#include "decompress.h" +#include "palette.h" +#include "pokedex.h" +#include "pokemon.h" +#include "rom_8077ABC.h" +#include "safari_zone.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "string_util.h" +#include "task.h" +#include "text.h" + +struct UnknownStruct5 +{ + u8 unk0; + u32 unk4; + u32 unk8; + u32 unkC; + u32 unk10; +}; + +struct UnknownStruct7 +{ + u8 filler0[0x180]; +}; + +extern u8 ewram[]; +#define ewram520 ((struct UnknownStruct7 *)(ewram + 0x00520)) +#define ewram16088 (*(u8 *) (ewram + 0x16088)) +#define ewram16089 (*(u8 *) (ewram + 0x16089)) +#define ewram17850 ((struct UnknownStruct5 *)(ewram + 0x17850)) + +extern u8 gDisplayedStringBattle[]; +extern u8 gNoOfAllBanks; +extern u16 gBattlePartyID[]; +extern u8 gBanksBySide[]; +extern u8 gHealthboxIDs[]; + +extern u16 gBattleTypeFlags; + +extern const struct SpriteTemplate gSpriteTemplate_820A4EC[]; +extern const struct SpriteTemplate gSpriteTemplate_820A51C[]; +extern const struct SpriteTemplate gSpriteTemplate_820A54C; +extern const struct SpriteTemplate gSpriteTemplate_820A56C[]; +extern const struct SubspriteTable gSubspriteTables_820A684[]; +extern const struct SubspriteTable gSubspriteTables_820A6E4[]; +extern const struct SubspriteTable gSubspriteTables_820A6EC[]; +extern const struct SpriteSheet gUnknown_0820A754[]; +extern const struct SpritePalette gUnknown_0820A764[]; +extern const struct SpritePalette gUnknown_0820A774[]; +extern const struct SpriteSheet gUnknown_0820A784[]; +extern const struct SpriteTemplate gSpriteTemplate_820A7A4[]; +extern const struct SpriteTemplate gSpriteTemplate_820A7D4[]; +extern void *const gUnknown_0820A804[]; +extern void *const gUnknown_0820A80C[]; +extern void *const gUnknown_0820A814[]; +extern void *const gUnknown_0820A83C[]; +extern void *const gUnknown_0820A848[]; +extern void *const gUnknown_0820A854[]; +extern void *const gUnknown_0820A85C[]; +extern void *const gUnknown_0820A87C[]; +extern void *const gUnknown_0820A894[]; +extern void *const gUnknown_0820A8B4[]; +extern void *const gUnknown_0820A8DC[]; +extern void *const gUnknown_0820A904[]; +extern const u8 gUnknown_0820A81C[]; +extern const u8 gUnknown_0820A864[]; +extern const u8 gUnknown_0820A89C[]; +extern const u8 gUnknown_0820A8B0[]; +extern const u8 BattleText_SafariBalls[]; +extern const u8 BattleText_SafariBallsLeft[]; +extern const u8 BattleText_HighlightRed[]; +extern const u8 gUnknown_08D1216C[][32]; + +extern const u16 gBattleInterfaceStatusIcons_DynPal[]; + +#define ABS(n) ((n) >= 0 ? (n) : -(n)) +// Used for computing copy destination addresses +#define MACRO1(n) ((n) - (n) / 8 * 8) + 64 * ((n) / 8) + +static void sub_8043D5C(struct Sprite *); +static const void *sub_8043CDC(u8); +static void sub_8044210(u8, s16, u8); +static void draw_status_ailment_maybe(u8); +extern void sub_8045180(struct Sprite *); +static void sub_8045110(struct Sprite *); +static void sub_8045048(struct Sprite *); +static void sub_8044F70(u8 taskId); +static void sub_8044E74(u8 taskId); +static void sub_8044ECC(u8 taskId); +static u8 sub_80457E8(u8, u8); +static int sub_8045F58(s32, s32, int, int *, u8, u16); +static u8 GetScaledExpFraction(int, int, int, u8); +static void sub_8045D58(u8, u8); +static u8 sub_804602C(int, int, int, int *, u8 *, u8); +static void sub_8046128(struct BattleInterfaceStruct1 *a, int *b, void *c); + +static int do_nothing(s16 unused1, s16 unused2, int unused3) +{ + return 9; +} + +#ifdef NONMATCHING +void sub_8043740(s16 a, u16 *b, u8 c) +{ + u8 sp0[4]; + s8 i; + s8 j; + s32 r9; + + for (i = 0; i < 4; i++) + sp0[i] = 0; + + //_0804377C + //i = 3; + //r9 = -1; + for (i = 3, r9 = -1;;) + { + if (a > 0) + { + sp0[i] = a % 10; + a /= 10; + i--; + } + else + break; + asm(""::"r"(r9)); + } + + //_080437AA + for (; i > r9; i--) + { + //asm("":"=r"(r9)); + sp0[i] = -1; + } + //_080437CE + if (sp0[3] == 0xFF) + sp0[3] = 0; + + //_080437DA + if (c == 0) + { + for (i = 0, j = 0; i < 4; i++) + { + if (sp0[j] == 0xFF) + { + b[j] = (b[j] & 0xFC00) | 0x1E; + b[i + 0x20] = (b[i + 0x20] & 0xFC00) | 0x1E; + } + else + { + b[j] = (b[j] & 0xFC00) | (sp0[j] + 0x14); + b[i + 0x20] = (b[i + 0x20] & 0xFC00) | (sp0[i] + 0x34); + } + j++; + } + + } + //_0804386A + else + { + for (i = 0; i < 4; i++) + { + if (sp0[i] == 0xFF) + { + b[i] = (b[i] & 0xFC00) | 0x1E; + b[i + 0x20] = (b[i + 0x20] & 0xFC00) | 0x1E; + } + else + { + b[i] = (b[i] & 0xFC00) | (sp0[i] + 0x14); + b[i + 0x20] = (b[i + 0x20] & 0xFC00) | (sp0[i] + 0x34); + } + } + } + asm(""::"r"(r9)); +} +#else +__attribute__((naked)) +void sub_8043740(s16 a, u16 *b, u8 c) +{ + 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, 0x4\n\ + adds r7, r1, 0\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + mov r10, r2\n\ + movs r3, 0\n\ + movs r2, 0\n\ +_0804375C:\n\ + lsls r0, r3, 24\n\ + asrs r0, 24\n\ + mov r3, sp\n\ + adds r1, r3, r0\n\ + strb r2, [r1]\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0x3\n\ + ble _0804375C\n\ + movs r3, 0x3\n\ + movs r0, 0x1\n\ + negs r0, r0\n\ + mov r9, r0\n\ + mov r8, sp\n\ +_0804377C:\n\ + lsls r0, r5, 16\n\ + asrs r6, r0, 16\n\ + cmp r6, 0\n\ + ble _080437AA\n\ + lsls r4, r3, 24\n\ + asrs r4, 24\n\ + mov r1, sp\n\ + adds r5, r1, r4\n\ + adds r0, r6, 0\n\ + movs r1, 0xA\n\ + bl __modsi3\n\ + strb r0, [r5]\n\ + adds r0, r6, 0\n\ + movs r1, 0xA\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + subs r4, 0x1\n\ + lsls r4, 24\n\ + lsrs r3, r4, 24\n\ + b _0804377C\n\ +_080437AA:\n\ + lsls r1, r3, 24\n\ + asrs r0, r1, 24\n\ + cmp r0, r9\n\ + ble _080437CE\n\ + movs r4, 0xFF\n\ + movs r3, 0x1\n\ + negs r3, r3\n\ +_080437B8:\n\ + asrs r2, r1, 24\n\ + mov r5, sp\n\ + adds r1, r5, r2\n\ + ldrb r0, [r1]\n\ + orrs r0, r4\n\ + strb r0, [r1]\n\ + subs r2, 0x1\n\ + lsls r1, r2, 24\n\ + asrs r0, r1, 24\n\ + cmp r0, r3\n\ + bgt _080437B8\n\ +_080437CE:\n\ + mov r1, r8\n\ + ldrb r0, [r1, 0x3]\n\ + cmp r0, 0xFF\n\ + bne _080437DA\n\ + movs r0, 0\n\ + strb r0, [r1, 0x3]\n\ +_080437DA:\n\ + mov r2, r10\n\ + cmp r2, 0\n\ + bne _0804386A\n\ + movs r3, 0\n\ + movs r1, 0\n\ + movs r6, 0xFC\n\ + lsls r6, 8\n\ + movs r5, 0x1E\n\ + mov r12, r5\n\ +_080437EC:\n\ + lsls r1, 24\n\ + asrs r2, r1, 24\n\ + mov r0, sp\n\ + adds r5, r0, r2\n\ + ldrb r0, [r5]\n\ + mov r8, r1\n\ + cmp r0, 0xFF\n\ + bne _08043822\n\ + lsls r1, r2, 1\n\ + adds r1, r7\n\ + ldrh r2, [r1]\n\ + adds r0, r6, 0\n\ + ands r0, r2\n\ + mov r2, r12\n\ + orrs r0, r2\n\ + strh r0, [r1]\n\ + lsls r3, 24\n\ + asrs r1, r3, 23\n\ + adds r1, r7\n\ + adds r1, 0x40\n\ + ldrh r2, [r1]\n\ + adds r0, r6, 0\n\ + ands r0, r2\n\ + mov r5, r12\n\ + orrs r0, r5\n\ + strh r0, [r1]\n\ + b _08043852\n\ +_08043822:\n\ + lsls r2, 1\n\ + adds r2, r7\n\ + ldrh r0, [r2]\n\ + adds r1, r6, 0\n\ + ands r1, r0\n\ + ldrb r0, [r5]\n\ + adds r0, 0x14\n\ + orrs r1, r0\n\ + strh r1, [r2]\n\ + lsls r4, r3, 24\n\ + asrs r3, r4, 24\n\ + lsls r2, r3, 1\n\ + adds r2, r7\n\ + adds r2, 0x40\n\ + ldrh r0, [r2]\n\ + adds r1, r6, 0\n\ + ands r1, r0\n\ + mov r5, sp\n\ + adds r0, r5, r3\n\ + ldrb r0, [r0]\n\ + adds r0, 0x34\n\ + orrs r1, r0\n\ + strh r1, [r2]\n\ + adds r3, r4, 0\n\ +_08043852:\n\ + movs r0, 0x80\n\ + lsls r0, 17\n\ + add r0, r8\n\ + lsrs r1, r0, 24\n\ + movs r2, 0x80\n\ + lsls r2, 17\n\ + adds r0, r3, r2\n\ + lsrs r3, r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0x3\n\ + ble _080437EC\n\ + b _080438CE\n\ +_0804386A:\n\ + movs r3, 0\n\ + movs r4, 0xFC\n\ + lsls r4, 8\n\ + movs r6, 0x1E\n\ +_08043872:\n\ + lsls r1, r3, 24\n\ + asrs r2, r1, 24\n\ + mov r3, sp\n\ + adds r5, r3, r2\n\ + ldrb r0, [r5]\n\ + adds r3, r1, 0\n\ + cmp r0, 0xFF\n\ + bne _0804389E\n\ + lsls r1, r2, 1\n\ + adds r1, r7\n\ + ldrh r2, [r1]\n\ + adds r0, r4, 0\n\ + ands r0, r2\n\ + orrs r0, r6\n\ + strh r0, [r1]\n\ + adds r1, 0x40\n\ + ldrh r2, [r1]\n\ + adds r0, r4, 0\n\ + ands r0, r2\n\ + orrs r0, r6\n\ + strh r0, [r1]\n\ + b _080438C0\n\ +_0804389E:\n\ + lsls r2, 1\n\ + adds r2, r7\n\ + ldrh r0, [r2]\n\ + adds r1, r4, 0\n\ + ands r1, r0\n\ + ldrb r0, [r5]\n\ + adds r0, 0x14\n\ + orrs r1, r0\n\ + strh r1, [r2]\n\ + adds r2, 0x40\n\ + ldrh r0, [r2]\n\ + adds r1, r4, 0\n\ + ands r1, r0\n\ + ldrb r0, [r5]\n\ + adds r0, 0x34\n\ + orrs r1, r0\n\ + strh r1, [r2]\n\ +_080438C0:\n\ + movs r5, 0x80\n\ + lsls r5, 17\n\ + adds r0, r3, r5\n\ + lsrs r3, r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0x3\n\ + ble _08043872\n\ +_080438CE:\n\ + add sp, 0x4\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\ + .syntax divided\n"); +} +#endif + +void unref_sub_80438E0(s16 a, s16 b, u16 *c) +{ + c[4] = 0x1E; + sub_8043740(b, c, 0); + sub_8043740(a, c + 5, 1); +} + +u8 battle_make_oam_normal_battle(u8 a) +{ + int sp0 = 0; + u8 spriteId1; + u8 spriteId2; + u8 spriteId3; + struct Sprite *sprite; + + if (!IsDoubleBattle()) + { + if (GetBankSide(a) == 0) + { + spriteId1 = CreateSprite(&gSpriteTemplate_820A4EC[0], 240, 160, 1); + spriteId2 = CreateSpriteAtEnd(&gSpriteTemplate_820A4EC[0], 240, 160, 1); + + gSprites[spriteId1].oam.shape = 0; + gSprites[spriteId2].oam.shape = 0; + gSprites[spriteId2].oam.tileNum += 64; + } + else + { + spriteId1 = CreateSprite(&gSpriteTemplate_820A51C[0], 240, 160, 1); + spriteId2 = CreateSpriteAtEnd(&gSpriteTemplate_820A51C[0], 240, 160, 1); + + gSprites[spriteId2].oam.tileNum += 32; + sp0 = 2; + } + //_080439F2 + + gSprites[spriteId1].oam.affineParam = spriteId2; + gSprites[spriteId2].data5 = spriteId1; + gSprites[spriteId2].callback = sub_8043D5C; + } + //_08043A28 + else + { + if (GetBankSide(a) == 0) + { + spriteId1 = CreateSprite(&gSpriteTemplate_820A4EC[GetBankIdentity(a) / 2], 240, 160, 1); + spriteId2 = CreateSpriteAtEnd(&gSpriteTemplate_820A4EC[GetBankIdentity(a) / 2], 240, 160, 1); + + gSprites[spriteId1].oam.affineParam = spriteId2; + gSprites[spriteId2].data5 = spriteId1; + gSprites[spriteId2].oam.tileNum += 32; + gSprites[spriteId2].callback = sub_8043D5C; + sp0 = 1; + } + //_08043ACC + else + { + spriteId1 = CreateSprite(&gSpriteTemplate_820A51C[GetBankIdentity(a) / 2], 240, 160, 1); + spriteId2 = CreateSpriteAtEnd(&gSpriteTemplate_820A51C[GetBankIdentity(a) / 2], 240, 160, 1); + + gSprites[spriteId1].oam.affineParam = spriteId2; + gSprites[spriteId2].data5 = spriteId1; + gSprites[spriteId2].oam.tileNum += 32; + gSprites[spriteId2].callback = sub_8043D5C; + sp0 = 2; + } + //_08043B4E + } + //_08043B50 + + spriteId3 = CreateSpriteAtEnd(&gSpriteTemplate_820A56C[gBanksBySide[a]], 140, 60, 0); + sprite = &gSprites[spriteId3]; + SetSubspriteTables(sprite, &gSubspriteTables_820A684[GetBankSide(a)]); + sprite->subspriteMode = 2; + sprite->oam.priority = 1; + CpuCopy32(sub_8043CDC(1), (void *)(OBJ_VRAM0 + sprite->oam.tileNum * 32), 64); + + gSprites[spriteId1].data5 = spriteId3; + gSprites[spriteId1].data6 = a; + gSprites[spriteId1].invisible = TRUE; + gSprites[spriteId2].invisible = TRUE; + sprite->data5 = spriteId1; + sprite->data6 = sp0; + sprite->invisible = TRUE; + + return spriteId1; +} + +u8 battle_make_oam_safari_battle(void) +{ + u8 spriteId1 = CreateSprite(&gSpriteTemplate_820A54C, 240, 160, 1); + u8 spriteId2 = CreateSpriteAtEnd(&gSpriteTemplate_820A54C, 240, 160, 1); + + gSprites[spriteId1].oam.shape = 0; + gSprites[spriteId2].oam.shape = 0; + gSprites[spriteId2].oam.tileNum += 0x40; + gSprites[spriteId1].oam.affineParam = spriteId2; + gSprites[spriteId2].data5 = spriteId1; + gSprites[spriteId2].callback = sub_8043D5C; + return spriteId1; +} + +static const void *sub_8043CDC(u8 a) +{ + return gUnknown_08D1216C[a]; +} + +void sub_8043CEC(struct Sprite *sprite) +{ + u8 r5 = sprite->data5; + + switch (sprite->data6) + { + case 0: + sprite->pos1.x = gSprites[r5].pos1.x + 16; + sprite->pos1.y = gSprites[r5].pos1.y; + break; + case 1: + sprite->pos1.x = gSprites[r5].pos1.x + 16; + sprite->pos1.y = gSprites[r5].pos1.y; + break; + default: + case 2: + sprite->pos1.x = gSprites[r5].pos1.x + 8; + sprite->pos1.y = gSprites[r5].pos1.y; + break; + } + sprite->pos2.x = gSprites[r5].pos2.x; + sprite->pos2.y = gSprites[r5].pos2.y; +} + +static void sub_8043D5C(struct Sprite *sprite) +{ + u8 data5 = sprite->data5; + + sprite->pos1.x = gSprites[data5].pos1.x + 64; + sprite->pos1.y = gSprites[data5].pos1.y; + sprite->pos2.x = gSprites[data5].pos2.x; + sprite->pos2.y = gSprites[data5].pos2.y; +} + +void sub_8043D84(u8 a, u8 b, u32 c, u32 d, u32 e) +{ + ewram17850[a].unk0 = b; + ewram17850[a].unk4 = c; + ewram17850[a].unk8 = d; + ewram17850[a].unkC = e; + ewram17850[a].unk10 = 0xFFFF8000; +} + +void sub_8043DB0(u8 a) +{ + gSprites[a].invisible = TRUE; + gSprites[gSprites[a].data5].invisible = TRUE; + gSprites[gSprites[a].oam.affineParam].invisible = TRUE; +} + +void sub_8043DFC(u8 a) +{ + gSprites[a].invisible = FALSE; + gSprites[gSprites[a].data5].invisible = FALSE; + gSprites[gSprites[a].oam.affineParam].invisible = FALSE; +} + +static void sub_8043E50(u8 spriteId, s16 x, s16 y) +{ + gSprites[spriteId].pos1.x = x; + gSprites[spriteId].pos1.y = y; +} + +void unref_sub_8043E70(u8 a) +{ + DestroySprite(&gSprites[gSprites[a].oam.affineParam]); + DestroySprite(&gSprites[gSprites[a].data5]); + DestroySprite(&gSprites[a]); +} + +void nullsub_11() +{ +} + +void sub_8043EB4(u8 priority) +{ + s32 i; + + for (i = 0; i < gNoOfAllBanks; i++) + { + u8 spriteId1; + u8 spriteId2; + u8 spriteId3; + + spriteId1 = gHealthboxIDs[i]; + spriteId2 = gSprites[spriteId1].oam.affineParam; + spriteId3 = gSprites[spriteId1].data5; + gSprites[spriteId1].oam.priority = priority; + gSprites[spriteId2].oam.priority = priority; + gSprites[spriteId3].oam.priority = priority; + } +} + +void sub_8043F44(u8 a) +{ + s16 x = 0; + s16 y = 0; + + if (!IsDoubleBattle()) + { + if (GetBankSide(a) != 0) + { + x = 44; + y = 30; + } + else + { + x = 158; + y = 88; + } + } + else + { + switch (GetBankIdentity(a)) + { + case 0: + x = 159; + y = 77; + break; + case 2: + x = 171; + y = 102; + break; + case 1: + x = 44; + y = 19; + break; + case 3: + x = 32; + y = 44; + break; + } + } + sub_8043E50(gHealthboxIDs[a], x, y); +} + +#if ENGLISH +#define CHAR_LV_SEPARATOR CHAR_COLON +#elif GERMAN +#define CHAR_LV_SEPARATOR CHAR_PERIOD +#endif + +static void sub_8043FC0(u8 a, u8 b) +{ + u8 str[30]; + void *const *r7; + u8 *ptr; + s32 i; + s32 two; + + // TODO: Make this a local variable + memcpy(str, gUnknown_0820A81C, sizeof(str)); + if (!IsDoubleBattle()) + { + if (GetBankSide(gSprites[a].data6) == 0) + r7 = gUnknown_0820A804; + else + r7 = gUnknown_0820A80C; + } + else + { + if (GetBankSide(gSprites[a].data6) == 0) + r7 = gUnknown_0820A814; + else + r7 = gUnknown_0820A80C; + } + + ptr = str + 6; + if (b == 100) + { + ptr = ConvertIntToDecimalStringN(ptr, 100, 0, 3); + } + else + { + *(ptr++) = EXT_CTRL_CODE_BEGIN; + *(ptr++) = 0x11; + *(ptr++) = 1; + *(ptr++) = EXT_CTRL_CODE_BEGIN; + *(ptr++) = 0x14; + *(ptr++) = 4; + *(ptr++) = CHAR_LV_SEPARATOR; + *(ptr++) = EXT_CTRL_CODE_BEGIN; + *(ptr++) = 0x14; + *(ptr++) = 0; + ptr = ConvertIntToDecimalStringN(ptr, b, 0, 2); + } + + *(ptr++) = EXT_CTRL_CODE_BEGIN; + *(ptr++) = 0x13; + *(ptr++) = 0xF; + *(ptr++) = EOS; + sub_80034D4((u8 *)0x02000000, str); + + two = 2; + for (i = 0; i < two; i++) + CpuCopy32((void *)(0x02000020 + i * 64), r7[i] + gSprites[a].oam.tileNum * 32, 32); +} + +#ifdef NONMATCHING +void sub_80440EC(u8 a, s16 b, u8 c) +{ + u8 str[0x14]; + u8 *ptr; + s32 foo; + void *const *r4; + s32 i; + + // TODO: make this a local variable + memcpy(str, gUnknown_0820A864, sizeof(str)); + foo = gSprites[a].data6; + + if (IsDoubleBattle() == TRUE || GetBankSide(foo) == 1) + { + //_08044136 + sub_8044210(a, b, c); + return; + } + // + ptr = str + 6; + if (c == 0) + { + if (GetBankSide(gSprites[a].data6) == 0) + r4 = gUnknown_0820A83C; + else + r4 = gUnknown_0820A848; + c = 3; + ptr = sub_8003504(ptr, b, 0x13, 1); + *(ptr++) = 0xBA; + *(ptr++) = 0xFF; + sub_80034D4((u8 *)0x02000000, str); + } + else + { + if (GetBankSide(gSprites[a].data6) == 0) + r4 = gUnknown_0820A854; + else + r4 = gUnknown_0820A85C; + c = 2; + sub_8003504(ptr, b, 0xF, 1); + sub_80034D4((u8 *)0x02000000, str); + } + //asm(""::"r"(a)); + //_080441B6 + for (i = 0; i < c; i++) // _080440BC + { + void *temp = r4[i] + gSprites[a].oam.tileNum * 32; + CpuCopy32((void *)(0x02000020 + i * 0x40), temp, 0x20); + } +} +#else +__attribute__((naked)) +void sub_80440EC(u8 a, s16 b, u8 c) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + sub sp, 0x14\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + lsls r1, 16\n\ + lsrs r6, r1, 16\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + mov r8, r2\n\ + ldr r1, _08044144 @ =gUnknown_0820A864\n\ + mov r0, sp\n\ + movs r2, 0x14\n\ + bl memcpy\n\ + ldr r1, _08044148 @ =gSprites\n\ + lsls r0, r7, 4\n\ + adds r0, r7\n\ + lsls r0, 2\n\ + adds r4, r0, r1\n\ + movs r0, 0x3A\n\ + ldrsh r5, [r4, r0]\n\ + bl IsDoubleBattle\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + beq _08044136\n\ + lsls r0, r5, 24\n\ + lsrs r0, 24\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + bne _0804414C\n\ +_08044136:\n\ + lsls r1, r6, 16\n\ + asrs r1, 16\n\ + adds r0, r7, 0\n\ + mov r2, r8\n\ + bl sub_8044210\n\ + b _080441F0\n\ + .align 2, 0\n\ +_08044144: .4byte gUnknown_0820A864\n\ +_08044148: .4byte gSprites\n\ +_0804414C:\n\ + mov r5, sp\n\ + adds r5, 0x6\n\ + mov r0, r8\n\ + cmp r0, 0\n\ + bne _08044190\n\ + ldrh r0, [r4, 0x3A]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + ldr r4, _08044188 @ =gUnknown_0820A848\n\ + cmp r0, 0\n\ + bne _0804416A\n\ + ldr r4, _0804418C @ =gUnknown_0820A83C\n\ +_0804416A:\n\ + movs r0, 0x3\n\ + mov r8, r0\n\ + lsls r1, r6, 16\n\ + asrs r1, 16\n\ + adds r0, r5, 0\n\ + movs r2, 0x13\n\ + movs r3, 0x1\n\ + bl sub_8003504\n\ + adds r5, r0, 0\n\ + movs r0, 0xBA\n\ + strb r0, [r5]\n\ + movs r0, 0xFF\n\ + strb r0, [r5, 0x1]\n\ + b _080441B6\n\ + .align 2, 0\n\ +_08044188: .4byte gUnknown_0820A848\n\ +_0804418C: .4byte gUnknown_0820A83C\n\ +_08044190:\n\ + ldrh r0, [r4, 0x3A]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + ldr r4, _080441FC @ =gUnknown_0820A85C\n\ + cmp r0, 0\n\ + bne _080441A4\n\ + ldr r4, _08044200 @ =gUnknown_0820A854\n\ +_080441A4:\n\ + movs r0, 0x2\n\ + mov r8, r0\n\ + lsls r1, r6, 16\n\ + asrs r1, 16\n\ + adds r0, r5, 0\n\ + movs r2, 0xF\n\ + movs r3, 0x1\n\ + bl sub_8003504\n\ +_080441B6:\n\ + movs r0, 0x80\n\ + lsls r0, 18\n\ + mov r1, sp\n\ + bl sub_80034D4\n\ + mov r0, r8\n\ + cmp r0, 0\n\ + beq _080441F0\n\ + ldr r1, _08044204 @ =gSprites\n\ + lsls r0, r7, 4\n\ + adds r0, r7\n\ + lsls r0, 2\n\ + adds r6, r0, r1\n\ + adds r7, r4, 0\n\ + ldr r5, _08044208 @ =0x02000020\n\ + mov r4, r8\n\ +_080441D6:\n\ + ldrh r0, [r6, 0x4]\n\ + lsls r0, 22\n\ + lsrs r0, 17\n\ + ldm r7!, {r1}\n\ + adds r1, r0\n\ + adds r0, r5, 0\n\ + ldr r2, _0804420C @ =REG_BG0CNT\n\ + bl CpuSet\n\ + adds r5, 0x40\n\ + subs r4, 0x1\n\ + cmp r4, 0\n\ + bne _080441D6\n\ +_080441F0:\n\ + add sp, 0x14\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_080441FC: .4byte gUnknown_0820A85C\n\ +_08044200: .4byte gUnknown_0820A854\n\ +_08044204: .4byte gSprites\n\ +_08044208: .4byte 0x02000020\n\ +_0804420C: .4byte 0x04000008\n\ + .syntax divided\n"); +} +#endif + +static void sub_8044210(u8 a, s16 b, u8 c) +{ + u8 str[0x14]; + u8 *ptr; + void *const *r7; + int r10; + int r4; + int i; + + // TODO: make this a local variable + memcpy(str, gUnknown_0820A89C, sizeof(str)); + r4 = gSprites[a].data6; + if ((ewram17800[r4].unk0_4) == 0) + return; + ptr = str + 6; + if (c == 0) + { + r7 = gUnknown_0820A87C; + r10 = 6; + ptr = sub_8003504(ptr, b, 0x2B, 1); + *(ptr++) = CHAR_SLASH; + *(ptr++) = EOS; + } + else + { + r7 = gUnknown_0820A894; + r10 = 2; + sub_8003504(ptr, b, 0xF, 1); + if (GetBankSide(r4) == 0) + { + CpuCopy32(sub_8043CDC(0x74), (void *)(OBJ_VRAM0 + (gSprites[a].oam.tileNum + 0x34) * 32), 32); + } + } + r4 = gSprites[a].data5; + sub_80034D4((u8 *)0x02000000, str); + for (i = 0; i < r10; i++) + { + CpuCopy32((void *)(0x02000020 + i * 0x40), r7[i] + gSprites[r4].oam.tileNum * 32, 0x20); + } +} + +#ifdef NONMATCHING +void sub_8044338(u8 a, struct Pokemon *pkmn) +{ + u8 str[0x14]; + u8 *r6; + s32 r8; + u8 nature; // = GetNature(pkmn); + s32 r7; + u8 i; + u8 r5; + + // TODO: make this a local variable + memcpy(str, gUnknown_0820A864, sizeof(str)); + r6 = ewram520[GetBankIdentity(gSprites[a].data6)].filler0; + r8 = 5; + nature = GetNature(pkmn); + StringCopy(str + 6, gNatureNames[nature]); + sub_80034D4(r6, str); + r7 = 6; + for (i = 0; i < (u32)r8; i++, r7++) //_080443AA + { + u8 val; + + if ((u8)(str[r7] - 0x37) <= 0x13 || (u8)(str[r7] + 0x79) <= 0x13) + val = 0x2C; + //_080443DC + else if ((u8)(str[r7] - 0x4B) <= 4 || (u8)(str[r7] + 0x65) <= 4) + val = 0x2D; + else + val = 0x2B; + + CpuCopy32(sub_8043CDC(val), r6 + i * 64, 32); + } + //r7 = 1; + //sp18 = a * 16; + for (r7 = 1; r7 < r8 + 1; r7++) + { + int foo; + + foo = gSprites[a].oam.tileNum + MACRO1(r7); + CpuCopy32(r6, (u8 *)0x06010000 + foo * 32, 32); + r6 += 32; + + foo = gSprites[a].oam.tileNum + 8 + MACRO1(r7); + CpuCopy32(r6, (u8 *)0x06010000 + foo * 32, 32); + r6 += 32; + } + //_08044486 + r5 = gSprites[a].data5; + ConvertIntToDecimalStringN(str + 6, ewram[0x16089], 1, 2); + ConvertIntToDecimalStringN(str + 9, ewram[0x16088], 1, 2); + str[5] = 0; + str[8] = 0xBA; + sub_80034D4((u8 *)0x02000000, str); + + for (r7 = 0; r7 < 5; r7++) + { + if (r7 <= 1) + { + int foo = (gSprites[r5].oam.tileNum + 2 + r7); + CpuCopy32((u8 *)0x02000020 + r7 * 0x40, (u8 *)0x06010000 + foo * 32, 32); + } + else + { + int foo = (r7 + gSprites[r5].oam.tileNum); + CpuCopy32((u8 *)0x02000020 + r7 * 0x40, (u8 *)0x060100C0 + foo * 32, 32); + } + } +} +#else +__attribute__((naked)) +void sub_8044338(u8 a, struct Pokemon *pkmn) +{ + 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, 0x20\n\ + adds r4, r1, 0\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x14]\n\ + ldr r1, _080443CC @ =gUnknown_0820A864\n\ + mov r0, sp\n\ + movs r2, 0x14\n\ + bl memcpy\n\ + ldr r1, _080443D0 @ =gSprites\n\ + ldr r2, [sp, 0x14]\n\ + lsls r0, r2, 4\n\ + adds r0, r2\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrh r0, [r0, 0x3A]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + bl GetBankIdentity\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + lsls r1, r0, 1\n\ + adds r1, r0\n\ + lsls r1, 7\n\ + ldr r3, _080443D4 @ =0x02000520\n\ + adds r6, r1, r3\n\ + movs r0, 0x5\n\ + mov r8, r0\n\ + adds r0, r4, 0\n\ + bl GetNature\n\ + lsls r0, 24\n\ + mov r4, sp\n\ + adds r4, 0x6\n\ + ldr r1, _080443D8 @ =gNatureNames\n\ + lsrs r0, 22\n\ + adds r0, r1\n\ + ldr r1, [r0]\n\ + adds r0, r4, 0\n\ + bl StringCopy\n\ + adds r0, r6, 0\n\ + mov r1, sp\n\ + bl sub_80034D4\n\ + movs r7, 0x6\n\ + movs r5, 0\n\ + mov r1, sp\n\ + adds r1, 0x9\n\ + str r1, [sp, 0x1C]\n\ +_080443AA:\n\ + mov r2, sp\n\ + adds r0, r2, r7\n\ + ldrb r1, [r0]\n\ + adds r0, r1, 0\n\ + subs r0, 0x37\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x13\n\ + bls _080443C8\n\ + adds r0, r1, 0\n\ + adds r0, 0x79\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x13\n\ + bhi _080443DC\n\ +_080443C8:\n\ + movs r0, 0x2C\n\ + b _080443FA\n\ + .align 2, 0\n\ +_080443CC: .4byte gUnknown_0820A864\n\ +_080443D0: .4byte gSprites\n\ +_080443D4: .4byte 0x02000520\n\ +_080443D8: .4byte gNatureNames\n\ +_080443DC:\n\ + adds r0, r1, 0\n\ + subs r0, 0x4B\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x4\n\ + bls _080443F4\n\ + adds r0, r1, 0\n\ + adds r0, 0x65\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x4\n\ + bhi _080443F8\n\ +_080443F4:\n\ + movs r0, 0x2D\n\ + b _080443FA\n\ +_080443F8:\n\ + movs r0, 0x2B\n\ +_080443FA:\n\ + bl sub_8043CDC\n\ + lsls r1, r5, 6\n\ + adds r1, r6, r1\n\ + ldr r2, _080444F8 @ =REG_BG0CNT\n\ + bl CpuSet\n\ + adds r0, r5, 0x1\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + adds r7, 0x1\n\ + cmp r5, r8\n\ + bcc _080443AA\n\ + movs r7, 0x1\n\ + ldr r3, [sp, 0x14]\n\ + lsls r3, 4\n\ + str r3, [sp, 0x18]\n\ + movs r0, 0x1\n\ + add r0, r8\n\ + mov r9, r0\n\ + cmp r7, r9\n\ + bge _08044486\n\ + ldr r1, _080444FC @ =gSprites\n\ + ldr r2, _080444F8 @ =REG_BG0CNT\n\ + mov r10, r2\n\ + ldr r2, [sp, 0x14]\n\ + adds r0, r3, r2\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + mov r8, r0\n\ +_08044436:\n\ + mov r3, r8\n\ + ldrh r0, [r3, 0x4]\n\ + lsls r0, 22\n\ + lsrs r0, 22\n\ + adds r5, r7, 0\n\ + cmp r7, 0\n\ + bge _08044446\n\ + adds r5, r7, 0x7\n\ +_08044446:\n\ + asrs r5, 3\n\ + lsls r4, r5, 3\n\ + subs r4, r7, r4\n\ + adds r0, r4\n\ + lsls r5, 6\n\ + adds r0, r5\n\ + lsls r0, 5\n\ + ldr r2, _08044500 @ =0x06010000\n\ + adds r1, r0, r2\n\ + adds r0, r6, 0\n\ + mov r2, r10\n\ + bl CpuSet\n\ + adds r6, 0x20\n\ + mov r3, r8\n\ + ldrh r0, [r3, 0x4]\n\ + lsls r0, 22\n\ + lsrs r0, 22\n\ + adds r4, 0x8\n\ + adds r0, r4\n\ + adds r0, r5\n\ + lsls r0, 5\n\ + ldr r2, _08044500 @ =0x06010000\n\ + adds r1, r0, r2\n\ + adds r0, r6, 0\n\ + mov r2, r10\n\ + bl CpuSet\n\ + adds r6, 0x20\n\ + adds r7, 0x1\n\ + cmp r7, r9\n\ + blt _08044436\n\ +_08044486:\n\ + ldr r6, _080444FC @ =gSprites\n\ + ldr r3, [sp, 0x18]\n\ + ldr r1, [sp, 0x14]\n\ + adds r0, r3, r1\n\ + lsls r0, 2\n\ + adds r0, r6\n\ + ldrh r5, [r0, 0x38]\n\ + lsls r5, 24\n\ + lsrs r5, 24\n\ + ldr r4, _08044504 @ =0x02000000\n\ + ldr r2, _08044508 @ =0x00016089\n\ + adds r0, r4, r2\n\ + ldrb r1, [r0]\n\ + mov r0, sp\n\ + adds r0, 0x6\n\ + movs r2, 0x1\n\ + movs r3, 0x2\n\ + bl ConvertIntToDecimalStringN\n\ + ldr r3, _0804450C @ =0x00016088\n\ + adds r4, r3\n\ + ldrb r1, [r4]\n\ + ldr r0, [sp, 0x1C]\n\ + movs r2, 0x1\n\ + movs r3, 0x2\n\ + bl ConvertIntToDecimalStringN\n\ + mov r1, sp\n\ + movs r0, 0\n\ + strb r0, [r1, 0x5]\n\ + movs r0, 0xBA\n\ + strb r0, [r1, 0x8]\n\ + movs r0, 0x80\n\ + lsls r0, 18\n\ + bl sub_80034D4\n\ + movs r7, 0\n\ + lsls r0, r5, 4\n\ + adds r0, r5\n\ + lsls r0, 2\n\ + adds r5, r0, r6\n\ + ldr r4, _08044510 @ =0x02000020\n\ +_080444DA:\n\ + cmp r7, 0x1\n\ + bgt _08044514\n\ + ldrh r1, [r5, 0x4]\n\ + lsls r1, 22\n\ + lsrs r1, 22\n\ + adds r0, r7, 0x2\n\ + adds r1, r0\n\ + lsls r1, 5\n\ + ldr r0, _08044500 @ =0x06010000\n\ + adds r1, r0\n\ + adds r0, r4, 0\n\ + ldr r2, _080444F8 @ =REG_BG0CNT\n\ + bl CpuSet\n\ + b _0804452A\n\ + .align 2, 0\n\ +_080444F8: .4byte 0x04000008\n\ +_080444FC: .4byte gSprites\n\ +_08044500: .4byte 0x06010000\n\ +_08044504: .4byte 0x02000000\n\ +_08044508: .4byte 0x00016089\n\ +_0804450C: .4byte 0x00016088\n\ +_08044510: .4byte 0x02000020\n\ +_08044514:\n\ + ldrh r1, [r5, 0x4]\n\ + lsls r1, 22\n\ + lsrs r1, 22\n\ + adds r1, r7, r1\n\ + lsls r1, 5\n\ + ldr r2, _08044544 @ =0x060100c0\n\ + adds r1, r2\n\ + adds r0, r4, 0\n\ + ldr r2, _08044548 @ =REG_BG0CNT\n\ + bl CpuSet\n\ +_0804452A:\n\ + adds r4, 0x40\n\ + adds r7, 0x1\n\ + cmp r7, 0x4\n\ + ble _080444DA\n\ + add sp, 0x20\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\ + .align 2, 0\n\ +_08044544: .4byte 0x060100c0\n\ +_08044548: .4byte 0x04000008\n\ + .syntax divided\n"); +} +#endif + +void sub_804454C(void) +{ + s32 i; + u8 spriteId; + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gSprites[gHealthboxIDs[i]].callback == SpriteCallbackDummy + && GetBankSide(i) != 1 + && (IsDoubleBattle() || GetBankSide(i) != 0)) + { + u8 r6; + + ewram17800[i].unk0_4 ^= 1; + r6 = ewram17800[i].unk0_4; + if (GetBankSide(i) == 0) + { + + if (!IsDoubleBattle()) + continue; + if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) + continue; + + if (r6 == 1) + { + spriteId = gSprites[gHealthboxIDs[i]].data5; + + CpuFill32(0, (void *)(OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * 32), 0x100); + sub_8044210(gHealthboxIDs[i], GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_HP), 0); + sub_8044210(gHealthboxIDs[i], GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_MAX_HP), 1); + } + else + { + draw_status_ailment_maybe(gHealthboxIDs[i]); + sub_8045A5C(gHealthboxIDs[i], &gPlayerParty[gBattlePartyID[i]], 5); + CpuCopy32(sub_8043CDC(0x75), (void *)(OBJ_VRAM0 + 0x680 + gSprites[gHealthboxIDs[i]].oam.tileNum * 32), 32); + } + } + else + { + if (r6 == 1) + { + if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) + { + sub_8044338(gHealthboxIDs[i], &gEnemyParty[gBattlePartyID[i]]); + } + else + { + spriteId = gSprites[gHealthboxIDs[i]].data5; + + CpuFill32(0, (void *)(OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * 32), 0x100); + sub_8044210(gHealthboxIDs[i], GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_HP), 0); + sub_8044210(gHealthboxIDs[i], GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_MAX_HP), 1); + } + } + else + { + draw_status_ailment_maybe(gHealthboxIDs[i]); + sub_8045A5C(gHealthboxIDs[i], &gEnemyParty[gBattlePartyID[i]], 5); + if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) + sub_8045A5C(gHealthboxIDs[i], &gEnemyParty[gBattlePartyID[i]], 4); + } + } + gSprites[gHealthboxIDs[i]].data7 ^= 1; + } + } +} + +// This function almost matches except for just two instructions around 0x08044B52 that are swapped. +#ifdef NONMATCHING +u8 sub_8044804(u8 a, const struct BattleInterfaceStruct2 *b, u8 c, u8 d) +{ + u8 r7; + s16 x; + s16 y; + s16 r8; + s16 r5; + + int i; + u8 sp[6]; + s8 sp14; + u8 sp18; + u8 taskId; + + if (c == 0 || GetBankIdentity(a) != 3) + { + if (GetBankSide(a) == 0) + { + r7 = 0; + x = 136; + y = 96; + r8 = 100; + r5 = -5; + } + else + { + r7 = 1; + if (c == 0 || !IsDoubleBattle()) + { + x = 104; + y = 40; + } + else + { + x = 104; + y = 16; + } + r8 = -100; + r5 = 5; + } + } + else + { + r7 = 1; + x = 104; + y = 40; + r8 = -100; + r5 = 5; + } + //_08044884 + + sp14 = 0; + for (i = 0; i < 6; i++) //_080448A0 + { + if (b[i].unk0 != 0xFFFF) + sp14++; + } + + LoadCompressedObjectPic(&gUnknown_0820A754[r7]); + LoadSpriteSheet(&gUnknown_0820A784[r7]); + LoadSpritePalette(&gUnknown_0820A764[r7]); + LoadSpritePalette(&gUnknown_0820A774[r7]); + + sp18 = CreateSprite(&gSpriteTemplate_820A7A4[r7], x, y, 10); + SetSubspriteTables(&gSprites[sp18], gSubspriteTables_820A6E4); + gSprites[sp18].pos2.x = r8; + gSprites[sp18].data0 = r5; + if (r7 != 0) + { + gSprites[sp18].pos1.x -= 96; + gSprites[sp18].oam.matrixNum = 8; + } + else + { + gSprites[sp18].pos1.x += 0x60; + } + //_0804495A + for (i = 0; i < 6; i++) //_08044970 + { + sp[i] = CreateSpriteAtEnd(&gSpriteTemplate_820A7D4[r7], x, y - 4, 9); + if (d == 0) + { + gSprites[sp[i]].callback = sub_8045180; + } + //_080449A0 + if (r7 == 0) + { + gSprites[sp[i]].pos2.x = 0; + gSprites[sp[i]].pos2.y = 0; + } + //_080449BE + gSprites[sp[i]].data0 = sp18; + if (r7 == 0) + { + gSprites[sp[i]].pos1.x += 10 * i + 24; + gSprites[sp[i]].data1 = i * 7 + 10; + gSprites[sp[i]].pos2.x = 120; + } + //_08044A18 + else + { + gSprites[sp[i]].pos1.x -= 10 * (5 - i) + 24; + gSprites[sp[i]].data1 = (6 - i) * 7 + 10; + gSprites[sp[i]].pos2.x = -120; + } + //_08044A56 + gSprites[sp[i]].data2 = r7; + } + //_08044A76 + if (GetBankSide(a) == 0) + { + for (i = 0; i < 6; i++) //_08044A9A + { + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) // && b[i] != 0xFFFF && b[i] + { + if (b[i].unk0 == 0xFFFF) + { + //_08044AE6 + gSprites[sp[i]].oam.tileNum += 1; + gSprites[sp[i]].data7 = 1; + // to _08044B52 + } + else if (b[i].unk0 == 0) + { + gSprites[sp[i]].oam.tileNum += 3; + // to _08044B46 + } + else if (b[i].unk4 != 0) + { + gSprites[sp[i]].oam.tileNum += 2; + } + } + //_08044ADC + else + { + if (i >= sp14) + { + //_08044AE6 + gSprites[sp[i]].oam.tileNum += 1; + gSprites[sp[i]].data7 = 1; + // to _08044B52 + } + else if (b[i].unk0 == 0) + { + //_08044B14 + gSprites[sp[i]].oam.tileNum += 3; + // to _08044B46 + } + else if (b[i].unk4 != 0) + { + gSprites[sp[i]].oam.tileNum += 2; + } + } + } + } + //_08044B5E + else + { + // Mismatch occurrs in this loop initialization + for (i = 0; i < 6; i++) + { + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + if (b[i].unk0 == 0xFFFF) + { + gSprites[sp[5 - i]].oam.tileNum += 1; + gSprites[sp[5 - i]].data7 = 1; + } + else if (b[i].unk0 == 0) + { + gSprites[sp[5 - i]].oam.tileNum += 3; + } + else if (b[i].unk4 != 0) + { + gSprites[sp[5 - i]].oam.tileNum += 2; + } + } + else + { + if (i >= sp14) + { + gSprites[sp[5 - i]].oam.tileNum += 1; + gSprites[sp[5 - i]].data7 = 1; + } + else if (b[i].unk0 == 0) + { + gSprites[sp[5 - i]].oam.tileNum += 3; + } + else if (b[i].unk4 != 0) + { + gSprites[sp[5 - i]].oam.tileNum += 2; + } + } + // This corrects the initialization order, but messes up the counter update order + asm(""::"r"(&b[i])); + } + } + //_08044C38 + taskId = CreateTask(TaskDummy, 5); + gTasks[taskId].data[0] = a; + gTasks[taskId].data[1] = sp18; + for (i = 0; i < 6; i++) + gTasks[taskId].data[3 + i] = sp[i]; + gTasks[taskId].data[10] = d; + PlaySE12WithPanning(SE_TB_START, 0); + return taskId; +} +#else +__attribute__((naked)) +u8 sub_8044804(u8 a, const struct BattleInterfaceStruct2 *b, u8 c, u8 d) +{ + 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, 0x28\n\ + str r1, [sp, 0xC]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x8]\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + adds r4, r2, 0\n\ + lsls r3, 24\n\ + lsrs r3, 24\n\ + str r3, [sp, 0x10]\n\ + cmp r4, 0\n\ + beq _08044834\n\ + bl GetBankIdentity\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x3\n\ + beq _08044878\n\ +_08044834:\n\ + ldr r0, [sp, 0x8]\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _08044854\n\ + movs r7, 0\n\ + movs r1, 0x88\n\ + movs r2, 0x60\n\ + movs r0, 0x64\n\ + mov r8, r0\n\ + ldr r5, _08044850 @ =0x0000fffb\n\ + b _08044884\n\ + .align 2, 0\n\ +_08044850: .4byte 0x0000fffb\n\ +_08044854:\n\ + movs r7, 0x1\n\ + cmp r4, 0\n\ + beq _08044864\n\ + bl IsDoubleBattle\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _0804486A\n\ +_08044864:\n\ + movs r1, 0x68\n\ + movs r2, 0x28\n\ + b _0804486E\n\ +_0804486A:\n\ + movs r1, 0x68\n\ + movs r2, 0x10\n\ +_0804486E:\n\ + ldr r3, _08044874 @ =0x0000ff9c\n\ + mov r8, r3\n\ + b _08044882\n\ + .align 2, 0\n\ +_08044874: .4byte 0x0000ff9c\n\ +_08044878:\n\ + movs r7, 0x1\n\ + movs r1, 0x68\n\ + movs r2, 0x28\n\ + ldr r5, _08044930 @ =0x0000ff9c\n\ + mov r8, r5\n\ +_08044882:\n\ + movs r5, 0x5\n\ +_08044884:\n\ + movs r6, 0\n\ + str r6, [sp, 0x14]\n\ + lsls r4, r7, 3\n\ + ldr r0, _08044934 @ =gUnknown_0820A754\n\ + mov r10, r0\n\ + lsls r3, r7, 1\n\ + mov r9, r3\n\ + lsls r1, 16\n\ + str r1, [sp, 0x20]\n\ + lsls r2, 16\n\ + str r2, [sp, 0x24]\n\ + ldr r2, _08044938 @ =0x0000ffff\n\ + ldr r1, [sp, 0xC]\n\ + movs r6, 0x5\n\ +_080448A0:\n\ + ldrh r0, [r1]\n\ + cmp r0, r2\n\ + beq _080448B4\n\ + ldr r3, [sp, 0x14]\n\ + lsls r0, r3, 24\n\ + movs r3, 0x80\n\ + lsls r3, 17\n\ + adds r0, r3\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x14]\n\ +_080448B4:\n\ + adds r1, 0x8\n\ + subs r6, 0x1\n\ + cmp r6, 0\n\ + bge _080448A0\n\ + mov r6, r10\n\ + adds r0, r4, r6\n\ + bl LoadCompressedObjectPic\n\ + ldr r0, _0804493C @ =gUnknown_0820A784\n\ + adds r0, r4, r0\n\ + bl LoadSpriteSheet\n\ + ldr r0, _08044940 @ =gUnknown_0820A764\n\ + adds r0, r4, r0\n\ + bl LoadSpritePalette\n\ + ldr r0, _08044944 @ =gUnknown_0820A774\n\ + adds r0, r4, r0\n\ + bl LoadSpritePalette\n\ + mov r1, r9\n\ + adds r0, r1, r7\n\ + lsls r0, 3\n\ + ldr r1, _08044948 @ =gSpriteTemplate_820A7A4\n\ + adds r0, r1\n\ + ldr r2, [sp, 0x20]\n\ + asrs r1, r2, 16\n\ + ldr r3, [sp, 0x24]\n\ + asrs r2, r3, 16\n\ + movs r3, 0xA\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x18]\n\ + lsls r0, 4\n\ + ldr r6, [sp, 0x18]\n\ + adds r0, r6\n\ + lsls r0, 2\n\ + ldr r1, _0804494C @ =gSprites\n\ + adds r4, r0, r1\n\ + ldr r1, _08044950 @ =gSubspriteTables_820A6E4\n\ + adds r0, r4, 0\n\ + bl SetSubspriteTables\n\ + mov r0, r8\n\ + strh r0, [r4, 0x24]\n\ + strh r5, [r4, 0x2E]\n\ + cmp r7, 0\n\ + beq _08044954\n\ + ldrh r0, [r4, 0x20]\n\ + subs r0, 0x60\n\ + strh r0, [r4, 0x20]\n\ + ldrb r1, [r4, 0x3]\n\ + movs r0, 0x3F\n\ + negs r0, r0\n\ + ands r0, r1\n\ + movs r1, 0x10\n\ + orrs r0, r1\n\ + strb r0, [r4, 0x3]\n\ + b _0804495A\n\ + .align 2, 0\n\ +_08044930: .4byte 0x0000ff9c\n\ +_08044934: .4byte gUnknown_0820A754\n\ +_08044938: .4byte 0x0000ffff\n\ +_0804493C: .4byte gUnknown_0820A784\n\ +_08044940: .4byte gUnknown_0820A764\n\ +_08044944: .4byte gUnknown_0820A774\n\ +_08044948: .4byte gSpriteTemplate_820A7A4\n\ +_0804494C: .4byte gSprites\n\ +_08044950: .4byte gSubspriteTables_820A6E4\n\ +_08044954:\n\ + ldrh r0, [r4, 0x20]\n\ + adds r0, 0x60\n\ + strh r0, [r4, 0x20]\n\ +_0804495A:\n\ + movs r6, 0\n\ + ldr r1, _08044A04 @ =gSprites\n\ + mov r10, r1\n\ + mov r4, sp\n\ + mov r2, r9\n\ + adds r0, r2, r7\n\ + lsls r0, 3\n\ + str r0, [sp, 0x1C]\n\ + movs r3, 0xA\n\ + mov r9, r3\n\ + mov r8, r6\n\ +_08044970:\n\ + ldr r0, _08044A08 @ =gSpriteTemplate_820A7D4\n\ + ldr r5, [sp, 0x24]\n\ + ldr r1, _08044A0C @ =0xfffc0000\n\ + adds r2, r5, r1\n\ + ldr r3, [sp, 0x1C]\n\ + adds r0, r3, r0\n\ + ldr r5, [sp, 0x20]\n\ + asrs r1, r5, 16\n\ + asrs r2, 16\n\ + movs r3, 0x9\n\ + bl CreateSpriteAtEnd\n\ + strb r0, [r4]\n\ + ldr r0, [sp, 0x10]\n\ + cmp r0, 0\n\ + bne _080449A0\n\ + ldrb r0, [r4]\n\ + lsls r1, r0, 4\n\ + adds r1, r0\n\ + lsls r1, 2\n\ + ldr r2, _08044A10 @ =gSprites + 0x1C\n\ + adds r1, r2\n\ + ldr r0, _08044A14 @ =sub_8045180\n\ + str r0, [r1]\n\ +_080449A0:\n\ + ldr r5, _08044A04 @ =gSprites\n\ + cmp r7, 0\n\ + bne _080449BE\n\ + ldrb r1, [r4]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + add r0, r10\n\ + strh r7, [r0, 0x24]\n\ + ldrb r1, [r4]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + add r0, r10\n\ + strh r7, [r0, 0x26]\n\ +_080449BE:\n\ + ldrb r1, [r4]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r5\n\ + movs r1, 0\n\ + mov r3, sp\n\ + ldrh r3, [r3, 0x18]\n\ + strh r3, [r0, 0x2E]\n\ + cmp r7, 0\n\ + bne _08044A18\n\ + ldrb r0, [r4]\n\ + lsls r1, r0, 4\n\ + adds r1, r0\n\ + lsls r1, 2\n\ + adds r1, r5\n\ + ldrh r0, [r1, 0x20]\n\ + adds r0, 0x18\n\ + add r0, r8\n\ + strh r0, [r1, 0x20]\n\ + ldrb r1, [r4]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r5\n\ + mov r1, r9\n\ + strh r1, [r0, 0x30]\n\ + ldrb r1, [r4]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r5\n\ + movs r1, 0x78\n\ + b _08044A56\n\ + .align 2, 0\n\ +_08044A04: .4byte gSprites\n\ +_08044A08: .4byte gSpriteTemplate_820A7D4\n\ +_08044A0C: .4byte 0xfffc0000\n\ +_08044A10: .4byte gSprites + 0x1C\n\ +_08044A14: .4byte sub_8045180\n\ +_08044A18:\n\ + ldrb r0, [r4]\n\ + lsls r2, r0, 4\n\ + adds r2, r0\n\ + lsls r2, 2\n\ + adds r2, r5\n\ + ldrh r3, [r2, 0x20]\n\ + subs r3, 0x18\n\ + movs r1, 0x5\n\ + subs r1, r6\n\ + lsls r0, r1, 2\n\ + adds r0, r1\n\ + lsls r0, 1\n\ + subs r3, r0\n\ + strh r3, [r2, 0x20]\n\ + ldrb r0, [r4]\n\ + lsls r2, r0, 4\n\ + adds r2, r0\n\ + lsls r2, 2\n\ + adds r2, r5\n\ + movs r1, 0x6\n\ + subs r1, r6\n\ + lsls r0, r1, 3\n\ + subs r0, r1\n\ + adds r0, 0xA\n\ + strh r0, [r2, 0x30]\n\ + ldrb r1, [r4]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r5\n\ + ldr r1, _08044AC4 @ =0x0000ff88\n\ +_08044A56:\n\ + strh r1, [r0, 0x24]\n\ + ldrb r1, [r4]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r5\n\ + strh r7, [r0, 0x32]\n\ + adds r4, 0x1\n\ + movs r2, 0x7\n\ + add r9, r2\n\ + movs r3, 0xA\n\ + add r8, r3\n\ + adds r6, 0x1\n\ + cmp r6, 0x5\n\ + bgt _08044A76\n\ + b _08044970\n\ +_08044A76:\n\ + ldr r0, [sp, 0x8]\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _08044B5E\n\ + movs r6, 0\n\ + ldr r5, _08044AC8 @ =gBattleTypeFlags\n\ + mov r10, r5\n\ + ldr r0, _08044ACC @ =0x0000ffff\n\ + mov r9, r0\n\ + ldr r7, _08044AD0 @ =gSprites\n\ + ldr r1, _08044AD4 @ =0x000003ff\n\ + mov r12, r1\n\ + ldr r2, _08044AD8 @ =0xfffffc00\n\ + mov r8, r2\n\ + mov r4, sp\n\ + ldr r5, [sp, 0xC]\n\ +_08044A9A:\n\ + mov r3, r10\n\ + ldrh r1, [r3]\n\ + movs r0, 0x40\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08044ADC\n\ + ldrh r0, [r5]\n\ + cmp r0, r9\n\ + beq _08044AE6\n\ + cmp r0, 0\n\ + bne _08044B2E\n\ + ldrb r0, [r4]\n\ + lsls r2, r0, 4\n\ + adds r2, r0\n\ + lsls r2, 2\n\ + adds r2, r7\n\ + ldrh r3, [r2, 0x4]\n\ + lsls r1, r3, 22\n\ + lsrs r1, 22\n\ + adds r1, 0x3\n\ + b _08044B46\n\ + .align 2, 0\n\ +_08044AC4: .4byte 0x0000ff88\n\ +_08044AC8: .4byte gBattleTypeFlags\n\ +_08044ACC: .4byte 0x0000ffff\n\ +_08044AD0: .4byte gSprites\n\ +_08044AD4: .4byte 0x000003ff\n\ +_08044AD8: .4byte 0xfffffc00\n\ +_08044ADC:\n\ + ldr r1, [sp, 0x14]\n\ + lsls r0, r1, 24\n\ + asrs r0, 24\n\ + cmp r6, r0\n\ + blt _08044B14\n\ +_08044AE6:\n\ + ldrb r0, [r4]\n\ + lsls r2, r0, 4\n\ + adds r2, r0\n\ + lsls r2, 2\n\ + adds r2, r7\n\ + ldrh r3, [r2, 0x4]\n\ + lsls r1, r3, 22\n\ + lsrs r1, 22\n\ + adds r1, 0x1\n\ + mov r0, r12\n\ + ands r1, r0\n\ + mov r0, r8\n\ + ands r0, r3\n\ + orrs r0, r1\n\ + strh r0, [r2, 0x4]\n\ + ldrb r1, [r4]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r7\n\ + movs r1, 0x1\n\ + strh r1, [r0, 0x3C]\n\ + b _08044B52\n\ +_08044B14:\n\ + ldrh r0, [r5]\n\ + cmp r0, 0\n\ + bne _08044B2E\n\ + ldrb r0, [r4]\n\ + lsls r2, r0, 4\n\ + adds r2, r0\n\ + lsls r2, 2\n\ + adds r2, r7\n\ + ldrh r3, [r2, 0x4]\n\ + lsls r1, r3, 22\n\ + lsrs r1, 22\n\ + adds r1, 0x3\n\ + b _08044B46\n\ +_08044B2E:\n\ + ldr r0, [r5, 0x4]\n\ + cmp r0, 0\n\ + beq _08044B52\n\ + ldrb r0, [r4]\n\ + lsls r2, r0, 4\n\ + adds r2, r0\n\ + lsls r2, 2\n\ + adds r2, r7\n\ + ldrh r3, [r2, 0x4]\n\ + lsls r1, r3, 22\n\ + lsrs r1, 22\n\ + adds r1, 0x2\n\ +_08044B46:\n\ + mov r0, r12\n\ + ands r1, r0\n\ + mov r0, r8\n\ + ands r0, r3\n\ + orrs r0, r1\n\ + strh r0, [r2, 0x4]\n\ +_08044B52:\n\ + adds r4, 0x1\n\ + adds r5, 0x8\n\ + adds r6, 0x1\n\ + cmp r6, 0x5\n\ + ble _08044A9A\n\ + b _08044C38\n\ +_08044B5E:\n\ + movs r6, 0\n\ + ldr r1, _08044BA4 @ =gBattleTypeFlags\n\ + mov r10, r1\n\ + ldr r2, _08044BA8 @ =0x0000ffff\n\ + mov r9, r2\n\ + ldr r7, _08044BAC @ =gSprites\n\ + ldr r3, _08044BB0 @ =0x000003ff\n\ + mov r12, r3\n\ + ldr r5, _08044BB4 @ =0xfffffc00\n\ + mov r8, r5\n\ + ldr r5, [sp, 0xC]\n\ + mov r4, sp\n\ + adds r4, 0x5\n\ +_08044B78:\n\ + mov r0, r10\n\ + ldrh r1, [r0]\n\ + movs r0, 0x40\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08044BB8\n\ + ldrh r0, [r5]\n\ + cmp r0, r9\n\ + beq _08044BC2\n\ + cmp r0, 0\n\ + bne _08044C0A\n\ + ldrb r0, [r4]\n\ + lsls r2, r0, 4\n\ + adds r2, r0\n\ + lsls r2, 2\n\ + adds r2, r7\n\ + ldrh r3, [r2, 0x4]\n\ + lsls r1, r3, 22\n\ + lsrs r1, 22\n\ + adds r1, 0x3\n\ + b _08044C22\n\ + .align 2, 0\n\ +_08044BA4: .4byte gBattleTypeFlags\n\ +_08044BA8: .4byte 0x0000ffff\n\ +_08044BAC: .4byte gSprites\n\ +_08044BB0: .4byte 0x000003ff\n\ +_08044BB4: .4byte 0xfffffc00\n\ +_08044BB8:\n\ + ldr r1, [sp, 0x14]\n\ + lsls r0, r1, 24\n\ + asrs r0, 24\n\ + cmp r6, r0\n\ + blt _08044BF0\n\ +_08044BC2:\n\ + ldrb r0, [r4]\n\ + lsls r2, r0, 4\n\ + adds r2, r0\n\ + lsls r2, 2\n\ + adds r2, r7\n\ + ldrh r3, [r2, 0x4]\n\ + lsls r1, r3, 22\n\ + lsrs r1, 22\n\ + adds r1, 0x1\n\ + mov r0, r12\n\ + ands r1, r0\n\ + mov r0, r8\n\ + ands r0, r3\n\ + orrs r0, r1\n\ + strh r0, [r2, 0x4]\n\ + ldrb r1, [r4]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r7\n\ + movs r1, 0x1\n\ + strh r1, [r0, 0x3C]\n\ + b _08044C2E\n\ +_08044BF0:\n\ + ldrh r0, [r5]\n\ + cmp r0, 0\n\ + bne _08044C0A\n\ + ldrb r0, [r4]\n\ + lsls r2, r0, 4\n\ + adds r2, r0\n\ + lsls r2, 2\n\ + adds r2, r7\n\ + ldrh r3, [r2, 0x4]\n\ + lsls r1, r3, 22\n\ + lsrs r1, 22\n\ + adds r1, 0x3\n\ + b _08044C22\n\ +_08044C0A:\n\ + ldr r0, [r5, 0x4]\n\ + cmp r0, 0\n\ + beq _08044C2E\n\ + ldrb r0, [r4]\n\ + lsls r2, r0, 4\n\ + adds r2, r0\n\ + lsls r2, 2\n\ + adds r2, r7\n\ + ldrh r3, [r2, 0x4]\n\ + lsls r1, r3, 22\n\ + lsrs r1, 22\n\ + adds r1, 0x2\n\ +_08044C22:\n\ + mov r0, r12\n\ + ands r1, r0\n\ + mov r0, r8\n\ + ands r0, r3\n\ + orrs r0, r1\n\ + strh r0, [r2, 0x4]\n\ +_08044C2E:\n\ + subs r4, 0x1\n\ + adds r5, 0x8\n\ + adds r6, 0x1\n\ + cmp r6, 0x5\n\ + ble _08044B78\n\ +_08044C38:\n\ + ldr r0, _08044C98 @ =TaskDummy\n\ + movs r1, 0x5\n\ + bl CreateTask\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + ldr r2, _08044C9C @ =gTasks\n\ + lsls r3, r4, 2\n\ + adds r1, r3, r4\n\ + lsls r1, 3\n\ + adds r0, r1, r2\n\ + mov r5, sp\n\ + ldrh r5, [r5, 0x8]\n\ + strh r5, [r0, 0x8]\n\ + mov r6, sp\n\ + ldrh r6, [r6, 0x18]\n\ + strh r6, [r0, 0xA]\n\ + movs r6, 0\n\ + adds r0, r2, 0\n\ + adds r0, 0xE\n\ + adds r1, r0\n\ +_08044C62:\n\ + mov r5, sp\n\ + adds r0, r5, r6\n\ + ldrb r0, [r0]\n\ + strh r0, [r1]\n\ + adds r1, 0x2\n\ + adds r6, 0x1\n\ + cmp r6, 0x5\n\ + ble _08044C62\n\ + adds r0, r3, r4\n\ + lsls r0, 3\n\ + adds r0, r2\n\ + ldrh r6, [r5, 0x10]\n\ + strh r6, [r0, 0x1C]\n\ + movs r0, 0x72\n\ + movs r1, 0\n\ + bl PlaySE12WithPanning\n\ + adds r0, r4, 0\n\ + add sp, 0x28\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ +_08044C98: .4byte TaskDummy\n\ +_08044C9C: .4byte gTasks\n\ + .syntax divided\n"); +} +#endif + +void sub_8044CA0(u8 taskId) +{ + u8 sp[6]; + u8 r9; + u8 r10; + u8 sp8; + s32 i; + + r9 = gTasks[taskId].data[10]; + r10 = gTasks[taskId].data[1]; + sp8 = gTasks[taskId].data[0]; + for (i = 0; i < 6; i++) + sp[i] = gTasks[taskId].data[3 + i]; + + REG_BLDCNT = 0x3F40; + REG_BLDALPHA = 0x10; + gTasks[taskId].data[15] = 16; + for (i = 0; i < 6; i++) + gSprites[sp[i]].oam.objMode = 1; + gSprites[r10].oam.objMode = 1; + if (r9 != 0) + { + for (i = 0; i < 6; i++) + { + if (GetBankSide(sp8) != 0) + { + gSprites[sp[5 - i]].data1 = 7 * i; + gSprites[sp[5 - i]].data3 = 0; + gSprites[sp[5 - i]].data4 = 0; + gSprites[sp[5 - i]].callback = sub_8045110; + } + else + { + gSprites[sp[i]].data1 = 7 * i; + gSprites[sp[i]].data3 = 0; + gSprites[sp[i]].data4 = 0; + gSprites[sp[i]].callback = sub_8045110; + } + } + gSprites[r10].data0 /= 2; + gSprites[r10].data1 = 0; + gSprites[r10].callback = sub_8045048; + SetSubspriteTables(&gSprites[r10], gSubspriteTables_820A6EC); + gTasks[taskId].func = sub_8044E74; + } + else + { + gTasks[taskId].func = sub_8044F70; + } +} + +static void sub_8044E74(u8 taskId) +{ + u16 temp = gTasks[taskId].data[11]++; + + if ((temp & 1) == 0) + { + gTasks[taskId].data[15]--; + if (gTasks[taskId].data[15] < 0) + return; + REG_BLDALPHA = (gTasks[taskId].data[15]) | ((16 - gTasks[taskId].data[15]) << 8); + } + if (gTasks[taskId].data[15] == 0) + gTasks[taskId].func = sub_8044ECC; +} + +static void sub_8044ECC(u8 taskId) +{ + u8 sp[6]; + s32 i; + + gTasks[taskId].data[15]--; + if (gTasks[taskId].data[15] == -1) + { + u8 var = gTasks[taskId].data[1]; + + for (i = 0; i < 6; i++) + sp[i] = gTasks[taskId].data[3 + i]; + DestroySpriteAndFreeResources(&gSprites[var]); + DestroySpriteAndFreeResources(&gSprites[sp[0]]); + for (i = 1; i < 6; i++) + DestroySprite(&gSprites[sp[i]]); + } + else if (gTasks[taskId].data[15] == -3) + { + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + DestroyTask(taskId); + } +} + +static void sub_8044F70(u8 taskId) +{ + u8 sp[6]; + s32 i; + + gTasks[taskId].data[15]--; + // Same as above function except with this check. + if (gTasks[taskId].data[15] >= 0) + { + REG_BLDALPHA = (gTasks[taskId].data[15]) | ((16 - gTasks[taskId].data[15]) << 8); + } + else if (gTasks[taskId].data[15] == -1) + { + u8 var = gTasks[taskId].data[1]; + + for (i = 0; i < 6; i++) + sp[i] = gTasks[taskId].data[3 + i]; + DestroySpriteAndFreeResources(&gSprites[var]); + DestroySpriteAndFreeResources(&gSprites[sp[0]]); + for (i = 1; i < 6; i++) + DestroySprite(&gSprites[sp[i]]); + } + else if (gTasks[taskId].data[15] == -3) + { + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + DestroyTask(taskId); + } +} + +void sub_8045030(struct Sprite *sprite) +{ + if (sprite->pos2.x != 0) + sprite->pos2.x += sprite->data0; +} + +static void sub_8045048(struct Sprite *sprite) +{ + sprite->data1 += 32; + if (sprite->data0 > 0) + sprite->pos2.x += sprite->data1 >> 4; + else + sprite->pos2.x -= sprite->data1 >> 4; + sprite->data1 &= 0xF; +} + +void sub_804507C(struct Sprite *sprite) +{ + u8 r3; + u16 r2; + s8 pan; + + if (sprite->data1 > 0) + { + sprite->data1--; + return; + } + r3 = sprite->data2; + r2 = sprite->data3; + r2 += 56; + sprite->data3 = r2 & 0xFFF0; + if (r3 != 0) + { + sprite->pos2.x += r2 >> 4; + if (sprite->pos2.x > 0) + sprite->pos2.x = 0; + } + else + { + sprite->pos2.x -= r2 >> 4; + if (sprite->pos2.x < 0) + sprite->pos2.x = 0; + } + if (sprite->pos2.x == 0) + { + pan = 63; + if (r3 != 0) + pan = -64; + if (sprite->data7 != 0) + PlaySE2WithPanning(SE_TB_KARA, pan); + else + PlaySE1WithPanning(SE_TB_KON, pan); + sprite->callback = SpriteCallbackDummy; + } +} + +static void sub_8045110(struct Sprite *sprite) +{ + u8 r0; + u16 r2; + + if (sprite->data1 > 0) + { + sprite->data1--; + return; + } + r0 = sprite->data2; + r2 = sprite->data3; + r2 += 56; + sprite->data3 = r2 & 0xFFF0; + if (r0 != 0) + sprite->pos2.x += r2 >> 4; + else + sprite->pos2.x -= r2 >> 4; + if (sprite->pos2.x + sprite->pos1.x > 248 + || sprite->pos2.x + sprite->pos1.x < -8) + { + sprite->invisible = TRUE; + sprite->callback = SpriteCallbackDummy; + } +} + +void sub_8045180(struct Sprite *sprite) +{ + u8 spriteId = sprite->data0; + + sprite->pos2.x = gSprites[spriteId].pos2.x; + sprite->pos2.y = gSprites[spriteId].pos2.y; +} + +static void sub_80451A0(u8 a, struct Pokemon *pkmn) +{ + u8 nickname[POKEMON_NAME_LENGTH]; + u8 gender; + u16 species; + u8 language; + u8 *ptr; + s32 i; + s32 _7; + u8 *const *r1; + + StringCopy(gDisplayedStringBattle, gUnknown_0820A8B0); + GetMonData(pkmn, MON_DATA_NICKNAME, nickname); + StringGetEnd10(nickname); + ptr = StringCopy(gDisplayedStringBattle + 3, nickname); + ptr[0] = EXT_CTRL_CODE_BEGIN; + ptr[1] = 3; + ptr[2] = 2; + ptr[3] = EXT_CTRL_CODE_BEGIN; + ptr[4] = 1; + ptr += 5; + gender = GetMonGender(pkmn); + species = GetMonData(pkmn, MON_DATA_SPECIES); + language = GetMonData(pkmn, MON_DATA_LANGUAGE); + if (sub_8040D3C(species, nickname, language)) + gender = 100; + switch (gender) + { + default: + ptr[0] = 0xB; + ptr[1] = EOS; + ptr += 1; + break; + case MON_MALE: + ptr[0] = 0xB; + ptr[1] = CHAR_MALE; + ptr[2] = EOS; + ptr += 2; + break; + case MON_FEMALE: + ptr[0] = 0xA; + ptr[1] = CHAR_FEMALE; + ptr[2] = EOS; + ptr += 2; + break; + } + ptr[0] = EXT_CTRL_CODE_BEGIN; + ptr[1] = 0x13; + ptr[2] = 0x37; + ptr[3] = EOS; + ptr = (u8 *)0x02000520 + GetBankIdentity(gSprites[a].data6) * 0x180; + sub_80034D4(ptr, gDisplayedStringBattle); + + i = 0; + _7 = 7; + if (GetMonData(pkmn, MON_DATA_LANGUAGE) == 1 + && GetMonData(pkmn, MON_DATA_IS_EGG) == 0) + { + u8 *p = gDisplayedStringBattle; + + while (*p != EOS) + { + if (*p == EXT_CTRL_CODE_BEGIN) + { + p += GetExtCtrlCodeLength(p[1]) + 1; + } + else + { + u8 r0; + + if ((*p >= 0x37 && *p <= 0x4A) || (*p >= 0x87 && *p <= 0x9A)) + r0 = 0x2C; + else if ((*p >= 0x4B && *p <= 0x4F) || (*p >= 0x9B && *p <= 0x9F)) + r0 = 0x2D; + else + r0 = 0x2B; + + CpuCopy32(sub_8043CDC(r0), ptr + 0x40 * i, 32); + i++; + p++; + } + } + } + + for (; i < _7; i++) + CpuCopy32(sub_8043CDC(0x2B), ptr + 64 * i, 32); + + if (GetBankSide(gSprites[a].data6) == 0 && !IsDoubleBattle()) + { + r1 = (u8 *const *)gUnknown_0820A8B4; + for (i = 0; i < _7; i++) + { + u8 *r4 = r1[i]; + + r4 += gSprites[a].oam.tileNum * 32; + CpuCopy32(ptr, r4, 32); + ptr += 32; + + r4 += 0x100; + CpuCopy32(ptr, r4, 32); + ptr += 32; + } + } + else + { + if (GetBankSide(gSprites[a].data6) == 0) + r1 = (u8 *const *)gUnknown_0820A904; + else + r1 = (u8 *const *)gUnknown_0820A8DC; + for (i = 0; i < _7; i++) + { + u8 *r4 = r1[i]; + + r4 += gSprites[a].oam.tileNum * 32; + CpuCopy32(ptr, r4, 32); + ptr += 32; + + r4 += 0x100; + CpuCopy32(ptr, r4, 32); + ptr += 32; + } + } +} + +static void sub_8045458(u8 a, u8 b) +{ + u8 r4; + + if (gBattleTypeFlags & 0x200) + return; + if (gBattleTypeFlags & 8) + return; + + r4 = gSprites[a].data6; + if (GetBankSide(r4) != 0) + { + u16 species = GetMonData(&gEnemyParty[gBattlePartyID[r4]], MON_DATA_SPECIES); + if (GetNationalPokedexFlag(SpeciesToNationalPokedexNum(species), 1) != 0) + { + r4 = gSprites[a].data5; + if (b != 0) + CpuCopy32(sub_8043CDC(0x46), (void *)(OBJ_VRAM0 + (gSprites[r4].oam.tileNum + 8) * 32), 32); + else + CpuFill32(0, (void *)(OBJ_VRAM0 + (gSprites[r4].oam.tileNum + 8) * 32), 32); + } + } +} + +static void draw_status_ailment_maybe(u8 a) +{ + s32 r4; + s32 r4_2; + u8 r7; + u8 r10; + s16 r8; + const u8 *r6; + u8 r0; + s32 i; + + r7 = gSprites[a].data6; + r10 = gSprites[a].data5; + if (GetBankSide(r7) == 0) + { + r4 = GetMonData(&gPlayerParty[gBattlePartyID[r7]], MON_DATA_STATUS); + if (!IsDoubleBattle()) + r8 = 0x1A; + else + r8 = 0x12; + } + else + { + r4 = GetMonData(&gEnemyParty[gBattlePartyID[r7]], MON_DATA_STATUS); + r8 = 0x11; + } + if (r4 & 7) + { + r6 = sub_8043CDC(sub_80457E8(0x1B, r7)); + r0 = 2; + } + else if (r4 & 0x88) + { + r6 = sub_8043CDC(sub_80457E8(0x15, r7)); + r0 = 0; + } + else if (r4 & 0x10) + { + r6 = sub_8043CDC(sub_80457E8(0x21, r7)); + r0 = 4; + } + else if (r4 & 0x20) + { + r6 = sub_8043CDC(sub_80457E8(0x1E, r7)); + r0 = 3; + } + else if (r4 & 0x40) + { + r6 = sub_8043CDC(sub_80457E8(0x18, r7)); + r0 = 1; + } + else + { + r6 = sub_8043CDC(0x27); + + for (i = 0; i < 3; i++) + CpuCopy32(r6, (void *)(OBJ_VRAM0 + (gSprites[a].oam.tileNum + r8 + i) * 32), 32); + + if (!ewram17800[r7].unk0_4) + CpuCopy32(sub_8043CDC(1), (void *)(OBJ_VRAM0 + gSprites[r10].oam.tileNum * 32), 64); + + sub_8045458(a, 1); + return; + } + + r4_2 = gSprites[a].oam.paletteNum * 16; + r4_2 += r7 + 12; + // I don't like writing the array index like this, but I can't get it to match otherwise. + FillPalette(r0[gBattleInterfaceStatusIcons_DynPal], r4_2 + 0x100, 2); + CpuCopy16(gPlttBufferUnfaded + 0x100 + r4_2, (void *)(OBJ_PLTT + r4_2 * 2), 2); + CpuCopy32(r6, (void *)(OBJ_VRAM0 + (gSprites[a].oam.tileNum + r8) * 32), 96); + if (IsDoubleBattle() == TRUE || GetBankSide(r7) == TRUE) + { + if (!ewram17800[r7].unk0_4) + { + CpuCopy32(sub_8043CDC(0), (void *)(OBJ_VRAM0 + gSprites[r10].oam.tileNum * 32), 32); + CpuCopy32(sub_8043CDC(0x41), (void *)(OBJ_VRAM0 + (gSprites[r10].oam.tileNum + 1) * 32), 32); + } + } + sub_8045458(a, 0); +} + +static u8 sub_80457E8(u8 a, u8 b) +{ + u8 ret = a; + + switch (a) + { + case 21: + if (b == 0) + ret = 21; + else if (b == 1) + ret = 71; + else if (b == 2) + ret = 86; + else + ret = 101; + break; + case 24: + if (b == 0) + ret = 24; + else if (b == 1) + ret = 74; + else if (b == 2) + ret = 89; + else + ret = 104; + break; + case 27: + if (b == 0) + ret = 27; + else if (b == 1) + ret = 77; + else if (b == 2) + ret = 92; + else + ret = 107; + break; + case 30: + if (b == 0) + ret = 30; + else if (b == 1) + ret = 80; + else if (b == 2) + ret = 95; + else + ret = 110; + break; + case 33: + if (b == 0) + ret = 33; + else if (b == 1) + ret = 83; + else if (b == 2) + ret = 98; + else + ret = 113; + break; + } + return ret; +} + +static void sub_80458B0(u8 a) +{ + u8 *r6; + u8 r8; + u8 i; + s32 r7; + u8 *addr; + + r6 = (u8 *)0x02000520 + GetBankIdentity(gSprites[a].data6) * 0x180; + r8 = 7; + sub_80034D4(r6, BattleText_SafariBalls); + for (i = 0; i < r8; i++) + CpuCopy32(sub_8043CDC(0x2B), r6 + i * 64, 32); + for (r7 = 3; r7 < 3 + r8; r7++) + { + addr = (void *)(OBJ_VRAM0 + (gSprites[a].oam.tileNum + MACRO1(r7)) * 32); + CpuCopy32(r6, addr, 32); + r6 += 32; + + addr = (void *)(OBJ_VRAM0 + (8 + gSprites[a].oam.tileNum + MACRO1(r7)) * 32); + CpuCopy32(r6, addr, 32); + r6 += 32; + } + +} + +static void sub_8045998(u8 a) +{ + u8 *r7; + u8 status; + s32 r6; + s32 i; + + r7 = StringCopy(gDisplayedStringBattle, BattleText_SafariBallsLeft); + r7 = sub_8003504(r7, gNumSafariBalls, 10, 1); + StringAppend(r7, BattleText_HighlightRed); + status = GetBankIdentity(gSprites[a].data6); + r7 = (u8 *)0x02000520 + status * 0x180; + r6 = 5; + sub_80034D4(r7, gDisplayedStringBattle); + r7 = (u8 *)0x02000520 + status * 0x180 + 32; + for (i = 6; i < 6 + r6; i++) + { + CpuCopy32(r7, (void *)(OBJ_VRAM0 + (gSprites[a].oam.tileNum + 0x18 + MACRO1(i)) * 32), 32); + r7 += 64; + } +} + +void sub_8045A5C(u8 a, struct Pokemon *pkmn, u8 c) +{ + u8 r10; + u32 maxhp; + u32 currhp; + + r10 = gSprites[a].data6; + if (GetBankSide(r10) == 0) + { + if (c == 3 || c == 0) + sub_8043FC0(a, GetMonData(pkmn, MON_DATA_LEVEL)); + if (c == 1 || c == 0) + sub_80440EC(a, GetMonData(pkmn, MON_DATA_HP), 0); + if (c == 2 || c == 0) + sub_80440EC(a, GetMonData(pkmn, MON_DATA_MAX_HP), 1); + if (c == 5 || c == 0) + { + load_gfxc_health_bar(0); + maxhp = GetMonData(pkmn, MON_DATA_MAX_HP); + currhp = GetMonData(pkmn, MON_DATA_HP); + sub_8043D84(r10, a, maxhp, currhp, 0); + sub_8045C78(r10, a, 0, 0); + } + if (!IsDoubleBattle() && (c == 6 || c == 0)) + { + u16 species; + u8 level; + u32 exp; + u32 var1; + u32 var2; + u32 currLevelExp; + + load_gfxc_health_bar(3); + species = GetMonData(pkmn, MON_DATA_SPECIES); + level = GetMonData(pkmn, MON_DATA_LEVEL); + exp = GetMonData(pkmn, MON_DATA_EXP); + currLevelExp = gExperienceTables[gBaseStats[species].growthRate][level]; + var1 = exp - currLevelExp; + var2 = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLevelExp; + sub_8043D84(r10, a, var2, var1, 0); + sub_8045C78(r10, a, 1, 0); + } + if (c == 4 || c == 0) + sub_80451A0(a, pkmn); + if (c == 9 || c == 0) + draw_status_ailment_maybe(a); + if (c == 10) + sub_80458B0(a); + if (c == 10 || c == 11) + sub_8045998(a); + } + else + { + if (c == 3 || c == 0) + sub_8043FC0(a, GetMonData(pkmn, MON_DATA_LEVEL)); + if (c == 5 || c == 0) + { + load_gfxc_health_bar(0); + maxhp = GetMonData(pkmn, MON_DATA_MAX_HP); + currhp = GetMonData(pkmn, MON_DATA_HP); + sub_8043D84(r10, a, maxhp, currhp, 0); + sub_8045C78(r10, a, 0, 0); + } + if (c == 4 || c == 0) + sub_80451A0(a, pkmn); + if (c == 9 || c == 0) + draw_status_ailment_maybe(a); + } +} + +s32 sub_8045C78(u8 a, u8 unused1, u8 c, u8 unused2) +{ + s32 r6; + + if (c == 0) + { + r6 = sub_8045F58(ewram17850[a].unk4, ewram17850[a].unk8, ewram17850[a].unkC, &ewram17850[a].unk10, 6, 1); + } + else + { + u16 r5; + s32 r8; + + r5 = GetScaledExpFraction(ewram17850[a].unk8, ewram17850[a].unkC, ewram17850[a].unk4, 8); + if (r5 == 0) + r5 = 1; + r8 = ewram17850[a].unkC; + r5 = ABS(r8 / r5); + r6 = sub_8045F58(ewram17850[a].unk4, ewram17850[a].unk8, r8, &ewram17850[a].unk10, 8, r5); + } + if (c == 1 || (c == 0 && (!ewram17800[a].unk0_4))) + sub_8045D58(a, c); + if (r6 == -1) + ewram17850[a].unk10 = 0; + return r6; +} + +static void sub_8045D58(u8 a, u8 b) +{ + u8 sp8[7]; + u8 r0; + u8 r8; + u8 i; + + switch (b) + { + case 0: + r0 = sub_804602C(ewram17850[a].unk4, ewram17850[a].unk8, ewram17850[a].unkC, &ewram17850[a].unk10, sp8, 6); + r8 = 3; + if (r0 <= 0x18) + { + r8 = 0x38; + if (r0 > 9) + r8 = 0x2F; + } + for (i = 0; i < 6; i++) + { + u8 r4 = gSprites[ewram17850[a].unk0].data5; + if (i < 2) + CpuCopy32(sub_8043CDC(r8) + sp8[i] * 32, (void *)(OBJ_VRAM0 + (gSprites[r4].oam.tileNum + 2 + i) * 32), 32); + else + CpuCopy32(sub_8043CDC(r8) + sp8[i] * 32, (void *)(OBJ_VRAM0 + 64 + (i + gSprites[r4].oam.tileNum) * 32), 32); + } + break; + case 1: + sub_804602C(ewram17850[a].unk4, ewram17850[a].unk8, ewram17850[a].unkC, &ewram17850[a].unk10, sp8, 8); + r0 = GetMonData(&gPlayerParty[gBattlePartyID[a]], MON_DATA_LEVEL); + if (r0 == 100) + { + for (i = 0; i < 8; i++) + sp8[i] = 0; + } + for (i = 0; i < 8; i++) + { + if (i < 4) + CpuCopy32(sub_8043CDC(0xC) + sp8[i] * 32, (void *)(OBJ_VRAM0 + (gSprites[ewram17850[a].unk0].oam.tileNum + 0x24 + i) * 32), 32); + else + CpuCopy32(sub_8043CDC(0xC) + sp8[i] * 32, (void *)(OBJ_VRAM0 + 0xB80 + (i + gSprites[ewram17850[a].unk0].oam.tileNum) * 32), 32); + } + break; + } +} + +static int sub_8045F58(s32 a, s32 b, int c, int *d, u8 e, u16 f) +{ + u8 r2 = e << 3; + int r6; + int ret; + + if (*d == -32768) + { + if (a < r2) + *d = b << 8; + else + *d = b; + } + //_08045F8A + b -= c; + if (b < 0) + b = 0; + else if (b > a) + b = a; + if (a < r2) + { + int var = *d >> 8; + + r6 = *d; + if (b == var && (r6 & 0xFF) == 0) + return -1; + } + else + { + r6 = *d; + if (b == r6) + return -1; + } + //_08045FC4 + if (a < r2) + { + int r0 = (a << 8) / r2; + + if (c < 0) + { + *d = r6 + r0; + ret = *d >> 8; + if (ret >= b) + { + *d = b << 8; + ret = b; + } + } + //_08045FE2 + else + { + *d = r6 - r0; + ret = *d >> 8; + if ((*d & 0xFF) > 0) + ret++; + if (ret <= b) + { + *d = b << 8; + ret = b; + } + } + } + else + { + //_08045FFE + if (c < 0) + { + *d += f; + if (*d > b) + *d = b; + ret = *d; + } + //_08046010 + else + { + *d -= f; + if (*d < b) + *d = b; + ret = *d; + } + } + return ret; +} + +static u8 sub_804602C(int a, int b, int c, int *d, u8 *e, u8 f) +{ + s32 r5 = b - c; + u8 r3; + u8 i; + u8 r2; + + if (r5 < 0) + r5 = 0; + else if (r5 > a) + r5 = a; + r3 = f << 3; + for (i = 0; i < f; i++) + e[i] = 0; + if (a < r3) + r2 = *d * r3 / a >> 8; + else + r2 = *d * r3 / a; + r3 = r2; + if (r3 == 0 && r5 > 0) + { + e[0] = 1; + r3 = 1; + } + else + { + for (i = 0; i < f; i++) + { + if (r2 >= 8) + { + e[i] = 8; + } + else + { + e[i] = r2; + break; + } + r2 -= 8; + } + } + return r3; +} + +s16 sub_80460C8(struct BattleInterfaceStruct1 *a, int *b, void *c, int d) +{ + u16 r7; + s16 r1; + + r7 = sub_8045F58(a->unk0, a->unk4, a->unk8, b, 6, 1); + sub_8046128(a, b, c); + if (a->unk0 < 0x30) + r1 = *b >> 8; + else + r1 = *b; + do_nothing(a->unk0, r1, d); + return r7; +} + +static void sub_8046128(struct BattleInterfaceStruct1 *a, int *b, void *c) +{ + u8 sp8[6]; + u16 sp10[6]; + u8 i; + + sub_804602C(a->unk0, a->unk4, a->unk8, b, (u8 *)sp8, 6); + for (i = 0; i < 6; i++) + sp10[i] = (a->unkC_0 << 12) | (a->unk10 + sp8[i]); + CpuCopy16(sp10, c, sizeof(sp10)); +} + +static u8 GetScaledExpFraction(int a, int b, int c, u8 d) +{ + u8 r7 = d * 8; + int r5 = a - b; + s8 r4; + s8 r0; + s32 result; + + if (r5 < 0) + r5 = 0; + else if (r5 > c) + r5 = c; + + r4 = a * r7 / c; + r0 = r5 * r7 / c; + result = r4 - r0; + return ABS(result); +} + +u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale) +{ + u8 result = hp * scale / maxhp; + + if (result == 0 && hp > 0) + return 1; + return result; +} + +u8 GetHPBarLevel(s16 hp, s16 maxhp) +{ + int result; + + if (hp == maxhp) + result = 4; + else + { + u8 fraction = GetScaledHPFraction(hp, maxhp, 48); + if (fraction > 24) + result = 3; + else if (fraction > 9) + result = 2; + else if (fraction > 0) + result = 1; + else + result = 0; + } + return result; +} diff --git a/src/battle_party_menu.c b/src/battle_party_menu.c new file mode 100644 index 000000000..cf572642e --- /dev/null +++ b/src/battle_party_menu.c @@ -0,0 +1,756 @@ +#include "global.h" +#include "battle_party_menu.h" +#include "battle.h" +#include "item_menu.h" +#include "main.h" +#include "menu.h" +#include "menu_helpers.h" +#include "palette.h" +#include "party_menu.h" +#include "pokemon.h" +#include "pokemon_summary_screen.h" +#include "rom_8077ABC.h" +#include "rom_8094928.h" +#include "songs.h" +#include "sound.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "text.h" + +extern u8 ewram[]; +#define UNK_201606C_ARRAY (ewram + 0x1606C) // lazy define but whatever. + +extern u8 IsLinkDoubleBattle(void); +extern void TryCreatePartyMenuMonIcon(u8, u8, struct Pokemon *); +extern void LoadHeldItemIconGraphics(void); +extern void CreateHeldItemIcons_806DC34(); +extern u8 sub_806BD58(u8, u8); +extern void PartyMenuPrintMonsLevelOrStatus(void); +extern void PrintPartyMenuMonNicknames(void); +extern void PartyMenuTryPrintMonsHP(void); +extern void nullsub_13(void); +extern void PartyMenuDrawHPBars(void); +extern u8 sub_806B58C(u8); +extern u8 GetItemEffectType(); +extern void sub_806E750(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, int); +extern u16 sub_806BD80(); +extern u8 sub_806CA38(); +extern void sub_806D5A4(void); +extern void sub_802E414(void); +extern void sub_80A6DCC(void); +extern void sub_806AF4C(); +extern u8 sub_80F9344(void); +extern u8 sub_806B124(void); +extern void sub_806C994(); +extern void sub_806BF74(); +extern void sub_806AEDC(void); +extern TaskFunc PartyMenuGetPopupMenuFunc(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, u8); +extern void sub_806E7D0(u8, const struct PartyPopupMenu *); +extern u8 *sub_8040D08(); +extern void sub_8040B8C(void); +extern void sub_806E6F0(); +extern void sub_806D538(); +extern void nullsub_14(); +extern void OpenPartyMenu(); +extern u8 sub_803FBBC(void); + +extern u16 gScriptItemId; +extern u8 gPlayerPartyCount; +extern u8 gNoOfAllBanks; +extern u16 gBattlePartyID[]; +extern u8 gBankInMenu; +extern u8 gUnknown_0202E8F4; +extern u8 gUnknown_0202E8F5; +extern u8 gUnknown_0202E8F6; +extern u8 gUnknown_02038470[3]; +extern u8 gUnknown_02038473; +extern u8 gUnknown_020384F0; +extern void (*gUnknown_03004AE4)(); //don't know types yet +extern struct PokemonStorage gPokemonStorage; +extern void nullsub_14(); + +void sub_8094C98(u8, u8); +u8 pokemon_order_func(u8); + +static void sub_8094998(u8[3], u8); +static void sub_8094A74(u8[3], u8, u32); +static void sub_8094D60(void); +static void Task_809527C(u8); +static void Task_80952B4(u8); +static void Task_80952E4(u8); +static void Task_8095330(u8); +static void Task_809538C(void); +static void Task_HandlePopupMenuInput(u8); +static void Task_BattlePartyMenuSummary(u8 taskId); +static void Task_BattlePartyMenuShift(u8 taskId); +static void Task_BattlePartyMenuCancel(u8 taskId); + +static const struct PartyMenuItem sBattlePartyMenuActions[] = +{ + {OtherText_Summary, Task_BattlePartyMenuSummary}, + {gOtherText_CancelNoTerminator, Task_BattlePartyMenuCancel}, + {OtherText_Shift, Task_BattlePartyMenuShift}, + {OtherText_SendOut, Task_BattlePartyMenuShift}, +}; +static const u8 Unknown_83B5FEC[] = {2, 0, 1}; //SHIFT, SUMMARY, CANCEL +static const u8 Unknown_83B5FEF[] = {3, 0, 1}; //SEND OUT, SUMMARY, CANCEL +static const u8 Unknown_83B5FF2[] = {0, 1}; //SUMMARY, CANCEL +static const struct PartyPopupMenu sBattlePartyPopupMenus[] = +{ + {ARRAY_COUNT(Unknown_83B5FEC), 9, Unknown_83B5FEC}, + {ARRAY_COUNT(Unknown_83B5FEF), 9, Unknown_83B5FEF}, + {ARRAY_COUNT(Unknown_83B5FF2), 9, Unknown_83B5FF2}, +}; + +void unref_sub_8094928(struct PokemonStorage *ptr) +{ + *ptr = gPokemonStorage; +} + +void unref_sub_8094940(struct PokemonStorage *ptr) +{ + gPokemonStorage = *ptr; +} + +void sub_8094958(void) +{ + sub_8094998(gUnknown_02038470, sub_803FBBC()); +} + +void sub_8094978(u8 arg1, u8 arg2) +{ + sub_8094A74((UNK_201606C_ARRAY) + arg1 * 3, arg2, arg1); +} + +static void sub_8094998(u8 arg[3], u8 player_number) +{ + int i; + u32 pos; + u8 temp[6]; + if (IsLinkDoubleBattle() == TRUE) + { + if (player_number) + { + *arg = 0x30; + arg[1] = 0x45; + arg[2] = 0x12; + } + else + { + *arg = 0x03; + arg[1] = 0x12; + arg[2] = 0x45; + } + } + else + { + if (!IsDoubleBattle()) + { + pos = 1; + *temp = gBattlePartyID[GetBankByPlayerAI(0)]; + for (i = 0; i <= 5; i++) + if (i != *temp) + temp[pos++] = i; + } + else + { + pos = 2; + *temp = gBattlePartyID[GetBankByPlayerAI(0)]; + temp[1] = gBattlePartyID[GetBankByPlayerAI(2)]; + for (i = 0; i <= 5; i++) + if ((i != *temp) && (i != temp[1])) + temp[pos++] = i; + } + for (i = 0; i <= 2; i++) + arg[i] = (temp[i << 1] << 4) | temp[(i << 1) + 1]; + } +} + +static void sub_8094A74(u8 arg[3], u8 player_number, u32 arg3) +{ + int i, j; + u8 temp[6]; + if (!GetBankSide(arg3)) + { + i = GetBankByPlayerAI(0); + j = GetBankByPlayerAI(2); + } + else + { + i = GetBankByPlayerAI(1); + j = GetBankByPlayerAI(3); + } + if (IsLinkDoubleBattle() == TRUE) + { + if (player_number) + { + *arg = 0x30; + arg[1] = 0x45; + arg[2] = 0x12; + } + else + { + *arg = 0x03; + arg[1] = 0x12; + arg[2] = 0x45; + } + } + else + { + if (!IsDoubleBattle()) + { + int pos = 1; + *temp = gBattlePartyID[i]; + for (i = 0; i <= 5; i++) + if (i != *temp) + temp[pos++] = i; + } + else + { + int pos = 2; + *temp = gBattlePartyID[i]; + temp[1] = gBattlePartyID[j]; + for (i = 0; i <= 5; i++) + if ((i != *temp) && (i != temp[1])) + temp[pos++] = i; + } + for (i = 0; i <= 2; i++) + arg[i] = (temp[i << 1] << 4) | temp[(i << 1) + 1]; + } +} + +void sub_8094B6C(u8 a, u8 b, u8 c) +{ + s32 i; + s32 j; + u8 temp[6]; + u8 r3; + u8 r7 = 0; + + if (IsLinkDoubleBattle()) + { + u8 *arr = ewram + 0x1606C + a * 3; + + for (i = 0, j = 0; i < 3; i++) + { + temp[j++] = arr[i] >> 4; + temp[j++] = arr[i] & 0xF; + } + r3 = temp[c]; + for (i = 0; i < 6; i++) + { + if (temp[i] == b) + { + r7 = temp[i]; + temp[i] = r3; + break; + } + } + if (i != 6) + { + temp[c] = r7; + + arr[0] = (temp[0] << 4) | temp[1]; + arr[1] = (temp[2] << 4) | temp[3]; + arr[2] = (temp[4] << 4) | temp[5]; + } + } +} + +u8 sub_8094C20(u8 a) +{ + u8 retVal; + u8 val = a & 1; + + a /= 2; + if (val) + retVal = gUnknown_02038470[a] & 0xF; + else + retVal = gUnknown_02038470[a] >> 4; + return retVal; +} + +void sub_8094C54(u8 a, u8 b) +{ + u8 val = a & 1; + + a /= 2; + if (val) + gUnknown_02038470[a] = (gUnknown_02038470[a] & 0xF0) | b; + else + gUnknown_02038470[a] = (gUnknown_02038470[a] & 0xF) | (b << 4); +} + +void sub_8094C98(u8 a, u8 b) +{ + u8 r4 = sub_8094C20(a); + u8 r1 = sub_8094C20(b); + + sub_8094C54(a, r1); + sub_8094C54(b, r4); +} + +u8 pokemon_order_func(u8 a) +{ + u8 i; + u8 r2; + + for (i = 0, r2 = 0; i < 3; i++) + { + if ((gUnknown_02038470[i] >> 4) == a) + return r2; + r2++; + if ((gUnknown_02038470[i] & 0xF) == a) + return r2; + r2++; + } + return 0; +} + +void pokemon_change_order(void) +{ + u8 i; + + memcpy(ewram1B000.unk0, gPlayerParty, sizeof(gPlayerParty)); + for (i = 0; i < 6; i++) + { + u8 n = pokemon_order_func(i); + + memcpy(&gPlayerParty[n], &ewram1B000.unk0[i], sizeof(struct Pokemon)); + } +} + +static void sub_8094D60(void) +{ + struct Pokemon temp[6]; + u8 i; + + memcpy(temp, gPlayerParty, sizeof(gPlayerParty)); + for (i = 0; i < 6; i++) + { + u8 n = sub_8094C20(i); + + memcpy(&gPlayerParty[n], &temp[i], sizeof(struct Pokemon)); + } +} + +void unref_sub_8094DB0(void) +{ + u8 i; + u8 r4; + + for (i = 1; i < 6; i++) + { + u8 n = sub_8094C20(i); + + if (GetMonData(&gPlayerParty[n], MON_DATA_SPECIES) != 0 + && GetMonData(&gPlayerParty[n], MON_DATA_HP) != 0) + { + r4 = sub_8094C20(0); + sub_8094C98(0, i); + sub_806E6F0(&gPlayerParty[r4], &gPlayerParty[n]); + break; + } + } +} + +void sub_8094E20(u8 a) +{ + gPaletteFade.bufferTransferDisabled = TRUE; + gUnknown_02038473 = a; + nullsub_14(); + pokemon_change_order(); + OpenPartyMenu(1, 0xFF); +} + +void sub_8094E4C(void) +{ + sub_8094E20(3); +} + +int SetUpBattlePartyMenu(void) +{ + switch (EWRAM_1B000.unk264) + //switch (ewram1B000.unk264[0]) + { + case 0: + //TODO: try to get rid of this duplicate code + if (IsLinkDoubleBattle() == TRUE) + { + if (EWRAM_1B000.unk266 != 6) + { + TryCreatePartyMenuMonIcon(EWRAM_1B000.unk260, EWRAM_1B000.unk266, &gPlayerParty[EWRAM_1B000.unk266]); + EWRAM_1B000.unk266++; + } + else + { + EWRAM_1B000.unk266 = 0; + EWRAM_1B000.unk264++; + } + } + else + { + if (EWRAM_1B000.unk266 < 6) + { + TryCreatePartyMenuMonIcon(EWRAM_1B000.unk260, EWRAM_1B000.unk266, &gPlayerParty[EWRAM_1B000.unk266]); + EWRAM_1B000.unk266++; + } + else + { + EWRAM_1B000.unk266 = 0; + EWRAM_1B000.unk264++; + } + } + break; + case 1: + LoadHeldItemIconGraphics(); + EWRAM_1B000.unk264++; + break; + case 2: + CreateHeldItemIcons_806DC34(EWRAM_1B000.unk260); + EWRAM_1B000.unk264++; + break; + case 3: + if (sub_806BD58(EWRAM_1B000.unk260, EWRAM_1B000.unk266) == 1) + { + EWRAM_1B000.unk266 = 0; + EWRAM_1B000.unk264++; + } + else + EWRAM_1B000.unk266++; + break; + case 4: + PartyMenuPrintMonsLevelOrStatus(); + EWRAM_1B000.unk264++; + break; + case 5: + PrintPartyMenuMonNicknames(); + EWRAM_1B000.unk264++; + break; + case 6: + PartyMenuTryPrintMonsHP(); + EWRAM_1B000.unk264++; + break; + case 7: + nullsub_13(); + EWRAM_1B000.unk264++; + break; + case 8: + PartyMenuDrawHPBars(); + EWRAM_1B000.unk264++; + break; + case 9: + if (sub_806B58C(EWRAM_1B000.unk266) == 1) + { + EWRAM_1B000.unk266 = 0; + EWRAM_1B000.unk264++; + } + else + EWRAM_1B000.unk266++; + break; + case 10: + if (gUnknown_02038473 == 3) + { + if (GetItemEffectType(gScriptItemId) == 10) + ewram1B000.unk259 = 0xFF; + else + ewram1B000.unk259 = 3; + } + return TRUE; + } + return FALSE; +} + +static void sub_8095050(u8 a, u8 b) +{ + if (!GetMonData(&gPlayerParty[b], MON_DATA_IS_EGG)) + { + if (gUnknown_02038473 == 1) + { + gTasks[EWRAM_1B000.unk260].data[4] = 1; + gTasks[EWRAM_1B000.unk260].data[5] = 1; + } + else + { + gTasks[EWRAM_1B000.unk260].data[4] = 0; + gTasks[EWRAM_1B000.unk260].data[5] = 0; + } + } + else + { + gTasks[EWRAM_1B000.unk260].data[4] = 2; + gTasks[EWRAM_1B000.unk260].data[5] = 2; + } + sub_806E750(gTasks[a].data[4], sBattlePartyPopupMenus, sBattlePartyMenuActions, 0); +} + +void SetUpBattlePokemonMenu(u8 a) +{ + if (!gPaletteFade.active) + { + if (gUnknown_02038473 == 3 && GetItemEffectType(gScriptItemId) == 10) + { + gUnknown_03004AE4(a, gScriptItemId, Task_80952E4); + return; + } + + switch (sub_806BD80(a)) + { + case 1: + if (gUnknown_02038473 == 3) + { + if (GetMonData(&gPlayerParty[sub_806CA38(a)], MON_DATA_IS_EGG)) + PlaySE(SE_HAZURE); + else + { + sub_806D5A4(); + gUnknown_03004AE4(a, gScriptItemId, Task_80952E4); + } + } + else + { + PlaySE(SE_SELECT); + GetMonNickname(&gPlayerParty[sub_806CA38(a)], gStringVar1); + sub_8095050(a, sub_806CA38(a)); + SetTaskFuncWithFollowupFunc(a, Task_HandlePopupMenuInput, SetUpBattlePokemonMenu); + } + break; + case 2: + if (gUnknown_02038473 == 1) + PlaySE(SE_HAZURE); + else + { + PlaySE(SE_SELECT); + if (gUnknown_02038473 == 3) + { + gUnknown_0202E8F4 = 0; + gTasks[a].func = Task_80952E4; + } + else + { + gUnknown_0202E8F4 = 0; + gTasks[a].func = Task_809527C; + } + } + break; + } + } +} + +static void Task_809527C(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = Task_80952B4; +} + +static void Task_80952B4(u8 taskId) +{ + if (!gPaletteFade.active) + { + sub_8094D60(); + DestroyTask(taskId); + SetMainCallback2(sub_802E414); + } +} + +static void Task_80952E4(u8 taskId) +{ + if (gUnknown_0202E8F4 != 0) + Task_809527C(taskId); + else + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = Task_8095330; + } +} + +static void Task_8095330(u8 taskId) +{ + if (!gPaletteFade.active) + { + sub_8094D60(); + DestroyTask(taskId); + sub_80A6DCC(); + } +} + +static void Task_809535C(void) +{ + gPaletteFade.bufferTransferDisabled = TRUE; + sub_806AF4C(1, 0xFF, SetUpBattlePokemonMenu, 5); + SetMainCallback2(Task_809538C); +} + +static void Task_809538C(void) +{ + do + { + if (sub_806B124() == 1) + { + sub_806C994(EWRAM_1B000.unk260, gUnknown_020384F0); + sub_806BF74(EWRAM_1B000.unk260, 0); + GetMonNickname(&gPlayerParty[gUnknown_020384F0], gStringVar1); + sub_8095050(EWRAM_1B000.unk260, gUnknown_020384F0); + SetTaskFuncWithFollowupFunc(EWRAM_1B000.unk260, Task_HandlePopupMenuInput, SetUpBattlePokemonMenu); + SetMainCallback2(sub_806AEDC); + return; + } + } while (sub_80F9344() != 1); +} + +static void Task_HandlePopupMenuInput(u8 taskId) +{ + TaskFunc func; + + if (!gPaletteFade.active) + { + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + return; + } + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + return; + } + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + func = PartyMenuGetPopupMenuFunc(gTasks[taskId].data[4], + sBattlePartyPopupMenus, + sBattlePartyMenuActions, + GetMenuCursorPos()); + func(taskId); + return; + } + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + Task_BattlePartyMenuCancel(taskId); + return; + } + } +} + +static void Task_80954C0(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + Task_BattlePartyMenuCancel(taskId); +} + +static void Task_ShowSummaryScreen(u8 taskId) +{ + u8 partySelection = sub_806CA38(taskId); + + if (!gPaletteFade.active) + { + DestroyTask(taskId); + EWRAM_1B000.unk262 = 1; + ShowPokemonSummaryScreen(gPlayerParty, partySelection, gPlayerPartyCount - 1, Task_809535C, 4); + } +} + +static void Task_BattlePartyMenuSummary(u8 taskId) +{ + sub_806CA38(taskId); //an unused variable was probably set with this. + gTasks[taskId].func = Task_ShowSummaryScreen; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); +} + +static void Task_BattlePartyMenuShift(u8 taskId) +{ + u8 partySelection; + u8 i; + u8 r4; + + sub_806E7D0(gTasks[taskId].data[4], sBattlePartyPopupMenus); + partySelection = sub_806CA38(taskId); + if (IsLinkDoubleBattle() == TRUE && (partySelection == 1 || partySelection == 4 || partySelection == 5)) + { + sub_806D5A4(); + StringCopy(gStringVar1, sub_8040D08()); + StringExpandPlaceholders(gStringVar4, gOtherText_CantSwitchPokeWithYours); + sub_806E834(gStringVar4, 0); + gTasks[taskId].func = Task_80954C0; + return; + } + if (GetMonData(&gPlayerParty[partySelection], MON_DATA_HP) == 0) + { + sub_806D5A4(); + GetMonNickname(&gPlayerParty[partySelection], gStringVar1); + StringExpandPlaceholders(gStringVar4, gOtherText_NoEnergyLeft); + sub_806E834(gStringVar4, 0); + gTasks[taskId].func = Task_80954C0; + return; + } + for (i = 0; i < gNoOfAllBanks; i++) + { + if (GetBankSide(i) == 0 + && sub_8094C20(partySelection) == gBattlePartyID[i]) + { + sub_806D5A4(); + GetMonNickname(&gPlayerParty[partySelection], gStringVar1); + StringExpandPlaceholders(gStringVar4, gOtherText_AlreadyBattle); + sub_806E834(gStringVar4, 0); + gTasks[taskId].func = Task_80954C0; + return; + } + } + if (GetMonData(&gPlayerParty[partySelection], MON_DATA_IS_EGG)) + { + sub_806D5A4(); + StringExpandPlaceholders(gStringVar4, gOtherText_EGGCantBattle); + sub_806E834(gStringVar4, 0); + gTasks[taskId].func = Task_80954C0; + return; + } + if (sub_8094C20(partySelection) == EWRAM_1609D) + { + sub_806D5A4(); + GetMonNickname(&gPlayerParty[partySelection], gStringVar1); + StringExpandPlaceholders(gStringVar4, gOtherText_AlreadySelected); + sub_806E834(gStringVar4, 0); + gTasks[taskId].func = Task_80954C0; + return; + } + if (gUnknown_02038473 == 4) + { + sub_806D5A4(); + sub_8040B8C(); + sub_806E834(gStringVar4, 0); + gTasks[taskId].func = Task_80954C0; + return; + } + if (gUnknown_02038473 == 2) + { + u8 r0; + u8 r4 = gBankInMenu; + + sub_806D5A4(); + r0 = pokemon_order_func(gBattlePartyID[r4]); + GetMonNickname(&gPlayerParty[r0], gStringVar1); + StringExpandPlaceholders(gStringVar4, gOtherText_CantBeSwitched); + sub_806E834(gStringVar4, 0); + gTasks[taskId].func = Task_80954C0; + return; + } + gUnknown_0202E8F5 = sub_8094C20(partySelection); + gUnknown_0202E8F4 = 1; + r4 = pokemon_order_func(gBattlePartyID[gBankInMenu]); + sub_8094C98(r4, partySelection); + sub_806E6F0(&gPlayerParty[r4], &gPlayerParty[partySelection]); + gTasks[taskId].func = Task_809527C; +} + +static void Task_BattlePartyMenuCancel(u8 taskId) +{ + HandleDestroyMenuCursors(); + sub_806E7D0(gTasks[taskId].data[4], sBattlePartyPopupMenus); + gTasks[taskId].data[4] = gTasks[taskId].data[5]; + sub_806D538(0, 0); + SwitchTaskToFollowupFunc(taskId); +} diff --git a/src/battle_records.c b/src/battle_records.c new file mode 100644 index 000000000..cf86787f0 --- /dev/null +++ b/src/battle_records.c @@ -0,0 +1,22 @@ +#include "global.h" +#include "battle_records.h" +#include "menu.h" +#include "strings2.h" + +void ShowLinkBattleRecords(void) { + s32 i; + MenuDrawTextWindow(1, 0, 28, 18); + sub_8072BD8((u8 *) gOtherText_BattleResults, 0, 1, 240); + + PrintLinkBattleWinsLossesDraws(gSaveBlock1.linkBattleRecords); +#if ENGLISH + MenuPrint(gOtherText_WinLoseDraw, 12, 6); +#elif GERMAN + MenuPrint_PixelCoords((u8 *) gOtherText_WinLoseDraw, 88, 48, 1); +#endif + + for (i = 0; i < 5; i++) + { + PrintLinkBattleRecord(gSaveBlock1.linkBattleRecords[i], 6 + (i + 1) * 2); + } +} diff --git a/src/battle_setup.c b/src/battle_setup.c index 0174c794f..adcbe8eaa 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1,81 +1,41 @@ #include "global.h" #include "battle_setup.h" -#include "asm.h" -#include "safari_zone.h" -#include "weather.h" -#include "palette.h" -#include "field_player_avatar.h" -#include "rom4.h" #include "battle.h" +#include "battle_transition.h" +#include "data2.h" +#include "event_data.h" +#include "field_control_avatar.h" +#include "field_fadetransition.h" +#include "field_map_obj_helpers.h" +#include "field_message_box.h" +#include "field_player_avatar.h" +#include "field_weather.h" +#include "fieldmap.h" +#include "fldeff_80C5CD4.h" #include "main.h" -#include "species.h" +#include "map_constants.h" +#include "metatile_behavior.h" +#include "opponent_constants.h" +#include "palette.h" +#include "rng.h" +#include "rom4.h" +#include "safari_zone.h" +#include "script.h" +#include "script_pokemon_80C4.h" +#include "secret_base.h" #include "songs.h" #include "sound.h" -#include "task.h" +#include "species.h" +#include "starter_choose.h" #include "string_util.h" -#include "rng.h" -#include "flag.h" -#include "var.h" -#include "script.h" -#include "field_message_box.h" +#include "strings.h" +#include "task.h" +#include "text.h" #include "trainer.h" -#include "starter_choose.h" - -#define NUM_TRAINER_EYE_TRAINERS 56 -#define TRAINER_REMATCH_STEPS 255 extern u16 gScriptResult; -struct TrainerPartyMember0 -{ - u16 iv; - u8 level; - u16 species; -}; - -struct TrainerPartyMember1 -{ - u16 iv; - u8 level; - u16 species; - u16 moves[4]; -}; - -struct TrainerPartyMember2 -{ - u16 iv; - u8 level; - u16 species; - u16 heldItem; -}; - -struct TrainerPartyMember3 -{ - u16 iv; - u8 level; - u16 species; - u16 heldItem; - u16 moves[4]; -}; - -struct TrainerBattleSpec -{ - void *ptr; - u8 ptrType; -}; - -struct TrainerEyeTrainer -{ - u16 trainerNums[5]; - u16 mapGroup; - u16 mapNum; -}; - -extern void (*gUnknown_0300485C)(void); - -extern struct Pokemon gEnemyParty[]; -extern struct Pokemon gPlayerParty[]; -extern struct Trainer gTrainers[]; +extern void (*gFieldCallback)(void); EWRAM_DATA u16 gTrainerBattleMode = 0; EWRAM_DATA u16 gTrainerBattleOpponent = 0; @@ -87,14 +47,9 @@ EWRAM_DATA u8 *gTrainerCannotBattleSpeech = NULL; EWRAM_DATA u8 *gTrainerBattleScriptReturnAddress = NULL; EWRAM_DATA u8 *gTrainerBattleEndScript = NULL; -extern struct TrainerEyeTrainer gTrainerEyeTrainers[]; - -extern u8 gOtherText_CancelWithTerminator[]; - -extern u16 gUnknown_020239F8; +extern u16 gBattleTypeFlags; extern u16 gScriptLastTalked; -extern u8 gUnknown_02024D26; -extern u16 gBadgeFlags[]; +extern u8 gBattleOutcome; extern struct MapObject gMapObjects[]; @@ -107,16 +62,367 @@ extern u8 gUnknown_0819F8AE[]; extern u8 gUnknown_0819F80B[]; extern u8 gUnknown_081C6C02[]; -extern struct TrainerBattleSpec gTrainerBattleSpecs_0[]; -extern struct TrainerBattleSpec gTrainerBattleSpecs_1[]; -extern struct TrainerBattleSpec gTrainerBattleSpecs_2[]; -extern struct TrainerBattleSpec gTrainerBattleSpecs_3[]; -extern struct TrainerBattleSpec gTrainerBattleSpecs_4[]; -extern u8 gStringVar4[]; +static const u8 gBattleTransitionTable_Wild[][2] = +{ + {8, 9}, + {5, 10}, + {0, 10}, + {7, 6}, +}; +static const u8 gBattleTransitionTable_Trainer[][2] = +{ + {4, 11}, + {2, 3}, + {0, 10}, + {1, 6}, +}; +static const struct TrainerBattleSpec gTrainerBattleSpecs_0[] = +{ + {&gTrainerBattleMode, 0}, + {&gTrainerBattleOpponent, 1}, + {&gTrainerMapObjectLocalId, 1}, + {&gTrainerIntroSpeech, 2}, + {&gTrainerDefeatSpeech, 2}, + {&gTrainerVictorySpeech, 5}, + {&gTrainerCannotBattleSpeech, 5}, + {&gTrainerBattleEndScript, 5}, + {&gTrainerBattleScriptReturnAddress, 6}, +}; +static const struct TrainerBattleSpec gTrainerBattleSpecs_1[] = +{ + {&gTrainerBattleMode, 0}, + {&gTrainerBattleOpponent, 1}, + {&gTrainerMapObjectLocalId, 1}, + {&gTrainerIntroSpeech, 2}, + {&gTrainerDefeatSpeech, 2}, + {&gTrainerVictorySpeech, 5}, + {&gTrainerCannotBattleSpeech, 5}, + {&gTrainerBattleEndScript, 2}, + {&gTrainerBattleScriptReturnAddress, 6}, +}; +static const struct TrainerBattleSpec gTrainerBattleSpecs_2[] = +{ + {&gTrainerBattleMode, 0}, + {&gTrainerBattleOpponent, 1}, + {&gTrainerMapObjectLocalId, 1}, + {&gTrainerIntroSpeech, 2}, + {&gTrainerDefeatSpeech, 2}, + {&gTrainerVictorySpeech, 5}, + {&gTrainerCannotBattleSpeech, 2}, + {&gTrainerBattleEndScript, 5}, + {&gTrainerBattleScriptReturnAddress, 6}, +}; +static const struct TrainerBattleSpec gTrainerBattleSpecs_3[] = +{ + {&gTrainerBattleMode, 0}, + {&gTrainerBattleOpponent, 1}, + {&gTrainerMapObjectLocalId, 1}, + {&gTrainerIntroSpeech, 5}, + {&gTrainerDefeatSpeech, 2}, + {&gTrainerVictorySpeech, 5}, + {&gTrainerCannotBattleSpeech, 5}, + {&gTrainerBattleEndScript, 5}, + {&gTrainerBattleScriptReturnAddress, 6}, +}; +static const struct TrainerBattleSpec gTrainerBattleSpecs_4[] = +{ + {&gTrainerBattleMode, 0}, + {&gTrainerBattleOpponent, 1}, + {&gTrainerMapObjectLocalId, 1}, + {&gTrainerIntroSpeech, 2}, + {&gTrainerDefeatSpeech, 2}, + {&gTrainerVictorySpeech, 5}, + {&gTrainerCannotBattleSpeech, 2}, + {&gTrainerBattleEndScript, 2}, + {&gTrainerBattleScriptReturnAddress, 6}, +}; + +const struct TrainerEyeTrainer gTrainerEyeTrainers[] = +{ + { + {OPPONENT_ROSE_1, OPPONENT_ROSE_2, OPPONENT_ROSE_3, OPPONENT_ROSE_4, OPPONENT_ROSE_5}, + MAP_GROUP_ROUTE118, + MAP_ID_ROUTE118, + }, + { + {OPPONENT_DUSTY_1, OPPONENT_DUSTY_2, OPPONENT_DUSTY_3, OPPONENT_DUSTY_4, OPPONENT_DUSTY_5}, + MAP_GROUP_ROUTE111, + MAP_ID_ROUTE111, + }, + { + {OPPONENT_LOLA_1, OPPONENT_LOLA_2, OPPONENT_LOLA_3, OPPONENT_LOLA_4, OPPONENT_LOLA_5}, + MAP_GROUP_ROUTE109, + MAP_ID_ROUTE109, + }, + { + {OPPONENT_RICKY_1, OPPONENT_RICKY_2, OPPONENT_RICKY_3, OPPONENT_RICKY_4, OPPONENT_RICKY_5}, + MAP_GROUP_ROUTE109, + MAP_ID_ROUTE109, + }, + { + {OPPONENT_RITA_AND_SAM_1, OPPONENT_RITA_AND_SAM_2, OPPONENT_RITA_AND_SAM_3, OPPONENT_RITA_AND_SAM_4, OPPONENT_RITA_AND_SAM_5}, + MAP_GROUP_ROUTE124, + MAP_ID_ROUTE124, + }, + { + {OPPONENT_BROOKE_1, OPPONENT_BROOKE_2, OPPONENT_BROOKE_3, OPPONENT_BROOKE_4, OPPONENT_BROOKE_5}, + MAP_GROUP_ROUTE111, + MAP_ID_ROUTE111, + }, + { + {OPPONENT_WILTON_1, OPPONENT_WILTON_2, OPPONENT_WILTON_3, OPPONENT_WILTON_4, OPPONENT_WILTON_5}, + MAP_GROUP_ROUTE111, + MAP_ID_ROUTE111, + }, + { + {OPPONENT_VALERIE_1, OPPONENT_VALERIE_2, OPPONENT_VALERIE_3, OPPONENT_VALERIE_4, OPPONENT_VALERIE_5}, + MAP_GROUP_MT_PYRE_6F, + MAP_ID_MT_PYRE_6F, + }, + { + {OPPONENT_CINDY_1, OPPONENT_CINDY_3, OPPONENT_CINDY_4, OPPONENT_CINDY_5, OPPONENT_CINDY_6}, + MAP_GROUP_ROUTE104, + MAP_ID_ROUTE104, + }, + { + {OPPONENT_JESSICA_1, OPPONENT_JESSICA_2, OPPONENT_JESSICA_3, OPPONENT_JESSICA_4, OPPONENT_JESSICA_5}, + MAP_GROUP_ROUTE121, + MAP_ID_ROUTE121, + }, + { + {OPPONENT_WINSTON_1, OPPONENT_WINSTON_2, OPPONENT_WINSTON_3, OPPONENT_WINSTON_4, OPPONENT_WINSTON_5}, + MAP_GROUP_ROUTE104, + MAP_ID_ROUTE104, + }, + { + {OPPONENT_STEVE_1, OPPONENT_STEVE_2, OPPONENT_STEVE_3, OPPONENT_STEVE_4, OPPONENT_STEVE_5}, + MAP_GROUP_ROUTE114, + MAP_ID_ROUTE114, + }, + { + {OPPONENT_TONY_1, OPPONENT_TONY_2, OPPONENT_TONY_3, OPPONENT_TONY_4, OPPONENT_TONY_5}, + MAP_GROUP_ROUTE107, + MAP_ID_ROUTE107, + }, + { + {OPPONENT_NOB_1, OPPONENT_NOB_2, OPPONENT_NOB_3, OPPONENT_NOB_4, OPPONENT_NOB_5}, + MAP_GROUP_ROUTE115, + MAP_ID_ROUTE115, + }, + { + {OPPONENT_DALTON_1, OPPONENT_DALTON_2, OPPONENT_DALTON_3, OPPONENT_DALTON_4, OPPONENT_DALTON_5}, + MAP_GROUP_ROUTE118, + MAP_ID_ROUTE118, + }, + { + {OPPONENT_BERNIE_1, OPPONENT_BERNIE_2, OPPONENT_BERNIE_3, OPPONENT_BERNIE_4, OPPONENT_BERNIE_5}, + MAP_GROUP_ROUTE114, + MAP_ID_ROUTE114, + }, + { + {OPPONENT_ETHAN_1, OPPONENT_ETHAN_2, OPPONENT_ETHAN_3, OPPONENT_ETHAN_4, OPPONENT_ETHAN_5}, + MAP_GROUP_JAGGED_PASS, + MAP_ID_JAGGED_PASS, + }, + { + {OPPONENT_JOHN_AND_JAY_1, OPPONENT_JOHN_AND_JAY_2, OPPONENT_JOHN_AND_JAY_3, OPPONENT_JOHN_AND_JAY_4, OPPONENT_JOHN_AND_JAY_5}, + MAP_GROUP_METEOR_FALLS_1F_2R, + MAP_ID_METEOR_FALLS_1F_2R, + }, + { + {OPPONENT_BRANDON_1, OPPONENT_BRANDON_2, OPPONENT_BRANDON_3, OPPONENT_BRANDON_4, OPPONENT_BRANDON_5}, + MAP_GROUP_ROUTE120, + MAP_ID_ROUTE120, + }, + { + {OPPONENT_CAMERON_1, OPPONENT_CAMERON_2, OPPONENT_CAMERON_3, OPPONENT_CAMERON_4, OPPONENT_CAMERON_5}, + MAP_GROUP_ROUTE123, + MAP_ID_ROUTE123, + }, + { + {OPPONENT_JACKI_1, OPPONENT_JACKI_2, OPPONENT_JACKI_3, OPPONENT_JACKI_4, OPPONENT_JACKI_5}, + MAP_GROUP_ROUTE123, + MAP_ID_ROUTE123, + }, + { + {OPPONENT_WALTER_1, OPPONENT_WALTER_2, OPPONENT_WALTER_3, OPPONENT_WALTER_4, OPPONENT_WALTER_5}, + MAP_GROUP_ROUTE121, + MAP_ID_ROUTE121, + }, + { + {OPPONENT_KAREN_1, OPPONENT_KAREN_2, OPPONENT_KAREN_3, OPPONENT_KAREN_4, OPPONENT_KAREN_5}, + MAP_GROUP_ROUTE116, + MAP_ID_ROUTE116, + }, + { + {OPPONENT_JERRY_1, OPPONENT_JERRY_2, OPPONENT_JERRY_3, OPPONENT_JERRY_4, OPPONENT_JERRY_5}, + MAP_GROUP_ROUTE116, + MAP_ID_ROUTE116, + }, + { + {OPPONENT_ANNA_AND_MEG_1, OPPONENT_ANNA_AND_MEG_2, OPPONENT_ANNA_AND_MEG_3, OPPONENT_ANNA_AND_MEG_4, OPPONENT_ANNA_AND_MEG_5}, + MAP_GROUP_ROUTE117, + MAP_ID_ROUTE117, + }, + { + {OPPONENT_ISABEL_1, OPPONENT_ISABEL_2, OPPONENT_ISABEL_3, OPPONENT_ISABEL_4, OPPONENT_ISABEL_5}, + MAP_GROUP_ROUTE110, + MAP_ID_ROUTE110, + }, + { + {OPPONENT_MIGUEL_1, OPPONENT_MIGUEL_2, OPPONENT_MIGUEL_3, OPPONENT_MIGUEL_4, OPPONENT_MIGUEL_5}, + MAP_GROUP_ROUTE103, + MAP_ID_ROUTE103, + }, + { + {OPPONENT_TIMOTHY_1, OPPONENT_TIMOTHY_2, OPPONENT_TIMOTHY_3, OPPONENT_TIMOTHY_4, OPPONENT_TIMOTHY_5}, + MAP_GROUP_ROUTE115, + MAP_ID_ROUTE115, + }, + { + {OPPONENT_SHELBY_1, OPPONENT_SHELBY_2, OPPONENT_SHELBY_3, OPPONENT_SHELBY_4, OPPONENT_SHELBY_5}, + MAP_GROUP_MT_CHIMNEY, + MAP_ID_MT_CHIMNEY, + }, + { + {OPPONENT_CALVIN_1, OPPONENT_CALVIN_2, OPPONENT_CALVIN_3, OPPONENT_CALVIN_4, OPPONENT_CALVIN_5}, + MAP_GROUP_ROUTE102, + MAP_ID_ROUTE102, + }, + { + {OPPONENT_ELLIOT_1, OPPONENT_ELLIOT_2, OPPONENT_ELLIOT_3, OPPONENT_ELLIOT_4, OPPONENT_ELLIOT_5}, + MAP_GROUP_ROUTE106, + MAP_ID_ROUTE106, + }, + { + {OPPONENT_ABIGAIL_1, OPPONENT_ABIGAIL_2, OPPONENT_ABIGAIL_3, OPPONENT_ABIGAIL_4, OPPONENT_ABIGAIL_5}, + MAP_GROUP_ROUTE110, + MAP_ID_ROUTE110, + }, + { + {OPPONENT_BENJAMIN_1, OPPONENT_BENJAMIN_2, OPPONENT_BENJAMIN_3, OPPONENT_BENJAMIN_4, OPPONENT_BENJAMIN_5}, + MAP_GROUP_ROUTE110, + MAP_ID_ROUTE110, + }, + { + {OPPONENT_ISAIAH_1, OPPONENT_ISAIAH_2, OPPONENT_ISAIAH_3, OPPONENT_ISAIAH_4, OPPONENT_ISAIAH_5}, + MAP_GROUP_ROUTE128, + MAP_ID_ROUTE128, + }, + { + {OPPONENT_KATELYN_1, OPPONENT_KATELYN_2, OPPONENT_KATELYN_3, OPPONENT_KATELYN_4, OPPONENT_KATELYN_5}, + MAP_GROUP_ROUTE128, + MAP_ID_ROUTE128, + }, + { + {OPPONENT_MARIA_1, OPPONENT_MARIA_2, OPPONENT_MARIA_3, OPPONENT_MARIA_4, OPPONENT_MARIA_5}, + MAP_GROUP_ROUTE117, + MAP_ID_ROUTE117, + }, + { + {OPPONENT_DYLAN_1, OPPONENT_DYLAN_2, OPPONENT_DYLAN_3, OPPONENT_DYLAN_4, OPPONENT_DYLAN_5}, + MAP_GROUP_ROUTE117, + MAP_ID_ROUTE117, + }, + { + {OPPONENT_NICOLAS_1, OPPONENT_NICOLAS_2, OPPONENT_NICOLAS_3, OPPONENT_NICOLAS_4, OPPONENT_NICOLAS_5}, + MAP_GROUP_METEOR_FALLS_1F_2R, + MAP_ID_METEOR_FALLS_1F_2R, + }, + { + {OPPONENT_ROBERT_1, OPPONENT_ROBERT_2, OPPONENT_ROBERT_3, OPPONENT_ROBERT_4, OPPONENT_ROBERT_5}, + MAP_GROUP_ROUTE120, + MAP_ID_ROUTE120, + }, + { + {OPPONENT_LAO_1, OPPONENT_LAO_2, OPPONENT_LAO_3, OPPONENT_LAO_4, OPPONENT_LAO_5}, + MAP_GROUP_ROUTE113, + MAP_ID_ROUTE113, + }, + { + {OPPONENT_CYNDY_1, OPPONENT_CYNDY_2, OPPONENT_CYNDY_3, OPPONENT_CYNDY_4, OPPONENT_CYNDY_5}, + MAP_GROUP_ROUTE115, + MAP_ID_ROUTE115, + }, + { + {OPPONENT_MADELINE_1, OPPONENT_MADELINE_2, OPPONENT_MADELINE_3, OPPONENT_MADELINE_4, OPPONENT_MADELINE_5}, + MAP_GROUP_ROUTE113, + MAP_ID_ROUTE113, + }, + { + {OPPONENT_JENNY_1, OPPONENT_JENNY_2, OPPONENT_JENNY_3, OPPONENT_JENNY_4, OPPONENT_JENNY_5}, + MAP_GROUP_ROUTE124, + MAP_ID_ROUTE124, + }, + { + {OPPONENT_DIANA_1, OPPONENT_DIANA_2, OPPONENT_DIANA_3, OPPONENT_DIANA_4, OPPONENT_DIANA_5}, + MAP_GROUP_JAGGED_PASS, + MAP_ID_JAGGED_PASS, + }, + { + {OPPONENT_AMY_AND_LIV_1, OPPONENT_AMY_AND_LIV_2, OPPONENT_AMY_AND_LIV_4, OPPONENT_AMY_AND_LIV_5, OPPONENT_AMY_AND_LIV_6}, + MAP_GROUP_ROUTE103, + MAP_ID_ROUTE103, + }, + { + {OPPONENT_ERNEST_1, OPPONENT_ERNEST_2, OPPONENT_ERNEST_3, OPPONENT_ERNEST_4, OPPONENT_ERNEST_5}, + MAP_GROUP_ROUTE125, + MAP_ID_ROUTE125, + }, + { + {OPPONENT_EDWIN_1, OPPONENT_EDWIN_2, OPPONENT_EDWIN_3, OPPONENT_EDWIN_4, OPPONENT_EDWIN_5}, + MAP_GROUP_ROUTE110, + MAP_ID_ROUTE110, + }, + { + {OPPONENT_LYDIA_1, OPPONENT_LYDIA_2, OPPONENT_LYDIA_3, OPPONENT_LYDIA_4, OPPONENT_LYDIA_5}, + MAP_GROUP_ROUTE117, + MAP_ID_ROUTE117, + }, + { + {OPPONENT_ISAAC_1, OPPONENT_ISAAC_2, OPPONENT_ISAAC_3, OPPONENT_ISAAC_4, OPPONENT_ISAAC_5}, + MAP_GROUP_ROUTE117, + MAP_ID_ROUTE117, + }, + { + {OPPONENT_CATHERINE_1, OPPONENT_CATHERINE_2, OPPONENT_CATHERINE_3, OPPONENT_CATHERINE_4, OPPONENT_CATHERINE_5}, + MAP_GROUP_ROUTE119, + MAP_ID_ROUTE119, + }, + { + {OPPONENT_JACKSON_1, OPPONENT_JACKSON_2, OPPONENT_JACKSON_3, OPPONENT_JACKSON_4, OPPONENT_JACKSON_5}, + MAP_GROUP_ROUTE119, + MAP_ID_ROUTE119, + }, + { + {OPPONENT_HALEY_1, OPPONENT_HALEY_2, OPPONENT_HALEY_3, OPPONENT_HALEY_4, OPPONENT_HALEY_5}, + MAP_GROUP_ROUTE104, + MAP_ID_ROUTE104, + }, + { + {OPPONENT_JAMES_1, OPPONENT_JAMES_2, OPPONENT_JAMES_3, OPPONENT_JAMES_4, OPPONENT_JAMES_5}, + MAP_GROUP_PETALBURG_WOODS, + MAP_ID_PETALBURG_WOODS, + }, + { + {OPPONENT_TRENT_1, OPPONENT_TRENT_2, OPPONENT_TRENT_3, OPPONENT_TRENT_4, OPPONENT_TRENT_5}, + MAP_GROUP_ROUTE112, + MAP_ID_ROUTE112, + }, + { + {OPPONENT_LOIS_AND_HAL_1, OPPONENT_LOIS_AND_HAL_2, OPPONENT_LOIS_AND_HAL_3, OPPONENT_LOIS_AND_HAL_4, OPPONENT_LOIS_AND_HAL_5}, + MAP_GROUP_ABANDONED_SHIP_ROOMS2_1F, + MAP_ID_ABANDONED_SHIP_ROOMS2_1F, + }, + { + {OPPONENT_WALLY_3, OPPONENT_WALLY_4, OPPONENT_WALLY_5, OPPONENT_WALLY_6, OPPONENT_NONE}, + MAP_GROUP_VICTORY_ROAD_1F, + MAP_ID_VICTORY_ROAD_1F, + }, +}; -extern u8 gBattleTransitionTable_Wild[][2]; -extern u8 gBattleTransitionTable_Trainer[][2]; +static const u16 sBadgeFlags[] = {BADGE01_GET, BADGE02_GET, BADGE03_GET, BADGE04_GET, BADGE05_GET, BADGE06_GET, BADGE07_GET, BADGE08_GET}; void task01_battle_start(u8 taskId) { @@ -154,143 +460,143 @@ void task_add_01_battle_start(u8 transition, u16 song) void CheckForSafariZoneAndProceed(void) { if (GetSafariZoneFlag()) - sub_8081AA4(); + StartBattle_Safari(); else - sub_8081A18(); + StartBattle_StandardWild(); } -void sub_8081A18(void) +void StartBattle_StandardWild(void) { ScriptContext2_Enable(); - player_bitmagic(); + FreezeMapObjects(); sub_80597F4(); - gMain.field_8 = sub_8081C8C; - gUnknown_020239F8 = 0; + gMain.savedCallback = HandleWildBattleEnd; + gBattleTypeFlags = 0; task_add_01_battle_start(GetWildBattleTransition(), 0); - sav12_xor_increment(7); - sav12_xor_increment(8); + IncrementGameStat(7); + IncrementGameStat(8); } -void sub_8081A5C(void) +void StartBattle_Roamer(void) { ScriptContext2_Enable(); - player_bitmagic(); + FreezeMapObjects(); sub_80597F4(); - gMain.field_8 = sub_8081C8C; - gUnknown_020239F8 = 1024; + gMain.savedCallback = HandleWildBattleEnd; + gBattleTypeFlags = BATTLE_TYPE_ROAMER; task_add_01_battle_start(GetWildBattleTransition(), 0); - sav12_xor_increment(7); - sav12_xor_increment(8); + IncrementGameStat(7); + IncrementGameStat(8); } -void sub_8081AA4(void) +void StartBattle_Safari(void) { ScriptContext2_Enable(); - player_bitmagic(); + FreezeMapObjects(); sub_80597F4(); - gMain.field_8 = sub_80C824C; - gUnknown_020239F8 = 128; + gMain.savedCallback = sub_80C824C; + gBattleTypeFlags = BATTLE_TYPE_SAFARI; task_add_01_battle_start(GetWildBattleTransition(), 0); } void task_add_01_battle_start_with_music_and_stats(void) { task_add_01_battle_start(GetTrainerBattleTransition(), 0); - sav12_xor_increment(7); - sav12_xor_increment(9); + IncrementGameStat(7); + IncrementGameStat(9); } //Initiates battle where Wally catches Ralts -void sub_8081AFC(void) +void StartBattle_WallyTutorial(void) { CreateMaleMon(&gEnemyParty[0], SPECIES_RALTS, 5); ScriptContext2_Enable(); - gMain.field_8 = c2_exit_to_overworld_1_continue_scripts_restart_music; - gUnknown_020239F8 = 512; + gMain.savedCallback = c2_exit_to_overworld_1_continue_scripts_restart_music; + gBattleTypeFlags = BATTLE_TYPE_WALLY_TUTORIAL; task_add_01_battle_start(8, 0); } -void sub_8081B3C(void) +void StartBattle_ScriptedWild(void) { ScriptContext2_Enable(); - gMain.field_8 = sub_8081CEC; - gUnknown_020239F8 = 0; + gMain.savedCallback = HandleScriptedWildBattleEnd; + gBattleTypeFlags = 0; task_add_01_battle_start(GetWildBattleTransition(), 0); - sav12_xor_increment(7); - sav12_xor_increment(8); + IncrementGameStat(7); + IncrementGameStat(8); } -void sub_8081B78(void) +void StartBattle_SouthernIsland(void) { ScriptContext2_Enable(); - gMain.field_8 = sub_8081CEC; - gUnknown_020239F8 = 0x2000; + gMain.savedCallback = HandleScriptedWildBattleEnd; + gBattleTypeFlags = BATTLE_TYPE_LEGENDARY; task_add_01_battle_start(GetWildBattleTransition(), 0); - sav12_xor_increment(7); - sav12_xor_increment(8); + IncrementGameStat(7); + IncrementGameStat(8); } -void sub_8081BB8(void) +void StartBattle_Rayquaza(void) { ScriptContext2_Enable(); - gMain.field_8 = sub_8081CEC; - gUnknown_020239F8 = 0x2000; + gMain.savedCallback = HandleScriptedWildBattleEnd; + gBattleTypeFlags = BATTLE_TYPE_LEGENDARY; task_add_01_battle_start(0, BGM_BATTLE34); - sav12_xor_increment(7); - sav12_xor_increment(8); + IncrementGameStat(7); + IncrementGameStat(8); } -void sub_8081BF8(void) +void StartBattle_GroudonKyogre(void) { ScriptContext2_Enable(); - gMain.field_8 = sub_8081CEC; - gUnknown_020239F8 = 12288; + gMain.savedCallback = HandleScriptedWildBattleEnd; + gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_KYOGRE_GROUDON; if (gGameVersion == 2) task_add_01_battle_start(0xB, BGM_BATTLE34); // KYOGRE else task_add_01_battle_start(0x6, BGM_BATTLE34); // GROUDON - sav12_xor_increment(7); - sav12_xor_increment(8); + IncrementGameStat(7); + IncrementGameStat(8); } -void sub_8081C50(void) +void StartBattle_Regi(void) { ScriptContext2_Enable(); - gMain.field_8 = sub_8081CEC; - gUnknown_020239F8 = 24576; + gMain.savedCallback = HandleScriptedWildBattleEnd; + gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_REGI; task_add_01_battle_start(0xA, BGM_BATTLE36); - sav12_xor_increment(7); - sav12_xor_increment(8); + IncrementGameStat(7); + IncrementGameStat(8); } -void sub_8081C8C(void) +void HandleWildBattleEnd(void) { CpuFill16(0, (void *)BG_PLTT, BG_PLTT_SIZE); ResetOamRange(0, 128); - if (battle_exit_is_player_defeat(gUnknown_02024D26) == TRUE) + if (battle_exit_is_player_defeat(gBattleOutcome) == TRUE) { - SetMainCallback2(c2_whiteout); + SetMainCallback2(CB2_WhiteOut); } else { SetMainCallback2(c2_exit_to_overworld_2_switch); - gUnknown_0300485C = sub_8080E44; + gFieldCallback = sub_8080E44; } } -void sub_8081CEC(void) +void HandleScriptedWildBattleEnd(void) { CpuFill16(0, (void *)BG_PLTT, BG_PLTT_SIZE); ResetOamRange(0, 128); - if (battle_exit_is_player_defeat(gUnknown_02024D26) == TRUE) - SetMainCallback2(c2_whiteout); + if (battle_exit_is_player_defeat(gBattleOutcome) == TRUE) + SetMainCallback2(CB2_WhiteOut); else SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); } -s8 sub_8081D3C(void) +s8 GetBattleTerrain(void) { u16 tileBehavior; s16 x, y; @@ -304,24 +610,24 @@ s8 sub_8081D3C(void) return 1; if (MetatileBehavior_IsSandOrDeepSand(tileBehavior)) return 2; - switch (gMapHeader.light) + switch (gMapHeader.mapType) { - case 1: - case 2: - case 3: + case MAP_TYPE_TOWN: + case MAP_TYPE_CITY: + case MAP_TYPE_ROUTE: break; - case 4: + case MAP_TYPE_UNDERGROUND: if (sub_80574C4(tileBehavior)) return 8; if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior)) return 5; return 7; - case 8: - case 9: + case MAP_TYPE_INDOOR: + case MAP_TYPE_SECRET_BASE: return 8; - case 5: + case MAP_TYPE_UNDERWATER: return 3; - case 6: + case MAP_TYPE_6: if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior)) return 4; return 9; @@ -346,7 +652,7 @@ s8 sub_8081D3C(void) return 9; } -s8 sub_8081E90(void) +s8 GetBattleTransitionTypeByMap(void) { u8 flashUsed; u16 tileBehavior; @@ -362,11 +668,11 @@ s8 sub_8081E90(void) if (!MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior)) { - switch (gMapHeader.light) + switch (gMapHeader.mapType) { - case 4: + case MAP_TYPE_UNDERGROUND: return 1; - case 5: + case MAP_TYPE_UNDERWATER: return 3; default: return 0; @@ -383,8 +689,8 @@ u16 GetSumOfPartyMonLevel(u8 numMons) for (i = 0; i < 6; i++) { u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); - - if (species != 412 && species != 0 && GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0) + + if (species != SPECIES_EGG && species != SPECIES_NONE && GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0) { sum += GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); numMons--; @@ -436,7 +742,7 @@ u8 GetSumOfEnemyPartyLevel(u16 trainerNum, u8 numMons) u8 GetWildBattleTransition(void) { - u8 flashVar = sub_8081E90(); + u8 flashVar = GetBattleTransitionTypeByMap(); u8 level = GetMonData(&gEnemyParty[0], MON_DATA_LEVEL); if (level < (u8)GetSumOfPartyMonLevel(1)) // is wild mon level than the player's mon level? @@ -447,8 +753,8 @@ u8 GetWildBattleTransition(void) u8 GetTrainerBattleTransition(void) { - struct Trainer *trainer; - u8 partyCount; + const struct Trainer *trainer; + u8 minPartyCount; u8 flashVar; u8 level; @@ -474,14 +780,14 @@ u8 GetTrainerBattleTransition(void) return 16; if (trainer[gTrainerBattleOpponent].doubleBattle == TRUE) - partyCount = 2; // double battles always at least have 2 pokemon. + minPartyCount = 2; // double battles always at least have 2 pokemon. else - partyCount = 1; + minPartyCount = 1; - flashVar = sub_8081E90(); - level = GetSumOfEnemyPartyLevel(gTrainerBattleOpponent, partyCount); + flashVar = GetBattleTransitionTypeByMap(); + level = GetSumOfEnemyPartyLevel(gTrainerBattleOpponent, minPartyCount); - if (level < (u8)GetSumOfPartyMonLevel(partyCount)) // is wild mon level than the player's mon level? + if (level < (u8)GetSumOfPartyMonLevel(minPartyCount)) // is wild mon level than the player's mon level? return gBattleTransitionTable_Trainer[flashVar][0]; else return gBattleTransitionTable_Trainer[flashVar][1]; @@ -497,13 +803,13 @@ u8 GetBattleTowerBattleTransition(void) return 3; } -void sub_8082168(void) +void ChooseStarter(void) { SetMainCallback2(CB2_ChooseStarter); - gMain.field_8 = sub_8082188; + gMain.savedCallback = CB2_GiveStarter; } -void sub_8082188(void) +void CB2_GiveStarter(void) { u16 starterPoke; @@ -512,28 +818,28 @@ void sub_8082188(void) ScriptGiveMon(starterPoke, 5, 0, 0, 0, 0); ResetTasks(); sub_80408BC(); - SetMainCallback2(sub_80821D8); + SetMainCallback2(CB2_StartFirstBattle); sub_811AAD8(0); } -void sub_80821D8(void) +void CB2_StartFirstBattle(void) { UpdatePaletteFade(); RunTasks(); if (sub_811AAE8() == TRUE) { - gUnknown_020239F8 = 16; - gMain.field_8 = sub_8082228; + gBattleTypeFlags = BATTLE_TYPE_FIRST_BATTLE; + gMain.savedCallback = HandleFirstBattleEnd; SetMainCallback2(sub_800E7C4); prev_quest_postbuffer_cursor_backup_reset(); overworld_poison_timer_set(); - sav12_xor_increment(7); - sav12_xor_increment(8); + IncrementGameStat(7); + IncrementGameStat(8); } } -void sub_8082228(void) +void HandleFirstBattleEnd(void) { sav1_reset_battle_music_maybe(); SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); @@ -589,7 +895,7 @@ void sub_80822BC(void) gTrainerBattleEndScript = 0; } -void TrainerBattleLoadArgs(struct TrainerBattleSpec *specs, u8 *data) +void TrainerBattleLoadArgs(const struct TrainerBattleSpec *specs, u8 *data) { while (1) { @@ -733,8 +1039,8 @@ void trainer_flag_clear(u16 flag) void sub_80825E4(void) { - gUnknown_020239F8 = 8; - gMain.field_8 = sub_808260C; + gBattleTypeFlags = BATTLE_TYPE_TRAINER; + gMain.savedCallback = sub_808260C; task_add_01_battle_start_with_music_and_stats(); ScriptContext1_Stop(); } @@ -745,9 +1051,9 @@ void sub_808260C(void) { SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); // link battle? } - else if (battle_exit_is_player_defeat(gUnknown_02024D26) == TRUE) + else if (battle_exit_is_player_defeat(gBattleOutcome) == TRUE) { - SetMainCallback2(c2_whiteout); + SetMainCallback2(CB2_WhiteOut); } else { @@ -762,9 +1068,9 @@ void do_choose_name_or_words_screen(void) { SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); // link battle? } - else if (battle_exit_is_player_defeat(gUnknown_02024D26) == TRUE) + else if (battle_exit_is_player_defeat(gBattleOutcome) == TRUE) { - SetMainCallback2(c2_whiteout); + SetMainCallback2(CB2_WhiteOut); } else { @@ -776,8 +1082,8 @@ void do_choose_name_or_words_screen(void) void sub_80826B0(void) { - gUnknown_020239F8 = 8; - gMain.field_8 = do_choose_name_or_words_screen; + gBattleTypeFlags = BATTLE_TYPE_TRAINER; + gMain.savedCallback = do_choose_name_or_words_screen; task_add_01_battle_start_with_music_and_stats(); ScriptContext1_Stop(); } @@ -803,7 +1109,7 @@ u8 *sub_8082700(void) return gUnknown_081C6C02; } -void sub_8082718() +void sub_8082718(void) { ShowFieldMessage(sub_8082880()); } @@ -863,12 +1169,12 @@ void PlayTrainerEncounterMusic(void) } //Returns an empty string if a null pointer was passed, otherwise returns str -u8 *SanitizeString(u8 *str) +u8 *SanitizeString(const u8 *str) { if (str) - return str; + return (u8 *) str; else - return gOtherText_CancelWithTerminator; + return (u8 *) gOtherText_CancelWithTerminator; } u8 *sub_808281C(void) @@ -899,7 +1205,7 @@ u8 *sub_8082880(void) return SanitizeString(gTrainerCannotBattleSpeech); } -s32 sub_8082894(struct TrainerEyeTrainer *trainers, u16 trainerNum) +s32 sub_8082894(const struct TrainerEyeTrainer *trainers, u16 trainerNum) { s32 i; @@ -911,7 +1217,7 @@ s32 sub_8082894(struct TrainerEyeTrainer *trainers, u16 trainerNum) return -1; } -s32 sub_80828B8(struct TrainerEyeTrainer *trainers, u16 trainerNum) +s32 sub_80828B8(const struct TrainerEyeTrainer *trainers, u16 trainerNum) { s32 i; s32 j; @@ -927,7 +1233,7 @@ s32 sub_80828B8(struct TrainerEyeTrainer *trainers, u16 trainerNum) return -1; } -bool32 sub_80828FC(struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum) +bool32 sub_80828FC(const struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum) { int i; bool32 ret = FALSE; @@ -952,7 +1258,7 @@ bool32 sub_80828FC(struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum) return ret; } -s32 sub_80829A8(struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum) +s32 sub_80829A8(const struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum) { s32 i; @@ -964,7 +1270,7 @@ s32 sub_80829A8(struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum) return 0; } -s32 sub_80829E8(struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum) +s32 sub_80829E8(const struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum) { s32 i; @@ -976,7 +1282,7 @@ s32 sub_80829E8(struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum) return 0; } -bool8 sub_8082A18(struct TrainerEyeTrainer *trainers, u16 trainerNum) +bool8 sub_8082A18(const struct TrainerEyeTrainer *trainers, u16 trainerNum) { s32 trainerEyeIndex = sub_8082894(trainers, trainerNum); @@ -986,7 +1292,7 @@ bool8 sub_8082A18(struct TrainerEyeTrainer *trainers, u16 trainerNum) return FALSE; } -bool8 sub_8082A54(struct TrainerEyeTrainer *trainers, u16 trainerNum) +bool8 sub_8082A54(const struct TrainerEyeTrainer *trainers, u16 trainerNum) { s32 trainerEyeIndex = sub_80828B8(trainers, trainerNum); @@ -996,10 +1302,10 @@ bool8 sub_8082A54(struct TrainerEyeTrainer *trainers, u16 trainerNum) return FALSE; } -u16 sub_8082A90(struct TrainerEyeTrainer *trainers, u16 trainerNum) +u16 sub_8082A90(const struct TrainerEyeTrainer *trainers, u16 trainerNum) { int i; - struct TrainerEyeTrainer *trainer; + const struct TrainerEyeTrainer *trainer; s32 trainerEyeIndex = sub_8082894(trainers, trainerNum); if (trainerEyeIndex == -1) @@ -1015,7 +1321,7 @@ u16 sub_8082A90(struct TrainerEyeTrainer *trainers, u16 trainerNum) return trainer->trainerNums[4]; } -void sub_8082AE4(struct TrainerEyeTrainer *trainers, u16 trainerNum) +void sub_8082AE4(const struct TrainerEyeTrainer *trainers, u16 trainerNum) { s32 trainerEyeIndex = sub_80828B8(trainers, trainerNum); @@ -1023,7 +1329,7 @@ void sub_8082AE4(struct TrainerEyeTrainer *trainers, u16 trainerNum) gSaveBlock1.trainerRematches[trainerEyeIndex] = 0; } -bool8 sub_8082B10(struct TrainerEyeTrainer *trainers, u16 trainerNum) +bool8 sub_8082B10(const struct TrainerEyeTrainer *trainers, u16 trainerNum) { s32 trainerEyeIndex = sub_8082894(trainers, trainerNum); @@ -1040,7 +1346,7 @@ bool32 sub_8082B44(void) for (i = 0; i < 8; i++) { - if (FlagGet(gBadgeFlags[i]) == TRUE) + if (FlagGet(sBadgeFlags[i]) == TRUE) { badgeCount++; if (badgeCount >= 5) diff --git a/src/berry.c b/src/berry.c index aee624c33..d6fbb955e 100644 --- a/src/berry.c +++ b/src/berry.c @@ -1,46 +1,1008 @@ #include "global.h" #include "berry.h" -#include "asm.h" +#include "field_control_avatar.h" +#include "field_map_obj.h" +#include "fieldmap.h" #include "item.h" +#include "item_menu.h" +#include "items.h" #include "main.h" -#include "text.h" #include "rng.h" +#include "text.h" + +#define BERRY_NAME_LENGTH 6 + +#define FIRST_BERRY ITEM_CHERI_BERRY +#define LAST_BERRY ITEM_ENIGMA_BERRY + +#ifdef ENGLISH +#define NAME_CHERI_BERRY _("CHERI") +#define NAME_CHESTO_BERRY _("CHESTO") +#define NAME_PECHA_BERRY _("PECHA") +#define NAME_RAWST_BERRY _("RAWST") +#define NAME_ASPEAR_BERRY _("ASPEAR") +#define NAME_LEPPA_BERRY _("LEPPA") +#define NAME_ORAN_BERRY _("ORAN") +#define NAME_PERSIM_BERRY _("PERSIM") +#define NAME_LUM_BERRY _("LUM") +#define NAME_SITRUS_BERRY _("SITRUS") +#define NAME_FIGY_BERRY _("FIGY") +#define NAME_WIKI_BERRY _("WIKI") +#define NAME_MAGO_BERRY _("MAGO") +#define NAME_AGUAV_BERRY _("AGUAV") +#define NAME_IAPAPA_BERRY _("IAPAPA") +#define NAME_RAZZ_BERRY _("RAZZ") +#define NAME_BLUK_BERRY _("BLUK") +#define NAME_NANAB_BERRY _("NANAB") +#define NAME_WEPEAR_BERRY _("WEPEAR") +#define NAME_PINAP_BERRY _("PINAP") +#define NAME_POMEG_BERRY _("POMEG") +#define NAME_KELPSY_BERRY _("KELPSY") +#define NAME_QUALOT_BERRY _("QUALOT") +#define NAME_HONDEW_BERRY _("HONDEW") +#define NAME_GREPA_BERRY _("GREPA") +#define NAME_TAMATO_BERRY _("TAMATO") +#define NAME_CORNN_BERRY _("CORNN") +#define NAME_MAGOST_BERRY _("MAGOST") +#define NAME_RABUTA_BERRY _("RABUTA") +#define NAME_NOMEL_BERRY _("NOMEL") +#define NAME_SPELON_BERRY _("SPELON") +#define NAME_PAMTRE_BERRY _("PAMTRE") +#define NAME_WATMEL_BERRY _("WATMEL") +#define NAME_DURIN_BERRY _("DURIN") +#define NAME_BELUE_BERRY _("BELUE") +#define NAME_LIECHI_BERRY _("LIECHI") +#define NAME_GANLON_BERRY _("GANLON") +#define NAME_SALAC_BERRY _("SALAC") +#define NAME_PETAYA_BERRY _("PETAYA") +#define NAME_APICOT_BERRY _("APICOT") +#define NAME_LANSAT_BERRY _("LANSAT") +#define NAME_STARF_BERRY _("STARF") +#define NAME_ENIGMA_BERRY _("ENIGMA") -#define FIRST_BERRY 0x85 // ITEM_CHERI_BERRY -#define LAST_BERRY 0xaf // ITEM_ENIGMA_BERRY +const u8 gBerryDescriptionPart1_Cheri[] = _("Blooms with delicate pretty flowers."); +const u8 gBerryDescriptionPart2_Cheri[] = _("The bright red BERRY is very spicy."); +const u8 gBerryDescriptionPart1_Chesto[] = _("The BERRY’s thick skin and fruit are"); +const u8 gBerryDescriptionPart2_Chesto[] = _("very tough. It is dry-tasting all over."); +const u8 gBerryDescriptionPart1_Pecha[] = _("Very sweet and delicious."); +const u8 gBerryDescriptionPart2_Pecha[] = _("Also very tender - handle with care."); +const u8 gBerryDescriptionPart1_Rawst[] = _("If the leaves grow long and curly,"); +const u8 gBerryDescriptionPart2_Rawst[] = _("the BERRY seems to grow very bitter."); +const u8 gBerryDescriptionPart1_Aspear[] = _("The hard BERRY is dense with a rich"); +const u8 gBerryDescriptionPart2_Aspear[] = _("juice. It is quite sour."); +const u8 gBerryDescriptionPart1_Leppa[] = _("Grows slower than CHERI and others."); +const u8 gBerryDescriptionPart2_Leppa[] = _("The smaller the BERRY, the tastier."); +const u8 gBerryDescriptionPart1_Oran[] = _("A peculiar BERRY with a mix of flavors."); +const u8 gBerryDescriptionPart2_Oran[] = _("BERRIES grow in half a day."); +const u8 gBerryDescriptionPart1_Persim[] = _("Loves sunlight. The BERRY’s color"); +const u8 gBerryDescriptionPart2_Persim[] = _("grows vivid when exposed to the sun."); +const u8 gBerryDescriptionPart1_Lum[] = _("Slow to grow. If raised with loving"); +const u8 gBerryDescriptionPart2_Lum[] = _("care, it may grow two BERRIES."); +const u8 gBerryDescriptionPart1_Sitrus[] = _("Closely related to ORAN. The large"); +const u8 gBerryDescriptionPart2_Sitrus[] = _("BERRY has a well-rounded flavor."); +const u8 gBerryDescriptionPart1_Figy[] = _("The BERRY, which looks chewed up,"); +const u8 gBerryDescriptionPart2_Figy[] = _("brims with spicy substances."); +const u8 gBerryDescriptionPart1_Wiki[] = _("The BERRY is said to have grown lumpy"); +const u8 gBerryDescriptionPart2_Wiki[] = _("to help POKéMON grip it."); +const u8 gBerryDescriptionPart1_Mago[] = _("The BERRY turns curvy as it grows."); +const u8 gBerryDescriptionPart2_Mago[] = _("The curvier, the sweeter and tastier."); +const u8 gBerryDescriptionPart1_Aguav[] = _("The flower is dainty. It is rare in its"); +const u8 gBerryDescriptionPart2_Aguav[] = _("ability to grow without light."); +const u8 gBerryDescriptionPart1_Iapapa[] = _("The BERRY is very big and sour."); +const u8 gBerryDescriptionPart2_Iapapa[] = _("It takes at least a day to grow."); +const u8 gBerryDescriptionPart1_Razz[] = _("The red BERRY tastes slightly spicy."); +const u8 gBerryDescriptionPart2_Razz[] = _("It grows quickly in just four hours."); +const u8 gBerryDescriptionPart1_Bluk[] = _("The BERRY is blue on the outside, but"); +const u8 gBerryDescriptionPart2_Bluk[] = _("it blackens the mouth when eaten."); +const u8 gBerryDescriptionPart1_Nanab[] = _("This BERRY was the seventh"); +const u8 gBerryDescriptionPart2_Nanab[] = _("discovered in the world. It is sweet."); +const u8 gBerryDescriptionPart1_Wepear[] = _("The flower is small and white. It has a"); +const u8 gBerryDescriptionPart2_Wepear[] = _("delicate balance of bitter and sour."); +const u8 gBerryDescriptionPart1_Pinap[] = _("Weak against wind and cold."); +const u8 gBerryDescriptionPart2_Pinap[] = _("The fruit is spicy and the skin, sour."); +const u8 gBerryDescriptionPart1_Pomeg[] = _("However much it is watered,"); +const u8 gBerryDescriptionPart2_Pomeg[] = _("it only grows up to six BERRIES."); +const u8 gBerryDescriptionPart1_Kelpsy[] = _("A rare variety shaped like a root."); +const u8 gBerryDescriptionPart2_Kelpsy[] = _("Grows a very large flower."); +const u8 gBerryDescriptionPart1_Qualot[] = _("Loves water. Grows strong even in"); +const u8 gBerryDescriptionPart2_Qualot[] = _("locations with constant rainfall."); +const u8 gBerryDescriptionPart1_Hondew[] = _("A BERRY that is very valuable and"); +const u8 gBerryDescriptionPart2_Hondew[] = _("rarely seen. It is very delicious."); +const u8 gBerryDescriptionPart1_Grepa[] = _("Despite its tenderness and round"); +const u8 gBerryDescriptionPart2_Grepa[] = _("shape, the BERRY is unimaginably sour."); +const u8 gBerryDescriptionPart1_Tamato[] = _("The BERRY is lip-bendingly spicy."); +const u8 gBerryDescriptionPart2_Tamato[] = _("It takes time to grow."); +const u8 gBerryDescriptionPart1_Cornn[] = _("A BERRY from an ancient era. May not"); +const u8 gBerryDescriptionPart2_Cornn[] = _("grow unless planted in quantity."); +const u8 gBerryDescriptionPart1_Magost[] = _("A BERRY that is widely said to have"); +const u8 gBerryDescriptionPart2_Magost[] = _("a finely balanced flavor."); +const u8 gBerryDescriptionPart1_Rabuta[] = _("A rare variety that is overgrown with"); +const u8 gBerryDescriptionPart2_Rabuta[] = _("hair. It is quite bitter."); +const u8 gBerryDescriptionPart1_Nomel[] = _("Quite sour. Just one bite makes it"); +const u8 gBerryDescriptionPart2_Nomel[] = _("impossible to taste for three days."); +const u8 gBerryDescriptionPart1_Spelon[] = _("The vividly red BERRY is very spicy."); +const u8 gBerryDescriptionPart2_Spelon[] = _("Its warts secrete a spicy substance."); +const u8 gBerryDescriptionPart1_Pamtre[] = _("Drifts on the sea from somewhere."); +const u8 gBerryDescriptionPart2_Pamtre[] = _("It is thought to grow elsewhere."); +const u8 gBerryDescriptionPart1_Watmel[] = _("A huge BERRY, with some over 20"); +const u8 gBerryDescriptionPart2_Watmel[] = _("inches discovered. Exceedingly sweet."); +const u8 gBerryDescriptionPart1_Durin[] = _("Bitter to even look at. It is so"); +const u8 gBerryDescriptionPart2_Durin[] = _("bitter, no one has ever eaten it as is."); +const u8 gBerryDescriptionPart1_Belue[] = _("It is glossy and looks delicious, but"); +const u8 gBerryDescriptionPart2_Belue[] = _("it is awfully sour. Takes time to grow."); +const u8 gBerryDescriptionPart1_Liechi[] = _("A mysterious BERRY. It is rumored to"); +const u8 gBerryDescriptionPart2_Liechi[] = _("contain the power of the sea."); +const u8 gBerryDescriptionPart1_Ganlon[] = _("A mysterious BERRY. It is rumored to"); +const u8 gBerryDescriptionPart2_Ganlon[] = _("contain the power of the land."); +const u8 gBerryDescriptionPart1_Salac[] = _("A mysterious BERRY. It is rumored to"); +const u8 gBerryDescriptionPart2_Salac[] = _("contain the power of the sky."); +const u8 gBerryDescriptionPart1_Petaya[] = _("A mysterious BERRY. It is rumored to"); +const u8 gBerryDescriptionPart2_Petaya[] = _("contain the power of all living things."); +const u8 gBerryDescriptionPart1_Apicot[] = _("A very mystifying BERRY. No telling"); +const u8 gBerryDescriptionPart2_Apicot[] = _("what may happen or how it can be used."); +const u8 gBerryDescriptionPart1_Lansat[] = _("Said to be a legendary BERRY."); +const u8 gBerryDescriptionPart2_Lansat[] = _("Holding it supposedly brings joy."); +const u8 gBerryDescriptionPart1_Starf[] = _("So strong, it was abandoned at the"); +const u8 gBerryDescriptionPart2_Starf[] = _("world’s edge. Considered a mirage."); +const u8 gBerryDescriptionPart1_Enigma[] = _("A completely enigmatic BERRY."); +const u8 gBerryDescriptionPart2_Enigma[] = _("Appears to have the power of stars."); +#elif defined(GERMAN) +#define NAME_CHERI_BERRY _("AMRENA") +#define NAME_CHESTO_BERRY _("MARON") +#define NAME_PECHA_BERRY _("PIRSIF") +#define NAME_RAWST_BERRY _("FRAGIA") +#define NAME_ASPEAR_BERRY _("WILBIR") +#define NAME_LEPPA_BERRY _("JONAGO") +#define NAME_ORAN_BERRY _("SINEL") +#define NAME_PERSIM_BERRY _("PERSIM") +#define NAME_LUM_BERRY _("PRUNUS") +#define NAME_SITRUS_BERRY _("TSITRU") +#define NAME_FIGY_BERRY _("GIEFE") +#define NAME_WIKI_BERRY _("WIKI") +#define NAME_MAGO_BERRY _("MAGO") +#define NAME_AGUAV_BERRY _("GAUVE") +#define NAME_IAPAPA_BERRY _("YAPA") +#define NAME_RAZZ_BERRY _("HIMMIH") +#define NAME_BLUK_BERRY _("MORB") +#define NAME_NANAB_BERRY _("NANAB") +#define NAME_WEPEAR_BERRY _("NIRBE") +#define NAME_PINAP_BERRY _("SANANA") +#define NAME_POMEG_BERRY _("GRANA") +#define NAME_KELPSY_BERRY _("SETANG") +#define NAME_QUALOT_BERRY _("QUALOT") +#define NAME_HONDEW_BERRY _("HONMEL") +#define NAME_GREPA_BERRY _("LABRUS") +#define NAME_TAMATO_BERRY _("TAMOT") +#define NAME_CORNN_BERRY _("SAIM") +#define NAME_MAGOST_BERRY _("MAGOST") +#define NAME_RABUTA_BERRY _("RABUTA") +#define NAME_NOMEL_BERRY _("TRONZI") +#define NAME_SPELON_BERRY _("KIWAN") +#define NAME_PAMTRE_BERRY _("PALLM") +#define NAME_WATMEL_BERRY _("WASMEL") +#define NAME_DURIN_BERRY _("DURIN") +#define NAME_BELUE_BERRY _("MYRTIL") +#define NAME_LIECHI_BERRY _("LYDZI") +#define NAME_GANLON_BERRY _("LINGAN") +#define NAME_SALAC_BERRY _("SALKA") +#define NAME_PETAYA_BERRY _("TAHAY") +#define NAME_APICOT_BERRY _("APIKO") +#define NAME_LANSAT_BERRY _("LANSAT") +#define NAME_STARF_BERRY _("KRAMBO") +#define NAME_ENIGMA_BERRY _("ENIGMA") + +const u8 gBerryDescriptionPart1_Cheri[] = _("Erblüht mit hübschen, zarten Blumen."); +const u8 gBerryDescriptionPart2_Cheri[] = _("Diese knallrote BEERE ist sehr scharf."); +const u8 gBerryDescriptionPart1_Chesto[] = _("Diese BEERE hat eine dicke Haut und"); +const u8 gBerryDescriptionPart2_Chesto[] = _("hartes Fruchtfleisch. Trocken!"); +const u8 gBerryDescriptionPart1_Pecha[] = _("Sehr süß und delikat."); +const u8 gBerryDescriptionPart2_Pecha[] = _("Sehr zart. Vorsichtig anfassen!"); +const u8 gBerryDescriptionPart1_Rawst[] = _("Wenn die Blätter lang und wellig sind,"); +const u8 gBerryDescriptionPart2_Rawst[] = _("wird die BEERE sehr bitter."); +const u8 gBerryDescriptionPart1_Aspear[] = _("Diese harte BEERE ist sehr"); +const u8 gBerryDescriptionPart2_Aspear[] = _("saftig und sauer im Geschmack!"); +const u8 gBerryDescriptionPart1_Leppa[] = _("Wächst langsamer als AMRENA und"); +const u8 gBerryDescriptionPart2_Leppa[] = _("andere. Je kleiner, desto delikater."); +const u8 gBerryDescriptionPart1_Oran[] = _("Eine BEERE unterschiedlichsten Ge-"); +const u8 gBerryDescriptionPart2_Oran[] = _("schmacks. Wächst an einem halben Tag."); +const u8 gBerryDescriptionPart1_Persim[] = _("Liebt Sonnenlicht. Die BEERE"); +const u8 gBerryDescriptionPart2_Persim[] = _("wächst im Sonnenlicht sehr schnell."); +const u8 gBerryDescriptionPart1_Lum[] = _("Langsamer Wuchs. Wird sie liebevoll ge-"); +const u8 gBerryDescriptionPart2_Lum[] = _("pflegt, kann sie 2 BEEREN tragen."); +const u8 gBerryDescriptionPart1_Sitrus[] = _("Eng verwandt mit SINEL. Diese große"); +const u8 gBerryDescriptionPart2_Sitrus[] = _("BEERE ist von rundem Geschmack."); +const u8 gBerryDescriptionPart1_Figy[] = _("Die BEERE sieht angekaut aus. Sie ist"); +const u8 gBerryDescriptionPart2_Figy[] = _("voller scharfer Substanzen."); +const u8 gBerryDescriptionPart1_Wiki[] = _("Die BEERE wächst unförmig,"); +const u8 gBerryDescriptionPart2_Wiki[] = _("damit PKMN sie besser greifen können."); +const u8 gBerryDescriptionPart1_Mago[] = _("Die BEERE hat Ausbeulungen. Je mehr"); +const u8 gBerryDescriptionPart2_Mago[] = _("Beulen, desto schmackhafter ist sie."); +const u8 gBerryDescriptionPart1_Aguav[] = _("Die Blume ist zart. Sie ist fähig,"); +const u8 gBerryDescriptionPart2_Aguav[] = _("ohne Licht wachsen zu können."); +const u8 gBerryDescriptionPart1_Iapapa[] = _("Die BEERE ist groß und sauer."); +const u8 gBerryDescriptionPart2_Iapapa[] = _("Sie braucht einen Tag zum Wachsen."); +const u8 gBerryDescriptionPart1_Razz[] = _("Diese rote BEERE schmeckt etwas"); +const u8 gBerryDescriptionPart2_Razz[] = _("scharf. Sie wächst in nur 4 Stunden."); +const u8 gBerryDescriptionPart1_Bluk[] = _("Die BEERE ist außen blau, verfärbt"); +const u8 gBerryDescriptionPart2_Bluk[] = _("sich im Mund aber schwarz."); +const u8 gBerryDescriptionPart1_Nanab[] = _("Diese BEERE war die 7., die auf der"); +const u8 gBerryDescriptionPart2_Nanab[] = _("Welt entdeckt wurde. Sie ist süß."); +const u8 gBerryDescriptionPart1_Wepear[] = _("Die Blume ist klein und weiß. Angenehm"); +const u8 gBerryDescriptionPart2_Wepear[] = _("bitter und sauer zugleich."); +const u8 gBerryDescriptionPart1_Pinap[] = _("Wind und Kälte verträgt sie nicht."); +const u8 gBerryDescriptionPart2_Pinap[] = _("Fruchtfleisch: Scharf. Haut: Sauer."); +const u8 gBerryDescriptionPart1_Pomeg[] = _("Egal wie viel Wasser sie bekommt, sie"); +const u8 gBerryDescriptionPart2_Pomeg[] = _("trägt immer bis zu 6 BEEREN."); +const u8 gBerryDescriptionPart1_Kelpsy[] = _("Eine Seltenheit. Geformt wie eine"); +const u8 gBerryDescriptionPart2_Kelpsy[] = _("Wurzel. Hat eine große Blume."); +const u8 gBerryDescriptionPart1_Qualot[] = _("Liebt das Wasser. Wächst besonders"); +const u8 gBerryDescriptionPart2_Qualot[] = _("gut in regenreichen Gegenden."); +const u8 gBerryDescriptionPart1_Hondew[] = _("Eine wertvolle und seltene BEERE."); +const u8 gBerryDescriptionPart2_Hondew[] = _("Sie ist sehr schmackhaft."); +const u8 gBerryDescriptionPart1_Grepa[] = _("Die BEERE ist zart und von runder"); +const u8 gBerryDescriptionPart2_Grepa[] = _("Form. Aber sie ist unglaublich sauer!"); +const u8 gBerryDescriptionPart1_Tamato[] = _("Die Schärfe der BEERE verbrennt die"); +const u8 gBerryDescriptionPart2_Tamato[] = _("Lippen. Sie braucht Zeit zum Wachsen."); +const u8 gBerryDescriptionPart1_Cornn[] = _("Eine BEERE aus alten Zeiten. Wächst"); +const u8 gBerryDescriptionPart2_Cornn[] = _("nur, wenn in großen Mengen gepflanzt."); +const u8 gBerryDescriptionPart1_Magost[] = _("Eine BEERE, die für ihren feinen, aus-"); +const u8 gBerryDescriptionPart2_Magost[] = _("gewogenen Geschmack bekannt ist."); +const u8 gBerryDescriptionPart1_Rabuta[] = _("Eine Seltenheit, die über und über mit"); +const u8 gBerryDescriptionPart2_Rabuta[] = _("Haaren bewachsen ist. Sehr bitter!"); +const u8 gBerryDescriptionPart1_Nomel[] = _("Sehr sauer. Ein Biss betäubt die"); +const u8 gBerryDescriptionPart2_Nomel[] = _("Geschmacksnerven für 3 Tage!"); +const u8 gBerryDescriptionPart1_Spelon[] = _("Die leuchtend rote BEERE ist sehr"); +const u8 gBerryDescriptionPart2_Spelon[] = _("scharf. Gibt scharfe Substanzen ab!"); +const u8 gBerryDescriptionPart1_Pamtre[] = _("Wird vom Meer angespült. Sie wächst"); +const u8 gBerryDescriptionPart2_Pamtre[] = _("an einem anderen Ort."); +const u8 gBerryDescriptionPart1_Watmel[] = _("Eine große BEERE, 25 cm groß."); +const u8 gBerryDescriptionPart2_Watmel[] = _("Außergewöhnlich süß."); +const u8 gBerryDescriptionPart1_Durin[] = _("Bitter schon ihr Anblick! Sie ist so"); +const u8 gBerryDescriptionPart2_Durin[] = _("bitter, dass niemand sie pur isst."); +const u8 gBerryDescriptionPart1_Belue[] = _("Sie glänzt, sieht zart aus, ist extrem"); +const u8 gBerryDescriptionPart2_Belue[] = _("sauer und braucht Zeit zum Wachsen."); +const u8 gBerryDescriptionPart1_Liechi[] = _("Eine geheimnisvolle BEERE. Man sagt,"); +const u8 gBerryDescriptionPart2_Liechi[] = _("sie enthalte die Kraft des Meeres."); +const u8 gBerryDescriptionPart1_Ganlon[] = _("Eine geheimnisvolle BEERE. Man sagt,"); +const u8 gBerryDescriptionPart2_Ganlon[] = _("sie enthalte die Kraft des Landes."); +const u8 gBerryDescriptionPart1_Salac[] = _("Eine geheimnisvolle BEERE. Man sagt,"); +const u8 gBerryDescriptionPart2_Salac[] = _("sie enthalte die Kraft des Himmels."); +const u8 gBerryDescriptionPart1_Petaya[] = _("Eine geheimnisvolle BEERE. Man sagt,"); +const u8 gBerryDescriptionPart2_Petaya[] = _("sie enthalte die Kraft allen Lebens."); +const u8 gBerryDescriptionPart1_Apicot[] = _("Eine rätselhafte BEERE. Man kann"); +const u8 gBerryDescriptionPart2_Apicot[] = _("nicht sagen, wie und was sie ist."); +const u8 gBerryDescriptionPart1_Lansat[] = _("Eine legendäre BEERE. Sie zu"); +const u8 gBerryDescriptionPart2_Lansat[] = _("tragen bringt Freude."); +const u8 gBerryDescriptionPart1_Starf[] = _("So stark, dass sie an den Rand der"); +const u8 gBerryDescriptionPart2_Starf[] = _("Welt verbannt wurde. Ein Märchen?"); +const u8 gBerryDescriptionPart1_Enigma[] = _("Eine enigmatische BEERE. Sie scheint"); +const u8 gBerryDescriptionPart2_Enigma[] = _("die Macht der Sterne zu besitzen."); +#endif + +const struct Berry gBerries[] = +{ + { + .name = NAME_CHERI_BERRY, + .firmness = BERRY_FIRMNESS_SOFT, + .size = 20, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Cheri, + .description2 = gBerryDescriptionPart2_Cheri, + .stageDuration = 3, + .spicy = 10, + .dry = 0, + .sweet = 0, + .bitter = 0, + .sour = 0, + .smoothness = 25, + }, + { + .name = NAME_CHESTO_BERRY, + .firmness = BERRY_FIRMNESS_SUPER_HARD, + .size = 80, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Chesto, + .description2 = gBerryDescriptionPart2_Chesto, + .stageDuration = 3, + .spicy = 0, + .dry = 10, + .sweet = 0, + .bitter = 0, + .sour = 0, + .smoothness = 25, + }, + { + .name = NAME_PECHA_BERRY, + .firmness = BERRY_FIRMNESS_VERY_SOFT, + .size = 40, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Pecha, + .description2 = gBerryDescriptionPart2_Pecha, + .stageDuration = 3, + .spicy = 0, + .dry = 0, + .sweet = 10, + .bitter = 0, + .sour = 0, + .smoothness = 25, + }, + { + .name = NAME_RAWST_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 32, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Rawst, + .description2 = gBerryDescriptionPart2_Rawst, + .stageDuration = 3, + .spicy = 0, + .dry = 0, + .sweet = 0, + .bitter = 10, + .sour = 0, + .smoothness = 25, + }, + { + .name = NAME_ASPEAR_BERRY, + .firmness = BERRY_FIRMNESS_SUPER_HARD, + .size = 50, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Aspear, + .description2 = gBerryDescriptionPart2_Aspear, + .stageDuration = 3, + .spicy = 0, + .dry = 0, + .sweet = 0, + .bitter = 0, + .sour = 10, + .smoothness = 25, + }, + { + .name = NAME_LEPPA_BERRY, + .firmness = BERRY_FIRMNESS_VERY_HARD, + .size = 28, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Leppa, + .description2 = gBerryDescriptionPart2_Leppa, + .stageDuration = 4, + .spicy = 10, + .dry = 0, + .sweet = 10, + .bitter = 10, + .sour = 10, + .smoothness = 20, + }, + { + .name = NAME_ORAN_BERRY, + .firmness = BERRY_FIRMNESS_SUPER_HARD, + .size = 35, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Oran, + .description2 = gBerryDescriptionPart2_Oran, + .stageDuration = 3, + .spicy = 10, + .dry = 10, + .sweet = 10, + .bitter = 10, + .sour = 10, + .smoothness = 20, + }, + { + .name = NAME_PERSIM_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 47, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Persim, + .description2 = gBerryDescriptionPart2_Persim, + .stageDuration = 3, + .spicy = 10, + .dry = 10, + .sweet = 10, + .bitter = 10, + .sour = 10, + .smoothness = 20, + }, + { + .name = NAME_LUM_BERRY, + .firmness = BERRY_FIRMNESS_SUPER_HARD, + .size = 34, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Lum, + .description2 = gBerryDescriptionPart2_Lum, + .stageDuration = 12, + .spicy = 10, + .dry = 10, + .sweet = 10, + .bitter = 10, + .sour = 10, + .smoothness = 20, + }, + { + .name = NAME_SITRUS_BERRY, + .firmness = BERRY_FIRMNESS_VERY_HARD, + .size = 95, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Sitrus, + .description2 = gBerryDescriptionPart2_Sitrus, + .stageDuration = 6, + .spicy = 10, + .dry = 10, + .sweet = 10, + .bitter = 10, + .sour = 10, + .smoothness = 20, + }, + { + .name = NAME_FIGY_BERRY, + .firmness = BERRY_FIRMNESS_SOFT, + .size = 100, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Figy, + .description2 = gBerryDescriptionPart2_Figy, + .stageDuration = 6, + .spicy = 10, + .dry = 0, + .sweet = 0, + .bitter = 0, + .sour = 0, + .smoothness = 25, + }, + { + .name = NAME_WIKI_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 115, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Wiki, + .description2 = gBerryDescriptionPart2_Wiki, + .stageDuration = 6, + .spicy = 0, + .dry = 10, + .sweet = 0, + .bitter = 0, + .sour = 0, + .smoothness = 25, + }, + { + .name = NAME_MAGO_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 126, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Mago, + .description2 = gBerryDescriptionPart2_Mago, + .stageDuration = 6, + .spicy = 0, + .dry = 0, + .sweet = 10, + .bitter = 0, + .sour = 0, + .smoothness = 25, + }, + { + .name = NAME_AGUAV_BERRY, + .firmness = BERRY_FIRMNESS_SUPER_HARD, + .size = 64, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Aguav, + .description2 = gBerryDescriptionPart2_Aguav, + .stageDuration = 6, + .spicy = 0, + .dry = 0, + .sweet = 0, + .bitter = 10, + .sour = 0, + .smoothness = 25, + }, + { + .name = NAME_IAPAPA_BERRY, + .firmness = BERRY_FIRMNESS_SOFT, + .size = 223, + .maxYield = 3, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Iapapa, + .description2 = gBerryDescriptionPart2_Iapapa, + .stageDuration = 6, + .spicy = 0, + .dry = 0, + .sweet = 0, + .bitter = 0, + .sour = 10, + .smoothness = 25, + }, + { + .name = NAME_RAZZ_BERRY, + .firmness = BERRY_FIRMNESS_VERY_HARD, + .size = 120, + .maxYield = 6, + .minYield = 3, + .description1 = gBerryDescriptionPart1_Razz, + .description2 = gBerryDescriptionPart2_Razz, + .stageDuration = 1, + .spicy = 10, + .dry = 10, + .sweet = 0, + .bitter = 0, + .sour = 0, + .smoothness = 20, + }, + { + .name = NAME_BLUK_BERRY, + .firmness = BERRY_FIRMNESS_SOFT, + .size = 108, + .maxYield = 6, + .minYield = 3, + .description1 = gBerryDescriptionPart1_Bluk, + .description2 = gBerryDescriptionPart2_Bluk, + .stageDuration = 1, + .spicy = 0, + .dry = 10, + .sweet = 10, + .bitter = 0, + .sour = 0, + .smoothness = 20, + }, + { + .name = NAME_NANAB_BERRY, + .firmness = BERRY_FIRMNESS_VERY_HARD, + .size = 77, + .maxYield = 6, + .minYield = 3, + .description1 = gBerryDescriptionPart1_Nanab, + .description2 = gBerryDescriptionPart2_Nanab, + .stageDuration = 1, + .spicy = 0, + .dry = 0, + .sweet = 10, + .bitter = 10, + .sour = 0, + .smoothness = 20, + }, + { + .name = NAME_WEPEAR_BERRY, + .firmness = BERRY_FIRMNESS_SUPER_HARD, + .size = 74, + .maxYield = 6, + .minYield = 3, + .description1 = gBerryDescriptionPart1_Wepear, + .description2 = gBerryDescriptionPart2_Wepear, + .stageDuration = 1, + .spicy = 0, + .dry = 0, + .sweet = 0, + .bitter = 10, + .sour = 10, + .smoothness = 20, + }, + { + .name = NAME_PINAP_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 80, + .maxYield = 6, + .minYield = 3, + .description1 = gBerryDescriptionPart1_Pinap, + .description2 = gBerryDescriptionPart2_Pinap, + .stageDuration = 1, + .spicy = 10, + .dry = 0, + .sweet = 0, + .bitter = 0, + .sour = 10, + .smoothness = 20, + }, + { + .name = NAME_POMEG_BERRY, + .firmness = BERRY_FIRMNESS_VERY_HARD, + .size = 135, + .maxYield = 6, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Pomeg, + .description2 = gBerryDescriptionPart2_Pomeg, + .stageDuration = 3, + .spicy = 10, + .dry = 0, + .sweet = 10, + .bitter = 10, + .sour = 0, + .smoothness = 20, + }, + { + .name = NAME_KELPSY_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 150, + .maxYield = 6, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Kelpsy, + .description2 = gBerryDescriptionPart2_Kelpsy, + .stageDuration = 3, + .spicy = 0, + .dry = 10, + .sweet = 0, + .bitter = 10, + .sour = 10, + .smoothness = 20, + }, + { + .name = NAME_QUALOT_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 110, + .maxYield = 6, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Qualot, + .description2 = gBerryDescriptionPart2_Qualot, + .stageDuration = 3, + .spicy = 10, + .dry = 0, + .sweet = 10, + .bitter = 0, + .sour = 10, + .smoothness = 20, + }, + { + .name = NAME_HONDEW_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 162, + .maxYield = 6, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Hondew, + .description2 = gBerryDescriptionPart2_Hondew, + .stageDuration = 3, + .spicy = 10, + .dry = 10, + .sweet = 0, + .bitter = 10, + .sour = 0, + .smoothness = 20, + }, + { + .name = NAME_GREPA_BERRY, + .firmness = BERRY_FIRMNESS_SOFT, + .size = 149, + .maxYield = 6, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Grepa, + .description2 = gBerryDescriptionPart2_Grepa, + .stageDuration = 3, + .spicy = 0, + .dry = 10, + .sweet = 10, + .bitter = 0, + .sour = 10, + .smoothness = 20, + }, + { + .name = NAME_TAMATO_BERRY, + .firmness = BERRY_FIRMNESS_SOFT, + .size = 200, + .maxYield = 4, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Tamato, + .description2 = gBerryDescriptionPart2_Tamato, + .stageDuration = 6, + .spicy = 20, + .dry = 10, + .sweet = 0, + .bitter = 0, + .sour = 0, + .smoothness = 30, + }, + { + .name = NAME_CORNN_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 75, + .maxYield = 4, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Cornn, + .description2 = gBerryDescriptionPart2_Cornn, + .stageDuration = 6, + .spicy = 0, + .dry = 20, + .sweet = 10, + .bitter = 0, + .sour = 0, + .smoothness = 30, + }, + { + .name = NAME_MAGOST_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 140, + .maxYield = 4, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Magost, + .description2 = gBerryDescriptionPart2_Magost, + .stageDuration = 6, + .spicy = 0, + .dry = 0, + .sweet = 20, + .bitter = 10, + .sour = 0, + .smoothness = 30, + }, + { + .name = NAME_RABUTA_BERRY, + .firmness = BERRY_FIRMNESS_SOFT, + .size = 226, + .maxYield = 4, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Rabuta, + .description2 = gBerryDescriptionPart2_Rabuta, + .stageDuration = 6, + .spicy = 0, + .dry = 0, + .sweet = 0, + .bitter = 20, + .sour = 10, + .smoothness = 30, + }, + { + .name = NAME_NOMEL_BERRY, + .firmness = BERRY_FIRMNESS_SUPER_HARD, + .size = 285, + .maxYield = 4, + .minYield = 2, + .description1 = gBerryDescriptionPart1_Nomel, + .description2 = gBerryDescriptionPart2_Nomel, + .stageDuration = 6, + .spicy = 10, + .dry = 0, + .sweet = 0, + .bitter = 0, + .sour = 20, + .smoothness = 30, + }, + { + .name = NAME_SPELON_BERRY, + .firmness = BERRY_FIRMNESS_SOFT, + .size = 133, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Spelon, + .description2 = gBerryDescriptionPart2_Spelon, + .stageDuration = 18, + .spicy = 40, + .dry = 10, + .sweet = 0, + .bitter = 0, + .sour = 0, + .smoothness = 70, + }, + { + .name = NAME_PAMTRE_BERRY, + .firmness = BERRY_FIRMNESS_VERY_SOFT, + .size = 244, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Pamtre, + .description2 = gBerryDescriptionPart2_Pamtre, + .stageDuration = 18, + .spicy = 0, + .dry = 40, + .sweet = 10, + .bitter = 0, + .sour = 0, + .smoothness = 70, + }, + { + .name = NAME_WATMEL_BERRY, + .firmness = BERRY_FIRMNESS_SOFT, + .size = 250, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Watmel, + .description2 = gBerryDescriptionPart2_Watmel, + .stageDuration = 18, + .spicy = 0, + .dry = 0, + .sweet = 40, + .bitter = 10, + .sour = 0, + .smoothness = 70, + }, + { + .name = NAME_DURIN_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 280, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Durin, + .description2 = gBerryDescriptionPart2_Durin, + .stageDuration = 18, + .spicy = 0, + .dry = 0, + .sweet = 0, + .bitter = 40, + .sour = 10, + .smoothness = 70, + }, + { + .name = NAME_BELUE_BERRY, + .firmness = BERRY_FIRMNESS_VERY_SOFT, + .size = 300, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Belue, + .description2 = gBerryDescriptionPart2_Belue, + .stageDuration = 18, + .spicy = 10, + .dry = 0, + .sweet = 0, + .bitter = 0, + .sour = 40, + .smoothness = 70, + }, + { + .name = NAME_LIECHI_BERRY, + .firmness = BERRY_FIRMNESS_VERY_HARD, + .size = 111, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Liechi, + .description2 = gBerryDescriptionPart2_Liechi, + .stageDuration = 24, + .spicy = 40, + .dry = 0, + .sweet = 40, + .bitter = 0, + .sour = 10, + .smoothness = 80, + }, + { + .name = NAME_GANLON_BERRY, + .firmness = BERRY_FIRMNESS_VERY_HARD, + .size = 33, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Ganlon, + .description2 = gBerryDescriptionPart2_Ganlon, + .stageDuration = 24, + .spicy = 0, + .dry = 40, + .sweet = 0, + .bitter = 40, + .sour = 0, + .smoothness = 80, + }, + { + .name = NAME_SALAC_BERRY, + .firmness = BERRY_FIRMNESS_VERY_HARD, + .size = 95, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Salac, + .description2 = gBerryDescriptionPart2_Salac, + .stageDuration = 24, + .spicy = 0, + .dry = 0, + .sweet = 40, + .bitter = 0, + .sour = 40, + .smoothness = 80, + }, + { + .name = NAME_PETAYA_BERRY, + .firmness = BERRY_FIRMNESS_VERY_HARD, + .size = 237, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Petaya, + .description2 = gBerryDescriptionPart2_Petaya, + .stageDuration = 24, + .spicy = 40, + .dry = 0, + .sweet = 0, + .bitter = 40, + .sour = 0, + .smoothness = 80, + }, + { + .name = NAME_APICOT_BERRY, + .firmness = BERRY_FIRMNESS_HARD, + .size = 75, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Apicot, + .description2 = gBerryDescriptionPart2_Apicot, + .stageDuration = 24, + .spicy = 0, + .dry = 40, + .sweet = 0, + .bitter = 0, + .sour = 40, + .smoothness = 80, + }, + { + .name = NAME_LANSAT_BERRY, + .firmness = BERRY_FIRMNESS_SOFT, + .size = 97, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Lansat, + .description2 = gBerryDescriptionPart2_Lansat, + .stageDuration = 24, + .spicy = 10, + .dry = 10, + .sweet = 10, + .bitter = 10, + .sour = 10, + .smoothness = 30, + }, + { + .name = NAME_STARF_BERRY, + .firmness = BERRY_FIRMNESS_SUPER_HARD, + .size = 153, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Starf, + .description2 = gBerryDescriptionPart2_Starf, + .stageDuration = 24, + .spicy = 10, + .dry = 10, + .sweet = 10, + .bitter = 10, + .sour = 10, + .smoothness = 30, + }, + { + .name = NAME_ENIGMA_BERRY, + .firmness = BERRY_FIRMNESS_UNKNOWN, + .size = 0, + .maxYield = 2, + .minYield = 1, + .description1 = gBerryDescriptionPart1_Enigma, + .description2 = gBerryDescriptionPart2_Enigma, + .stageDuration = 24, + .spicy = 40, + .dry = 40, + .sweet = 40, + .bitter = 40, + .sour = 40, + .smoothness = 40, + }, +}; + +const struct BerryTree gBlankBerryTree = {0}; -extern struct Berry gBerries[]; extern u8 BerryTreeScript; -extern struct BerryTree gUnknown_083CD780; extern u16 gScriptItemId; extern u16 gScriptLastTalked; extern u16 gSpecialVar_0x8004; extern u16 gSpecialVar_0x8005; extern u16 gSpecialVar_0x8006; -void unref_sub_80B4884(void) +// unused +void ClearEnigmaBerries(void) { CpuFill16(0, &gSaveBlock1.enigmaBerry, sizeof(gSaveBlock1.enigmaBerry)); } -// setEnigmaBerry -void sub_80B48A8(u8 *src) +void SetEnigmaBerry(u8 *src) { - unsigned int i; + u32 i; u8 *dest = (u8*)&gSaveBlock1.enigmaBerry; - + for (i = 0; i < sizeof(gSaveBlock1.enigmaBerry); i++) dest[i] = src[i]; + gSaveBlock1.enigmaBerry.berry.description1 = gSaveBlock1.enigmaBerry.description1; gSaveBlock1.enigmaBerry.berry.description2 = gSaveBlock1.enigmaBerry.description2; } -// checksum -u32 sub_80B48F8(struct EnigmaBerry *enigmaBerry) +u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry) { - u8 *description1; - u8 *description2; - unsigned int i; + const u8 *description1; + const u8 *description2; + u32 i; u32 checksum; u8 *dest; @@ -51,7 +1013,7 @@ u32 sub_80B48F8(struct EnigmaBerry *enigmaBerry) dest = (u8*)enigmaBerry; checksum = 0; - for (i = 0; i < ((int)&gSaveBlock1.enigmaBerry.checksum - (int)&gSaveBlock1.enigmaBerry); i++) + for (i = 0; i < ((u32)&gSaveBlock1.enigmaBerry.checksum - (u32)&gSaveBlock1.enigmaBerry); i++) { checksum += dest[i]; } @@ -62,20 +1024,20 @@ u32 sub_80B48F8(struct EnigmaBerry *enigmaBerry) return checksum; } -bool32 sub_80B4940(void) +bool32 IsEnigmaBerryValid(void) { if (!gSaveBlock1.enigmaBerry.berry.stageDuration) return FALSE; if (!gSaveBlock1.enigmaBerry.berry.maxYield) return FALSE; - if (sub_80B48F8(&gSaveBlock1.enigmaBerry) != gSaveBlock1.enigmaBerry.checksum) + if (GetEnigmaBerryChecksum(&gSaveBlock1.enigmaBerry) != gSaveBlock1.enigmaBerry.checksum) return FALSE; return TRUE; } -struct Berry *GetBerryInfo(u8 berry) +const struct Berry *GetBerryInfo(u8 berry) { - if (berry == 0x2B && sub_80B4940()) + if (berry == 0x2B && IsEnigmaBerryValid()) return &gSaveBlock1.enigmaBerry.berry; else { @@ -93,7 +1055,7 @@ struct BerryTree *GetBerryTreeInfo(u8 id) bool32 FieldObjectInteractionWaterBerryTree(void) { struct BerryTree *tree = GetBerryTreeInfo(FieldObjectGetBerryTreeId(gSelectedMapObject)); - + switch (tree->stage) { case 1: @@ -114,7 +1076,7 @@ bool32 FieldObjectInteractionWaterBerryTree(void) return TRUE; } -bool32 IsPlayerFacingPlantedBerryTree(void) +bool8 IsPlayerFacingPlantedBerryTree(void) { if (GetFieldObjectScriptPointerForComparison() == &BerryTreeScript && GetStageByBerryTreeId(FieldObjectGetBerryTreeId(gSelectedMapObject)) == 0) @@ -123,21 +1085,21 @@ bool32 IsPlayerFacingPlantedBerryTree(void) return FALSE; } -u8 WaterBerryTree(void) +bool8 TryToWaterBerryTree(void) { if (GetFieldObjectScriptPointerForComparison() != &BerryTreeScript) - return 0; + return FALSE; else return FieldObjectInteractionWaterBerryTree(); } -void sub_80B4A90(void) +void ClearBerryTrees(void) { int i; struct SaveBlock1 *saveBlock1 = &gSaveBlock1; - struct BerryTree berryTree = gUnknown_083CD780; - - for (i = 0; i < 128; i++) + struct BerryTree berryTree = gBlankBerryTree; + + for (i = 0; i < (u8)ARRAY_COUNT(saveBlock1->berryTrees); i++) // casting to u8 fixes a mismatched signed compare. what saveBlock1->berryTrees[i] = berryTree; } @@ -164,44 +1126,44 @@ bool32 BerryTreeGrow(struct BerryTree *tree) tree->berryYield = 0; tree->stage = 2; if (++tree->regrowthCount == 10) - *tree = gUnknown_083CD780; + *tree = gBlankBerryTree; break; } return TRUE; } -void BerryTreeTimeUpdate(int time) +void BerryTreeTimeUpdate(s32 minutes) { int i; struct BerryTree *tree; - - for (i = 0; i < 128; i++) + + for (i = 0; i < (u8)ARRAY_COUNT(gSaveBlock1.berryTrees); i++) { tree = &gSaveBlock1.berryTrees[i]; if (tree->berry && tree->stage && !tree->growthSparkle) { - if (time >= GetStageDurationByBerryType(tree->berry) * 71) + if (minutes >= GetStageDurationByBerryType(tree->berry) * 71) { - *tree = gUnknown_083CD780; + *tree = gBlankBerryTree; } else { - int time2 = time; - - while (time2 != 0) + s32 time = minutes; + + while (time != 0) { - if (tree->secondsUntilNextStage > time2) + if (tree->minutesUntilNextStage > time) { - tree->secondsUntilNextStage -= time2; + tree->minutesUntilNextStage -= time; break; } - time2 -= tree->secondsUntilNextStage; - tree->secondsUntilNextStage = GetStageDurationByBerryType(tree->berry); + time -= tree->minutesUntilNextStage; + tree->minutesUntilNextStage = GetStageDurationByBerryType(tree->berry); if (!BerryTreeGrow(tree)) break; if (tree->stage == 5) - tree->secondsUntilNextStage *= 4; + tree->minutesUntilNextStage *= 4; } } } @@ -211,15 +1173,15 @@ void BerryTreeTimeUpdate(int time) void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle) { struct BerryTree *tree = GetBerryTreeInfo(id); - - *tree = gUnknown_083CD780; + + *tree = gBlankBerryTree; tree->berry = berry; - tree->secondsUntilNextStage = GetStageDurationByBerryType(berry); + tree->minutesUntilNextStage = GetStageDurationByBerryType(berry); tree->stage = stage; if (stage == 5) { tree->berryYield = CalcBerryYield(tree); - tree->secondsUntilNextStage *= 4; + tree->minutesUntilNextStage *= 4; } if (!sparkle) { @@ -229,7 +1191,7 @@ void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle) void RemoveBerryTree(u8 id) { - gSaveBlock1.berryTrees[id] = gUnknown_083CD780; + gSaveBlock1.berryTrees[id] = gBlankBerryTree; } u8 GetBerryTypeByBerryTreeId(u8 id) @@ -245,7 +1207,7 @@ u8 GetStageByBerryTreeId(u8 id) u8 ItemIdToBerryType(u16 item) { u16 berry = item - FIRST_BERRY; - + if (berry > LAST_BERRY - FIRST_BERRY) return 1; else @@ -255,7 +1217,7 @@ u8 ItemIdToBerryType(u16 item) u16 BerryTypeToItemId(u16 berry) { u16 item = berry - 1; - + if (item > LAST_BERRY - FIRST_BERRY) return FIRST_BERRY; else @@ -264,8 +1226,8 @@ u16 BerryTypeToItemId(u16 berry) void GetBerryNameByBerryType(u8 berry, u8 *string) { - memcpy(string, GetBerryInfo(berry)->name, 6); - string[6] = EOS; + memcpy(string, GetBerryInfo(berry)->name, BERRY_NAME_LENGTH); + string[BERRY_NAME_LENGTH] = EOS; } void ResetBerryTreeSparkleFlag(u8 id) @@ -276,7 +1238,7 @@ void ResetBerryTreeSparkleFlag(u8 id) u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree) { u8 count = 0; - + if (tree->watered1) count++; if (tree->watered2) @@ -299,7 +1261,7 @@ u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water) u32 randMax; u32 rand; u32 extraYield; - + if (water == 0) return min; else @@ -307,7 +1269,7 @@ u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water) randMin = (max - min) * (water - 1); randMax = (max - min) * (water); rand = randMin + Random() % (randMax - randMin + 1); - + if ((rand & 3) > 1) extraYield = rand / 4 + 1; else @@ -318,10 +1280,10 @@ u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water) u8 CalcBerryYield(struct BerryTree *tree) { - struct Berry *berry = GetBerryInfo(tree->berry); + const struct Berry *berry = GetBerryInfo(tree->berry); u8 min = berry->minYield; u8 max = berry->maxYield; - + return CalcBerryYieldInternal(max, min, BerryTreeGetNumStagesWatered(tree)); } @@ -342,7 +1304,7 @@ void FieldObjectInteractionGetBerryTreeData(void) u8 unk; u8 group; u8 num; - + id = FieldObjectGetBerryTreeId(gSelectedMapObject); berry = GetBerryTypeByBerryTreeId(id); ResetBerryTreeSparkleFlag(id); @@ -366,7 +1328,7 @@ void sub_80B4EE4(void) void FieldObjectInteractionPlantBerryTree(void) { u8 berry = ItemIdToBerryType(gScriptItemId); - + PlantBerryTree(FieldObjectGetBerryTreeId(gSelectedMapObject), berry, 1, TRUE); FieldObjectInteractionGetBerryTreeData(); } @@ -375,7 +1337,7 @@ void FieldObjectInteractionPickBerryTree(void) { u8 id = FieldObjectGetBerryTreeId(gSelectedMapObject); u8 berry = GetBerryTypeByBerryTreeId(id); - + gSpecialVar_0x8004 = AddBagItem(BerryTypeToItemId(berry), GetBerryCountByBerryTreeId(id)); } @@ -387,7 +1349,7 @@ void FieldObjectInteractionRemoveBerryTree(void) u8 PlayerHasBerries(void) { - return IsBagPocketNonEmpty(4); + return IsBagPocketNonEmpty(BAG_BERRIES); } void ResetBerryTreeSparkleFlags(void) @@ -405,7 +1367,7 @@ void ResetBerryTreeSparkleFlags(void) top = cam_top + 3; right = cam_left + 14; bottom = top + 8; - for (i = 0; i < 16; i++) + for (i = 0; i < (u8)ARRAY_COUNT(gSaveBlock1.mapObjects); i++) { if (gMapObjects[i].active && gMapObjects[i].animPattern == 12) { diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c index e7ef9ca76..116ca2cca 100644 --- a/src/berry_tag_screen.c +++ b/src/berry_tag_screen.c @@ -1,45 +1,46 @@ #include "global.h" #include "berry_tag_screen.h" -#include "asm.h" #include "berry.h" #include "decompress.h" +#include "field_map_obj.h" +#include "item_menu.h" +#include "items.h" #include "main.h" #include "menu.h" +#include "menu_helpers.h" #include "palette.h" #include "rom4.h" #include "songs.h" #include "sound.h" #include "sprite.h" #include "string_util.h" +#include "strings.h" #include "task.h" #include "text.h" #define OFFSET_7B (123) -#define FIRST_BERRY (0x85) // ITEM_CHERI_BERRY +#define FIRST_BERRY ITEM_CHERI_BERRY -struct Struct2000000 { +struct Struct2000000 +{ /*0x00*/ u8 filler_0[0x1FFFF]; - /*0x1FFFF*/ bool8 var_1FFFF; + /*0x1FFFF*/ u8 var_1FFFF; }; -struct BerryTagStatus { +struct BerryTagStatus +{ s16 circles[5]; }; extern struct Struct2000000 unk_2000000; -extern u16 gBGTilemapBuffers[4][0x400]; extern u8 gUnknown_0203932C; extern struct BerryTagStatus gUnknown_0203932E; extern u16 gScriptItemId; extern u16 gUnknown_030041B4; -extern const struct SpriteSheet gUnknown_083C1F74; -extern const struct SpritePalette gUnknown_083C1F7C; +extern const struct CompressedSpriteSheet gUnknown_083C1F74; +extern const struct CompressedSpritePalette gUnknown_083C1F7C; -extern u8 gOtherText_ThreeQuestions2[]; -extern u8 gOtherText_Size[]; -extern u8 gOtherText_Firm[]; -extern u8 gContestStatsText_Unknown1[]; extern u8 *gUnknown_0841192C[]; extern u8 gBerryCheck_Gfx[]; @@ -58,19 +59,21 @@ static void sub_8146480(u8 taskid); static void sub_81464E4(void); static void sub_8146600(u8 berry); // static void sub_81466A0(void); -static void sub_81466E8(u8 taskId, s32 direction); +static void sub_81466E8(u8 taskId, s8 direction); // static void sub_8146798(u8 berry); -// static void sub_8146810(u8 berry); -// static void sub_81468BC(void); +static void sub_8146810(s8 berry); +static void sub_81468BC(void); -static void sub_8146014(void) { +static void sub_8146014(void) +{ AnimateSprites(); BuildOamBuffer(); RunTasks(); UpdatePaletteFade(); } -static void sub_814602C(void) { +static void sub_814602C(void) +{ REG_BG0VOFS = gUnknown_030041B4; REG_BG1VOFS = gUnknown_030041B4; @@ -79,794 +82,491 @@ static void sub_814602C(void) { TransferPlttBuffer(); } -static bool8 sub_8146058(void) { +static bool8 sub_8146058(void) +{ u8 berry; u16 backup; - switch (gMain.state) { - case 0: - sub_80F9438(); - sub_80F9368(); - sub_8146288(); - REG_BLDCNT = 0; - gMain.state += 1; + switch (gMain.state) + { + case 0: + sub_80F9438(); + sub_80F9368(); + sub_8146288(); + REG_BLDCNT = 0; + gMain.state += 1; + break; + case 1: + ResetPaletteFade(); + gPaletteFade.bufferTransferDisabled = 1; + gMain.state += 1; + break; + case 2: + ResetSpriteData(); + gMain.state += 1; + break; + case 3: + SetUpWindowConfig(&gWindowConfig_81E6E18); + gMain.state += 1; + break; + case 4: + MultistepInitMenuWindowBegin(&gWindowConfig_81E6E18); + gMain.state += 1; + break; + case 5: + if (!MultistepInitMenuWindowContinue()) break; - - case 1: - ResetPaletteFade(); - gPaletteFade.bufferTransferDisabled = 1; - gMain.state += 1; - break; - - case 2: - ResetSpriteData(); - gMain.state += 1; - break; - - case 3: - SetUpWindowConfig(&gWindowConfig_81E6E18); - gMain.state += 1; - break; - - case 4: - MultistepInitMenuWindowBegin(&gWindowConfig_81E6E18); - gMain.state += 1; - break; - - case 5: - if (!MultistepInitMenuWindowContinue()) { - return FALSE; - } - unk_2000000.var_1FFFF = 0; - gMain.state += 1; - break; - - case 6: - if (!sub_81462B8()) { - break; - } - - unk_2000000.var_1FFFF = 0; - gMain.state += 1; - break; - - case 7: - sub_81464E4(); - gMain.state += 1; + unk_2000000.var_1FFFF = 0; + gMain.state += 1; + break; + case 6: + if (!sub_81462B8()) break; - - case 8: - berry = gScriptItemId + OFFSET_7B; - gUnknown_0203932C = sub_80A7D8C(berry, 56, 64); - gMain.state += 1; - break; - - case 9: - sub_8146600(gScriptItemId + OFFSET_7B); - gMain.state += 1; - break; - - case 10: - backup = REG_IME; - REG_IME = 0; - REG_IE |= INTR_FLAG_VBLANK; - REG_IME = backup; - - REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; - SetVBlankCallback(sub_814602C); - REG_DISPCNT = DISPCNT_OBJ_ON | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_1D_MAP; - gMain.state += 1; - break; - - case 11: - if (sub_8055870() == TRUE) { - break; - } - gMain.state += 1; + unk_2000000.var_1FFFF = 0; + gMain.state += 1; + break; + case 7: + sub_81464E4(); + gMain.state += 1; + break; + case 8: + berry = gScriptItemId + OFFSET_7B; + gUnknown_0203932C = sub_80A7D8C(berry, 56, 64); + gMain.state += 1; + break; + case 9: + sub_8146600(gScriptItemId + OFFSET_7B); + gMain.state += 1; + break; + case 10: + backup = REG_IME; + REG_IME = 0; + REG_IE |= INTR_FLAG_VBLANK; + REG_IME = backup; + REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; + SetVBlankCallback(sub_814602C); + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_ON | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_1D_MAP; + gMain.state += 1; + break; + case 11: + if (sub_8055870() == TRUE) break; - - case 12: - BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - gPaletteFade.bufferTransferDisabled = 0; - SetMainCallback2(sub_8146014); - return TRUE; - + gMain.state += 1; + break; + case 12: + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + gPaletteFade.bufferTransferDisabled = 0; + SetMainCallback2(sub_8146014); + return TRUE; } return FALSE; } -void BerryTagScreen_814625C(u8 taskId) { - do { - if (sub_8146058() == TRUE) { +void BerryTagScreen_814625C(u8 taskId) +{ + do + { + if (sub_8146058() == TRUE) + { CreateTask(sub_8146480, 0); return; } - } while (sub_80F9344() != TRUE); } -static void sub_8146288(void) { - REG_BG1CNT = 0x502; - REG_BG2CNT = 0x600; - REG_BG3CNT = 0x703; +static void sub_8146288(void) +{ + REG_BG1CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(5) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(6) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; gUnknown_030041B4 = 0; } -#ifdef NONMATCHING -bool8 sub_81462B8(void) { +bool8 sub_81462B8(void) +{ u16 i; - - switch (unk_2000000.var_1FFFF) { - case 0: - LZDecompressVram(gBerryCheck_Gfx, (void *) VRAM); - unk_2000000.var_1FFFF += 1; - break; - - case 1: - LZDecompressVram(gUnknown_08E788E4, (void *) VRAM + 0x2800); - unk_2000000.var_1FFFF += 1; - break; - - case 2: - LZDecompressVram(gUnknown_08E78A84, (void *) VRAM + 0x3000); - unk_2000000.var_1FFFF += 1; - break; - - case 3: - for (i = 0; i < 0x400; i++) { - u16 (*buffer)[0x400] = &gBGTilemapBuffers[3]; - if (gSaveBlock2.playerGender == MALE) { - (*buffer)[i] = 0x4042; - } else { - (*buffer)[i] = 0x5042; - } - } - unk_2000000.var_1FFFF += 1; - break; - - case 4: - LoadCompressedPalette(gBerryCheck_Pal, 0, 96 * 2); - unk_2000000.var_1FFFF += 1; - break; - - case 5: - LoadCompressedObjectPic(&gUnknown_083C1F74); - unk_2000000.var_1FFFF += 1; - break; - - case 6: - LoadCompressedObjectPalette(&gUnknown_083C1F7C); - unk_2000000.var_1FFFF = 0; - return TRUE; + void *addr; + + switch (unk_2000000.var_1FFFF) + { + case 0: + LZDecompressVram(gBerryCheck_Gfx, (void *)VRAM); + unk_2000000.var_1FFFF += 1; + break; + case 1: + LZDecompressVram(gUnknown_08E788E4, (void *)VRAM + 0x2800); + unk_2000000.var_1FFFF += 1; + break; + case 2: + LZDecompressVram(gUnknown_08E78A84, (void *)VRAM + 0x3000); + unk_2000000.var_1FFFF += 1; + break; + case 3: + for (i = 0; i < 0x400; i++) + { + if (gSaveBlock2.playerGender == MALE) + gBGTilemapBuffers[2][i] = 0x4042; + else + gBGTilemapBuffers[2][i] = 0x5042; + } + addr = (void *)(VRAM + 0x3800); + DmaCopy16(3, gBGTilemapBuffers[2], addr, 0x800); + unk_2000000.var_1FFFF += 1; + break; + case 4: + LoadCompressedPalette(gBerryCheck_Pal, 0, 96 * 2); + unk_2000000.var_1FFFF += 1; + break; + case 5: + LoadCompressedObjectPic(&gUnknown_083C1F74); + unk_2000000.var_1FFFF += 1; + break; + case 6: + LoadCompressedObjectPalette(&gUnknown_083C1F7C); + unk_2000000.var_1FFFF = 0; + return TRUE; } return FALSE; } -#else -__attribute__((naked)) -static bool8 sub_81462B8(void) { - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - ldr r1, _081462D4 @ =0x02000000\n\ - ldr r2, _081462D8 @ =0x0001ffff\n\ - adds r0, r1, r2\n\ - ldrb r0, [r0]\n\ - mov r12, r1\n\ - cmp r0, 0x6\n\ - bls _081462CA\n\ - b _08146404\n\ -_081462CA:\n\ - lsls r0, 2\n\ - ldr r1, _081462DC @ =_081462E0\n\ - adds r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .align 2, 0\n\ -_081462D4: .4byte 0x02000000\n\ -_081462D8: .4byte 0x0001ffff\n\ -_081462DC: .4byte _081462E0\n\ - .align 2, 0\n\ -_081462E0:\n\ - .4byte _081462FC\n\ - .4byte _0814630C\n\ - .4byte _0814632C\n\ - .4byte _08146340\n\ - .4byte _081463A4\n\ - .4byte _081463C4\n\ - .4byte _081463E4\n\ -_081462FC:\n\ - ldr r0, _08146308 @ =gBerryCheck_Gfx\n\ - movs r1, 0xC0\n\ - lsls r1, 19\n\ - bl LZDecompressVram\n\ - b _081463CA\n\ - .align 2, 0\n\ -_08146308: .4byte gBerryCheck_Gfx\n\ -_0814630C:\n\ - ldr r0, _0814631C @ =gUnknown_08E788E4\n\ - ldr r1, _08146320 @ =0x06002800\n\ - bl LZDecompressVram\n\ - ldr r1, _08146324 @ =0x02000000\n\ - ldr r2, _08146328 @ =0x0001ffff\n\ - adds r1, r2\n\ - b _081463D0\n\ - .align 2, 0\n\ -_0814631C: .4byte gUnknown_08E788E4\n\ -_08146320: .4byte 0x06002800\n\ -_08146324: .4byte 0x02000000\n\ -_08146328: .4byte 0x0001ffff\n\ -_0814632C:\n\ - ldr r0, _08146338 @ =gUnknown_08E78A84\n\ - ldr r1, _0814633C @ =0x06003000\n\ - bl LZDecompressVram\n\ - b _081463CA\n\ - .align 2, 0\n\ -_08146338: .4byte gUnknown_08E78A84\n\ -_0814633C: .4byte 0x06003000\n\ -_08146340:\n\ - movs r1, 0\n\ - ldr r7, _0814635C @ =gBGTilemapBuffers + 0x1000\n\ - adds r2, r7, 0\n\ - ldr r6, _08146360 @ =0x00004042\n\ - ldr r5, _08146364 @ =gSaveBlock2\n\ - ldr r4, _08146368 @ =0x00005042\n\ - ldr r3, _0814636C @ =0x000003ff\n\ -_0814634E:\n\ - ldrb r0, [r5, 0x8]\n\ - cmp r0, 0\n\ - bne _08146370\n\ - lsls r0, r1, 1\n\ - adds r0, r2\n\ - strh r6, [r0]\n\ - b _08146376\n\ - .align 2, 0\n\ -_0814635C: .4byte gBGTilemapBuffers + 0x1000\n\ -_08146360: .4byte 0x00004042\n\ -_08146364: .4byte gSaveBlock2\n\ -_08146368: .4byte 0x00005042\n\ -_0814636C: .4byte 0x000003ff\n\ -_08146370:\n\ - lsls r0, r1, 1\n\ - adds r0, r2\n\ - strh r4, [r0]\n\ -_08146376:\n\ - adds r0, r1, 0x1\n\ - lsls r0, 16\n\ - lsrs r1, r0, 16\n\ - cmp r1, r3\n\ - bls _0814634E\n\ - ldr r1, _08146394 @ =0x06003800\n\ - ldr r0, _08146398 @ =0x040000d4\n\ - str r7, [r0]\n\ - str r1, [r0, 0x4]\n\ - ldr r1, _0814639C @ =0x80000400\n\ - str r1, [r0, 0x8]\n\ - ldr r0, [r0, 0x8]\n\ - ldr r1, _081463A0 @ =0x0001ffff\n\ - add r1, r12\n\ - b _081463D0\n\ - .align 2, 0\n\ -_08146394: .4byte 0x06003800\n\ -_08146398: .4byte 0x040000d4\n\ -_0814639C: .4byte 0x80000400\n\ -_081463A0: .4byte 0x0001ffff\n\ -_081463A4:\n\ - ldr r0, _081463B8 @ =gBerryCheck_Pal\n\ - movs r1, 0\n\ - movs r2, 0xC0\n\ - bl LoadCompressedPalette\n\ - ldr r1, _081463BC @ =0x02000000\n\ - ldr r2, _081463C0 @ =0x0001ffff\n\ - adds r1, r2\n\ - b _081463D0\n\ - .align 2, 0\n\ -_081463B8: .4byte gBerryCheck_Pal\n\ -_081463BC: .4byte 0x02000000\n\ -_081463C0: .4byte 0x0001ffff\n\ -_081463C4:\n\ - ldr r0, _081463D8 @ =gUnknown_083C1F74\n\ - bl LoadCompressedObjectPic\n\ -_081463CA:\n\ - ldr r1, _081463DC @ =0x02000000\n\ - ldr r0, _081463E0 @ =0x0001ffff\n\ - adds r1, r0\n\ -_081463D0:\n\ - ldrb r0, [r1]\n\ - adds r0, 0x1\n\ - strb r0, [r1]\n\ - b _08146404\n\ - .align 2, 0\n\ -_081463D8: .4byte gUnknown_083C1F74\n\ -_081463DC: .4byte 0x02000000\n\ -_081463E0: .4byte 0x0001ffff\n\ -_081463E4:\n\ - ldr r0, _081463F8 @ =gUnknown_083C1F7C\n\ - bl LoadCompressedObjectPalette\n\ - ldr r0, _081463FC @ =0x02000000\n\ - ldr r1, _08146400 @ =0x0001ffff\n\ - adds r0, r1\n\ - movs r1, 0\n\ - strb r1, [r0]\n\ - movs r0, 0x1\n\ - b _08146406\n\ - .align 2, 0\n\ -_081463F8: .4byte gUnknown_083C1F7C\n\ -_081463FC: .4byte 0x02000000\n\ -_08146400: .4byte 0x0001ffff\n\ -_08146404:\n\ - movs r0, 0\n\ -_08146406:\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n\ - .syntax divided\n"); -} -#endif -static void sub_814640C(u8 taskId) { - if (gPaletteFade.active) { - return; +static void sub_814640C(u8 taskId) +{ + if (!gPaletteFade.active) + { + SetMainCallback2(sub_80A5B40); + sub_80A7DD4(); + gpu_pal_allocator_reset__manage_upper_four(); + DestroyTask(taskId); } - - SetMainCallback2(sub_80A5B40); - sub_80A7DD4(); - gpu_pal_allocator_reset__manage_upper_four(); - DestroyTask(taskId); } -static void sub_8146440(u8 taskId) { +static void sub_8146440(u8 taskId) +{ PlaySE(SE_SELECT); BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - gTasks[taskId].func = sub_814640C; } -static void sub_8146480(u8 taskid) { - register u16 keys asm("r1"); - - if (gPaletteFade.active) { - return; - } - - keys = gMain.newAndRepeatedKeys & (DPAD_RIGHT | DPAD_LEFT | DPAD_UP | DPAD_DOWN); - if (keys == DPAD_UP) { - sub_81466E8(taskid, -1); - } - - keys = gMain.newAndRepeatedKeys & (DPAD_RIGHT | DPAD_LEFT | DPAD_UP | DPAD_DOWN); - if (keys == DPAD_DOWN) { - sub_81466E8(taskid, 1); - } - - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) { - sub_8146440(taskid); +static void sub_8146480(u8 taskid) +{ + if (!gPaletteFade.active) + { + if ((gMain.newAndRepeatedKeys & (DPAD_RIGHT | DPAD_LEFT | DPAD_UP | DPAD_DOWN)) == DPAD_UP) + sub_81466E8(taskid, -1); + if ((gMain.newAndRepeatedKeys & (DPAD_RIGHT | DPAD_LEFT | DPAD_UP | DPAD_DOWN)) == DPAD_DOWN) + sub_81466E8(taskid, 1); + if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + sub_8146440(taskid); } } -static void sub_81464E4(void) { - struct Berry *berryInfo; +static void sub_81464E4(void) +{ + const struct Berry *berryInfo; +#ifdef UNITS_IMPERIAL u32 size; s32 sizeMajor; s32 sizeMinor; +#endif +#if GERMAN + u8 buffer[16]; +#endif berryInfo = GetBerryInfo(gScriptItemId + OFFSET_7B + 1); ConvertIntToDecimalStringN(gStringVar1, gScriptItemId - FIRST_BERRY + 1, STR_CONV_MODE_LEADING_ZEROS, 2); MenuPrint(gStringVar1, 12, 4); +#if ENGLISH MenuPrint(berryInfo->name, 14, 4); +#elif GERMAN + StringCopy(buffer, berryInfo->name); + StringAppend(buffer, gOtherText_Berry2); + MenuPrint(buffer, 14, 4); +#endif + MenuPrint(berryInfo->description1, 4, 14); MenuPrint(berryInfo->description2, 4, 16); +#ifdef UNITS_IMPERIAL size = (berryInfo->size * 1000) / 254; - if (size % 10 >= 5) { + if (size % 10 >= 5) size += 10; - } sizeMinor = (size % 100) / 10; sizeMajor = size / 100; +#endif MenuPrint(gOtherText_Size, 11, 7); - if (berryInfo->size != 0) { + if (berryInfo->size != 0) + { +#ifdef UNITS_IMPERIAL ConvertIntToDecimalStringN(gStringVar1, sizeMajor, STR_CONV_MODE_LEFT_ALIGN, 2); ConvertIntToDecimalStringN(gStringVar2, sizeMinor, STR_CONV_MODE_LEFT_ALIGN, 2); +#else + ConvertIntToDecimalStringN(gStringVar1, berryInfo->size / 10, STR_CONV_MODE_LEFT_ALIGN, 2); + ConvertIntToDecimalStringN(gStringVar2, berryInfo->size % 10, STR_CONV_MODE_LEFT_ALIGN, 2); +#endif MenuPrint(gContestStatsText_Unknown1, 16, 7); - } else { + } + else + { MenuPrint(gOtherText_ThreeQuestions2, 16, 7); } MenuPrint(gOtherText_Firm, 11, 9); - if (berryInfo->firmness != 0) { + if (berryInfo->firmness != 0) MenuPrint(gUnknown_0841192C[berryInfo->firmness - 1], 16, 9); - } else { + else MenuPrint(gOtherText_ThreeQuestions2, 16, 9); - } } -#ifdef NONMATCHING -static void sub_8146600(u8 berry) { - struct Berry *berryInfo; +static void sub_8146600(u8 berry) +{ + const struct Berry *berryInfo; u16 i; - berryInfo = GetBerryInfo(berry +1); - - for (i = 0; i < 5; i++) { - gUnknown_0203932E.circles[i] |= 0xFFFF; - } + berryInfo = GetBerryInfo(berry + 1); + for (i = 0; i < 5; i++) + gUnknown_0203932E.circles[i] = (u16)gUnknown_0203932E.circles[i] | 0xFFFF; - if (berryInfo->spicy) { - // argument is the center of the circle + // argument is the center of the circle + if (berryInfo->spicy) gUnknown_0203932E.circles[0] = sub_80A7E5C(48); - } - - if (berryInfo->dry) { + if (berryInfo->dry) gUnknown_0203932E.circles[1] = sub_80A7E5C(88); - } - - if (berryInfo->sweet) { + if (berryInfo->sweet) gUnknown_0203932E.circles[2] = sub_80A7E5C(128); - } - - if (berryInfo->bitter) { + if (berryInfo->bitter) gUnknown_0203932E.circles[3] = sub_80A7E5C(168); - } - - if (berryInfo->sour) { + if (berryInfo->sour) gUnknown_0203932E.circles[4] = sub_80A7E5C(208); - } } -#else -__attribute__((naked)) -static void sub_8146600(u8 berry) { - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - lsls r0, 24\n\ - movs r1, 0x80\n\ - lsls r1, 17\n\ - adds r0, r1\n\ - lsrs r0, 24\n\ - bl GetBerryInfo\n\ - adds r4, r0, 0\n\ - movs r2, 0\n\ - ldr r5, _08146698 @ =gUnknown_0203932E\n\ - ldr r0, _0814669C @ =0x0000ffff\n\ - adds r3, r0, 0\n\ -_0814661A:\n\ - lsls r0, r2, 1\n\ - adds r0, r5\n\ - ldrh r1, [r0]\n\ - orrs r1, r3\n\ - strh r1, [r0]\n\ - adds r0, r2, 0x1\n\ - lsls r0, 16\n\ - lsrs r2, r0, 16\n\ - cmp r2, 0x4\n\ - bls _0814661A\n\ - ldrb r0, [r4, 0x15]\n\ - cmp r0, 0\n\ - beq _08146642\n\ - movs r0, 0x30\n\ - bl sub_80A7E5C\n\ - ldr r1, _08146698 @ =gUnknown_0203932E\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - strh r0, [r1]\n\ -_08146642:\n\ - ldrb r0, [r4, 0x16]\n\ - cmp r0, 0\n\ - beq _08146656\n\ - movs r0, 0x58\n\ - bl sub_80A7E5C\n\ - ldr r1, _08146698 @ =gUnknown_0203932E\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - strh r0, [r1, 0x2]\n\ -_08146656:\n\ - ldrb r0, [r4, 0x17]\n\ - cmp r0, 0\n\ - beq _0814666A\n\ - movs r0, 0x80\n\ - bl sub_80A7E5C\n\ - ldr r1, _08146698 @ =gUnknown_0203932E\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - strh r0, [r1, 0x4]\n\ -_0814666A:\n\ - ldrb r0, [r4, 0x18]\n\ - cmp r0, 0\n\ - beq _0814667E\n\ - movs r0, 0xA8\n\ - bl sub_80A7E5C\n\ - ldr r1, _08146698 @ =gUnknown_0203932E\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - strh r0, [r1, 0x6]\n\ -_0814667E:\n\ - ldrb r0, [r4, 0x19]\n\ - cmp r0, 0\n\ - beq _08146692\n\ - movs r0, 0xD0\n\ - bl sub_80A7E5C\n\ - ldr r1, _08146698 @ =gUnknown_0203932E\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - strh r0, [r1, 0x8]\n\ -_08146692:\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_08146698: .4byte gUnknown_0203932E\n\ -_0814669C: .4byte 0x0000ffff\n\ - .syntax divided\n"); -} -#endif - -void sub_81466A0(void) { +void sub_81466A0(void) +{ u16 i; - for (i = 0; i < 5; i++) { - if (gUnknown_0203932E.circles[i] != -1) { + for (i = 0; i < 5; i++) + { + if (gUnknown_0203932E.circles[i] != -1) + { DestroySprite(&gSprites[gUnknown_0203932E.circles[i]]); gUnknown_0203932E.circles[i] = -1; } } } - __attribute__((naked)) -static void sub_81466E8(u8 taskId, s32 direction) { +static void sub_81466E8(u8 taskId, s8 direction) +{ asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - lsls r0, 24\n\ - lsrs r7, r0, 24\n\ - lsls r1, 24\n\ - lsrs r2, r1, 24\n\ - lsls r0, r7, 2\n\ - adds r0, r7\n\ - lsls r0, 3\n\ - ldr r1, _08146748 @ =gTasks + 0x8\n\ - adds r6, r0, r1\n\ - ldr r4, _0814674C @ =gUnknown_03005D10\n\ - movs r0, 0xC\n\ - adds r0, r4\n\ - mov r8, r0\n\ - ldrb r1, [r0, 0x1]\n\ - ldrb r0, [r4, 0xC]\n\ - adds r1, r0\n\ - cmp r1, 0\n\ - bne _08146718\n\ - lsls r0, r2, 24\n\ - cmp r0, 0\n\ - blt _0814678C\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + lsls r1, 24\n\ + lsrs r2, r1, 24\n\ + lsls r0, r7, 2\n\ + adds r0, r7\n\ + lsls r0, 3\n\ + ldr r1, _08146748 @ =gTasks + 0x8\n\ + adds r6, r0, r1\n\ + ldr r4, _0814674C @ =gUnknown_03005D10\n\ + movs r0, 0xC\n\ + adds r0, r4\n\ + mov r8, r0\n\ + ldrb r1, [r0, 0x1]\n\ + ldrb r0, [r4, 0xC]\n\ + adds r1, r0\n\ + cmp r1, 0\n\ + bne _08146718\n\ + lsls r0, r2, 24\n\ + cmp r0, 0\n\ + blt _0814678C\n\ _08146718:\n\ - adds r0, r1, 0x1\n\ - lsls r5, r2, 24\n\ - mov r1, r8\n\ - ldrb r1, [r1, 0x2]\n\ - cmp r0, r1\n\ - bne _08146728\n\ - cmp r5, 0\n\ - bgt _0814678C\n\ + adds r0, r1, 0x1\n\ + lsls r5, r2, 24\n\ + mov r1, r8\n\ + ldrb r1, [r1, 0x2]\n\ + cmp r0, r1\n\ + bne _08146728\n\ + cmp r5, 0\n\ + bgt _0814678C\n\ _08146728:\n\ - movs r0, 0x5\n\ - bl PlaySE\n\ - mov r2, r8\n\ - ldrb r3, [r2, 0x1]\n\ - ldrb r4, [r4, 0xC]\n\ - mov r12, r4\n\ - adds r0, r3, r4\n\ - asrs r2, r5, 24\n\ - adds r1, r0, r2\n\ - cmp r1, 0\n\ - bge _08146750\n\ - negs r0, r0\n\ - strh r0, [r6, 0x2]\n\ - b _08146766\n\ - .align 2, 0\n\ + movs r0, 0x5\n\ + bl PlaySE\n\ + mov r2, r8\n\ + ldrb r3, [r2, 0x1]\n\ + ldrb r4, [r4, 0xC]\n\ + mov r12, r4\n\ + adds r0, r3, r4\n\ + asrs r2, r5, 24\n\ + adds r1, r0, r2\n\ + cmp r1, 0\n\ + bge _08146750\n\ + negs r0, r0\n\ + strh r0, [r6, 0x2]\n\ + b _08146766\n\ + .align 2, 0\n\ _08146748: .4byte gTasks + 0x8\n\ _0814674C: .4byte gUnknown_03005D10\n\ _08146750:\n\ - mov r4, r8\n\ - ldrb r0, [r4, 0x2]\n\ - cmp r1, r0\n\ - blt _08146764\n\ - subs r0, r3\n\ - mov r1, r12\n\ - subs r0, r1\n\ - subs r0, 0x1\n\ - strh r0, [r6, 0x2]\n\ - b _08146766\n\ + mov r4, r8\n\ + ldrb r0, [r4, 0x2]\n\ + cmp r1, r0\n\ + blt _08146764\n\ + subs r0, r3\n\ + mov r1, r12\n\ + subs r0, r1\n\ + subs r0, 0x1\n\ + strh r0, [r6, 0x2]\n\ + b _08146766\n\ _08146764:\n\ - strh r2, [r6, 0x2]\n\ + strh r2, [r6, 0x2]\n\ _08146766:\n\ - ldr r0, _08146780 @ =gTasks\n\ - lsls r1, r7, 2\n\ - adds r1, r7\n\ - lsls r1, 3\n\ - adds r1, r0\n\ - ldr r0, _08146784 @ =sub_8146798\n\ - str r0, [r1]\n\ - cmp r5, 0\n\ - bge _08146788\n\ - movs r2, 0x10\n\ - negs r2, r2\n\ - adds r0, r2, 0\n\ - b _0814678A\n\ - .align 2, 0\n\ + ldr r0, _08146780 @ =gTasks\n\ + lsls r1, r7, 2\n\ + adds r1, r7\n\ + lsls r1, 3\n\ + adds r1, r0\n\ + ldr r0, _08146784 @ =sub_8146798\n\ + str r0, [r1]\n\ + cmp r5, 0\n\ + bge _08146788\n\ + movs r2, 0x10\n\ + negs r2, r2\n\ + adds r0, r2, 0\n\ + b _0814678A\n\ + .align 2, 0\n\ _08146780: .4byte gTasks\n\ _08146784: .4byte sub_8146798\n\ _08146788:\n\ - movs r0, 0x10\n\ + movs r0, 0x10\n\ _0814678A:\n\ - strh r0, [r6]\n\ + strh r0, [r6]\n\ _0814678C:\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided\n"); + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .syntax divided\n"); } -__attribute__((naked)) -void sub_8146798(u8 berry) { - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - lsls r0, r4, 2\n\ - adds r0, r4\n\ - lsls r0, 3\n\ - ldr r1, _08146800 @ =gTasks + 0x8\n\ - adds r0, r1\n\ - ldr r2, _08146804 @ =gUnknown_030041B4\n\ - ldrh r1, [r0]\n\ - ldrh r5, [r2]\n\ - adds r3, r1, r5\n\ - movs r1, 0xFF\n\ - ands r3, r1\n\ - strh r3, [r2]\n\ - movs r1, 0\n\ - ldrsh r0, [r0, r1]\n\ - cmp r0, 0\n\ - ble _081467C2\n\ - cmp r3, 0x90\n\ - beq _081467CA\n\ -_081467C2:\n\ - cmp r0, 0\n\ - bge _081467E0\n\ - cmp r3, 0x70\n\ - bne _081467E0\n\ -_081467CA:\n\ - ldr r0, _08146808 @ =gTasks\n\ - lsls r1, r4, 2\n\ - adds r1, r4\n\ - lsls r1, 3\n\ - adds r1, r0\n\ - movs r0, 0xA\n\ - ldrsb r0, [r1, r0]\n\ - bl sub_8146810\n\ - bl sub_81468BC\n\ -_081467E0:\n\ - ldr r0, _08146804 @ =gUnknown_030041B4\n\ - ldrh r2, [r0]\n\ - cmp r2, 0\n\ - bne _081467FA\n\ - ldr r0, _08146808 @ =gTasks\n\ - lsls r1, r4, 2\n\ - adds r1, r4\n\ - lsls r1, 3\n\ - adds r1, r0\n\ - strh r2, [r1, 0x8]\n\ - strh r2, [r1, 0xA]\n\ - ldr r0, _0814680C @ =sub_8146480\n\ - str r0, [r1]\n\ -_081467FA:\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_08146800: .4byte gTasks + 0x8\n\ -_08146804: .4byte gUnknown_030041B4\n\ -_08146808: .4byte gTasks\n\ -_0814680C: .4byte sub_8146480\n\ - .syntax divided\n"); +void sub_8146798(u8 taskId) +{ + s16 *taskData = gTasks[taskId].data; + + gUnknown_030041B4 = (gUnknown_030041B4 + taskData[0]) & 0xFF; + if ((taskData[0] > 0 && gUnknown_030041B4 == 144) + || (taskData[0] < 0 && gUnknown_030041B4 == 112)) + { + sub_8146810(gTasks[taskId].data[1]); + sub_81468BC(); + } + if (gUnknown_030041B4 == 0) + { + gTasks[taskId].data[0] = gUnknown_030041B4; + gTasks[taskId].data[1] = gUnknown_030041B4; + gTasks[taskId].func = sub_8146480; + } } __attribute__((naked)) -void sub_8146810(u8 berry) { +static void sub_8146810(s8 berry) +{ asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - lsls r0, 24\n\ - lsrs r3, r0, 24\n\ - adds r4, r3, 0\n\ - lsls r0, r3, 24\n\ - asrs r1, r0, 24\n\ - cmp r1, 0\n\ - ble _08146848\n\ - ldr r0, _08146840 @ =gUnknown_03005D10\n\ - adds r4, r0, 0\n\ - adds r4, 0xC\n\ - ldrb r2, [r0, 0xC]\n\ - adds r1, r2, r1\n\ - adds r6, r0, 0\n\ - cmp r1, 0x7\n\ - ble _08146844\n\ - adds r0, r3, 0\n\ - adds r0, 0xF9\n\ - adds r0, r2, r0\n\ - ldrb r1, [r4, 0x1]\n\ - adds r0, r1\n\ - strb r0, [r4, 0x1]\n\ - movs r0, 0x7\n\ - b _0814686E\n\ - .align 2, 0\n\ + push {r4-r6,lr}\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + adds r4, r3, 0\n\ + lsls r0, r3, 24\n\ + asrs r1, r0, 24\n\ + cmp r1, 0\n\ + ble _08146848\n\ + ldr r0, _08146840 @ =gUnknown_03005D10\n\ + adds r4, r0, 0\n\ + adds r4, 0xC\n\ + ldrb r2, [r0, 0xC]\n\ + adds r1, r2, r1\n\ + adds r6, r0, 0\n\ + cmp r1, 0x7\n\ + ble _08146844\n\ + adds r0, r3, 0\n\ + adds r0, 0xF9\n\ + adds r0, r2, r0\n\ + ldrb r1, [r4, 0x1]\n\ + adds r0, r1\n\ + strb r0, [r4, 0x1]\n\ + movs r0, 0x7\n\ + b _0814686E\n\ + .align 2, 0\n\ _08146840: .4byte gUnknown_03005D10\n\ _08146844:\n\ - adds r0, r2, r3\n\ - b _0814686E\n\ + adds r0, r2, r3\n\ + b _0814686E\n\ _08146848:\n\ - ldr r0, _08146868 @ =gUnknown_03005D10\n\ - adds r5, r0, 0\n\ - adds r5, 0xC\n\ - ldrb r2, [r0, 0xC]\n\ - adds r1, r2, r1\n\ - adds r6, r0, 0\n\ - cmp r1, 0\n\ - bge _0814686C\n\ - adds r0, r2, r3\n\ - ldrb r1, [r5, 0x1]\n\ - adds r0, r1\n\ - movs r1, 0\n\ - strb r0, [r5, 0x1]\n\ - strb r1, [r6, 0xC]\n\ - b _08146870\n\ - .align 2, 0\n\ + ldr r0, _08146868 @ =gUnknown_03005D10\n\ + adds r5, r0, 0\n\ + adds r5, 0xC\n\ + ldrb r2, [r0, 0xC]\n\ + adds r1, r2, r1\n\ + adds r6, r0, 0\n\ + cmp r1, 0\n\ + bge _0814686C\n\ + adds r0, r2, r3\n\ + ldrb r1, [r5, 0x1]\n\ + adds r0, r1\n\ + movs r1, 0\n\ + strb r0, [r5, 0x1]\n\ + strb r1, [r6, 0xC]\n\ + b _08146870\n\ + .align 2, 0\n\ _08146868: .4byte gUnknown_03005D10\n\ _0814686C:\n\ - adds r0, r2, r4\n\ + adds r0, r2, r4\n\ _0814686E:\n\ - strb r0, [r6, 0xC]\n\ + strb r0, [r6, 0xC]\n\ _08146870:\n\ - ldr r2, _081468AC @ =gScriptItemId\n\ - movs r0, 0x3\n\ - lsls r0, 2\n\ - adds r0, r6\n\ - ldrb r1, [r0, 0x1]\n\ - ldrb r0, [r0]\n\ - adds r1, r0\n\ - ldr r0, _081468B0 @ =gUnknown_03005D24\n\ - ldr r0, [r0]\n\ - lsls r1, 2\n\ - adds r1, r0\n\ - ldrh r0, [r1]\n\ - strh r0, [r2]\n\ - ldr r0, _081468B4 @ =gUnknown_0203932C\n\ - ldrb r1, [r0]\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - ldr r1, _081468B8 @ =gSprites\n\ - adds r0, r1\n\ - bl DestroySprite\n\ - bl sub_81466A0\n\ - bl sub_80A7DD4\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ + ldr r2, _081468AC @ =gScriptItemId\n\ + movs r0, 0x3\n\ + lsls r0, 2\n\ + adds r0, r6\n\ + ldrb r1, [r0, 0x1]\n\ + ldrb r0, [r0]\n\ + adds r1, r0\n\ + ldr r0, _081468B0 @ =gUnknown_03005D24\n\ + ldr r0, [r0]\n\ + lsls r1, 2\n\ + adds r1, r0\n\ + ldrh r0, [r1]\n\ + strh r0, [r2]\n\ + ldr r0, _081468B4 @ =gUnknown_0203932C\n\ + ldrb r1, [r0]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + ldr r1, _081468B8 @ =gSprites\n\ + adds r0, r1\n\ + bl DestroySprite\n\ + bl sub_81466A0\n\ + bl sub_80A7DD4\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ _081468AC: .4byte gScriptItemId\n\ _081468B0: .4byte gUnknown_03005D24\n\ _081468B4: .4byte gUnknown_0203932C\n\ _081468B8: .4byte gSprites\n\ - .syntax divided\n"); + .syntax divided\n"); } -void sub_81468BC(void) { +static void sub_81468BC(void) +{ MenuZeroFillWindowRect(0, 4, 29, 19); sub_81464E4(); diff --git a/src/bike.c b/src/bike.c new file mode 100644 index 000000000..f37eb2144 --- /dev/null +++ b/src/bike.c @@ -0,0 +1,1015 @@ +#include "global.h" +#include "bike.h" +#include "field_map_obj.h" +#include "field_player_avatar.h" +#include "fieldmap.h" +#include "flags.h" +#include "global.fieldmap.h" +#include "metatile_behavior.h" +#include "rom4.h" +#include "songs.h" +#include "sound.h" + +extern u8 sub_80608A4(u8); + +extern u8 gUnknown_02039250; +extern u8 gUnknown_02039251; +extern u8 gUnknown_0202E854; +extern u8 gUnknown_0202E86C[]; +extern u8 gUnknown_0202E874[]; + +static void MovePlayerOnMachBike(u8, u16, u16); +static u8 GetMachBikeTransition(u8 *); +static void MachBikeTransition_FaceDirection(u8); +static void MachBikeTransition_80E517C(u8); +static void MachBikeTransition_80E51C4(u8); +static void MachBikeTransition_80E5270(u8); +static void MovePlayerOnAcroBike(u8, u16, u16); +static u8 CheckMovementInputAcroBike(u8 *, u16, u16); +static u8 AcroBikeHandleInputNormal(u8 *, u16, u16); +static u8 AcroBikeHandleInputTurning(u8 *, u16, u16); +static u8 AcroBikeHandleInputWheelieStanding(u8 *, u16, u16); +static u8 AcroBikeHandleInputBunnyHop(u8 *, u16, u16); +static u8 AcroBikeHandleInputWheelieMoving(u8 *, u16, u16); +static u8 AcroBikeHandleInputState5(u8 *, u16, u16); +static u8 AcroBikeHandleInputState6(u8 *, u16, u16); +static void AcroBikeTransition_FaceDirection(u8); +static void AcroBikeTransition_80E5708(u8); +static void AcroBikeTransition_80E5744(u8); +static void AcroBikeTransition_NormalToWheelie(u8); +static void AcroBikeTransition_80E57F8(u8); +static void AcroBikeTransition_80E5834(u8); +static void AcroBikeTransition_80E5870(u8); +static void AcroBikeTransition_80E58AC(u8); +static void AcroBikeTransition_80E5920(u8); +static void AcroBikeTransition_80E5990(u8); +static void AcroBikeTransition_80E59A0(u8); +static void AcroBikeTransition_80E5A30(u8); +static void AcroBikeTransition_80E5AC0(u8); +static void sub_80E5B60(u16, u16); +static u8 sub_80E5C2C(void); +static void sub_80E5C7C(u8); +static void sub_80E5CB8(u8); +static u8 sub_80E5CF4(u16); +static u8 get_some_collision(u8); +static u8 sub_80E5DA0(struct MapObject *, s16, s16, u8, u8); +static bool8 IsRunningDisallowedByMetatile(u8); +static void sub_80E5E4C(); +static u8 CanBikeFaceDirOnMetatile(u8, u8); +static bool8 sub_80E5EC0(u8, u8); +static void sub_80E6024(void); + +static void (*const sMachBikeTransitions[])(u8) = +{ + MachBikeTransition_FaceDirection, + MachBikeTransition_80E517C, + MachBikeTransition_80E51C4, + MachBikeTransition_80E5270, +}; + +static void (*const gUnknown_083DB5A4[])(u8) = +{ + PlayerGoSpeed0, + sub_80593C4, + sub_80593F4, +}; + +static void (*const sAcroBikeTransitions[])(u8) = +{ + AcroBikeTransition_FaceDirection, + AcroBikeTransition_80E5708, + AcroBikeTransition_80E5744, + AcroBikeTransition_NormalToWheelie, + AcroBikeTransition_80E57F8, + AcroBikeTransition_80E5834, + AcroBikeTransition_80E5870, + AcroBikeTransition_80E58AC, + AcroBikeTransition_80E5920, + AcroBikeTransition_80E5990, + AcroBikeTransition_80E59A0, + AcroBikeTransition_80E5A30, + AcroBikeTransition_80E5AC0, +}; + +static u8 (*const sAcroBikeInputHandlers[])(u8 *, u16, u16) = +{ + AcroBikeHandleInputNormal, + AcroBikeHandleInputTurning, + AcroBikeHandleInputWheelieStanding, + AcroBikeHandleInputBunnyHop, + AcroBikeHandleInputWheelieMoving, + AcroBikeHandleInputState5, + AcroBikeHandleInputState6, +}; + +const u16 gMachBikeSpeeds[] = {SPEED_NORMAL, SPEED_FAST, SPEED_FASTEST}; +static const u8 Unknown_3DB606[] = {4, 0}; + +static const struct UnknownStruct1 gUnknown_083DB608[] = +{ + {1, 2, 15, 15, Unknown_3DB606, Unknown_3DB606, 1}, + {2, 2, 15, 15, Unknown_3DB606, Unknown_3DB606, 2}, + {3, 2, 15, 15, Unknown_3DB606, Unknown_3DB606, 3}, + {4, 2, 15, 15, Unknown_3DB606, Unknown_3DB606, 4}, +}; + +void MovePlayerOnBike(u8 direction, u16 newKeys, u16 heldKeys) +{ + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE) + MovePlayerOnMachBike(direction, newKeys, heldKeys); + else + MovePlayerOnAcroBike(direction, newKeys, heldKeys); +} + +static void MovePlayerOnMachBike(u8 direction, u16 newKeys, u16 heldKeys) +{ + sMachBikeTransitions[GetMachBikeTransition(&direction)](direction); +} + +static u8 GetMachBikeTransition(u8 *ptr) +{ + u8 direction = player_get_direction_upper_nybble(); + + if (*ptr == 0) + { + *ptr = direction; + if (gPlayerAvatar.unkB == 0) + { + gPlayerAvatar.running2 = 0; + return 0; + } + gPlayerAvatar.running2 = 2; + return 3; + } + + if (*ptr != direction && gPlayerAvatar.running2 != 2) + { + if (gPlayerAvatar.unkB != 0) + { + *ptr = direction; + gPlayerAvatar.running2 = 2; + return 3; + } + gPlayerAvatar.running2 = 1; + return 1; + } + else + { + gPlayerAvatar.running2 = 2; + return 2; + } +} + +static void MachBikeTransition_FaceDirection(u8 direction) +{ + PlayerFaceDirection(direction); + sub_80E6024(); +} + +static void MachBikeTransition_80E517C(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E)) + { + PlayerTurnInPlace(direction); + sub_80E6024(); + } + else + { + MachBikeTransition_FaceDirection(playerMapObj->mapobj_unk_18); + } +} + +static void MachBikeTransition_80E51C4(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + u8 collision; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + { + if (gPlayerAvatar.unkB) + MachBikeTransition_80E5270(playerMapObj->placeholder18); + else + MachBikeTransition_FaceDirection(playerMapObj->placeholder18); + } + else + { + collision = get_some_collision(direction); + if (collision > 0 && collision < 12) + { + if (collision == COLLISION_LEDGE_JUMP) + { + PlayerJumpLedge(direction); + } + else + { + sub_80E6024(); + if (collision < 5 || collision > 8) + PlayerOnBikeCollide(direction); + } + } + else + { + gUnknown_083DB5A4[gPlayerAvatar.bikeFrameCounter](direction); + gPlayerAvatar.unkB = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // same as dividing by 2, but compiler is insistent on >> 1 + if (gPlayerAvatar.bikeFrameCounter < 2) // do not go faster than the last element in the mach bike array + gPlayerAvatar.bikeFrameCounter++; + } + } +} + +static void MachBikeTransition_80E5270(u8 var) +{ + u8 collision; + + if (gPlayerAvatar.unkB != 0) + gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.unkB; + + collision = get_some_collision(var); + + if (collision > 0 && collision < 12) + { + if (collision == COLLISION_LEDGE_JUMP) + { + PlayerJumpLedge(var); + } + else + { + sub_80E6024(); + if (collision < 5 || collision > 8) + PlayerOnBikeCollide(var); + } + } + else + { + gUnknown_083DB5A4[gPlayerAvatar.bikeFrameCounter](var); + } +} + +static void MovePlayerOnAcroBike(u8 newDirection, u16 newKeys, u16 heldKeys) +{ + sAcroBikeTransitions[CheckMovementInputAcroBike(&newDirection, newKeys, heldKeys)](newDirection); +} + +static u8 CheckMovementInputAcroBike(u8 *newDirection, u16 newKeys, u16 heldKeys) +{ + return sAcroBikeInputHandlers[gPlayerAvatar.acroBikeState](newDirection, newKeys, heldKeys); +} + +static u8 AcroBikeHandleInputNormal(u8 *newDirection, u16 newKeys, u16 heldKeys) +{ + u8 direction = player_get_direction_upper_nybble(); + + gPlayerAvatar.bikeFrameCounter = 0; + if (*newDirection == DIR_NONE) + { + if (newKeys & B_BUTTON) + { + //We're standing still with the B button held. + //Do a wheelie. + *newDirection = direction; + gPlayerAvatar.running2 = 0; + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING; + return ACRO_TRANS_NORMAL_TO_WHEELIE; + } + else + { + *newDirection = direction; + gPlayerAvatar.running2 = 0; + return ACRO_TRANS_FACE_DIRECTION; + } + } + if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.unkB == 0) + { + gPlayerAvatar.unkB++; + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING; + return 11; + } + if (*newDirection != direction && gPlayerAvatar.running2 != 2) + { + gPlayerAvatar.acroBikeState = ACRO_STATE_TURNING; + gPlayerAvatar.unk9 = *newDirection; + gPlayerAvatar.running2 = 0; + return CheckMovementInputAcroBike(newDirection, newKeys, heldKeys); + } + gPlayerAvatar.running2 = 2; + return 2; +} + +static u8 AcroBikeHandleInputTurning(u8 *newDirection, u16 newKeys, u16 heldKeys) +{ + u8 direction; + + *newDirection = gPlayerAvatar.unk9; + gPlayerAvatar.bikeFrameCounter++; + + //Wait 6 frames before actually changing direction + if (gPlayerAvatar.bikeFrameCounter > 6) + { + gPlayerAvatar.running2 = 1; + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + sub_80E6024(); + return 1; + } + direction = player_get_direction_upper_nybble(); + if (*newDirection == sub_80E5C2C()) + { + sub_80E6024(); + gPlayerAvatar.unkB = 1; + if (*newDirection == GetOppositeDirection(direction)) + { + gPlayerAvatar.acroBikeState = ACRO_STATE_6; + return 9; + } + else + { + gPlayerAvatar.running2 = 2; + gPlayerAvatar.acroBikeState = ACRO_STATE_5; + return 8; + } + } + *newDirection = direction; + return 0; +} + +static u8 AcroBikeHandleInputWheelieStanding(u8 *ptr, u16 newKeys, u16 heldKeys) +{ + u8 direction; + struct MapObject *playerMapObj; + + direction = player_get_direction_upper_nybble(); + playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + gPlayerAvatar.running2 = 0; + + if (heldKeys & B_BUTTON) + gPlayerAvatar.bikeFrameCounter++; + else + { + //B button was released. + gPlayerAvatar.bikeFrameCounter = 0; + if (!MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E)) + { + //Go back to normal on flat ground + *ptr = direction; + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + sub_80E6024(); + return 4; + } + } + if (gPlayerAvatar.bikeFrameCounter >= 40) + { + *ptr = direction; + gPlayerAvatar.acroBikeState = ACRO_STATE_BUNNY_HOP; + sub_80E6024(); + return 6; + } + if (*ptr == direction) + { + gPlayerAvatar.running2 = 2; + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING; + sub_80E6024(); + return 10; + } + if (*ptr == 0) + { + *ptr = direction; + return 5; + } + gPlayerAvatar.running2 = 1; + return 5; +} + +static u8 AcroBikeHandleInputBunnyHop(u8 *ptr, u16 newKeys, u16 heldKeys) +{ + u8 direction; + struct MapObject *playerMapObj; + + direction = player_get_direction_upper_nybble(); + playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (!(heldKeys & B_BUTTON)) + { + //B button was released + sub_80E6024(); + if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E)) + { + //Do a standing wheelie on a bumpy slope + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING; + return CheckMovementInputAcroBike(ptr, newKeys, heldKeys); + } + else + { + //Go back to normal on flat ground + *ptr = direction; + gPlayerAvatar.running2 = 0; + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + return 4; + } + } + + //B Button is still held + + if (*ptr == DIR_NONE) + { + *ptr = direction; + gPlayerAvatar.running2 = 0; + return 6; + } + if (*ptr != direction && gPlayerAvatar.running2 != 2) + { + gPlayerAvatar.running2 = 1; + return 6; + } + gPlayerAvatar.running2 = 2; + return 7; +} + +static u8 AcroBikeHandleInputWheelieMoving(u8 *ptr, u16 newKeys, u16 heldKeys) +{ + u8 direction; + struct MapObject *playerMapObj; + + direction = player_get_direction_lower_nybble(); + playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (!(heldKeys & B_BUTTON)) + { + sub_80E6024(); + if (!MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E)) + { + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + if (*ptr == 0) + { + *ptr = direction; + gPlayerAvatar.running2 = 0; + return 4; + } + if (*ptr != direction && gPlayerAvatar.running2 != 2) + { + gPlayerAvatar.running2 = 0; + return 4; + } + gPlayerAvatar.running2 = 2; + return 12; + } + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING; + return CheckMovementInputAcroBike(ptr, newKeys, heldKeys); + } + if (*ptr == 0) + { + *ptr = direction; + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING; + gPlayerAvatar.running2 = 0; + sub_80E6024(); + return 5; + } + if (direction != *ptr && gPlayerAvatar.running2 != 2) + { + gPlayerAvatar.running2 = 0; + return 5; + } + gPlayerAvatar.running2 = 2; + return 10; +} + +static u8 AcroBikeHandleInputState5(u8 *ptr, u16 newKeys, u16 heldKeys) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + playerMapObj->mapobj_bit_9 = 0; + FieldObjectSetDirection(playerMapObj, playerMapObj->mapobj_unk_18); + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + return CheckMovementInputAcroBike(ptr, newKeys, heldKeys); +} + +static u8 AcroBikeHandleInputState6(u8 *ptr, u16 newKeys, u16 heldKeys) +{ + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + return CheckMovementInputAcroBike(ptr, newKeys, heldKeys); +} + +static void AcroBikeTransition_FaceDirection(u8 direction) +{ + PlayerFaceDirection(direction); +} + +static void AcroBikeTransition_80E5708(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + direction = playerMapObj->placeholder18; + PlayerFaceDirection(direction); +} + +static void AcroBikeTransition_80E5744(u8 direction) +{ + u8 collision; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + { + AcroBikeTransition_FaceDirection(playerMapObj->placeholder18); + return; + } + collision = get_some_collision(direction); + if (collision > 0 && collision < 12) + { + if (collision == COLLISION_LEDGE_JUMP) + PlayerJumpLedge(direction); + else if (collision < 5 || collision > 8) + PlayerOnBikeCollide(direction); + } + else + { + npc_use_some_d2s(direction); + } +} + +static void AcroBikeTransition_NormalToWheelie(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + direction = playerMapObj->placeholder18; + PlayerStartWheelie(direction); +} + +static void AcroBikeTransition_80E57F8(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + direction = playerMapObj->placeholder18; + sub_8059534(direction); +} + +static void AcroBikeTransition_80E5834(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + direction = playerMapObj->placeholder18; + sub_8059504(direction); +} + +static void AcroBikeTransition_80E5870(u8 direction) +{ + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + direction = playerMapObj->placeholder18; + sub_805954C(direction); +} + +static void AcroBikeTransition_80E58AC(u8 direction) +{ + u8 var; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + { + AcroBikeTransition_80E5870(playerMapObj->placeholder18); + return; + } + var = get_some_collision(direction); + //TODO: Try to get rid of this goto + if (var == 0 || var == 9) + { + goto derp; + } + else if (var == 6) + { + sub_8059594(direction); + } + else if (var < 5 || var > 8) + { + if (var <= 11) + { + AcroBikeTransition_80E5870(direction); + } + else + { + derp: + sub_8059570(direction); + } + } +} + +static void AcroBikeTransition_80E5920(u8 direction) +{ + u8 var; + struct MapObject *playerMapObj; + + var = get_some_collision(direction); + if (var != 0) + { + if (var == 7) + return; + if (var < 10) + { + AcroBikeTransition_80E5708(direction); + return; + } + if (sub_80E5EC0(var, direction) == 0) + { + AcroBikeTransition_80E5708(direction); + return; + } + } + playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + PlaySE(SE_JITE_PYOKO); + playerMapObj->mapobj_bit_9 = 1; + PlayerSetAnimId(sub_80608A4(direction), 2); +} + +static void AcroBikeTransition_80E5990(u8 direction) +{ + sub_80595B8(direction); +} + +static void AcroBikeTransition_80E59A0(u8 direction) +{ + u8 var; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + { + sub_8059504(playerMapObj->placeholder18); + return; + } + var = get_some_collision(direction); + if (var > 0 && var < 12) + { + if (var == 6) + { + sub_8059594(direction); + } + else if (var == 9) + { + sub_8059504(direction); + } + else if (var <= 4) + { + if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E)) + sub_8059504(direction); + else + sub_80595DC(direction); //hit wall? + } + return; + } + sub_8059618(direction); + gPlayerAvatar.running2 = 2; +} + +static void AcroBikeTransition_80E5A30(u8 direction) +{ + u8 var; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + { + PlayerStartWheelie(playerMapObj->placeholder18); + return; + } + var = get_some_collision(direction); + if (var > 0 && var < 12) + { + if (var == 6) + { + sub_8059594(direction); + } + else if (var == 9) + { + sub_8059504(direction); + } + else if (var <= 4) + { + if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E)) + sub_8059504(direction); + else + sub_80595DC(direction); //hit wall? + } + return; + } + sub_8059600(direction); + gPlayerAvatar.running2 = 2; +} + +static void AcroBikeTransition_80E5AC0(u8 direction) +{ + u8 var; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0) + { + sub_8059534(playerMapObj->placeholder18); + return; + } + var = get_some_collision(direction); + if (var > 0 && var < 12) + { + if (var == 6) + PlayerJumpLedge(direction); + else if (var < 5 || var > 8) + sub_8059534(direction); + return; + } + sub_8059630(direction); +} + +void sub_80E5B38(u16 a, u16 b) +{ + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE) + sub_80E5B60(a, b); +} + +static void sub_80E5B60(u16 unused, u16 b) +{ + u8 var; + + var = sub_80E5CF4(b); + if (var == (gPlayerAvatar.unkC & 0xF)) + { + if (gPlayerAvatar.unk14[0] < 0xFF) + gPlayerAvatar.unk14[0]++; + } + else + { + sub_80E5C7C(var); + gPlayerAvatar.unkB = 0; + } + + var = b & 0xF; + if (var == (gPlayerAvatar.unk10 & 0xF)) + { + if (gPlayerAvatar.unk1C[0] < 0xFF) + gPlayerAvatar.unk1C[0]++; + } + else + { + sub_80E5CB8(var); + gPlayerAvatar.unkB = 0; + } +} + +static bool8 sub_80E5BC8(const u8 *a, const u8 *b) +{ + u8 i; + + for (i = 0; a[i] != 0; i++) + { + if (gUnknown_0202E86C[i] > a[i]) + return FALSE; + } + for (i = 0; b[i] != 0; i++) + { + if (gUnknown_0202E874[i] > b[i]) + return FALSE; + } + return TRUE; +} + +static u8 sub_80E5C2C(void) +{ + u32 i; + + for (i = 0; i < 4; i++) + { + const struct UnknownStruct1 *s = &gUnknown_083DB608[i]; + u32 r1 = gPlayerAvatar.unkC; + u32 r2 = gPlayerAvatar.unk10; + + r1 &= s->unk8; + r2 &= s->unkC; + if (r1 == s->unk0 && r2 == s->unk4 && sub_80E5BC8(s->unk10, s->unk14)) + return s->unk18; + } + return 0; +} + +static void sub_80E5C7C(u8 a) +{ + u8 i; + + gPlayerAvatar.unkC = (gPlayerAvatar.unkC << 4) | (a & 0xF); + + for (i = 7; i != 0; i--) + gPlayerAvatar.unk14[i] = gPlayerAvatar.unk14[i - 1]; + gPlayerAvatar.unk14[0] = 1; +} + +static void sub_80E5CB8(u8 a) +{ + u8 i; + + gPlayerAvatar.unk10 = (gPlayerAvatar.unk10 << 4) | (a & 0xF); + + for (i = 7; i != 0; i--) + gPlayerAvatar.unk1C[i] = gPlayerAvatar.unk1C[i - 1]; + gPlayerAvatar.unk1C[0] = 1; +} + +static u8 sub_80E5CF4(u16 a) +{ + if (a & 0x40) + return 2; + if (a & 0x80) + return 1; + if (a & 0x20) + return 3; + if (a & 0x10) + return 4; + return 0; +} + +static u8 get_some_collision(u8 direction) +{ + s16 x; + s16 y; + u8 metatitleBehavior; + struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; + + x = playerMapObj->coords2.x; + y = playerMapObj->coords2.y; + MoveCoords(direction, &x, &y); + metatitleBehavior = MapGridGetMetatileBehaviorAt(x, y); + return sub_80E5DA0(playerMapObj, x, y, direction, metatitleBehavior); +} + +static u8 sub_80E5DA0(struct MapObject *mapObject, s16 x, s16 y, u8 direction, u8 metatitleBehavior) +{ + u8 collision = CheckForFieldObjectCollision(mapObject, x, y, direction, metatitleBehavior); + + if (collision > 4) + return collision; + + if (collision == 0 && IsRunningDisallowedByMetatile(metatitleBehavior)) + collision = 2; + + if (collision) + sub_80E5E4C(); + + return collision; +} + +bool8 IsRunningDisallowed(u8 tile) +{ + if (IsRunningDisallowedByMetatile(tile) != FALSE || gMapHeader.mapType == MAP_TYPE_INDOOR) + return TRUE; + else + return FALSE; +} + +static bool8 IsRunningDisallowedByMetatile(u8 tile) +{ + if (MetatileBehavior_IsRunningDisallowed(tile)) + return TRUE; + if (MetatileBehavior_IsFortreeBridge(tile) && (PlayerGetZCoord() & 1) == 0) + return TRUE; + return FALSE; +} + +static void sub_80E5E4C(void) +{ + if (gUnknown_02039250 != 0 && gUnknown_02039251 < 100) + gUnknown_02039251++; +} + +static bool8 CanBikeFaceDirOnMetatile(u8 direction, u8 tile) +{ + if (direction == DIR_EAST || direction == DIR_WEST) + { + //Bike cannot face east or west on a vertical rail + if (MetatileBehavior_IsIsolatedVerticalRail(tile) + || MetatileBehavior_IsVerticalRail(tile)) + return FALSE; + } + else + { + //Bike cannot face north or south on a horizontal rail + if (MetatileBehavior_IsIsolatedHorizontalRail(tile) + || MetatileBehavior_IsHorizontalRail(tile)) + return FALSE; + } + return TRUE; +} + +static bool8 sub_80E5EC0(u8 var1, u8 direction) +{ + if (direction == DIR_NORTH || direction == DIR_SOUTH) + { + if (var1 == 10 || var1 == 12) + return FALSE; + } + else if (var1 == 11 || var1 == 13) + { + return FALSE; + } + + return TRUE; +} + +bool8 IsBikingDisallowedByPlayer(void) +{ + s16 x, y; + u8 tileBehavior; + + if (!(gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_4))) + { + PlayerGetDestCoords(&x, &y); + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (!IsRunningDisallowedByMetatile(tileBehavior)) + return FALSE; + } + return TRUE; +} + +bool8 player_should_look_direction_be_enforced_upon_movement(void) +{ + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE) != FALSE && MetatileBehavior_IsBumpySlope(gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E) != FALSE) + return FALSE; + else + return TRUE; +} + +void GetOnOffBike(u8 var) +{ + gUnknown_0202E854 = 0; + + if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) + { + SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT); + sav1_reset_battle_music_maybe(); + sub_8053E90(); + } + else + { + SetPlayerAvatarTransitionFlags(var); + sav1_set_battle_music_maybe(BGM_CYCLING); + sub_8053FB0(BGM_CYCLING); + } +} + +void BikeClearState(int var1, int var2) +{ + u8 i; + + gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; + gPlayerAvatar.unk9 = 0; + gPlayerAvatar.bikeFrameCounter = 0; + gPlayerAvatar.unkB = 0; + gPlayerAvatar.unkC = var1; + gPlayerAvatar.unk10 = var2; + + for (i = 0; i < 8; i++) + gPlayerAvatar.unk14[i] = 0; + + for (i = 0; i < 8; i++) + gPlayerAvatar.unk1C[i] = 0; +} + +void sub_80E6010(u8 var) +{ + gPlayerAvatar.bikeFrameCounter = var; + gPlayerAvatar.unkB = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // lazy way of multiplying by 1.5. +} + +static void sub_80E6024(void) +{ + gPlayerAvatar.bikeFrameCounter = 0; + gPlayerAvatar.unkB = 0; +} + +s16 GetPlayerSpeed(void) +{ + // because the player pressed a direction, it won't ever return a speed of 0 since this function returns the player's current speed. + s16 machSpeeds[3]; + + memcpy(machSpeeds, gMachBikeSpeeds, sizeof(machSpeeds)); + + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE) + return machSpeeds[gPlayerAvatar.bikeFrameCounter]; + else if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE) + return SPEED_FASTER; + else if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_DASH)) + return SPEED_FAST; + else + return SPEED_NORMAL; +} + +void sub_80E6084(void) +{ + s16 x, y; + u8 tileBehavior; + + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE) + { + PlayerGetDestCoords(&x, &y); + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (MetatileBehavior_IsBumpySlope(tileBehavior)) + { + gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING; + sub_8059C94(player_get_direction_upper_nybble()); + } + } +} diff --git a/src/birch_pc.c b/src/birch_pc.c new file mode 100644 index 000000000..5fb6427c3 --- /dev/null +++ b/src/birch_pc.c @@ -0,0 +1,114 @@ +#include "global.h" +#include "event_data.h" +#include "field_message_box.h" +#include "pokedex.h" +#include "species.h" + +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u16 gSpecialVar_0x8006; + +extern const u8 gBirchDexRatingText_LessThan10[]; +extern const u8 gBirchDexRatingText_LessThan20[]; +extern const u8 gBirchDexRatingText_LessThan30[]; +extern const u8 gBirchDexRatingText_LessThan40[]; +extern const u8 gBirchDexRatingText_LessThan50[]; +extern const u8 gBirchDexRatingText_LessThan60[]; +extern const u8 gBirchDexRatingText_LessThan70[]; +extern const u8 gBirchDexRatingText_LessThan80[]; +extern const u8 gBirchDexRatingText_LessThan90[]; +extern const u8 gBirchDexRatingText_LessThan100[]; +extern const u8 gBirchDexRatingText_LessThan110[]; +extern const u8 gBirchDexRatingText_LessThan120[]; +extern const u8 gBirchDexRatingText_LessThan130[]; +extern const u8 gBirchDexRatingText_LessThan140[]; +extern const u8 gBirchDexRatingText_LessThan150[]; +extern const u8 gBirchDexRatingText_LessThan160[]; +extern const u8 gBirchDexRatingText_LessThan170[]; +extern const u8 gBirchDexRatingText_LessThan180[]; +extern const u8 gBirchDexRatingText_LessThan190[]; +extern const u8 gBirchDexRatingText_LessThan200[]; +extern const u8 gBirchDexRatingText_DexCompleted[]; + +bool16 ScriptGetPokedexInfo(void) +{ + if (gSpecialVar_0x8004 == 0) // is national dex not present? + { + gSpecialVar_0x8005 = GetHoennPokedexCount(0); + gSpecialVar_0x8006 = GetHoennPokedexCount(1); + } + else + { + gSpecialVar_0x8005 = GetNationalPokedexCount(0); + gSpecialVar_0x8006 = GetNationalPokedexCount(1); + } + + return IsNationalPokedexEnabled(); +} + +// This shows your Hoenn Pokedex rating and not your National Dex. +const u8 *GetPokedexRatingText(u16 count) +{ + if (count < 10) + return gBirchDexRatingText_LessThan10; + if (count < 20) + return gBirchDexRatingText_LessThan20; + if (count < 30) + return gBirchDexRatingText_LessThan30; + if (count < 40) + return gBirchDexRatingText_LessThan40; + if (count < 50) + return gBirchDexRatingText_LessThan50; + if (count < 60) + return gBirchDexRatingText_LessThan60; + if (count < 70) + return gBirchDexRatingText_LessThan70; + if (count < 80) + return gBirchDexRatingText_LessThan80; + if (count < 90) + return gBirchDexRatingText_LessThan90; + if (count < 100) + return gBirchDexRatingText_LessThan100; + if (count < 110) + return gBirchDexRatingText_LessThan110; + if (count < 120) + return gBirchDexRatingText_LessThan120; + if (count < 130) + return gBirchDexRatingText_LessThan130; + if (count < 140) + return gBirchDexRatingText_LessThan140; + if (count < 150) + return gBirchDexRatingText_LessThan150; + if (count < 160) + return gBirchDexRatingText_LessThan160; + if (count < 170) + return gBirchDexRatingText_LessThan170; + if (count < 180) + return gBirchDexRatingText_LessThan180; + if (count < 190) + return gBirchDexRatingText_LessThan190; + if (count < 200) + return gBirchDexRatingText_LessThan200; + if (count == 200) + { + if (GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) + || GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // Jirachi or Deoxys is not counted towards the dex completion. If either of these flags are enabled, it means the actual count is less than 200. + return gBirchDexRatingText_LessThan200; + return gBirchDexRatingText_DexCompleted; + } + if (count == 201) + { + if (GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) + && GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // If both of these flags are enabled, it means the actual count is less than 200. + return gBirchDexRatingText_LessThan200; + return gBirchDexRatingText_DexCompleted; + } + if (count == 202) + return gBirchDexRatingText_DexCompleted; // Hoenn dex is considered complete, even though the hoenn dex count is 210. + return gBirchDexRatingText_LessThan10; +} + +void ShowPokedexRatingMessage(void) +{ + ShowFieldMessage(GetPokedexRatingText(gSpecialVar_0x8004)); +} diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c new file mode 100644 index 000000000..4de945b9c --- /dev/null +++ b/src/braille_puzzles.c @@ -0,0 +1,260 @@ +#include "global.h" +#include "braille_puzzles.h" +#include "event_data.h" +#include "field_camera.h" +#include "field_effect.h" +#include "fieldmap.h" +#include "flags.h" +#include "main.h" +#include "map_obj_lock.h" +#include "menu.h" +#include "rom6.h" +#include "script.h" +#include "songs.h" +#include "sound.h" +#include "species.h" +#include "task.h" +#include "text.h" + +extern u8 gPlayerPartyCount; +extern u8 gLastFieldPokeMenuOpened; + +extern u32 gUnknown_0202FF84[]; + +extern u8 gIslandCave_EventScript_OpenRegiiceChamber[]; // regiice event script + +bool8 ShouldDoBrailleDigEffect(void) +{ + if (!FlagGet(SYS_BRAILLE_DIG) && (gSaveBlock1.location.mapGroup == 0x18 && gSaveBlock1.location.mapNum == 0x47)) + { + if (gSaveBlock1.pos.x == 10 && gSaveBlock1.pos.y == 3) + return TRUE; + else if (gSaveBlock1.pos.x == 9 && gSaveBlock1.pos.y == 3) + return TRUE; + else if (gSaveBlock1.pos.x == 11 && gSaveBlock1.pos.y == 3) + return TRUE; + } + + return FALSE; +} + +void DoBrailleDigEffect(void) +{ + MapGridSetMetatileIdAt(16, 8, 554); + MapGridSetMetatileIdAt(17, 8, 555); + MapGridSetMetatileIdAt(18, 8, 556); + MapGridSetMetatileIdAt(16, 9, 3634); + MapGridSetMetatileIdAt(17, 9, 563); + MapGridSetMetatileIdAt(18, 9, 3636); + DrawWholeMapView(); + PlaySE(SE_BAN); + FlagSet(SYS_BRAILLE_DIG); + ScriptContext2_Disable(); +} + +bool8 CheckRelicanthWailord(void) +{ + if (GetMonData(&gPlayerParty, MON_DATA_SPECIES2, 0) == SPECIES_RELICANTH) + { + CalculatePlayerPartyCount(); + + if (GetMonData(&gPlayerParty[gPlayerPartyCount - 1], MON_DATA_SPECIES2, 0) == SPECIES_WAILORD) + return TRUE; + } + return FALSE; +} + +bool8 ShouldDoBrailleStrengthEffect(void) +{ + if (!FlagGet(SYS_BRAILLE_STRENGTH) && (gSaveBlock1.location.mapGroup == 0x18 && gSaveBlock1.location.mapNum == 0x6)) + { + if (gSaveBlock1.pos.x == 10 && gSaveBlock1.pos.y == 23) + return TRUE; + else if (gSaveBlock1.pos.x == 9 && gSaveBlock1.pos.y == 23) + return TRUE; + else if (gSaveBlock1.pos.x == 11 && gSaveBlock1.pos.y == 23) + return TRUE; + } + + return FALSE; +} + +void DoBrailleStrengthEffect(void) +{ + FieldEffectActiveListRemove(0x28); + MapGridSetMetatileIdAt(14, 26, 554); + MapGridSetMetatileIdAt(15, 26, 555); + MapGridSetMetatileIdAt(16, 26, 556); + MapGridSetMetatileIdAt(14, 27, 3634); + MapGridSetMetatileIdAt(15, 27, 563); + MapGridSetMetatileIdAt(16, 27, 3636); + DrawWholeMapView(); + PlaySE(SE_BAN); + FlagSet(SYS_BRAILLE_STRENGTH); + ScriptContext2_Disable(); +} + +bool8 ShouldDoBrailleFlyEffect(void) +{ + if (!FlagGet(SYS_BRAILLE_FLY) && (gSaveBlock1.location.mapGroup == 0x18 && gSaveBlock1.location.mapNum == 0x44)) + { + if (gSaveBlock1.pos.x == 8 && gSaveBlock1.pos.y == 25) + return TRUE; + } + + return FALSE; +} + +void DoBrailleFlyEffect(void) +{ + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; + FieldEffectStart(0x3C); +} + +bool8 FldEff_UseFlyAncientTomb(void) +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)UseFlyAncientTomb_Callback >> 16; + gTasks[taskId].data[9] = (u32)UseFlyAncientTomb_Callback; + return FALSE; +} + +void UseFlyAncientTomb_Callback(void) +{ + FieldEffectActiveListRemove(0x3C); + UseFlyAncientTomb_Finish(); +} + +void UseFlyAncientTomb_Finish(void) +{ + MapGridSetMetatileIdAt(14, 26, 554); + MapGridSetMetatileIdAt(15, 26, 555); + MapGridSetMetatileIdAt(16, 26, 556); + MapGridSetMetatileIdAt(14, 27, 3634); + MapGridSetMetatileIdAt(15, 27, 563); + MapGridSetMetatileIdAt(16, 27, 3636); + DrawWholeMapView(); + PlaySE(SE_BAN); + FlagSet(SYS_BRAILLE_FLY); + ScriptContext2_Disable(); +} + +void DoBrailleWait(void) +{ + if (!FlagGet(SYS_BRAILLE_WAIT)) + CreateTask(Task_BrailleWait, 0x50); +} + +void Task_BrailleWait(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + switch (data[0]) + { + case 0: + data[1] = 7200; + data[0] = 1; + break; + case 1: + if (BrailleWait_CheckButtonPress() != FALSE) + { + MenuZeroFillScreen(); + PlaySE(5); + data[0] = 2; + } + else + { + data[1] = data[1] - 1; + if (data[1] == 0) + { + MenuZeroFillScreen(); + data[0] = 3; + data[1] = 30; + } + } + break; + case 2: + if (BrailleWait_CheckButtonPress() == FALSE) + { + data[1] = data[1] - 1; + if (data[1] == 0) + data[0] = 4; + break; + } + sub_8064E2C(); + DestroyTask(taskId); + ScriptContext2_Disable(); + break; + case 3: + data[1] = data[1] - 1; + if (data[1] == 0) + data[0] = 4; + break; + case 4: + sub_8064E2C(); + ScriptContext1_SetupScript(gIslandCave_EventScript_OpenRegiiceChamber); + DestroyTask(taskId); + break; + } +} + +bool32 BrailleWait_CheckButtonPress(void) +{ + u16 var = 0xFF; + + if (gSaveBlock2.optionsButtonMode == 1) + var |= 0x300; + if (gSaveBlock2.optionsButtonMode == 2) + var |= 0x200; + + if ((var & gMain.newKeys) != FALSE) + return TRUE; + else + return FALSE; +} + +void DoSealedChamberShakingEffect1(void) +{ + u8 taskId = CreateTask(SealedChamberShakingEffect, 0x9); + + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[4] = 2; + gTasks[taskId].data[5] = 5; + gTasks[taskId].data[6] = 50; + SetCameraPanningCallback(0); +} + +void DoSealedChamberShakingEffect2(void) +{ + u8 taskId = CreateTask(SealedChamberShakingEffect, 0x9); + + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[4] = 3; + gTasks[taskId].data[5] = 5; + gTasks[taskId].data[6] = 2; + SetCameraPanningCallback(0); +} + +void SealedChamberShakingEffect(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + task->data[1]++; + + if (!(task->data[1] % task->data[5])) + { + task->data[1] = 0; + task->data[2]++; + task->data[4] = -task->data[4]; + SetCameraPanning(0, task->data[4]); + if (task->data[2] == task->data[6]) + { + DestroyTask(taskId); + EnableBothScriptContexts(); + InstallCameraPanAheadCallback(); + } + } +} diff --git a/src/cable_club.c b/src/cable_club.c new file mode 100644 index 000000000..70b372205 --- /dev/null +++ b/src/cable_club.c @@ -0,0 +1,318 @@ +#include "global.h" +#include "cable_club.h" +#include "field_message_box.h" +#include "link.h" +#include "main.h" +#include "script.h" +#include "songs.h" +#include "sound.h" +#include "string_util.h" +#include "task.h" +#include "text.h" +#include "trainer_card.h" + +extern u16 gScriptResult; +extern struct TrainerCard gTrainerCards[4]; +extern struct LinkPlayer gLinkPlayers[]; + +extern u8 gUnknown_03004860; +extern u8 gFieldLinkPlayerCount; + +extern u8 gUnknown_081A4932[]; +extern const u8 gUnknown_081A4975[]; + +static void sub_80830E4(u8 taskId); +static void sub_8083288(u8 taskId); +static void sub_8083314(u8 taskId); + +void sub_808303C(u8 taskId) { + s32 linkPlayerCount; + s16 *taskData; + + taskData = gTasks[taskId].data; + + linkPlayerCount = GetLinkPlayerCount_2(); + + if (sub_8082E28(taskId) == 1 || + sub_8082EB8(taskId) == 1 || + sub_8082DF4(taskId) == 1) + { + return; + } + + sub_8082D60(taskId, linkPlayerCount); + + if (!(gMain.newKeys & A_BUTTON)) + { + return; + } + +#if ENGLISH + if (linkPlayerCount < taskData[1]) + { + return; + } + + sub_80081C8(linkPlayerCount); + sub_8082D4C(); + ConvertIntToDecimalStringN(gStringVar1, linkPlayerCount, STR_CONV_MODE_LEFT_ALIGN, 1); // r5 + ShowFieldAutoScrollMessage((u8 *) gUnknown_081A4975); + gTasks[taskId].func = sub_80830E4; +#elif GERMAN + if ((gLinkType == 0x2255 && (u32) linkPlayerCount > 1) || + (gLinkType != 0x2255 && taskData[1] <= linkPlayerCount)) + { + sub_80081C8(linkPlayerCount); + sub_8082D4C(); + ConvertIntToDecimalStringN(gStringVar1, linkPlayerCount, STR_CONV_MODE_LEFT_ALIGN, 1); // r5 + ShowFieldAutoScrollMessage((u8 *) gUnknown_081A4975); + gTasks[taskId].func = sub_80830E4; + } +#endif +} + +#ifdef NONMATCHING +static void sub_80830E4(u8 taskId) { + if (sub_8082E28(taskId) == 1 || + sub_8082EB8(taskId) == 1 || + sub_8082DF4(taskId) == 1 || + GetFieldMessageBoxMode()) + { + return; + } + + if (sub_800820C() == GetLinkPlayerCount_2() && + !(gMain.heldKeys & B_BUTTON)) + { + ShowFieldAutoScrollMessage(gUnknown_081A4932); + gTasks[taskId].func = sub_8082FEC; + return; + } + + if (gMain.heldKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + sub_8007F4C(); + gTasks[(u32) taskId].func = sub_8083188; + } +} +#else +__attribute__((naked)) +static void sub_80830E4(u8 taskId) { + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + adds r6, r5, 0\n\ + adds r0, r5, 0\n\ + bl sub_8082E28\n\ + cmp r0, 0x1\n\ + beq _08083178\n\ + adds r0, r5, 0\n\ + bl sub_8082EB8\n\ + cmp r0, 0x1\n\ + beq _08083178\n\ + adds r0, r5, 0\n\ + bl sub_8082DF4\n\ + cmp r0, 0x1\n\ + beq _08083178\n\ + bl GetFieldMessageBoxMode\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _08083178\n\ + bl sub_800820C\n\ + adds r4, r0, 0\n\ + bl GetLinkPlayerCount_2\n\ + lsls r4, 24\n\ + lsls r0, 24\n\ + cmp r4, r0\n\ + bne _08083132\n\ + ldr r0, _08083148 @ =gMain\n\ + ldrh r1, [r0, 0x2C]\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08083158\n\ +_08083132:\n\ + ldr r0, _0808314C @ =gUnknown_081A4932\n\ + bl ShowFieldAutoScrollMessage\n\ + ldr r1, _08083150 @ =gTasks\n\ + lsls r0, r5, 2\n\ + adds r0, r5\n\ + lsls r0, 3\n\ + adds r0, r1\n\ + ldr r1, _08083154 @ =sub_8082FEC\n\ + str r1, [r0]\n\ + b _08083178\n\ + .align 2, 0\n\ +_08083148: .4byte gMain\n\ +_0808314C: .4byte gUnknown_081A4932\n\ +_08083150: .4byte gTasks\n\ +_08083154: .4byte sub_8082FEC\n\ +_08083158:\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08083178\n\ + movs r0, 0x5\n\ + bl PlaySE\n\ + bl sub_8007F4C\n\ + ldr r0, _08083180 @ =gTasks\n\ + lsls r1, r6, 2\n\ + adds r1, r6\n\ + lsls r1, 3\n\ + adds r1, r0\n\ + ldr r0, _08083184 @ =sub_8083188\n\ + str r0, [r1]\n\ +_08083178:\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_08083180: .4byte gTasks\n\ +_08083184: .4byte sub_8083188\n\ + .syntax divided\n"); +} +#endif + +void sub_8083188(u8 taskId) { + u8 local1, local2; + u16 *result; + + local1 = gTasks[taskId].data[1]; + local2 = gTasks[taskId].data[2]; + + + if (sub_8082DF4(taskId) == 1 || + sub_8083444(taskId) == 1) + { + return; + } + + if (GetLinkPlayerCount_2() != sub_800820C()) + { + gTasks[taskId].func = sub_8083418; + return; + } + + result = &gScriptResult; + *result = sub_8082D9C(local1, local2); + if (*result) + { + gTasks[taskId].func = sub_8083288; + } +} + +void sub_80831F8(u8 taskId) { + u8 local1, local2; + u16 *result; + + local1 = gTasks[taskId].data[1]; + local2 = gTasks[taskId].data[2]; + + if (sub_8082E28(taskId) == 1 || + sub_8082DF4(taskId) == 1) + { + return; + } + + result = &gScriptResult; + *result = sub_8082D9C(local1, local2); + if (*result == 0) + { + return; + } + + + if (*result == 3) + { + sub_800832C(); + HideFieldMessageBox(); + gTasks[taskId].func = sub_80833C4; + } + else + { + gFieldLinkPlayerCount = GetLinkPlayerCount_2(); + gUnknown_03004860 = GetMultiplayerId(); + sub_80081C8(gFieldLinkPlayerCount); + sub_8093390((struct TrainerCard *) gBlockSendBuffer); + gTasks[taskId].func = sub_8083314; + } +} + +static void sub_8083288(u8 taskId) { + if (sub_8082DF4(taskId) == 1) + { + return; + } + + if (gScriptResult == 3) + { + sub_800832C(); + HideFieldMessageBox(); + gTasks[taskId].func = sub_80833C4; + } + else + { + gFieldLinkPlayerCount = GetLinkPlayerCount_2(); + gUnknown_03004860 = GetMultiplayerId(); + sub_80081C8(gFieldLinkPlayerCount); + sub_8093390((struct TrainerCard *) gBlockSendBuffer); + gTasks[taskId].func = sub_8083314; + sub_8007E9C(2); + } +} + +static void sub_8083314(u8 taskId) { + u8 index; + + struct TrainerCard *trainerCards; + + if (sub_8082DF4(taskId) == 1) + { + return; + } + + if (GetBlockReceivedStatus() != sub_8008198()) + { + return; + } + + index = 0; + trainerCards = gTrainerCards; + for (index = 0; index < GetLinkPlayerCount(); index++) + { + void *src; + src = gBlockRecvBuffer[index]; + memcpy(&trainerCards[index], src, sizeof(struct TrainerCard)); + } + + SetSuppressLinkErrorMessage(FALSE); + ResetBlockReceivedFlags(); + HideFieldMessageBox(); + + if (gScriptResult == 1) + { +#if ENGLISH + u16 linkType; + linkType = gLinkType; + // FIXME: sub_8082D4C doesn't take any arguments + sub_8082D4C(0x00004411, linkType); +#elif GERMAN + if (gLinkType != 0x4411) + { + if (gLinkType == 0x6601) + { + deUnkValue2 = 1; + } + } + sub_8082D4C(); +#endif + EnableBothScriptContexts(); + DestroyTask(taskId); + return; + } + + sub_800832C(); + gTasks[taskId].func = sub_80833C4; +} diff --git a/src/calculate_base_damage.c b/src/calculate_base_damage.c new file mode 100644 index 000000000..ae60e30fe --- /dev/null +++ b/src/calculate_base_damage.c @@ -0,0 +1,1470 @@ +#include "global.h" +#include "abilities.h" +#include "battle.h" +#include "berry.h" +#include "data2.h" +#include "event_data.h" +#include "hold_effects.h" +#include "item.h" +#include "items.h" +#include "main.h" +#include "pokemon.h" +#include "species.h" +#include "sprite.h" +#include "string_util.h" +#include "strings2.h" +#include "text.h" + +extern u8 gPlayerPartyCount; +extern u8 gEnemyPartyCount; + +extern u16 unk_20160BC[]; +extern struct SecretBaseRecord gSecretBaseRecord; +extern u32 dword_2017100[]; +extern u16 gBattleTypeFlags; +extern struct BattlePokemon gBattleMons[4]; +extern u16 gCurrentMove; +extern u8 gLastUsedAbility; +extern u8 gCritMultiplier; +extern u16 gBattleWeather; +extern struct BattleEnigmaBerry gEnigmaBerries[]; +extern u16 gBattleMovePower; +extern struct SpriteTemplate gUnknown_02024E8C; +extern u16 gTrainerBattleOpponent; +extern struct PokemonStorage gPokemonStorage; + +extern u8 gBadEggNickname[]; +extern struct SpriteTemplate gSpriteTemplate_8208288[]; +extern u8 gSecretBaseTrainerClasses[]; +extern u8 gHoldEffectToType[][2]; + +#define APPLY_STAT_MOD(var, mon, stat, statIndex) \ +{ \ + (var) = (stat) * (gStatStageRatios)[(mon)->statStages[(statIndex)] * 2]; \ + (var) /= (gStatStageRatios + 1)[(mon)->statStages[(statIndex)] * 2]; \ +} + +#ifdef NONMATCHING +s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 a4, u16 powerOverride, u8 typeOverride, u8 a7, u8 a8) +{ + s32 i; + s32 damage = 0; + u8 type; + u16 attack, defense; + u16 spAttack, spDefense; + u8 defenderHoldEffect; + u8 defenderHoldEffectParam; + u8 attackerHoldEffect; + u8 attackerHoldEffectParam; + s32 a, b; + + if (!powerOverride) + gBattleMovePower = gBattleMoves[move].power; + else + gBattleMovePower = powerOverride; + + if (!typeOverride) + type = gBattleMoves[move].type; + else + type = typeOverride & 0x3F; + + attack = attacker->attack; + defense = defender->defense; + spAttack = attacker->spAttack; + spDefense = defender->spDefense; + + if (attacker->item == ITEM_ENIGMA_BERRY) + { + attackerHoldEffect = gEnigmaBerries[a7].holdEffect; + attackerHoldEffectParam = gEnigmaBerries[a7].holdEffectParam; + } + else + { + attackerHoldEffect = ItemId_GetHoldEffect(attacker->item); + attackerHoldEffectParam = ItemId_GetHoldEffectParam(attacker->item); + } + + if (defender->item == ITEM_ENIGMA_BERRY) + { + defenderHoldEffect = gEnigmaBerries[a8].holdEffect; + defenderHoldEffectParam = gEnigmaBerries[a8].holdEffectParam; + } + else + { + defenderHoldEffect = ItemId_GetHoldEffect(defender->item); + defenderHoldEffectParam = ItemId_GetHoldEffectParam(defender->item); + } + + if (attacker->ability == ABILITY_HUGE_POWER || attacker->ability == ABILITY_PURE_POWER) + attack *= 2; + + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_EREADER_TRAINER))) + { + if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER) + && gTrainerBattleOpponent != 1024 + && FlagGet(BADGE01_GET) + && !GetBankSide(a7)) + attack = (110 * attack) / 100; + + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_EREADER_TRAINER))) + { + if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER) + && gTrainerBattleOpponent != 1024 + && FlagGet(BADGE05_GET) + && !GetBankSide(a8)) + defense = (110 * defense) / 100; + + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_EREADER_TRAINER))) + { + if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER) + && gTrainerBattleOpponent != 1024 + && FlagGet(BADGE07_GET) + && !GetBankSide(a7)) + spAttack = (110 * spAttack) / 100; + + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_EREADER_TRAINER))) + { + if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER) + && gTrainerBattleOpponent != 1024 + && FlagGet(BADGE07_GET) + && !GetBankSide(a8)) + spDefense = (110 * spDefense) / 100; + } + } + } + } + + for (i = 0; i < 17; i++) + { + if (attackerHoldEffect == gHoldEffectToType[i][0] + && type == gHoldEffectToType[i][1]) + { + if (type <= 8) + attack = (attack * (attackerHoldEffectParam + 100)) / 100; + else + spAttack = (spAttack * (attackerHoldEffectParam + 100)) / 100; + break; + } + } + + if (attackerHoldEffect == HOLD_EFFECT_CHOICE_BAND) + attack = (150 * attack) / 100; + if (attackerHoldEffect == HOLD_EFFECT_SOUL_DEW && !(gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) && (attacker->species == SPECIES_LATIAS || attacker->species == SPECIES_LATIOS)) + spAttack = (150 * spAttack) / 100; + if (defenderHoldEffect == HOLD_EFFECT_SOUL_DEW && !(gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) && (defender->species == SPECIES_LATIAS || defender->species == SPECIES_LATIOS)) + spDefense = (150 * spDefense) / 100; + if (attackerHoldEffect == HOLD_EFFECT_DEEP_SEA_TOOTH && attacker->species == SPECIES_CLAMPERL) + spAttack *= 2; + if (defenderHoldEffect == HOLD_EFFECT_DEEP_SEA_SCALE && defender->species == SPECIES_CLAMPERL) + spDefense *= 2; + if (attackerHoldEffect == HOLD_EFFECT_LIGHT_BALL && attacker->species == SPECIES_PIKACHU) + spAttack *= 2; + if (defenderHoldEffect == HOLD_EFFECT_METAL_POWDER && defender->species == SPECIES_DITTO) + defense *= 2; + if (attackerHoldEffect == HOLD_EFFECT_THICK_CLUB && (attacker->species == SPECIES_CUBONE || attacker->species == SPECIES_MAROWAK)) + attack *= 2; + if (defender->ability == ABILITY_THICK_FAT && (type == TYPE_FIRE || type == TYPE_ICE)) + spAttack /= 2; + if (attacker->ability == ABILITY_HUSTLE) + attack = (150 * attack) / 100; + if (attacker->ability == ABILITY_PLUS && AbilityBattleEffects(0xE, 0, ABILITY_MINUS, 0, 0)) + spAttack = (150 * spAttack) / 100; + if (attacker->ability == ABILITY_MINUS && AbilityBattleEffects(0xE, 0, ABILITY_PLUS, 0, 0)) + spAttack = (150 * spAttack) / 100; + if (attacker->ability == ABILITY_GUTS && attacker->status1) + attack = (150 * attack) / 100; + if (defender->ability == ABILITY_MARVEL_SCALE && defender->status1) + defense = (150 * defense) / 100; + if (type == TYPE_ELECTRIC && AbilityBattleEffects(0xE, 0, 0, 0xFD, 0)) + gBattleMovePower /= 2; + if (type == TYPE_FIRE && AbilityBattleEffects(0xE, 0, 0, 0xFE, 0)) + gBattleMovePower /= 2; + if (type == TYPE_GRASS && attacker->ability == ABILITY_OVERGROW && attacker->hp <= (attacker->maxHP / 3)) + gBattleMovePower = (150 * gBattleMovePower) / 100; + if (type == TYPE_FIRE && attacker->ability == ABILITY_BLAZE && attacker->hp <= (attacker->maxHP / 3)) + gBattleMovePower = (150 * gBattleMovePower) / 100; + if (type == TYPE_WATER && attacker->ability == ABILITY_TORRENT && attacker->hp <= (attacker->maxHP / 3)) + gBattleMovePower = (150 * gBattleMovePower) / 100; + if (type == TYPE_BUG && attacker->ability == ABILITY_SWARM && attacker->hp <= (attacker->maxHP / 3)) + gBattleMovePower = (150 * gBattleMovePower) / 100; + if (gBattleMoves[gCurrentMove].effect == 7) + defense /= 2; + + if (type < TYPE_MYSTERY) // is physical? + { + if (gCritMultiplier == 2) + { + if (attacker->statStages[1] > 6) + APPLY_STAT_MOD(a, attacker, attack, 1) + else + a = attack; + } + else + APPLY_STAT_MOD(a, attacker, attack, 1) + + a = a * gBattleMovePower * (2 * attacker->level / 5 + 2); + + if (gCritMultiplier == 2) + { + if (defender->statStages[2] < 6) + APPLY_STAT_MOD(b, defender, defense, 2) + else + b = defense; + } + else + APPLY_STAT_MOD(b, defender, defense, 2) + + damage = (a / b) / 50; + + if ((attacker->status1 & 0x10) && attacker->ability != ABILITY_GUTS) + damage /= 2; + + if ((a4 & 1) && gCritMultiplier == 1) + { + if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMons(2) == 2) + damage = 2 * (damage / 3); + else + damage /= 2; + } + + if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMons(2) == 2) + damage /= 2; + + // moves always do at least 1 damage. + if (damage == 0) + damage = 1; + } + + if (type == TYPE_MYSTERY) + damage = 0; // is ??? type. does 0 damage. + + if (type > TYPE_MYSTERY) // is special? + { + if (gCritMultiplier == 2) + { + if (attacker->statStages[4] > 6) + APPLY_STAT_MOD(a, attacker, spAttack, 4) + else + a = spAttack; + } + else + APPLY_STAT_MOD(a, attacker, spAttack, 4) + + a = a * gBattleMovePower * (2 * attacker->level / 5 + 2); + + if (gCritMultiplier == 2) + { + if (defender->statStages[5] < 6) + APPLY_STAT_MOD(b, defender, spDefense, 5) + else + b = spDefense; + } + else + APPLY_STAT_MOD(b, defender, spDefense, 5) + + damage = (a / b) / 50; + + if ((a4 & 2) && gCritMultiplier == 1) + { + if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMons(2) == 2) + damage = 2 * (damage / 3); + else + damage /= 2; + } + + if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMons(2) == 2) + damage /= 2; + + // are effects of weather negated with cloud nine or air lock? + if (!AbilityBattleEffects(0xE, 0, ABILITY_CLOUD_NINE, 0, 0) && !AbilityBattleEffects(0xE, 0, ABILITY_AIR_LOCK, 0, 0)) + { + // rain? + if (gBattleWeather & 1) + { + if (type == TYPE_FIRE) + damage /= 2; + else if (type == TYPE_WATER) + damage = (15 * damage) / 10; + } + + // does lack of sun half solar beam damage? + if ((gBattleWeather & 0x9F) && gCurrentMove == 76) + damage /= 2; + + // sunny? + if (gBattleWeather & 0x60) + { + if (type == TYPE_FIRE) + damage = (15 * damage) / 10; + else if (type == TYPE_WATER) + damage /= 2; + } + } + + // flash fire triggered? + if ((dword_2017100[a7] & 1) && type == TYPE_FIRE) + damage = (15 * damage) / 10; + } + + return damage + 2; +} +#else +__attribute__((naked)) +s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 a4, u16 powerOverride, u8 typeOverride, u8 a7, u8 a8) +{ + 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, 0x2C\n\ + adds r7, r0, 0\n\ + str r1, [sp, 0x4]\n\ + str r2, [sp, 0x8]\n\ + ldr r0, [sp, 0x4C]\n\ + ldr r1, [sp, 0x50]\n\ + ldr r2, [sp, 0x54]\n\ + ldr r4, [sp, 0x58]\n\ + lsls r3, 16\n\ + lsrs r3, 16\n\ + str r3, [sp, 0xC]\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + lsls r1, 24\n\ + lsrs r6, r1, 24\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + str r2, [sp, 0x10]\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + movs r5, 0\n\ + cmp r3, 0\n\ + bne _0803BA80\n\ + ldr r2, _0803BA78 @ =gBattleMovePower\n\ + ldr r1, _0803BA7C @ =gBattleMoves\n\ + ldr r3, [sp, 0x8]\n\ + lsls r0, r3, 1\n\ + adds r0, r3\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r0, [r0, 0x1]\n\ + strh r0, [r2]\n\ + b _0803BA84\n\ + .align 2, 0\n\ +_0803BA78: .4byte gBattleMovePower\n\ +_0803BA7C: .4byte gBattleMoves\n\ +_0803BA80:\n\ + ldr r0, _0803BA9C @ =gBattleMovePower\n\ + strh r3, [r0]\n\ +_0803BA84:\n\ + cmp r6, 0\n\ + bne _0803BAA4\n\ + ldr r1, _0803BAA0 @ =gBattleMoves\n\ + ldr r6, [sp, 0x8]\n\ + lsls r0, r6, 1\n\ + adds r0, r6\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r0, [r0, 0x2]\n\ + mov r9, r0\n\ + b _0803BAAE\n\ + .align 2, 0\n\ +_0803BA9C: .4byte gBattleMovePower\n\ +_0803BAA0: .4byte gBattleMoves\n\ +_0803BAA4:\n\ + movs r0, 0x3F\n\ + mov r9, r0\n\ + mov r1, r9\n\ + ands r1, r6\n\ + mov r9, r1\n\ +_0803BAAE:\n\ + ldrh r6, [r7, 0x2]\n\ + ldr r2, [sp, 0x4]\n\ + ldrh r2, [r2, 0x4]\n\ + str r2, [sp, 0x14]\n\ + ldrh r3, [r7, 0x8]\n\ + mov r8, r3\n\ + ldr r0, [sp, 0x4]\n\ + ldrh r0, [r0, 0xA]\n\ + str r0, [sp, 0x18]\n\ + ldrh r0, [r7, 0x2E]\n\ + cmp r0, 0xAF\n\ + bne _0803BAE0\n\ + ldr r1, _0803BADC @ =gEnigmaBerries\n\ + ldr r2, [sp, 0x10]\n\ + lsls r0, r2, 3\n\ + subs r0, r2\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r3, [r0, 0x7]\n\ + mov r10, r3\n\ + ldrb r0, [r0, 0x1A]\n\ + b _0803BAF6\n\ + .align 2, 0\n\ +_0803BADC: .4byte gEnigmaBerries\n\ +_0803BAE0:\n\ + ldrh r0, [r7, 0x2E]\n\ + bl ItemId_GetHoldEffect\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r10, r0\n\ + ldrh r0, [r7, 0x2E]\n\ + bl ItemId_GetHoldEffectParam\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ +_0803BAF6:\n\ + str r0, [sp, 0x20]\n\ + ldr r1, [sp, 0x4]\n\ + ldrh r0, [r1, 0x2E]\n\ + cmp r0, 0xAF\n\ + bne _0803BB26\n\ + ldr r1, _0803BB10 @ =gEnigmaBerries\n\ + lsls r0, r4, 3\n\ + subs r0, r4\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r0, [r0, 0x7]\n\ + str r0, [sp, 0x1C]\n\ + b _0803BB3C\n\ + .align 2, 0\n\ +_0803BB10: .4byte gEnigmaBerries\n\ +_0803BB14:\n\ + ldr r0, [sp, 0x20]\n\ + adds r0, 0x64\n\ + muls r0, r6\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ + b _0803BCDC\n\ +_0803BB26:\n\ + ldr r2, [sp, 0x4]\n\ + ldrh r0, [r2, 0x2E]\n\ + bl ItemId_GetHoldEffect\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x1C]\n\ + ldr r3, [sp, 0x4]\n\ + ldrh r0, [r3, 0x2E]\n\ + bl ItemId_GetHoldEffectParam\n\ +_0803BB3C:\n\ + adds r0, r7, 0\n\ + adds r0, 0x20\n\ + ldrb r1, [r0]\n\ + str r0, [sp, 0x24]\n\ + cmp r1, 0x25\n\ + beq _0803BB4C\n\ + cmp r1, 0x4A\n\ + bne _0803BB50\n\ +_0803BB4C:\n\ + lsls r0, r6, 17\n\ + lsrs r6, r0, 16\n\ +_0803BB50:\n\ + ldr r0, _0803BCB8 @ =gBattleTypeFlags\n\ + ldrh r1, [r0]\n\ + ldr r0, _0803BCBC @ =0x00000902\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803BB5E\n\ + b _0803BC78\n\ +_0803BB5E:\n\ + movs r0, 0x8\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803BB98\n\ + ldr r0, _0803BCC0 @ =gTrainerBattleOpponent\n\ + ldrh r1, [r0]\n\ + movs r0, 0x80\n\ + lsls r0, 3\n\ + cmp r1, r0\n\ + beq _0803BB98\n\ + ldr r0, _0803BCC4 @ =0x00000807\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0803BB98\n\ + ldr r0, [sp, 0x10]\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _0803BB98\n\ + movs r0, 0x6E\n\ + muls r0, r6\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ +_0803BB98:\n\ + ldr r0, _0803BCB8 @ =gBattleTypeFlags\n\ + ldrh r1, [r0]\n\ + ldr r0, _0803BCBC @ =0x00000902\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0803BC78\n\ + movs r0, 0x8\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803BBE2\n\ + ldr r0, _0803BCC0 @ =gTrainerBattleOpponent\n\ + ldrh r1, [r0]\n\ + movs r0, 0x80\n\ + lsls r0, 3\n\ + cmp r1, r0\n\ + beq _0803BBE2\n\ + ldr r0, _0803BCC8 @ =0x0000080b\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0803BBE2\n\ + adds r0, r4, 0\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _0803BBE2\n\ + movs r0, 0x6E\n\ + ldr r1, [sp, 0x14]\n\ + muls r0, r1\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x14]\n\ +_0803BBE2:\n\ + ldr r0, _0803BCB8 @ =gBattleTypeFlags\n\ + ldrh r1, [r0]\n\ + ldr r0, _0803BCBC @ =0x00000902\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0803BC78\n\ + movs r0, 0x8\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803BC2E\n\ + ldr r0, _0803BCC0 @ =gTrainerBattleOpponent\n\ + ldrh r1, [r0]\n\ + movs r0, 0x80\n\ + lsls r0, 3\n\ + cmp r1, r0\n\ + beq _0803BC2E\n\ + ldr r0, _0803BCCC @ =0x0000080d\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0803BC2E\n\ + ldr r0, [sp, 0x10]\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _0803BC2E\n\ + movs r0, 0x6E\n\ + mov r2, r8\n\ + muls r2, r0\n\ + adds r0, r2, 0\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r8, r0\n\ +_0803BC2E:\n\ + ldr r0, _0803BCB8 @ =gBattleTypeFlags\n\ + ldrh r1, [r0]\n\ + ldr r0, _0803BCBC @ =0x00000902\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0803BC78\n\ + movs r0, 0x8\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803BC78\n\ + ldr r0, _0803BCC0 @ =gTrainerBattleOpponent\n\ + ldrh r1, [r0]\n\ + movs r0, 0x80\n\ + lsls r0, 3\n\ + cmp r1, r0\n\ + beq _0803BC78\n\ + ldr r0, _0803BCCC @ =0x0000080d\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0803BC78\n\ + adds r0, r4, 0\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _0803BC78\n\ + movs r0, 0x6E\n\ + ldr r3, [sp, 0x18]\n\ + muls r0, r3\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x18]\n\ +_0803BC78:\n\ + movs r2, 0\n\ + ldr r4, _0803BCD0 @ =gHoldEffectToType\n\ + ldr r0, [sp, 0x4]\n\ + adds r0, 0x20\n\ + str r0, [sp, 0x28]\n\ + adds r3, r4, 0\n\ +_0803BC84:\n\ + lsls r1, r2, 1\n\ + ldrb r0, [r3]\n\ + cmp r10, r0\n\ + bne _0803BCD4\n\ + adds r0, r4, 0x1\n\ + adds r0, r1, r0\n\ + ldrb r0, [r0]\n\ + cmp r9, r0\n\ + bne _0803BCD4\n\ + mov r1, r9\n\ + cmp r1, 0x8\n\ + bhi _0803BC9E\n\ + b _0803BB14\n\ +_0803BC9E:\n\ + ldr r0, [sp, 0x20]\n\ + adds r0, 0x64\n\ + mov r2, r8\n\ + muls r2, r0\n\ + adds r0, r2, 0\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r8, r0\n\ + b _0803BCDC\n\ + .align 2, 0\n\ +_0803BCB8: .4byte gBattleTypeFlags\n\ +_0803BCBC: .4byte 0x00000902\n\ +_0803BCC0: .4byte gTrainerBattleOpponent\n\ +_0803BCC4: .4byte 0x00000807\n\ +_0803BCC8: .4byte 0x0000080b\n\ +_0803BCCC: .4byte 0x0000080d\n\ +_0803BCD0: .4byte gHoldEffectToType\n\ +_0803BCD4:\n\ + adds r3, 0x2\n\ + adds r2, 0x1\n\ + cmp r2, 0x10\n\ + bls _0803BC84\n\ +_0803BCDC:\n\ + mov r3, r10\n\ + cmp r3, 0x1D\n\ + bne _0803BCF0\n\ + movs r0, 0x96\n\ + muls r0, r6\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ +_0803BCF0:\n\ + mov r0, r10\n\ + cmp r0, 0x22\n\ + bne _0803BD28\n\ + ldr r0, _0803BFDC @ =gBattleTypeFlags\n\ + ldrh r1, [r0]\n\ + movs r0, 0x80\n\ + lsls r0, 1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0803BD28\n\ + ldr r1, _0803BFE0 @ =0xfffffe69\n\ + adds r0, r1, 0\n\ + ldrh r2, [r7]\n\ + adds r0, r2\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r0, 0x1\n\ + bhi _0803BD28\n\ + movs r0, 0x96\n\ + mov r3, r8\n\ + muls r3, r0\n\ + adds r0, r3, 0\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r8, r0\n\ +_0803BD28:\n\ + ldr r0, [sp, 0x1C]\n\ + cmp r0, 0x22\n\ + bne _0803BD60\n\ + ldr r0, _0803BFDC @ =gBattleTypeFlags\n\ + ldrh r1, [r0]\n\ + movs r0, 0x80\n\ + lsls r0, 1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0803BD60\n\ + ldr r1, _0803BFE0 @ =0xfffffe69\n\ + adds r0, r1, 0\n\ + ldr r2, [sp, 0x4]\n\ + ldrh r2, [r2]\n\ + adds r0, r2\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r0, 0x1\n\ + bhi _0803BD60\n\ + movs r0, 0x96\n\ + ldr r3, [sp, 0x18]\n\ + muls r0, r3\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x18]\n\ +_0803BD60:\n\ + mov r0, r10\n\ + cmp r0, 0x23\n\ + bne _0803BD76\n\ + ldrh r1, [r7]\n\ + ldr r0, _0803BFE4 @ =0x00000175\n\ + cmp r1, r0\n\ + bne _0803BD76\n\ + mov r1, r8\n\ + lsls r0, r1, 17\n\ + lsrs r0, 16\n\ + mov r8, r0\n\ +_0803BD76:\n\ + ldr r2, [sp, 0x1C]\n\ + cmp r2, 0x24\n\ + bne _0803BD8E\n\ + ldr r3, [sp, 0x4]\n\ + ldrh r1, [r3]\n\ + ldr r0, _0803BFE4 @ =0x00000175\n\ + cmp r1, r0\n\ + bne _0803BD8E\n\ + ldr r1, [sp, 0x18]\n\ + lsls r0, r1, 17\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x18]\n\ +_0803BD8E:\n\ + mov r2, r10\n\ + cmp r2, 0x2D\n\ + bne _0803BDA2\n\ + ldrh r0, [r7]\n\ + cmp r0, 0x19\n\ + bne _0803BDA2\n\ + mov r3, r8\n\ + lsls r0, r3, 17\n\ + lsrs r0, 16\n\ + mov r8, r0\n\ +_0803BDA2:\n\ + ldr r0, [sp, 0x1C]\n\ + cmp r0, 0x40\n\ + bne _0803BDB8\n\ + ldr r1, [sp, 0x4]\n\ + ldrh r0, [r1]\n\ + cmp r0, 0x84\n\ + bne _0803BDB8\n\ + ldr r2, [sp, 0x14]\n\ + lsls r0, r2, 17\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x14]\n\ +_0803BDB8:\n\ + mov r3, r10\n\ + cmp r3, 0x41\n\ + bne _0803BDCE\n\ + ldrh r0, [r7]\n\ + subs r0, 0x68\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r0, 0x1\n\ + bhi _0803BDCE\n\ + lsls r0, r6, 17\n\ + lsrs r6, r0, 16\n\ +_0803BDCE:\n\ + ldr r1, [sp, 0x28]\n\ + ldrb r0, [r1]\n\ + cmp r0, 0x2F\n\ + bne _0803BDE6\n\ + mov r2, r9\n\ + cmp r2, 0xA\n\ + beq _0803BDE0\n\ + cmp r2, 0xF\n\ + bne _0803BDE6\n\ +_0803BDE0:\n\ + mov r3, r8\n\ + lsrs r3, 1\n\ + mov r8, r3\n\ +_0803BDE6:\n\ + ldr r0, [sp, 0x24]\n\ + ldrb r4, [r0]\n\ + cmp r4, 0x37\n\ + bne _0803BDFC\n\ + movs r0, 0x96\n\ + muls r0, r6\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ +_0803BDFC:\n\ + cmp r4, 0x39\n\ + bne _0803BE2A\n\ + movs r0, 0\n\ + str r0, [sp]\n\ + movs r0, 0xE\n\ + movs r1, 0\n\ + movs r2, 0x3A\n\ + movs r3, 0\n\ + bl AbilityBattleEffects\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0803BE2A\n\ + movs r0, 0x96\n\ + mov r1, r8\n\ + muls r1, r0\n\ + adds r0, r1, 0\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r8, r0\n\ +_0803BE2A:\n\ + ldr r2, [sp, 0x24]\n\ + ldrb r0, [r2]\n\ + cmp r0, 0x3A\n\ + bne _0803BE5C\n\ + movs r0, 0\n\ + str r0, [sp]\n\ + movs r0, 0xE\n\ + movs r1, 0\n\ + movs r2, 0x39\n\ + movs r3, 0\n\ + bl AbilityBattleEffects\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0803BE5C\n\ + movs r0, 0x96\n\ + mov r3, r8\n\ + muls r3, r0\n\ + adds r0, r3, 0\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r8, r0\n\ +_0803BE5C:\n\ + ldr r1, [sp, 0x24]\n\ + ldrb r0, [r1]\n\ + cmp r0, 0x3E\n\ + bne _0803BE78\n\ + ldr r0, [r7, 0x4C]\n\ + cmp r0, 0\n\ + beq _0803BE78\n\ + movs r0, 0x96\n\ + muls r0, r6\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ +_0803BE78:\n\ + ldr r2, [sp, 0x28]\n\ + ldrb r0, [r2]\n\ + cmp r0, 0x3F\n\ + bne _0803BE9A\n\ + ldr r3, [sp, 0x4]\n\ + ldr r0, [r3, 0x4C]\n\ + cmp r0, 0\n\ + beq _0803BE9A\n\ + movs r0, 0x96\n\ + ldr r1, [sp, 0x14]\n\ + muls r0, r1\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x14]\n\ +_0803BE9A:\n\ + mov r2, r9\n\ + cmp r2, 0xD\n\ + bne _0803BEBE\n\ + movs r0, 0\n\ + str r0, [sp]\n\ + movs r0, 0xE\n\ + movs r1, 0\n\ + movs r2, 0\n\ + movs r3, 0xFD\n\ + bl AbilityBattleEffects\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0803BEBE\n\ + ldr r1, _0803BFE8 @ =gBattleMovePower\n\ + ldrh r0, [r1]\n\ + lsrs r0, 1\n\ + strh r0, [r1]\n\ +_0803BEBE:\n\ + mov r3, r9\n\ + cmp r3, 0xA\n\ + bne _0803BEE2\n\ + movs r0, 0\n\ + str r0, [sp]\n\ + movs r0, 0xE\n\ + movs r1, 0\n\ + movs r2, 0\n\ + movs r3, 0xFE\n\ + bl AbilityBattleEffects\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0803BEE2\n\ + ldr r1, _0803BFE8 @ =gBattleMovePower\n\ + ldrh r0, [r1]\n\ + lsrs r0, 1\n\ + strh r0, [r1]\n\ +_0803BEE2:\n\ + mov r0, r9\n\ + cmp r0, 0xC\n\ + bne _0803BF12\n\ + ldr r1, [sp, 0x24]\n\ + ldrb r0, [r1]\n\ + cmp r0, 0x41\n\ + bne _0803BF12\n\ + ldrh r0, [r7, 0x2C]\n\ + movs r1, 0x3\n\ + bl __udivsi3\n\ + ldrh r1, [r7, 0x28]\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r1, r0\n\ + bhi _0803BF12\n\ + ldr r4, _0803BFE8 @ =gBattleMovePower\n\ + ldrh r1, [r4]\n\ + movs r0, 0x96\n\ + muls r0, r1\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + strh r0, [r4]\n\ +_0803BF12:\n\ + mov r2, r9\n\ + cmp r2, 0xA\n\ + bne _0803BF42\n\ + ldr r3, [sp, 0x24]\n\ + ldrb r0, [r3]\n\ + cmp r0, 0x42\n\ + bne _0803BF42\n\ + ldrh r0, [r7, 0x2C]\n\ + movs r1, 0x3\n\ + bl __udivsi3\n\ + ldrh r1, [r7, 0x28]\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r1, r0\n\ + bhi _0803BF42\n\ + ldr r4, _0803BFE8 @ =gBattleMovePower\n\ + ldrh r1, [r4]\n\ + movs r0, 0x96\n\ + muls r0, r1\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + strh r0, [r4]\n\ +_0803BF42:\n\ + mov r0, r9\n\ + cmp r0, 0xB\n\ + bne _0803BF72\n\ + ldr r1, [sp, 0x24]\n\ + ldrb r0, [r1]\n\ + cmp r0, 0x43\n\ + bne _0803BF72\n\ + ldrh r0, [r7, 0x2C]\n\ + movs r1, 0x3\n\ + bl __udivsi3\n\ + ldrh r1, [r7, 0x28]\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r1, r0\n\ + bhi _0803BF72\n\ + ldr r4, _0803BFE8 @ =gBattleMovePower\n\ + ldrh r1, [r4]\n\ + movs r0, 0x96\n\ + muls r0, r1\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + strh r0, [r4]\n\ +_0803BF72:\n\ + mov r2, r9\n\ + cmp r2, 0x6\n\ + bne _0803BFA2\n\ + ldr r3, [sp, 0x24]\n\ + ldrb r0, [r3]\n\ + cmp r0, 0x44\n\ + bne _0803BFA2\n\ + ldrh r0, [r7, 0x2C]\n\ + movs r1, 0x3\n\ + bl __udivsi3\n\ + ldrh r1, [r7, 0x28]\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r1, r0\n\ + bhi _0803BFA2\n\ + ldr r4, _0803BFE8 @ =gBattleMovePower\n\ + ldrh r1, [r4]\n\ + movs r0, 0x96\n\ + muls r0, r1\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + strh r0, [r4]\n\ +_0803BFA2:\n\ + ldr r2, _0803BFEC @ =gBattleMoves\n\ + ldr r0, _0803BFF0 @ =gCurrentMove\n\ + ldrh r1, [r0]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r2\n\ + ldrb r0, [r0]\n\ + cmp r0, 0x7\n\ + bne _0803BFBC\n\ + ldr r0, [sp, 0x14]\n\ + lsrs r0, 1\n\ + str r0, [sp, 0x14]\n\ +_0803BFBC:\n\ + mov r1, r9\n\ + cmp r1, 0x8\n\ + bls _0803BFC4\n\ + b _0803C122\n\ +_0803BFC4:\n\ + ldr r0, _0803BFF4 @ =gCritMultiplier\n\ + ldrb r1, [r0]\n\ + adds r4, r0, 0\n\ + cmp r1, 0x2\n\ + bne _0803C000\n\ + movs r0, 0x19\n\ + ldrsb r0, [r7, r0]\n\ + cmp r0, 0x6\n\ + ble _0803BFFC\n\ + ldr r2, _0803BFF8 @ =gStatStageRatios\n\ + b _0803C006\n\ + .align 2, 0\n\ +_0803BFDC: .4byte gBattleTypeFlags\n\ +_0803BFE0: .4byte 0xfffffe69\n\ +_0803BFE4: .4byte 0x00000175\n\ +_0803BFE8: .4byte gBattleMovePower\n\ +_0803BFEC: .4byte gBattleMoves\n\ +_0803BFF0: .4byte gCurrentMove\n\ +_0803BFF4: .4byte gCritMultiplier\n\ +_0803BFF8: .4byte gStatStageRatios\n\ +_0803BFFC:\n\ + adds r5, r6, 0\n\ + b _0803C01E\n\ +_0803C000:\n\ + ldr r2, _0803C050 @ =gStatStageRatios\n\ + movs r0, 0x19\n\ + ldrsb r0, [r7, r0]\n\ +_0803C006:\n\ + lsls r0, 1\n\ + adds r1, r0, r2\n\ + ldrb r1, [r1]\n\ + adds r5, r6, 0\n\ + muls r5, r1\n\ + adds r2, 0x1\n\ + adds r0, r2\n\ + ldrb r1, [r0]\n\ + adds r0, r5, 0\n\ + bl __divsi3\n\ + adds r5, r0, 0\n\ +_0803C01E:\n\ + ldr r0, _0803C054 @ =gBattleMovePower\n\ + ldrh r0, [r0]\n\ + muls r5, r0\n\ + adds r0, r7, 0\n\ + adds r0, 0x2A\n\ + ldrb r0, [r0]\n\ + lsls r0, 1\n\ + movs r1, 0x5\n\ + bl __divsi3\n\ + adds r0, 0x2\n\ + muls r5, r0\n\ + ldrb r0, [r4]\n\ + cmp r0, 0x2\n\ + bne _0803C05C\n\ + ldr r2, [sp, 0x4]\n\ + movs r0, 0x1A\n\ + ldrsb r0, [r2, r0]\n\ + cmp r0, 0x5\n\ + bgt _0803C058\n\ + ldr r2, _0803C050 @ =gStatStageRatios\n\ + ldr r3, [sp, 0x4]\n\ + movs r0, 0x1A\n\ + ldrsb r0, [r3, r0]\n\ + b _0803C064\n\ + .align 2, 0\n\ +_0803C050: .4byte gStatStageRatios\n\ +_0803C054: .4byte gBattleMovePower\n\ +_0803C058:\n\ + ldr r3, [sp, 0x14]\n\ + b _0803C07E\n\ +_0803C05C:\n\ + ldr r2, _0803C0DC @ =gStatStageRatios\n\ + ldr r1, [sp, 0x4]\n\ + movs r0, 0x1A\n\ + ldrsb r0, [r1, r0]\n\ +_0803C064:\n\ + lsls r0, 1\n\ + adds r1, r0, r2\n\ + ldrb r1, [r1]\n\ + ldr r6, [sp, 0x14]\n\ + adds r3, r6, 0\n\ + muls r3, r1\n\ + adds r2, 0x1\n\ + adds r0, r2\n\ + ldrb r1, [r0]\n\ + adds r0, r3, 0\n\ + bl __divsi3\n\ + adds r3, r0, 0\n\ +_0803C07E:\n\ + adds r0, r5, 0\n\ + adds r1, r3, 0\n\ + bl __divsi3\n\ + adds r5, r0, 0\n\ + movs r1, 0x32\n\ + bl __divsi3\n\ + adds r5, r0, 0\n\ + ldr r0, [r7, 0x4C]\n\ + movs r1, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803C0A8\n\ + ldr r1, [sp, 0x24]\n\ + ldrb r0, [r1]\n\ + cmp r0, 0x3E\n\ + beq _0803C0A8\n\ + lsrs r0, r5, 31\n\ + adds r0, r5, r0\n\ + asrs r5, r0, 1\n\ +_0803C0A8:\n\ + movs r0, 0x1\n\ + ldr r2, [sp, 0xC]\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _0803C0EA\n\ + ldrb r1, [r4]\n\ + cmp r1, 0x1\n\ + bne _0803C0EA\n\ + ldr r0, _0803C0E0 @ =gBattleTypeFlags\n\ + ldrh r0, [r0]\n\ + ands r1, r0\n\ + cmp r1, 0\n\ + beq _0803C0E4\n\ + movs r0, 0x2\n\ + bl CountAliveMons\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x2\n\ + bne _0803C0E4\n\ + adds r0, r5, 0\n\ + movs r1, 0x3\n\ + bl __divsi3\n\ + lsls r5, r0, 1\n\ + b _0803C0EA\n\ + .align 2, 0\n\ +_0803C0DC: .4byte gStatStageRatios\n\ +_0803C0E0: .4byte gBattleTypeFlags\n\ +_0803C0E4:\n\ + lsrs r0, r5, 31\n\ + adds r0, r5, r0\n\ + asrs r5, r0, 1\n\ +_0803C0EA:\n\ + ldr r0, _0803C148 @ =gBattleTypeFlags\n\ + ldrh r1, [r0]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803C11C\n\ + ldr r0, _0803C14C @ =gBattleMoves\n\ + ldr r3, [sp, 0x8]\n\ + lsls r1, r3, 1\n\ + adds r1, r3\n\ + lsls r1, 2\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x6]\n\ + cmp r0, 0x8\n\ + bne _0803C11C\n\ + movs r0, 0x2\n\ + bl CountAliveMons\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x2\n\ + bne _0803C11C\n\ + lsrs r0, r5, 31\n\ + adds r0, r5, r0\n\ + asrs r5, r0, 1\n\ +_0803C11C:\n\ + cmp r5, 0\n\ + bne _0803C122\n\ + movs r5, 0x1\n\ +_0803C122:\n\ + mov r6, r9\n\ + cmp r6, 0x9\n\ + bne _0803C12A\n\ + movs r5, 0\n\ +_0803C12A:\n\ + mov r0, r9\n\ + cmp r0, 0x9\n\ + bhi _0803C132\n\ + b _0803C330\n\ +_0803C132:\n\ + ldr r0, _0803C150 @ =gCritMultiplier\n\ + ldrb r1, [r0]\n\ + adds r4, r0, 0\n\ + cmp r1, 0x2\n\ + bne _0803C15C\n\ + movs r0, 0x1C\n\ + ldrsb r0, [r7, r0]\n\ + cmp r0, 0x6\n\ + ble _0803C158\n\ + ldr r2, _0803C154 @ =gStatStageRatios\n\ + b _0803C162\n\ + .align 2, 0\n\ +_0803C148: .4byte gBattleTypeFlags\n\ +_0803C14C: .4byte gBattleMoves\n\ +_0803C150: .4byte gCritMultiplier\n\ +_0803C154: .4byte gStatStageRatios\n\ +_0803C158:\n\ + mov r5, r8\n\ + b _0803C17A\n\ +_0803C15C:\n\ + ldr r2, _0803C1A8 @ =gStatStageRatios\n\ + movs r0, 0x1C\n\ + ldrsb r0, [r7, r0]\n\ +_0803C162:\n\ + lsls r0, 1\n\ + adds r1, r0, r2\n\ + ldrb r1, [r1]\n\ + mov r5, r8\n\ + muls r5, r1\n\ + adds r2, 0x1\n\ + adds r0, r2\n\ + ldrb r1, [r0]\n\ + adds r0, r5, 0\n\ + bl __divsi3\n\ + adds r5, r0, 0\n\ +_0803C17A:\n\ + ldr r0, _0803C1AC @ =gBattleMovePower\n\ + ldrh r0, [r0]\n\ + muls r5, r0\n\ + adds r0, r7, 0\n\ + adds r0, 0x2A\n\ + ldrb r0, [r0]\n\ + lsls r0, 1\n\ + movs r1, 0x5\n\ + bl __divsi3\n\ + adds r0, 0x2\n\ + muls r5, r0\n\ + ldrb r0, [r4]\n\ + cmp r0, 0x2\n\ + bne _0803C1B4\n\ + ldr r1, [sp, 0x4]\n\ + movs r0, 0x1D\n\ + ldrsb r0, [r1, r0]\n\ + cmp r0, 0x5\n\ + bgt _0803C1B0\n\ + ldr r2, _0803C1A8 @ =gStatStageRatios\n\ + b _0803C1BC\n\ + .align 2, 0\n\ +_0803C1A8: .4byte gStatStageRatios\n\ +_0803C1AC: .4byte gBattleMovePower\n\ +_0803C1B0:\n\ + ldr r3, [sp, 0x18]\n\ + b _0803C1D6\n\ +_0803C1B4:\n\ + ldr r2, _0803C21C @ =gStatStageRatios\n\ + ldr r1, [sp, 0x4]\n\ + movs r0, 0x1D\n\ + ldrsb r0, [r1, r0]\n\ +_0803C1BC:\n\ + lsls r0, 1\n\ + adds r1, r0, r2\n\ + ldrb r1, [r1]\n\ + ldr r6, [sp, 0x18]\n\ + adds r3, r6, 0\n\ + muls r3, r1\n\ + adds r2, 0x1\n\ + adds r0, r2\n\ + ldrb r1, [r0]\n\ + adds r0, r3, 0\n\ + bl __divsi3\n\ + adds r3, r0, 0\n\ +_0803C1D6:\n\ + adds r0, r5, 0\n\ + adds r1, r3, 0\n\ + bl __divsi3\n\ + adds r5, r0, 0\n\ + movs r1, 0x32\n\ + bl __divsi3\n\ + adds r5, r0, 0\n\ + movs r0, 0x2\n\ + ldr r1, [sp, 0xC]\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803C22A\n\ + ldrb r1, [r4]\n\ + cmp r1, 0x1\n\ + bne _0803C22A\n\ + ldr r0, _0803C220 @ =gBattleTypeFlags\n\ + ldrh r0, [r0]\n\ + ands r1, r0\n\ + cmp r1, 0\n\ + beq _0803C224\n\ + movs r0, 0x2\n\ + bl CountAliveMons\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x2\n\ + bne _0803C224\n\ + adds r0, r5, 0\n\ + movs r1, 0x3\n\ + bl __divsi3\n\ + lsls r5, r0, 1\n\ + b _0803C22A\n\ + .align 2, 0\n\ +_0803C21C: .4byte gStatStageRatios\n\ +_0803C220: .4byte gBattleTypeFlags\n\ +_0803C224:\n\ + lsrs r0, r5, 31\n\ + adds r0, r5, r0\n\ + asrs r5, r0, 1\n\ +_0803C22A:\n\ + ldr r0, _0803C2A4 @ =gBattleTypeFlags\n\ + ldrh r1, [r0]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803C25C\n\ + ldr r0, _0803C2A8 @ =gBattleMoves\n\ + ldr r2, [sp, 0x8]\n\ + lsls r1, r2, 1\n\ + adds r1, r2\n\ + lsls r1, 2\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x6]\n\ + cmp r0, 0x8\n\ + bne _0803C25C\n\ + movs r0, 0x2\n\ + bl CountAliveMons\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x2\n\ + bne _0803C25C\n\ + lsrs r0, r5, 31\n\ + adds r0, r5, r0\n\ + asrs r5, r0, 1\n\ +_0803C25C:\n\ + movs r0, 0\n\ + str r0, [sp]\n\ + movs r0, 0xE\n\ + movs r1, 0\n\ + movs r2, 0xD\n\ + movs r3, 0\n\ + bl AbilityBattleEffects\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0\n\ + bne _0803C30C\n\ + str r0, [sp]\n\ + movs r0, 0xE\n\ + movs r1, 0\n\ + movs r2, 0x4D\n\ + movs r3, 0\n\ + bl AbilityBattleEffects\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _0803C30C\n\ + ldr r2, _0803C2AC @ =gBattleWeather\n\ + ldrh r1, [r2]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + adds r4, r2, 0\n\ + cmp r0, 0\n\ + beq _0803C2C4\n\ + mov r3, r9\n\ + cmp r3, 0xA\n\ + beq _0803C2B0\n\ + cmp r3, 0xB\n\ + beq _0803C2B8\n\ + b _0803C2C4\n\ + .align 2, 0\n\ +_0803C2A4: .4byte gBattleTypeFlags\n\ +_0803C2A8: .4byte gBattleMoves\n\ +_0803C2AC: .4byte gBattleWeather\n\ +_0803C2B0:\n\ + lsrs r0, r5, 31\n\ + adds r0, r5, r0\n\ + asrs r5, r0, 1\n\ + b _0803C2C4\n\ +_0803C2B8:\n\ + lsls r0, r5, 4\n\ + subs r0, r5\n\ + movs r1, 0xA\n\ + bl __divsi3\n\ + adds r5, r0, 0\n\ +_0803C2C4:\n\ + ldrh r1, [r4]\n\ + movs r0, 0x9F\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803C2DC\n\ + ldr r0, _0803C2F4 @ =gCurrentMove\n\ + ldrh r0, [r0]\n\ + cmp r0, 0x4C\n\ + bne _0803C2DC\n\ + lsrs r0, r5, 31\n\ + adds r0, r5, r0\n\ + asrs r5, r0, 1\n\ +_0803C2DC:\n\ + ldrh r1, [r4]\n\ + movs r0, 0x60\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803C30C\n\ + mov r6, r9\n\ + cmp r6, 0xA\n\ + beq _0803C2F8\n\ + cmp r6, 0xB\n\ + beq _0803C306\n\ + b _0803C30C\n\ + .align 2, 0\n\ +_0803C2F4: .4byte gCurrentMove\n\ +_0803C2F8:\n\ + lsls r0, r5, 4\n\ + subs r0, r5\n\ + movs r1, 0xA\n\ + bl __divsi3\n\ + adds r5, r0, 0\n\ + b _0803C30C\n\ +_0803C306:\n\ + lsrs r0, r5, 31\n\ + adds r0, r5, r0\n\ + asrs r5, r0, 1\n\ +_0803C30C:\n\ + ldr r1, _0803C344 @ =0x02017100\n\ + ldr r2, [sp, 0x10]\n\ + lsls r0, r2, 2\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + movs r1, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0803C330\n\ + mov r3, r9\n\ + cmp r3, 0xA\n\ + bne _0803C330\n\ + lsls r0, r5, 4\n\ + subs r0, r5\n\ + movs r1, 0xA\n\ + bl __divsi3\n\ + adds r5, r0, 0\n\ +_0803C330:\n\ + adds r0, r5, 0x2\n\ + add sp, 0x2C\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ +_0803C344: .4byte 0x02017100\n\ + .syntax divided"); +} +#endif diff --git a/src/choose_party.c b/src/choose_party.c new file mode 100644 index 000000000..63e9c8477 --- /dev/null +++ b/src/choose_party.c @@ -0,0 +1,1071 @@ +#include "global.h" +#include "decoration.h" +#include "field_fadetransition.h" +#include "main.h" +#include "menu.h" +#include "name_string_util.h" +#include "palette.h" +#include "party_menu.h" +#include "pokemon.h" +#include "pokemon_summary_screen.h" +#include "rom4.h" +#include "script.h" +#include "songs.h" +#include "sound.h" +#include "strings.h" +#include "string_util.h" +#include "task.h" +#include "text.h" + +struct UnknownPokemonStruct2 +{ + /*0x00*/ u16 species; + /*0x02*/ u16 heldItem; + /*0x04*/ u8 nickname[11]; + /*0x0F*/ u8 level; + /*0x10*/ u16 hp; + /*0x12*/ u16 maxhp; + /*0x14*/ u32 status; + /*0x18*/ u32 personality; + /*0x1C*/ u8 gender; + /*0x1D*/ u8 language; +}; + +extern u8 gSelectedOrderFromParty[]; +extern u8 gPlayerPartyCount; +extern u8 gLastFieldPokeMenuOpened; +extern u8 gUnknown_020384F0; +extern struct UnknownPokemonStruct2 gUnknown_02023A00[]; +extern u8 gUnknown_0202E8F6; +extern struct Pokemon gUnknown_030042FC[]; +extern const u16 gBattleTowerBanlist[]; + +extern void OpenPartyMenu(); +extern void TryCreatePartyMenuMonIcon(u8, u8, struct Pokemon *); +extern void LoadHeldItemIconGraphics(void); +extern void CreateHeldItemIcons_806DC34(); +extern u8 sub_806BD58(u8, u8); +extern void PartyMenuPrintMonsLevelOrStatus(void); +extern void PrintPartyMenuMonNicknames(void); +extern void sub_806BC3C(u8, u8); +extern u8 sub_806B58C(u8); +extern void sub_806D538(); +extern u16 sub_806BE38(); +extern u8 sub_806CA38(); +extern void sub_808B5B4(); +extern TaskFunc PartyMenuGetPopupMenuFunc(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, u8); +extern u8 sub_806B124(); +extern void sub_806C994(); +extern void sub_806C658(); +extern void sub_806AEDC(void); +extern void sub_806AF4C(); +extern void ShowPokemonSummaryScreen(struct Pokemon *, u8, u8, void (*)(void), int); +extern void sub_806C890(); +extern void sub_806D5A4(); +extern void sub_806B908(void); +extern void CreateMonIcon_806D99C(int, u8, int, struct UnknownPokemonStruct2 *); +extern void sub_806D50C(int, u8); +extern void CreatePartyMenuMonIcon(); +extern void CreateHeldItemIcon_806DCD4(int, u8, int); +extern u8 GetMonStatusAndPokerus(); +extern void PartyMenuPrintHP(); +extern void PartyMenuPutStatusTilemap(u8, int, u8); +extern void PartyMenuPrintLevel(); +extern void PartyMenuPutNicknameTilemap(); +extern void PrintPartyMenuMonNickname(); +extern void PartyMenuDrawHPBar(); +extern bool8 sub_80F9344(void); +extern void sub_806D4AC(); +extern void sub_806D3B4(); +extern void PartyMenuDoPrintLevel(u8, u8, u8); +extern void PartyMenuDoDrawHPBar(u8, u8, u16, u16); +extern void PartyMenuDoPutNicknameTilemap(u16, u8, u8, u8, const u8 *); +extern void box_print(u8, int, const u8 *); +extern void sub_806BCE8(void); +extern void sub_806E750(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, int); +extern u16 sub_806BD80(); +extern void sub_806BF74(); + +static void ClearPartySelection(void); +static bool8 IsMonAllowedInBattleTower(struct Pokemon *); +static void sub_812238C(u8); +static void sub_8122450(u8); +static void sub_81224A8(u8); +static void sub_8122728(u8); +static void BattleTowerEntryMenuCallback_Exit(u8); +static void sub_81228E8(u8); +static void sub_8122950(u8); +static void sub_81229B8(void); +static void sub_8122AB8(u8); +static void sub_8122B10(u8); +static void sub_8122C18(u8); +static void Task_DaycareStorageMenu8122EAC(u8); +void sub_8123138(u8); +static void sub_8123170(u8); +static void sub_81231AC(void); + +void sub_8121E10(void) +{ + ClearPartySelection(); + ewram1B000.unk263 = 0; + OpenPartyMenu(4, 0); +} + +void sub_8121E34(void) +{ + ClearPartySelection(); + ewram1B000.unk263 = 1; + OpenPartyMenu(4, 0); +} + +static void ClearPartySelection(void) +{ + u8 i; + + for (i = 0; i < 3; i++) + gSelectedOrderFromParty[i] = 0; +} + +bool8 sub_8121E78(void) +{ + u8 i; + + switch (ewram1B000_alt.unk264) + { + case 0: + if (ewram1B000_alt.unk266 < gPlayerPartyCount) + { + TryCreatePartyMenuMonIcon(ewram1B000_alt.unk260, ewram1B000_alt.unk266, &gPlayerParty[ewram1B000_alt.unk266]); + ewram1B000_alt.unk266++; + } + else + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + break; + case 1: + LoadHeldItemIconGraphics(); + ewram1B000_alt.unk264++; + break; + case 2: + CreateHeldItemIcons_806DC34(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 3: + if (sub_806BD58(ewram1B000_alt.unk260, ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + else + { + ewram1B000_alt.unk266++; + } + break; + case 4: + PartyMenuPrintMonsLevelOrStatus(); + ewram1B000_alt.unk264++; + break; + case 5: + PrintPartyMenuMonNicknames(); + ewram1B000_alt.unk264++; + break; + case 6: + for (i = 0; i < gPlayerPartyCount; i++) + { + u8 j; + + for (j = 0; j < 3; j++) + { + if (gSelectedOrderFromParty[j] == i + 1) + { + sub_806BC3C(i, j * 14 + 0x1C); + break; + } + } + if (j == 3) + { + if (IsMonAllowedInBattleTower(&gPlayerParty[i]) == TRUE) + sub_806BC3C(i, 0x70); + else + sub_806BC3C(i, 0x7E); + } + } + ewram1B000_alt.unk264++; + break; + case 7: + if (sub_806B58C(ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264 = 0; + return TRUE; + } + else + { + ewram1B000_alt.unk266++; + } + break; + } + return FALSE; +} + +#ifdef NONMATCHING +static bool8 IsMonAllowedInBattleTower(struct Pokemon *pkmn) +{ + u16 r3; + s32 i; + + if (GetMonData(pkmn, MON_DATA_IS_EGG)) + return FALSE; + + if (ewram1B000.unk263 == 0) + { + if (GetMonData(pkmn, MON_DATA_HP) == 0) + return FALSE; + else + return TRUE; + } + + if ((gSaveBlock2.filler_A8.var_4AC & 1) == 0 + && GetMonData(pkmn, MON_DATA_LEVEL) > 50) + return FALSE; + + r3 = GetMonData(pkmn, MON_DATA_SPECIES); + // Can't stop the compiler from optimizing out the first index + for (i = 0; gBattleTowerBanlist[i] != 0xFFFF; i++) + { + if (gBattleTowerBanlist[i] == r3) + return FALSE; + } + return TRUE; +} +#else +__attribute__((naked)) +static bool8 IsMonAllowedInBattleTower(struct Pokemon *pkmn) +{ + asm_unified( + "push {r4,lr}\n\ + adds r4, r0, 0\n\ + movs r1, 0x2D\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + bne _0812207C\n\ + ldr r0, _08122058 @ =0x0201b000\n\ + ldr r1, _0812205C @ =0x00000263\n\ + adds r0, r1\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + bne _08122060\n\ + adds r0, r4, 0\n\ + movs r1, 0x39\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + beq _0812207C\n\ + b _081220B6\n\ + .align 2, 0\n\ +_08122058: .4byte 0x0201b000\n\ +_0812205C: .4byte 0x00000263\n\ +_08122060:\n\ + ldr r0, _08122080 @ =gSaveBlock2\n\ + ldr r1, _08122084 @ =0x00000554\n\ + adds r0, r1\n\ + ldrb r1, [r0]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08122088\n\ + adds r0, r4, 0\n\ + movs r1, 0x38\n\ + bl GetMonData\n\ + cmp r0, 0x32\n\ + bls _08122088\n\ +_0812207C:\n\ + movs r0, 0\n\ + b _081220B8\n\ + .align 2, 0\n\ +_08122080: .4byte gSaveBlock2\n\ +_08122084: .4byte 0x00000554\n\ +_08122088:\n\ + adds r0, r4, 0\n\ + movs r1, 0xB\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + ldr r1, _081220C0 @ =gBattleTowerBanlist\n\ + movs r0, 0\n\ + lsls r0, 1\n\ + adds r2, r0, r1\n\ + ldrh r0, [r2]\n\ + ldr r1, _081220C4 @ =0x0000ffff\n\ + cmp r0, r1\n\ + beq _081220B6\n\ + adds r4, r1, 0\n\ + adds r1, r2, 0\n\ +_081220A8:\n\ + ldrh r0, [r1]\n\ + cmp r0, r3\n\ + beq _0812207C\n\ + adds r1, 0x2\n\ + ldrh r0, [r1]\n\ + cmp r0, r4\n\ + bne _081220A8\n\ +_081220B6:\n\ + movs r0, 0x1\n\ +_081220B8:\n\ + pop {r4}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ +_081220C0: .4byte gBattleTowerBanlist\n\ +_081220C4: .4byte 0x0000ffff\n" + ); +} +#endif + +static u8 sub_81220C8(void) +{ + u8 i; + + if (ewram1B000.unk263 == 0) + return 0xFF; + if (gSelectedOrderFromParty[2] == 0) + return 0x11; + for (i = 0; i < 2; i++) + { + u8 j; + + ewram1B000.unk282 = GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[i]], MON_DATA_SPECIES); + ewram1B000.unk280 = GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[i]], MON_DATA_HELD_ITEM); + for (j = i + 1; j < 3; j++) + { + if (ewram1B000.unk282 == GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[j]], MON_DATA_SPECIES)) + return 0x12; + if (ewram1B000.unk280 != 0 && ewram1B000.unk280 == GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[j]], MON_DATA_HELD_ITEM)) + return 0x13; + } + } + return 0xFF; +} + +//------------------------------------------------------------------------------ +// Battle Tower Entry Menu +//------------------------------------------------------------------------------ + +static void BattleTowerEntryMenuCallback_Summary(u8); +static void BattleTowerEntryMenuCallback_Enter(u8); +static void BattleTowerEntryMenuCallback_NoEntry(u8); +static void BattleTowerEntryMenuCallback_Exit(u8); + +static const struct PartyMenuItem sBattleTowerEntryMenuItems[] = +{ + {OtherText_Summary, BattleTowerEntryMenuCallback_Summary}, + {OtherText_Enter2, BattleTowerEntryMenuCallback_Enter}, + {OtherText_NoEntry, BattleTowerEntryMenuCallback_NoEntry}, + {gUnknownText_Exit, BattleTowerEntryMenuCallback_Exit}, +}; + +static const u8 gUnknown_084017D0[] = {1, 0, 3}; +static const u8 gUnknown_084017D3[] = {2, 0, 3}; +static const u8 gUnknown_084017D6[] = {0, 3}; + +static const struct PartyPopupMenu sBattleTowerEntryMenu[] = +{ + {ARRAY_COUNT(gUnknown_084017D0), 9, gUnknown_084017D0}, + {ARRAY_COUNT(gUnknown_084017D3), 9, gUnknown_084017D3}, + {ARRAY_COUNT(gUnknown_084017D6), 9, gUnknown_084017D6}, +}; + + +static bool8 IsPartyMemberAlreadySelected(u8 partyMember) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gSelectedOrderFromParty[i] == partyMember) + return TRUE; + } + return FALSE; +} + +static void sub_81221F8(u8 taskId) +{ + sub_806D538(5, 1); + if (IsMonAllowedInBattleTower(&gPlayerParty[gLastFieldPokeMenuOpened]) == TRUE) + { + if (IsPartyMemberAlreadySelected(gLastFieldPokeMenuOpened + 1) == TRUE) + { + gTasks[taskId].data[4] = 1; + sub_806E750(1, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); + } + else + { + gTasks[taskId].data[4] = 0; + sub_806E750(0, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); + } + } + else + { + gTasks[taskId].data[4] = 2; + sub_806E750(2, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); + } +} + +void sub_81222B0(u8 taskId) +{ + if (!gPaletteFade.active) + { + switch (sub_806BE38(taskId)) + { + case 1: + PlaySE(SE_SELECT); + gLastFieldPokeMenuOpened = sub_806CA38(taskId); + if (gLastFieldPokeMenuOpened != 6) + { + GetMonNickname(&gPlayerParty[gLastFieldPokeMenuOpened], gStringVar1); + sub_81221F8(taskId); + gTasks[taskId].func = sub_812238C; + } + else + { + gTasks[taskId].func = sub_81224A8; + } + sub_808B5B4(taskId); + break; + case 2: + PlaySE(SE_SELECT); + ClearPartySelection(); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8122450; + break; + } + } +} + +// Handle input +static void sub_812238C(u8 taskId) +{ + if (!gPaletteFade.active) + { + if (gMain.newAndRepeatedKeys & 0x40) + { + if (GetMenuCursorPos() != 0) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + } + return; + } + if (gMain.newAndRepeatedKeys & 0x80) + { + if (GetMenuCursorPos() != 3) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + } + return; + } + if (gMain.newKeys & A_BUTTON) + { + TaskFunc popupMenuFunc; + + PlaySE(SE_SELECT); + popupMenuFunc = PartyMenuGetPopupMenuFunc( + gTasks[taskId].data[4], + sBattleTowerEntryMenu, + sBattleTowerEntryMenuItems, + GetMenuCursorPos()); + popupMenuFunc(taskId); + return; + } + if (gMain.newKeys & B_BUTTON) + { + BattleTowerEntryMenuCallback_Exit(taskId); + return; + } + } +} + +// Return from menu? +static void sub_8122450(u8 taskId) +{ + if (!gPaletteFade.active) + { + SetMainCallback2(gMain.savedCallback); + DestroyTask(taskId); + } +} + +// Wait for A or B press +static void sub_8122480(u8 taskId) +{ + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + BattleTowerEntryMenuCallback_Exit(taskId); +} + +static void sub_81224A8(u8 taskId) +{ + u8 val = sub_81220C8(); + + if (val != 0xFF) + { + sub_806D538(val, 0); + gTasks[taskId].func = sub_8122480; + } + else + { + if (gSelectedOrderFromParty[0] != 0) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8122450; + } + else + { + PlaySE(SE_HAZURE); + sub_806D538(14, 0); + gTasks[taskId].func = sub_8122480; + } + } +} + +// CB2 for menu? +static void sub_8122530(void) +{ + while (1) + { + if (sub_806B124() == 1) + { + sub_806C994(ewram1B000.unk260, gUnknown_020384F0); + sub_806C658(ewram1B000.unk260, 0); + GetMonNickname(&gPlayerParty[gUnknown_020384F0], gStringVar1); + gLastFieldPokeMenuOpened = gUnknown_020384F0; + sub_81221F8(ewram1B000.unk260); + SetMainCallback2(sub_806AEDC); + break; + } + if (sub_80F9344() == 1) + break; + } +} + +static void sub_81225A4(void) +{ + gPaletteFade.bufferTransferDisabled = TRUE; + sub_806AF4C(4, 0xFF, sub_812238C, 5); + SetMainCallback2(sub_8122530); +} + +// Wait for fade, then show summary screen +static void sub_81225D4(u8 taskId) +{ + if (!gPaletteFade.active) + { + u8 r4 = gSprites[gTasks[taskId].data[3] >> 8].data0; + + DestroyTask(taskId); + ewram1B000.unk262 = 1; + ShowPokemonSummaryScreen(gPlayerParty, r4, gPlayerPartyCount - 1, sub_81225A4, 0); + } +} + +// Summary callback? +static void BattleTowerEntryMenuCallback_Summary(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_81225D4; +} + +static void BattleTowerEntryMenuCallback_Enter(u8 taskId) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gSelectedOrderFromParty[i] == 0) + { + gSelectedOrderFromParty[i] = gLastFieldPokeMenuOpened + 1; + sub_806BC3C(gLastFieldPokeMenuOpened, i * 14 + 0x1C); + if (i == 2) + sub_806C890(taskId); + BattleTowerEntryMenuCallback_Exit(taskId); + return; + } + } + PlaySE(SE_HAZURE); + MenuZeroFillWindowRect(20, 10, 29, 19); + HandleDestroyMenuCursors(); + sub_806D5A4(); + sub_806E834(gOtherText_NoMoreThreePoke, 1); + gTasks[taskId].func = sub_8122728; +} + +static void sub_8122728(u8 taskId) +{ + if (gUnknown_0202E8F6 == 1) + return; + + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + { + MenuZeroFillWindowRect(0, 14, 29, 19); + HandleDestroyMenuCursors(); + BattleTowerEntryMenuCallback_Exit(taskId); + } +} + +static void BattleTowerEntryMenuCallback_NoEntry(u8 taskId) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gSelectedOrderFromParty[i] == gLastFieldPokeMenuOpened + 1) + { + gSelectedOrderFromParty[i] = 0; + switch (i) + { + case 0: + gSelectedOrderFromParty[0] = gSelectedOrderFromParty[1]; + gSelectedOrderFromParty[1] = gSelectedOrderFromParty[2]; + gSelectedOrderFromParty[2] = 0; + break; + case 1: + gSelectedOrderFromParty[1] = gSelectedOrderFromParty[2]; + gSelectedOrderFromParty[2] = 0; + break; + } + break; // exit loop + } + } + sub_806BC3C(gLastFieldPokeMenuOpened, 0x70); + if (gSelectedOrderFromParty[0] != 0) + sub_806BC3C(gSelectedOrderFromParty[0] - 1, 0x1C); + if (gSelectedOrderFromParty[1] != 0) + sub_806BC3C(gSelectedOrderFromParty[1] - 1, 0x2A); + BattleTowerEntryMenuCallback_Exit(taskId); +} + +static void sub_81227FC(u8 taskId) +{ + MenuZeroFillWindowRect(20, 10, 29, 19); + HandleDestroyMenuCursors(); + sub_806D538(0, 0); + gTasks[taskId].func = sub_81222B0; +} + +static void BattleTowerEntryMenuCallback_Exit(u8 taskId) +{ + PlaySE(SE_SELECT); + sub_81227FC(taskId); +} + +bool8 sub_8122854(void) +{ + switch (ewram1B000_alt.unk264) + { + case 0: + sub_81228E8(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 1: + LoadHeldItemIconGraphics(); + ewram1B000_alt.unk264++; + break; + case 2: + sub_8122950(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 3: + sub_81229B8(); + ewram1B000_alt.unk264++; + break; + case 4: + sub_806B908(); + return TRUE; + } + return FALSE; +} + +static void sub_81228E8(u8 a) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) + CreatePartyMenuMonIcon(a, i, 3, &gPlayerParty[i]); + if (gUnknown_02023A00[i].species != 0) + { + CreateMonIcon_806D99C(a, i + 3, 3, &gUnknown_02023A00[i]); + sub_806D50C(a, i + 3); + } + } +} + +static void sub_8122950(u8 a) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) + { + u16 item = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + + CreateHeldItemIcon_806DCD4(a, i, item); + } + if (gUnknown_02023A00[i].species != 0) + CreateHeldItemIcon_806DCD4(a, i + 3, gUnknown_02023A00[i].heldItem); + } +} + +static void sub_81229B8(void) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) + { + u8 status; + + PartyMenuPrintHP(i, 3, &gPlayerParty[i]); + status = GetMonStatusAndPokerus(&gPlayerParty[i]); + if (status != 0 && status != 6) + PartyMenuPutStatusTilemap(i, 3, status - 1); + else + PartyMenuPrintLevel(i, 3, &gPlayerParty[i]); + PartyMenuPutNicknameTilemap(i, 3, &gPlayerParty[i]); + PrintPartyMenuMonNickname(i, 3, &gPlayerParty[i]); + PartyMenuDrawHPBar(i, 3, &gPlayerParty[i]); + } + } +} + +void sub_8122A48(u8 taskId) +{ + if (!gPaletteFade.active) + { + gTasks[taskId].data[0] = 30; + sub_806D4AC(taskId, gUnknown_02023A00[0].species, 0); + sub_806D4AC(taskId, gUnknown_02023A00[1].species, 1); + sub_806D4AC(taskId, gUnknown_02023A00[2].species, 2); + gTasks[taskId].func = sub_8122AB8; + ewram1B000.unk261 = 1; + } +} + +static void sub_8122AB8(u8 taskId) +{ + sub_806D3B4(taskId, gUnknown_02023A00[1].species, gUnknown_02023A00[2].species); + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].func = sub_8122B10; + ewram1B000.unk261 = 2; + PlaySE(SE_W231); + } +} + +static void sub_8122B10(u8 taskId) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gUnknown_02023A00[i].species != 0) + { + u8 r2; + + PartyMenuDoPrintHP(i + 3, 3, gUnknown_02023A00[i].hp, gUnknown_02023A00[i].maxhp); + if (gUnknown_02023A00[i].hp == 0) + r2 = 7; + else + r2 = pokemon_ailments_get_primary(gUnknown_02023A00[i].status); + if (r2 != 0) + PartyMenuPutStatusTilemap(i + 3, 3, r2 - 1); + else + PartyMenuDoPrintLevel(i + 3, 3, gUnknown_02023A00[i].level); + PartyMenuDoPutNicknameTilemap(gUnknown_02023A00[i].species, gUnknown_02023A00[i].gender, 3, i + 3, gUnknown_02023A00[i].nickname); + StringCopy(gStringVar1, gUnknown_02023A00[i].nickname); + StringGetEnd10(gStringVar1); + SanitizeNameString(gStringVar1); + box_print(i + 3, 3, gStringVar1); + PartyMenuDoDrawHPBar(i + 3, 3, gUnknown_02023A00[i].hp, gUnknown_02023A00[i].maxhp); + } + } + gTasks[taskId].func = sub_8122C18; + gTasks[taskId].data[0] = 0; +} + +static void sub_8122C18(u8 taskId) +{ + gTasks[taskId].data[0]++; + if (gTasks[taskId].data[0] == 256) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8122450; + } +} + +// Exactly the same as sub_8121E78 except for case 6 +bool8 unref_sub_8122C60(void) +{ + switch (ewram1B000_alt.unk264) + { + case 0: + if (ewram1B000_alt.unk266 < gPlayerPartyCount) + { + TryCreatePartyMenuMonIcon(ewram1B000_alt.unk260, ewram1B000_alt.unk266, &gPlayerParty[ewram1B000_alt.unk266]); + ewram1B000_alt.unk266++; + } + else + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + break; + case 1: + LoadHeldItemIconGraphics(); + ewram1B000_alt.unk264++; + break; + case 2: + CreateHeldItemIcons_806DC34(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 3: + if (sub_806BD58(ewram1B000_alt.unk260, ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + else + { + ewram1B000_alt.unk266++; + } + break; + case 4: + PartyMenuPrintMonsLevelOrStatus(); + ewram1B000_alt.unk264++; + break; + case 5: + PrintPartyMenuMonNicknames(); + ewram1B000_alt.unk264++; + break; + case 6: + sub_806BCE8(); + ewram1B000_alt.unk264++; + break; + case 7: + if (sub_806B58C(ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264 = 0; + return TRUE; + } + else + { + ewram1B000_alt.unk266++; + } + break; + } + return FALSE; +} + +//------------------------------------------------------------------------------ +// Daycare Pokemon Storage Menu +//------------------------------------------------------------------------------ + +static void DaycareStorageMenuCallback_Store(u8); +static void DaycareStorageMenuCallback_Summary(u8); +static void DaycareStorageMenuCallback_Exit(u8); + +static const struct PartyMenuItem sDaycareStorageMenuItems[] = +{ + {OtherText_Store, DaycareStorageMenuCallback_Store}, + {OtherText_Summary, DaycareStorageMenuCallback_Summary}, + {gUnknownText_Exit, DaycareStorageMenuCallback_Exit}, +}; + +static const u8 gUnknown_08401808[] = {0, 1, 2}; +static const u8 gUnknown_0840180B[] = {1, 2}; + +static const struct PartyPopupMenu sDaycareStorageMenus[] = +{ + {ARRAY_COUNT(gUnknown_08401808), 9, gUnknown_08401808}, + {ARRAY_COUNT(gUnknown_0840180B), 9, gUnknown_0840180B}, +}; + +static void sub_8122D94(u8 taskId) +{ + if (!GetMonData(&gPlayerParty[gLastFieldPokeMenuOpened], MON_DATA_IS_EGG)) + { + gTasks[taskId].data[4] = 0; + sub_806E750(0, sDaycareStorageMenus, sDaycareStorageMenuItems, 0); + } + else + { + gTasks[taskId].data[4] = 1; + sub_806E750(1, sDaycareStorageMenus, sDaycareStorageMenuItems, 0); + } +} + +void sub_8122E0C(u8 taskId) +{ + if (!gPaletteFade.active) + { + switch (sub_806BD80(taskId)) + { + case 1: + PlaySE(SE_SELECT); + gLastFieldPokeMenuOpened = sub_806CA38(taskId); + GetMonNickname(&gPlayerParty[gLastFieldPokeMenuOpened], gStringVar1); + sub_8122D94(taskId); + gTasks[taskId].func = Task_DaycareStorageMenu8122EAC; + break; + case 2: + PlaySE(SE_SELECT); + gLastFieldPokeMenuOpened = 0xFF; + gSpecialVar_0x8004 = 0xFF; + sub_8123138(taskId); + break; + } + } +} + +static void Task_DaycareStorageMenu8122EAC(u8 taskId) +{ + if (!gPaletteFade.active) + { + if (gMain.newAndRepeatedKeys & 0x40) + { + if (GetMenuCursorPos() != 0) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + } + return; + } + if (gMain.newAndRepeatedKeys & 0x80) + { + if (GetMenuCursorPos() != 3) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + } + return; + } + if (gMain.newKeys & A_BUTTON) + { + TaskFunc popupMenuFunc; + + PlaySE(SE_SELECT); + popupMenuFunc = PartyMenuGetPopupMenuFunc( + gTasks[taskId].data[4], + sDaycareStorageMenus, + sDaycareStorageMenuItems, + GetMenuCursorPos()); + popupMenuFunc(taskId); + return; + } + if (gMain.newKeys & B_BUTTON) + { + DaycareStorageMenuCallback_Exit(taskId); + return; + } + } +} + +static void DaycareStorageMenuCallback_Store(u8 taskId) +{ + gSpecialVar_0x8004 = gLastFieldPokeMenuOpened; + sub_8123138(taskId); +} + +static void sub_8122F90(void) +{ + while (1) + { + if (sub_806B124() == 1) + { + sub_806C994(ewram1B000.unk260, gUnknown_020384F0); + sub_806BF74(ewram1B000.unk260, 0); + GetMonNickname(&gPlayerParty[gUnknown_020384F0], gStringVar1); + gLastFieldPokeMenuOpened = gUnknown_020384F0; + sub_8122D94(ewram1B000.unk260); + SetMainCallback2(sub_806AEDC); + break; + } + if (sub_80F9344() == 1) + break; + } +} + +static void sub_8123004(void) +{ + gPaletteFade.bufferTransferDisabled = TRUE; + sub_806AF4C(6, 0xFF, Task_DaycareStorageMenu8122EAC, 5); + SetMainCallback2(sub_8122F90); +} + +static void sub_8123034(u8 taskId) +{ + if (!gPaletteFade.active) + { + u8 r4 = gSprites[gTasks[taskId].data[3] >> 8].data0; + + DestroyTask(taskId); + ewram1B000.unk262 = 1; + ShowPokemonSummaryScreen(gPlayerParty, r4, gPlayerPartyCount - 1, sub_8123004, 0); + } +} + +static void DaycareStorageMenuCallback_Summary(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8123034; +} + +static void DaycareStorageMenuCallback_Exit(u8 taskId) +{ + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(20, 10, 29, 19); + HandleDestroyMenuCursors(); + sub_806D538(15, 0); + gTasks[taskId].func = sub_8122E0C; +} + +void sub_8123138(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8123170; +} + +static void sub_8123170(u8 taskId) +{ + if (!gPaletteFade.active) + { + gFieldCallback = sub_81231AC; + SetMainCallback2(c2_exit_to_overworld_2_switch); + DestroyTask(taskId); + } +} + +// Do these last two functions really belong in here? + +static void sub_81231C4(u8); + +void sub_81231AC(void) +{ + pal_fill_black(); + CreateTask(sub_81231C4, 10); +} + +static void sub_81231C4(u8 taskId) +{ + if (sub_807D770() == TRUE) + { + DestroyTask(taskId); + ScriptContext2_Disable(); + EnableBothScriptContexts(); + } +} diff --git a/src/clear_save_data_menu.c b/src/clear_save_data_menu.c index 8865eeb57..498562fe0 100644 --- a/src/clear_save_data_menu.c +++ b/src/clear_save_data_menu.c @@ -1,17 +1,14 @@ #include "global.h" #include "clear_save_data_menu.h" -#include "save.h" -#include "task.h" -#include "songs.h" -#include "menu.h" #include "main.h" -#include "sprite.h" +#include "menu.h" #include "palette.h" +#include "save.h" +#include "songs.h" #include "sound.h" - -extern u8 gSystemText_ClearAllSaveDataPrompt[]; -extern u8 gSystemText_ClearingData[]; -extern const struct MenuAction gUnknown_08376D74[]; +#include "sprite.h" +#include "strings2.h" +#include "task.h" static void VBlankCB_ClearSaveDataScreen(void); static void Task_InitMenu(u8); @@ -41,14 +38,14 @@ static void Task_InitMenu(u8 taskId) { ResetSpriteData(); - REG_DISPCNT = DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; SetVBlankCallback(VBlankCB_ClearSaveDataScreen); MenuDrawTextWindow(2, 14, 27, 19); MenuPrint(gSystemText_ClearAllSaveDataPrompt, 3, 15); MenuDrawTextWindow(2, 1, 8, 6); - PrintMenuItems(3, 2, 2, gUnknown_08376D74); + PrintMenuItems(3, 2, 2, gMenuYesNoItems); InitMenu(0, 3, 2, 2, 1, 5); gTasks[taskId].func = Task_ProcessMenuInput; @@ -99,65 +96,65 @@ static u8 InitClearSaveDataScreen(void) switch (gMain.state) { - case 0: - default: - SetVBlankCallback(NULL); - - REG_DISPCNT = 0; - REG_BG0HOFS = 0; - REG_BG0VOFS = 0; - REG_BG3HOFS = 0; - REG_BG3VOFS = 0; - REG_WIN0H = 0; - REG_WIN0V = 0; - REG_WININ = 0; - REG_WINOUT = 0; - REG_BLDCNT = 0; - REG_BLDALPHA = 0; - REG_BLDY = 0; - - DmaFill16(3, 0, (void *)VRAM, VRAM_SIZE); - DmaFill32(3, 0, (void *)OAM, OAM_SIZE); - DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2); - - ResetPaletteFade(); - - gPlttBufferUnfaded[0] = 0x7fff; - gPlttBufferFaded[0] = 0x7fff; - gPlttBufferUnfaded[1] = 0x3945; - gPlttBufferFaded[1] = 0x3945; - - for (i = 0; i < 0x10; i++) - ((u16 *)(VRAM + 0x20))[i] = 0x1111; - - for (i = 0; i < 0x500; i++) - ((u16 *)(VRAM + 0x3800))[i] = 0x0001; - - ResetTasks(); - ResetSpriteData(); - - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); - BeginNormalPaletteFade(-1, 0, 0x10, 0, 0xffff); - - ime = REG_IME; - REG_IME = 0; - REG_IE |= INTR_FLAG_VBLANK; - REG_IME = ime; - REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; - - SetVBlankCallback(VBlankCB_InitClearSaveDataScreen); - - REG_BG3CNT = 0x0703; - REG_DISPCNT = 0x0900; - gMain.state = 1; + case 0: + default: + SetVBlankCallback(NULL); + + REG_DISPCNT = 0; + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; + REG_WIN0H = 0; + REG_WIN0V = 0; + REG_WININ = 0; + REG_WINOUT = 0; + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + REG_BLDY = 0; + + DmaFill16(3, 0, (void *)VRAM, VRAM_SIZE); + DmaFill32(3, 0, (void *)OAM, OAM_SIZE); + DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2); + + ResetPaletteFade(); + + gPlttBufferUnfaded[0] = 0x7fff; + gPlttBufferFaded[0] = 0x7fff; + gPlttBufferUnfaded[1] = 0x3945; + gPlttBufferFaded[1] = 0x3945; + + for (i = 0; i < 0x10; i++) + ((u16 *)(VRAM + 0x20))[i] = 0x1111; + + for (i = 0; i < 0x500; i++) + ((u16 *)(VRAM + 0x3800))[i] = 0x0001; + + ResetTasks(); + ResetSpriteData(); + + SetUpWindowConfig(&gWindowConfig_81E6C3C); + InitMenuWindow(&gWindowConfig_81E6CE4); + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0xffff); + + ime = REG_IME; + REG_IME = 0; + REG_IE |= INTR_FLAG_VBLANK; + REG_IME = ime; + REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; + + SetVBlankCallback(VBlankCB_InitClearSaveDataScreen); + + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_BG0_ON | DISPCNT_BG3_ON; + gMain.state = 1; + return 0; + case 1: + UpdatePaletteFade(); + if (gPaletteFade.active) return 0; - case 1: - UpdatePaletteFade(); - if (gPaletteFade.active) - return 0; - SetMainCallback2(CB2_ClearSaveDataScreen); - return 1; + SetMainCallback2(CB2_ClearSaveDataScreen); + return 1; } } @@ -165,16 +162,16 @@ static void CB2_SoftReset(void) { switch (gMain.state) { - case 0: - default: - BeginNormalPaletteFade(-1, 0, 0, 0x10, 0xffff); - gMain.state = 1; - break; - case 1: - UpdatePaletteFade(); - if (gPaletteFade.active) - return; - DoSoftReset(); - break; + case 0: + default: + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0xffff); + gMain.state = 1; + break; + case 1: + UpdatePaletteFade(); + if (gPaletteFade.active) + return; + DoSoftReset(); + break; } } diff --git a/src/clock.c b/src/clock.c new file mode 100644 index 000000000..1f2aac9fd --- /dev/null +++ b/src/clock.c @@ -0,0 +1,90 @@ +#include "global.h" +#include "clock.h" +#include "berry.h" +#include "dewford_trend.h" +#include "event_data.h" +#include "field_specials.h" +#include "field_weather.h" +#include "lottery_corner.h" +#include "main.h" +#include "rom4.h" +#include "rtc.h" +#include "time_events.h" +#include "tv.h" +#include "wallclock.h" + +static void InitTimeBasedEvents(void); +static void UpdatePerDay(struct Time *time); +static void UpdatePerMinute(struct Time *time); +static void ReturnFromStartWallClock(void); + +static void InitTimeBasedEvents(void) +{ + FlagSet(SYS_CLOCK_SET); + RtcCalcLocalTime(); + gSaveBlock2.lastBerryTreeUpdate = gLocalTime; + VarSet(VAR_DAYS, gLocalTime.days); +} + +void DoTimeBasedEvents(void) +{ + if (FlagGet(SYS_CLOCK_SET)) + { + RtcCalcLocalTime(); + UpdatePerDay(&gLocalTime); + UpdatePerMinute(&gLocalTime); + } +} + +static void UpdatePerDay(struct Time *time) +{ + u16 *varPtr = GetVarPointer(VAR_DAYS); + int days = *varPtr; + u16 newDays; + + if (days != time->days && days <= time->days) + { + newDays = time->days - days; + ClearUpperFlags(); + UpdateDewfordTrendPerDay(newDays); + UpdateTVShowsPerDay(newDays); + UpdateWeatherPerDay(newDays); + UpdatePartyPokerusTime(newDays); + UpdateMirageRnd(newDays); + UpdateBirchState(newDays); + SetShoalItemFlag(newDays); + SetRandomLotteryNumber(newDays); + *varPtr = time->days; + } +} + +static void UpdatePerMinute(struct Time *time) +{ + struct Time newTime; + s32 minutes; + + CalcTimeDifference(&newTime, &gSaveBlock2.lastBerryTreeUpdate, time); + minutes = 1440 * newTime.days + 60 * newTime.hours + newTime.minutes; + + // there's no way to get the correct assembly other than with this nested if check. so dumb. + if (minutes != 0) + { + if (minutes >= 0) + { + BerryTreeTimeUpdate(minutes); + gSaveBlock2.lastBerryTreeUpdate = *time; + } + } +} + +static void ReturnFromStartWallClock(void) +{ + InitTimeBasedEvents(); + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); +} + +void StartWallClock(void) +{ + SetMainCallback2(CB2_StartWallClock); + gMain.savedCallback = ReturnFromStartWallClock; +} diff --git a/src/coins.c b/src/coins.c index 87d96f2bb..3c6356612 100644 --- a/src/coins.c +++ b/src/coins.c @@ -2,12 +2,10 @@ #include "coins.h" #include "menu.h" #include "string_util.h" +#include "strings.h" #define MAX_COINS 9999 -extern u8 gOtherText_Coins2[]; - - void UpdateCoinsWindow(s32 a, u8 b, u8 c) { PrintCoins(a, 4, b + 2, c + 1); @@ -30,13 +28,13 @@ void PrintCoins(s32 a, u8 b, u8 c, u8 d) u8 *ptr; u8 r1; u8 foo; - + ConvertIntToDecimalString(string, a); r1 = (b * 6 + 0x21 - 8 * (b + 2)); c = c - r1 / 8; foo = r1 % 8; ptr = gStringVar1; - if(foo) + if (foo) { ptr[0] = 0xFC; ptr[1] = 0x11; @@ -59,16 +57,16 @@ u16 GetCoins(void) bool8 GiveCoins(u16 coins) { u32 newCoins; - - if(GetCoins() >= MAX_COINS) + + if (GetCoins() >= MAX_COINS) return FALSE; newCoins = coins + gSaveBlock1.coins; - if(gSaveBlock1.coins > (u16)newCoins) + if (gSaveBlock1.coins > (u16)newCoins) gSaveBlock1.coins = MAX_COINS; else { gSaveBlock1.coins = newCoins; - if((u16)newCoins > MAX_COINS) + if ((u16)newCoins > MAX_COINS) gSaveBlock1.coins = MAX_COINS; } return TRUE; @@ -76,7 +74,7 @@ bool8 GiveCoins(u16 coins) bool8 TakeCoins(u16 coins) { - if(GetCoins() >= coins) + if (GetCoins() >= coins) { gSaveBlock1.coins -= coins; return TRUE; diff --git a/src/contest_link_80C857C.c b/src/contest_link_80C857C.c new file mode 100644 index 000000000..0ae98af09 --- /dev/null +++ b/src/contest_link_80C857C.c @@ -0,0 +1,55 @@ +#include "global.h" +#include "link.h" + +#if GERMAN + +void de_sub_80C9274(bool32 arg0) { + if (deUnkValue2 != 1) + { + return; + } + + if (arg0) + { + deUnkValue2 = 3; + } + else + { + deUnkValue2 = 2; + } +} + +void de_sub_80C9294(bool32 arg0) { + if (deUnkValue2 == 1) + { + if (arg0) + { + deUnkValue2 = 3; + } + else + { + deUnkValue2 = 2; + } + + return; + } + + + if (deUnkValue2 == 2) + { + SendBlock(0, sBlockRequestLookupTable[deUnkValue1].address, sBlockRequestLookupTable[deUnkValue1].size); + + if (arg0) + { + deUnkValue2 = 0; + } + else + { + deUnkValue2 = 1; + } + + return; + } +} + +#endif diff --git a/src/contest_painting.c b/src/contest_painting.c new file mode 100644 index 000000000..d75947e05 --- /dev/null +++ b/src/contest_painting.c @@ -0,0 +1,803 @@ +#include "global.h" +#include "contest_painting.h" +#include "cute_sketch.h" +#include "data2.h" +#include "decompress.h" +#include "main.h" +#include "menu.h" +#include "palette.h" +#include "rng.h" +#include "sprite.h" +#include "string_util.h" +#include "strings.h" +#include "text.h" +#include "unknown_task.h" + +extern u8 unk_2000000[]; +extern u8 gUnknown_03000750; +extern u16 gUnknown_03000752; +extern u16 gUnknown_03000754; +extern u16 (*gUnknown_03005E10)[][32]; +extern u8 gUnknown_03005E40[]; +extern u16 (*gUnknown_03005E90)[]; + +extern struct ContestEntry unk_2015de0; +extern struct Unk2015E00 unk_2015e00; +extern struct Unk3000756 gUnknown_03000756; +extern struct Unk03005E20 gUnknown_03005E20; +extern struct ContestEntry *gUnknown_03005E8C; + +static const u16 gPictureFramePalettes[][16] = +{ + INCBIN_U16("graphics/picture_frame/bg0.gbapal"), + INCBIN_U16("graphics/picture_frame/bg1.gbapal"), + INCBIN_U16("graphics/picture_frame/bg2.gbapal"), + INCBIN_U16("graphics/picture_frame/bg3.gbapal"), + INCBIN_U16("graphics/picture_frame/bg4.gbapal"), + INCBIN_U16("graphics/picture_frame/bg5.gbapal"), + {0}, + {0}, +}; +const u8 emptySpace[8 * 32] = {0}; +const u8 gPictureFrameTiles_0[] = INCBIN_U8("graphics/picture_frame/frame0.4bpp.rl"); +const u8 gPictureFrameTiles_1[] = INCBIN_U8("graphics/picture_frame/frame1.4bpp.rl"); +const u8 gPictureFrameTiles_2[] = INCBIN_U8("graphics/picture_frame/frame2.4bpp.rl"); +const u8 gPictureFrameTiles_3[] = INCBIN_U8("graphics/picture_frame/frame3.4bpp.rl"); +const u8 gPictureFrameTiles_4[] = INCBIN_U8("graphics/picture_frame/frame4.4bpp.rl"); +const u8 gPictureFrameTiles_5[] = INCBIN_U8("graphics/picture_frame/frame5.4bpp.rl"); +const u8 gPictureFrameTilemap_0[] = INCBIN_U8("graphics/picture_frame/frame0_map.bin.rl"); +const u8 gPictureFrameTilemap_1[] = INCBIN_U8("graphics/picture_frame/frame1_map.bin.rl"); +const u8 gPictureFrameTilemap_2[] = INCBIN_U8("graphics/picture_frame/frame2_map.bin.rl"); +const u8 gPictureFrameTilemap_3[] = INCBIN_U8("graphics/picture_frame/frame3_map.bin.rl"); +const u8 gPictureFrameTilemap_4[] = INCBIN_U8("graphics/picture_frame/frame4_map.bin.rl"); +const u8 gPictureFrameTilemap_5[] = INCBIN_U8("graphics/picture_frame/frame5_map.bin.rl"); +const u8 *const gUnknown_083F60AC[] = +{ + OtherText_Cool, + OtherText_Beauty2, + OtherText_Cute, + OtherText_Smart, + OtherText_Tough, +}; +const struct LabelPair gUnknown_083F60C0[] = +{ + {OtherText_NonstopSuperCool, OtherText_Terminator6}, + {OtherText_GoodLookingPoke, OtherText_Terminator7}, + {OtherText_MarvelousGreat, OtherText_Terminator8}, + {OtherText_CenturyLastVenus, OtherText_Terminator9}, + {OtherText_Terminator10, OtherText_DazzlingSmile}, + {OtherText_PokeCenterIdol, OtherText_Terminator11}, + {OtherText_LovelyAndSweet, OtherText_Terminator12}, + {OtherText_ThePretty, OtherText_WinningPortrait}, + {OtherText_GiveUsWink, OtherText_Terminator13}, + {OtherText_SmartnessMaestro, OtherText_Terminator15}, + {OtherText_ChosenPokeAmong, OtherText_Terminator15}, + {OtherText_TheExcellent, OtherText_ItsMomentOfElegance}, + {OtherText_PowerfullyMuscular, OtherText_Terminator16}, + {OtherText_StrongErEst, OtherText_Terminator17}, + {OtherText_MightyTough, OtherText_Exclamation}, +}; +const struct OamData gOamData_83F6138 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 1, + .bpp = 1, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +const u16 gUnknown_083F6140[] = {0, 0}; + +static void ShowContestPainting(); +static void CB2_HoldContestPainting(void); +static void HoldContestPainting(void); +static void ContestPaintingInitWindow(u8 arg0); +static void ContestPaintingPrintCaption(u8 arg0, u8 arg1); +static void ContestPaintingInitBG(void); +static void ContestPaintingInitVars(u8 arg0); +static void VBlankCB_ContestPainting(void); +void sub_8106B90(); //should be static +static void sub_8107090(u8 arg0, u8 arg1); + +__attribute__((naked)) +void sub_8106630(u32 arg0) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + ldr r2, _0810665C @ =0x02015de0\n\ + subs r4, r2, 0x2\n\ + subs r5, r2, 0x1\n\ + ldr r3, _08106660 @ =gSaveBlock1\n\ + subs r0, 0x1\n\ + lsls r1, r0, 5\n\ + adds r1, r3\n\ + ldr r3, _08106664 @ =0x00002dfc\n\ + adds r1, r3\n\ + ldm r1!, {r3,r6,r7}\n\ + stm r2!, {r3,r6,r7}\n\ + ldm r1!, {r3,r6,r7}\n\ + stm r2!, {r3,r6,r7}\n\ + ldm r1!, {r6,r7}\n\ + stm r2!, {r6,r7}\n\ + strb r0, [r4]\n\ + movs r0, 0\n\ + strb r0, [r5]\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_0810665C: .4byte 0x02015de0\n\ +_08106660: .4byte gSaveBlock1\n\ +_08106664: .4byte 0x00002dfc\n\ + .syntax divided\n"); +} + +void CB2_ContestPainting(void) +{ + ShowContestPainting(); +} + +static void ShowContestPainting(void) +{ + switch (gMain.state) + { + case 0: + remove_some_task(); + SetVBlankCallback(NULL); + gUnknown_03005E8C = &unk_2015de0; + ContestPaintingInitVars(TRUE); + ContestPaintingInitBG(); + gMain.state++; + break; + case 1: + { + u8 *addr; + size_t size; + + ResetPaletteFade(); + addr = (void *)VRAM; + size = 0x18000; + while (1) + { + DmaFill32(3, 0, addr, 0x1000); + addr += 0x1000; + size -= 0x1000; + if (size <= 0x1000) + { + DmaFill32(3, 0, addr, size); + break; + } + } + ResetSpriteData(); + gMain.state++; + break; + } + case 2: + SeedRng(gMain.vblankCounter1); + InitKeys(); + ContestPaintingInitWindow(unk_2000000[0x15DDF]); + gMain.state++; + break; + case 3: + sub_8107090(unk_2000000[0x15DDE], unk_2000000[0x15DDF]); + gMain.state++; + break; + case 4: + ContestPaintingPrintCaption(unk_2000000[0x15DDE], unk_2000000[0x15DDF]); + LoadPalette(gUnknown_083F6140, 0, 1 * 2); + DmaClear32(3, PLTT, 0x400); + BeginFastPaletteFade(2); + SetVBlankCallback(VBlankCB_ContestPainting); + gUnknown_03000750 = 0; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON; + SetMainCallback2(CB2_HoldContestPainting); + break; + } +} + +static void CB2_HoldContestPainting(void) +{ + HoldContestPainting(); + UpdatePaletteFade(); +} + +static void CB2_QuitContestPainting(void) +{ + SetMainCallback2(gMain.savedCallback); +} + +static void HoldContestPainting(void) +{ + switch (gUnknown_03000750) + { + case 0: + if (!gPaletteFade.active) + gUnknown_03000750 = 1; + if (gUnknown_03000756.var_0 != 0 && gUnknown_03000754 != 0) + gUnknown_03000754--; + break; + case 1: + if ((gMain.newKeys & 1) || (gMain.newKeys & 2)) + { + u8 two = 2; //needed to make the asm match + + gUnknown_03000750 = two; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + } + if (gUnknown_03000756.var_0 != 0) + gUnknown_03000754 = 0; + break; + case 2: + if (!gPaletteFade.active) + SetMainCallback2(CB2_QuitContestPainting); + if (gUnknown_03000756.var_0 != 0 && gUnknown_03000754 <= 0x1D) + gUnknown_03000754++; + break; + } +} + +static void ContestPaintingInitWindow(u8 arg0) +{ + InitMenuWindow(&gWindowConfig_81E7160); + SetUpWindowConfig(&gWindowConfig_81E7160); +} + +static void ContestPaintingPrintCaption(u8 contestType, u8 arg1) +{ + u8 xPos, yPos; + u8 *ptr; + u8 type; + + if (arg1 == TRUE) + return; + ptr = gUnknown_03005E40; + type = gUnknown_03005E8C->contestType; + if (contestType < 8) + { + ptr = StringCopy(ptr, gUnknown_083F60AC[type]); + ptr = StringCopy(ptr, gContestText_ContestWinner); +#if ENGLISH + ptr = StringCopy(ptr, gUnknown_03005E8C->trainer_name); +#elif GERMAN + ptr = StringCopy10(ptr, gUnknown_03005E8C->pokemon_name); +#endif + + // {LATIN} + ptr[0] = 0xFC; + ptr[1] = 0x16; + ptr += 2; + + ptr = StringCopy(ptr, gOtherText_Unknown1); +#if ENGLISH + ptr = StringCopy10(ptr, gUnknown_03005E8C->pokemon_name); +#elif GERMAN + ptr = StringCopy(ptr, gUnknown_03005E8C->trainer_name); +#endif + + xPos = 6; + yPos = 14; + } + else + { + ptr = StringCopy(ptr, gUnknown_083F60C0[type].prefix); + ptr = StringCopy10(ptr, gUnknown_03005E8C->pokemon_name); + ptr = StringCopy(ptr, gUnknown_083F60C0[type].suffix); + + xPos = 3; + yPos = 14; + } + MenuPrint_PixelCoords(gUnknown_03005E40, xPos * 8 + 1, yPos * 8, 1); +} + +static void ContestPaintingInitBG(void) +{ + REG_DISPCNT = 0; + REG_IE |= INTR_FLAG_VBLANK; + REG_BG0CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(12) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(10) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + REG_BLDY = 0; +} + +static void ContestPaintingInitVars(bool8 arg0) +{ + if (arg0 == FALSE) + { + gUnknown_03000756.var_0 = FALSE; + gUnknown_03000752 = 0; + gUnknown_03000754 = 0; + } + else + { + gUnknown_03000756.var_0 = TRUE; + gUnknown_03000752 = 15; + gUnknown_03000754 = 30; + } +} + +static void ContestPaintingMosaic(void) +{ + if (gUnknown_03000756.var_0 == FALSE) + { + REG_MOSAIC = 0; + return; + } + + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(10) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256; + gUnknown_03000752 = gUnknown_03000754 / 2; + + REG_MOSAIC = (gUnknown_03000752 << 12) | (gUnknown_03000752 << 8) | (gUnknown_03000752 << 4) | (gUnknown_03000752 << 0); +} + +static void VBlankCB_ContestPainting(void) +{ + ContestPaintingMosaic(); + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +#ifdef NONMATCHING +static void sub_8106AC4(u16 species, u8 arg1) +{ + void *pal; + + // Unsure what gUnknown_03005E8C->var0 is supposed to be. + pal = species_and_otid_get_pal(species, gUnknown_03005E8C->var4, gUnknown_03005E8C->var0); + LZDecompressVram(pal, gUnknown_03005E90); + + if (arg1 == 1) + { + HandleLoadSpecialPokePic( + &gMonFrontPicTable[species], + gMonFrontPicCoords[species].x, + gMonFrontPicCoords[species].y, + 0x2000000, + gUnknown_081FAF4C[1], + species, + (u32)gUnknown_03005E8C->var0 + ); + sub_8106B90(gUnknown_081FAF4C[1], gUnknown_03005E90, gUnknown_03005E10); + } + else + { + HandleLoadSpecialPokePic( + &gMonBackPicTable[species], + gMonBackPicCoords[species].x, + gMonBackPicCoords[species].y, + 0x2000000, + gUnknown_081FAF4C[0], + species, + (u32)gUnknown_03005E8C->var0 + ); + sub_8106B90(gUnknown_081FAF4C[0], gUnknown_03005E90, gUnknown_03005E10); + } +} +#else +__attribute__((naked)) +static void sub_8106AC4(u16 arg0, u8 arg2) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + sub sp, 0xC\n\ + adds r4, r1, 0\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + ldr r7, _08106B28 @ =gUnknown_03005E8C\n\ + ldr r0, [r7]\n\ + ldr r1, [r0, 0x4]\n\ + ldr r2, [r0]\n\ + adds r0, r6, 0\n\ + bl species_and_otid_get_pal\n\ + ldr r1, _08106B2C @ =gUnknown_03005E90\n\ + mov r8, r1\n\ + ldr r1, [r1]\n\ + bl LZDecompressVram\n\ + cmp r4, 0\n\ + bne _08106B40\n\ + lsls r0, r6, 3\n\ + ldr r1, _08106B30 @ =gMonFrontPicTable\n\ + adds r0, r1\n\ + ldr r1, _08106B34 @ =gMonFrontPicCoords\n\ + lsls r2, r6, 2\n\ + adds r2, r1\n\ + ldrb r1, [r2]\n\ + ldrb r2, [r2, 0x1]\n\ + movs r3, 0x80\n\ + lsls r3, 18\n\ + ldr r4, _08106B38 @ =gUnknown_081FAF4C\n\ + ldr r5, [r4, 0x4]\n\ + str r5, [sp]\n\ + str r6, [sp, 0x4]\n\ + ldr r4, [r7]\n\ + ldr r4, [r4]\n\ + str r4, [sp, 0x8]\n\ + bl HandleLoadSpecialPokePic\n\ + mov r2, r8\n\ + ldr r1, [r2]\n\ + ldr r0, _08106B3C @ =gUnknown_03005E10\n\ + ldr r2, [r0]\n\ + adds r0, r5, 0\n\ + bl sub_8106B90\n\ + b _08106B74\n\ + .align 2, 0\n\ +_08106B28: .4byte gUnknown_03005E8C\n\ +_08106B2C: .4byte gUnknown_03005E90\n\ +_08106B30: .4byte gMonFrontPicTable\n\ +_08106B34: .4byte gMonFrontPicCoords\n\ +_08106B38: .4byte gUnknown_081FAF4C\n\ +_08106B3C: .4byte gUnknown_03005E10\n\ +_08106B40:\n\ + lsls r0, r6, 3\n\ + ldr r1, _08106B80 @ =gMonBackPicTable\n\ + adds r0, r1\n\ + ldr r1, _08106B84 @ =gMonBackPicCoords\n\ + lsls r2, r6, 2\n\ + adds r2, r1\n\ + ldrb r1, [r2]\n\ + ldrb r2, [r2, 0x1]\n\ + movs r3, 0x80\n\ + lsls r3, 18\n\ + ldr r4, _08106B88 @ =gUnknown_081FAF4C\n\ + ldr r5, [r4]\n\ + str r5, [sp]\n\ + str r6, [sp, 0x4]\n\ + ldr r4, [r7]\n\ + ldr r4, [r4]\n\ + str r4, [sp, 0x8]\n\ + bl HandleLoadSpecialPokePic\n\ + mov r0, r8\n\ + ldr r1, [r0]\n\ + ldr r0, _08106B8C @ =gUnknown_03005E10\n\ + ldr r2, [r0]\n\ + adds r0, r5, 0\n\ + bl sub_8106B90\n\ +_08106B74:\n\ + add sp, 0xC\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_08106B80: .4byte gMonBackPicTable\n\ +_08106B84: .4byte gMonBackPicCoords\n\ +_08106B88: .4byte gUnknown_081FAF4C\n\ +_08106B8C: .4byte gUnknown_03005E10\n\ + .syntax divided\n"); +} +#endif + +#ifdef NONMATCHING +void sub_8106B90(u8 a[][8][8][4], u16 b[], u16 c[][8][8][8]) +{ + u16 i; + u16 j; + u16 k; + u16 l; + + for (i = 0; i < 8; i++) + { + for (j = 0; j < 8; j++) + { + for (k = 0; k < 8; k++) + { + for (l = 0; l < 8; l++) + { + //u8 *arr = a[i][j][k]; + //u8 r1 = arr[l / 2]; + u8 r1 = a[i][j][k][l / 2]; + + if (l & 1) + r1 /= 16; + else + r1 %= 16; + //_08106BEA + if (r1 == 0) + c[i][k][j][l] = 0x8000; + else + c[i][k][j][l] = b[r1]; + } + } + } + } +} +#else +__attribute__((naked)) +void sub_8106B90() +{ + 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, 0xC\n\ + mov r10, r0\n\ + mov r9, r1\n\ + str r2, [sp]\n\ + movs r0, 0\n\ +_08106BA4:\n\ + movs r3, 0\n\ + adds r1, r0, 0x1\n\ + str r1, [sp, 0x4]\n\ + lsls r0, 3\n\ + str r0, [sp, 0x8]\n\ +_08106BAE:\n\ + movs r1, 0\n\ + adds r2, r3, 0x1\n\ + mov r8, r2\n\ + ldr r7, [sp, 0x8]\n\ + adds r0, r7, r3\n\ + lsls r0, 5\n\ + mov r12, r0\n\ + lsls r4, r3, 3\n\ +_08106BBE:\n\ + movs r3, 0\n\ + lsls r0, r1, 2\n\ + adds r6, r1, 0x1\n\ + mov r2, r12\n\ + adds r5, r2, r0\n\ + ldr r7, [sp, 0x8]\n\ + adds r0, r7, r1\n\ + lsls r0, 7\n\ + ldr r1, [sp]\n\ + adds r2, r0, r1\n\ +_08106BD2:\n\ + lsrs r0, r3, 1\n\ + adds r0, r5, r0\n\ + add r0, r10\n\ + ldrb r1, [r0]\n\ + movs r0, 0x1\n\ + ands r0, r3\n\ + cmp r0, 0\n\ + beq _08106BE6\n\ + lsrs r1, 4\n\ + b _08106BEA\n\ +_08106BE6:\n\ + movs r0, 0xF\n\ + ands r1, r0\n\ +_08106BEA:\n\ + cmp r1, 0\n\ + bne _08106BFC\n\ + adds r0, r4, r3\n\ + lsls r0, 1\n\ + adds r0, r2\n\ + movs r7, 0x80\n\ + lsls r7, 8\n\ + adds r1, r7, 0\n\ + b _08106C08\n\ +_08106BFC:\n\ + adds r0, r4, r3\n\ + lsls r0, 1\n\ + adds r0, r2\n\ + lsls r1, 1\n\ + add r1, r9\n\ + ldrh r1, [r1]\n\ +_08106C08:\n\ + strh r1, [r0]\n\ + adds r0, r3, 0x1\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + cmp r3, 0x7\n\ + bls _08106BD2\n\ + lsls r0, r6, 16\n\ + lsrs r1, r0, 16\n\ + cmp r1, 0x7\n\ + bls _08106BBE\n\ + mov r1, r8\n\ + lsls r0, r1, 16\n\ + lsrs r3, r0, 16\n\ + cmp r3, 0x7\n\ + bls _08106BAE\n\ + ldr r2, [sp, 0x4]\n\ + lsls r0, r2, 16\n\ + lsrs r0, 16\n\ + cmp r0, 0x7\n\ + bls _08106BA4\n\ + add sp, 0xC\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\ + .syntax divided\n"); +} +#endif + +static void sub_8106C40(u8 arg0, u8 arg1) +{ + u8 x, y; + + LoadPalette(gPictureFramePalettes, 0, sizeof(gPictureFramePalettes)); + if (arg1 == 1) + { + switch (gUnknown_03005E8C->contestType / 3) + { + case CONTEST_COOL: + RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM); + RLUnCompWram(gPictureFrameTilemap_0, gUnknown_03005E10); + break; + case CONTEST_BEAUTY: + RLUnCompVram(gPictureFrameTiles_1, (void *)VRAM); + RLUnCompWram(gPictureFrameTilemap_1, gUnknown_03005E10); + break; + case CONTEST_CUTE: + RLUnCompVram(gPictureFrameTiles_2, (void *)VRAM); + RLUnCompWram(gPictureFrameTilemap_2, gUnknown_03005E10); + break; + case CONTEST_SMART: + RLUnCompVram(gPictureFrameTiles_3, (void *)VRAM); + RLUnCompWram(gPictureFrameTilemap_3, gUnknown_03005E10); + break; + case CONTEST_TOUGH: + RLUnCompVram(gPictureFrameTiles_4, (void *)VRAM); + RLUnCompWram(gPictureFrameTilemap_4, gUnknown_03005E10); + break; + } + +#define VRAM_PICTURE_DATA(x, y) (((u16 *)(VRAM + 0x6000))[(y) * 32 + (x)]) + + // Set the background + for (y = 0; y < 20; y++) + { + for (x = 0; x < 32; x++) + VRAM_PICTURE_DATA(x, y) = 0x1015; + } + + // Copy the image frame + for (y = 0; y < 10; y++) + { + for (x = 0; x < 18; x++) + VRAM_PICTURE_DATA(x + 6, y + 2) = (*gUnknown_03005E10)[y + 2][x + 6]; + } + + // Re-set the entire top row to the first top frame part + for (x = 0; x < 16; x++) + VRAM_PICTURE_DATA(x + 7, 2) = (*gUnknown_03005E10)[2][7]; + +#undef VRAM_PICTURE_DATA + } + else if (arg0 < 8) + { + RLUnCompVram(gPictureFrameTiles_5, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_5, (void *)(VRAM + 0x6000)); + } + else + { + switch (gUnknown_03005E8C->contestType / 3) + { + case CONTEST_COOL: + RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_0, (void *)(VRAM + 0x6000)); + break; + case CONTEST_BEAUTY: + RLUnCompVram(gPictureFrameTiles_1, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_1, (void *)(VRAM + 0x6000)); + break; + case CONTEST_CUTE: + RLUnCompVram(gPictureFrameTiles_2, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_2, (void *)(VRAM + 0x6000)); + break; + case CONTEST_SMART: + RLUnCompVram(gPictureFrameTiles_3, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_3, (void *)(VRAM + 0x6000)); + break; + case CONTEST_TOUGH: + RLUnCompVram(gPictureFrameTiles_4, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_4, (void *)(VRAM + 0x6000)); + break; + } + } +} + +static void sub_8106E98(u8 arg0) +{ + //Some hacks just to get the asm to match +#ifndef NONMATCHING + asm(""::"r"(arg0)); +#endif + + gMain.oamBuffer[0] = gOamData_83F6138; + gMain.oamBuffer[0].tileNum = 0; + +#ifndef NONMATCHING + if (arg0) arg0 = gMain.oamBuffer[0].tileNum; +#endif + + gMain.oamBuffer[0].x = 88; + gMain.oamBuffer[0].y = 24; +} + +static u8 sub_8106EE0(u8 arg0) +{ + u8 contestType; + + if (arg0 < 8) + contestType = gUnknown_03005E8C->contestType; + else + contestType = gUnknown_03005E8C->contestType / 3; + + switch (contestType) + { + case CONTEST_COOL: + return CONTESTRESULT_COOL; + case CONTEST_BEAUTY: + return CONTESTRESULT_BEAUTY; + case CONTEST_CUTE: + return CONTESTRESULT_CUTE; + case CONTEST_SMART: + return CONTESTRESULT_SMART; + case CONTEST_TOUGH: + return CONTESTRESULT_TOUGH; + } + + return contestType; +} + +static void sub_8106F4C(void) +{ + gUnknown_03005E90 = &unk_2015e00.unk2017e00; + gUnknown_03005E10 = &unk_2015e00.unk2015e00; +} + +static void sub_8106F6C(u8 arg0) +{ + gUnknown_03005E20.var_4 = gUnknown_03005E10; + gUnknown_03005E20.var_8 = gUnknown_03005E90; + gUnknown_03005E20.var_18 = 0; + gUnknown_03005E20.var_1F = gUnknown_03005E8C->var0; + gUnknown_03005E20.var_19 = 0; + gUnknown_03005E20.var_1A = 0; + gUnknown_03005E20.var_1B = 64; + gUnknown_03005E20.var_1C = 64; + gUnknown_03005E20.var_1D = 64; + gUnknown_03005E20.var_1E = 64; + + switch (arg0) + { + case CONTESTRESULT_SMART: + case CONTESTRESULT_TOUGH: + gUnknown_03005E20.var_14 = 3; + break; + case CONTESTRESULT_COOL: + case CONTESTRESULT_BEAUTY: + case CONTESTRESULT_CUTE: + default: + gUnknown_03005E20.var_14 = 1; + break; + } + + gUnknown_03005E20.var_16 = 2; + gUnknown_03005E20.var_0 = arg0; + gUnknown_03005E20.var_10 = 0x6010000; + + sub_80FC7A0(&gUnknown_03005E20); + sub_80FDA18(&gUnknown_03005E20); + sub_80FD8CC(&gUnknown_03005E20); + + LoadPalette(gUnknown_03005E90, 256, 256 * 2); +} + +static void sub_8107090(u8 arg0, u8 arg1) +{ + sub_8106F4C(); + sub_8106AC4(gUnknown_03005E8C->var8, 0); + sub_8106F6C(sub_8106EE0(arg0)); + sub_8106E98(arg0); + sub_8106C40(arg0, arg1); +} diff --git a/src/coord_event_weather.c b/src/coord_event_weather.c new file mode 100644 index 000000000..9c5a1ca4d --- /dev/null +++ b/src/coord_event_weather.c @@ -0,0 +1,118 @@ +#include "global.h" +#include "coord_event_weather.h" +#include "field_weather.h" + +struct CoordEventWeather +{ + u8 weather; + void (*func)(void); +}; + +static void CoordEventWeather_Indoor(void); +static void CoordEventWeather_Sunny(void); +static void CoordEventWeather_Rain(void); +static void CoordEventWeather_Snowflakes(void); +static void CoordEventWeather_Thunderstorm(void); +static void CoordEventWeather_Fog(void); +static void CoordEventWeather_DiagonalFog(void); +static void CoordEventWeather_Snow(void); +static void CoordEventWeather_Sandstorm(void); +static void CoordEventWeather_Cloudy(void); +static void CoordEventWeather_Drought(void); +static void CoordEventWeather_UnderwaterFog(void); +static void CoordEventWeather_UnderwaterBubbles(void); + +static const struct CoordEventWeather sCoordEventWeatherFuncs[] = +{ + { 0x1, CoordEventWeather_Indoor }, + { 0x2, CoordEventWeather_Sunny }, + { 0x3, CoordEventWeather_Rain }, + { 0x4, CoordEventWeather_Snowflakes }, + { 0x5, CoordEventWeather_Thunderstorm }, + { 0x6, CoordEventWeather_Fog }, + { 0x7, CoordEventWeather_DiagonalFog }, + { 0x8, CoordEventWeather_Snow }, + { 0x9, CoordEventWeather_Sandstorm }, + { 0xa, CoordEventWeather_Cloudy }, + { 0xb, CoordEventWeather_Drought }, + { 0x14, CoordEventWeather_UnderwaterFog }, + { 0x15, CoordEventWeather_UnderwaterBubbles }, +}; + +static void CoordEventWeather_Indoor(void) +{ + SetWeather(1); +} + +static void CoordEventWeather_Sunny(void) +{ + SetWeather(2); +} + +static void CoordEventWeather_Rain(void) +{ + SetWeather(3); +} + +static void CoordEventWeather_Snowflakes(void) +{ + SetWeather(4); +} + +static void CoordEventWeather_Thunderstorm(void) +{ + SetWeather(5); +} + +static void CoordEventWeather_Fog(void) +{ + SetWeather(6); +} + +static void CoordEventWeather_DiagonalFog(void) +{ + SetWeather(9); +} + +static void CoordEventWeather_Snow(void) +{ + SetWeather(7); +} + +static void CoordEventWeather_Sandstorm(void) +{ + SetWeather(8); +} + +static void CoordEventWeather_Cloudy(void) +{ + SetWeather(11); +} + +static void CoordEventWeather_Drought(void) +{ + SetWeather(12); +} + +static void CoordEventWeather_UnderwaterFog(void) +{ + SetWeather(20); +} + +static void CoordEventWeather_UnderwaterBubbles(void) +{ + SetWeather(21); +} + +void DoCoordEventWeather(u8 n) +{ + u8 i; + for (i = 0; i < ARRAY_COUNT(sCoordEventWeatherFuncs); i++) + { + if (sCoordEventWeatherFuncs[i].weather == n) + { + sCoordEventWeatherFuncs[i].func(); + return; + } + } +} diff --git a/src/credits.c b/src/credits.c new file mode 100644 index 000000000..8ec126a41 --- /dev/null +++ b/src/credits.c @@ -0,0 +1,1640 @@ +#include "global.h" +#include "data2.h" +#include "decompress.h" +#include "event_data.h" +#include "hall_of_fame.h" +#include "intro_credits_graphics.h" +#include "m4a.h" +#include "main.h" +#include "menu.h" +#include "palette.h" +#include "pokedex.h" +#include "rng.h" +#include "songs.h" +#include "sound.h" +#include "species.h" +#include "starter_choose.h" +#include "task.h" +#include "trig.h" + +asm(".set REG_BASE, 0x4000000"); +asm(".set OFFSET_REG_BLDCNT, 0x50"); +asm(".set OFFSET_REG_BLDALPHA, 0x52"); +asm(".set REG_BLDCNT, REG_BASE + OFFSET_REG_BLDCNT"); +asm(".set REG_BLDALPHA, REG_BASE + OFFSET_REG_BLDALPHA"); + +enum +{ + PAGE_TITLE, + PAGE_DIRECTOR, + PAGE_ART_DIRECTOR, + PAGE_BATTLE_DIRECTOR, + PAGE_MAIN_PROGRAMMER, + PAGE_BATTLE_SYSTEM_PROGRAMMER, + PAGE_PROGRAMMERS_1, + PAGE_PROGRAMMERS_2, + PAGE_PROGRAMMERS_3, + PAGE_MAIN_GRAHPICS_DESIGNER, + PAGE_POKEMON_GRAHPIC_DESIGNERS_1, + PAGE_POKEMON_GRAHPIC_DESIGNERS_2, + PAGE_POKEMON_GRAHPIC_DESIGNERS_3, + PAGE_POKEMON_DESIGNERS_1, + PAGE_POKEMON_DESIGNERS_2, + PAGE_MUSIC_COMPOSITION, + PAGE_SOUND_EFFECTS, + PAGE_GAME_DESIGNERS_1, + PAGE_GAME_DESIGNERS_2, + PAGE_GAME_DESIGNERS_3, + PAGE_PLOT_SCENARIO, + PAGE_GAME_SCENARIO, + PAGE_SCRIPT_DESIGNERS, + PAGE_MAP_DESIGNERS, + PAGE_MAP_DATA_DESIGNERS, + PAGE_PARAMETRIC_DESIGNERS, + PAGE_POKEDEX_TEXT, + PAGE_ENVIRONMENT_TOOLS, + PAGE_PRODUCT_TESTING, + PAGE_SPECIAL_THANKS, + PAGE_SPECIAL_THANKS_1, + PAGE_SPECIAL_THANKS_2, + PAGE_SPECIAL_THANKS_3, + PAGE_INFORMATION_SUPERVISORS, + PAGE_COORDINATORS, + PAGE_TASK_MANAGERS, + PAGE_PRODUCERS, + PAGE_EXECUTIVE_DIRECTOR, + PAGE_EXECUTIVE_PRODUCERS_1, + PAGE_EXECUTIVE_PRODUCERS_2, + PAGE_TRANSLATION_COORDINATOR, + PAGE_TRANSLATORS, + PAGE_PROGRAMMERS, + PAGE_GRAPHIC_DESIGNERS, + PAGE_PRODUCT_SUPPORT, + +#if ENGLISH + PAGE_ARTWORK, + PAGE_TEXT_EDITOR, + PAGE_NOA_TESTING, + PAGE_BRAILLE_CODE_CHECK_1, + PAGE_BRAILLE_CODE_CHECK_2, +#elif GERMAN + PAGE_NOE_TESTING, + PAGE_BRAILLE_CODE_CHECK_1, +#endif + + PAGE_SPECIAL_THANKS_4, + PAGE_SPECIAL_THANKS_5, + + PAGE_COUNT +}; + +#if ENGLISH +#define POKEMON_TILE_COUNT 68 +#define LAST_PAGE (PAGE_TEXT_EDITOR) +#define UNK_DEFINE_45 (0x45) +#define UNK_DEFINE_82 (0x82) +#define UNK_DEF_1F3 (499) +#elif GERMAN +#define POKEMON_TILE_COUNT 65 +#define LAST_PAGE (PAGE_NOE_TESTING) +#define UNK_DEFINE_45 (8) +#define UNK_DEFINE_82 (0x8D) +#define UNK_DEF_1F3 (554) +#endif + +#define COLOR_DARK_GREEN 0x1967 +#define COLOR_LIGHT_GREEN 0x328D + +enum +{ + TDA_0 = 0, + TDA_TASK_C_ID = 1, + TDA_TASK_E_ID = 2, + TDA_TASK_D_ID = 3, + TDA_4 = 4, + TDA_PLAYER_CYCLIST = 5, + TDA_RIVAL_CYCLIST = 6, + TDA_7 = 7, // Has something to do with the bike scene + TDA_11 = 11, // Gets set depending on whether the bike or the grass scene should be shown + TDA_12 = 12, + TDA_13 = 13, + TDA_14 = 14, + TDA_TASK_B_ID = 15, + + // Appears to be responsible for text + TDB_0 = 0, + TDB_TASK_A_ID = 1, + TDB_CURRENT_PAGE = 2, + TDB_3 = 3, + + TDC_0 = 0, + TDC_1 = 1, + TDC_2 = 2, + TDC_3 = 3, + TDC_4 = 4, + TDC_5 = 5, + + TDD_STATE = 0, + TDD_TASK_A_ID = 1, + TDD_2 = 2, + TDD_3 = 3, + + TDE_0 = 0, + TDE_1 = 1, + TDE_TASK_A_ID = 2, +}; + + +struct Unk201C000 +{ + u16 unk0[POKEMON_TILE_COUNT]; + u16 unk88; + u16 unk8A; + u16 unk8C; + u16 unk8E; + u16 unk90[386]; + u16 unk394; +}; + +struct CreditsEntry +{ + u8 var_0; + u8 *text; +}; + +extern u8 ewram[]; + +#define EWRAM_1F800 ((u16 *)(ewram + 0x1F800)) +#define HALL_OF_FAME_SHEET_0 ((u8 *)(ewram + 0x1E000)) +#define HALL_OF_FAME_SHEET_1 ((u8 *)(ewram + 0x1E800)) +#define HALL_OF_FAME_SHEET_2 ((u8 *)(ewram + 0x1F000)) +#define ewram1c000 (*(struct Unk201C000 *)(ewram + 0x1C000)) + +extern struct HallOfFame gHallOfFame; +extern u8 unk_201e800[0x800]; +extern u8 unk_201f000[0x800]; +extern u16 unk_201f800[]; + +extern struct SpriteTemplate gUnknown_02024E8C; + +extern s16 gUnknown_02039320; +extern u16 gUnknown_02039322; // TASK A +extern u8 gUnknown_02039324; +extern u8 gUnknown_02039325; +extern u16 gUnknown_02039358; +extern s16 gUnknown_0203935A; +extern s16 gUnknown_0203935C; + +extern u8 gReservedSpritePaletteCount; + +// data/hall_of_fame +extern void *gUnknown_0840B5A0[]; + +// data/credits +const u16 gUnknown_0840B7BC[] = INCBIN_U16("graphics/credits/palette_1.gbapal"); +const u8 gUnknown_0840B7FC[] = INCBIN_U8("graphics/credits/ampersand.4bpp"); +extern u8 gUnknown_0840B83C[]; +extern u8 gUnknown_0840B84B[]; +extern u8 gUnknown_0840B85A[]; +extern u8 gUnknown_0840B869[]; +extern u8 gUnknown_0840B878[]; +extern struct CreditsEntry *gCreditsEntryPointerTable[][5]; +extern u8 gUnknown_0840CA00[][2]; +extern struct SpriteSheet gUnknown_0840CAA0; +extern struct SpritePalette gUnknown_0840CAB0; +extern const union AnimCmd *const gSpriteAnimTable_0840CA54[]; +extern const union AnimCmd *const gSpriteAnimTable_0840CA94[]; +extern struct SpriteTemplate gSpriteTemplate_840CAEC; + +// graphics +extern u8 gCreditsCopyrightEnd_Gfx[]; +extern u16 gIntroCopyright_Pal[16]; + +static void task_a_8143B38(u8 taskIdA); +static void task_a_8143B68(u8 taskIdA); +static void task_a_8143BFC(u8 taskIdA); +static void task_a_80C9BFC(u8 taskIdA); +static void task_a_8143CC0(u8 taskIdA); +static void task_a_8143D04(u8 taskIdA); +static void task_a_8143EBC(u8 taskIdA); +static void task_a_8143F04(u8 taskIdA); +static void task_a_8143F3C(u8 taskIdA); +static void task_a_8143FDC(u8 taskIdA); +static void task_a_8144024(u8 taskIdA); +static void task_a_8144080(u8 taskIdA); +static void task_a_8144114(u8 taskIdA); +static void sub_8144130(void); +static void task_b_81441B8(u8 taskIdB); +static u8 sub_8144454(u8 page, u8 taskIdA); +static void task_d_8144514(u8 taskIdD); +static bool8 sub_8144ECC(u8 data, u8 taskIdA); +static void sub_81450AC(u8 taskIdA); +static void sub_8145128(u16, u16, u16); +static void sub_81452D0(u16 arg0, u16 palette); +static void spritecb_player_8145378(struct Sprite *sprite); +static void spritecb_rival_8145420(struct Sprite *sprite); +static u8 sub_81456B4(u16 species, u16 x, u16 y, u16 position); +static void sub_81458DC(void); + +static void vblank_8143948(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +static void sub_814395C(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); + + if (!(gMain.heldKeys & B_BUTTON)) + { + return; + } + + if (!gUnknown_02039324) + { + return; + } + + if (gTasks[gUnknown_02039322].func != task_a_8143B68) + { + return; + } + + vblank_8143948(); + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); + gUnknown_02039325 = 1; +} + +void sub_81439D0(void) +{ + u8 taskIdA; + s16 taskIdC; + u8 taskIdB; + u16 savedIme; + struct Unk201C000 *c000; + + sub_8144130(); + SetVBlankCallback(NULL); + ResetPaletteFade(); + ResetTasks(); + + taskIdA = CreateTask(task_a_8143B38, 0); + + gTasks[taskIdA].data[TDA_4] = 0; + gTasks[taskIdA].data[TDA_7] = 0; + gTasks[taskIdA].data[TDA_11] = 0; + gTasks[taskIdA].data[TDA_13] = 1; + + while (TRUE) + { + if (sub_8144ECC(0, taskIdA)) + { + break; + } + } + + taskIdC = gTasks[taskIdA].data[TDA_TASK_C_ID]; + gTasks[taskIdC].data[TDC_0] = 40; + + SetUpWindowConfig(&gWindowConfig_81E7208); + InitMenuWindow(&gWindowConfig_81E7208); + LoadPalette(&gUnknown_0840B7BC, 0x80, sizeof(gUnknown_0840B7BC)); + + CpuCopy16(&gUnknown_0840B7FC, (void *)(VRAM + 0xBEE0), sizeof(gUnknown_0840B7FC)); + + REG_BG0VOFS = 0xFFFC; + + taskIdB = CreateTask(task_b_81441B8, 0); + + gTasks[taskIdB].data[TDB_TASK_A_ID] = taskIdA; + gTasks[taskIdA].data[TDA_TASK_B_ID] = taskIdB; + + BeginNormalPaletteFade(-1, 0, 16, 0, 0); + + savedIme = REG_IME; + REG_IME = 0; + REG_IE |= INTR_FLAG_VBLANK; + REG_IME = savedIme; + REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; + + + SetVBlankCallback(vblank_8143948); + m4aSongNumStart(BGM_THANKFOR); + SetMainCallback2(sub_814395C); + gUnknown_02039325 = 0; + + c000 = &ewram1c000; + + sub_81458DC(); + + c000->unk88 = 0; + c000->unk8A = 0; + c000->unk8C = 0; + + gUnknown_02039322 = taskIdA; +} + +static void task_a_8143B38(u8 taskIdA) +{ + if (gPaletteFade.active) + { + return; + } + + gTasks[taskIdA].func = task_a_8143B68; +} + +static void task_a_8143B68(u8 taskIdA) +{ + u16 data11; + + if (gTasks[taskIdA].data[TDA_4]) + { + s16 taskIdC; + + taskIdC = gTasks[taskIdA].data[TDA_TASK_C_ID]; + gTasks[taskIdC].data[TDC_0] = 30; + + gTasks[taskIdA].data[TDA_12] = 0x100; + gTasks[taskIdA].func = task_a_8143EBC; + return; + } + + gUnknown_02039320 = 0; + data11 = gTasks[taskIdA].data[TDA_11]; + + if (gTasks[taskIdA].data[TDA_11] == 1) + { + gTasks[taskIdA].data[TDA_13] = data11; + gTasks[taskIdA].data[TDA_11] = 0; + BeginNormalPaletteFade(-1, 0, 0, 16, 0); + gTasks[taskIdA].func = task_a_8143BFC; + } + else if (gTasks[taskIdA].data[TDA_11] == 2) + { + gTasks[taskIdA].data[TDA_13] = data11; + gTasks[taskIdA].data[TDA_11] = 0; + BeginNormalPaletteFade(-1, 0, 0, 16, 0); + gTasks[taskIdA].func = task_a_8143CC0; + } +} + +static void task_a_8143BFC(u8 taskIdA) +{ + if (gPaletteFade.active) + { + return; + } + + REG_DISPCNT = 0; + sub_81450AC(taskIdA); + gTasks[taskIdA].func = task_a_80C9BFC; +} + +static void task_a_80C9BFC(u8 taskIdA) +{ + u16 backup; + + SetVBlankCallback(NULL); + + if (!sub_8144ECC(gTasks[taskIdA].data[TDA_7], taskIdA)) + { + return; + } + + BeginNormalPaletteFade(-1, 0, 16, 0, 0); + + backup = REG_IME; + REG_IME = 0; + REG_IE |= INTR_FLAG_VBLANK; + REG_IME = backup; + REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; + + SetVBlankCallback(vblank_8143948); + gTasks[taskIdA].func = task_a_8143B38; +} + +static void task_a_8143CC0(u8 taskIdA) +{ + if (gPaletteFade.active) + { + return; + } + + REG_DISPCNT = 0; + sub_81450AC(taskIdA); + gTasks[taskIdA].func = task_a_8143D04; +} + +void task_a_8143D04(u8 taskIdA) +{ + switch (gMain.state) + { + default: + case 0: + { + u16 i; + + ResetSpriteData(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 8; + LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM); + LZ77UnCompVram(&gBirchGrassTilemap, (void *)(VRAM + 0x3800)); + LoadPalette(gBirchBagGrassPal[0] + 1, 1, 31 * 2); + + for (i = 0; i < 0x800; i++) + HALL_OF_FAME_SHEET_0[i] = 0x11; + for (i = 0; i < 0x800; i++) + HALL_OF_FAME_SHEET_1[i] = 0x22; + for (i = 0; i < 0x800; i++) + HALL_OF_FAME_SHEET_2[i] = 0x33; + + EWRAM_1F800[0] = 0; + EWRAM_1F800[1] = 0x53FF; // light yellow + EWRAM_1F800[2] = 0x529F; // light red + EWRAM_1F800[3] = 0x7E94; // light blue + + LoadSpriteSheet(&gUnknown_0840CAA0); + LoadSpritePalette(&gUnknown_0840CAB0); + + gMain.state += 1; + break; + } + case 1: + gTasks[taskIdA].data[TDA_TASK_D_ID] = CreateTask(task_d_8144514, 0); + gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_STATE] = 1; + gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_TASK_A_ID] = taskIdA; + gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_2] = gTasks[taskIdA].data[TDA_7]; + + BeginNormalPaletteFade(-1, 0, 16, 0, 0); + REG_BG3HOFS = 0; + REG_BG3VOFS = 32; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; + + gMain.state = 0; + gUnknown_0203935C = 0; + gTasks[taskIdA].func = task_a_8143B38; + break; + } +} + +static void task_a_8143EBC(u8 taskIdA) +{ + if (gTasks[taskIdA].data[TDA_12]) + { + gTasks[taskIdA].data[TDA_12] -= 1; + return; + } + + BeginNormalPaletteFade(-1, 12, 0, 16, 0); + gTasks[taskIdA].func = task_a_8143F04; +} + +static void task_a_8143F04(u8 taskIdA) +{ + if (gPaletteFade.active) + { + return; + } + + sub_81450AC(taskIdA); + gTasks[taskIdA].func = task_a_8143F3C; +} + +static void task_a_8143F3C(u8 taskIdA) +{ + u16 backup; + + sub_8144130(); + ResetPaletteFade(); + sub_8145128(0, 0x3800, 0); + ResetSpriteData(); + FreeAllSpritePalettes(); + BeginNormalPaletteFade(-1, 8, 16, 0, 0); + + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + backup = REG_IME; + REG_IME = 0; + REG_IE |= INTR_FLAG_VBLANK; + REG_IME = backup; + REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON; + + gTasks[taskIdA].data[TDA_0] = 0x100; + gTasks[taskIdA].func = task_a_8143FDC; +} + +static void task_a_8143FDC(u8 taskIdA) +{ + if (gTasks[taskIdA].data[TDA_0]) + { + gTasks[taskIdA].data[TDA_0] -= 1; + return; + } + + BeginNormalPaletteFade(-1, 6, 0, 16, 0); + gTasks[taskIdA].func = task_a_8144024; +} + +static void task_a_8144024(u8 taskIdA) +{ + if (gPaletteFade.active) + { + return; + } + + sub_81452D0(0x3800, 0); + + BeginNormalPaletteFade(-1, 0, 0, 0, 0); + gTasks[taskIdA].data[TDA_0] = 7200; + gTasks[taskIdA].func = task_a_8144080; +} + +static void task_a_8144080(u8 taskIdA) +{ + if (gPaletteFade.active) + { + return; + } + + if (gTasks[taskIdA].data[TDA_0] == 0) + { + FadeOutBGM(4); + BeginNormalPaletteFade(-1, 8, 0, 16, 0xFFFF); + gTasks[taskIdA].func = task_a_8144114; + return; + } + + if (gMain.newKeys) + { + FadeOutBGM(4); + BeginNormalPaletteFade(-1, 8, 0, 16, 0xFFFF); + gTasks[taskIdA].func = task_a_8144114; + return; + } + + if (gTasks[taskIdA].data[TDA_0] == 7144) + { + FadeOutBGM(8); + } + + if (gTasks[taskIdA].data[TDA_0] == 6840) + { + m4aSongNumStart(BGM_END); + } + + gTasks[taskIdA].data[TDA_0] -= 1; +} + +static void task_a_8144114(u8 taskIdA) +{ + if (gPaletteFade.active) + { + return; + } + + SoftReset(0xFF); +} + +static void sub_8144130(void) +{ + REG_DISPCNT = 0; + + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; + REG_BG2HOFS = 0; + REG_BG2VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + REG_BLDY = 0; + + DmaFill16(3, 0, (void *)VRAM, VRAM_SIZE); + DmaFill32(3, 0, (void *)OAM, OAM_SIZE); + DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2); +} + +static void task_b_81441B8(u8 taskIdB) +{ + u16 i; + + switch (gTasks[taskIdB].data[TDB_0]) + { + case 0: + case 6: + case 7: + case 8: + case 9: + default: + if (gPaletteFade.active) + { + return; + } + gTasks[taskIdB].data[TDB_0] = 1; + gTasks[taskIdB].data[TDB_3] = 0x58; + gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_14] = 0; + gUnknown_02039320 = 0; + return; + + case 1: + if (gTasks[taskIdB].data[TDB_3] != 0) + { + gTasks[taskIdB].data[TDB_3] -= 1; + return; + } + + gTasks[taskIdB].data[TDB_0] += 1; + return; + + case 2: + REG_DISPCNT &= ~DISPCNT_BG0_ON; + + if (gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].func == task_a_8143B68) + { + if (gTasks[taskIdB].data[TDB_CURRENT_PAGE] < PAGE_COUNT) + { + + for (i = 0; i < 5; i++) + { + sub_8072BD8(gCreditsEntryPointerTable[gTasks[taskIdB].data[TDB_CURRENT_PAGE]][i]->text, 0, 9 + i * 2, 240); + } + + gTasks[taskIdB].data[TDB_CURRENT_PAGE] += 1; + gTasks[taskIdB].data[TDB_0] += 1; + + gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_14] = 1; + + if (gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_13] == 1) + { + BeginNormalPaletteFade(0x300, 0, 16, 0, COLOR_LIGHT_GREEN); + } + else + { + BeginNormalPaletteFade(0x300, 0, 16, 0, COLOR_DARK_GREEN); + } + return; + } + + + gTasks[taskIdB].data[TDB_0] = 10; + return; + } + + gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_14] = 0; + return; + + case 3: + REG_DISPCNT |= DISPCNT_BG0_ON; + + if (gPaletteFade.active) + { + return; + } + + gTasks[taskIdB].data[TDB_3] = UNK_DEFINE_82; + gTasks[taskIdB].data[TDB_0] += 1; + return; + + case 4: + if (gTasks[taskIdB].data[TDB_3] != 0) + { + gTasks[taskIdB].data[TDB_3] -= 1; + return; + } + + if (sub_8144454((u8)gTasks[taskIdB].data[TDB_CURRENT_PAGE], (u8)gTasks[taskIdB].data[TDB_TASK_A_ID])) + { + gTasks[taskIdB].data[TDB_0] += 1; + return; + } + + gTasks[taskIdB].data[TDB_0] += 1; + + if (gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_13] == 1) + { + BeginNormalPaletteFade(0x300, 0, 0, 16, COLOR_LIGHT_GREEN); + } + else + { + BeginNormalPaletteFade(0x300, 0, 0, 16, COLOR_DARK_GREEN); + } + + return; + + case 5: + if (gPaletteFade.active) + { + return; + } + + MenuZeroFillWindowRect(0, 9, 29, 19); + gTasks[taskIdB].data[TDB_0] = 2; + return; + + case 10: + gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_4] = 1; + DestroyTask(taskIdB); + return; + } +} + +static u8 sub_8144454(u8 page, u8 taskIdA) +{ + // Starts with bike + ocean + morning + + if (page == PAGE_PROGRAMMERS_1) + { + // Grass patch + gTasks[taskIdA].data[TDA_11] = 2; + } + + if (page == PAGE_POKEMON_GRAHPIC_DESIGNERS_3) + { + // Bike + ocean + sunset + gTasks[taskIdA].data[TDA_7] = 1; + gTasks[taskIdA].data[TDA_11] = 1; + } + + if (page == PAGE_GAME_DESIGNERS_2) + { + // Grass patch + gTasks[taskIdA].data[TDA_11] = 2; + } + + if (page == PAGE_MAP_DATA_DESIGNERS) + { + // Bike + forest + sunset + gTasks[taskIdA].data[TDA_7] = 2; + gTasks[taskIdA].data[TDA_11] = 1; + } + + if (page == PAGE_SPECIAL_THANKS_1) + { + // Grass patch + gTasks[taskIdA].data[TDA_11] = 2; + } + + if (page == PAGE_TASK_MANAGERS) + { + // Bike + forest + sunset + gTasks[taskIdA].data[TDA_7] = 3; + gTasks[taskIdA].data[TDA_11] = 1; + } + + if (page == PAGE_TRANSLATION_COORDINATOR) + { + // Grass patch + gTasks[taskIdA].data[TDA_11] = 2; + } + + if (page == LAST_PAGE) + { + // Bike + town + night + gTasks[taskIdA].data[TDA_7] = 4; + gTasks[taskIdA].data[TDA_11] = 1; + } + + if (gTasks[taskIdA].data[TDA_11] != 0) + { + // Returns true if changed? + return TRUE; + } + + return FALSE; +} + +static void task_d_8144514(u8 taskIdD) +{ + struct Unk201C000 *r6 = &ewram1c000; + u8 r2; + + switch (gTasks[taskIdD].data[TDD_STATE]) + { + case 0: + break; + case 1: + if (r6->unk8A == 0 && gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].data[TDA_14] == 0) + break; + gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].data[TDA_14] = 0; + gTasks[taskIdD].data[TDD_STATE]++; + break; + case 2: + if (r6->unk88 == POKEMON_TILE_COUNT || gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].func != task_a_8143B68) + break; + r2 = sub_81456B4(r6->unk0[r6->unk8C], gUnknown_0840CA00[r6->unk8A][0], gUnknown_0840CA00[r6->unk8A][1], r6->unk8A); + if (r6->unk8C < r6->unk8E - 1) + { + r6->unk8C++; + gSprites[r2].data3 = 50; + } + else + { + r6->unk8C = 0; + gSprites[r2].data3 = 512; + } + r6->unk88++; + if (r6->unk8A == 2) + r6->unk8A = 0; + else + r6->unk8A++; + gTasks[taskIdD].data[TDD_3] = 50; + gTasks[taskIdD].data[TDD_STATE]++; + break; + case 3: + if (gTasks[taskIdD].data[TDD_3] != 0) + gTasks[taskIdD].data[TDD_3]--; + else + gTasks[taskIdD].data[TDD_STATE] = 1; + break; + } +} + +void task_c_8144664(u8 taskIdC) +{ + switch (gTasks[taskIdC].data[TDC_0]) + { + case 0: + gUnknown_0203935A = Sin((gTasks[taskIdC].data[TDC_5] >> 1) & 0x7F, 12); + gTasks[taskIdC].data[TDC_5]++; + break; + case 1: + if (gUnknown_0203935A != 0) + { + gUnknown_0203935A = Sin((gTasks[taskIdC].data[TDC_5] >> 1) & 0x7F, 12); + gTasks[taskIdC].data[TDC_5]++; + } + else + { + gSprites[gTasks[taskIdC].data[TDC_2]].data0 = 2; + gTasks[taskIdC].data[TDC_5] = 0; + gTasks[taskIdC].data[TDC_0]++; + } + break; + case 2: + if (gTasks[taskIdC].data[TDC_5] < 64) + { + gTasks[taskIdC].data[TDC_5]++; + gUnknown_0203935A = Sin(gTasks[taskIdC].data[TDC_5] & 0x7F, 20); + } + else + { + gTasks[taskIdC].data[TDC_0]++; + } + break; + case 3: + gSprites[gTasks[taskIdC].data[TDC_2]].data0 = 3; + gSprites[gTasks[taskIdC].data[TDC_3]].data0 = 1; + gTasks[taskIdC].data[TDC_4] = 120; + gTasks[taskIdC].data[TDC_0]++; + break; + case 4: + if (gTasks[taskIdC].data[TDC_4] != 0) + { + gTasks[taskIdC].data[TDC_4]--; + } + else + { + gTasks[taskIdC].data[TDC_5] = 64; + gTasks[taskIdC].data[TDC_0]++; + } + break; + case 5: + if (gTasks[taskIdC].data[TDC_5] > 0) + { + gTasks[taskIdC].data[TDC_5]--; + gUnknown_0203935A = Sin(gTasks[taskIdC].data[TDC_5] & 0x7F, 20); + } + else + { + gSprites[gTasks[taskIdC].data[TDC_2]].data0 = 1; + gTasks[taskIdC].data[TDC_0]++; + } + break; + case 6: + gTasks[taskIdC].data[TDC_0] = 50; + break; + case 10: + gSprites[gTasks[taskIdC].data[TDC_3]].data0 = 2; + gTasks[taskIdC].data[TDC_0] = 50; + break; + case 20: + gSprites[gTasks[taskIdC].data[TDC_2]].data0 = 4; + gTasks[taskIdC].data[TDC_0] = 50; + break; + case 30: + gSprites[gTasks[taskIdC].data[TDC_2]].data0 = 5; + gSprites[gTasks[taskIdC].data[TDC_3]].data0 = 3; + gTasks[taskIdC].data[TDC_0] = 50; + break; + case 50: + gTasks[taskIdC].data[TDC_0] = 0; + break; + } +} + +void task_e_8144934(u8 taskIdE) +{ + s16 taskIdC; + + switch (gTasks[taskIdE].data[TDE_0]) + { + default: + case 0: + if (gTasks[taskIdE].data[TDE_1] != 0x7FFF) + { + + if (gTasks[gTasks[gTasks[taskIdE].data[TDE_TASK_A_ID]].data[TDA_TASK_B_ID]].data[TDB_CURRENT_PAGE] == PAGE_ART_DIRECTOR) + { + gTasks[gTasks[gTasks[taskIdE].data[TDE_TASK_A_ID]].data[TDA_TASK_C_ID]].data[TDC_0] = 20; + gTasks[taskIdE].data[TDE_1] = 0x7FFF; + } + } + + sub_8149020(0); + break; + + case 1: + sub_8149020(0); + break; + + case 2: + if (gTasks[taskIdE].data[TDE_1] != 0x7FFF) + { + taskIdC = gTasks[gTasks[taskIdE].data[TDE_TASK_A_ID]].data[TDA_TASK_C_ID]; + + // Floor to multiple of 128 + if ((gTasks[taskIdC].data[TDC_5] & -128) == 640) + { + gTasks[taskIdC].data[TDC_0] = 1; + gTasks[taskIdE].data[TDE_1] = 0x7FFF; + } + } + sub_8149020(1); + break; + + case 3: + if (gTasks[taskIdE].data[TDE_1] != 0x7FFF) + { + + if (gTasks[taskIdE].data[TDE_1] == UNK_DEF_1F3) + { + gTasks[gTasks[gTasks[taskIdE].data[TDE_TASK_A_ID]].data[TDA_TASK_C_ID]].data[TDC_0] = 10; + gTasks[taskIdE].data[TDE_1] = 0x7FFF; + } + else + { + gTasks[taskIdE].data[TDE_1] += 1; + } + } + + sub_8149020(1); + break; + + case 4: + sub_8149020(2); + break; + } +} + +static void sub_8144A68(u8 data, u8 taskIdA) +{ + switch (data) + { + case 0: + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = 0; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].invisible = 0; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.x = 272; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.x = 272; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.y = 46; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.y = 46; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].data0 = 0; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].data0 = 0; + gTasks[taskIdA].data[TDA_0] = sub_8148EC0(0, 0x2000, 0x20, 8); + break; + + case 1: + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = 0; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].invisible = 0; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.x = 120; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.x = 272; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.y = 46; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.y = 46; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].data0 = 0; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].data0 = 0; + gTasks[taskIdA].data[TDA_0] = sub_8148EC0(0, 0x2000, 0x20, 8); + break; + + case 2: + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = 0; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].invisible = 0; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.x = 120; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.x = 272; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.y = 46; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.y = 46; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].data0 = 0; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].data0 = 0; + gTasks[taskIdA].data[TDA_0] = sub_8148EC0(1, 0x2000, 0x200, 8); + break; + + case 3: + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = 0; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].invisible = 0; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.x = 120; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.x = -32; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.y = 46; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.y = 46; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].data0 = 0; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].data0 = 0; + gTasks[taskIdA].data[TDA_0] = sub_8148EC0(1, 0x2000, 0x200, 8); + break; + + case 4: + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = 0; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].invisible = 0; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.x = 88; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.x = 152; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.y = 46; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.y = 46; + gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].data0 = 0; + gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].data0 = 0; + gTasks[taskIdA].data[TDA_0] = sub_8148EC0(2, 0x2000, 0x200, 8); + break; + } + + gTasks[taskIdA].data[TDA_TASK_E_ID] = CreateTask(task_e_8144934, 0); + gTasks[gTasks[taskIdA].data[TDA_TASK_E_ID]].data[TDE_0] = data; + gTasks[gTasks[taskIdA].data[TDA_TASK_E_ID]].data[TDE_1] = 0; + gTasks[gTasks[taskIdA].data[TDA_TASK_E_ID]].data[TDE_TASK_A_ID] = taskIdA; + + gTasks[taskIdA].data[TDA_TASK_C_ID] = CreateTask(task_c_8144664, 0); + gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_0] = 0; + gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_1] = taskIdA; + gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_2] = gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]; + gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_3] = gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]; + gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_4] = 0; + + if (data == 2) + { + gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_5] = UNK_DEFINE_45; + } +} + +static bool8 sub_8144ECC(u8 data, u8 taskIdA) +{ + u8 spriteId; + + switch (gMain.state) + { + default: + case 0: + REG_DISPCNT = 0; + REG_BG3HOFS = 8; + REG_BG3VOFS = 0; + REG_BG2HOFS = 0; + REG_BG2VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + ResetSpriteData(); + FreeAllSpritePalettes(); + gMain.state = 1; + break; + + case 1: + gUnknown_02039358 = 34; + gUnknown_0203935A = 0; + sub_8148CB0(data); + gMain.state += 1; + break; + + case 2: + if (gSaveBlock2.playerGender == MALE) + { + LoadCompressedObjectPic(&gIntro2BrendanSpriteSheet); + LoadCompressedObjectPic(&gUnknown_08416E34); + LoadCompressedObjectPic(&gIntro2BicycleSpriteSheet); + LoadSpritePalettes(gIntro2SpritePalettes); + + spriteId = intro_create_brendan_sprite(120, 46); + gTasks[taskIdA].data[TDA_PLAYER_CYCLIST] = spriteId; + gSprites[spriteId].callback = spritecb_player_8145378; + gSprites[spriteId].anims = gSpriteAnimTable_0840CA54; + + spriteId = intro_create_may_sprite(272, 46); + gTasks[taskIdA].data[TDA_RIVAL_CYCLIST] = spriteId; + gSprites[spriteId].callback = spritecb_rival_8145420; + gSprites[spriteId].anims = gSpriteAnimTable_0840CA94; + } + else + { + LoadCompressedObjectPic(&gIntro2MaySpriteSheet); + LoadCompressedObjectPic(&gUnknown_08416E24); + LoadCompressedObjectPic(&gIntro2BicycleSpriteSheet); + LoadSpritePalettes(gIntro2SpritePalettes); + + spriteId = intro_create_may_sprite(120, 46); + gTasks[taskIdA].data[TDA_PLAYER_CYCLIST] = spriteId; + gSprites[spriteId].callback = spritecb_player_8145378; + gSprites[spriteId].anims = gSpriteAnimTable_0840CA54; + + spriteId = intro_create_brendan_sprite(272, 46); + gTasks[taskIdA].data[TDA_RIVAL_CYCLIST] = spriteId; + gSprites[spriteId].callback = spritecb_rival_8145420; + gSprites[spriteId].anims = gSpriteAnimTable_0840CA94; + }; + + gMain.state += 1; + break; + + case 3: + sub_8144A68(data, taskIdA); + sub_8148E90(data); + gMain.state = 0; + return TRUE; + } + + return FALSE; +} + +static void sub_81450AC(u8 taskIdA) +{ + if (gTasks[taskIdA].data[TDA_0] != 0) + { + DestroyTask(gTasks[taskIdA].data[TDA_0]); + gTasks[taskIdA].data[TDA_0] = 0; + } + + if (gTasks[taskIdA].data[TDA_TASK_C_ID] != 0) + { + DestroyTask(gTasks[taskIdA].data[TDA_TASK_C_ID]); + gTasks[taskIdA].data[TDA_TASK_C_ID] = 0; + } + + if (gTasks[taskIdA].data[TDA_TASK_E_ID] != 0) + { + DestroyTask(gTasks[taskIdA].data[TDA_TASK_E_ID]); + gTasks[taskIdA].data[TDA_TASK_E_ID] = 0; + } + + if (gTasks[taskIdA].data[TDA_TASK_D_ID] != 0) + { + DestroyTask(gTasks[taskIdA].data[TDA_TASK_D_ID]); + gTasks[taskIdA].data[TDA_TASK_D_ID] = 0; + } + + gUnknown_0203935C = 1; +} + +static void sub_8145128(u16 arg0, u16 arg1, u16 arg2) { + u16 baseTile; + u16 i; + + LZ77UnCompVram(gCreditsCopyrightEnd_Gfx, (void *) (VRAM + arg0)); + LoadPalette(gIntroCopyright_Pal, arg2, sizeof(gIntroCopyright_Pal)); + + baseTile = (arg2 / 16) << 12; + + for (i = 0; i < 32 * 32; i++) + { + ((u16 *) (VRAM + arg1))[i] = baseTile + 1; + } + + for (i = 0; i < 21; i++) + { + ((u16 *) (VRAM + arg1))[7 * 32 + 4 + i] = i + 2 + baseTile; + } + + for (i = 0; i < 20; i++) + { + ((u16 *) (VRAM + arg1))[9 * 32 + 4 + i] = i + 23 + baseTile; + } + + for (i = 0; i < 23; i++) + { + ((u16 *) (VRAM + arg1))[11 * 32 + 4 + i] = i + 43 + baseTile; + } + + for (i = 0; i < 12; i++) + { + ((u16 *) (VRAM + arg1))[13 * 32 + 4 + i] = i + 66 + baseTile; + } +} + +u16 sub_8145208(u8 arg0) +{ + + u16 out = (arg0 & 0x3F) + 80; + + if (arg0 == 0xFF) + { + return 1; + } + + if (arg0 & (1 << 7)) + { + out |= 1 << 11; + } + + if (arg0 & (1 << 6)) + { + out |= 1 << 10; + } + + return out; +} + +void sub_814524C(u8 arg0[], u8 baseX, u8 baseY, u16 arg3, u16 palette) { + u8 y, x; + + const u16 tileOffset = (palette / 16) << 12; + + for (y = 0; y < 5; y++) + { + for (x = 0; x < 3; x++) + { + ((u16 *) (VRAM + arg3 + (baseY + y) * 64))[baseX + x] = tileOffset + sub_8145208(arg0[y * 3 + x]); + } + } +} + +static void sub_81452D0(u16 arg0, u16 palette) +{ + u16 pos; + u16 baseTile = (palette / 16) << 12; + + for (pos = 0; pos < 32 * 32; pos++) + ((u16 *) (VRAM + arg0))[pos] = baseTile + 1; + +#if ENGLISH + sub_814524C(gUnknown_0840B83C, 3, 7, arg0, palette); + sub_814524C(gUnknown_0840B84B, 7, 7, arg0, palette); + sub_814524C(gUnknown_0840B85A, 11, 7, arg0, palette); + sub_814524C(gUnknown_0840B85A, 16, 7, arg0, palette); + sub_814524C(gUnknown_0840B869, 20, 7, arg0, palette); + sub_814524C(gUnknown_0840B878, 24, 7, arg0, palette); +#elif GERMAN + sub_814524C(gUnknown_0840B85A, 7, 7, arg0, palette); + sub_814524C(gUnknown_0840B869, 11, 7, arg0, palette); + sub_814524C(gUnknown_0840B878, 15, 7, arg0, palette); + sub_814524C(gUnknown_0840B85A, 19, 7, arg0, palette); +#endif +} + +static void spritecb_player_8145378(struct Sprite *sprite) +{ + if (gUnknown_0203935C != 0) + { + DestroySprite(sprite); + return; + } + + switch (sprite->data0) + { + case 0: + StartSpriteAnimIfDifferent(sprite, 0); + break; + + case 1: + StartSpriteAnimIfDifferent(sprite, 1); + if (sprite->pos1.x > -32) + { + sprite->pos1.x -= 1; + } + break; + + case 2: + StartSpriteAnimIfDifferent(sprite, 2); + break; + + case 3: + StartSpriteAnimIfDifferent(sprite, 3); + break; + + case 4: + StartSpriteAnimIfDifferent(sprite, 0); + if (sprite->pos1.x > 120) + { + sprite->pos1.x -= 1; + } + break; + + case 5: + StartSpriteAnimIfDifferent(sprite, 0); + if (sprite->pos1.x > -32) + { + sprite->pos1.x -= 1; + } + break; + } +} + +static void spritecb_rival_8145420(struct Sprite *sprite) +{ + if (gUnknown_0203935C != 0) + { + DestroySprite(sprite); + return; + } + + switch (sprite->data0) + { + case 0: + sprite->pos2.y = 0; + StartSpriteAnimIfDifferent(sprite, 0); + break; + + case 1: + if (sprite->pos1.x > 200) + { + StartSpriteAnimIfDifferent(sprite, 1); + } + else + { + StartSpriteAnimIfDifferent(sprite, 2); + } + + if (sprite->pos1.x > -32) + { + sprite->pos1.x -= 2; + } + + sprite->pos2.y = -gUnknown_0203935A; + break; + + case 2: + sprite->data7 += 1; + StartSpriteAnimIfDifferent(sprite, 0); + + if ((sprite->data7 & 3) == 0) + { + sprite->pos1.x += 1; + } + break; + + case 3: + StartSpriteAnimIfDifferent(sprite, 0); + + if (sprite->pos1.x > -32) + { + sprite->pos1.x -= 1; + } + break; + + + } +} + +void spritecb_81454E0(struct Sprite *sprite) { + if (gUnknown_0203935C) + { + DestroySprite(sprite); + return; + } + + sprite->data7 += 1; + switch (sprite->data0) + { + case 0: + default: + sprite->oam.affineMode = 1; + sprite->oam.matrixNum = sprite->data1; + sprite->data2 = 16; + SetOamMatrix(sprite->data1, 0x10000 / sprite->data2, 0, 0, 0x10000 / sprite->data2); + sprite->invisible = FALSE; + sprite->data0 = 1; + break; + + case 1: + if (sprite->data2 < 256) + { + sprite->data2 += 8; + SetOamMatrix(sprite->data1, 0x10000 / sprite->data2, 0, 0, 0x10000 / sprite->data2); + } + else + { + sprite->data0 += 1; + } + switch (sprite->data1) + { + case 1: + if ((sprite->data7 & 3) == 0) + { + sprite->pos1.y += 1; + } + sprite->pos1.x -= 2; + break; + case 2: + break; + case 3: + if ((sprite->data7 & 3) == 0) + { + sprite->pos1.y += 1; + } + sprite->pos1.x += 2; + break; + } + break; + + case 2: + if (sprite->data3 != 0) + { + sprite->data3 -= 1; + } + else + { + REG_BLDCNT = 0xF40; + REG_BLDALPHA = 0x10; + sprite->oam.objMode = 1; + sprite->data3 = 16; + sprite->data0 += 1; + } + break; + + case 3: + if (sprite->data3 != 0) + { + int data3; + vu16 *reg; + + sprite->data3 -= 1; + + reg = ®_BLDALPHA; + data3 = 16 - sprite->data3; + *reg = (data3 << 8) + sprite->data3; + } + else + { + sprite->invisible = TRUE; + sprite->data0 = 10; + } + break; + + case 10: + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + DestroySprite(sprite); + break; + + } +} + +static u8 sub_81456B4(u16 species, u16 x, u16 y, u16 position) +{ + u32 personality; + const u8 *lzPaletteData; + u8 spriteId; + u8 spriteId2; + + species = NationalPokedexNumToSpecies(species); + + switch (species) + { + default: + personality = 0; + break; + + case SPECIES_SPINDA: + personality = gSaveBlock2.pokedex.spindaPersonality; + break; + + case SPECIES_UNOWN: + personality = gSaveBlock2.pokedex.unownPersonality; + break; + } + + LoadSpecialPokePic( + &gMonFrontPicTable[species], + gMonFrontPicCoords[species].coords, + gMonFrontPicCoords[species].y_offset, + 0x2000000, + gUnknown_0840B5A0[position], + species, + personality, + 1 + ); + + lzPaletteData = species_and_otid_get_pal(species, 0, 0xFFFF); + LoadCompressedPalette(lzPaletteData, 0x100 + (position * 16), 0x20); + sub_8143648(position, position); + + spriteId = CreateSprite(&gUnknown_02024E8C, x, y, 0); + gSprites[spriteId].oam.paletteNum = position; + gSprites[spriteId].oam.priority = 1; + gSprites[spriteId].data1 = position + 1; + gSprites[spriteId].invisible = TRUE; + gSprites[spriteId].callback = spritecb_81454E0; + + spriteId2 = CreateSprite(&gSpriteTemplate_840CAEC, gSprites[spriteId].pos1.x, gSprites[spriteId].pos1.y, 1); + gSprites[spriteId2].data0 = spriteId; + + StartSpriteAnimIfDifferent(&gSprites[spriteId2], position); + + return spriteId; +} + +void spritecb_814580C(struct Sprite *sprite) +{ + if (gSprites[sprite->data0].data0 == 10 || gUnknown_0203935C) + { + DestroySprite(sprite); + return; + } + + sprite->invisible = gSprites[sprite->data0].invisible; + sprite->oam.objMode = gSprites[sprite->data0].oam.objMode; + sprite->oam.affineMode = gSprites[sprite->data0].oam.affineMode; + sprite->oam.matrixNum = gSprites[sprite->data0].oam.matrixNum; + sprite->pos1.x = gSprites[sprite->data0].pos1.x; + sprite->pos1.y = gSprites[sprite->data0].pos1.y; +} + +static void sub_81458DC(void) { + struct Unk201C000 *unk201C000 = &ewram1c000; + u16 starter = SpeciesToNationalPokedexNum(GetStarterPokemon(VarGet(VAR_FIRST_POKE))); + u16 seenTypesCount; + u16 page; + u16 dexNum; + u16 j; + + for (dexNum = 1, seenTypesCount = 0; dexNum < 386; dexNum++) + { + if (GetNationalPokedexFlag(dexNum, 1)) + { + unk201C000->unk90[seenTypesCount] = dexNum; + seenTypesCount++; + } + } + + for (dexNum = seenTypesCount; dexNum < 386; dexNum++) + { + unk201C000->unk90[dexNum] = 0; + } + + unk201C000->unk394 = seenTypesCount; + if (unk201C000->unk394 < POKEMON_TILE_COUNT) + { + unk201C000->unk8E = seenTypesCount; + } + else + { + unk201C000->unk8E = POKEMON_TILE_COUNT; + } + + j = 0; + do + { + page = Random() % unk201C000->unk394; + unk201C000->unk0[j] = unk201C000->unk90[page]; + + j++; + unk201C000->unk90[page] = 0; + unk201C000->unk394--; + if (page != unk201C000->unk394) + { + unk201C000->unk90[page] = unk201C000->unk90[unk201C000->unk394]; + unk201C000->unk90[unk201C000->unk394] = 0; + } + } + while (unk201C000->unk394 != 0 && j < POKEMON_TILE_COUNT); + + if (unk201C000->unk8E < POKEMON_TILE_COUNT) + { + for (j = unk201C000->unk8E, page = 0; j < POKEMON_TILE_COUNT; j++) + { + unk201C000->unk0[j] = unk201C000->unk0[page]; + + page++; + if (page == unk201C000->unk8E) + page = 0; + } + unk201C000->unk0[POKEMON_TILE_COUNT - 1] = starter; + } + else + { + + for (dexNum = 0; unk201C000->unk0[dexNum] != starter && dexNum < POKEMON_TILE_COUNT; dexNum++); + + if (dexNum < unk201C000->unk8E - 1) + { + unk201C000->unk0[dexNum] = unk201C000->unk0[POKEMON_TILE_COUNT - 1]; + unk201C000->unk0[POKEMON_TILE_COUNT - 1] = starter; + } + else + unk201C000->unk0[POKEMON_TILE_COUNT - 1] = starter; + } + unk201C000->unk8E = POKEMON_TILE_COUNT; +} diff --git a/src/data/.clang-format b/src/data/.clang-format new file mode 100644 index 000000000..036aa7d76 --- /dev/null +++ b/src/data/.clang-format @@ -0,0 +1,22 @@ +BasedOnStyle: LLVM +AllowShortFunctionsOnASingleLine: None +BreakBeforeBraces: Allman +ColumnLimit: 0 +UseTab: Never +IndentWidth: 4 +TabWidth: 4 +AlignAfterOpenBracket: DontAlign +Cpp11BracedListStyle: false +BreakStringLiterals: false +IndentCaseLabels: false +IncludeCategories: + - Regex: '^"gba/types\.h"$' + Priority: -4 + - Regex: '^"global\.h"$' + Priority: -3 + - Regex: '^"gba/gba\.h"$' + Priority: -2 + - Regex: '^"gba/' + Priority: -1 + - Regex: '.\*' + Priority: 1 diff --git a/src/data/decoration/decorations.h b/src/data/decoration/decorations.h new file mode 100644 index 000000000..a25f3408f --- /dev/null +++ b/src/data/decoration/decorations.h @@ -0,0 +1,1212 @@ +const struct Decoration gDecorations[] = { + { + .id = DECOR_NONE, + .name = DECORNAME_SMALL_DESK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DESK, + .price = 0, + .description = DecorDesc_SMALL_DESK, + .tiles = DecorGfx_SMALL_DESK, + }, + { + .id = DECOR_SMALL_DESK, + .name = DECORNAME_SMALL_DESK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DESK, + .price = 3000, + .description = DecorDesc_SMALL_DESK, + .tiles = DecorGfx_SMALL_DESK, + }, + { + .id = DECOR_POKEMON_DESK, + .name = DECORNAME_POKEMON_DESK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DESK, + .price = 3000, + .description = DecorDesc_POKEMON_DESK, + .tiles = DecorGfx_POKEMON_DESK, + }, + { + .id = DECOR_HEAVY_DESK, + .name = DECORNAME_HEAVY_DESK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x2, + .category = DECORCAT_DESK, + .price = 6000, + .description = DecorDesc_HEAVY_DESK, + .tiles = DecorGfx_HEAVY_DESK, + }, + { + .id = DECOR_RAGGED_DESK, + .name = DECORNAME_RAGGED_DESK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x2, + .category = DECORCAT_DESK, + .price = 6000, + .description = DecorDesc_RAGGED_DESK, + .tiles = DecorGfx_RAGGED_DESK, + }, + { + .id = DECOR_COMFORT_DESK, + .name = DECORNAME_COMFORT_DESK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x2, + .category = DECORCAT_DESK, + .price = 6000, + .description = DecorDesc_COMFORT_DESK, + .tiles = DecorGfx_COMFORT_DESK, + }, + { + .id = DECOR_PRETTY_DESK, + .name = DECORNAME_PRETTY_DESK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_DESK, + .price = 9000, + .description = DecorDesc_PRETTY_DESK, + .tiles = DecorGfx_PRETTY_DESK, + }, + { + .id = DECOR_BRICK_DESK, + .name = DECORNAME_BRICK_DESK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_DESK, + .price = 9000, + .description = DecorDesc_BRICK_DESK, + .tiles = DecorGfx_BRICK_DESK, + }, + { + .id = DECOR_CAMP_DESK, + .name = DECORNAME_CAMP_DESK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_DESK, + .price = 9000, + .description = DecorDesc_CAMP_DESK, + .tiles = DecorGfx_CAMP_DESK, + }, + { + .id = DECOR_HARD_DESK, + .name = DECORNAME_HARD_DESK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_DESK, + .price = 9000, + .description = DecorDesc_HARD_DESK, + .tiles = DecorGfx_HARD_DESK, + }, + { + .id = DECOR_SMALL_CHAIR, + .name = DECORNAME_SMALL_CHAIR, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_SMALL_CHAIR, + .tiles = DecorGfx_SMALL_CHAIR, + }, + { + .id = DECOR_POKEMON_CHAIR, + .name = DECORNAME_POKEMON_CHAIR, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_POKEMON_CHAIR, + .tiles = DecorGfx_POKEMON_CHAIR, + }, + { + .id = DECOR_HEAVY_CHAIR, + .name = DECORNAME_HEAVY_CHAIR, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_HEAVY_CHAIR, + .tiles = DecorGfx_HEAVY_CHAIR, + }, + { + .id = DECOR_PRETTY_CHAIR, + .name = DECORNAME_PRETTY_CHAIR, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_PRETTY_CHAIR, + .tiles = DecorGfx_PRETTY_CHAIR, + }, + { + .id = DECOR_COMFORT_CHAIR, + .name = DECORNAME_COMFORT_CHAIR, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_COMFORT_CHAIR, + .tiles = DecorGfx_COMFORT_CHAIR, + }, + { + .id = DECOR_RAGGED_CHAIR, + .name = DECORNAME_RAGGED_CHAIR, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_RAGGED_CHAIR, + .tiles = DecorGfx_RAGGED_CHAIR, + }, + { + .id = DECOR_BRICK_CHAIR, + .name = DECORNAME_BRICK_CHAIR, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_BRICK_CHAIR, + .tiles = DecorGfx_BRICK_CHAIR, + }, + { + .id = DECOR_CAMP_CHAIR, + .name = DECORNAME_CAMP_CHAIR, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_CAMP_CHAIR, + .tiles = DecorGfx_CAMP_CHAIR, + }, + { + .id = DECOR_HARD_CHAIR, + .name = DECORNAME_HARD_CHAIR, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_HARD_CHAIR, + .tiles = DecorGfx_HARD_CHAIR, + }, + { + .id = DECOR_RED_PLANT, + .name = DECORNAME_RED_PLANT, + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_PLANT, + .price = 3000, + .description = DecorDesc_RED_PLANT, + .tiles = DecorGfx_RED_PLANT, + }, + { + .id = DECOR_TROPICAL_PLANT, + .name = DECORNAME_TROPICAL_PLANT, + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_PLANT, + .price = 3000, + .description = DecorDesc_TROPICAL_PLANT, + .tiles = DecorGfx_TROPICAL_PLANT, + }, + { + .id = DECOR_PRETTY_FLOWERS, + .name = DECORNAME_PRETTY_FLOWERS, + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_PLANT, + .price = 3000, + .description = DecorDesc_PRETTY_FLOWERS, + .tiles = DecorGfx_PRETTY_FLOWERS, + }, + { + .id = DECOR_COLORFUL_PLANT, + .name = DECORNAME_COLORFUL_PLANT, + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_2x2, + .category = DECORCAT_PLANT, + .price = 5000, + .description = DecorDesc_COLORFUL_PLANT, + .tiles = DecorGfx_COLORFUL_PLANT, + }, + { + .id = DECOR_BIG_PLANT, + .name = DECORNAME_BIG_PLANT, + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_2x2, + .category = DECORCAT_PLANT, + .price = 5000, + .description = DecorDesc_BIG_PLANT, + .tiles = DecorGfx_BIG_PLANT, + }, + { + .id = DECOR_GORGEOUS_PLANT, + .name = DECORNAME_GORGEOUS_PLANT, + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_2x2, + .category = DECORCAT_PLANT, + .price = 5000, + .description = DecorDesc_GORGEOUS_PLANT, + .tiles = DecorGfx_GORGEOUS_PLANT, + }, + { + .id = DECOR_RED_BRICK, + .name = DECORNAME_RED_BRICK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_RED_BRICK, + .tiles = DecorGfx_RED_BRICK, + }, + { + .id = DECOR_YELLOW_BRICK, + .name = DECORNAME_YELLOW_BRICK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_YELLOW_BRICK, + .tiles = DecorGfx_YELLOW_BRICK, + }, + { + .id = DECOR_BLUE_BRICK, + .name = DECORNAME_BLUE_BRICK, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_BLUE_BRICK, + .tiles = DecorGfx_BLUE_BRICK, + }, + { + .id = DECOR_RED_BALLOON, + .name = DECORNAME_RED_BALLOON, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_RED_BALLOON, + .tiles = DecorGfx_RED_BALLOON, + }, + { + .id = DECOR_BLUE_BALLOON, + .name = DECORNAME_BLUE_BALLOON, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_BLUE_BALLOON, + .tiles = DecorGfx_BLUE_BALLOON, + }, + { + .id = DECOR_YELLOW_BALLOON, + .name = DECORNAME_YELLOW_BALLOON, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_YELLOW_BALLOON, + .tiles = DecorGfx_YELLOW_BALLOON, + }, + { + .id = DECOR_RED_TENT, + .name = DECORNAME_RED_TENT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_ORNAMENT, + .price = 10000, + .description = DecorDesc_RED_TENT, + .tiles = DecorGfx_RED_TENT, + }, + { + .id = DECOR_BLUE_TENT, + .name = DECORNAME_BLUE_TENT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_ORNAMENT, + .price = 10000, + .description = DecorDesc_BLUE_TENT, + .tiles = DecorGfx_BLUE_TENT, + }, + { + .id = DECOR_SOLID_BOARD, + .name = DECORNAME_SOLID_BOARD, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 3000, + .description = DecorDesc_SOLID_BOARD, + .tiles = DecorGfx_SOLID_BOARD, + }, + { + .id = DECOR_SLIDE, + .name = DECORNAME_SLIDE, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_2x4, + .category = DECORCAT_ORNAMENT, + .price = 8000, + .description = DecorDesc_SLIDE, + .tiles = DecorGfx_SLIDE, + }, + { + .id = DECOR_FENCE_LENGTH, + .name = DECORNAME_FENCE_LENGTH, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_FENCE_LENGTH, + .tiles = DecorGfx_FENCE_LENGTH, + }, + { + .id = DECOR_FENCE_WIDTH, + .name = DECORNAME_FENCE_WIDTH, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_FENCE_WIDTH, + .tiles = DecorGfx_FENCE_WIDTH, + }, + { + .id = DECOR_TIRE, + .name = DECORNAME_TIRE, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_2x2, + .category = DECORCAT_ORNAMENT, + .price = 800, + .description = DecorDesc_TIRE, + .tiles = DecorGfx_TIRE, + }, + { + .id = DECOR_STAND, + .name = DECORNAME_STAND, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_4x2, + .category = DECORCAT_ORNAMENT, + .price = 7000, + .description = DecorDesc_STAND, + .tiles = DecorGfx_STAND, + }, + { + .id = DECOR_MUD_BALL, + .name = DECORNAME_MUD_BALL, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 200, + .description = DecorDesc_MUD_BALL, + .tiles = DecorGfx_MUD_BALL, + }, + { + .id = DECOR_BREAKABLE_DOOR, + .name = DECORNAME_BREAKABLE_DOOR, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 3000, + .description = DecorDesc_BREAKABLE_DOOR, + .tiles = DecorGfx_BREAKABLE_DOOR, + }, + { + .id = DECOR_SAND_ORNAMENT, + .name = DECORNAME_SAND_ORNAMENT, + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 3000, + .description = DecorDesc_SAND_ORNAMENT, + .tiles = DecorGfx_SAND_ORNAMENT, + }, + { + .id = DECOR_SILVER_SHIELD, + .name = DECORNAME_SILVER_SHIELD, + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 0, + .description = DecorDesc_SILVER_SHIELD, + .tiles = DecorGfx_SILVER_SHIELD, + }, + { + .id = DECOR_GOLD_SHIELD, + .name = DECORNAME_GOLD_SHIELD, + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 0, + .description = DecorDesc_GOLD_SHIELD, + .tiles = DecorGfx_GOLD_SHIELD, + }, + { + .id = DECOR_GLASS_ORNAMENT, + .name = DECORNAME_GLASS_ORNAMENT, + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 0, + .description = DecorDesc_GLASS_ORNAMENT, + .tiles = DecorGfx_GLASS_ORNAMENT, + }, + { + .id = DECOR_TV, + .name = DECORNAME_TV, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 3000, + .description = DecorDesc_TV, + .tiles = DecorGfx_TV, + }, + { + .id = DECOR_ROUND_TV, + .name = DECORNAME_ROUND_TV, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 4000, + .description = DecorDesc_ROUND_TV, + .tiles = DecorGfx_ROUND_TV, + }, + { + .id = DECOR_CUTE_TV, + .name = DECORNAME_CUTE_TV, + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 4000, + .description = DecorDesc_CUTE_TV, + .tiles = DecorGfx_CUTE_TV, + }, + { + .id = DECOR_GLITTER_MAT, + .name = DECORNAME_GLITTER_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 2000, + .description = DecorDesc_GLITTER_MAT, + .tiles = DecorGfx_GLITTER_MAT, + }, + { + .id = DECOR_JUMP_MAT, + .name = DECORNAME_JUMP_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 2000, + .description = DecorDesc_JUMP_MAT, + .tiles = DecorGfx_JUMP_MAT, + }, + { + .id = DECOR_SPIN_MAT, + .name = DECORNAME_SPIN_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 2000, + .description = DecorDesc_SPIN_MAT, + .tiles = DecorGfx_SPIN_MAT, + }, + { + .id = DECOR_C_LOW_NOTE_MAT, + .name = DECORNAME_C_LOW_NOTE_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_C_LOW_NOTE_MAT, + .tiles = DecorGfx_C_LOW_NOTE_MAT, + }, + { + .id = DECOR_D_NOTE_MAT, + .name = DECORNAME_D_NOTE_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_D_NOTE_MAT, + .tiles = DecorGfx_D_NOTE_MAT, + }, + { + .id = DECOR_E_NOTE_MAT, + .name = DECORNAME_E_NOTE_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_E_NOTE_MAT, + .tiles = DecorGfx_E_NOTE_MAT, + }, + { + .id = DECOR_F_NOTE_MAT, + .name = DECORNAME_F_NOTE_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_F_NOTE_MAT, + .tiles = DecorGfx_F_NOTE_MAT, + }, + { + .id = DECOR_G_NOTE_MAT, + .name = DECORNAME_G_NOTE_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_G_NOTE_MAT, + .tiles = DecorGfx_G_NOTE_MAT, + }, + { + .id = DECOR_A_NOTE_MAT, + .name = DECORNAME_A_NOTE_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_A_NOTE_MAT, + .tiles = DecorGfx_A_NOTE_MAT, + }, + { + .id = DECOR_B_NOTE_MAT, + .name = DECORNAME_B_NOTE_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_B_NOTE_MAT, + .tiles = DecorGfx_B_NOTE_MAT, + }, + { + .id = DECOR_C_HIGH_NOTE_MAT, + .name = DECORNAME_C_HIGH_NOTE_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_C_HIGH_NOTE_MAT, + .tiles = DecorGfx_C_HIGH_NOTE_MAT, + }, + { + .id = DECOR_SURF_MAT, + .name = DECORNAME_SURF_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_SURF_MAT, + .tiles = DecorGfx_SURF_MAT, + }, + { + .id = DECOR_THUNDER_MAT, + .name = DECORNAME_THUNDER_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_THUNDER_MAT, + .tiles = DecorGfx_THUNDER_MAT, + }, + { + .id = DECOR_FIRE_BLAST_MAT, + .name = DECORNAME_FIRE_BLAST_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_FIRE_BLAST_MAT, + .tiles = DecorGfx_FIRE_BLAST_MAT, + }, + { + .id = DECOR_POWDER_SNOW_MAT, + .name = DECORNAME_POWDER_SNOW_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_POWDER_SNOW_MAT, + .tiles = DecorGfx_POWDER_SNOW_MAT, + }, + { + .id = DECOR_ATTRACT_MAT, + .name = DECORNAME_ATTRACT_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_ATTRACT_MAT, + .tiles = DecorGfx_ATTRACT_MAT, + }, + { + .id = DECOR_FISSURE_MAT, + .name = DECORNAME_FISSURE_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_FISSURE_MAT, + .tiles = DecorGfx_FISSURE_MAT, + }, + { + .id = DECOR_SPIKES_MAT, + .name = DECORNAME_SPIKES_MAT, + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_SPIKES_MAT, + .tiles = DecorGfx_SPIKES_MAT, + }, + { + .id = DECOR_BALL_POSTER, + .name = DECORNAME_BALL_POSTER, + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_POSTER, + .price = 1000, + .description = DecorDesc_BALL_POSTER, + .tiles = DecorGfx_BALL_POSTER, + }, + { + .id = DECOR_GREEN_POSTER, + .name = DECORNAME_GREEN_POSTER, + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_POSTER, + .price = 1000, + .description = DecorDesc_GREEN_POSTER, + .tiles = DecorGfx_GREEN_POSTER, + }, + { + .id = DECOR_RED_POSTER, + .name = DECORNAME_RED_POSTER, + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_POSTER, + .price = 1000, + .description = DecorDesc_RED_POSTER, + .tiles = DecorGfx_RED_POSTER, + }, + { + .id = DECOR_BLUE_POSTER, + .name = DECORNAME_BLUE_POSTER, + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_POSTER, + .price = 1000, + .description = DecorDesc_BLUE_POSTER, + .tiles = DecorGfx_BLUE_POSTER, + }, + { + .id = DECOR_CUTE_POSTER, + .name = DECORNAME_CUTE_POSTER, + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_POSTER, + .price = 1000, + .description = DecorDesc_CUTE_POSTER, + .tiles = DecorGfx_CUTE_POSTER, + }, + { + .id = DECOR_PIKA_POSTER, + .name = DECORNAME_PIKA_POSTER, + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_2x1, + .category = DECORCAT_POSTER, + .price = 1500, + .description = DecorDesc_PIKA_POSTER, + .tiles = DecorGfx_PIKA_POSTER, + }, + { + .id = DECOR_LONG_POSTER, + .name = DECORNAME_LONG_POSTER, + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_2x1, + .category = DECORCAT_POSTER, + .price = 1500, + .description = DecorDesc_LONG_POSTER, + .tiles = DecorGfx_LONG_POSTER, + }, + { + .id = DECOR_SEA_POSTER, + .name = DECORNAME_SEA_POSTER, + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_2x1, + .category = DECORCAT_POSTER, + .price = 1500, + .description = DecorDesc_SEA_POSTER, + .tiles = DecorGfx_SEA_POSTER, + }, + { + .id = DECOR_SKY_POSTER, + .name = DECORNAME_SKY_POSTER, + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_2x1, + .category = DECORCAT_POSTER, + .price = 1500, + .description = DecorDesc_SKY_POSTER, + .tiles = DecorGfx_SKY_POSTER, + }, + { + .id = DECOR_KISS_POSTER, + .name = DECORNAME_KISS_POSTER, + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_2x1, + .category = DECORCAT_POSTER, + .price = 1500, + .description = DecorDesc_KISS_POSTER, + .tiles = DecorGfx_KISS_POSTER, + }, + { + .id = DECOR_PICHU_DOLL, + .name = DECORNAME_PICHU_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_PICHU_DOLL, + .tiles = DecorGfx_PICHU_DOLL, + }, + { + .id = DECOR_PIKACHU_DOLL, + .name = DECORNAME_PIKACHU_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_PIKACHU_DOLL, + .tiles = DecorGfx_PIKACHU_DOLL, + }, + { + .id = DECOR_MARILL_DOLL, + .name = DECORNAME_MARILL_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_MARILL_DOLL, + .tiles = DecorGfx_MARILL_DOLL, + }, + { + .id = DECOR_TOGEPI_DOLL, + .name = DECORNAME_TOGEPI_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_TOGEPI_DOLL, + .tiles = DecorGfx_TOGEPI_DOLL, + }, + { + .id = DECOR_CYNDAQUIL_DOLL, + .name = DECORNAME_CYNDAQUIL_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_CYNDAQUIL_DOLL, + .tiles = DecorGfx_CYNDAQUIL_DOLL, + }, + { + .id = DECOR_CHIKORITA_DOLL, + .name = DECORNAME_CHIKORITA_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_CHIKORITA_DOLL, + .tiles = DecorGfx_CHIKORITA_DOLL, + }, + { + .id = DECOR_TOTODILE_DOLL, + .name = DECORNAME_TOTODILE_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_TOTODILE_DOLL, + .tiles = DecorGfx_TOTODILE_DOLL, + }, + { + .id = DECOR_JIGGLYPUFF_DOLL, + .name = DECORNAME_JIGGLYPUFF_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_JIGGLYPUFF_DOLL, + .tiles = DecorGfx_JIGGLYPUFF_DOLL, + }, + { + .id = DECOR_MEOWTH_DOLL, + .name = DECORNAME_MEOWTH_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_MEOWTH_DOLL, + .tiles = DecorGfx_MEOWTH_DOLL, + }, + { + .id = DECOR_CLEFAIRY_DOLL, + .name = DECORNAME_CLEFAIRY_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_CLEFAIRY_DOLL, + .tiles = DecorGfx_CLEFAIRY_DOLL, + }, + { + .id = DECOR_DITTO_DOLL, + .name = DECORNAME_DITTO_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_DITTO_DOLL, + .tiles = DecorGfx_DITTO_DOLL, + }, + { + .id = DECOR_SMOOCHUM_DOLL, + .name = DECORNAME_SMOOCHUM_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_SMOOCHUM_DOLL, + .tiles = DecorGfx_SMOOCHUM_DOLL, + }, + { + .id = DECOR_TREECKO_DOLL, + .name = DECORNAME_TREECKO_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_TREECKO_DOLL, + .tiles = DecorGfx_TREECKO_DOLL, + }, + { + .id = DECOR_TORCHIC_DOLL, + .name = DECORNAME_TORCHIC_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_TORCHIC_DOLL, + .tiles = DecorGfx_TORCHIC_DOLL, + }, + { + .id = DECOR_MUDKIP_DOLL, + .name = DECORNAME_MUDKIP_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_MUDKIP_DOLL, + .tiles = DecorGfx_MUDKIP_DOLL, + }, + { + .id = DECOR_DUSKULL_DOLL, + .name = DECORNAME_DUSKULL_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_DUSKULL_DOLL, + .tiles = DecorGfx_DUSKULL_DOLL, + }, + { + .id = DECOR_WYNAUT_DOLL, + .name = DECORNAME_WYNAUT_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_WYNAUT_DOLL, + .tiles = DecorGfx_WYNAUT_DOLL, + }, + { + .id = DECOR_BALTOY_DOLL, + .name = DECORNAME_BALTOY_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_BALTOY_DOLL, + .tiles = DecorGfx_BALTOY_DOLL, + }, + { + .id = DECOR_KECLEON_DOLL, + .name = DECORNAME_KECLEON_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_KECLEON_DOLL, + .tiles = DecorGfx_KECLEON_DOLL, + }, + { + .id = DECOR_AZURILL_DOLL, + .name = DECORNAME_AZURILL_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_AZURILL_DOLL, + .tiles = DecorGfx_AZURILL_DOLL, + }, + { + .id = DECOR_SKITTY_DOLL, + .name = DECORNAME_SKITTY_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_SKITTY_DOLL, + .tiles = DecorGfx_SKITTY_DOLL, + }, + { + .id = DECOR_SWABLU_DOLL, + .name = DECORNAME_SWABLU_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_SWABLU_DOLL, + .tiles = DecorGfx_SWABLU_DOLL, + }, + { + .id = DECOR_GULPIN_DOLL, + .name = DECORNAME_GULPIN_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_GULPIN_DOLL, + .tiles = DecorGfx_GULPIN_DOLL, + }, + { + .id = DECOR_LOTAD_DOLL, + .name = DECORNAME_LOTAD_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_LOTAD_DOLL, + .tiles = DecorGfx_LOTAD_DOLL, + }, + { + .id = DECOR_SEEDOT_DOLL, + .name = DECORNAME_SEEDOT_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_SEEDOT_DOLL, + .tiles = DecorGfx_SEEDOT_DOLL, + }, + { + .id = DECOR_PIKA_CUSHION, + .name = DECORNAME_PIKA_CUSHION, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_PIKA_CUSHION, + .tiles = DecorGfx_PIKA_CUSHION, + }, + { + .id = DECOR_ROUND_CUSHION, + .name = DECORNAME_ROUND_CUSHION, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_ROUND_CUSHION, + .tiles = DecorGfx_ROUND_CUSHION, + }, + { + .id = DECOR_KISS_CUSHION, + .name = DECORNAME_KISS_CUSHION, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_KISS_CUSHION, + .tiles = DecorGfx_KISS_CUSHION, + }, + { + .id = DECOR_ZIGZAG_CUSHION, + .name = DECORNAME_ZIGZAG_CUSHION, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_ZIGZAG_CUSHION, + .tiles = DecorGfx_ZIGZAG_CUSHION, + }, + { + .id = DECOR_SPIN_CUSHION, + .name = DECORNAME_SPIN_CUSHION, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_SPIN_CUSHION, + .tiles = DecorGfx_SPIN_CUSHION, + }, + { + .id = DECOR_DIAMOND_CUSHION, + .name = DECORNAME_DIAMOND_CUSHION, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_DIAMOND_CUSHION, + .tiles = DecorGfx_DIAMOND_CUSHION, + }, + { + .id = DECOR_BALL_CUSHION, + .name = DECORNAME_BALL_CUSHION, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_BALL_CUSHION, + .tiles = DecorGfx_BALL_CUSHION, + }, + { + .id = DECOR_GRASS_CUSHION, + .name = DECORNAME_GRASS_CUSHION, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_GRASS_CUSHION, + .tiles = DecorGfx_GRASS_CUSHION, + }, + { + .id = DECOR_FIRE_CUSHION, + .name = DECORNAME_FIRE_CUSHION, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_FIRE_CUSHION, + .tiles = DecorGfx_FIRE_CUSHION, + }, + { + .id = DECOR_WATER_CUSHION, + .name = DECORNAME_WATER_CUSHION, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_WATER_CUSHION, + .tiles = DecorGfx_WATER_CUSHION, + }, + { + .id = DECOR_SNORLAX_DOLL, + .name = DECORNAME_SNORLAX_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_SNORLAX_DOLL, + .tiles = DecorGfx_SNORLAX_DOLL, + }, + { + .id = DECOR_RHYDON_DOLL, + .name = DECORNAME_RHYDON_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_RHYDON_DOLL, + .tiles = DecorGfx_RHYDON_DOLL, + }, + { + .id = DECOR_LAPRAS_DOLL, + .name = DECORNAME_LAPRAS_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_LAPRAS_DOLL, + .tiles = DecorGfx_LAPRAS_DOLL, + }, + { + .id = DECOR_VENUSAUR_DOLL, + .name = DECORNAME_VENUSAUR_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_VENUSAUR_DOLL, + .tiles = DecorGfx_VENUSAUR_DOLL, + }, + { + .id = DECOR_CHARIZARD_DOLL, + .name = DECORNAME_CHARIZARD_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_CHARIZARD_DOLL, + .tiles = DecorGfx_CHARIZARD_DOLL, + }, + { + .id = DECOR_BLASTOISE_DOLL, + .name = DECORNAME_BLASTOISE_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_BLASTOISE_DOLL, + .tiles = DecorGfx_BLASTOISE_DOLL, + }, + { + .id = DECOR_WAILMER_DOLL, + .name = DECORNAME_WAILMER_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_WAILMER_DOLL, + .tiles = DecorGfx_WAILMER_DOLL, + }, + { + .id = DECOR_REGIROCK_DOLL, + .name = DECORNAME_REGIROCK_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_REGIROCK_DOLL, + .tiles = DecorGfx_REGIROCK_DOLL, + }, + { + .id = DECOR_REGICE_DOLL, + .name = DECORNAME_REGICE_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_REGICE_DOLL, + .tiles = DecorGfx_REGICE_DOLL, + }, + { + .id = DECOR_REGISTEEL_DOLL, + .name = DECORNAME_REGISTEEL_DOLL, + .permission = DECORPERM_SOLID_MAT, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_REGISTEEL_DOLL, + .tiles = DecorGfx_REGISTEEL_DOLL, + } +}; diff --git a/src/data/decoration/descriptions_de.h b/src/data/decoration/descriptions_de.h new file mode 100644 index 000000000..4c5559044 --- /dev/null +++ b/src/data/decoration/descriptions_de.h @@ -0,0 +1,699 @@ +const u8 DecorDesc_SMALL_DESK[] = _( + "Ein kleiner Tisch\n" + "für eine Person."); + +const u8 DecorDesc_POKEMON_DESK[] = _( + "Ein kleiner Tisch,\n" + "geformt wie ein\n" + "POKéBALL."); + +const u8 DecorDesc_HEAVY_DESK[] = _( + "Ein großer Tisch\n" + "aus Stahl. Für\n" + "Dekorationen."); + +const u8 DecorDesc_RAGGED_DESK[] = _( + "Ein großer Tisch\n" + "aus Holz. Für\n" + "Dekorationen."); + +const u8 DecorDesc_COMFORT_DESK[] = _( + "Ein riesiger Tisch\n" + "aus Blättern. Für\n" + "Dekorationen."); + +const u8 DecorDesc_PRETTY_DESK[] = _( + "Ein riesiger Tisch\n" + "aus Glas. Trägt\n" + "viele Dekorationen."); + +const u8 DecorDesc_BRICK_DESK[] = _( + "Ein riesiger Tisch\n" + "aus Backstein. Für\n" + "viele Dekorationen."); + +const u8 DecorDesc_CAMP_DESK[] = _( + "Ein riesiger Tisch\n" + "aus Baumstämmen.\n" + "Für Dekorationen."); + +const u8 DecorDesc_HARD_DESK[] = _( + "Ein riesiger Tisch\n" + "aus Stein. Trägt\n" + "viele Dekorationen."); + +const u8 DecorDesc_SMALL_CHAIR[] = _( + "Ein kleiner Stuhl\n" + "für eine Person."); + +const u8 DecorDesc_POKEMON_CHAIR[] = _( + "Ein kleiner Stuhl\n" + "in der Form eines\n" + "POKéBALLS."); + +const u8 DecorDesc_HEAVY_CHAIR[] = _( + "Ein kleiner Stuhl\n" + "aus Stahl."); + +const u8 DecorDesc_PRETTY_CHAIR[] = _( + "Ein kleiner Stuhl\n" + "aus Glas."); + +const u8 DecorDesc_COMFORT_CHAIR[] = _( + "Ein kleiner Stuhl\n" + "aus Blättern."); + +const u8 DecorDesc_RAGGED_CHAIR[] = _( + "Ein kleiner Stuhl\n" + "aus Holz."); + +const u8 DecorDesc_BRICK_CHAIR[] = _( + "Ein kleiner Stuhl\n" + "aus Backstein."); + +const u8 DecorDesc_CAMP_CHAIR[] = _( + "Ein kleiner Stuhl\n" + "aus Baumstämmen."); + +const u8 DecorDesc_HARD_CHAIR[] = _( + "Ein kleiner Stuhl\n" + "aus Stein."); + +const u8 DecorDesc_RED_PLANT[] = _( + "Eine leuchtend\n" + "rote Pflanze."); + +const u8 DecorDesc_TROPICAL_PLANT[] = _( + "Eine blühende,\n" + "tropische Pflanze\n" + "in einem Übertopf."); + +const u8 DecorDesc_PRETTY_FLOWERS[] = _( + "Ein Topf mit\n" + "hübschen Blumen."); + +const u8 DecorDesc_COLORFUL_PLANT[] = _( + "Ein großer Topf mit\n" + "vielen, farben-\n" + "prächtigen Blumen."); + +const u8 DecorDesc_BIG_PLANT[] = _( + "Eine große, schirm-\n" + "förmige Pflanze in\n" + "einem großen Topf."); + +const u8 DecorDesc_GORGEOUS_PLANT[] = _( + "Eine beeindruckend\n" + "große Pflanze in\n" + "einem großen Topf."); + +const u8 DecorDesc_RED_BRICK[] = _( + "Ein roter Back-\n" + "stein. Stelle Deko-\n" + "rationen darauf."); + +const u8 DecorDesc_YELLOW_BRICK[] = _( + "Ein gelber Back-\n" + "stein. Stelle Deko-\n" + "rationen darauf."); + +const u8 DecorDesc_BLUE_BRICK[] = _( + "Ein blauer Back-\n" + "stein. Stelle Deko-\n" + "rationen darauf."); + +const u8 DecorDesc_RED_BALLOON[] = _( + "Ein roter Ballon mit\n" + "Wasser. Platzt beim\n" + "Drauftreten."); + +const u8 DecorDesc_BLUE_BALLOON[] = _( + "Ein blauer Ballon\n" + "mit Wasser. Platzt\n" + "beim Drauftreten."); + +const u8 DecorDesc_YELLOW_BALLOON[] = _( + "Ein gelber Ballon\n" + "mit Wasser. Platzt\n" + "beim Drauftreten."); + +const u8 DecorDesc_RED_TENT[] = _( + "Ein großes, rotes\n" + "Zelt. Darin kann man\n" + "sich verstecken."); + +const u8 DecorDesc_BLUE_TENT[] = _( + "Ein großes, blaues\n" + "Zelt. Darin kann man\n" + "sich verstecken."); + +const u8 DecorDesc_SOLID_BOARD[] = _( + "Leg es über ein\n" + "Loch, um die andere\n" + "Seite zu erreichen."); + +const u8 DecorDesc_SLIDE[] = _( + "Nützlich, um von der\n" + "Plattform hinab-\n" + "gleiten zu können."); + +const u8 DecorDesc_FENCE_LENGTH[] = _( + "Ein kleiner Zaun,\n" + "der den Durchgang\n" + "versperrt."); + +const u8 DecorDesc_FENCE_WIDTH[] = _( + "Ein kleiner Zaun,\n" + "der den Durchgang\n" + "versperrt."); + +const u8 DecorDesc_TIRE[] = _( + "Ein großer, alter\n" + "Reifen. Für\n" + "Dekorationen."); + +const u8 DecorDesc_STAND[] = _( + "Ein Podest mit\n" + "Stufen."); + +const u8 DecorDesc_MUD_BALL[] = _( + "Ein großer Ball aus\n" + "Lehm. Geht kaputt\n" + "beim Drauftreten."); + +const u8 DecorDesc_BREAKABLE_DOOR[] = _( + "Eine verrückte Tür,\n" + "durch die man hin-\n" + "durchlaufen kann."); + +const u8 DecorDesc_SAND_ORNAMENT[] = _( + "Ein Ornament aus\n" + "Sand. Fällt bei\n" + "Kontakt zusammen."); + +const u8 DecorDesc_SILVER_SHIELD[] = _( + "Belohnung für\n" + "50 Siege in Folge im\n" + "DUELLTURM."); + +const u8 DecorDesc_GOLD_SHIELD[] = _( + "Belohnung für\n" + "100 Siege in Folge\n" + "im DUELLTURM."); + +const u8 DecorDesc_GLASS_ORNAMENT[] = _( + "Das Replikat einer\n" + "berühmten Skulptur\n" + "des KUNSTMUSEUMS."); + +const u8 DecorDesc_TV[] = _( + "Ein kleiner, grauer\n" + "Spielzeug-\n" + "Fernseher."); + +const u8 DecorDesc_ROUND_TV[] = _( + "Ein Spielzeug-\n" + "Fernseher in der\n" + "Form von SAMURZEL."); + +const u8 DecorDesc_CUTE_TV[] = _( + "Ein Spielzeug-\n" + "Fernseher in der\n" + "Form eines ENECO."); + +const u8 DecorDesc_GLITTER_MAT[] = _( + "Eine seltsame\n" + "Matte. Glitzert\n" + "beim Drauftreten."); + +const u8 DecorDesc_JUMP_MAT[] = _( + "Eine Trick-Matte,\n" + "die hüpft, wenn man\n" + "drauftritt."); + +const u8 DecorDesc_SPIN_MAT[] = _( + "Eine Trick-Matte,\n" + "die sich beim\n" + "Drauftreten dreht."); + +const u8 DecorDesc_C_LOW_NOTE_MAT[] = _( + "Eine Matte, die das\n" + "tiefe C spielt, wenn\n" + "man drauftritt."); + +const u8 DecorDesc_D_NOTE_MAT[] = _( + "Eine Matte, die\n" + "ein D spielt, wenn\n" + "man drauftritt."); + +const u8 DecorDesc_E_NOTE_MAT[] = _( + "Eine Matte, die\n" + "ein E spielt, wenn\n" + "man drauftritt."); + +const u8 DecorDesc_F_NOTE_MAT[] = _( + "Eine Matte, die\n" + "ein F spielt, wenn\n" + "man drauftritt."); + +const u8 DecorDesc_G_NOTE_MAT[] = _( + "Eine Matte, die\n" + "ein G spielt, wenn\n" + "man drauftritt."); + +const u8 DecorDesc_A_NOTE_MAT[] = _( + "Eine Matte, die\n" + "ein A spielt, wenn\n" + "man drauftritt."); + +const u8 DecorDesc_B_NOTE_MAT[] = _( + "Eine Matte, die\n" + "ein H spielt, wenn\n" + "man drauftritt."); + +const u8 DecorDesc_C_HIGH_NOTE_MAT[] = _( + "Eine Matte, die das\n" + "hohe C spielt, wenn\n" + "man drauftritt."); + +const u8 DecorDesc_SURF_MAT[] = _( + "Eine Matte mit\n" + "einem SURFER-\n" + "Muster. Für Items."); + +const u8 DecorDesc_THUNDER_MAT[] = _( + "Eine Matte mit\n" + "einem DONNER-\n" + "Muster. Für Items."); + +const u8 DecorDesc_FIRE_BLAST_MAT[] = _( + "Eine Matte mit\n" + "FEUERSTURM-\n" + "Muster. Für Items."); + +const u8 DecorDesc_POWDER_SNOW_MAT[] = _( + "Eine Matte mit\n" + "PULVERSCHNEE-\n" + "Muster. Für Items."); + +const u8 DecorDesc_ATTRACT_MAT[] = _( + "Eine Matte mit\n" + "ANZIEHUNG-\n" + "Muster. Für Items."); + +const u8 DecorDesc_FISSURE_MAT[] = _( + "Eine Matte mit\n" + "GEOFISSUR-\n" + "Muster. Für Items."); + +const u8 DecorDesc_SPIKES_MAT[] = _( + "Eine Matte mit\n" + "STACHLER-\n" + "Muster. Für Items."); + +const u8 DecorDesc_BALL_POSTER[] = _( + "Ein kleines Poster\n" + "von POKéBÄLLEN."); + +const u8 DecorDesc_GREEN_POSTER[] = _( + "Ein kleines Poster\n" + "von GECKARBOR."); + +const u8 DecorDesc_RED_POSTER[] = _( + "Ein kleines Poster\n" + "von FLEMMLI."); + +const u8 DecorDesc_BLUE_POSTER[] = _( + "Ein kleines Poster\n" + "von HYDROPI."); + +const u8 DecorDesc_CUTE_POSTER[] = _( + "Ein kleines Poster\n" + "von AZURILL."); + +const u8 DecorDesc_PIKA_POSTER[] = _( + "Ein großes Poster\n" + "von PIKACHU und\n" + "PICHU."); + +const u8 DecorDesc_LONG_POSTER[] = _( + "Ein großes Poster\n" + "von VIPITIS."); + +const u8 DecorDesc_SEA_POSTER[] = _( + "Ein großes Poster\n" + "von RELICANTH."); + +const u8 DecorDesc_SKY_POSTER[] = _( + "Ein großes Poster\n" + "von WINGULL."); + +const u8 DecorDesc_KISS_POSTER[] = _( + "Ein großes Poster\n" + "von KUSSILLA."); + +const u8 DecorDesc_PICHU_DOLL[] = _( + "PICHU-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_PIKACHU_DOLL[] = _( + "PIKACHU-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_MARILL_DOLL[] = _( + "MARILL-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_TOGEPI_DOLL[] = _( + "TOGEPI-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_CYNDAQUIL_DOLL[] = _( + "FEURIGEL-Puppe.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_CHIKORITA_DOLL[] = _( + "ENDIVIE-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_TOTODILE_DOLL[] = _( + "KARNIMANI-Puppe.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_JIGGLYPUFF_DOLL[] = _( + "PUMMELUFF-Puppe.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_MEOWTH_DOLL[] = _( + "MAUZI-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_CLEFAIRY_DOLL[] = _( + "PIEPI-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_DITTO_DOLL[] = _( + "DITTO-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_SMOOCHUM_DOLL[] = _( + "KUSSILLA-Puppe.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_TREECKO_DOLL[] = _( + "GECKARBOR-Puppe.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_TORCHIC_DOLL[] = _( + "FLEMMLI-Puppe.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_MUDKIP_DOLL[] = _( + "HYDROPI-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_DUSKULL_DOLL[] = _( + "ZWIRRLICHT-Puppe.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_WYNAUT_DOLL[] = _( + "ISSO-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_BALTOY_DOLL[] = _( + "PUPPANCE-Puppe.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_KECLEON_DOLL[] = _( + "KECLEON-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_AZURILL_DOLL[] = _( + "AZURILL-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_SKITTY_DOLL[] = _( + "ENECO-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_SWABLU_DOLL[] = _( + "WABLU-Puppe. Leg\n" + "sie auf eine Matte\n" + "oder einen Tisch."); + +const u8 DecorDesc_GULPIN_DOLL[] = _( + "SCHLUPPUCK-Puppe.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_LOTAD_DOLL[] = _( + "LOTURZEL-Puppe.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_SEEDOT_DOLL[] = _( + "SAMURZEL-Puppe.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_PIKA_CUSHION[] = _( + "PIKACHU-Kissen.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_ROUND_CUSHION[] = _( + "MARILL-Kissen.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_KISS_CUSHION[] = _( + "KUSSILLA-Kissen.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_ZIGZAG_CUSHION[] = _( + "ZIGZACHS-Kissen.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_SPIN_CUSHION[] = _( + "PANDIR-Kissen.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_DIAMOND_CUSHION[] = _( + "ZOBIRIS-Kissen.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_BALL_CUSHION[] = _( + "BALL-Kissen.\n" + "Für eine Matte oder\n" + "den Tisch."); + +const u8 DecorDesc_GRASS_CUSHION[] = _( + "Kissen mit Gras-\n" + "muster. Für\n" + "Matte oder Tisch."); + +const u8 DecorDesc_FIRE_CUSHION[] = _( + "Kissen mit Feuer-\n" + "muster. Für\n" + "Matte oder Tisch."); + +const u8 DecorDesc_WATER_CUSHION[] = _( + "Kissen mit Wasser-\n" + "muster. Für\n" + "Matte oder Tisch."); + +const u8 DecorDesc_SNORLAX_DOLL[] = _( + "Große Puppe. Leg\n" + "sie auf eine Matte\n" + "oder den Tisch."); + +const u8 DecorDesc_RHYDON_DOLL[] = _( + "Große Puppe. Leg\n" + "sie auf eine Matte\n" + "oder den Tisch."); + +const u8 DecorDesc_LAPRAS_DOLL[] = _( + "Große Puppe. Leg\n" + "sie auf eine Matte\n" + "oder den Tisch."); + +const u8 DecorDesc_VENUSAUR_DOLL[] = _( + "Große Puppe. Leg\n" + "sie auf eine Matte\n" + "oder den Tisch."); + +const u8 DecorDesc_CHARIZARD_DOLL[] = _( + "Große Puppe. Leg\n" + "sie auf eine Matte\n" + "oder den Tisch."); + +const u8 DecorDesc_BLASTOISE_DOLL[] = _( + "Große Puppe. Leg\n" + "sie auf eine Matte\n" + "oder den Tisch."); + +const u8 DecorDesc_WAILMER_DOLL[] = _( + "Große Puppe. Leg\n" + "sie auf eine Matte\n" + "oder den Tisch."); + +const u8 DecorDesc_REGIROCK_DOLL[] = _( + "Große Puppe. Leg\n" + "sie auf eine Matte\n" + "oder den Tisch."); + +const u8 DecorDesc_REGICE_DOLL[] = _( + "Große Puppe. Leg\n" + "sie auf eine Matte\n" + "oder den Tisch."); + +const u8 DecorDesc_REGISTEEL_DOLL[] = _( + "Große Puppe. Leg\n" + "sie auf eine Matte\n" + "oder den Tisch."); + +#define DECORNAME_SMALL_DESK _("KLEINER TISCH") +#define DECORNAME_POKEMON_DESK _("POKéMONTISCH") +#define DECORNAME_HEAVY_DESK _("SCHWERER TISCH") +#define DECORNAME_RAGGED_DESK _("INTARSIENTISCH") +#define DECORNAME_COMFORT_DESK _("NATURTISCH") +#define DECORNAME_PRETTY_DESK _("EDLER TISCH") +#define DECORNAME_BRICK_DESK _("BACKSTEINTISCH") +#define DECORNAME_CAMP_DESK _("CAMPINGTISCH") +#define DECORNAME_HARD_DESK _("MASSIVER TISCH") +#define DECORNAME_SMALL_CHAIR _("KLEINER STUHL") +#define DECORNAME_POKEMON_CHAIR _("POKéMON STUHL") +#define DECORNAME_HEAVY_CHAIR _("SCHWERER STUHL") +#define DECORNAME_PRETTY_CHAIR _("EDLER STUHL") +#define DECORNAME_COMFORT_CHAIR _("NATURSTUHL") +#define DECORNAME_RAGGED_CHAIR _("INTARSIENSTUHL") +#define DECORNAME_BRICK_CHAIR _("BACKSTEINSTUHL") +#define DECORNAME_CAMP_CHAIR _("CAMPINGSTUHL") +#define DECORNAME_HARD_CHAIR _("MASSIVER STUHL") +#define DECORNAME_RED_PLANT _("ROTE PFLANZE") +#define DECORNAME_TROPICAL_PLANT _("TROPENPFLANZE") +#define DECORNAME_PRETTY_FLOWERS _("HÜBSCHE BLUMEN") +#define DECORNAME_COLORFUL_PLANT _("BUNTE PFLANZE") +#define DECORNAME_BIG_PLANT _("GROSSE PFLANZE") +#define DECORNAME_GORGEOUS_PLANT _("ZIERPFLANZE") +#define DECORNAME_RED_BRICK _("ROTER STEIN") +#define DECORNAME_YELLOW_BRICK _("GELBER STEIN") +#define DECORNAME_BLUE_BRICK _("BLAUER STEIN") +#define DECORNAME_RED_BALLOON _("ROTER BALLON") +#define DECORNAME_BLUE_BALLOON _("BLAUER BALLON") +#define DECORNAME_YELLOW_BALLOON _("GELBER BALLON") +#define DECORNAME_RED_TENT _("ROTES ZELT") +#define DECORNAME_BLUE_TENT _("BLAUES ZELT") +#define DECORNAME_SOLID_BOARD _("SOLIDES BRETT") +#define DECORNAME_SLIDE _("RUTSCHE") +#define DECORNAME_FENCE_LENGTH _("ZAUN VERTIKAL") +#define DECORNAME_FENCE_WIDTH _("ZAUN HORIZONTAL") +#define DECORNAME_TIRE _("REIFEN") +#define DECORNAME_STAND _("PODEST") +#define DECORNAME_MUD_BALL _("LEHMBALL") +#define DECORNAME_BREAKABLE_DOOR _("BRECHBARE TÜR") +#define DECORNAME_SAND_ORNAMENT _("SANDORNAMENT") +#define DECORNAME_SILVER_SHIELD _("SILBERSCHILD") +#define DECORNAME_GOLD_SHIELD _("GOLDSCHILD") +#define DECORNAME_GLASS_ORNAMENT _("GLASORNAMENT") +#define DECORNAME_TV _("FERNSEHER") +#define DECORNAME_ROUND_TV _("RUNDER TV") +#define DECORNAME_CUTE_TV _("HÜBSCHER TV") +#define DECORNAME_GLITTER_MAT _("GLITZER-MATTE") +#define DECORNAME_JUMP_MAT _("SPRUNG-MATTE") +#define DECORNAME_SPIN_MAT _("DREH-MATTE") +#define DECORNAME_C_LOW_NOTE_MAT _("Tiefes C-MATTE") +#define DECORNAME_D_NOTE_MAT _("D-MATTE") +#define DECORNAME_E_NOTE_MAT _("E-MATTE") +#define DECORNAME_F_NOTE_MAT _("F-MATTE") +#define DECORNAME_G_NOTE_MAT _("G-MATTE") +#define DECORNAME_A_NOTE_MAT _("A-MATTE") +#define DECORNAME_B_NOTE_MAT _("H-MATTE") +#define DECORNAME_C_HIGH_NOTE_MAT _("Hohes C-MATTE") +#define DECORNAME_SURF_MAT _("SURFER-MATTE") +#define DECORNAME_THUNDER_MAT _("DONNER-MATTE") +#define DECORNAME_FIRE_BLAST_MAT _("FEUER-MATTE") +#define DECORNAME_POWDER_SNOW_MAT _("SCHNEE-MATTE") +#define DECORNAME_ATTRACT_MAT _("ANZIEHUNG-MAT.") +#define DECORNAME_FISSURE_MAT _("GEOFISSUR-MAT.") +#define DECORNAME_SPIKES_MAT _("STACHLER-MATTE") +#define DECORNAME_BALL_POSTER _("BALLPOSTER") +#define DECORNAME_GREEN_POSTER _("GRÜNES POSTER") +#define DECORNAME_RED_POSTER _("ROTES POSTER") +#define DECORNAME_BLUE_POSTER _("BLAUES POSTER") +#define DECORNAME_CUTE_POSTER _("HÜBSCHES POSTER") +#define DECORNAME_PIKA_POSTER _("PICHUKA-POSTER") +#define DECORNAME_LONG_POSTER _("SCHLANG-POSTER") +#define DECORNAME_SEA_POSTER _("MEER-POSTER") +#define DECORNAME_SKY_POSTER _("HIMMEL-POSTER") +#define DECORNAME_KISS_POSTER _("KUSS-POSTER") +#define DECORNAME_PICHU_DOLL _("PICHU-PUPPE") +#define DECORNAME_PIKACHU_DOLL _("PIKACHU-PUPPE") +#define DECORNAME_MARILL_DOLL _("MARILL-PUPPE") +#define DECORNAME_TOGEPI_DOLL _("TOGEPI-PUPPE") +#define DECORNAME_CYNDAQUIL_DOLL _("FEURIGEL-PUPPE") +#define DECORNAME_CHIKORITA_DOLL _("ENDIVIE-PUPPE") +#define DECORNAME_TOTODILE_DOLL _("KARNIMANIPUPPE") +#define DECORNAME_JIGGLYPUFF_DOLL _("PUMMELUFFPUPPE") +#define DECORNAME_MEOWTH_DOLL _("MAUZI-PUPPE") +#define DECORNAME_CLEFAIRY_DOLL _("PIEPI-PUPPE") +#define DECORNAME_DITTO_DOLL _("DITTO-PUPPE") +#define DECORNAME_SMOOCHUM_DOLL _("KUSSILLA-PUPPE") +#define DECORNAME_TREECKO_DOLL _("GECKARBOR-PUPP.") +#define DECORNAME_TORCHIC_DOLL _("FLEMMLI-PUPPE") +#define DECORNAME_MUDKIP_DOLL _("HYDROPI-PUPPE") +#define DECORNAME_DUSKULL_DOLL _("ZWIRRLICHTPUP.") +#define DECORNAME_WYNAUT_DOLL _("ISSO-PUPPE") +#define DECORNAME_BALTOY_DOLL _("PUPPANCE-PUPPE") +#define DECORNAME_KECLEON_DOLL _("KECLEON-PUPPE") +#define DECORNAME_AZURILL_DOLL _("AZURILL-PUPPE") +#define DECORNAME_SKITTY_DOLL _("ENECO-PUPPE") +#define DECORNAME_SWABLU_DOLL _("WABLU-PUPPE") +#define DECORNAME_GULPIN_DOLL _("SCHLUPPUCKPUP.") +#define DECORNAME_LOTAD_DOLL _("LOTURZEL-PUPPE") +#define DECORNAME_SEEDOT_DOLL _("SAMURZEL-PUPPE") +#define DECORNAME_PIKA_CUSHION _("PIKA-KISSEN") +#define DECORNAME_ROUND_CUSHION _("RUNDES KISSEN") +#define DECORNAME_KISS_CUSHION _("KUSS-KISSEN") +#define DECORNAME_ZIGZAG_CUSHION _("ZIGZACHS-KISS.") +#define DECORNAME_SPIN_CUSHION _("KREISEL-KISSEN") +#define DECORNAME_DIAMOND_CUSHION _("DIAMANT-KISSEN") +#define DECORNAME_BALL_CUSHION _("BALL-KISSEN") +#define DECORNAME_GRASS_CUSHION _("PFLANZEN-KISS.") +#define DECORNAME_FIRE_CUSHION _("FEUER-KISSEN") +#define DECORNAME_WATER_CUSHION _("WASSER-KISSEN") +#define DECORNAME_SNORLAX_DOLL _("RELAXO-PUPPE") +#define DECORNAME_RHYDON_DOLL _("RIZEROS-PUPPE") +#define DECORNAME_LAPRAS_DOLL _("LAPRAS-PUPPE") +#define DECORNAME_VENUSAUR_DOLL _("BISAFLOR-PUPPE") +#define DECORNAME_CHARIZARD_DOLL _("GLURAK-PUPPE") +#define DECORNAME_BLASTOISE_DOLL _("TURTOK-PUPPE") +#define DECORNAME_WAILMER_DOLL _("WAILMER-PUPPE") +#define DECORNAME_REGIROCK_DOLL _("REGIROCK-PUPPE") +#define DECORNAME_REGICE_DOLL _("REGICE-PUPPE") +#define DECORNAME_REGISTEEL_DOLL _("REGISTEEL-PUPP.") diff --git a/src/data/pokedex_entries_de.h b/src/data/pokedex_entries_de.h new file mode 100644 index 000000000..38263ec6e --- /dev/null +++ b/src/data/pokedex_entries_de.h @@ -0,0 +1,7955 @@ +static const u8 DexDescription_Dummy_1[] = _( + "Dieses POKéMON wurde erst vor kurzem \n" + "entdeckt und wird noch erforscht."); +static const u8 DexDescription_Dummy_2[] = _( + "Zur Zeit sind keine genauen\n" + "Informationen über dieses\n" + "POKéMON vorhanden."); + +static const u8 DexDescription_Bisasam_1[] = _( + "BISASAM macht gern einmal ein\n" + "Nickerchen im Sonnenschein.\n" + "Auf seinem Rücken trägt es einen Samen."); +static const u8 DexDescription_Bisasam_2[] = _( + "Indem es Sonnenstrahlen aufsaugt,\n" + "wird der Samen zunehmend größer."); + +static const u8 DexDescription_Bisaknosp_1[] = _( + "BISAKNOSP hat eine Knospe auf seinem\n" + "Rücken. Beine und Rumpf sind kräftig\n" + "genug, um sein Gewicht zu tragen."); +static const u8 DexDescription_Bisaknosp_2[] = _( + "Wenn es lange in der Sonne liegt, ist das\n" + "ein Anzeichen dafür, dass die Knospe\n" + "bald blüht."); + +static const u8 DexDescription_Bisaflor_1[] = _( + "BISAFLOR hat eine Blume auf seinem\n" + "Rücken. Wenn sie viel Nahrung und Sonne\n" + "aufnimmt, verfärbt sie sich bunt."); +static const u8 DexDescription_Bisaflor_2[] = _( + "Der Duft der Blume mildert die Emotionen\n" + "der Menschen."); + +static const u8 DexDescription_Glumanda_1[] = _( + "Die Flamme auf seiner Schweifspitze\n" + "zeigt seine Gefühlslage an. Sie\n" + "flackert, wenn GLUMANDA zufrieden ist."); +static const u8 DexDescription_Glumanda_2[] = _( + "Wenn dieses POKéMON wütend wird, lodert\n" + "die Flamme gewaltig."); + +static const u8 DexDescription_Glutexo_1[] = _( + "Gnadenlos besiegt GLUTEXO seine Geg-\n" + "ner mit seinen scharfen Klauen. Wenn es \n" + "auf starke Gegner trifft, wird es"); +static const u8 DexDescription_Glutexo_2[] = _( + "wütend und die Flamme auf seiner\n" + "Schweifspitze flackert in einem\n" + "bläulichen Ton."); + +static const u8 DexDescription_Glurak_1[] = _( + "GLURAK fliegt durch die Lüfte, um\n" + "starke Gegner aufzuspüren. Sein heißer\n" + "Feueratem bringt alles zum Schmelzen."); +static const u8 DexDescription_Glurak_2[] = _( + "Aber es richtet seinen Feueratem nie\n" + "auf schwächere Gegner."); + +static const u8 DexDescription_Schiggy_1[] = _( + "SCHIGGYs Panzer dient nicht nur zum\n" + "Schutz. Die runde Form und die Furchen\n" + "auf der Oberfläche verringern den"); +static const u8 DexDescription_Schiggy_2[] = _( + "Widerstand im Wasser, so dass dieses\n" + "POKéMON sehr schnell schwimmen kann."); + +static const u8 DexDescription_Schillok_1[] = _( + "SCHILLOK hat einen langen, buschigen\n" + "Schweif, dessen Farbe intensiver wird,\n" + "wenn es altert."); +static const u8 DexDescription_Schillok_2[] = _( + "Die Kratzer auf seinem Panzer zeugen\n" + "von seiner Kampfkraft."); + +static const u8 DexDescription_Turtok_1[] = _( + "TURTOK besitzt Wasserdüsen, die aus\n" + "seinem Panzer herausragen. Diese sind\n" + "sehr präzise."); +static const u8 DexDescription_Turtok_2[] = _( + "Es kann Wassergeschosse so genau\n" + "verschießen, dass es damit aus fast\n" + "50 Metern leere Dosen trifft."); + +static const u8 DexDescription_Raupy_1[] = _( + "RAUPY ist sehr gefräßig, es kann\n" + "Blätter verschlingen, die größer sind\n" + "als es selbst."); +static const u8 DexDescription_Raupy_2[] = _( + "Seine Antennen sondern einen\n" + "übel riechenden Gestank ab."); + +static const u8 DexDescription_Safcon_1[] = _( + "Der Panzer dieses POKéMON ist hart wie\n" + "Stahl. SAFCON bewegt sich kaum,"); +static const u8 DexDescription_Safcon_2[] = _( + "da es das weiche Innere unter seiner\n" + "harten Schale auf seine Entwicklung \n" + "vorbereitet."); + +static const u8 DexDescription_Smettbo_1[] = _( + "SMETTBOs größte Fähigkeit ist das Auf-\n" + "spüren köstlichen Blütenhonigs."); +static const u8 DexDescription_Smettbo_2[] = _( + "Es findet sogar Honig in Blumen, die\n" + "fast 10 km von seinem Nest entfernt\n" + "blühen."); + +static const u8 DexDescription_Hornliu_1[] = _( + "HORNLIU verfügt über einen ausge-\n" + "zeichneten Geruchssinn. So kann es\n" + "seine Lieblingsblätter von denen"); +static const u8 DexDescription_Hornliu_2[] = _( + "unterscheiden, die es nicht mag, indem\n" + "es mit seiner großen roten Nase daran\n" + "schnuppert."); + +static const u8 DexDescription_Kokuna_1[] = _( + "KOKUNA bewegt sich kaum, wenn es an\n" + "einem Baum haftet. In seinem Inneren\n" + "jedoch regt sich einiges, da es sich auf"); +static const u8 DexDescription_Kokuna_2[] = _( + "seine bevorstehende Entwicklung vor-\n" + "bereitet. Dabei wird seine Schale sehr\n" + "heiß."); + +static const u8 DexDescription_Bibor_1[] = _( + "BIBOR sind sehr wehrhaft. Es sollte sich\n" + "besser niemand ihrem Nest nähern."); +static const u8 DexDescription_Bibor_2[] = _( + "Wenn man sie ärgert, greifen sie in\n" + "Schwärmen an."); + +static const u8 DexDescription_Taubsi_1[] = _( + "TAUBSI verfügt über einen sehr ge-\n" + "schulten Orientierungssinn. Es kehrt \n" + "zielsicher zu seinem Nest zurück,"); +static const u8 DexDescription_Taubsi_2[] = _( + "egal, wie weit es sich von seiner\n" + "gewohnten Umgebung entfernt hat."); + +static const u8 DexDescription_Tauboga_1[] = _( + "TAUBOGA nennt ein großes Gebiet sein\n" + "Eigen. Es fliegt umher und kontrolliert\n" + "seinen Lebensraum."); +static const u8 DexDescription_Tauboga_2[] = _( + "Wenn jemand sein Gebiet betritt, zeigt\n" + "es keine Gnade und greift seine Gegner\n" + "mit seinen scharfen Krallen an."); + +static const u8 DexDescription_Tauboss_1[] = _( + "Dieses POKéMON hat ein wunderschönes, \n" + "glänzendes Gefieder.\n" + "Viele TRAINER sind von der auffälligen"); +static const u8 DexDescription_Tauboss_2[] = _( + "Schönheit seines Federkleids begeis-\n" + "tert, so dass sie TAUBOSS als ihr\n" + "POKéMON wählen."); + +static const u8 DexDescription_Rattfratz_1[] = _( + "RATTFRATZ ist extrem vorsichtig. Sogar\n" + "im Schlaf nimmt es alles wahr, indem es\n" + "seine Ohren bewegt."); +static const u8 DexDescription_Rattfratz_2[] = _( + "Es stellt keine großen Ansprüche an\n" + "seinen Lebensraum und richtet sein\n" + "Nest überall ein."); + +static const u8 DexDescription_Rattikarl_1[] = _( + "RATTIKARLs kräftige Zähne wachsen\n" + "ständig. Deshalb nagt es unablässig\n" + "Steine und Baumstämme an,"); +static const u8 DexDescription_Rattikarl_2[] = _( + "um sie abzuwetzen. Manchmal knabbert\n" + "es sogar Hauswände an."); + +static const u8 DexDescription_Habitak_1[] = _( + "HABITAK kann einen sehr lauten Schrei\n" + "ausstoßen, den man über die Entfernung\n" + "von 1 km vernehmen kann."); +static const u8 DexDescription_Habitak_2[] = _( + "Durch das Echo seiner hohen, wehklagen-\n" + "den Schreie warnt dieses POKéMON seine\n" + "Artgenossen vor drohender Gefahr."); + +static const u8 DexDescription_Ibitak_1[] = _( + "IBITAK erkennt man an seinem langen \n" + "Hals und Schnabel. \n" + "Er ist hervorragend dafür geeignet,"); +static const u8 DexDescription_Ibitak_2[] = _( + "im Erdreich oder im Wasser Beute zu\n" + "jagen. Es setzt seinen langen, dünnen\n" + "Schnabel dabei sehr geschickt ein."); + +static const u8 DexDescription_Rettan_1[] = _( + "RETTAN rollt sich zu einer Spirale zu-\n" + "sammen, wenn es sich ausruht.\n" + "Aus dieser Haltung kann es blitzschnell"); +static const u8 DexDescription_Rettan_2[] = _( + "auf Bedrohungen aus allen Richtungen\n" + "reagieren, indem es seinen Kopf hebt."); + +static const u8 DexDescription_Arbok_1[] = _( + "Dieses POKéMON ist unheimlich stark. Es\n" + "kann seine Beute mit seinem Körper um-\n" + "wickeln und sogar Ölfässer zerdrücken."); +static const u8 DexDescription_Arbok_2[] = _( + "Wenn ARBOK einen Gegner umwickelt, ist\n" + "es unmöglich, seinem Würgegriff zu ent-\n" + "kommen."); + +static const u8 DexDescription_Pikachu_1[] = _( + "Immer wenn PIKACHU auf etwas Neues\n" + "stößt, jagt es einen Elektroschock \n" + "hindurch."); +static const u8 DexDescription_Pikachu_2[] = _( + "Wenn du eine verkohlte Beere findest,\n" + "hat dieses POKéMON seine elektrische\n" + "Ladung falsch eingeschätzt."); + +static const u8 DexDescription_Raichu_1[] = _( + "Wenn seine elektrische Ladung zu groß\n" + "wird, entlädt RAICHU seine Energie ins\n" + "Erdreich."); +static const u8 DexDescription_Raichu_2[] = _( + "Neben dem Nest dieses POKéMON findet\n" + "man häufig versengtes Erdreich."); + +static const u8 DexDescription_Sandan_1[] = _( + "SANDANs Körper kann sehr viel Wasser\n" + "aufnehmen, so dass es auch in der\n" + "Wüste überleben kann."); +static const u8 DexDescription_Sandan_2[] = _( + "Dieses POKéMON rollt sich zusammen, um\n" + "sich vor Feinden zu schützen."); + +static const u8 DexDescription_Sandamer_1[] = _( + "SANDAMERs Körper ist übersät\n" + "mit spitzen Stacheln, die eigentlich\n" + "Hauthärtungen darstellen."); +static const u8 DexDescription_Sandamer_2[] = _( + "Einmal im Jahr fallen die alten Stacheln\n" + "aus und werden durch neue ersetzt."); + +static const u8 DexDescription_NidoranF_1[] = _( + "NIDORAN besitzt Widerhaken, die ein\n" + "starkes Gift ausstoßen. Sie sind ver-\n" + "mutlich zum Schutz dieses"); +static const u8 DexDescription_NidoranF_2[] = _( + "schmächtigen POKéMON entstanden.\n" + "Wenn es wütend wird, stößt es ein\n" + "gefährliches Gift aus seinem Horn aus."); + +static const u8 DexDescription_Nidorina_1[] = _( + "Wenn NIDORINA mit seinen Freunden oder\n" + "seiner Familie zusammen ist, zieht\n" + "es seine Widerhaken ein, damit es"); +static const u8 DexDescription_Nidorina_2[] = _( + "niemanden verletzt. Dieses\n" + "POKéMON wird nervös, wenn man es\n" + "von seinen Artgenossen trennt."); + +static const u8 DexDescription_Nidoqueen_1[] = _( + "NIDOQUEENs Körper ist mit sehr harten\n" + "Schuppen bedeckt. Es ist sehr ge-\n" + "schickt darin, Gegner mit starken"); +static const u8 DexDescription_Nidoqueen_2[] = _( + "Attacken wegzuschleudern.\n" + "Dieses POKéMON entwickelt am meisten\n" + "Kraft, wenn es seine Jungen verteidigt."); + +static const u8 DexDescription_NidoranM_1[] = _( + "Das männliche NIDORAN hat Muskeln ent-\n" + "wickelt, um seine Ohren bewegen zu kön-\n" + "nen. Dadurch kann es sie in jede beliebi-"); +static const u8 DexDescription_NidoranM_2[] = _( + "ge Richtung drehen. Diesem POKéMON \n" + "entgeht nicht einmal das leiseste Ge-\n" + "räusch."); + +static const u8 DexDescription_Nidorino_1[] = _( + "NIDORINO besitzt ein Horn, das sogar\n" + "härter ist als ein Diamant. Wenn es\n" + "einen Feind wahrnimmt, stellen sich"); +static const u8 DexDescription_Nidorino_2[] = _( + "all die Widerhaken auf seinem Rücken\n" + "auf und es schlägt den Gegner mit aller\n" + "Kraft in die Flucht."); + +static const u8 DexDescription_Nidoking_1[] = _( + "NIDOKINGs Schweif ist enorm stark. Mit\n" + "einer Bewegung kann es einen metalle-\n" + "nen Sendemast zum Einsturz bringen."); +static const u8 DexDescription_Nidoking_2[] = _( + "Wenn es in Rage gerät, ist es nur schwer\n" + "aufzuhalten."); + +static const u8 DexDescription_Piepi_1[] = _( + "In Vollmondnächten sammeln sich einige\n" + "dieser POKéMON, um zu spielen. Wird es \n" + "Tag, kehrt PIEPI zu seinem Zufluchts-"); +static const u8 DexDescription_Piepi_2[] = _( + "ort in den Bergen zurück und\n" + "schläft eingekuschelt neben\n" + "seinen Artgenossen ein."); + +static const u8 DexDescription_Pixi_1[] = _( + "PIXI bewegt sich fort, indem es leicht\n" + "mit den Flügeln schlägt. Durch seinen\n" + "federnden Gang kann es sogar über"); +static const u8 DexDescription_Pixi_2[] = _( + "Wasser gehen. Bei Mondschein \n" + "unternimmt es Spaziergänge auf Seen."); + +static const u8 DexDescription_Vulpix_1[] = _( + "VULPIX kommt mit einem weißen Schweif\n" + "zur Welt. Dieser teilt sich sechsfach, \n" + "wenn das POKéMON von seinem TRAINER"); +static const u8 DexDescription_Vulpix_2[] = _( + "viel Zuneigung bekommt.\n" + "Seine sechs Schweife kräuseln sich\n" + "schließlich."); + +static const u8 DexDescription_Vulnona_1[] = _( + "VULNONA sendet einen unheimlichen\n" + "Lichtstrahl aus seinen hellroten Augen\n" + "aus, um totale Kontrolle über die"); +static const u8 DexDescription_Vulnona_2[] = _( + "Gedanken seines Gegners zu erlangen.\n" + "Man sagt, dieses POKéMON könne 1000\n" + "Jahre leben."); + +static const u8 DexDescription_Pummeluff_1[] = _( + "PUMMELUFFs Stimmbänder können die\n" + "Tonlage seiner Stimme beliebig vari-\n" + "ieren. Dieses POKéMON benutzt diese"); +static const u8 DexDescription_Pummeluff_2[] = _( + "Fähigkeit, um seine Gegner mit monoto-\n" + "nem Gesang in Tiefschlaf zu versetzen."); + +static const u8 DexDescription_Knuddeluff_1[] = _( + "KNUDDELUFF hat handtellergroße Augen,\n" + "die immer mit Tränenflüssigkeit bedeckt\n" + "sind. Gerät Staub in die Augen dieses"); +static const u8 DexDescription_Knuddeluff_2[] = _( + "POKéMON, so wird dieser sofort ausge-\n" + "spült."); + +static const u8 DexDescription_Zubat_1[] = _( + "Tagsüber bleibt ZUBAT an einem dunklen\n" + "Ort und bewegt sich kaum. Wenn es dem \n" + "Sonnenlicht längere Zeit ausgesetzt"); +static const u8 DexDescription_Zubat_2[] = _( + "wird, zieht es sich Verbrennungen an\n" + "seinem Körper zu."); + +static const u8 DexDescription_Golbat_1[] = _( + "GOLBAT hat es auf das Blut von Lebe-\n" + "wesen abgesehen. Im Schutze der Nacht\n" + "wird es besonders aktiv."); +static const u8 DexDescription_Golbat_2[] = _( + "Dieses POKéMON fliegt durch die\n" + "Nacht, um nach frischem Blut zu\n" + "suchen."); + +static const u8 DexDescription_Myrapla_1[] = _( + "Am Tage vergräbt sich MYRAPLA im Boden,\n" + "um mit seinem ganzen Körper Nahrung\n" + "aufzunehmen."); +static const u8 DexDescription_Myrapla_2[] = _( + "Je fruchtbarer der Boden ist, desto\n" + "glänzender werden seine Blätter."); + +static const u8 DexDescription_Duflor_1[] = _( + "DUFLOR produziert einen Ekel\n" + "erregenden Gestank aus dem Stempel\n" + "seiner Blume. Wenn es in Gefahr gerät,"); +static const u8 DexDescription_Duflor_2[] = _( + "wird der Gestank noch unerträglicher. \n" + "Wenn sich dieses POKéMON in Sicherheit\n" + "befindet, stößt es keinen Gestank aus."); + +static const u8 DexDescription_Giflor_1[] = _( + "GIFLORs giftige Pollen rufen böse\n" + "allergische Anfälle hervor. Deshalb ist\n" + "es ratsam, sich keiner schönen Blume im"); +static const u8 DexDescription_Giflor_2[] = _( + "Dschungel zu nähern, so anziehend sie\n" + "auch sein mag."); + +static const u8 DexDescription_Paras_1[] = _( + "Auf PARAS’ Rücken wachsen parasitäre\n" + "Pilze, die Tochukaso genannt werden.\n" + "Sie wachsen, indem sie dem"); +static const u8 DexDescription_Paras_2[] = _( + "KÄFER/PFLANZEN-PKMN Nährstoffe\n" + "entziehen. Sie sind sehr wertvoll als\n" + "lebensverlängernde Medizin."); + +static const u8 DexDescription_Parasek_1[] = _( + "PARASEK sucht große Bäume heim und\n" + "entzieht Nährstoffe aus Stamm und \n" + "Wurzeln."); +static const u8 DexDescription_Parasek_2[] = _( + "Wenn ein befallener Baum stirbt, sucht\n" + "es sich zusammen mit seinen Artge-\n" + "nossen einen neuen Wirt."); + +static const u8 DexDescription_Bluzuk_1[] = _( + "BLUZUK hat einen Pelz aus dünnen\n" + "Borsten entwickelt, der dem Schutz\n" + "seines Körpers dient."); +static const u8 DexDescription_Bluzuk_2[] = _( + "Es hat große Augen, denen auch winzig\n" + "kleine Beute nicht entgeht."); + +static const u8 DexDescription_Omot_1[] = _( + "OMOT ist ein nachtaktives POKéMON.\n" + "Kleine Insekten, die vom Licht in der\n" + "Dunkelheit angezogen Straßenlaternen"); +static const u8 DexDescription_Omot_2[] = _( + "umschwärmen, sind seine bevorzugte\n" + "Beute."); + +static const u8 DexDescription_Digda_1[] = _( + "DIGDA wird zumeist auf Farmen\n" + "gezüchtet. Denn wo auch immer dieses\n" + "POKéMON zu graben beginnt, hinterlässt"); +static const u8 DexDescription_Digda_2[] = _( + "es Erde, die für das Anpflanzen von\n" + "Feldfrüchten perfekt geeignet und für\n" + "den Anbau köstlichen Gemüses ideal ist."); + +static const u8 DexDescription_Digdri_1[] = _( + "DIGDRI sind Drillinge, die aus einem\n" + "Körper entstanden sind. Daher denken\n" + "alle Köpfe gleich."); +static const u8 DexDescription_Digdri_2[] = _( + "Sie arbeiten so gut zusammen, dass sie \n" + "endlos graben können."); + +static const u8 DexDescription_Mauzi_1[] = _( + "MAUZI zieht seine scharfen Krallen ein,\n" + "um umherschleichen zu können, ohne\n" + "verräterische Spuren zu hinterlassen."); +static const u8 DexDescription_Mauzi_2[] = _( + "Dieses POKéMON hat eine Vorliebe für\n" + "Münzen, die im Licht glitzern."); + +static const u8 DexDescription_Snobilikat_1[] = _( + "SNOBILIKAT hat sechs dicke Schnurr-\n" + "haare, wodurch es Furcht einflößend\n" + "wirkt. Durch diese nimmt es wahr, wenn"); +static const u8 DexDescription_Snobilikat_2[] = _( + "sich etwas in seiner Nähe bewegt. Es\n" + "wird sehr zutraulich, wenn man es an den\n" + "Schnurrhaaren berührt."); + +static const u8 DexDescription_Enton_1[] = _( + "ENTON verwendet eine geheimnisvolle\n" + "Kraft. Dabei erzeugt es Gehirnströme,\n" + "die man sonst nur von Schlafenden"); +static const u8 DexDescription_Enton_2[] = _( + "kennt. Diese Entdeckung führte zu \n" + "einer umstrittenen Diskussion unter\n" + "Wissenschaftlern."); + +static const u8 DexDescription_Entoron_1[] = _( + "Die schwimmhäutigen Flossen an seinen\n" + "Vorder- und Hinterbeinen und der \n" + "stromlinienförmige Körper machen"); +static const u8 DexDescription_Entoron_2[] = _( + "ENTORON unheimlich schnell. Dieses\n" + "POKéMON ist auf jeden Fall schneller als\n" + "die meisten Hochleistungsschwimmer."); + +static const u8 DexDescription_Menki_1[] = _( + "Wenn MENKI sich schüttelt und schwer\n" + "durch die Nase atmet, dann ist es \n" + "wütend. Da es blitzartig in Raserei"); +static const u8 DexDescription_Menki_2[] = _( + "gerät, ist es unmöglich seinem Zorn\n" + "zu entkommen."); + +static const u8 DexDescription_Rasaff_1[] = _( + "Wenn RASAFF wütend ist, wird seine Blut-\n" + "zirkulation gesteigert und seine Mus-\n" + "keln werden noch stärker."); +static const u8 DexDescription_Rasaff_2[] = _( + "Allerdings mindert das auch die \n" + "Fähigkeit zum logischen Denken."); + +static const u8 DexDescription_Fukano_1[] = _( + "FUKANO hat einen ausgezeichneten Ge-\n" + "ruchssinn. Wenn dieses POKéMON ein-\n" + "mal einen Geruch wahrgenommen hat,"); +static const u8 DexDescription_Fukano_2[] = _( + "vergisst es ihn nicht mehr. Es benutzt\n" + "diese Fähigkeit dazu, die Gefühlslage\n" + "von Lebewesen auszuloten."); + +static const u8 DexDescription_Arkani_1[] = _( + "ARKANI ist sehr schnell. Es kann an\n" + "einem Tag fast 10.000 km zurücklegen.\n" + "Das Feuer, das im Innern dieses POKéMON"); +static const u8 DexDescription_Arkani_2[] = _( + "lodert, dient ihm als Energiequelle."); + +static const u8 DexDescription_Quapsel_1[] = _( + "QUAPSEL hat eine sehr dünne Haut.\n" + "Durch sie hindurch kann man sogar sein\n" + "spiralförmiges Inneres sehen."); +static const u8 DexDescription_Quapsel_2[] = _( + "Obwohl seine Haut so dünn ist, ist sie\n" + "sehr elastisch. Selbst scharfe Reiß-\n" + "zähne können sie nicht durchdringen."); + +static const u8 DexDescription_Quaputzi_1[] = _( + "QUAPUTZIs Körper ist immer feucht und\n" + "glitschig. Dadurch kann es während\n" + "eines Kampfes leicht der Umklammerung"); +static const u8 DexDescription_Quaputzi_2[] = _( + "eines Gegners entkommen."); + +static const u8 DexDescription_Quappo_1[] = _( + "QUAPPO besitzt hochentwickelte, starke\n" + "Muskeln, die niemals ermüden, egal, wie\n" + "sehr es sie auch beansprucht."); +static const u8 DexDescription_Quappo_2[] = _( + "Es ist so kräftig, dass es mühelos den\n" + "Pazifik durchschwimmen kann."); + +static const u8 DexDescription_Abra_1[] = _( + "ABRA schläft 18 Stunden am Tag.\n" + "Es nimmt die Gegenwart von Feinden\n" + "aber auch im Schlaf wahr."); +static const u8 DexDescription_Abra_2[] = _( + "In einer solchen Situation bringt es\n" + "sich umgehend mit TELEPORT in\n" + "Sicherheit."); + +static const u8 DexDescription_Kadabra_1[] = _( + "KADABRA sendet Alphawellen aus, wenn es\n" + "Kopfschmerzen hat. Nur wer eine beson-\n" + "ders starke Psyche hat, kann"); +static const u8 DexDescription_Kadabra_2[] = _( + "dieses POKéMON unter seine Fittiche\n" + "nehmen."); + +static const u8 DexDescription_Simsala_1[] = _( + "SIMSALAs Gehirn hört nicht auf zu\n" + "wachsen, so dass sein Kopf zu schwer\n" + "für seine Nackenmuskulatur wird."); +static const u8 DexDescription_Simsala_2[] = _( + "Dieses POKéMON hält seinen Kopf mit\n" + "psychokinetischer Energie aufrecht."); + +static const u8 DexDescription_Machollo_1[] = _( + "MACHOLLOs Muskeln sind etwas Beson-\n" + "deres. Sie schmerzen nie, egal, wie sehr\n" + "sie beansprucht werden."); +static const u8 DexDescription_Machollo_2[] = _( + "Dieses POKéMON hat genug Kraft, um 100\n" + "Erwachsene umherzuwerfen."); + +static const u8 DexDescription_Maschock_1[] = _( + "MASCHOCKs starke Muskeln sind so hart\n" + "wie Stahl. Dieses POKéMON hat so viel\n" + "Kraft, dass es mit nur einem Finger"); +static const u8 DexDescription_Maschock_2[] = _( + "einen Sumo-Ringer in der Luft halten\n" + "kann."); + +static const u8 DexDescription_Machomei_1[] = _( + "MACHOMEI hat genug Kraft, um alles \n" + "Mögliche zu stemmen. Bei Tätigkeiten,\n" + "die Geschick und Sorgfalt erfordern,"); +static const u8 DexDescription_Machomei_2[] = _( + "machen es ihm seine Arme jedoch nicht\n" + "leicht. Dieses POKéMON neigt dazu,\n" + "zuerst zu handeln und dann zu denken."); + +static const u8 DexDescription_Knofensa_1[] = _( + "KNOFENSAs schlanker und elastischer\n" + "Körper ermöglicht es ihm, jedem\n" + "Angriff auszuweichen, so heftig dieser"); +static const u8 DexDescription_Knofensa_2[] = _( + "auch sein mag. Dieses POKéMON spuckt\n" + "eine ätzende Flüssigkeit aus, die sogar\n" + "Eisen zersetzen kann."); + +static const u8 DexDescription_Ultrigaria_1[] = _( + "ULTRIGARIA hat einen großen Haken\n" + "an seinem Hinterteil. Nachts hängt\n" + "sich dieses POKéMON zum Schlafen an"); +static const u8 DexDescription_Ultrigaria_2[] = _( + "einen Ast. Wenn es sich im Schlaf be-\n" + "wegt, kann es passieren, dass es auf\n" + "dem Boden wieder aufwacht."); + +static const u8 DexDescription_Sarzenia_1[] = _( + "Aus SARZENIAs Kopf ragt eine lange\n" + "Ranke hervor. Diese schwingt hin und \n" + "her, als ob sie etwas fangen"); +static const u8 DexDescription_Sarzenia_2[] = _( + "möchte. Wenn sich ahnungslose Beute \n" + "nähert, wird sie von diesem POKéMON\n" + "im Ganzen verschlungen."); + +static const u8 DexDescription_Tentacha_1[] = _( + "TENTACHAs Körper setzt sich zum größ-\n" + "ten Teil aus Wasser zusammen. Wenn es\n" + "das Meer verlässt, vertrocknet es."); +static const u8 DexDescription_Tentacha_2[] = _( + "Wenn dieses POKéMON auszutrocknen be-\n" + "ginnt, sollte man es schnell wieder ins\n" + "Wasser zurückbringen."); + +static const u8 DexDescription_Tentoxa_1[] = _( + "TENTOXA hat große, rote Kugeln auf \n" + "seinem Kopf. Sie glühen auf, bevor sie \n" + "seine Gegner mit Ultraschall"); +static const u8 DexDescription_Tentoxa_2[] = _( + "erschüttern. Ein Ausbruch dieses \n" + "POKéMON erzeugt starke Wellen \n" + "in seiner Umgebung."); + +static const u8 DexDescription_Kleinstein_1[] = _( + "Je länger ein KLEINSTEIN lebt, desto\n" + "mehr wird seine raue Oberfläche ab-\n" + "geschliffen, so dass es runder wird."); +static const u8 DexDescription_Kleinstein_2[] = _( + "Das Herz dieses POKéMON bleibt aber\n" + "für immer versteinert, hart und rau."); + +static const u8 DexDescription_Georok_1[] = _( + "GEOROK wächst, indem es sich von Stei-\n" + "nen ernährt. Am liebsten mag es Steine,\n" + "die mit Moos überzogen sind."); +static const u8 DexDescription_Georok_2[] = _( + "Dieses POKéMON frisst sich täglich\n" + "durch eine riesige Menge von Steinen."); + +static const u8 DexDescription_Geowaz_1[] = _( + "GEOWAZ lebt hoch in den Bergen. Gibt es \n" + "ein starkes Erdbeben, rollt dieses\n" + "POKéMON so lange den Berg hinunter,"); +static const u8 DexDescription_Geowaz_2[] = _( + "bis es schließlich unten angekommen ist."); + +static const u8 DexDescription_Ponita_1[] = _( + "Nach seiner Geburt ist PONITA so\n" + "schwach, dass es kaum von alleine\n" + "aufstehen kann. Dieses POKéMON wird"); +static const u8 DexDescription_Ponita_2[] = _( + "dadurch schnell stärker, dass es sich\n" + "beim Versuch, mit seinen Eltern Schritt\n" + "zu halten, immer wieder aufrappeln muss."); + +static const u8 DexDescription_Gallopa_1[] = _( + "Man kann GALLOPA dabei beobachten, \n" + "wie es lässig über Felder und Wiesen\n" + "galoppiert. Wenn dieses POKéMON"); +static const u8 DexDescription_Gallopa_2[] = _( + "jedoch Ernst macht, erreicht es bis zu\n" + "240 km/h. Dann beginnt seine Mähne\n" + "zu lodern."); + +static const u8 DexDescription_Flegmon_1[] = _( + "FLEGMON benutzt seinen Schweif, um \n" + "Beute zu fangen, indem es ihn an einem \n" + "Flussufer ins Wasser taucht."); +static const u8 DexDescription_Flegmon_2[] = _( + "Dieses POKéMON vergisst häufig, was es\n" + "gerade tun wollte, und verbringt ganze \n" + "Tage damit, am Ufer herumzutrödeln."); + +static const u8 DexDescription_Lahmus_1[] = _( + "An LAHMUS’ Rute hat sich ein MUSCHAS\n" + "festgebissen. Daher kann es ihn nicht\n" + "mehr zum Angeln benutzen"); +static const u8 DexDescription_Lahmus_2[] = _( + "und es ist dazu gezwungen, umherzu-\n" + "schwimmen und nach Beute Ausschau\n" + "zu halten."); + +static const u8 DexDescription_Magnetilo_1[] = _( + "MAGNETILO ernährt sich von Elektri-\n" + "zität aus Stromleitungen. Dieses\n" + "POKéMON hängt sich gern an"); +static const u8 DexDescription_Magnetilo_2[] = _( + "Sicherungskästen. Wenn es in deinem\n" + "Haus zu einem Stromausfall kommt,\n" + "solltest du die Sicherungen überprüfen."); + +static const u8 DexDescription_Magneton_1[] = _( + "MAGNETON erzeugt ein sehr starkes Mag-\n" + "netfeld, das Maschinen zerstören kann.\n" + "Deshalb hört man in großen Städten oft"); +static const u8 DexDescription_Magneton_2[] = _( + "Sirenen, die die Bürger vor Scharen\n" + "dieses POKéMON warnen sollen."); + +static const u8 DexDescription_Porenta_1[] = _( + "PORENTA trifft man immer mit einer\n" + "Lauchstange an. Es gibt gute und\n" + "schlechte Stangen."); +static const u8 DexDescription_Porenta_2[] = _( + "Dieses POKéMON kämpft mit Hilfe seiner\n" + "Stange gegen seine Gegner."); + +static const u8 DexDescription_Dodu_1[] = _( + "DODU hat zwei Köpfe, die nie zur \n" + "selben Zeit, sondern abwechselnd\n" + "schlafen. Während ein Kopf schläft,"); +static const u8 DexDescription_Dodu_2[] = _( + "hält der andere Ausschau nach Feinden."); + +static const u8 DexDescription_Dodri_1[] = _( + "DODRIs drei Köpfe blicken in drei ver-\n" + "schiedene Richtungen. Es ist immer auf\n" + "der Hut."); +static const u8 DexDescription_Dodri_2[] = _( + "Du solltest dich diesem POKéMON nicht\n" + "nähern, wenn es bereits misstrauisch \n" + "ist. Es könnte nach dir hacken."); + +static const u8 DexDescription_Jurob_1[] = _( + "JUROB jagt unter der eisigen Ober-\n" + "fläche des Eismeeres nach Beute. Zum\n" + "Luft holen schlägt es mit dem"); +static const u8 DexDescription_Jurob_2[] = _( + "vorstehenden Teil seines Kopfes ein \n" + "Loch ins Eis."); + +static const u8 DexDescription_Jugong_1[] = _( + "JUGONG liebt es, auf bitterkalten Eis-\n" + "schollen ein Nickerchen zu machen.\n" + "Ein Seemann, der einmal ein solches"); +static const u8 DexDescription_Jugong_2[] = _( + "POKéMON schlafend auf einem\n" + "Eisberg sah, hielt es irrtümlicherweise\n" + "für eine Meerjungfrau."); + +static const u8 DexDescription_Sleima_1[] = _( + "SLEIMAs glitschiger, gummiartiger\n" + "Körper passt durch jede noch so kleine\n" + "Öffnung. Dieses POKéMON steigt in die"); +static const u8 DexDescription_Sleima_2[] = _( + "Kanalisation hinab, um fauliges\n" + "Abwasser zu trinken."); + +static const u8 DexDescription_Sleimok_1[] = _( + "SLEIMOK scheidet eine widerlich\n" + "stinkende Substanz aus. Ein einziger\n" + "Tropfen seiner Körpersubstanz reicht"); +static const u8 DexDescription_Sleimok_2[] = _( + "aus, um ein Gewässer zu verseuchen."); + +static const u8 DexDescription_Muschas_1[] = _( + "Nachts benutzt dieses POKéMON seine\n" + "breite Zunge, um ein Loch in den \n" + "Meeresboden zu graben."); +static const u8 DexDescription_Muschas_2[] = _( + "Darin schläft es. Dabei schließt es\n" + "seine Schale, aber die Zunge hängt\n" + "heraus."); + +static const u8 DexDescription_Austos_1[] = _( + "AUSTOS kann im Meerwasser schwimmen,\n" + "indem es Wasser schluckt und wieder\n" + "herausspritzt."); +static const u8 DexDescription_Austos_2[] = _( + "Dieses POKéMON kann sich auch ver- \n" + "teidigen, indem es spitze Stacheln mit\n" + "Hilfe des Wasserdrucks verschießt."); + +static const u8 DexDescription_Nebulak_1[] = _( + "NEBULAK hat einen gasförmigen Körper.\n" + "Wenn es starkem Wind ausgesetzt wird,\n" + "kann es davongeweht werden."); +static const u8 DexDescription_Nebulak_2[] = _( + "Scharen dieses POKéMON sammeln sich\n" + "unter Dachrinnen, um sich vor dem\n" + "gefährlichen Wind zu schützen."); + +static const u8 DexDescription_Alpollo_1[] = _( + "ALPOLLO ist ein gefährliches POKéMON.\n" + "Wenn es dich zu sich lockt, während es\n" + "durch die Dunkelheit schwebt, darfst"); +static const u8 DexDescription_Alpollo_2[] = _( + "du ihm keinesfalls zu nahe kommen.\n" + "Dieses POKéMON wird versuchen, an dir\n" + "zu lecken und dein Leben zu stehlen."); + +static const u8 DexDescription_Gengar_1[] = _( + "Nachts kann es passieren, dass dich\n" + "dein Schatten im Licht einer\n" + "Straßenlaterne plötzlich überholt."); +static const u8 DexDescription_Gengar_2[] = _( + "Dann ist es ein GENGAR, das an dir\n" + "vorbeiläuft und sich als dein Schatten\n" + "ausgibt."); + +static const u8 DexDescription_Onix_1[] = _( + "ONIX hat einen Magneten in seinem\n" + "Gehirn. Er dient ihm als Kompass,\n" + "so dass es beim Graben von Tunneln"); +static const u8 DexDescription_Onix_2[] = _( + "nicht die Orientierung verliert. Wenn es\n" + "älter wird, wird sein Körper immer\n" + "runder und glatter."); + +static const u8 DexDescription_Traumato_1[] = _( + "Wenn dir im Schlaf die Nase juckt, ist\n" + "das ein sicheres Zeichen dafür, dass\n" + "eines dieser POKéMON auf deinem"); +static const u8 DexDescription_Traumato_2[] = _( + "Kissen sitzt, um deinen Traum durch\n" + "deine Nasenlöcher hindurch zu\n" + "verspeisen."); + +static const u8 DexDescription_Hypno_1[] = _( + "HYPNO hält ein Pendel in der Hand. Das\n" + "Schwingen und Glitzern des Pendels \n" + "versetzt seine Feinde in eine tiefe"); +static const u8 DexDescription_Hypno_2[] = _( + "Hypnose. Während dieses POKéMON auf \n" + "der Suche nach Beute ist, poliert es \n" + "sein Pendel."); + +static const u8 DexDescription_Krabby_1[] = _( + "KRABBY lebt an Stränden, in Löchern im \n" + "Sand. An Sandstränden, an denen es\n" + "wenig Nahrung findet, sieht man dieses"); +static const u8 DexDescription_Krabby_2[] = _( + "POKéMON mit Artgenossen um sein\n" + "Revier streiten."); + +static const u8 DexDescription_Kingler_1[] = _( + "KINGLER hat eine riesige Schere. Es\n" + "winkt damit, um mit anderen zu \n" + "kommunizieren."); +static const u8 DexDescription_Kingler_2[] = _( + "Da seine Schere aber so schwer ist, wird\n" + "dieses POKéMON schnell müde."); + +static const u8 DexDescription_Voltobal_1[] = _( + "VOLTOBAL wurde zuerst bei einer Firma\n" + "beobachtet, die POKéBÄLLE herstellt.\n" + "Der Zusammenhang zwischen dieser"); +static const u8 DexDescription_Voltobal_2[] = _( + "Beobachtung und der Tatsache, dass\n" + "dieses POKéMON wie ein POKéBALL\n" + "aussieht, ist noch ungeklärt."); + +static const u8 DexDescription_Lektrobal_1[] = _( + "LEKTROBAL ernährt sich von\n" + "Elektrizität aus der Atmosphäre. An\n" + "Tagen, an denen es blitzt, explodiert"); +static const u8 DexDescription_Lektrobal_2[] = _( + "dieses POKéMON dauernd, da es zu viel\n" + "Elektrizität zu sich nimmt."); + +static const u8 DexDescription_Owei_1[] = _( + "Dieses POKéMON besteht aus sechs\n" + "Eiern, die ein engmaschiges Netz\n" + "bilden. Die sechs Eier ziehen sich"); +static const u8 DexDescription_Owei_2[] = _( + "gegenseitig an und drehen sich. Wenn\n" + "die Eier Risse bekommen, steht OWEI\n" + "kurz vor seiner Entwicklung."); + +static const u8 DexDescription_Kokowei_1[] = _( + "KOKOWEI stammt ursprünglich aus den\n" + "Tropen. Seine Köpfe wachsen stetig,\n" + "wenn es starkem Sonnenlicht"); +static const u8 DexDescription_Kokowei_2[] = _( + "ausgesetzt ist. Wenn seine Köpfe\n" + "abfallen, bilden sie zusammen ein OWEI."); + +static const u8 DexDescription_Tragosso_1[] = _( + "TRAGOSSO sehnt sich nach seiner\n" + "Mutter, die nicht mehr da ist. Wenn es\n" + "im Vollmond das Ebenbild seiner Mutter"); +static const u8 DexDescription_Tragosso_2[] = _( + "erblickt, muss es weinen. Die Flecken\n" + "auf dem Totenkopf, den es trägt,\n" + "stammen von vergossenen Tränen."); + +static const u8 DexDescription_Knogga_1[] = _( + "KNOGGA ist eine entwickelte Form von\n" + "TRAGOSSO, die den Verlust der Mutter\n" + "überwunden hat und stärker geworden"); +static const u8 DexDescription_Knogga_2[] = _( + "ist. Die temperamentvolle und\n" + "gestärkte Seele dieses POKéMON ist\n" + "nur schwer zu brechen."); + +static const u8 DexDescription_Kicklee_1[] = _( + "KICKLEE kann seine Beine ausfahren\n" + "und einziehen. Es verblüfft seine\n" + "Gegner mit brutalen Tritten."); +static const u8 DexDescription_Kicklee_2[] = _( + "Nach einem Kampf massiert es seine\n" + "Beine und lockert die Muskeln, um der\n" + "Erschöpfung vorzubeugen."); + +static const u8 DexDescription_Nockchan_1[] = _( + "NOCKCHAN besitzt das Herz eines\n" + "Boxers, der sich auf eine\n" + "Weltmeisterschaft vorbereitet."); +static const u8 DexDescription_Nockchan_2[] = _( + "Dieses POKéMON hat einen unbeugsamen\n" + "Willen und gibt niemals auf."); + +static const u8 DexDescription_Schlurp_1[] = _( + "Wenn SCHLURP etwas Neues entdeckt,\n" + "leckt es daran. Es merkt sich \n" + "Gegenstände anhand der Struktur und"); +static const u8 DexDescription_Schlurp_2[] = _( + "des Geschmacks.\n" + "Saure Sachen schrecken es eher ab."); + +static const u8 DexDescription_Smogon_1[] = _( + "Wenn SMOGON sich aufregt, lässt es\n" + "das giftige Gas in seinem Inneren\n" + "entweichen. Wenn es sich zu sehr"); +static const u8 DexDescription_Smogon_2[] = _( + "aufbläht, explodiert dieses POKéMON."); + +static const u8 DexDescription_Smogmog_1[] = _( + "SMOGMOG liebt die Gase verrottender,\n" + "fauler Küchenabfälle. Dieses POKéMON\n" + "sucht sich ein vernachlässigtes,"); +static const u8 DexDescription_Smogmog_2[] = _( + "schmutziges Gebäude und richtet sich\n" + "dort häuslich ein. Nachts, wenn die\n" + "Menschen schlafen, wühlt es im Müll."); + +static const u8 DexDescription_Rihorn_1[] = _( + "RIHORN läuft immer geradeaus und\n" + "zerstampft alles, was ihm in die Quere\n" + "kommt. Es macht ihm auch nichts aus,"); +static const u8 DexDescription_Rihorn_2[] = _( + "wenn es mit dem Kopf voran gegen einen\n" + "Stahlklotz rennt. Am nächsten Tag\n" + "allerdings könnte es Schmerzen haben."); + +static const u8 DexDescription_Rizeros_1[] = _( + "Mit seinem Horn kann RIZEROS selbst\n" + "Diamanten zerbrechen. Ein einziger\n" + "Hieb mit seinem Schweif kann ein Haus"); +static const u8 DexDescription_Rizeros_2[] = _( + "zum Einsturz bringen. Die Haut dieses\n" + "POKéMON ist so hart, dass nicht einmal\n" + "Kanonenkugeln Kratzer hinterlassen."); + +static const u8 DexDescription_Chaneira_1[] = _( + "CHANEIRA legt täglich ausgesprochen\n" + "nahrhafte Eier. Sie sind so köstlich,\n" + "dass sie sogar von Menschen verspeist"); +static const u8 DexDescription_Chaneira_2[] = _( + "werden, die gar keinen Appetit haben."); + +static const u8 DexDescription_Tangela_1[] = _( + "Wenn man TANGELAs Ranken berührt, \n" + "fallen diese sofort ab. Das tut ihm\n" + "aber nicht weh und es kann"); +static const u8 DexDescription_Tangela_2[] = _( + "sich schnell in Sicherheit bringen. \n" + "Verliert es Ranken, werden diese am\n" + "nächsten Tag durch neue ersetzt."); + +static const u8 DexDescription_Kangama_1[] = _( + "Wenn du auf ein spielendes KANGAMA\n" + "stößt, solltest du es nicht stören oder\n" + "versuchen, es einzufangen."); +static const u8 DexDescription_Kangama_2[] = _( + "Die Mutter dieses Baby-POKéMON ist\n" + "bestimmt in Reichweite und könnte\n" + "sehr wütend auf dich werden."); + +static const u8 DexDescription_Seeper_1[] = _( + "SEEPER ernährt sich von kleinen\n" + "Insekten und dem Moos auf Steinen.\n" + "Bei unruhiger See verankert sich"); +static const u8 DexDescription_Seeper_2[] = _( + "dieses POKéMON mit seinem Schweif an\n" + "Steinen oder Korallen, damit es nicht\n" + "weggespült wird."); + +static const u8 DexDescription_Seemon_1[] = _( + "Sobald sich SEEMON um eine Koralle\n" + "gewickelt hat, schläft es. Von Zeit zu\n" + "Zeit werden Menschen durch die"); +static const u8 DexDescription_Seemon_2[] = _( + "Widerhaken dieses POKéMON verletzt, \n" + "wenn sie versuchen, Korallen zu ernten\n" + "und es dabei nicht bemerken."); + +static const u8 DexDescription_Goldini_1[] = _( + "GOLDINI ist ein wunderschönes POKéMON,\n" + "dessen Flossen sich elegant im Wasser\n" + "wiegen. Aber man muss auf dieses"); +static const u8 DexDescription_Goldini_2[] = _( + "POKéMON Acht geben. Es könnte einen\n" + "sonst heftig mit seinem Horn rammen."); + +static const u8 DexDescription_Golking_1[] = _( + "Im Herbst kann man männliche GOLKING\n" + "dabei beobachten, wie sie Balztänze in \n" + "Flussbetten aufführen, um die"); +static const u8 DexDescription_Golking_2[] = _( + "weiblichen Exemplare zu beeindrucken.\n" + "Während dieser Zeit ist die Farbe\n" + "dieser POKéMON am schönsten."); + +static const u8 DexDescription_Sterndu_1[] = _( + "In STERNDUs Körpermitte befindet sich\n" + "ein hellrot leuchtendes Organ - \n" + "sein Kern. Wenn du im Spätsommer"); +static const u8 DexDescription_Sterndu_2[] = _( + "an einen Strand gehst, sehen die\n" + "leuchtenden Kerne dieser POKéMON aus\n" + "wie Sterne."); + +static const u8 DexDescription_Starmie_1[] = _( + "STARMIEs Mittelteil, sein Kern, leuchtet\n" + "in sieben Farben. Aufgrund dieser\n" + "Eigenschaft wird es auch"); +static const u8 DexDescription_Starmie_2[] = _( + "“Juwel des Meeres” genannt."); + +static const u8 DexDescription_Pantimos_1[] = _( + "PANTIMOS ist ein Meister der Pantomime.\n" + "Seine Gesten und Bewegungen machen\n" + "den Zuschauer glauben, dass etwas"); +static const u8 DexDescription_Pantimos_2[] = _( + "Unsichtbares tatsächlich existiert.\n" + "Wenn ein Objekt für real gehalten wird,\n" + "beginnt es wirklich zu existieren."); + +static const u8 DexDescription_Sichlor_1[] = _( + "SICHLOR ist unheimlich schnell. Dadurch\n" + "werden die beiden Sensen an seinen\n" + "Unterarmen noch effektiver."); +static const u8 DexDescription_Sichlor_2[] = _( + "Dieses POKéMON kann mit seinen Sensen\n" + "in Sekundenschnelle Baumstämme\n" + "zerteilen."); + +static const u8 DexDescription_Rossana_1[] = _( + "ROSSANA bewegt sich rhythmisch fort.\n" + "Es wiegt und schwingt seine Hüften, als\n" + "würde es tanzen. Seine Bewegungen"); +static const u8 DexDescription_Rossana_2[] = _( + "wirken so anziehend auf Menschen, dass\n" + "diese beginnen, mit den Hüften zu\n" + "schwingen, ohne darüber nachzudenken."); + +static const u8 DexDescription_Elektek_1[] = _( + "Bei Gewitter konkurrieren diese\n" + "POKéMON darum, wie viele\n" + "Spannungseinheiten sie erreichen,"); +static const u8 DexDescription_Elektek_2[] = _( + "wenn sie vom Blitz getroffen werden.\n" + "Einige Ortschaften benutzen ELEKTEK\n" + "an Stelle von Blitzableitern."); + +static const u8 DexDescription_Magmar_1[] = _( + "Im Kampf stößt MAGMAR glühend heiße\n" + "Flammen aus, um seinen Gegner\n" + "einzuschüchtern."); +static const u8 DexDescription_Magmar_2[] = _( + "Diese Feuersalven erzeugen Hitzewellen,\n" + "die das Gras und die Bäume der Umgebung\n" + "in Brand setzen."); + +static const u8 DexDescription_Pinsir_1[] = _( + "PINSIR ist erstaunlich stark. Es kann\n" + "einen Feind, der doppelt so viel wiegt\n" + "wie es selbst, mit seinen Hörnern"); +static const u8 DexDescription_Pinsir_2[] = _( + "packen und hochheben. Bei niedrigen\n" + "Temperaturen werden die Bewegungen\n" + "dieses POKéMON schwerfällig."); + +static const u8 DexDescription_Tauros_1[] = _( + "Dieses POKéMON ist nur zufrieden, wenn\n" + "es kämpfen kann. Wenn TAUROS keinen\n" + "Gegner findet, sucht es sich starke"); +static const u8 DexDescription_Tauros_2[] = _( + "Bäume und lässt sich an ihnen aus,\n" + "um sich abzureagieren."); + +static const u8 DexDescription_Karpador_1[] = _( + "KARPADOR ist ein armseliges POKéMON,\n" + "das nur platschen kann. Sein\n" + "merkwürdiges Verhalten hat so manchen"); +static const u8 DexDescription_Karpador_2[] = _( + "Wissenschaftler zum Forschen\n" + "angeregt."); + +static const u8 DexDescription_Garados_1[] = _( + "Wenn sich KARPADOR zu GARADOS\n" + "entwickelt, durchlaufen seine\n" + "Gehirnzellen eine strukturelle"); +static const u8 DexDescription_Garados_2[] = _( + "Veränderung, was wohl der Grund für die\n" + "zügellose, gewalttätige Natur dieses\n" + "POKéMON ist."); + +static const u8 DexDescription_Lapras_1[] = _( + "Die Menschen sind dafür verantwortlich,\n" + "dass LAPRAS fast ausgestorben wäre.\n" + "Abends singt es traurige Klagelieder,"); +static const u8 DexDescription_Lapras_2[] = _( + "da nur noch wenige seiner Artgenossen\n" + "übrig sind."); + +static const u8 DexDescription_Ditto_1[] = _( + "DITTO verändert seine Zellstruktur, um\n" + "sich in eine andere Form zu verwandeln.\n" + "Wenn es sich dabei jedoch auf sein"); +static const u8 DexDescription_Ditto_2[] = _( + "Gedächtnis verlässt, unterlaufen \n" + "diesem POKéMON schon mal Fehler."); + +static const u8 DexDescription_Evoli_1[] = _( + "EVOLIs genetisches Erbmaterial ist so\n" + "instabil, dass die Umgebung plötzliche\n" + "Mutationen auslösen kann."); +static const u8 DexDescription_Evoli_2[] = _( + "Die Wirkung verschiedener \n" + "STEINE führt zur Entwicklung dieses \n" + "POKéMON."); + +static const u8 DexDescription_Aquana_1[] = _( + "AQUANA hat eine spontane Mutation\n" + "durchgemacht und ihm sind Flossen und \n" + "Kiemen gewachsen. Dadurch kann es"); +static const u8 DexDescription_Aquana_2[] = _( + "unter Wasser leben.\n" + "Dieses POKéMON kann Wasser nach\n" + "Belieben manipulieren."); + +static const u8 DexDescription_Blitza_1[] = _( + "BLITZAs Zellen erzeugen schwache\n" + "Elektrizität. Diese wird aber durch die\n" + "statische Aufladung seines Fells"); +static const u8 DexDescription_Blitza_2[] = _( + "verstärkt, so dass es Blitzschläge\n" + "erzeugen kann. Sein Fell besteht aus \n" + "elektrisch geladenen Nadeln."); + +static const u8 DexDescription_Flamara_1[] = _( + "FLAMARAs flauschiges Fell dient einem\n" + "besonderen Zweck. Es gibt Hitze an die\n" + "Luft ab, damit sein Körper nicht"); +static const u8 DexDescription_Flamara_2[] = _( + "zu heiß wird. Die Körpertemperatur \n" + "dieses POKéMON kann bis auf 900 Grad\n" + "ansteigen."); + +static const u8 DexDescription_Porygon_1[] = _( + "PORYGON ist in der Lage, sich in Daten\n" + "zurückzuverwandeln und in den\n" + "Cyberspace zu gelangen."); +static const u8 DexDescription_Porygon_2[] = _( + "Dieses POKéMON ist kopiergeschützt, so\n" + "dass es durch Kopieren nicht\n" + "vervielfältigt werden kann."); + +static const u8 DexDescription_Amonitas_1[] = _( + "AMONITAS ist ein POKéMON, das seit\n" + "langer Zeit ausgestorben war, aber\n" + "von den Menschen aus Fossilien"); +static const u8 DexDescription_Amonitas_2[] = _( + "reproduziert wurde. Wenn es von einem\n" + "Feind angegriffen wird, zieht es sich in\n" + "sein hartes Gehäuse zurück."); + +static const u8 DexDescription_Amoroso_1[] = _( + "AMOROSO benutzt seine Tentakel, um\n" + "Beute einzufangen. Man nimmt an,\n" + "dass es ausgestorben ist, weil seine"); +static const u8 DexDescription_Amoroso_2[] = _( + "Schale zu groß und zu schwer geworden\n" + "war, so dass seine Bewegungen immer\n" + "langsamer und schwerfälliger wurden."); + +static const u8 DexDescription_Kabuto_1[] = _( + "KABUTO ist ein POKéMON, das aus einem\n" + "Fossil reproduziert wurde. Höchst\n" + "selten wurden lebende Exemplare dieser"); +static const u8 DexDescription_Kabuto_2[] = _( + "Art entdeckt.\n" + "Dieses POKéMON hat sich seit 300 Mio.\n" + "Jahren überhaupt nicht verändert."); + +static const u8 DexDescription_Kabutops_1[] = _( + "In der Antike jagte KABUTOPS unter\n" + "Wasser nach Beute. Es hat sich von\n" + "einem Meeresbewohner zu einem Land-"); +static const u8 DexDescription_Kabutops_2[] = _( + "bewohner entwickelt, was man an den\n" + "Veränderungen seiner Kiemen und\n" + "Beine sehen kann."); + +static const u8 DexDescription_Aerodactyl_1[] = _( + "AERODACTYL ist ein POKéMON aus dem\n" + "Zeitalter der Dinosaurier. Es wurde aus\n" + "genetischem Material reproduziert, das"); +static const u8 DexDescription_Aerodactyl_2[] = _( + "aus Bernstein gewonnen wurde.\n" + "Man geht davon aus, dass es in der\n" + "Antike der König der Lüfte war."); + +static const u8 DexDescription_Relaxo_1[] = _( + "Der typische Tagesablauf von RELAXO\n" + "besteht lediglich aus Essen und\n" + "Schlafen. Es ist so zutraulich, dass"); +static const u8 DexDescription_Relaxo_2[] = _( + "Kinder seinen dicken Bauch als Platz\n" + "zum Spielen nutzen."); + +static const u8 DexDescription_Arktos_1[] = _( + "ARKTOS ist ein sagenumwobenes\n" + "Vogel-POKéMON, das Eis manipulieren\n" + "kann. Das Schlagen seiner Flügel"); +static const u8 DexDescription_Arktos_2[] = _( + "bringt die Luft zum Gefrieren. Es wird\n" + "behauptet, dass es zu schneien\n" + "beginnt, wenn dieses POKéMON fliegt."); + +static const u8 DexDescription_Zapdos_1[] = _( + "ZAPDOS ist ein legendäres\n" + "Vogel-POKéMON, das die Fähigkeit\n" + "besitzt, Elektrizität zu manipulieren."); +static const u8 DexDescription_Zapdos_2[] = _( + "Es lebt in Gewitterwolken.\n" + "Dieses POKéMON nimmt Energie auf,\n" + "wenn es vom Blitz getroffen wird."); + +static const u8 DexDescription_Lavados_1[] = _( + "LAVADOS ist ein legendäres\n" + "Vogel-POKéMON, das Feuer manipulieren\n" + "kann. Wenn es verletzt wird, taucht es"); +static const u8 DexDescription_Lavados_2[] = _( + "seinen Körper in das Magma eines\n" + "Vulkans, um sich zu verbrennen\n" + "und selbst zu heilen."); + +static const u8 DexDescription_Dratini_1[] = _( + "DRATINI häutet sich ständig und\n" + "entledigt sich so seiner Haut, da die\n" + "Lebensenergie in seinem Körper"); +static const u8 DexDescription_Dratini_2[] = _( + "stetig und unkontrollierbar ansteigt."); + +static const u8 DexDescription_Dragonir_1[] = _( + "DRAGONIR speichert eine enorme Menge\n" + "an Energie in seinem Körper. Es kann die\n" + "Witterung in seiner Umgebung ändern,"); +static const u8 DexDescription_Dragonir_2[] = _( + "indem es Energie aus den Kristallen an\n" + "seinem Nacken und an seinem Schweif\n" + "entlädt."); + +static const u8 DexDescription_Dragoran_1[] = _( + "DRAGORAN kann die Welt innerhalb\n" + "von 16 Stunden umkreisen.\n" + "Es ist ein gutherziges POKéMON, das"); +static const u8 DexDescription_Dragoran_2[] = _( + "vermisste und sinkende Schiffe bei\n" + "Unwetter sicher an Land zurückbringt."); + +static const u8 DexDescription_Mewtu_1[] = _( + "MEWTU ist ein POKéMON, das durch\n" + "Genmanipulation entstanden ist. Die\n" + "Menschen haben es zwar mit ihrem"); +static const u8 DexDescription_Mewtu_2[] = _( + "wissenschaftlichen Sachverstand\n" + "erzeugt, aber nicht mit einem\n" + "mitfühlenden Herzen ausgestattet."); + +static const u8 DexDescription_Mew_1[] = _( + "MEW soll die genetische\n" + "Zusammensetzung aller POKéMON\n" + "besitzen. Es kann sich unsichtbar"); +static const u8 DexDescription_Mew_2[] = _( + "machen, so dass es sich auch Menschen\n" + "nähern kann, ohne bemerkt zu werden."); + +static const u8 DexDescription_Endivie_1[] = _( + "Im Kampf wedelt ENDIVIE mit seinem\n" + "Blatt, um den Feind fern zu halten. Von\n" + "dem Blatt geht auch ein süßlicher Duft"); +static const u8 DexDescription_Endivie_2[] = _( + "aus, der die kämpfenden POKéMON\n" + "beruhigt und eine gemütliche,\n" + "freundliche Atmosphäre schafft."); + +static const u8 DexDescription_Lorblatt_1[] = _( + "LORBLATTs Nacken ist mit\n" + "zusammengerollten Blättern behangen.\n" + "In jedem Blatt befindet sich ein kleiner"); +static const u8 DexDescription_Lorblatt_2[] = _( + "Trieb eines Baumes.\n" + "Der Duft dieses Triebes bringt\n" + "Menschen auf Trab."); + +static const u8 DexDescription_Meganie_1[] = _( + "Der Duft von MEGANIEs Blume besänftigt\n" + "Gemüter. Im Kampf gibt dieses POKéMON\n" + "mehr von seinem beruhigenden"); +static const u8 DexDescription_Meganie_2[] = _( + "Duftstoff ab, um den Kampfgeist des\n" + "Gegners zu schwächen."); + +static const u8 DexDescription_Feurigel_1[] = _( + "FEURIGEL lässt Flammen aus seinem\n" + "Rücken lodern, wenn es sich schützen\n" + "muss. Die Flammen sind sehr verzehrend,"); +static const u8 DexDescription_Feurigel_2[] = _( + "wenn dieses POKéMON wütend ist. Ist es\n" + "aber müde, flackern die Flammen nur\n" + "unregelmäßig und schwach."); + +static const u8 DexDescription_Igelavar_1[] = _( + "IGELAVAR hält seine Gegner mit Flammen\n" + "und Böen heißer Luft auf Distanz.\n" + "Dieses POKéMON nutzt seine"); +static const u8 DexDescription_Igelavar_2[] = _( + "außergewöhnliche Gewandtheit dazu,\n" + "Angriffen auszuweichen und seinen\n" + "Gegner gleichzeitig zu versengen."); + +static const u8 DexDescription_Tornupto_1[] = _( + "TORNUPTO versteckt sich hinter einem\n" + "flimmernden Hitzeschild, den es mit\n" + "Hilfe seiner heißen Flammen erzeugt."); +static const u8 DexDescription_Tornupto_2[] = _( + "Dieses POKéMON erzeugt Explosionen,\n" + "die alles in Schutt und Asche\n" + "legen."); + +static const u8 DexDescription_Karnimani_1[] = _( + "KARNIMANI ist zwar sehr klein, aber\n" + "seine Kiefer sind sehr stark. Wenn\n" + "die POKéMON denken, dass es nur"); +static const u8 DexDescription_Karnimani_2[] = _( + "spielerisch an ihnen knabbert, sollten\n" + "sie vorsichtig sein, denn sein Biss \n" + "kann zu schweren Verletzungen führen."); + +static const u8 DexDescription_Tyracroc_1[] = _( + "Wenn TYRACROC einen Feind mit seinen\n" + "Kiefern eingeklemmt hat, lässt es ihn\n" + "nicht mehr los. Da seine Zahnspitzen"); +static const u8 DexDescription_Tyracroc_2[] = _( + "wie Angelhaken gebogen sind, kann man\n" + "sie nicht mehr entfernen, wenn sie\n" + "sich verfangen haben."); + +static const u8 DexDescription_Impergator_1[] = _( + "IMPERGATOR schüchtert seine Feinde\n" + "dadurch ein, dass es sein riesiges Maul\n" + "aufreißt. Im Kampf erschüttert es den"); +static const u8 DexDescription_Impergator_2[] = _( + "Boden mit seinen kräftigen Hinterbei-\n" + "nen, wenn es mit unglaublicher Geschwin-\n" + "digkeit auf seinen Gegner losrennt."); + +static const u8 DexDescription_Wiesor_1[] = _( + "Wenn WIESOR schläft, hält immer jemand\n" + "Wache. Beim ersten Anflug von Gefahr\n" + "weckt die Wache die anderen auf."); +static const u8 DexDescription_Wiesor_2[] = _( + "Wenn dieses POKéMON von seinen\n" + "Artgenossen getrennt wird, kann es\n" + "vor Angst nicht mehr schlafen."); + +static const u8 DexDescription_Wiesenior_1[] = _( + "WIESENIOR ist sehr schlank. Wenn es\n" + "angegriffen wird, kann es sich durch\n" + "enge Zwischenräume schlängeln und"); +static const u8 DexDescription_Wiesenior_2[] = _( + "entkommen. Trotz seiner kurzen\n" + "Gliedmaßen ist dieses POKéMON sehr\n" + "wendig und flink."); + +static const u8 DexDescription_Hoothoot_1[] = _( + "HOOTHOOT besitzt ein inneres Organ, das\n" + "die Erdumdrehung wahrnimmt. Dieses\n" + "besondere Organ ermöglicht es diesem"); +static const u8 DexDescription_Hoothoot_2[] = _( + "POKéMON, jeden Tag zur selben Zeit zu\n" + "schreien."); + +static const u8 DexDescription_Noctuh_1[] = _( + "Dank seines hervorragenden\n" + "Sehvermögens, mit dem es auch bei\n" + "geringer Beleuchtung sehen kann, und"); +static const u8 DexDescription_Noctuh_2[] = _( + "dank seiner geschmeidigen Flügel,\n" + "mit denen es geräuschlos fliegt,\n" + "entgeht NOCTUH keine Beute."); + +static const u8 DexDescription_Ledyba_1[] = _( + "LEDYBA sondert eine duftende\n" + "Flüssigkeit ab. Darüber kommuniziert\n" + "es mit anderen. Dieses POKéMON"); +static const u8 DexDescription_Ledyba_2[] = _( + "übermittelt seine Gefühle, indem es die\n" + "Duftnote des Sekrets verändert."); + +static const u8 DexDescription_Ledian_1[] = _( + "In Ländern mit frischer Luft und\n" + "Sternen am Himmel leben unzählig viele\n" + "LEDIAN."); +static const u8 DexDescription_Ledian_2[] = _( + "Dafür gibt es einen guten Grund:\n" + "Dieses POKéMON nutzt das Licht der\n" + "Sterne als Energie."); + +static const u8 DexDescription_Webarak_1[] = _( + "Das von WEBARAK gesponnene Netz ist\n" + "sein zweites Nervensystem. Dieses\n" + "POKéMON kann anhand der feinen"); +static const u8 DexDescription_Webarak_2[] = _( + "Vibrationen der Netzfäden bestimmen,\n" + "welche Art Beute sich darauf befindet."); + +static const u8 DexDescription_Ariados_1[] = _( + "ARIADOS hat kleine hakenförmige Krallen\n" + "an seinen Füßen. Damit kann es an\n" + "Decken und Wänden entlang flitzen."); +static const u8 DexDescription_Ariados_2[] = _( + "Dieses POKéMON erdrückt seine Gegner\n" + "mit starkem, dünnem Seidenfaden."); + +static const u8 DexDescription_Iksbat_1[] = _( + "Wenn IKSBAT fliegt, indem es nur ein \n" + "Paar Flügel, entweder an seinen Vorder-\n" + "oder Hinterbeinen bewegt, ist dies ein"); +static const u8 DexDescription_Iksbat_2[] = _( + "Anzeichen dafür, dass dieses POKéMON \n" + "bereits eine lange Strecke hinter sich\n" + "hat. Dann wechselt es die Flügel häufig."); + +static const u8 DexDescription_Lampi_1[] = _( + "LAMPI gibt positive und negative\n" + "elektrische Ladungen durch seine\n" + "Antennen ab, um seine Beute zu lähmen."); +static const u8 DexDescription_Lampi_2[] = _( + "Dieses POKéMON lässt seine Lichter\n" + "aufflackern und tauscht Signale mit\n" + "seinen Artgenossen aus."); + +static const u8 DexDescription_Lanturn_1[] = _( + "LANTURN wird auch “Tiefseestern”\n" + "genannt, da es leuchtende Antennen\n" + "besitzt. Dieses POKéMON erzeugt Licht,"); +static const u8 DexDescription_Lanturn_2[] = _( + "indem es in den Antennen eine chemische\n" + "Reaktion zwischen Bakterien und seinen\n" + "Körperflüssigkeiten erzeugt."); + +static const u8 DexDescription_Pichu_1[] = _( + "An Gewittertagen oder Tagen, an denen\n" + "die Luft sehr trocken ist, kann sich\n" + "PICHU leichter mit Elektrizität"); +static const u8 DexDescription_Pichu_2[] = _( + "aufladen. Dann kann man das Knistern\n" + "statischer Aufladung hören."); + +static const u8 DexDescription_Pii_1[] = _( + "In Nächten mit vielen Sternschnuppen,\n" + "kann man PII im Kreis tanzen sehen. Es\n" + "tanzt die ganze Nacht hindurch und"); +static const u8 DexDescription_Pii_2[] = _( + "hört erst bei Sonnenaufgang auf, um\n" + "seinen Durst mit Morgentau zu stillen."); + +static const u8 DexDescription_Fluffeluff_1[] = _( + "FLUFFELUFFs Stimmbänder sind noch\n" + "nicht voll entwickelt. Wenn es zu viel\n" + "singt, schmerzt ihm die Kehle."); +static const u8 DexDescription_Fluffeluff_2[] = _( + "Dieses POKéMON gurgelt mit Süßwasser\n" + "aus einem sauberen Fluss."); + +static const u8 DexDescription_Togepi_1[] = _( + "TOGEPI nutzt die positiven Emotionen,\n" + "wie Freude und Mitgefühl, von Menschen\n" + "und POKéMON als Energie."); +static const u8 DexDescription_Togepi_2[] = _( + "Dieses POKéMON speichert Glücksgefühle\n" + "in seiner Schale und teilt sie mit\n" + "anderen."); + +static const u8 DexDescription_Togetic_1[] = _( + "TOGETIC ist ein POKéMON, das Glück\n" + "bringt. Wenn es jemanden trifft, der\n" + "reinen Herzens ist, zeigt es sich und"); +static const u8 DexDescription_Togetic_2[] = _( + "teilt sein Glück mit dieser Person."); + +static const u8 DexDescription_Natu_1[] = _( + "NATU kann nicht fliegen, da seine Flügel\n" + "noch nicht ausgewachsen sind. Wenn du\n" + "diesem POKéMON in die Augen schaust,"); +static const u8 DexDescription_Natu_2[] = _( + "starrt es dich konzentriert an. Wenn du\n" + "dich aber bewegst, hüpft es weg, um sich\n" + "in Sicherheit zu bringen."); + +static const u8 DexDescription_Xatu_1[] = _( + "XATU bleibt den ganzen Tag an ein und\n" + "demselben Ort wie angewurzelt stehen. \n" + "Die Menschen glauben, dass es dies aus"); +static const u8 DexDescription_Xatu_2[] = _( + "Angst vor den Dingen tut, die es für die\n" + "Zukunft vorausgesehen hat."); + +static const u8 DexDescription_Voltilamm_1[] = _( + "VOLTILAMMs flauschiges, wollenes Fell\n" + "erzeugt Reibung und statische\n" + "Aufladung. Je höher die elektrische"); +static const u8 DexDescription_Voltilamm_2[] = _( + "Ladung wird, desto heller leuchtet die\n" + "Glühbirne an seinem Schweif."); + +static const u8 DexDescription_Waaty_1[] = _( + "Die Qualität von WAATYs Wolle verändert\n" + "sich, so dass es mit nur wenig Wolle eine\n" + "große statische Aufladung erzeugen"); +static const u8 DexDescription_Waaty_2[] = _( + "kann. Die kahlen Stellen in seinem Fell\n" + "sind gegen Elektrizität abgeschirmt."); + +static const u8 DexDescription_Ampharos_1[] = _( + "AMPHAROS strahlt so viel Licht aus,\n" + "dass es sogar aus dem Weltraum noch \n" + "gesehen werden kann. In der Antike"); +static const u8 DexDescription_Ampharos_2[] = _( + "benutzten die Menschen das Licht\n" + "dieses POKéMON dazu, Signale über\n" + "weite Entfernungen auszutauschen."); + +static const u8 DexDescription_Blubella_1[] = _( + "Wenn BLUBELLA starkem Sonnenlicht\n" + "ausgesetzt ist, beginnen sich die Blät-\n" + "ter an seinem Körper zu drehen."); +static const u8 DexDescription_Blubella_2[] = _( + "Der Tanz dieses POKéMON ist in\n" + "südlichen Ländern sehr bekannt."); + +static const u8 DexDescription_Marill_1[] = _( + "MARILLs Schweif ist mit Öl gefüllt und\n" + "dient ihm als eine Art Rettungsring.\n" + "Wenn nur sein Schweif an der"); +static const u8 DexDescription_Marill_2[] = _( + "Wasseroberfläche zu sehen ist, taucht\n" + "dieses POKéMON gerade, um sich von\n" + "Wasserpflanzen zu ernähren."); + +static const u8 DexDescription_Azumarill_1[] = _( + "AZUMARILLs lange Ohren dienen ihm\n" + "als unentbehrliche Sensoren. Wenn es\n" + "sein Gehör fokussiert, kann dieses"); +static const u8 DexDescription_Azumarill_2[] = _( + "POKéMON auch in reißenden Flüssen\n" + "identifizieren, welche Art von Beute\n" + "sich in seiner Nähe befindet."); + +static const u8 DexDescription_Mogelbaum_1[] = _( + "MOGELBAUM tarnt sich als Baum, um\n" + "Angriffen von Feinden aus dem Weg\n" + "zu gehen. Da seine Vorderbeine aber"); +static const u8 DexDescription_Mogelbaum_2[] = _( + "das ganze Jahr über grün bleiben, fällt\n" + "seine Tarnung im Winter leicht auf."); + +static const u8 DexDescription_Quaxo_1[] = _( + "QUAXO hat gelocktes Haar, das ihm den\n" + "Status eines Königs bescheinigt. Je\n" + "länger und lockiger sein Haar ist, desto"); +static const u8 DexDescription_Quaxo_2[] = _( + "mehr Respekt erntet dieses POKéMON\n" + "von seinen Artgenossen."); + +static const u8 DexDescription_Hoppspross_1[] = _( + "HOPPSPROSS lässt sich vom Wind\n" + "treiben. Wenn es bemerkt, dass ein\n" + "Sturm aufkommt, verbindet es seine"); +static const u8 DexDescription_Hoppspross_2[] = _( + "Blätter mit anderen HOPPSPROSS,\n" + "damit es nicht davongeweht wird."); + +static const u8 DexDescription_Hubelupf_1[] = _( + "HUBELUPFs Blume beginnt zu blühen, wenn\n" + "die Temperatur über 18 Grad steigt. Wie\n" + "weit sich die Blüte öffnet, hängt von"); +static const u8 DexDescription_Hubelupf_2[] = _( + "der Höhe der Temperatur ab. Daher wird\n" + "dieses POKéMON manchmal als\n" + "Thermometer eingesetzt."); + +static const u8 DexDescription_Papungha_1[] = _( + "PAPUNGHA nutzt den Südwind, um das\n" + "Meer zu überqueren und in ferne\n" + "Länder zu fliegen. Dieses POKéMON"); +static const u8 DexDescription_Papungha_2[] = _( + "sinkt zu Boden, wenn es während seines\n" + "Fluges auf kalte Luftschichten stößt."); + +static const u8 DexDescription_Griffel_1[] = _( + "An GRIFFELs Schweif befindet sich ein\n" + "handähnliches Anhängsel, mit dem es\n" + "geschickt zu Werke gehen kann."); +static const u8 DexDescription_Griffel_2[] = _( + "Da dieses POKéMON sehr häufig seinen\n" + "Schweif einsetzt, wirken seine Hände\n" + "eher plump."); + +static const u8 DexDescription_Sonnkern_1[] = _( + "SONNKERN versucht, sich so wenig wie\n" + "möglich zu bewegen, um alle\n" + "gespeicherten Nährstoffe für seine"); +static const u8 DexDescription_Sonnkern_2[] = _( + "Entwicklung aufzusparen. Außer\n" + "Morgentau nimmt es nichts weiter zu\n" + "sich."); + +static const u8 DexDescription_Sonnflora_1[] = _( + "SONNFLORA verwandelt Solarenergie in\n" + "Nährstoffe. Tagsüber, wenn es warm ist,\n" + "ist es sehr aktiv."); +static const u8 DexDescription_Sonnflora_2[] = _( + "Wenn aber die Sonne untergegangen ist,\n" + "hört es auf sich zu bewegen."); + +static const u8 DexDescription_Yanma_1[] = _( + "YANMA hat einen Blickwinkel von 360\n" + "Grad, ohne die Augen bewegen zu müssen.\n" + "Es ist ein großartiger Flieger und geübt"); +static const u8 DexDescription_Yanma_2[] = _( + "darin, plötzlich anzuhalten oder\n" + "Wendemanöver vorzunehmen. So kann es\n" + "sich blitzschnell auf Beute stürzen."); + +static const u8 DexDescription_Felino_1[] = _( + "FELINO lebt eigentlich im Wasser.\n" + "Manchmal kommt es jedoch an Land, um \n" + "nach Nahrung zu suchen."); +static const u8 DexDescription_Felino_2[] = _( + "An Land bedeckt es seinen Körper mit\n" + "einem schleimigen Giftfilm."); + +static const u8 DexDescription_Morlord_1[] = _( + "MORLORD jagt seine Nahrung, indem es im\n" + "Wasser sein Maul weit aufmacht und\n" + "auf unvorsichtige Beute wartet."); +static const u8 DexDescription_Morlord_2[] = _( + "Da sich dieses POKéMON nicht bewegt,\n" + "wird es auch nicht besonders hungrig."); + +static const u8 DexDescription_Psiana_1[] = _( + "PSIANA ist jedem TRAINER treu, dem es\n" + "zugetan ist. Dieses POKéMON hat die\n" + "Fähigkeit der Prophezeiung entwickelt,"); +static const u8 DexDescription_Psiana_2[] = _( + "um seine TRAINER vor Unheil zu\n" + "bewahren."); + +static const u8 DexDescription_Nachtara_1[] = _( + "NACHTARA hat sich dadurch entwickelt,\n" + "dass es den Mondwellen ausgesetzt war.\n" + "Es versteckt sich im Schutze der"); +static const u8 DexDescription_Nachtara_2[] = _( + "Dunkelheit und wartet darauf, dass sich\n" + "ein Feind bewegt. Die Ringe an seinem\n" + "Körper leuchten auf, wenn es angreift."); + +static const u8 DexDescription_Kramurx_1[] = _( + "KRAMURX wurde als vermeintlicher\n" + "Überbringer des Unheils verabscheut\n" + "und gefürchtet. Dieses POKéMON hat"); +static const u8 DexDescription_Kramurx_2[] = _( + "ein großes Interesse an allem, was\n" + "funkelt und glitzert. Es stiehlt auch\n" + "Ringe von Frauen."); + +static const u8 DexDescription_Laschoking_1[] = _( + "LASCHOKING betreibt jeden Tag \n" + "Forschung, um die Geheimnisse der Welt\n" + "zu lüften. Dieses POKéMON vergisst aber"); +static const u8 DexDescription_Laschoking_2[] = _( + "alles, was es bereits herausgefunden\n" + "hat, wenn das MUSCHAS auf seinem\n" + "Kopf abfällt."); + +static const u8 DexDescription_Traunfugil_1[] = _( + "TRAUNFUGIL erschreckt Menschen mit\n" + "einem markerschütternden Schrei.\n" + "Dieses POKéMON verwendet seine roten"); +static const u8 DexDescription_Traunfugil_2[] = _( + "Kraftfelder dazu, die Ängste seiner\n" + "Feinde aufzunehmen und sie in\n" + "Nahrung umzuwandeln."); + +static const u8 DexDescription_Icognito_1[] = _( + "ICOGNITO hat die Form antiker\n" + "Schriftzeichen. Bis heute ist unklar,\n" + "was zuerst da war: Die antiken"); +static const u8 DexDescription_Icognito_2[] = _( + "Schriftzeichen oder die vielen unter-\n" + "schiedlichen ICOGNITO. Trotz umfang-\n" + "reicher Forschung bleiben Fragen offen."); + +static const u8 DexDescription_Woingenau_1[] = _( + "Wenn zwei oder mehr WOINGENAU \n" + "aufeinander treffen, versuchen sie,\n" + "gegenseitig ihre Geduld zu übertreffen."); +static const u8 DexDescription_Woingenau_2[] = _( + "Sie möchten herausfinden, welches\n" + "POKéMON es am längsten ohne Nahrung\n" + "aushält. Darauf müssen Trainer achten."); + +static const u8 DexDescription_Girafarig_1[] = _( + "Der Kopf an GIRAFARIGs Hinterteil hat\n" + "ein eigenes Gehirn. Er reagiert mit\n" + "Angriffen auf Gerüche und Geräusche."); +static const u8 DexDescription_Girafarig_2[] = _( + "Wenn man sich diesem POKéMON von\n" + "hinten nähert, könnte der hintere Kopf\n" + "plötzlich vorschnellen und zubeißen."); + +static const u8 DexDescription_Tannza_1[] = _( + "TANNZA hängt an Ästen und wartet auf\n" + "Beute. Wenn man dieses POKéMON bei\n" + "einer Mahlzeit stört, indem man den"); +static const u8 DexDescription_Tannza_2[] = _( + "Baum, auf dem es sich befindet,\n" + "schüttelt, fällt es herunter und\n" + "explodiert ohne Vorwarnung."); + +static const u8 DexDescription_Forstellka_1[] = _( + "FORSTELLKA versteckt sich in seiner\n" + "stahlharten Schale. Die Schale öffnet\n" + "sich, wenn es nach Beute schnappt."); +static const u8 DexDescription_Forstellka_2[] = _( + "Dies geht jedoch so schnell, dass man\n" + "das Innere der Schale nicht zu Gesicht\n" + "bekommt."); + +static const u8 DexDescription_Dummisel_1[] = _( + "DUMMISEL hat einen Bohrer als Schweif.\n" + "Diesen benutzt es, um sich rückwärts in\n" + "den Boden einzugraben."); +static const u8 DexDescription_Dummisel_2[] = _( + "Dieses POKéMON baut seinen \n" + "Nestkomplex tief unter der\n" + "Erdoberfläche auf."); + +static const u8 DexDescription_Skorgla_1[] = _( + "SKORGLA segelt lautlos durch die Lüfte.\n" + "Es verankert sich mit Hilfe der Krallen\n" + "an seinen Hinterbeinen und der riesigen"); +static const u8 DexDescription_Skorgla_2[] = _( + "Scheren an seinen Vorderbeinen am\n" + "Gesicht eines Feindes fest und\n" + "vergiftet ihn mit seinem Giftstachel."); + +static const u8 DexDescription_Stahlos_1[] = _( + "STAHLOS lebt noch tiefer unter der Erde\n" + "als ONIX. Dieses POKéMON gräbt immer\n" + "in Richtung des Erdkerns."); +static const u8 DexDescription_Stahlos_2[] = _( + "Nachweislich hat dieses POKéMON\n" + "bereits Tiefen von einem Kilometer\n" + "erreicht."); + +static const u8 DexDescription_Snubbull_1[] = _( + "Indem es seine Zähne fletscht und\n" + "ein Furcht erregendes Gesicht macht,\n" + "schlägt SNUBBULL kleinere POKéMON"); +static const u8 DexDescription_Snubbull_2[] = _( + "in die Flucht. Es scheint darüber jedoch\n" + "etwas traurig zu sein."); + +static const u8 DexDescription_Granbull_1[] = _( + "GRANBULL besitzt einen besonders\n" + "ausgeprägten Unterkiefer. Wegen seiner\n" + "schweren Zähne wackelt es mit dem Kopf."); +static const u8 DexDescription_Granbull_2[] = _( + "Es beißt nur zu, wenn es erschreckt\n" + "wird."); + +static const u8 DexDescription_Baldorfish_1[] = _( + "BALDORFISH saugt Wasser ein, um sich\n" + "aufzublasen. Dieses POKéMON nutzt den\n" + "Druck des Wassers dazu, giftige"); +static const u8 DexDescription_Baldorfish_2[] = _( + "Stacheln aus seinem Körper zu\n" + "verschießen. Es betrachtet Schwimmen\n" + "als eine echte Herausforderung."); + +static const u8 DexDescription_Scherox_1[] = _( + "SCHEROX’ Körper ist hart wie Stahl.\n" + "Gewöhnliche Angriffe jagen ihm keine\n" + "Angst ein. Dieses POKéMON schlägt"); +static const u8 DexDescription_Scherox_2[] = _( + "mit den Flügeln, um seine\n" + "Körpertemperatur zu regulieren."); + +static const u8 DexDescription_Pottrott_1[] = _( + "POTTROTT versteckt sich leise unter\n" + "Steinen und verbirgt seinen Körper in\n" + "seiner harten Schale, wenn es"); +static const u8 DexDescription_Pottrott_2[] = _( + "gesammelte Beeren zu sich nimmt. Die\n" + "Beeren vermischen sich mit seinen\n" + "Körperflüssigkeiten zu einem Saft."); + +static const u8 DexDescription_Skaraborn_1[] = _( + "SKARABORN geht direkt auf seinen\n" + "Gegner los, rutscht auf ihn zu, um ihn\n" + "auszuhebeln und mit seinem mächtigen"); +static const u8 DexDescription_Skaraborn_2[] = _( + "Horn wegzuschleudern. Dieses POKéMON\n" + "hat genug Kraft, um einen massigen\n" + "Baum umzustoßen."); + +static const u8 DexDescription_Sniebel_1[] = _( + "SNIEBEL klettert an Bäumen hoch, indem\n" + "es seine hakenförmigen Krallen in die\n" + "Rinde schlägt. Dieses POKéMON sucht"); +static const u8 DexDescription_Sniebel_2[] = _( + "nach unbewachten Nestern und stiehlt\n" + "die Eier, wenn die Eltern auf Nahrungs-\n" + "suche sind. Davon ernährt es sich."); + +static const u8 DexDescription_Teddiursa_1[] = _( + "TEDDIURSA leckt gern seine mit Honig\n" + "bedeckten Pranken ab. Dieses POKéMON\n" + "bereitet seinen eigenen Honig zu, indem"); +static const u8 DexDescription_Teddiursa_2[] = _( + "es die von BIBOR gesammelten Früchte\n" + "und Pollen miteinander vermengt."); + +static const u8 DexDescription_Ursaring_1[] = _( + "In den von URSARING bewohnten Wäldern\n" + "gibt es viele Flüsse und hohe Bäume, in\n" + "denen es Nahrung findet. Dieses"); +static const u8 DexDescription_Ursaring_2[] = _( + "POKéMON läuft täglich durch den Wald,\n" + "um nach Essbarem zu suchen."); + +static const u8 DexDescription_Schneckmag_1[] = _( + "Durch SCHNECKMAGs Kreislaufsystem\n" + "fließt Magma. Wenn dieses POKéMON\n" + "erkältet ist, kühlt das Magma"); +static const u8 DexDescription_Schneckmag_2[] = _( + "aus und erhärtet. Sein Körper wird\n" + "spröde und es brechen Stücke heraus,\n" + "so dass es kleiner wird."); + +static const u8 DexDescription_Magcargo_1[] = _( + "MAGCARGOs Schale ist eigentlich seine\n" + "Haut, die erhärtet ist, als es auskühlte.\n" + "Seine Schale ist sehr spröde und"); +static const u8 DexDescription_Magcargo_2[] = _( + "zerbrechlich. Schon bei einer leichten\n" + "Berührung bricht sie auseinander. Dann\n" + "muss es ein Bad in Magma nehmen."); + +static const u8 DexDescription_Quiekel_1[] = _( + "Auf Nahrungssuche schnüffelt QUIEKEL\n" + "am Boden entlang. Seine \n" + "Lieblingsspeise ist ein Pilz, der unter"); +static const u8 DexDescription_Quiekel_2[] = _( + "verwesendem Gras wächst. \n" + "Manchmal spürt dieses POKéMON heiße\n" + "Quellen auf."); + +static const u8 DexDescription_Keifel_1[] = _( + "KEIFEL hat ein dichtes Fell aus langen\n" + "Haaren. Dadurch ist es gegen eisige\n" + "Kälte gewappnet."); +static const u8 DexDescription_Keifel_2[] = _( + "Dieses POKéMON benutzt seine\n" + "Hauer, um an Nahrung zu gelangen, die\n" + "unter dem Eis eingeschlossen ist."); + +static const u8 DexDescription_Corasonn_1[] = _( + "Wenn CORASONNs Arme Sonnenlicht\n" + "abbekommen, glitzern sie wunderschön\n" + "in sieben Farben. Wenn ein Arm"); +static const u8 DexDescription_Corasonn_2[] = _( + "abbricht, wächst über Nacht ein neuer\n" + "nach."); + +static const u8 DexDescription_Remoraid_1[] = _( + "REMORAID saugt Wasser ein und spritzt\n" + "es unter Einsatz seiner Bauchmuskeln\n" + "mit Hochdruck wieder heraus. So schießt"); +static const u8 DexDescription_Remoraid_2[] = _( + "es fliegende Beute ab. Wenn seine\n" + "Entwicklung näher rückt, wandert\n" + "dieses POKéMON flussabwärts."); + +static const u8 DexDescription_Octillery_1[] = _( + "OCTILLERY saugt sich mit seinen\n" + "Tentakeln an einem Feind fest. Dieses\n" + "POKéMON betäubt seinen Gegner,"); +static const u8 DexDescription_Octillery_2[] = _( + "bevor es ihm den Rest gibt.\n" + "Wenn ein Feind zu stark ist, speit es\n" + "Tinte aus und flüchtet."); + +static const u8 DexDescription_Botogel_1[] = _( + "BOTOGEL sammelt seine Nahrung in\n" + "seinem Schweif. Es gab einmal einen\n" + "berühmten Entdecker, der es dank eines"); +static const u8 DexDescription_Botogel_2[] = _( + "BOTOGELs geschafft hat, einen der\n" + "höchsten Berge der Welt zu besteigen.\n" + "Es hatte seine Nahrung mit ihm geteilt."); + +static const u8 DexDescription_Mantax_1[] = _( + "An schönen Tagen sieht man Schwärme\n" + "von MANTAX elegant über die Wellen des\n" + "Ozeans springen."); +static const u8 DexDescription_Mantax_2[] = _( + "Durch REMORAID, die an ihm haften\n" + "und ihn begleiten, fühlt sich dieses\n" + "POKéMON nicht belästigt."); + +static const u8 DexDescription_Panzaeron_1[] = _( + "PANZAERON ist komplett in einen harten,\n" + "schützenden Panzer eingehüllt. Dieses\n" + "POKéMON fliegt 300 km/h."); +static const u8 DexDescription_Panzaeron_2[] = _( + "Es greift seine Feinde mit seinen\n" + "messerscharfen Flügeln an."); + +static const u8 DexDescription_Hunduster_1[] = _( + "HUNDUSTER jagen in Gruppen. Sie\n" + "kommunizieren miteinander über\n" + "verschiedene Arten von Geheul und"); +static const u8 DexDescription_Hunduster_2[] = _( + "treiben ihre Feinde in die Enge.\n" + "Die Zusammenarbeit dieser POKéMON\n" + "ist einzigartig."); + +static const u8 DexDescription_Hundemon_1[] = _( + "In einer Gruppe von HUNDEMON ist\n" + "dasjenige mit den nach hinten\n" + "gebogenen Hörnern der Anführer."); +static const u8 DexDescription_Hundemon_2[] = _( + "Diese POKéMON bestimmen ihren Anführer\n" + "durch das Ausfechten von Kämpfen\n" + "untereinander."); + +static const u8 DexDescription_Seedraking_1[] = _( + "SEEDRAKING lebt in den Tiefen des\n" + "Ozeans, die ansonsten verwaist sind.\n" + "Lange hat man geglaubt, dass das"); +static const u8 DexDescription_Seedraking_2[] = _( + "Gähnen dieses POKéMON Strudel auslöst."); + +static const u8 DexDescription_Phanpy_1[] = _( + "Um sich ein Nest zu bauen, gräbt\n" + "PHANPY am Flussufer ein Loch ins\n" + "Erdreich. Es markiert die Umgebung"); +static const u8 DexDescription_Phanpy_2[] = _( + "seines Nests mit Hilfe seines Rüssels,\n" + "damit seine Artgenossen wissen, dass\n" + "dieses Gebiet vergeben ist."); + +static const u8 DexDescription_Donphan_1[] = _( + "DONPHANs Lieblingsattacke ist es, als\n" + "Ball zusammengerollt mit voller Wucht\n" + "gegen seine Gegner zu krachen."); +static const u8 DexDescription_Donphan_2[] = _( + "Wenn es erst einmal rollt, ist dieses\n" + "POKéMON nur schwer aufzuhalten."); + +static const u8 DexDescription_Porygon2_1[] = _( + "PORYGON2 wurde in einem\n" + "wissenschaftlichen Experiment von\n" + "Menschen erzeugt. Es verfügt über"); +static const u8 DexDescription_Porygon2_2[] = _( + "künstliche Intelligenz, wodurch es \n" + "selbstständig neue Gesten und Gefühle\n" + "erlernen kann."); + +static const u8 DexDescription_Damhirplex_1[] = _( + "DAMHIRPLEX hat ein prächtiges Geweih,\n" + "für das hohe Preise gezahlt werden, da\n" + "sie als Kunstwerke gelten."); +static const u8 DexDescription_Damhirplex_2[] = _( + "Daher wurde dieses POKéMON gejagt und\n" + "wäre beinahe ausgestorben."); + +static const u8 DexDescription_Farbeagle_1[] = _( + "FARBEAGLE markiert sein Revier mit\n" + "einer Flüssigkeit, die aus seiner\n" + "Schweifspitze austritt."); +static const u8 DexDescription_Farbeagle_2[] = _( + "Es wurden über 5000 unterschiedliche\n" + "Markierungen entdeckt, die dieses\n" + "POKéMON hinterlassen hat."); + +static const u8 DexDescription_Rabauz_1[] = _( + "RABAUZ muss jeden Tag trainieren,\n" + "sonst ist es nicht ausgelastet und\n" + "reagiert gestresst. Wenn man dieses"); +static const u8 DexDescription_Rabauz_2[] = _( + "POKéMON trainiert, muss man\n" + "zahlreiche Trainingsmethoden\n" + "einsetzen und sie ständig ausbauen."); + +static const u8 DexDescription_Kapoera_1[] = _( + "KAPOERA dreht sich auf dem Kopf\n" + "stehend um die eigene Achse und teilt\n" + "Tritte aus. Seine Technik ist eine"); +static const u8 DexDescription_Kapoera_2[] = _( + "bemerkenswerte Mischung aus Angriff \n" + "und Verteidigung. Es bewegt sich \n" + "drehend schneller voran als laufend."); + +static const u8 DexDescription_Kussilla_1[] = _( + "KUSSILLA läuft hektisch umher, fällt\n" + "aber auch ziemlich oft hin. Es lässt\n" + "keine Möglichkeit aus sein Spiegelbild"); +static const u8 DexDescription_Kussilla_2[] = _( + "zu betrachten, um sicherzustellen,\n" + "dass sein Gesicht nicht schmutzig\n" + "geworden ist."); + +static const u8 DexDescription_Elekid_1[] = _( + "ELEKID speichert Elektrizität in seinem\n" + "Körper. Wenn es Metall berührt und\n" + "versehentlich die aufgestaute Energie"); +static const u8 DexDescription_Elekid_2[] = _( + "entlädt, rotiert es mit den Armen, um\n" + "sich wieder aufzuladen."); + +static const u8 DexDescription_Magby_1[] = _( + "MAGBYs Gesundheitszustand kann man\n" + "am Feuer erkennen, das es ausatmet.\n" + "Wenn es gelbe Flammen ausstößt, ist es"); +static const u8 DexDescription_Magby_2[] = _( + "in guter Verfassung. Ist es erschöpft,\n" + "vermischen sich die Flammen mit\n" + "schwarzem Rauch."); + +static const u8 DexDescription_Miltank_1[] = _( + "MILTANK gibt täglich 20 Liter Milch.\n" + "Sie ist süßlich und wird von Kindern und\n" + "Erwachsenen gleichermaßen genossen."); +static const u8 DexDescription_Miltank_2[] = _( + "Menschen, die keine Milch trinken,\n" + "essen sie stattdessen als Joghurt."); + +static const u8 DexDescription_Heiteira_1[] = _( + "HEITEIRA nimmt mit seinem flauschigen\n" + "Fell Traurigkeit wahr. Es hastet zu\n" + "einer traurigen Person, egal, wie weit"); +static const u8 DexDescription_Heiteira_2[] = _( + "diese entfernt ist und teilt ein \n" + "GLÜCKS-EI mit ihr, um sie zum Lächeln\n" + "zu bringen."); + +static const u8 DexDescription_Raikou_1[] = _( + "RAIKOU ist so schnell wie der Blitz. Das\n" + "Gebrüll dieses POKéMON sendet\n" + "Schockwellen aus, die wie Donnerschläge"); +static const u8 DexDescription_Raikou_2[] = _( + "durch die Luft beben und den Boden\n" + "erschüttern."); + +static const u8 DexDescription_Entei_1[] = _( + "ENTEI verfügt über die Leidenschaft\n" + "von Magma. Dieses POKéMON wurde\n" + "bei einem Vulkanausbruch geboren"); +static const u8 DexDescription_Entei_2[] = _( + "und bringt Feuersbrünste hervor, die\n" + "alles auslöschen, was mit ihnen in\n" + "Kontakt kommt."); + +static const u8 DexDescription_Suicune_1[] = _( + "SUICUNE wohnt die Reinheit einer\n" + "Quelle inne. Es bewegt sich graziös und \n" + "hat die Macht, schmutziges Wasser zu"); +static const u8 DexDescription_Suicune_2[] = _( + "reinigen."); + +static const u8 DexDescription_Larvitar_1[] = _( + "LARVITAR wurde tief unter der Erde\n" + "geboren. Um an die Oberfläche zu\n" + "gelangen, muss es sich durch das"); +static const u8 DexDescription_Larvitar_2[] = _( + "Erdreich fressen. Erst dann bekommt es\n" + "seine Eltern zu Gesicht."); + +static const u8 DexDescription_Pupitar_1[] = _( + "PUPITAR erzeugt in seinem Körper ein\n" + "Gas, das es komprimiert und kraftvoll\n" + "ausstößt, um sich wie ein"); +static const u8 DexDescription_Pupitar_2[] = _( + "Düsenflugzeug anzutreiben. Sein\n" + "Körper ist sehr robust und er hält\n" + "auch massivem Stahl stand."); + +static const u8 DexDescription_Despotar_1[] = _( + "DESPOTAR ist erstaunlich stark. Es\n" + "kann einen ganzen Berg vernichten, um\n" + "sein Nest zu bauen. Dieses POKéMON"); +static const u8 DexDescription_Despotar_2[] = _( + "wandert in den Bergen umher und sucht\n" + "nach Gegnern für einen Kampf."); + +static const u8 DexDescription_Lugia_1[] = _( + "LUGIAs Flügel haben eine\n" + "zerstörerische Kraft. Bereits ein\n" + "leichtes Flattern kann Häuser"); +static const u8 DexDescription_Lugia_2[] = _( + "hinfortwehen. Daher hat sich dieses\n" + "POKéMON dafür entschieden, tief unter\n" + "dem Meer zu leben, wo es niemand sieht."); + +static const u8 DexDescription_HoOh_1[] = _( + "HO-OHs Federn leuchten in sieben\n" + "Farben, je nachdem aus welchem Winkel\n" + "das Licht auf sie fällt."); +static const u8 DexDescription_HoOh_2[] = _( + "Die Federn sollen ihrem Besitzer Glück\n" + "bringen. Dieses POKéMON lebt am Fuße\n" + "eines Regenbogens."); + +static const u8 DexDescription_Celebi_1[] = _( + "Dieses POKéMON kommt aus der Zukunft\n" + "und ist durch die Zeit gereist. Solange\n" + "CELEBI auftaucht,"); +static const u8 DexDescription_Celebi_2[] = _( + "ist der Menschheit angeblich eine\n" + "rosige Zukunft beschieden."); + +static const u8 DexDescription_Geckarbor_1[] = _( + "Mit den kleinen Haken unter seinen\n" + "Füßen kann GECKARBOR an Wänden\n" + "hochklettern. Dieses POKéMON greift"); +static const u8 DexDescription_Geckarbor_2[] = _( + "Feinde an, indem es mit seinem\n" + "mächtigen Schweif zuschlägt."); + +static const u8 DexDescription_Reptain_1[] = _( + "REPTAIN kann sich mit den Blättern, die\n" + "aus seinem Körper herauswachsen, im\n" + "Wald hervorragend tarnen."); +static const u8 DexDescription_Reptain_2[] = _( + "Dieses POKéMON ist ein wahrer Meister\n" + "darin, auf die Bäume des Dschungels zu\n" + "klettern."); + +static const u8 DexDescription_Gewaldro_1[] = _( + "Die Blätter, die auf GEWALDROs Körper\n" + "wachsen, sind sehr scharfkantig. Dieses\n" + "POKéMON ist sehr agil. Es hüpft von"); +static const u8 DexDescription_Gewaldro_2[] = _( + "Ast zu Ast und springt seine Feinde\n" + "von oben oder hinten an."); + +static const u8 DexDescription_Flemmli_1[] = _( + "FLEMMLI hängt an seinem Trainer wie\n" + "eine Klette. Es schlurft immer hinter ihm\n" + "her. Dieses POKéMON spuckt 1000 Grad"); +static const u8 DexDescription_Flemmli_2[] = _( + "heißes Feuer, das seinen Feinden\n" + "ordentlich einheizt."); + +static const u8 DexDescription_Jungglut_1[] = _( + "JUNGGLUT trainiert seine Beine und\n" + "Oberschenkel, indem es über Felder und\n" + "Berge läuft. Die Beine dieses POKéMON"); +static const u8 DexDescription_Jungglut_2[] = _( + "sind sowohl schnell als auch kräftig,\n" + "so dass es 10 Tritte pro Sekunde\n" + "ausführen kann."); + +static const u8 DexDescription_Lohgock_1[] = _( + "LOHGOCK stößt heftige Flammen aus\n" + "seinen Handgelenken aus und greift\n" + "seine Feinde mutig an. Je stärker ein"); +static const u8 DexDescription_Lohgock_2[] = _( + "Feind ist, desto stärker lodern die\n" + "Handgelenke dieses POKéMON."); + +static const u8 DexDescription_Hydropi_1[] = _( + "Die Flosse an HYDROPIs Kopf dient als\n" + "hochempfindliches Radar. Damit kann es\n" + "Bewegungen im Wasser und in der Luft"); +static const u8 DexDescription_Hydropi_2[] = _( + "wahrnehmen. So weiß es jederzeit, was\n" + "in seiner Umgebung passiert, ohne\n" + "dabei seine Augen zu benutzen."); + +static const u8 DexDescription_Moorabbel_1[] = _( + "MOORABBELs Körper ist mit einem\n" + "klebrigen Film überzogen, durch den es\n" + "an Land überleben kann. Dieses POKéMON"); +static const u8 DexDescription_Moorabbel_2[] = _( + "spielt bei Ebbe in den Schlammpfützen\n" + "am Strand."); + +static const u8 DexDescription_Sumpex_1[] = _( + "SUMPEX ist sehr stark. Es kann mit\n" + "Leichtigkeit einen Felsblock bewegen,\n" + "der über eine Tonne wiegt."); +static const u8 DexDescription_Sumpex_2[] = _( + "Weiterhin ist es mit einem exzellenten\n" + "Sehvermögen ausgestattet, wodurch es\n" + "auch in trüben Gewässern sehen kann."); + +static const u8 DexDescription_Fiffyen_1[] = _( + "Sobald FIFFYEN eine Bewegung wahr-\n" + "nimmt, schnappt es zu. Es jagt seine\n" + "Beute so lange, bis sie vollkommen"); +static const u8 DexDescription_Fiffyen_2[] = _( + "erschöpft ist. Wenn sich die Beute\n" + "allerdings wehrt, kann es passieren, \n" + "dass FIFFYEN klein beigibt und flieht."); + +static const u8 DexDescription_Magnayen_1[] = _( + "MAGNAYEN sendet deutliche Signale\n" + "aus, wenn es sich auf einen Angriff\n" + "vorbereitet. Es knurrt heftig und macht"); +static const u8 DexDescription_Magnayen_2[] = _( + "sich flach. Dieses POKéMON kann mit\n" + "seinen spitzen Zähnen brutal zubeißen."); + +static const u8 DexDescription_Zigzachs_1[] = _( + "ZIGZACHS ist ein rastloser Wanderer.\n" + "Dieses POKéMON ist nämlich sehr\n" + "neugierig und es inspiziert alles,"); +static const u8 DexDescription_Zigzachs_2[] = _( + "was ihm zufällig begegnet."); + +static const u8 DexDescription_Geradaks_1[] = _( + "GERADAKS rennt immer mit vollem Tempo\n" + "und nie im Zickzack, sondern nur gerade.\n" + "Wenn ihm ein Hindernis im Weg ist,"); +static const u8 DexDescription_Geradaks_2[] = _( + "läuft es rechtwinklig daran vorbei. Für\n" + "dieses POKéMON stellen leichte Kurven\n" + "eine große Herausforderung dar."); + +static const u8 DexDescription_Waumpel_1[] = _( + "WAUMPEL kann mit den Stacheln an\n" + "seinem Hinterteil die Rinde von Bäumen\n" + "entfernen und ernährt sich von dem"); +static const u8 DexDescription_Waumpel_2[] = _( + "austretenden Saft. An den Füßen dieses\n" + "POKéMON befinden sich Saugnäpfe, mit\n" + "denen es auch an Glas nicht abrutscht."); + +static const u8 DexDescription_Schaloko_1[] = _( + "SCHALOKO bindet sich mit einem\n" + "Seidenfaden an einen Ast. Es baumelt\n" + "dort und wartet auf seine Entwicklung."); +static const u8 DexDescription_Schaloko_2[] = _( + "Durch ein kleines Loch in seinem\n" + "Seidenkokon lugt es heraus."); + +static const u8 DexDescription_Papinella_1[] = _( + "PAPINELLAs Lieblingsspeise ist\n" + "Blütenstaub. Wenn du dieses POKéMON\n" + "beobachten möchtest, musst du bloß"); +static const u8 DexDescription_Papinella_2[] = _( + "einen Blumentopf vor ein geöffnetes\n" + "Fenster stellen. PAPINELLA wird sich\n" + "diese Leckerei nicht entgehen lassen."); + +static const u8 DexDescription_Panekon_1[] = _( + "PANEKON baut seinen schützenden\n" + "Kokon, indem es seinen Körper mit\n" + "feiner Seide einwickelt, die aus seinem"); +static const u8 DexDescription_Panekon_2[] = _( + "Mund austritt. Wenn sein Körper mit\n" + "Seide bedeckt ist, wird diese hart. Im\n" + "Kokon wartet es auf seine Entwicklung."); + +static const u8 DexDescription_Pudox_1[] = _( + "PUDOX wird instinktiv vom Licht\n" + "angezogen. In hell erleuchteten \n" + "Städten kann man Scharen dieses"); +static const u8 DexDescription_Pudox_2[] = _( + "POKéMON dabei beobachten, die\n" + "großen Schaden anrichten, indem sie die\n" + "Blätter von Bäumen abfressen."); + +static const u8 DexDescription_Loturzel_1[] = _( + "LOTURZEL lebt auf der Wasseroberfläche\n" + "von Teichen oder Seen. Es wird\n" + "schwächer, wenn sein breites Blatt"); +static const u8 DexDescription_Loturzel_2[] = _( + "abstirbt. Nur selten geht dieses\n" + "POKéMON an Land, um nach sauberem\n" + "Wasser Ausschau zu halten."); + +static const u8 DexDescription_Lombrero_1[] = _( + "LOMBRERO liebt die Nacht und wird mit\n" + "Einbruch der Dunkelheit aktiv. Es spielt\n" + "auch gerne Streiche."); +static const u8 DexDescription_Lombrero_2[] = _( + "Wenn es Angler sieht, zieht es unter\n" + "Wasser an ihren Angelschnüren und\n" + "erfreut sich an ihrer Entrüstung."); + +static const u8 DexDescription_Kappalores_1[] = _( + "KAPPALORES fängt sofort zu tanzen an,\n" + "wenn es stimmungsvolle, feierliche Musik\n" + "vernimmt. Dieses POKéMON erscheint"); +static const u8 DexDescription_Kappalores_2[] = _( + "angeblich, wenn es Kinder auf \n" + "Wanderausflügen singen hört."); + +static const u8 DexDescription_Samurzel_1[] = _( + "SAMURZEL hängt sich mit dem Kopf an\n" + "einen Ast. Dabei entzieht es dem Baum\n" + "Feuchtigkeit. Je mehr Wasser es trinkt,"); +static const u8 DexDescription_Samurzel_2[] = _( + "desto glänzender wird der Körper dieses\n" + "POKéMON."); + +static const u8 DexDescription_Blanas_1[] = _( + "BLANAS lebt in dichten Wäldern.\n" + "Manchmal wagt es sich aus dem Wald\n" + "heraus, um Menschen zu erschrecken."); +static const u8 DexDescription_Blanas_2[] = _( + "Dieses POKéMON mag es überhaupt nicht,\n" + "wenn man seine lange Nase zwickt."); + +static const u8 DexDescription_Tengulist_1[] = _( + "TENGULIST ist ein geheimnisvolles\n" + "POKéMON, das angeblich auf hohen\n" + "Bäumen lebt, die tausende von Jahren"); +static const u8 DexDescription_Tengulist_2[] = _( + "alt sind. Mit den Blätterventilatoren an\n" + "seinen Händen kann es heftige Stürme\n" + "erzeugen."); + +static const u8 DexDescription_Schwalbini_1[] = _( + "Mutig behauptet SCHWALBINI sein\n" + "Territorium gegen Eindringlinge, so\n" + "stark diese auch sein mögen."); +static const u8 DexDescription_Schwalbini_2[] = _( + "Dieses unerschrockene POKéMON bleibt\n" + "trotz einer Niederlage angriffslustig,\n" + "heult aber laut, wenn es Hunger hat."); + +static const u8 DexDescription_Schwalboss_1[] = _( + "Dieses POKéMON taucht in einem steilen\n" + "Winkel ab, sobald es Beute wahrgenommen\n" + "hat. Es packt seine Beute mit"); +static const u8 DexDescription_Schwalboss_2[] = _( + "seinen Krallen und lässt sie\n" + "nicht mehr entkommen."); + +static const u8 DexDescription_Wingull_1[] = _( + "Man sieht WINGULL oft mit seiner\n" + "Beute oder seinen Besitztümern im\n" + "Schnabel herumfliegen auf der Suche"); +static const u8 DexDescription_Wingull_2[] = _( + "nach geeigneten Verstecken. Dieses\n" + "POKéMON fliegt durch die Lüfte, als\n" + "würde es gleiten."); + +static const u8 DexDescription_Pelipper_1[] = _( + "PELIPPER transportiert kleine POKéMON\n" + "und Eier in seinem riesigen Schnabel\n" + "durch die Lüfte. Dieses POKéMON baut"); +static const u8 DexDescription_Pelipper_2[] = _( + "sein Nest auf steilen Klippen am Meer."); + +static const u8 DexDescription_Trasla_1[] = _( + "TRASLA nimmt mit den Hörnern an seinem\n" + "Kopf die Gefühle von Menschen wahr.\n" + "Menschen bekommen dieses POKéMON"); +static const u8 DexDescription_Trasla_2[] = _( + "nur selten zu Gesicht. Wenn es bemerkt,\n" + "dass eine Person gut gelaunt ist, traut\n" + "es sich näher an sie heran."); + +static const u8 DexDescription_Kirlia_1[] = _( + "Man sagt, dass ein KIRLIA, das häufig\n" + "positive Emotionen seines TRAINERs\n" + "wahrnimmt, sehr schön wird."); +static const u8 DexDescription_Kirlia_2[] = _( + "Dieses POKéMON kontrolliert\n" + "psychokinetische Energie mit seinem\n" + "hochentwickelten Gehirn."); + +static const u8 DexDescription_Guardevoir_1[] = _( + "GUARDEVOIR kann in die Zukunft\n" + "schauen. Wenn es eine Gefahr für seinen\n" + "TRAINER voraussieht, entlädt es seine"); +static const u8 DexDescription_Guardevoir_2[] = _( + "psychokinetische Energie mit voller\n" + "Kraft."); + +static const u8 DexDescription_Gehweiher_1[] = _( + "GEHWEIHER scheidet aus seinen Zehen\n" + "ein Öl aus, das es ihm ermöglicht, über\n" + "Wasser zu gleiten. Dieses POKéMON"); +static const u8 DexDescription_Gehweiher_2[] = _( + "ernährt sich von Mikroorganismen aus\n" + "Teichen und Seen."); + +static const u8 DexDescription_Maskeregen_1[] = _( + "MASKEREGEN schüchtert seine Feinde\n" + "mit den augenähnlichen Mustern auf\n" + "seinen Antennen ein. Dieses POKéMON"); +static const u8 DexDescription_Maskeregen_2[] = _( + "kann mit seinen vier Flügeln wie ein\n" + "Hubschrauber in jede Richtung fliegen,\n" + "sogar seitwärts und rückwärts."); + +static const u8 DexDescription_Knilz_1[] = _( + "KNILZ lebt im feuchten Erdboden\n" + "finsterer Wälder. Es wird oft reglos\n" + "unter herabgefallenen Blättern"); +static const u8 DexDescription_Knilz_2[] = _( + "gefunden. Dieses POKéMON ernährt sich\n" + "von Kompost aus verrotteten Blättern."); + +static const u8 DexDescription_Kapilz_1[] = _( + "Mit leichtfüßiger Beinarbeit nähert \n" + "sich KAPILZ seinen Feinden und\n" + "schlägt dann mit seinen dehnbaren"); +static const u8 DexDescription_Kapilz_2[] = _( + "Armen um sich. Die Kampftechnik dieses\n" + "POKéMON treibt Profiboxern die\n" + "Schamesröte ins Gesicht."); + +static const u8 DexDescription_Bummelz_1[] = _( + "BUMMELZ geht zwanzig Stunden pro Tag\n" + "müßig. Da es sich sehr wenig bewegt,\n" + "braucht es auch nicht viel Nahrung."); +static const u8 DexDescription_Bummelz_2[] = _( + "Seine Tagesration besteht lediglich aus\n" + "drei Blättern."); + +static const u8 DexDescription_Muntier_1[] = _( + "MUNTIER brennt darauf, sich\n" + "auszutoben. Es kann nicht einmal für\n" + "eine Minute stillsitzen. Es gerät in"); +static const u8 DexDescription_Muntier_2[] = _( + "Stress, wenn es sich nicht andauernd\n" + "bewegen kann."); + +static const u8 DexDescription_Letarking_1[] = _( + "LETARKING verbringt den Tag damit,\n" + "herumzuliegen und nichts zu tun. Es \n" + "ernährt sich von Gras, das in seiner"); +static const u8 DexDescription_Letarking_2[] = _( + "Reichweite wächst. Hat es alles\n" + "aufgefressen, so sucht es sich\n" + "widerwillig ein anderes Plätzchen."); + +static const u8 DexDescription_Nincada_1[] = _( + "NINCADA lebt viele Jahre in absoluter\n" + "Dunkelheit unter der Erde. Dieses\n" + "POKéMON nimmt Nährstoffe aus"); +static const u8 DexDescription_Nincada_2[] = _( + "Baumwurzeln auf. Es rührt sich nicht,\n" + "da es auf seine Entwicklung wartet."); + +static const u8 DexDescription_Ninjask_1[] = _( + "NINJASK bewegt sich so schnell, dass\n" + "man es nicht sehen kann. Seine Schreie\n" + "sind aber laut und deutlich zu hören."); +static const u8 DexDescription_Ninjask_2[] = _( + "Deshalb hielt man dieses POKéMON lange\n" + "für unsichtbar."); + +static const u8 DexDescription_Ninjatom_1[] = _( + "NINJATOMs harter Körper bewegt sich\n" + "überhaupt nicht. Er scheint bloß eine\n" + "hohle Schale zu sein. Dieses POKéMON"); +static const u8 DexDescription_Ninjatom_2[] = _( + "soll angeblich die Seele eines jeden\n" + "stehlen, der hinterrücks einen Blick in\n" + "seinen hohlen Körper riskiert."); + +static const u8 DexDescription_Flurmel_1[] = _( + "Normalerweise ist FLURMELs Stimme sehr\n" + "leise, selbst mit größter Anstrengung\n" + "ist sie kaum hörbar. Wenn dieses"); +static const u8 DexDescription_Flurmel_2[] = _( + "POKéMON jedoch eine Gefahr wittert,\n" + "stößt es ohrenbetäubende Schreie aus."); + +static const u8 DexDescription_Krakeelo_1[] = _( + "KRAKEELOs Brüllen kann ein Holzhaus zum\n" + "Einsturz bringen. Es setzt seine Stimme\n" + "ein, um seine Gegner anzugreifen."); +static const u8 DexDescription_Krakeelo_2[] = _( + "Die runden Ohren dieses POKéMON dienen\n" + "als Lautsprecher."); + +static const u8 DexDescription_Krawumms_1[] = _( + "KRAWUMMS kann durch sein Brüllen\n" + "Erdbeben auslösen. Wenn dieses\n" + "POKéMON durch seine Körperöffnungen"); +static const u8 DexDescription_Krawumms_2[] = _( + "kräftig einatmet, ist es kurz davor,\n" + "ein mächtiges Brüllen von sich zu geben."); + +static const u8 DexDescription_Makuhita_1[] = _( + "MAKUHITA ist sehr zäh. Selbst wenn es im\n" + "Kampf mehrfach niedergeschlagen\n" + "wurde, steht es immer wieder auf und"); +static const u8 DexDescription_Makuhita_2[] = _( + "greift seinen Gegner an. Bei jedem Mal\n" + "speichert es mehr Energie in seinem\n" + "Körper für seine Entwicklung."); + +static const u8 DexDescription_Hariyama_1[] = _( + "HARIYAMA führt seinen berüchtigten\n" + "Streckarm-Schlag überall aus. Ein Schlag\n" + "von diesem POKéMON reicht aus,"); +static const u8 DexDescription_Hariyama_2[] = _( + "um einen Strommast zu zerlegen."); + +static const u8 DexDescription_Azurill_1[] = _( + "AZURILL schleudert seinen Schweif wie\n" + "ein Lasso weit aus und fliegt dann \n" + "selbst hinterher. Ein AZURILL"); +static const u8 DexDescription_Azurill_2[] = _( + "hat es auf diese Weise geschafft, die\n" + "Rekordweite von 10 Metern\n" + "zurückzulegen."); + +static const u8 DexDescription_Nasgnet_1[] = _( + "NASGNET besitzt eine magnetische\n" + "Nase, die immer nach Norden zeigt. Wenn\n" + "sich zwei NASGNET treffen, können sie"); +static const u8 DexDescription_Nasgnet_2[] = _( + "sich einander nicht zuwenden, da ihre\n" + "magnetischen Nasen sich gegenseitig\n" + "abstoßen."); + +static const u8 DexDescription_Eneco_1[] = _( + "ENECO ist davon fasziniert,\n" + "Gegenstände zu bewegen und sie zu\n" + "jagen. Dieses POKéMON jagt häufig"); +static const u8 DexDescription_Eneco_2[] = _( + "seinen eigenen Schweif, so dass ihm\n" + "schwindlig wird."); + +static const u8 DexDescription_Enekoro_1[] = _( + "ENEKORO liebt seine Eigenständigkeit.\n" + "So kann es das tun, was es möchte, und\n" + "kann selbst das Tempo bestimmen."); +static const u8 DexDescription_Enekoro_2[] = _( + "Da dieses POKéMON schläft und isst,\n" + "wenn es Lust dazu hat, ist sein\n" + "Tagesablauf eher zufälliger Natur."); + +static const u8 DexDescription_Zobiris_1[] = _( + "ZOBIRIS führt ein ruhiges, \n" + "zurückgezogenes Leben tief im Innern\n" + "einer Höhle. Es ist aber trotzdem sehr"); +static const u8 DexDescription_Zobiris_2[] = _( + "gefürchtet, da man sagt, es stehle die\n" + "Seelen der Menschen, wenn seine Augen\n" + "im Dunkeln Furcht erregend funkeln."); + +static const u8 DexDescription_Flunkifer_1[] = _( + "FLUNKIFERs sagenhafte Kiefer sind\n" + "eigentlich umgewandelte Stahlhörner.\n" + "Sein unterwürfiger Gesichtsausdruck"); +static const u8 DexDescription_Flunkifer_2[] = _( + "dient dazu, seinen Gegner in Sicherheit\n" + "zu wiegen, so dass er unaufmerksam\n" + "wird. Dann schnappt es zu!"); + +static const u8 DexDescription_Stollunior_1[] = _( + "Dieses POKéMON hat einen Körper aus\n" + "Stahl. STOLLUNIOR ernährt sich von\n" + "Eisenerz aus den Bergen. Zuweilen"); +static const u8 DexDescription_Stollunior_2[] = _( + "richtet es großen Schaden an, weil es\n" + "Brücken und Bahngleise auffrisst."); + +static const u8 DexDescription_Stollrak_1[] = _( + "STOLLRAK temperiert seinen Körper,\n" + "indem es ausgesprochen nahrhaftes \n" + "Quellwasser trinkt, bis es völlig"); +static const u8 DexDescription_Stollrak_2[] = _( + "aufgebläht ist. Dieses POKéMON baut\n" + "sein Nest in der Nähe von Quellen, aus\n" + "denen köstliches Wasser sprudelt."); + +static const u8 DexDescription_Stolloss_1[] = _( + "STOLLOSS nennt einen ganzen Berg sein\n" + "Territorium. Gnadenlos schlägt es jeden\n" + "in die Flucht, der sein Reich betritt."); +static const u8 DexDescription_Stolloss_2[] = _( + "Dieses POKéMON behält sein Territorium\n" + "jederzeit im Auge."); + +static const u8 DexDescription_Meditie_1[] = _( + "MEDITIE unterzieht sich einem\n" + "strikten mentalen Training tief in den\n" + "Bergen. Wenn es meditiert, verliert es"); +static const u8 DexDescription_Meditie_2[] = _( + "jedoch immer seine Konzentration.\n" + "Deshalb wird sein Training niemals\n" + "ein Ende haben."); + +static const u8 DexDescription_Meditalis_1[] = _( + "Mittels Meditation erhöht MEDITALIS\n" + "seine Körperenergie und schärft seinen\n" + "sechsten Sinn. Dieses POKéMON"); +static const u8 DexDescription_Meditalis_2[] = _( + "verbirgt sich, indem es eins mit den\n" + "Feldern und Bergen wird."); + +static const u8 DexDescription_Frizelbliz_1[] = _( + "FRIZELBLIZ speichert Elektrizität in\n" + "seiner langen Körperbehaarung. Dieses\n" + "POKéMON stimuliert seine"); +static const u8 DexDescription_Frizelbliz_2[] = _( + "Beinmuskulatur durch Stromstöße.\n" + "Dadurch ist es in der Lage, explosiv\n" + "zu beschleunigen."); + +static const u8 DexDescription_Voltenso_1[] = _( + "VOLTENSO entlädt ständig Elektrizität\n" + "aus seiner Mähne. Es fliegen dabei\n" + "Funken, die zuweilen zu Waldbränden"); +static const u8 DexDescription_Voltenso_2[] = _( + "führen. In einem Kampf erzeugt dieses\n" + "POKéMON Gewitterwolken."); + +static const u8 DexDescription_Plusle_1[] = _( + "PLUSLE dient seinen Artgenossen als\n" + "Cheerleader. Wenn ein Teamkamerad\n" + "im Kampf erfolgreich ist, erzeugt es"); +static const u8 DexDescription_Plusle_2[] = _( + "das prasselnde Geräusch von Funken, um\n" + "so seine Freude zu zeigen."); + +static const u8 DexDescription_Minun_1[] = _( + "MINUN kümmert sich mehr um das\n" + "Anfeuern seiner Partner als um seine\n" + "eigene Sicherheit. Es nutzt die"); +static const u8 DexDescription_Minun_2[] = _( + "Elektrizität in seinem Körper dazu,\n" + "einen Funkenregen zu erzeugen und\n" + "seine Teamkameraden anzufeuern."); + +static const u8 DexDescription_Volbeat_1[] = _( + "Wenn es Nacht wird, beginnt VOLBEATs\n" + "Schweif zu leuchten. Es kommuniziert\n" + "mit anderen, indem es die Helligkeit"); +static const u8 DexDescription_Volbeat_2[] = _( + "und das Blinken dieses Lichts reguliert.\n" + "Dieses POKéMON wird vom süßen Duft\n" + "der ILLUMISE angezogen."); + +static const u8 DexDescription_Illumise_1[] = _( + "ILLUMISE zieht ganze VOLBEAT-Scharen\n" + "mit seinem süßlichen Duft an. Dann\n" + "führt es diesen hell leuchtenden"); +static const u8 DexDescription_Illumise_2[] = _( + "Schwarm an, indem es geometrische\n" + "Figuren an den Nachthimmel malt."); + +static const u8 DexDescription_Roselia_1[] = _( + "ROSELIA verschießt scharfe Stacheln\n" + "auf jeden Feind, der versucht, die\n" + "Blumen an seinen Armen zu stehlen."); +static const u8 DexDescription_Roselia_2[] = _( + "Der Duft dieses POKéMON beruhigt\n" + "Lebewesen."); + +static const u8 DexDescription_Schluppuck_1[] = _( + "Eigentlich besteht SCHLUPPUCKs Körper\n" + "nur aus einem Magen. Daher kann es\n" + "etwas verschlingen, das beinahe seine"); +static const u8 DexDescription_Schluppuck_2[] = _( + "Größe hat. Sein Magen enthält eine\n" + "spezielle Flüssigkeit, die wirklich alles\n" + "verdauen kann."); + +static const u8 DexDescription_Schlukwech_1[] = _( + "Wenn SCHLUKWECH Beute sichtet,\n" + "verspritzt es eine höchst giftige\n" + "Substanz aus seinen Poren und"); +static const u8 DexDescription_Schlukwech_2[] = _( + "besprüht damit sein Ziel. Wenn die Beute\n" + "geschwächt ist, schluckt es sie mit\n" + "seinem riesigen Maul im Ganzen herunter."); + +static const u8 DexDescription_Kanivanha_1[] = _( + "KANIVANHAs starke Kiefer und seine\n" + "spitzen Zähne verfügen über die \n" + "zerstörerische Kraft, Bootsrümpfe"); +static const u8 DexDescription_Kanivanha_2[] = _( + "verschlingen zu können. Dieses POKéMON\n" + "hat schon viele Boote versenkt."); + +static const u8 DexDescription_Tohaido_1[] = _( + "TOHAIDO trägt den Spitznamen\n" + "“Tyrann des Meeres” und ist\n" + "sehr gefürchtet. Seine grausamen Zähne"); +static const u8 DexDescription_Tohaido_2[] = _( + "wachsen sofort nach, wenn sie\n" + "ausgebrochen sind. Es kann sogar einen\n" + "Öltanker zerreißen."); + +static const u8 DexDescription_Wailmer_1[] = _( + "WAILMERs Nasenlöcher liegen über\n" + "seinen Augen. Dieses verspielte\n" + "POKéMON erschreckt gern Menschen,"); +static const u8 DexDescription_Wailmer_2[] = _( + "indem es das Meerwasser, das es in\n" + "seinem Körper speichert, mit aller Kraft\n" + "herausprustet."); + +static const u8 DexDescription_Wailord_1[] = _( + "WAILORD ist bisher das größte aller\n" + "identifizierten POKéMON. Es schwimmt\n" + "reglos auf dem offenen Meer und nimmt"); +static const u8 DexDescription_Wailord_2[] = _( + "mit seinem enormen Maul riesige Mengen\n" + "an Nahrung auf."); + +static const u8 DexDescription_Camaub_1[] = _( + "CAMAUB ist nicht besonders helle. Es\n" + "nimmt nicht einmal wahr, wenn es\n" + "getroffen wurde. Ein Hungergefühl"); +static const u8 DexDescription_Camaub_2[] = _( + "allerdings kann es nicht einmal eine\n" + "Sekunde lang aushalten. In seinem\n" + "Körper brodelt glühend heißes Magma."); + +static const u8 DexDescription_Camerupt_1[] = _( + "CAMERUPT trägt einen Vulkan in seinem\n" + "Körper. 10.000 Grad heißes Magma fließt\n" + "in ihm. Manchmal brechen die Höcker auf"); +static const u8 DexDescription_Camerupt_2[] = _( + "seinem Rücken aus und verspucken \n" + "glühend heißes Magma."); + +static const u8 DexDescription_Qurtel_1[] = _( + "QURTEL schaufelt sich auf der Suche\n" + "nach Kohle durch die Berge. Wenn es\n" + "welche findet, füllt es die Hohlräume"); +static const u8 DexDescription_Qurtel_2[] = _( + "seines Panzers mit Kohle und verbrennt\n" + "diese. Wenn es angegriffen wird, stößt\n" + "es dicken schwarzen Rauch aus."); + +static const u8 DexDescription_Spoink_1[] = _( + "SPOINK hüpft auf seinem Schweif durch\n" + "die Gegend. Die Erschütterung des\n" + "Hüpfens bringt sein Herz zum Schlagen."); +static const u8 DexDescription_Spoink_2[] = _( + "Deshalb kann dieses POKéMON das Hüpfen\n" + "nicht sein lassen, ansonsten würde sein\n" + "Herz aufhören zu schlagen."); + +static const u8 DexDescription_Groink_1[] = _( + "GROINK benutzt die schwarzen Perlen\n" + "an seinem Körper dazu, die\n" + "psychischen Kraftwellen zu verstärken."); +static const u8 DexDescription_Groink_2[] = _( + "Wenn es diese spezielle Fähigkeit nutzt,\n" + "wird sein schnaubender Atem\n" + "schwerfällig."); + +static const u8 DexDescription_Pandir_1[] = _( + "Jedes PANDIR auf der Welt soll ein\n" + "einzigartiges Fleckenmuster haben. Der\n" + "schwankende Gang dieses POKéMON"); +static const u8 DexDescription_Pandir_2[] = _( + "erweckt den Eindruck, es würde tanzen."); + +static const u8 DexDescription_Knacklion_1[] = _( + "KNACKLIONs Bau ist eine Art in den Sand\n" + "gegrabener Kessel. Dieses POKéMON\n" + "wartet geduldig auf Beute, um sie in"); +static const u8 DexDescription_Knacklion_2[] = _( + "seinen Bau zu werfen. Seine gigan-\n" + "tischen Kiefer verfügen über genügend\n" + "Kraft, um einen Felsen zu zerquetschen."); + +static const u8 DexDescription_Vibrava_1[] = _( + "Um seine Beute zu schwächen, erzeugt\n" + "VIBRAVA Ultraschallwellen, indem es\n" + "seine Flügel vibrieren lässt."); +static const u8 DexDescription_Vibrava_2[] = _( + "Die Ultraschallwellen dieses POKéMON \n" + "sind so stark, dass sie bei Menschen\n" + "Kopfschmerzen verursachen können."); + +static const u8 DexDescription_Libelldra_1[] = _( + "LIBELLDRA wird auch “Geist der\n" + "Wüste” genannt. Da seine flatternden\n" + "Flügel eine Sandwolke aufwirbeln, ist"); +static const u8 DexDescription_Libelldra_2[] = _( + "dieses POKéMON beim Fliegen immer\n" + "von einem Sandsturm umgeben."); + +static const u8 DexDescription_Tuska_1[] = _( + "TUSKA lebt an trockenen Orten, z. B. in\n" + "Wüsten. Es versprüht einen starken\n" + "Duft aus seiner Blume, um Beute"); +static const u8 DexDescription_Tuska_2[] = _( + "anzuziehen. Wenn sich Beute nähert,\n" + "verschießt es scharfe Stacheln, um\n" + "seinen Gegner zu überwältigen."); + +static const u8 DexDescription_Noktuska_1[] = _( + "Am Tage bleibt NOKTUSKA reglos, damit es\n" + "in der brennenden Wüstenhitze keine\n" + "Feuchtigkeit verliert."); +static const u8 DexDescription_Noktuska_2[] = _( + "Dieses POKéMON wird bei Nacht aktiv,\n" + "wenn die Temperatur sinkt."); + +static const u8 DexDescription_Wablu_1[] = _( + "WABLU hat leichte, flauschige Flügel,\n" + "die wie Schäfchenwolken aussehen.\n" + "Dieses POKéMON hat keine Angst vor"); +static const u8 DexDescription_Wablu_2[] = _( + "Menschen. Es landet auf ihren Köpfen \n" + "und bleibt dort sitzen wie ein \n" + "wattierter Hut."); + +static const u8 DexDescription_Altaria_1[] = _( + "ALTARIA tanzt und dreht sich in der\n" + "Luft durch viele Schäfchenwolken.\n" + "Indem es mit seiner kristallklaren"); +static const u8 DexDescription_Altaria_2[] = _( + "Stimme Melodien singt, versetzt es\n" + "seine Zuhörer in verträumtes\n" + "Erstaunen."); + +static const u8 DexDescription_Sengo_1[] = _( + "Die Erinnerungen an den Kampf mit\n" + "seinem Erzrivalen VIPITIS haben sich in\n" + "jede Zelle von SENGOs Körper"); +static const u8 DexDescription_Sengo_2[] = _( + "eingebrannt. Dieses POKéMON weicht\n" + "feindlichen Angriffen unheimlich\n" + "raffiniert und geschickt aus."); + +static const u8 DexDescription_Vipitis_1[] = _( + "VIPITIS lebt seit Generationen in\n" + "Fehde mit SENGO. Die Narben auf\n" + "seinem Körper sind Zeugen grausamer"); +static const u8 DexDescription_Vipitis_2[] = _( + "Kämpfe. Dieses POKéMON greift seine\n" + "Gegner mit seinem scharfkantigen\n" + "Schweif an."); + +static const u8 DexDescription_Lunastein_1[] = _( + "LUNASTEIN wurde in der Nähe eines\n" + "Meteoritenkraters entdeckt. Daher\n" + "nehmen einige Menschen an, dass"); +static const u8 DexDescription_Lunastein_2[] = _( + "dieses POKéMON aus dem Weltall stammt.\n" + "Diese Theorie konnte allerdings bisher\n" + "noch nicht belegt werden."); + +static const u8 DexDescription_Sonnfel_1[] = _( + "SONNFEL ist eine neue POKéMON-Spezies,\n" + "die angeblich aus dem Weltall\n" + "kam. Es gleitet durch die"); +static const u8 DexDescription_Sonnfel_2[] = _( + "Luft und bewegt sich leise. Im Kampf\n" + "setzt dieses POKéMON sehr helles Licht\n" + "ein."); + +static const u8 DexDescription_Schmerbe_1[] = _( + "SCHMERBEs empfindliche Barthaare\n" + "dienen ihm als hervorragendes\n" + "Radarsystem. Dieses POKéMON versteckt"); +static const u8 DexDescription_Schmerbe_2[] = _( + "sich im Schlamm, so dass nur noch seine\n" + "Barthaare herausgucken, und wartet\n" + "auf Beute."); + +static const u8 DexDescription_Welsar_1[] = _( + "WELSAR legt viel Wert auf sein\n" + "Territorium. Ein einzelnes POKéMON\n" + "dieser Art nennt einen Teich sein Eigen."); +static const u8 DexDescription_Welsar_2[] = _( + "Wenn sich ein Feind nähert, schlägt es\n" + "um sich und verursacht ein gewaltiges\n" + "Erdbeben."); + +static const u8 DexDescription_Krebscorps_1[] = _( + "KREBSCORPS ist kein heimisches\n" + "POKéMON, sondern wurde als Haustier\n" + "importiert. Schließlich verwilderte es."); +static const u8 DexDescription_Krebscorps_2[] = _( + "Dieses POKéMON ist mittlerweile sehr\n" + "robust und hat seine Population\n" + "vergrößert."); + +static const u8 DexDescription_Krebutack_1[] = _( + "KREBUTACK ist von Natur aus sehr\n" + "gewalttätig, so dass es dauernd andere\n" + "Lebewesen zum Kampf herausfordern"); +static const u8 DexDescription_Krebutack_2[] = _( + "muss. Andere Lebensformen lehnen es ab,\n" + "mit diesem POKéMON in ein und demselben\n" + "Teich zu leben."); + +static const u8 DexDescription_Puppance_1[] = _( + "PUPPANCE bewegt sich, indem es sich auf\n" + "seinem Fuß im Kreis dreht. In sehr alten\n" + "Ruinen wurden primitive Wandmalereien"); +static const u8 DexDescription_Puppance_2[] = _( + "entdeckt, die dieses POKéMON in\n" + "Begleitung von Menschen zeigen."); + +static const u8 DexDescription_Lepumentas_1[] = _( + "LEPUMENTAS sind aus Schlamm gefertigte\n" + "Puppen, die von primitiven Menschen\n" + "hergestellt und durch mysteriöse"); +static const u8 DexDescription_Lepumentas_2[] = _( + "Strahlen zum Leben erweckt wurden.\n" + "Diese POKéMON bewegen sich\n" + "schwebend fort."); + +static const u8 DexDescription_Liliep_1[] = _( + "Von LILIEP nahm man an, es sei seit\n" + "etwa hundert Millionen Jahren\n" + "ausgestorben. Mit seinen wie"); +static const u8 DexDescription_Liliep_2[] = _( + "Blütenblätter geformten Tentakeln\n" + "heftet es sich an einen Felsen auf dem\n" + "Meeresboden und fängt Beute."); + +static const u8 DexDescription_Wielie_1[] = _( + "WIELIE durchforstet den Meeresboden\n" + "nach Beute. Dieses POKéMON fährt\n" + "seinen baumstammartigen Nacken aus"); +static const u8 DexDescription_Wielie_2[] = _( + "und fängt mit seinen acht Tentakeln\n" + "Beute."); + +static const u8 DexDescription_Anorith_1[] = _( + "ANORITH wurde aus einem\n" + "prähistorischen Fossil erzeugt. Dieses\n" + "primitive POKéMON lebte einst in warmen"); +static const u8 DexDescription_Anorith_2[] = _( + "Gewässern. Es klemmt seine Beute\n" + "fest zwischen seine beiden riesigen\n" + "Klauen ein."); + +static const u8 DexDescription_Armaldo_1[] = _( + "Von ARMALDOs hartem Panzer prallen\n" + "alle Angriffe ab. Dieses POKéMON\n" + "hat zwei mächtige Klauen, die es"); +static const u8 DexDescription_Armaldo_2[] = _( + "ausfahren oder einziehen kann. Es hat\n" + "so viel Kraft, dass es damit eine\n" + "Stahlplatte pulverisieren kann."); + +static const u8 DexDescription_Barschwa_1[] = _( + "BARSCHWAs Flossen waren schon immer\n" + "zerfetzt. Wegen seines merkwürdigen\n" + "Aussehens wird dieses POKéMON"); +static const u8 DexDescription_Barschwa_2[] = _( + "weitgehend ignoriert. Es kann sowohl im\n" + "Meer als auch in Flüssen leben."); + +static const u8 DexDescription_Milotic_1[] = _( + "MILOTIC soll das Schönste aller\n" + "POKéMON sein. Es hat die Macht,\n" + "Emotionen wie Wut und Feindseligkeit zu"); +static const u8 DexDescription_Milotic_2[] = _( + "besänftigen und somit erbitterten\n" + "Streit zu vermeiden."); + +static const u8 DexDescription_Formeo_1[] = _( + "FORMEOs Erscheinung ändert sich\n" + "mit dem Wetter. Dieses POKéMON hat\n" + "die Fähigkeit erworben, die mächtige"); +static const u8 DexDescription_Formeo_2[] = _( + "Kraft der Natur zu nutzen, um seinen\n" + "winzigen Körper zu schützen."); + +static const u8 DexDescription_Kecleon_1[] = _( + "KECLEON kann die Farbe seines Körpers\n" + "bei Bedarf verändern, um sich seiner\n" + "Umgebung anzupassen. Es gibt allerdings"); +static const u8 DexDescription_Kecleon_2[] = _( + "eine Ausnahme: Das Zickzackmuster auf\n" + "seinem Bauch kann es nicht verändern."); + +static const u8 DexDescription_Shuppet_1[] = _( + "SHUPPET wird durch Gefühle wie Neid und\n" + "Rachsucht angezogen. Wenn jemand\n" + "starke Rachegelüste entwickelt,"); +static const u8 DexDescription_Shuppet_2[] = _( + "erscheint dieses POKéMON in Scharen\n" + "und reiht sich unter der Dachrinne der\n" + "Person auf."); + +static const u8 DexDescription_Banette_1[] = _( + "BANETTE belegt andere mit Flüchen,\n" + "indem es Nadeln in seinen eigenen\n" + "Körper sticht. Dieses POKéMON war"); +static const u8 DexDescription_Banette_2[] = _( + "ursprünglich eine Mitleid erregende\n" + "Plüschpuppe, die weggeworfen wurde."); + +static const u8 DexDescription_Zwirrlicht_1[] = _( + "ZWIRRLICHT kann durch jede Wand gehen,\n" + "egal, wie dick diese ist. Wenn dieses\n" + "POKéMON sich ein Ziel gesucht hat,"); +static const u8 DexDescription_Zwirrlicht_2[] = _( + "verfolgt es seinen Feind unnachgiebig\n" + "bis zum Sonnenaufgang."); + +static const u8 DexDescription_Zwirrklop_1[] = _( + "ZWIRRKLOPs Körper ist komplett hohl. Es\n" + "wird auch mit einem Schwarzen Loch\n" + "verglichen. Dieses POKéMON nimmt alles"); +static const u8 DexDescription_Zwirrklop_2[] = _( + "in seinem Körper auf, es kommt jedoch\n" + "nichts wieder heraus."); + +static const u8 DexDescription_Tropius_1[] = _( + "Die Früchte am Nacken von TROPIUS\n" + "sind bei Kindern sehr beliebt. Dieses\n" + "POKéMON liebt Früchte und isst sie"); +static const u8 DexDescription_Tropius_2[] = _( + "ständig. Offensichtlich sind ihm wegen\n" + "dieser Vorliebe selber Früchte\n" + "gewachsen."); + +static const u8 DexDescription_Palimpalim_1[] = _( + "PALIMPALIMs Schreie hallen durch\n" + "seinen hohlen Körper. Wenn dieses\n" + "POKéMON wütend wird, erzeugen"); +static const u8 DexDescription_Palimpalim_2[] = _( + "seine Schreie Ultraschallwellen, die\n" + "seine Feinde buchstäblich wegfegen\n" + "können."); + +static const u8 DexDescription_Absol_1[] = _( + "Jedes Mal, wenn ABSOL sich den Menschen\n" + "zeigt, endet dies in einer Katastrophe\n" + "wie Erdbeben oder Sturmflut."); +static const u8 DexDescription_Absol_2[] = _( + "Deswegen ist es auch als das\n" + "Katastrophen-POKéMON bekannt."); + +static const u8 DexDescription_Isso_1[] = _( + "ISSO hat immer ein breites, fröhliches\n" + "Lächeln auf seinem Gesicht. Um \n" + "festzustellen, ob es wütend ist, muss"); +static const u8 DexDescription_Isso_2[] = _( + "man seinen Schweif betrachten. Wenn es\n" + "wütend ist, schlägt es damit auf den\n" + "Boden."); + +static const u8 DexDescription_Schneppke_1[] = _( + "SCHNEPPKE lebt in Gebieten mit heftigem\n" + "Schneefall. In Jahreszeiten, in denen es\n" + "nicht schneit, wie im Frühling oder im"); +static const u8 DexDescription_Schneppke_2[] = _( + "Sommer, nimmt das POKéMON Reißaus, um\n" + "in einer Höhle ein ruhiges Leben unter\n" + "Stalaktiten und Stalagmiten zu führen."); + +static const u8 DexDescription_Firnontor_1[] = _( + "FIRNONTOR hat einen Körper aus Stein,\n" + "den es mit einem Panzer aus Eis noch\n" + "verstärkt. Dieses POKéMON kann"); +static const u8 DexDescription_Firnontor_2[] = _( + "die Luftfeuchtigkeit der Atmosphäre\n" + "einfrieren und in jegliche Form\n" + "verwandeln."); + +static const u8 DexDescription_Seemops_1[] = _( + "SEEMOPS kann schneller rollen als laufen.\n" + "Wenn Gruppen dieses POKéMON \n" + "zusammen essen, klatschen sie"); +static const u8 DexDescription_Seemops_2[] = _( + "gleichzeitig, um ihre Freude zu zeigen.\n" + "Deswegen sind ihre Mahlzeiten sehr\n" + "laut."); + +static const u8 DexDescription_Seejong_1[] = _( + "SEEJONG hat die Angewohnheit, alles,\n" + "was es zum ersten Mal sieht, auf seiner \n" + "Nasenspitze zu jonglieren. Dieses"); +static const u8 DexDescription_Seejong_2[] = _( + "POKéMON hält sich bei Laune, indem es\n" + "manchmal ein SEEMOPS auf seiner Nase\n" + "balanciert und hin- und herrollt."); + +static const u8 DexDescription_Walraisa_1[] = _( + "WALRAISA hat zwei massive Stoßzähne,\n" + "die mit einem Hieb Eisblöcke\n" + "zertrümmern können, die bis zu"); +static const u8 DexDescription_Walraisa_2[] = _( + "10 Tonnen wiegen. Es besitzt eine dicke\n" + "Speckschicht, die es vor eisigen\n" + "Temperaturen schützt."); + +static const u8 DexDescription_Perlu_1[] = _( + "PERLUs kräftige Schale dient nicht\n" + "nur dem Schutz, es nutzt sie auch zum\n" + "Fangen von Beute. Die ausgewachsene"); +static const u8 DexDescription_Perlu_2[] = _( + "Schale eines PERLU weist viele\n" + "Kerben und Kratzer auf."); + +static const u8 DexDescription_Aalabyss_1[] = _( + "AALABYSS entging lange der\n" + "Aufmerksamkeit des Menschen, da es in\n" + "extremen Tiefen des Meeres lebt."); +static const u8 DexDescription_Aalabyss_2[] = _( + "Die Augen dieses POKéMON können\n" + "selbst in den dunklen und trüben Tiefen\n" + "des Meeres einwandfrei sehen."); + +static const u8 DexDescription_Saganabyss_1[] = _( + "SAGANABYSS lebt in extremen Tiefen des\n" + "Südmeeres. Sein Körper ist so angelegt,\n" + "dass er dem enormen Wasserdruck dieser"); +static const u8 DexDescription_Saganabyss_2[] = _( + "unglaublichen Tiefe standhalten kann.\n" + "Daher übersteht dieses POKéMON\n" + "gewöhnliche Attacken unbeschadet."); + +static const u8 DexDescription_Relicanth_1[] = _( + "RELICANTH ist eine POKéMON-Spezies,\n" + "die vor hundert Millionen Jahren\n" + "existierte, ohne jemals ihre Form zu"); +static const u8 DexDescription_Relicanth_2[] = _( + "verändern. Dieses antike POKéMON\n" + "hat ein zahnloses Maul und ernährt sich\n" + "von Mikroorganismen."); + +static const u8 DexDescription_Liebiskus_1[] = _( + "LIEBISKUS lebt in den seichten\n" + "Gewässern der Tropen. Dieses herz-\n" + "förmige POKéMON verdankt seinen Namen"); +static const u8 DexDescription_Liebiskus_2[] = _( + "der Tatsache, dass es hinter Liebes-\n" + "paaren herschwamm, die es in den Wellen\n" + "des Ozeans beobachtet hatte."); + +static const u8 DexDescription_Kindwurm_1[] = _( + "KINDWURM hat den Traum, fliegen zu\n" + "können. In zahlreichen vergeblichen\n" + "Versuchen stürzte es sich die Klippen"); +static const u8 DexDescription_Kindwurm_2[] = _( + "herunter. Daher ist sein Kopf sehr\n" + "robust und so hart wie Stahl geworden."); + +static const u8 DexDescription_Draschel_1[] = _( + "In DRASCHELs panzerartiger Schale\n" + "vollziehen seine Zellen eine\n" + "Transformation, um einen völlig neuen"); +static const u8 DexDescription_Draschel_2[] = _( + "Körper zu bilden. Die Schale dieses\n" + "POKéMON ist ausgesprochen schwer, so\n" + "dass seine Bewegungen träge wirken."); + +static const u8 DexDescription_Brutalanda_1[] = _( + "BRUTALANDA träumte sehr lange davon,\n" + "dass ihm Flügel wachsen mögen. Dieser\n" + "sehnliche Wunsch hat wohl eine"); +static const u8 DexDescription_Brutalanda_2[] = _( + "plötzliche Mutation in den Zellen dieses\n" + "POKéMON hervorgerufen, so dass ihm\n" + "plötzlich prächtige Flügel wuchsen."); + +static const u8 DexDescription_Tanhel_1[] = _( + "Anstelle von Blut fließt eine starke\n" + "magnetische Energie durch TANHELs\n" + "Körper. Dieses POKéMON kommuniziert"); +static const u8 DexDescription_Tanhel_2[] = _( + "mit anderen, indem es kontrollierte\n" + "magnetische Impulse aussendet."); + +static const u8 DexDescription_Metang_1[] = _( + "Wenn zwei TANHEL miteinander\n" + "verschmelzen, entsteht daraus METANG.\n" + "Die Gehirne der TANHEL werden mit"); +static const u8 DexDescription_Metang_2[] = _( + "einem magnetischen Nervensystem\n" + "verbunden. Dadurch erzeugt es starke\n" + "psychokinetische Energie."); + +static const u8 DexDescription_Metagross_1[] = _( + "METAGROSS hat insgesamt vier Gehirne.\n" + "Diese können schwierige Berechnungen\n" + "schneller lösen als ein Supercomputer."); +static const u8 DexDescription_Metagross_2[] = _( + "Dieses POKéMON kann durch die Lüfte\n" + "schweben, indem es seine vier Beine\n" + "einklappt."); + +static const u8 DexDescription_Regirock_1[] = _( + "REGIROCK wurde vor langer Zeit von\n" + "Menschen weggeschlossen. Wenn der\n" + "Körper dieses POKéMON im Kampf"); +static const u8 DexDescription_Regirock_2[] = _( + "Schaden nimmt, sucht es nach\n" + "passenden Steinen, um sich selber zu\n" + "reparieren."); + +static const u8 DexDescription_Regice_1[] = _( + "REGICEs tiefgefrorener Körper\n" + "entstand während der Eiszeit. Es kann\n" + "nicht einmal durch Feuer geschmolzen"); +static const u8 DexDescription_Regice_2[] = _( + "werden. Dieses POKéMON kontrolliert\n" + "eisige Luft von minus 200 Grad."); + +static const u8 DexDescription_Registeel_1[] = _( + "REGISTEEL hat einen Körper, der härter\n" + "ist als jede Art von Metall. Sein Körper\n" + "scheint hohl zu sein."); +static const u8 DexDescription_Registeel_2[] = _( + "Niemand hat eine Ahnung, was dieses\n" + "POKéMON wohl frisst."); + +static const u8 DexDescription_Latias_1[] = _( + "LATIAS ist in höchstem Maße empfindlich\n" + "gegenüber den Emotionen der Menschen.\n" + "Wenn es den Anflug von Feindseligkeit"); +static const u8 DexDescription_Latias_2[] = _( + "wahrnimmt, werden seine Federn\n" + "zerzaust und es stößt schrille Schreie\n" + "aus, um seinen Gegner einzuschüchtern."); + +static const u8 DexDescription_Latios_1[] = _( + "LATIOS kann seinem Feind ein Bild\n" + "von etwas, das dieser einmal gesehen\n" + "hat, in den Kopf projizieren. Dieses"); +static const u8 DexDescription_Latios_2[] = _( + "POKéMON ist intelligent und es versteht\n" + "die menschliche Sprache."); + +static const u8 DexDescription_Kyogre_1[] = _( + "KYOGRE kann riesige Regenwolken\n" + "erzeugen, die den gesamten Himmel\n" + "bedecken, und wolkenbruchartige"); +static const u8 DexDescription_Kyogre_2[] = _( + "Niederschläge hervorrufen. Dieses\n" + "POKéMON hat vielen Menschen das Leben\n" + "gerettet, die unter einer Dürre litten."); + +static const u8 DexDescription_Groudon_1[] = _( + "GROUDON wurde lange Zeit in der\n" + "Mythologie als ein POKéMON\n" + "beschrieben, das Land erschaffen und"); +static const u8 DexDescription_Groudon_2[] = _( + "Kontinente vergrößern kann. Dieses\n" + "POKéMON fiel nach einem erbitterten\n" + "Kampf mit KYOGRE in den Schlaf."); + +static const u8 DexDescription_Rayquaza_1[] = _( + "RAYQUAZA lebte für hunderte Millionen\n" + "Jahre in der Ozonschicht und stieg nie\n" + "zur Erde hinab. Dieses POKéMON"); +static const u8 DexDescription_Rayquaza_2[] = _( + "lebt von Wasser und Partikeln aus der\n" + "Atmosphäre."); + +static const u8 DexDescription_Jirachi_1[] = _( + "Einer Legende nach erfüllt JIRACHI\n" + "jeden Wunsch, der auf einen Notizzettel\n" + "an seinem Kopf geschrieben wird. Wenn"); +static const u8 DexDescription_Jirachi_2[] = _( + "dieses POKéMON Gefahr wittert, kämpft\n" + "es bereits, bevor es überhaupt\n" + "aufgewacht ist."); + +static const u8 DexDescription_Deoxys_1[] = _( + "Die DNS eines Weltraumvirus hat eine\n" + "spontane Mutation erfahren, da sie\n" + "einem Laserstrahl ausgesetzt wurde."); +static const u8 DexDescription_Deoxys_2[] = _( + "Daraus entstand DEOXYS. \n" + "Das kristallartige Organ auf der Brust\n" + "dieses POKéMON ist sein Gehirn."); + +static const struct PokedexEntry gPokedexEntries[] = { + { + // Dummy + .categoryName = _("UNBEKANNT"), + .height = 0, + .weight = 0, + .descriptionPage1 = DexDescription_Dummy_1, + .descriptionPage2 = DexDescription_Dummy_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Bisasam + .categoryName = _("SAMEN"), + .height = 7, + .weight = 69, + .descriptionPage1 = DexDescription_Bisasam_1, + .descriptionPage2 = DexDescription_Bisasam_2, + .pokemonScale = 356, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Bisaknosp + .categoryName = _("SAMEN"), + .height = 10, + .weight = 130, + .descriptionPage1 = DexDescription_Bisaknosp_1, + .descriptionPage2 = DexDescription_Bisaknosp_2, + .pokemonScale = 335, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Bisaflor + .categoryName = _("SAMEN"), + .height = 20, + .weight = 1000, + .descriptionPage1 = DexDescription_Bisaflor_1, + .descriptionPage2 = DexDescription_Bisaflor_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 388, + .trainerOffset = 6, + }, + { + // Glumanda + .categoryName = _("ECHSE"), + .height = 6, + .weight = 85, + .descriptionPage1 = DexDescription_Glumanda_1, + .descriptionPage2 = DexDescription_Glumanda_2, + .pokemonScale = 444, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Glutexo + .categoryName = _("FLAMME"), + .height = 11, + .weight = 190, + .descriptionPage1 = DexDescription_Glutexo_1, + .descriptionPage2 = DexDescription_Glutexo_2, + .pokemonScale = 302, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Glurak + .categoryName = _("FLAMME"), + .height = 17, + .weight = 905, + .descriptionPage1 = DexDescription_Glurak_1, + .descriptionPage2 = DexDescription_Glurak_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 302, + .trainerOffset = 3, + }, + { + // Schiggy + .categoryName = _("MINIKRÖTE"), + .height = 5, + .weight = 90, + .descriptionPage1 = DexDescription_Schiggy_1, + .descriptionPage2 = DexDescription_Schiggy_2, + .pokemonScale = 412, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Schillok + .categoryName = _("KRÖTE"), + .height = 10, + .weight = 225, + .descriptionPage1 = DexDescription_Schillok_1, + .descriptionPage2 = DexDescription_Schillok_2, + .pokemonScale = 332, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Turtok + .categoryName = _("PANZERTIER"), + .height = 16, + .weight = 855, + .descriptionPage1 = DexDescription_Turtok_1, + .descriptionPage2 = DexDescription_Turtok_2, + .pokemonScale = 256, + .pokemonOffset = 65535, + .trainerScale = 293, + .trainerOffset = 2, + }, + { + // Raupy + .categoryName = _("WURM"), + .height = 3, + .weight = 29, + .descriptionPage1 = DexDescription_Raupy_1, + .descriptionPage2 = DexDescription_Raupy_2, + .pokemonScale = 549, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Safcon + .categoryName = _("KOKON"), + .height = 7, + .weight = 99, + .descriptionPage1 = DexDescription_Safcon_1, + .descriptionPage2 = DexDescription_Safcon_2, + .pokemonScale = 350, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Smettbo + .categoryName = _("FALTER"), + .height = 11, + .weight = 320, + .descriptionPage1 = DexDescription_Smettbo_1, + .descriptionPage2 = DexDescription_Smettbo_2, + .pokemonScale = 312, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Hornliu + .categoryName = _("RAUPE"), + .height = 3, + .weight = 32, + .descriptionPage1 = DexDescription_Hornliu_1, + .descriptionPage2 = DexDescription_Hornliu_2, + .pokemonScale = 455, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kokuna + .categoryName = _("KOKON"), + .height = 6, + .weight = 100, + .descriptionPage1 = DexDescription_Kokuna_1, + .descriptionPage2 = DexDescription_Kokuna_2, + .pokemonScale = 424, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Bibor + .categoryName = _("GIFTBIENE"), + .height = 10, + .weight = 295, + .descriptionPage1 = DexDescription_Bibor_1, + .descriptionPage2 = DexDescription_Bibor_2, + .pokemonScale = 366, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Taubsi + .categoryName = _("KLEINVOGEL"), + .height = 3, + .weight = 18, + .descriptionPage1 = DexDescription_Taubsi_1, + .descriptionPage2 = DexDescription_Taubsi_2, + .pokemonScale = 508, + .pokemonOffset = 65533, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Tauboga + .categoryName = _("VOGEL"), + .height = 11, + .weight = 300, + .descriptionPage1 = DexDescription_Tauboga_1, + .descriptionPage2 = DexDescription_Tauboga_2, + .pokemonScale = 331, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Tauboss + .categoryName = _("VOGEL"), + .height = 15, + .weight = 395, + .descriptionPage1 = DexDescription_Tauboss_1, + .descriptionPage2 = DexDescription_Tauboss_2, + .pokemonScale = 269, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Rattfratz + .categoryName = _("MAUS"), + .height = 3, + .weight = 35, + .descriptionPage1 = DexDescription_Rattfratz_1, + .descriptionPage2 = DexDescription_Rattfratz_2, + .pokemonScale = 481, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Rattikarl + .categoryName = _("MAUS"), + .height = 7, + .weight = 185, + .descriptionPage1 = DexDescription_Rattikarl_1, + .descriptionPage2 = DexDescription_Rattikarl_2, + .pokemonScale = 459, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Habitak + .categoryName = _("KLEINVOGEL"), + .height = 3, + .weight = 20, + .descriptionPage1 = DexDescription_Habitak_1, + .descriptionPage2 = DexDescription_Habitak_2, + .pokemonScale = 571, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Ibitak + .categoryName = _("PICKVOGEL"), + .height = 12, + .weight = 380, + .descriptionPage1 = DexDescription_Ibitak_1, + .descriptionPage2 = DexDescription_Ibitak_2, + .pokemonScale = 278, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Rettan + .categoryName = _("SCHLANGE"), + .height = 20, + .weight = 69, + .descriptionPage1 = DexDescription_Rettan_1, + .descriptionPage2 = DexDescription_Rettan_2, + .pokemonScale = 298, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Arbok + .categoryName = _("KOBRA"), + .height = 35, + .weight = 650, + .descriptionPage1 = DexDescription_Arbok_1, + .descriptionPage2 = DexDescription_Arbok_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 296, + .trainerOffset = 2, + }, + { + // Pikachu + .categoryName = _("MAUS"), + .height = 4, + .weight = 60, + .descriptionPage1 = DexDescription_Pikachu_1, + .descriptionPage2 = DexDescription_Pikachu_2, + .pokemonScale = 479, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Raichu + .categoryName = _("MAUS"), + .height = 8, + .weight = 300, + .descriptionPage1 = DexDescription_Raichu_1, + .descriptionPage2 = DexDescription_Raichu_2, + .pokemonScale = 426, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sandan + .categoryName = _("MAUS"), + .height = 6, + .weight = 120, + .descriptionPage1 = DexDescription_Sandan_1, + .descriptionPage2 = DexDescription_Sandan_2, + .pokemonScale = 365, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sandamer + .categoryName = _("MAUS"), + .height = 10, + .weight = 295, + .descriptionPage1 = DexDescription_Sandamer_1, + .descriptionPage2 = DexDescription_Sandamer_2, + .pokemonScale = 341, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Nidoran♀ + .categoryName = _("GIFTDORN"), + .height = 4, + .weight = 70, + .descriptionPage1 = DexDescription_NidoranF_1, + .descriptionPage2 = DexDescription_NidoranF_2, + .pokemonScale = 488, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Nidorina + .categoryName = _("GIFTDORN"), + .height = 8, + .weight = 200, + .descriptionPage1 = DexDescription_Nidorina_1, + .descriptionPage2 = DexDescription_Nidorina_2, + .pokemonScale = 381, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Nidoqueen + .categoryName = _("BOHRER"), + .height = 13, + .weight = 600, + .descriptionPage1 = DexDescription_Nidoqueen_1, + .descriptionPage2 = DexDescription_Nidoqueen_2, + .pokemonScale = 293, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Nidoran♂ + .categoryName = _("GIFTDORN"), + .height = 5, + .weight = 90, + .descriptionPage1 = DexDescription_NidoranM_1, + .descriptionPage2 = DexDescription_NidoranM_2, + .pokemonScale = 511, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Nidorino + .categoryName = _("GIFTDORN"), + .height = 9, + .weight = 195, + .descriptionPage1 = DexDescription_Nidorino_1, + .descriptionPage2 = DexDescription_Nidorino_2, + .pokemonScale = 408, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Nidoking + .categoryName = _("BOHRER"), + .height = 14, + .weight = 620, + .descriptionPage1 = DexDescription_Nidoking_1, + .descriptionPage2 = DexDescription_Nidoking_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Piepi + .categoryName = _("FEE"), + .height = 6, + .weight = 75, + .descriptionPage1 = DexDescription_Piepi_1, + .descriptionPage2 = DexDescription_Piepi_2, + .pokemonScale = 441, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Pixi + .categoryName = _("FEE"), + .height = 13, + .weight = 400, + .descriptionPage1 = DexDescription_Pixi_1, + .descriptionPage2 = DexDescription_Pixi_2, + .pokemonScale = 256, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Vulpix + .categoryName = _("FUCHS"), + .height = 6, + .weight = 99, + .descriptionPage1 = DexDescription_Vulpix_1, + .descriptionPage2 = DexDescription_Vulpix_2, + .pokemonScale = 542, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Vulnona + .categoryName = _("FUCHS"), + .height = 11, + .weight = 199, + .descriptionPage1 = DexDescription_Vulnona_1, + .descriptionPage2 = DexDescription_Vulnona_2, + .pokemonScale = 339, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Pummeluff + .categoryName = _("BALLON"), + .height = 5, + .weight = 55, + .descriptionPage1 = DexDescription_Pummeluff_1, + .descriptionPage2 = DexDescription_Pummeluff_2, + .pokemonScale = 433, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Knuddeluff + .categoryName = _("BALLON"), + .height = 10, + .weight = 120, + .descriptionPage1 = DexDescription_Knuddeluff_1, + .descriptionPage2 = DexDescription_Knuddeluff_2, + .pokemonScale = 328, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Zubat + .categoryName = _("FLEDERMAUS"), + .height = 8, + .weight = 75, + .descriptionPage1 = DexDescription_Zubat_1, + .descriptionPage2 = DexDescription_Zubat_2, + .pokemonScale = 362, + .pokemonOffset = 65531, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Golbat + .categoryName = _("FLEDERMAUS"), + .height = 16, + .weight = 550, + .descriptionPage1 = DexDescription_Golbat_1, + .descriptionPage2 = DexDescription_Golbat_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Myrapla + .categoryName = _("UNKRAUT"), + .height = 5, + .weight = 54, + .descriptionPage1 = DexDescription_Myrapla_1, + .descriptionPage2 = DexDescription_Myrapla_2, + .pokemonScale = 423, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Duflor + .categoryName = _("UNKRAUT"), + .height = 8, + .weight = 86, + .descriptionPage1 = DexDescription_Duflor_1, + .descriptionPage2 = DexDescription_Duflor_2, + .pokemonScale = 329, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Giflor + .categoryName = _("BLUME"), + .height = 12, + .weight = 186, + .descriptionPage1 = DexDescription_Giflor_1, + .descriptionPage2 = DexDescription_Giflor_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Paras + .categoryName = _("PILZ"), + .height = 3, + .weight = 54, + .descriptionPage1 = DexDescription_Paras_1, + .descriptionPage2 = DexDescription_Paras_2, + .pokemonScale = 593, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Parasek + .categoryName = _("PILZ"), + .height = 10, + .weight = 295, + .descriptionPage1 = DexDescription_Parasek_1, + .descriptionPage2 = DexDescription_Parasek_2, + .pokemonScale = 307, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Bluzuk + .categoryName = _("INSEKT"), + .height = 10, + .weight = 300, + .descriptionPage1 = DexDescription_Bluzuk_1, + .descriptionPage2 = DexDescription_Bluzuk_2, + .pokemonScale = 360, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 65535, + }, + { + // Omot + .categoryName = _("GIFTMOTTE"), + .height = 15, + .weight = 125, + .descriptionPage1 = DexDescription_Omot_1, + .descriptionPage2 = DexDescription_Omot_2, + .pokemonScale = 285, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 1, + }, + { + // Digda + .categoryName = _("MAULWURF"), + .height = 2, + .weight = 8, + .descriptionPage1 = DexDescription_Digda_1, + .descriptionPage2 = DexDescription_Digda_2, + .pokemonScale = 833, + .pokemonOffset = 25, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Digdri + .categoryName = _("MAULWURF"), + .height = 7, + .weight = 333, + .descriptionPage1 = DexDescription_Digdri_1, + .descriptionPage2 = DexDescription_Digdri_2, + .pokemonScale = 406, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Mauzi + .categoryName = _("KATZE"), + .height = 4, + .weight = 42, + .descriptionPage1 = DexDescription_Mauzi_1, + .descriptionPage2 = DexDescription_Mauzi_2, + .pokemonScale = 480, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Snobilikat + .categoryName = _("RASSEKATZE"), + .height = 10, + .weight = 320, + .descriptionPage1 = DexDescription_Snobilikat_1, + .descriptionPage2 = DexDescription_Snobilikat_2, + .pokemonScale = 320, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Enton + .categoryName = _("ENTE"), + .height = 8, + .weight = 196, + .descriptionPage1 = DexDescription_Enton_1, + .descriptionPage2 = DexDescription_Enton_2, + .pokemonScale = 369, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Entoron + .categoryName = _("ENTE"), + .height = 17, + .weight = 766, + .descriptionPage1 = DexDescription_Entoron_1, + .descriptionPage2 = DexDescription_Entoron_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 273, + .trainerOffset = 1, + }, + { + // Menki + .categoryName = _("SCHW./ AFFE"), + .height = 5, + .weight = 280, + .descriptionPage1 = DexDescription_Menki_1, + .descriptionPage2 = DexDescription_Menki_2, + .pokemonScale = 404, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Rasaff + .categoryName = _("SCHW./ AFFE"), + .height = 10, + .weight = 320, + .descriptionPage1 = DexDescription_Rasaff_1, + .descriptionPage2 = DexDescription_Rasaff_2, + .pokemonScale = 326, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Fukano + .categoryName = _("HUND"), + .height = 7, + .weight = 190, + .descriptionPage1 = DexDescription_Fukano_1, + .descriptionPage2 = DexDescription_Fukano_2, + .pokemonScale = 346, + .pokemonOffset = 14, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Arkani + .categoryName = _("LEGENDÄR"), + .height = 19, + .weight = 1550, + .descriptionPage1 = DexDescription_Arkani_1, + .descriptionPage2 = DexDescription_Arkani_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 312, + .trainerOffset = 4, + }, + { + // Quapsel + .categoryName = _("KAULQUAPPE"), + .height = 6, + .weight = 124, + .descriptionPage1 = DexDescription_Quapsel_1, + .descriptionPage2 = DexDescription_Quapsel_2, + .pokemonScale = 369, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Quaputzi + .categoryName = _("KAULQUAPPE"), + .height = 10, + .weight = 200, + .descriptionPage1 = DexDescription_Quaputzi_1, + .descriptionPage2 = DexDescription_Quaputzi_2, + .pokemonScale = 288, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Quappo + .categoryName = _("KAULQUAPPE"), + .height = 13, + .weight = 540, + .descriptionPage1 = DexDescription_Quappo_1, + .descriptionPage2 = DexDescription_Quappo_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Abra + .categoryName = _("PSI"), + .height = 9, + .weight = 195, + .descriptionPage1 = DexDescription_Abra_1, + .descriptionPage2 = DexDescription_Abra_2, + .pokemonScale = 363, + .pokemonOffset = 14, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kadabra + .categoryName = _("PSI"), + .height = 13, + .weight = 565, + .descriptionPage1 = DexDescription_Kadabra_1, + .descriptionPage2 = DexDescription_Kadabra_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Simsala + .categoryName = _("PSI"), + .height = 15, + .weight = 480, + .descriptionPage1 = DexDescription_Simsala_1, + .descriptionPage2 = DexDescription_Simsala_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Machollo + .categoryName = _("KRAFTPROTZ"), + .height = 8, + .weight = 195, + .descriptionPage1 = DexDescription_Machollo_1, + .descriptionPage2 = DexDescription_Machollo_2, + .pokemonScale = 342, + .pokemonOffset = 14, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Maschock + .categoryName = _("KRAFTPROTZ"), + .height = 15, + .weight = 705, + .descriptionPage1 = DexDescription_Maschock_1, + .descriptionPage2 = DexDescription_Maschock_2, + .pokemonScale = 323, + .pokemonOffset = 9, + .trainerScale = 257, + .trainerOffset = 0, + }, + { + // Machomei + .categoryName = _("KRAFTPROTZ"), + .height = 16, + .weight = 1300, + .descriptionPage1 = DexDescription_Machomei_1, + .descriptionPage2 = DexDescription_Machomei_2, + .pokemonScale = 280, + .pokemonOffset = 1, + .trainerScale = 269, + .trainerOffset = 65535, + }, + { + // Knofensa + .categoryName = _("BLUME"), + .height = 7, + .weight = 40, + .descriptionPage1 = DexDescription_Knofensa_1, + .descriptionPage2 = DexDescription_Knofensa_2, + .pokemonScale = 354, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Ultrigaria + .categoryName = _("FLIEGENTOT"), + .height = 10, + .weight = 64, + .descriptionPage1 = DexDescription_Ultrigaria_1, + .descriptionPage2 = DexDescription_Ultrigaria_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sarzenia + .categoryName = _("FLIEGENTOT"), + .height = 17, + .weight = 155, + .descriptionPage1 = DexDescription_Sarzenia_1, + .descriptionPage2 = DexDescription_Sarzenia_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 312, + .trainerOffset = 3, + }, + { + // Tentacha + .categoryName = _("QUALLE"), + .height = 9, + .weight = 455, + .descriptionPage1 = DexDescription_Tentacha_1, + .descriptionPage2 = DexDescription_Tentacha_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Tentoxa + .categoryName = _("QUALLE"), + .height = 16, + .weight = 550, + .descriptionPage1 = DexDescription_Tentoxa_1, + .descriptionPage2 = DexDescription_Tentoxa_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 312, + .trainerOffset = 1, + }, + { + // Kleinstein + .categoryName = _("GESTEIN"), + .height = 4, + .weight = 200, + .descriptionPage1 = DexDescription_Kleinstein_1, + .descriptionPage2 = DexDescription_Kleinstein_2, + .pokemonScale = 347, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Georok + .categoryName = _("GESTEIN"), + .height = 10, + .weight = 1050, + .descriptionPage1 = DexDescription_Georok_1, + .descriptionPage2 = DexDescription_Georok_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Geowaz + .categoryName = _("URGESTEIN"), + .height = 14, + .weight = 3000, + .descriptionPage1 = DexDescription_Geowaz_1, + .descriptionPage2 = DexDescription_Geowaz_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 296, + .trainerOffset = 2, + }, + { + // Ponita + .categoryName = _("FEUERPFERD"), + .height = 10, + .weight = 300, + .descriptionPage1 = DexDescription_Ponita_1, + .descriptionPage2 = DexDescription_Ponita_2, + .pokemonScale = 283, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Gallopa + .categoryName = _("FEUERPFERD"), + .height = 17, + .weight = 950, + .descriptionPage1 = DexDescription_Gallopa_1, + .descriptionPage2 = DexDescription_Gallopa_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 289, + .trainerOffset = 1, + }, + { + // Flegmon + .categoryName = _("SCHNARCHER"), + .height = 12, + .weight = 360, + .descriptionPage1 = DexDescription_Flegmon_1, + .descriptionPage2 = DexDescription_Flegmon_2, + .pokemonScale = 256, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Lahmus + .categoryName = _("SYMBIOSE"), + .height = 16, + .weight = 785, + .descriptionPage1 = DexDescription_Lahmus_1, + .descriptionPage2 = DexDescription_Lahmus_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 296, + .trainerOffset = 2, + }, + { + // Magnetilo + .categoryName = _("MAGNET"), + .height = 3, + .weight = 60, + .descriptionPage1 = DexDescription_Magnetilo_1, + .descriptionPage2 = DexDescription_Magnetilo_2, + .pokemonScale = 288, + .pokemonOffset = 65527, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Magneton + .categoryName = _("MAGNET"), + .height = 10, + .weight = 600, + .descriptionPage1 = DexDescription_Magneton_1, + .descriptionPage2 = DexDescription_Magneton_2, + .pokemonScale = 292, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Porenta + .categoryName = _("WILDENTE"), + .height = 8, + .weight = 150, + .descriptionPage1 = DexDescription_Porenta_1, + .descriptionPage2 = DexDescription_Porenta_2, + .pokemonScale = 330, + .pokemonOffset = 2, + .trainerScale = 293, + .trainerOffset = 2, + }, + { + // Dodu + .categoryName = _("DUOVOGEL"), + .height = 14, + .weight = 392, + .descriptionPage1 = DexDescription_Dodu_1, + .descriptionPage2 = DexDescription_Dodu_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 257, + .trainerOffset = 65535, + }, + { + // Dodri + .categoryName = _("TRIVOGEL"), + .height = 18, + .weight = 852, + .descriptionPage1 = DexDescription_Dodri_1, + .descriptionPage2 = DexDescription_Dodri_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 268, + .trainerOffset = 0, + }, + { + // Jurob + .categoryName = _("SEEHUND"), + .height = 11, + .weight = 900, + .descriptionPage1 = DexDescription_Jurob_1, + .descriptionPage2 = DexDescription_Jurob_2, + .pokemonScale = 297, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Jugong + .categoryName = _("SEEHUND"), + .height = 17, + .weight = 1200, + .descriptionPage1 = DexDescription_Jugong_1, + .descriptionPage2 = DexDescription_Jugong_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 275, + .trainerOffset = 0, + }, + { + // Sleima + .categoryName = _("SCHLAMM"), + .height = 9, + .weight = 300, + .descriptionPage1 = DexDescription_Sleima_1, + .descriptionPage2 = DexDescription_Sleima_2, + .pokemonScale = 258, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sleimok + .categoryName = _("SCHLAMM"), + .height = 12, + .weight = 300, + .descriptionPage1 = DexDescription_Sleimok_1, + .descriptionPage2 = DexDescription_Sleimok_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Muschas + .categoryName = _("MUSCHEL"), + .height = 3, + .weight = 40, + .descriptionPage1 = DexDescription_Muschas_1, + .descriptionPage2 = DexDescription_Muschas_2, + .pokemonScale = 675, + .pokemonOffset = 24, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Austos + .categoryName = _("MUSCHEL"), + .height = 15, + .weight = 1325, + .descriptionPage1 = DexDescription_Austos_1, + .descriptionPage2 = DexDescription_Austos_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 269, + .trainerOffset = 1, + }, + { + // Nebulak + .categoryName = _("GAS"), + .height = 13, + .weight = 1, + .descriptionPage1 = DexDescription_Nebulak_1, + .descriptionPage2 = DexDescription_Nebulak_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Alpollo + .categoryName = _("GAS"), + .height = 16, + .weight = 1, + .descriptionPage1 = DexDescription_Alpollo_1, + .descriptionPage2 = DexDescription_Alpollo_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 293, + .trainerOffset = 2, + }, + { + // Gengar + .categoryName = _("SCHATTEN"), + .height = 15, + .weight = 405, + .descriptionPage1 = DexDescription_Gengar_1, + .descriptionPage2 = DexDescription_Gengar_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 302, + .trainerOffset = 2, + }, + { + // Onix + .categoryName = _("FELSNATTER"), + .height = 88, + .weight = 2100, + .descriptionPage1 = DexDescription_Onix_1, + .descriptionPage2 = DexDescription_Onix_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 515, + .trainerOffset = 14, + }, + { + // Traumato + .categoryName = _("HYPNOSE"), + .height = 10, + .weight = 324, + .descriptionPage1 = DexDescription_Traumato_1, + .descriptionPage2 = DexDescription_Traumato_2, + .pokemonScale = 274, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Hypno + .categoryName = _("HYPNOSE"), + .height = 16, + .weight = 756, + .descriptionPage1 = DexDescription_Hypno_1, + .descriptionPage2 = DexDescription_Hypno_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 257, + .trainerOffset = 0, + }, + { + // Krabby + .categoryName = _("KRABBE"), + .height = 4, + .weight = 65, + .descriptionPage1 = DexDescription_Krabby_1, + .descriptionPage2 = DexDescription_Krabby_2, + .pokemonScale = 469, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kingler + .categoryName = _("KNEIFER"), + .height = 13, + .weight = 600, + .descriptionPage1 = DexDescription_Kingler_1, + .descriptionPage2 = DexDescription_Kingler_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Voltobal + .categoryName = _("BALL"), + .height = 5, + .weight = 104, + .descriptionPage1 = DexDescription_Voltobal_1, + .descriptionPage2 = DexDescription_Voltobal_2, + .pokemonScale = 364, + .pokemonOffset = 65528, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Lektrobal + .categoryName = _("BALL"), + .height = 12, + .weight = 666, + .descriptionPage1 = DexDescription_Lektrobal_1, + .descriptionPage2 = DexDescription_Lektrobal_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Owei + .categoryName = _("EI"), + .height = 4, + .weight = 25, + .descriptionPage1 = DexDescription_Owei_1, + .descriptionPage2 = DexDescription_Owei_2, + .pokemonScale = 489, + .pokemonOffset = 65532, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kokowei + .categoryName = _("PALMFRUCHT"), + .height = 20, + .weight = 1200, + .descriptionPage1 = DexDescription_Kokowei_1, + .descriptionPage2 = DexDescription_Kokowei_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 309, + .trainerOffset = 5, + }, + { + // Tragosso + .categoryName = _("EINSAM"), + .height = 4, + .weight = 65, + .descriptionPage1 = DexDescription_Tragosso_1, + .descriptionPage2 = DexDescription_Tragosso_2, + .pokemonScale = 545, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Knogga + .categoryName = _("KNOCHENFAN"), + .height = 10, + .weight = 450, + .descriptionPage1 = DexDescription_Knogga_1, + .descriptionPage2 = DexDescription_Knogga_2, + .pokemonScale = 293, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kicklee + .categoryName = _("KICKER"), + .height = 15, + .weight = 498, + .descriptionPage1 = DexDescription_Kicklee_1, + .descriptionPage2 = DexDescription_Kicklee_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 259, + .trainerOffset = 1, + }, + { + // Nockchan + .categoryName = _("PUNCHER"), + .height = 14, + .weight = 502, + .descriptionPage1 = DexDescription_Nockchan_1, + .descriptionPage2 = DexDescription_Nockchan_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 277, + .trainerOffset = 2, + }, + { + // Schlurp + .categoryName = _("SCHLECKER"), + .height = 12, + .weight = 655, + .descriptionPage1 = DexDescription_Schlurp_1, + .descriptionPage2 = DexDescription_Schlurp_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Smogon + .categoryName = _("GIFTWOLKE"), + .height = 6, + .weight = 10, + .descriptionPage1 = DexDescription_Smogon_1, + .descriptionPage2 = DexDescription_Smogon_2, + .pokemonScale = 369, + .pokemonOffset = 65535, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Smogmog + .categoryName = _("GIFTWOLKE"), + .height = 12, + .weight = 95, + .descriptionPage1 = DexDescription_Smogmog_1, + .descriptionPage2 = DexDescription_Smogmog_2, + .pokemonScale = 305, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Rihorn + .categoryName = _("STACHLER"), + .height = 10, + .weight = 1150, + .descriptionPage1 = DexDescription_Rihorn_1, + .descriptionPage2 = DexDescription_Rihorn_2, + .pokemonScale = 267, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Rizeros + .categoryName = _("BOHRER"), + .height = 19, + .weight = 1200, + .descriptionPage1 = DexDescription_Rizeros_1, + .descriptionPage2 = DexDescription_Rizeros_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 299, + .trainerOffset = 2, + }, + { + // Chaneira + .categoryName = _("EI"), + .height = 11, + .weight = 346, + .descriptionPage1 = DexDescription_Chaneira_1, + .descriptionPage2 = DexDescription_Chaneira_2, + .pokemonScale = 257, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Tangela + .categoryName = _("RANKE"), + .height = 10, + .weight = 350, + .descriptionPage1 = DexDescription_Tangela_1, + .descriptionPage2 = DexDescription_Tangela_2, + .pokemonScale = 304, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kangama + .categoryName = _("MUTTERTIER"), + .height = 22, + .weight = 800, + .descriptionPage1 = DexDescription_Kangama_1, + .descriptionPage2 = DexDescription_Kangama_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 387, + .trainerOffset = 8, + }, + { + // Seeper + .categoryName = _("DRACHE"), + .height = 4, + .weight = 80, + .descriptionPage1 = DexDescription_Seeper_1, + .descriptionPage2 = DexDescription_Seeper_2, + .pokemonScale = 399, + .pokemonOffset = 65535, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Seemon + .categoryName = _("DRACHE"), + .height = 12, + .weight = 250, + .descriptionPage1 = DexDescription_Seemon_1, + .descriptionPage2 = DexDescription_Seemon_2, + .pokemonScale = 299, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Goldini + .categoryName = _("GOLDFISCH"), + .height = 6, + .weight = 150, + .descriptionPage1 = DexDescription_Goldini_1, + .descriptionPage2 = DexDescription_Goldini_2, + .pokemonScale = 379, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Golking + .categoryName = _("GOLDFISCH"), + .height = 13, + .weight = 390, + .descriptionPage1 = DexDescription_Golking_1, + .descriptionPage2 = DexDescription_Golking_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sterndu + .categoryName = _("STERNFORM"), + .height = 8, + .weight = 345, + .descriptionPage1 = DexDescription_Sterndu_1, + .descriptionPage2 = DexDescription_Sterndu_2, + .pokemonScale = 326, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Starmie + .categoryName = _("MYSTERIÖS"), + .height = 11, + .weight = 800, + .descriptionPage1 = DexDescription_Starmie_1, + .descriptionPage2 = DexDescription_Starmie_2, + .pokemonScale = 301, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Pantimos + .categoryName = _("SPERRE"), + .height = 13, + .weight = 545, + .descriptionPage1 = DexDescription_Pantimos_1, + .descriptionPage2 = DexDescription_Pantimos_2, + .pokemonScale = 258, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sichlor + .categoryName = _("MANTIS"), + .height = 15, + .weight = 560, + .descriptionPage1 = DexDescription_Sichlor_1, + .descriptionPage2 = DexDescription_Sichlor_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 293, + .trainerOffset = 2, + }, + { + // Rossana + .categoryName = _("HUMANOTYP"), + .height = 14, + .weight = 406, + .descriptionPage1 = DexDescription_Rossana_1, + .descriptionPage2 = DexDescription_Rossana_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 300, + .trainerOffset = 1, + }, + { + // Elektek + .categoryName = _("ELEKTRO"), + .height = 11, + .weight = 300, + .descriptionPage1 = DexDescription_Elektek_1, + .descriptionPage2 = DexDescription_Elektek_2, + .pokemonScale = 351, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Magmar + .categoryName = _("BRENNER"), + .height = 13, + .weight = 445, + .descriptionPage1 = DexDescription_Magmar_1, + .descriptionPage2 = DexDescription_Magmar_2, + .pokemonScale = 277, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Pinsir + .categoryName = _("KNEIFKÄFER"), + .height = 15, + .weight = 550, + .descriptionPage1 = DexDescription_Pinsir_1, + .descriptionPage2 = DexDescription_Pinsir_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 257, + .trainerOffset = 0, + }, + { + // Tauros + .categoryName = _("WILDBULLE"), + .height = 14, + .weight = 884, + .descriptionPage1 = DexDescription_Tauros_1, + .descriptionPage2 = DexDescription_Tauros_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Karpador + .categoryName = _("FISCH"), + .height = 9, + .weight = 100, + .descriptionPage1 = DexDescription_Karpador_1, + .descriptionPage2 = DexDescription_Karpador_2, + .pokemonScale = 310, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Garados + .categoryName = _("GRAUSAM"), + .height = 65, + .weight = 2350, + .descriptionPage1 = DexDescription_Garados_1, + .descriptionPage2 = DexDescription_Garados_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 481, + .trainerOffset = 13, + }, + { + // Lapras + .categoryName = _("TRANSPORT"), + .height = 25, + .weight = 2200, + .descriptionPage1 = DexDescription_Lapras_1, + .descriptionPage2 = DexDescription_Lapras_2, + .pokemonScale = 257, + .pokemonOffset = 10, + .trainerScale = 423, + .trainerOffset = 8, + }, + { + // Ditto + .categoryName = _("TRANSFORM"), + .height = 3, + .weight = 40, + .descriptionPage1 = DexDescription_Ditto_1, + .descriptionPage2 = DexDescription_Ditto_2, + .pokemonScale = 633, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Evoli + .categoryName = _("EVOLUTION"), + .height = 3, + .weight = 65, + .descriptionPage1 = DexDescription_Evoli_1, + .descriptionPage2 = DexDescription_Evoli_2, + .pokemonScale = 476, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Aquana + .categoryName = _("BLUBBLASE"), + .height = 10, + .weight = 290, + .descriptionPage1 = DexDescription_Aquana_1, + .descriptionPage2 = DexDescription_Aquana_2, + .pokemonScale = 316, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Blitza + .categoryName = _("BLITZ"), + .height = 8, + .weight = 245, + .descriptionPage1 = DexDescription_Blitza_1, + .descriptionPage2 = DexDescription_Blitza_2, + .pokemonScale = 283, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Flamara + .categoryName = _("FEUER"), + .height = 9, + .weight = 250, + .descriptionPage1 = DexDescription_Flamara_1, + .descriptionPage2 = DexDescription_Flamara_2, + .pokemonScale = 306, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Porygon + .categoryName = _("VIRTUELL"), + .height = 8, + .weight = 365, + .descriptionPage1 = DexDescription_Porygon_1, + .descriptionPage2 = DexDescription_Porygon_2, + .pokemonScale = 328, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Amonitas + .categoryName = _("SPIRALE"), + .height = 4, + .weight = 75, + .descriptionPage1 = DexDescription_Amonitas_1, + .descriptionPage2 = DexDescription_Amonitas_2, + .pokemonScale = 521, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Amoroso + .categoryName = _("SPIRALE"), + .height = 10, + .weight = 350, + .descriptionPage1 = DexDescription_Amoroso_1, + .descriptionPage2 = DexDescription_Amoroso_2, + .pokemonScale = 307, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kabuto + .categoryName = _("PANZERTIER"), + .height = 5, + .weight = 115, + .descriptionPage1 = DexDescription_Kabuto_1, + .descriptionPage2 = DexDescription_Kabuto_2, + .pokemonScale = 454, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kabutops + .categoryName = _("PANZERTIER"), + .height = 13, + .weight = 405, + .descriptionPage1 = DexDescription_Kabutops_1, + .descriptionPage2 = DexDescription_Kabutops_2, + .pokemonScale = 271, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Aerodactyl + .categoryName = _("FOSSIL"), + .height = 18, + .weight = 590, + .descriptionPage1 = DexDescription_Aerodactyl_1, + .descriptionPage2 = DexDescription_Aerodactyl_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 302, + .trainerOffset = 4, + }, + { + // Relaxo + .categoryName = _("TAGTRÄUMER"), + .height = 21, + .weight = 4600, + .descriptionPage1 = DexDescription_Relaxo_1, + .descriptionPage2 = DexDescription_Relaxo_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 423, + .trainerOffset = 11, + }, + { + // Arktos + .categoryName = _("EIS"), + .height = 17, + .weight = 554, + .descriptionPage1 = DexDescription_Arktos_1, + .descriptionPage2 = DexDescription_Arktos_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 309, + .trainerOffset = 2, + }, + { + // Zapdos + .categoryName = _("ELEKTRO"), + .height = 16, + .weight = 526, + .descriptionPage1 = DexDescription_Zapdos_1, + .descriptionPage2 = DexDescription_Zapdos_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 318, + .trainerOffset = 3, + }, + { + // Lavados + .categoryName = _("FLAMME"), + .height = 20, + .weight = 600, + .descriptionPage1 = DexDescription_Lavados_1, + .descriptionPage2 = DexDescription_Lavados_2, + .pokemonScale = 270, + .pokemonOffset = 0, + .trainerScale = 387, + .trainerOffset = 8, + }, + { + // Dratini + .categoryName = _("DRACHE"), + .height = 18, + .weight = 33, + .descriptionPage1 = DexDescription_Dratini_1, + .descriptionPage2 = DexDescription_Dratini_2, + .pokemonScale = 256, + .pokemonOffset = 8, + .trainerScale = 386, + .trainerOffset = 6, + }, + { + // Dragonir + .categoryName = _("DRACHE"), + .height = 40, + .weight = 165, + .descriptionPage1 = DexDescription_Dragonir_1, + .descriptionPage2 = DexDescription_Dragonir_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 411, + .trainerOffset = 5, + }, + { + // Dragoran + .categoryName = _("DRACHE"), + .height = 22, + .weight = 2100, + .descriptionPage1 = DexDescription_Dragoran_1, + .descriptionPage2 = DexDescription_Dragoran_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 309, + .trainerOffset = 4, + }, + { + // Mewtu + .categoryName = _("GENMUTANT"), + .height = 20, + .weight = 1220, + .descriptionPage1 = DexDescription_Mewtu_1, + .descriptionPage2 = DexDescription_Mewtu_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 309, + .trainerOffset = 4, + }, + { + // Mew + .categoryName = _("NEUE ART"), + .height = 4, + .weight = 40, + .descriptionPage1 = DexDescription_Mew_1, + .descriptionPage2 = DexDescription_Mew_2, + .pokemonScale = 457, + .pokemonOffset = 65534, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Endivie + .categoryName = _("LAUB"), + .height = 9, + .weight = 64, + .descriptionPage1 = DexDescription_Endivie_1, + .descriptionPage2 = DexDescription_Endivie_2, + .pokemonScale = 512, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Lorblatt + .categoryName = _("LAUB"), + .height = 12, + .weight = 158, + .descriptionPage1 = DexDescription_Lorblatt_1, + .descriptionPage2 = DexDescription_Lorblatt_2, + .pokemonScale = 296, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Meganie + .categoryName = _("KRÄUTER"), + .height = 18, + .weight = 1005, + .descriptionPage1 = DexDescription_Meganie_1, + .descriptionPage2 = DexDescription_Meganie_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 277, + .trainerOffset = 1, + }, + { + // Feurigel + .categoryName = _("FEUERMAUS"), + .height = 5, + .weight = 79, + .descriptionPage1 = DexDescription_Feurigel_1, + .descriptionPage2 = DexDescription_Feurigel_2, + .pokemonScale = 539, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Igelavar + .categoryName = _("VULKAN"), + .height = 9, + .weight = 190, + .descriptionPage1 = DexDescription_Igelavar_1, + .descriptionPage2 = DexDescription_Igelavar_2, + .pokemonScale = 329, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Tornupto + .categoryName = _("VULKAN"), + .height = 17, + .weight = 795, + .descriptionPage1 = DexDescription_Tornupto_1, + .descriptionPage2 = DexDescription_Tornupto_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 268, + .trainerOffset = 1, + }, + { + // Karnimani + .categoryName = _("GROSSMAUL"), + .height = 6, + .weight = 95, + .descriptionPage1 = DexDescription_Karnimani_1, + .descriptionPage2 = DexDescription_Karnimani_2, + .pokemonScale = 487, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Tyracroc + .categoryName = _("GROSSMAUL"), + .height = 11, + .weight = 250, + .descriptionPage1 = DexDescription_Tyracroc_1, + .descriptionPage2 = DexDescription_Tyracroc_2, + .pokemonScale = 378, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Impergator + .categoryName = _("GROSSMAUL"), + .height = 23, + .weight = 888, + .descriptionPage1 = DexDescription_Impergator_1, + .descriptionPage2 = DexDescription_Impergator_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 342, + .trainerOffset = 7, + }, + { + // Wiesor + .categoryName = _("SPÄHER"), + .height = 8, + .weight = 60, + .descriptionPage1 = DexDescription_Wiesor_1, + .descriptionPage2 = DexDescription_Wiesor_2, + .pokemonScale = 439, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Wiesenior + .categoryName = _("LANGLEIB"), + .height = 18, + .weight = 325, + .descriptionPage1 = DexDescription_Wiesenior_1, + .descriptionPage2 = DexDescription_Wiesenior_2, + .pokemonScale = 346, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Hoothoot + .categoryName = _("EULE"), + .height = 7, + .weight = 212, + .descriptionPage1 = DexDescription_Hoothoot_1, + .descriptionPage2 = DexDescription_Hoothoot_2, + .pokemonScale = 380, + .pokemonOffset = 65534, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Noctuh + .categoryName = _("EULE"), + .height = 16, + .weight = 408, + .descriptionPage1 = DexDescription_Noctuh_1, + .descriptionPage2 = DexDescription_Noctuh_2, + .pokemonScale = 278, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Ledyba + .categoryName = _("FÜNF-PUNKT"), + .height = 10, + .weight = 108, + .descriptionPage1 = DexDescription_Ledyba_1, + .descriptionPage2 = DexDescription_Ledyba_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Ledian + .categoryName = _("FÜNF-PUNKT"), + .height = 14, + .weight = 356, + .descriptionPage1 = DexDescription_Ledian_1, + .descriptionPage2 = DexDescription_Ledian_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Webarak + .categoryName = _("FADENWURF"), + .height = 5, + .weight = 85, + .descriptionPage1 = DexDescription_Webarak_1, + .descriptionPage2 = DexDescription_Webarak_2, + .pokemonScale = 414, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Ariados + .categoryName = _("LANGBEIN"), + .height = 11, + .weight = 335, + .descriptionPage1 = DexDescription_Ariados_1, + .descriptionPage2 = DexDescription_Ariados_2, + .pokemonScale = 316, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Iksbat + .categoryName = _("FLEDERMAUS"), + .height = 18, + .weight = 750, + .descriptionPage1 = DexDescription_Iksbat_1, + .descriptionPage2 = DexDescription_Iksbat_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 281, + .trainerOffset = 1, + }, + { + // Lampi + .categoryName = _("ANGLER"), + .height = 5, + .weight = 120, + .descriptionPage1 = DexDescription_Lampi_1, + .descriptionPage2 = DexDescription_Lampi_2, + .pokemonScale = 424, + .pokemonOffset = 65534, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Lanturn + .categoryName = _("LEUCHTE"), + .height = 12, + .weight = 225, + .descriptionPage1 = DexDescription_Lanturn_1, + .descriptionPage2 = DexDescription_Lanturn_2, + .pokemonScale = 269, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Pichu + .categoryName = _("BABYMAUS"), + .height = 3, + .weight = 20, + .descriptionPage1 = DexDescription_Pichu_1, + .descriptionPage2 = DexDescription_Pichu_2, + .pokemonScale = 508, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Pii + .categoryName = _("STERNFORM"), + .height = 3, + .weight = 30, + .descriptionPage1 = DexDescription_Pii_1, + .descriptionPage2 = DexDescription_Pii_2, + .pokemonScale = 462, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Fluffeluff + .categoryName = _("BALLON"), + .height = 3, + .weight = 10, + .descriptionPage1 = DexDescription_Fluffeluff_1, + .descriptionPage2 = DexDescription_Fluffeluff_2, + .pokemonScale = 457, + .pokemonOffset = 65535, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Togepi + .categoryName = _("ZACKENBALL"), + .height = 3, + .weight = 15, + .descriptionPage1 = DexDescription_Togepi_1, + .descriptionPage2 = DexDescription_Togepi_2, + .pokemonScale = 507, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Togetic + .categoryName = _("FREUDE"), + .height = 6, + .weight = 32, + .descriptionPage1 = DexDescription_Togetic_1, + .descriptionPage2 = DexDescription_Togetic_2, + .pokemonScale = 424, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Natu + .categoryName = _("KLEINVOGEL"), + .height = 2, + .weight = 20, + .descriptionPage1 = DexDescription_Natu_1, + .descriptionPage2 = DexDescription_Natu_2, + .pokemonScale = 610, + .pokemonOffset = 25, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Xatu + .categoryName = _("MYSTIK"), + .height = 15, + .weight = 150, + .descriptionPage1 = DexDescription_Xatu_1, + .descriptionPage2 = DexDescription_Xatu_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 318, + .trainerOffset = 4, + }, + { + // Voltilamm + .categoryName = _("WOLLE"), + .height = 6, + .weight = 78, + .descriptionPage1 = DexDescription_Voltilamm_1, + .descriptionPage2 = DexDescription_Voltilamm_2, + .pokemonScale = 379, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Waaty + .categoryName = _("WOLLE"), + .height = 8, + .weight = 133, + .descriptionPage1 = DexDescription_Waaty_1, + .descriptionPage2 = DexDescription_Waaty_2, + .pokemonScale = 372, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Ampharos + .categoryName = _("LEUCHTE"), + .height = 14, + .weight = 615, + .descriptionPage1 = DexDescription_Ampharos_1, + .descriptionPage2 = DexDescription_Ampharos_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Blubella + .categoryName = _("BLUME"), + .height = 4, + .weight = 58, + .descriptionPage1 = DexDescription_Blubella_1, + .descriptionPage2 = DexDescription_Blubella_2, + .pokemonScale = 472, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Marill + .categoryName = _("AQUAMAUS"), + .height = 4, + .weight = 85, + .descriptionPage1 = DexDescription_Marill_1, + .descriptionPage2 = DexDescription_Marill_2, + .pokemonScale = 476, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Azumarill + .categoryName = _("AQUAHASE"), + .height = 8, + .weight = 285, + .descriptionPage1 = DexDescription_Azumarill_1, + .descriptionPage2 = DexDescription_Azumarill_2, + .pokemonScale = 448, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Mogelbaum + .categoryName = _("IMITATION"), + .height = 12, + .weight = 380, + .descriptionPage1 = DexDescription_Mogelbaum_1, + .descriptionPage2 = DexDescription_Mogelbaum_2, + .pokemonScale = 305, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Quaxo + .categoryName = _("FROSCH"), + .height = 11, + .weight = 339, + .descriptionPage1 = DexDescription_Quaxo_1, + .descriptionPage2 = DexDescription_Quaxo_2, + .pokemonScale = 289, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Hoppspross + .categoryName = _("LÖWENZAHN"), + .height = 4, + .weight = 5, + .descriptionPage1 = DexDescription_Hoppspross_1, + .descriptionPage2 = DexDescription_Hoppspross_2, + .pokemonScale = 562, + .pokemonOffset = 65529, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Hubelupf + .categoryName = _("LÖWENZAHN"), + .height = 6, + .weight = 10, + .descriptionPage1 = DexDescription_Hubelupf_1, + .descriptionPage2 = DexDescription_Hubelupf_2, + .pokemonScale = 387, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Papungha + .categoryName = _("LÖWENZAHN"), + .height = 8, + .weight = 30, + .descriptionPage1 = DexDescription_Papungha_1, + .descriptionPage2 = DexDescription_Papungha_2, + .pokemonScale = 418, + .pokemonOffset = 65532, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Griffel + .categoryName = _("LANGSCHWEIF"), + .height = 8, + .weight = 115, + .descriptionPage1 = DexDescription_Griffel_1, + .descriptionPage2 = DexDescription_Griffel_2, + .pokemonScale = 363, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sonnkern + .categoryName = _("SAMEN"), + .height = 3, + .weight = 18, + .descriptionPage1 = DexDescription_Sonnkern_1, + .descriptionPage2 = DexDescription_Sonnkern_2, + .pokemonScale = 541, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sonnflora + .categoryName = _("SONNE"), + .height = 8, + .weight = 85, + .descriptionPage1 = DexDescription_Sonnflora_1, + .descriptionPage2 = DexDescription_Sonnflora_2, + .pokemonScale = 444, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Yanma + .categoryName = _("LIBELLE"), + .height = 12, + .weight = 380, + .descriptionPage1 = DexDescription_Yanma_1, + .descriptionPage2 = DexDescription_Yanma_2, + .pokemonScale = 274, + .pokemonOffset = 65535, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Felino + .categoryName = _("FISCH"), + .height = 4, + .weight = 85, + .descriptionPage1 = DexDescription_Felino_1, + .descriptionPage2 = DexDescription_Felino_2, + .pokemonScale = 479, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Morlord + .categoryName = _("FISCH"), + .height = 14, + .weight = 750, + .descriptionPage1 = DexDescription_Morlord_1, + .descriptionPage2 = DexDescription_Morlord_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Psiana + .categoryName = _("SONNE"), + .height = 9, + .weight = 265, + .descriptionPage1 = DexDescription_Psiana_1, + .descriptionPage2 = DexDescription_Psiana_2, + .pokemonScale = 363, + .pokemonOffset = 14, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Nachtara + .categoryName = _("MONDSCHEIN"), + .height = 10, + .weight = 270, + .descriptionPage1 = DexDescription_Nachtara_1, + .descriptionPage2 = DexDescription_Nachtara_2, + .pokemonScale = 317, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kramurx + .categoryName = _("FINSTERNIS"), + .height = 5, + .weight = 21, + .descriptionPage1 = DexDescription_Kramurx_1, + .descriptionPage2 = DexDescription_Kramurx_2, + .pokemonScale = 401, + .pokemonOffset = 65528, + .trainerScale = 256, + .trainerOffset = 1, + }, + { + // Laschoking + .categoryName = _("MONARCH"), + .height = 20, + .weight = 795, + .descriptionPage1 = DexDescription_Laschoking_1, + .descriptionPage2 = DexDescription_Laschoking_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 309, + .trainerOffset = 5, + }, + { + // Traunfugil + .categoryName = _("KREISCHER"), + .height = 7, + .weight = 10, + .descriptionPage1 = DexDescription_Traunfugil_1, + .descriptionPage2 = DexDescription_Traunfugil_2, + .pokemonScale = 407, + .pokemonOffset = 65528, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Icognito + .categoryName = _("SYMBOL"), + .height = 5, + .weight = 50, + .descriptionPage1 = DexDescription_Icognito_1, + .descriptionPage2 = DexDescription_Icognito_2, + .pokemonScale = 411, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Woingenau + .categoryName = _("GEDULD"), + .height = 13, + .weight = 285, + .descriptionPage1 = DexDescription_Woingenau_1, + .descriptionPage2 = DexDescription_Woingenau_2, + .pokemonScale = 274, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Girafarig + .categoryName = _("LANGHALS"), + .height = 15, + .weight = 415, + .descriptionPage1 = DexDescription_Girafarig_1, + .descriptionPage2 = DexDescription_Girafarig_2, + .pokemonScale = 281, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Tannza + .categoryName = _("BEUTELWURM"), + .height = 6, + .weight = 72, + .descriptionPage1 = DexDescription_Tannza_1, + .descriptionPage2 = DexDescription_Tannza_2, + .pokemonScale = 445, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Forstellka + .categoryName = _("BEUTELWURM"), + .height = 12, + .weight = 1258, + .descriptionPage1 = DexDescription_Forstellka_1, + .descriptionPage2 = DexDescription_Forstellka_2, + .pokemonScale = 293, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Dummisel + .categoryName = _("SCHLANGE"), + .height = 15, + .weight = 140, + .descriptionPage1 = DexDescription_Dummisel_1, + .descriptionPage2 = DexDescription_Dummisel_2, + .pokemonScale = 316, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Skorgla + .categoryName = _("FLUGSKORPI"), + .height = 11, + .weight = 648, + .descriptionPage1 = DexDescription_Skorgla_1, + .descriptionPage2 = DexDescription_Skorgla_2, + .pokemonScale = 350, + .pokemonOffset = 65535, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Stahlos + .categoryName = _("STAHLBOA"), + .height = 92, + .weight = 4000, + .descriptionPage1 = DexDescription_Stahlos_1, + .descriptionPage2 = DexDescription_Stahlos_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 516, + .trainerOffset = 13, + }, + { + // Snubbull + .categoryName = _("FEE"), + .height = 6, + .weight = 78, + .descriptionPage1 = DexDescription_Snubbull_1, + .descriptionPage2 = DexDescription_Snubbull_2, + .pokemonScale = 465, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Granbull + .categoryName = _("FEE"), + .height = 14, + .weight = 487, + .descriptionPage1 = DexDescription_Granbull_1, + .descriptionPage2 = DexDescription_Granbull_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Baldorfish + .categoryName = _("BALLON"), + .height = 5, + .weight = 39, + .descriptionPage1 = DexDescription_Baldorfish_1, + .descriptionPage2 = DexDescription_Baldorfish_2, + .pokemonScale = 430, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Scherox + .categoryName = _("KNEIFER"), + .height = 18, + .weight = 1180, + .descriptionPage1 = DexDescription_Scherox_1, + .descriptionPage2 = DexDescription_Scherox_2, + .pokemonScale = 278, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Pottrott + .categoryName = _("SCHIMMEL"), + .height = 6, + .weight = 205, + .descriptionPage1 = DexDescription_Pottrott_1, + .descriptionPage2 = DexDescription_Pottrott_2, + .pokemonScale = 485, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Skaraborn + .categoryName = _("EINZELHORN"), + .height = 15, + .weight = 540, + .descriptionPage1 = DexDescription_Skaraborn_1, + .descriptionPage2 = DexDescription_Skaraborn_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sniebel + .categoryName = _("STICHKLAUE"), + .height = 9, + .weight = 280, + .descriptionPage1 = DexDescription_Sniebel_1, + .descriptionPage2 = DexDescription_Sniebel_2, + .pokemonScale = 413, + .pokemonOffset = 65533, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Teddiursa + .categoryName = _("KLEINBÄR"), + .height = 6, + .weight = 88, + .descriptionPage1 = DexDescription_Teddiursa_1, + .descriptionPage2 = DexDescription_Teddiursa_2, + .pokemonScale = 455, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Ursaring + .categoryName = _("SCHLÄFER"), + .height = 18, + .weight = 1258, + .descriptionPage1 = DexDescription_Ursaring_1, + .descriptionPage2 = DexDescription_Ursaring_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Schneckmag + .categoryName = _("LAVA"), + .height = 7, + .weight = 350, + .descriptionPage1 = DexDescription_Schneckmag_1, + .descriptionPage2 = DexDescription_Schneckmag_2, + .pokemonScale = 329, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Magcargo + .categoryName = _("LAVA"), + .height = 8, + .weight = 550, + .descriptionPage1 = DexDescription_Magcargo_1, + .descriptionPage2 = DexDescription_Magcargo_2, + .pokemonScale = 332, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Quiekel + .categoryName = _("FERKEL"), + .height = 4, + .weight = 65, + .descriptionPage1 = DexDescription_Quiekel_1, + .descriptionPage2 = DexDescription_Quiekel_2, + .pokemonScale = 324, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Keifel + .categoryName = _("SCHWEIN"), + .height = 11, + .weight = 558, + .descriptionPage1 = DexDescription_Keifel_1, + .descriptionPage2 = DexDescription_Keifel_2, + .pokemonScale = 306, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Corasonn + .categoryName = _("KORALLE"), + .height = 6, + .weight = 50, + .descriptionPage1 = DexDescription_Corasonn_1, + .descriptionPage2 = DexDescription_Corasonn_2, + .pokemonScale = 410, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Remoraid + .categoryName = _("HOCHDRUCK"), + .height = 6, + .weight = 120, + .descriptionPage1 = DexDescription_Remoraid_1, + .descriptionPage2 = DexDescription_Remoraid_2, + .pokemonScale = 316, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Octillery + .categoryName = _("HOCHDRUCK"), + .height = 9, + .weight = 285, + .descriptionPage1 = DexDescription_Octillery_1, + .descriptionPage2 = DexDescription_Octillery_2, + .pokemonScale = 296, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Botogel + .categoryName = _("LIEFERANT"), + .height = 9, + .weight = 160, + .descriptionPage1 = DexDescription_Botogel_1, + .descriptionPage2 = DexDescription_Botogel_2, + .pokemonScale = 293, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Mantax + .categoryName = _("FLUGROCHEN"), + .height = 21, + .weight = 2200, + .descriptionPage1 = DexDescription_Mantax_1, + .descriptionPage2 = DexDescription_Mantax_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 342, + .trainerOffset = 7, + }, + { + // Panzaeron + .categoryName = _("FLUGSTAHL"), + .height = 17, + .weight = 505, + .descriptionPage1 = DexDescription_Panzaeron_1, + .descriptionPage2 = DexDescription_Panzaeron_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 271, + .trainerOffset = 1, + }, + { + // Hunduster + .categoryName = _("HADES"), + .height = 6, + .weight = 108, + .descriptionPage1 = DexDescription_Hunduster_1, + .descriptionPage2 = DexDescription_Hunduster_2, + .pokemonScale = 393, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Hundemon + .categoryName = _("HADES"), + .height = 14, + .weight = 350, + .descriptionPage1 = DexDescription_Hundemon_1, + .descriptionPage2 = DexDescription_Hundemon_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Seedraking + .categoryName = _("DRACHE"), + .height = 18, + .weight = 1520, + .descriptionPage1 = DexDescription_Seedraking_1, + .descriptionPage2 = DexDescription_Seedraking_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 287, + .trainerOffset = 0, + }, + { + // Phanpy + .categoryName = _("LANGRÜSSEL"), + .height = 5, + .weight = 335, + .descriptionPage1 = DexDescription_Phanpy_1, + .descriptionPage2 = DexDescription_Phanpy_2, + .pokemonScale = 465, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Donphan + .categoryName = _("PANZERTIER"), + .height = 11, + .weight = 1200, + .descriptionPage1 = DexDescription_Donphan_1, + .descriptionPage2 = DexDescription_Donphan_2, + .pokemonScale = 313, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Porygon2 + .categoryName = _("VIRTUELL"), + .height = 6, + .weight = 325, + .descriptionPage1 = DexDescription_Porygon2_1, + .descriptionPage2 = DexDescription_Porygon2_2, + .pokemonScale = 320, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Damhirplex + .categoryName = _("VIELENDER"), + .height = 14, + .weight = 712, + .descriptionPage1 = DexDescription_Damhirplex_1, + .descriptionPage2 = DexDescription_Damhirplex_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Farbeagle + .categoryName = _("MALER"), + .height = 12, + .weight = 580, + .descriptionPage1 = DexDescription_Farbeagle_1, + .descriptionPage2 = DexDescription_Farbeagle_2, + .pokemonScale = 287, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Rabauz + .categoryName = _("RACKER"), + .height = 7, + .weight = 210, + .descriptionPage1 = DexDescription_Rabauz_1, + .descriptionPage2 = DexDescription_Rabauz_2, + .pokemonScale = 292, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kapoera + .categoryName = _("KOPFSTAND"), + .height = 14, + .weight = 480, + .descriptionPage1 = DexDescription_Kapoera_1, + .descriptionPage2 = DexDescription_Kapoera_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 257, + .trainerOffset = 0, + }, + { + // Kussilla + .categoryName = _("KUSS"), + .height = 4, + .weight = 60, + .descriptionPage1 = DexDescription_Kussilla_1, + .descriptionPage2 = DexDescription_Kussilla_2, + .pokemonScale = 440, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Elekid + .categoryName = _("ELEKTRO"), + .height = 6, + .weight = 235, + .descriptionPage1 = DexDescription_Elekid_1, + .descriptionPage2 = DexDescription_Elekid_2, + .pokemonScale = 363, + .pokemonOffset = 14, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Magby + .categoryName = _("GLUTHERD"), + .height = 7, + .weight = 214, + .descriptionPage1 = DexDescription_Magby_1, + .descriptionPage2 = DexDescription_Magby_2, + .pokemonScale = 284, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Miltank + .categoryName = _("MILCHKUH"), + .height = 12, + .weight = 755, + .descriptionPage1 = DexDescription_Miltank_1, + .descriptionPage2 = DexDescription_Miltank_2, + .pokemonScale = 280, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Heiteira + .categoryName = _("FREUDE"), + .height = 15, + .weight = 468, + .descriptionPage1 = DexDescription_Heiteira_1, + .descriptionPage2 = DexDescription_Heiteira_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 310, + .trainerOffset = 3, + }, + { + // Raikou + .categoryName = _("DONNER"), + .height = 19, + .weight = 1780, + .descriptionPage1 = DexDescription_Raikou_1, + .descriptionPage2 = DexDescription_Raikou_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 345, + .trainerOffset = 7, + }, + { + // Entei + .categoryName = _("VULKAN"), + .height = 21, + .weight = 1980, + .descriptionPage1 = DexDescription_Entei_1, + .descriptionPage2 = DexDescription_Entei_2, + .pokemonScale = 259, + .pokemonOffset = 0, + .trainerScale = 345, + .trainerOffset = 7, + }, + { + // Suicune + .categoryName = _("POLARLICHT"), + .height = 20, + .weight = 1870, + .descriptionPage1 = DexDescription_Suicune_1, + .descriptionPage2 = DexDescription_Suicune_2, + .pokemonScale = 269, + .pokemonOffset = 0, + .trainerScale = 345, + .trainerOffset = 7, + }, + { + // Larvitar + .categoryName = _("FELSHAUT"), + .height = 6, + .weight = 720, + .descriptionPage1 = DexDescription_Larvitar_1, + .descriptionPage2 = DexDescription_Larvitar_2, + .pokemonScale = 472, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Pupitar + .categoryName = _("HARTSCHALE"), + .height = 12, + .weight = 1520, + .descriptionPage1 = DexDescription_Pupitar_1, + .descriptionPage2 = DexDescription_Pupitar_2, + .pokemonScale = 292, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Despotar + .categoryName = _("PANZERTIER"), + .height = 20, + .weight = 2020, + .descriptionPage1 = DexDescription_Despotar_1, + .descriptionPage2 = DexDescription_Despotar_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 345, + .trainerOffset = 7, + }, + { + // Lugia + .categoryName = _("TAUCHER"), + .height = 52, + .weight = 2160, + .descriptionPage1 = DexDescription_Lugia_1, + .descriptionPage2 = DexDescription_Lugia_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 721, + .trainerOffset = 19, + }, + { + // Ho-oh + .categoryName = _("REGENBOGEN"), + .height = 38, + .weight = 1990, + .descriptionPage1 = DexDescription_HoOh_1, + .descriptionPage2 = DexDescription_HoOh_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 610, + .trainerOffset = 17, + }, + { + // Celebi + .categoryName = _("ZEITREISE"), + .height = 6, + .weight = 50, + .descriptionPage1 = DexDescription_Celebi_1, + .descriptionPage2 = DexDescription_Celebi_2, + .pokemonScale = 393, + .pokemonOffset = 65526, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Geckarbor + .categoryName = _("WALDGECKO"), + .height = 5, + .weight = 50, + .descriptionPage1 = DexDescription_Geckarbor_1, + .descriptionPage2 = DexDescription_Geckarbor_2, + .pokemonScale = 541, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Reptain + .categoryName = _("WALDGECKO"), + .height = 9, + .weight = 216, + .descriptionPage1 = DexDescription_Reptain_1, + .descriptionPage2 = DexDescription_Reptain_2, + .pokemonScale = 360, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Gewaldro + .categoryName = _("DSCHUNGEL"), + .height = 17, + .weight = 522, + .descriptionPage1 = DexDescription_Gewaldro_1, + .descriptionPage2 = DexDescription_Gewaldro_2, + .pokemonScale = 256, + .pokemonOffset = 65535, + .trainerScale = 275, + .trainerOffset = 2, + }, + { + // Flemmli + .categoryName = _("KÜKEN"), + .height = 4, + .weight = 25, + .descriptionPage1 = DexDescription_Flemmli_1, + .descriptionPage2 = DexDescription_Flemmli_2, + .pokemonScale = 566, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Jungglut + .categoryName = _("KLEINHAHN"), + .height = 9, + .weight = 195, + .descriptionPage1 = DexDescription_Jungglut_1, + .descriptionPage2 = DexDescription_Jungglut_2, + .pokemonScale = 343, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Lohgock + .categoryName = _("GROSSBRAND"), + .height = 19, + .weight = 520, + .descriptionPage1 = DexDescription_Lohgock_1, + .descriptionPage2 = DexDescription_Lohgock_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 301, + .trainerOffset = 4, + }, + { + // Hydropi + .categoryName = _("LEHMHÜPFER"), + .height = 4, + .weight = 76, + .descriptionPage1 = DexDescription_Hydropi_1, + .descriptionPage2 = DexDescription_Hydropi_2, + .pokemonScale = 535, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Moorabbel + .categoryName = _("LEHMHÜPFER"), + .height = 7, + .weight = 280, + .descriptionPage1 = DexDescription_Moorabbel_1, + .descriptionPage2 = DexDescription_Moorabbel_2, + .pokemonScale = 340, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sumpex + .categoryName = _("LEHMHÜPFER"), + .height = 15, + .weight = 819, + .descriptionPage1 = DexDescription_Sumpex_1, + .descriptionPage2 = DexDescription_Sumpex_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Fiffyen + .categoryName = _("BISS"), + .height = 5, + .weight = 136, + .descriptionPage1 = DexDescription_Fiffyen_1, + .descriptionPage2 = DexDescription_Fiffyen_2, + .pokemonScale = 481, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Magnayen + .categoryName = _("BISS"), + .height = 10, + .weight = 370, + .descriptionPage1 = DexDescription_Magnayen_1, + .descriptionPage2 = DexDescription_Magnayen_2, + .pokemonScale = 362, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Zigzachs + .categoryName = _("KLEINDACHS"), + .height = 4, + .weight = 175, + .descriptionPage1 = DexDescription_Zigzachs_1, + .descriptionPage2 = DexDescription_Zigzachs_2, + .pokemonScale = 560, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Geradaks + .categoryName = _("SPRINTER"), + .height = 5, + .weight = 325, + .descriptionPage1 = DexDescription_Geradaks_1, + .descriptionPage2 = DexDescription_Geradaks_2, + .pokemonScale = 321, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Waumpel + .categoryName = _("WURM"), + .height = 3, + .weight = 36, + .descriptionPage1 = DexDescription_Waumpel_1, + .descriptionPage2 = DexDescription_Waumpel_2, + .pokemonScale = 711, + .pokemonOffset = 24, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Schaloko + .categoryName = _("KOKON"), + .height = 6, + .weight = 100, + .descriptionPage1 = DexDescription_Schaloko_1, + .descriptionPage2 = DexDescription_Schaloko_2, + .pokemonScale = 431, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Papinella + .categoryName = _("FALTER"), + .height = 10, + .weight = 284, + .descriptionPage1 = DexDescription_Papinella_1, + .descriptionPage2 = DexDescription_Papinella_2, + .pokemonScale = 298, + .pokemonOffset = 65535, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Panekon + .categoryName = _("KOKON"), + .height = 7, + .weight = 115, + .descriptionPage1 = DexDescription_Panekon_1, + .descriptionPage2 = DexDescription_Panekon_2, + .pokemonScale = 391, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Pudox + .categoryName = _("GIFTMOTTE"), + .height = 12, + .weight = 316, + .descriptionPage1 = DexDescription_Pudox_1, + .descriptionPage2 = DexDescription_Pudox_2, + .pokemonScale = 269, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Loturzel + .categoryName = _("WASSERLINSE"), + .height = 5, + .weight = 26, + .descriptionPage1 = DexDescription_Loturzel_1, + .descriptionPage2 = DexDescription_Loturzel_2, + .pokemonScale = 406, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Lombrero + .categoryName = _("FROHMUT"), + .height = 12, + .weight = 325, + .descriptionPage1 = DexDescription_Lombrero_1, + .descriptionPage2 = DexDescription_Lombrero_2, + .pokemonScale = 277, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kappalores + .categoryName = _("SORGLOS"), + .height = 15, + .weight = 550, + .descriptionPage1 = DexDescription_Kappalores_1, + .descriptionPage2 = DexDescription_Kappalores_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 268, + .trainerOffset = 65535, + }, + { + // Samurzel + .categoryName = _("EICHELNUSS"), + .height = 5, + .weight = 40, + .descriptionPage1 = DexDescription_Samurzel_1, + .descriptionPage2 = DexDescription_Samurzel_2, + .pokemonScale = 472, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Blanas + .categoryName = _("HINTERLIST"), + .height = 10, + .weight = 280, + .descriptionPage1 = DexDescription_Blanas_1, + .descriptionPage2 = DexDescription_Blanas_2, + .pokemonScale = 299, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Tengulist + .categoryName = _("VERSCHLAGEN"), + .height = 13, + .weight = 596, + .descriptionPage1 = DexDescription_Tengulist_1, + .descriptionPage2 = DexDescription_Tengulist_2, + .pokemonScale = 290, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Schwalbini + .categoryName = _("SCHWÄLBLEIN"), + .height = 3, + .weight = 23, + .descriptionPage1 = DexDescription_Schwalbini_1, + .descriptionPage2 = DexDescription_Schwalbini_2, + .pokemonScale = 465, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Schwalboss + .categoryName = _("SCHWALBE"), + .height = 7, + .weight = 198, + .descriptionPage1 = DexDescription_Schwalboss_1, + .descriptionPage2 = DexDescription_Schwalboss_2, + .pokemonScale = 428, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Wingull + .categoryName = _("SEEMÖWE"), + .height = 6, + .weight = 95, + .descriptionPage1 = DexDescription_Wingull_1, + .descriptionPage2 = DexDescription_Wingull_2, + .pokemonScale = 295, + .pokemonOffset = 65534, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Pelipper + .categoryName = _("WASSERVOGEL"), + .height = 12, + .weight = 280, + .descriptionPage1 = DexDescription_Pelipper_1, + .descriptionPage2 = DexDescription_Pelipper_2, + .pokemonScale = 288, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Trasla + .categoryName = _("GEFÜHL"), + .height = 4, + .weight = 66, + .descriptionPage1 = DexDescription_Trasla_1, + .descriptionPage2 = DexDescription_Trasla_2, + .pokemonScale = 457, + .pokemonOffset = 65533, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kirlia + .categoryName = _("EMOTION"), + .height = 8, + .weight = 202, + .descriptionPage1 = DexDescription_Kirlia_1, + .descriptionPage2 = DexDescription_Kirlia_2, + .pokemonScale = 354, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Guardevoir + .categoryName = _("UMARMUNG"), + .height = 16, + .weight = 484, + .descriptionPage1 = DexDescription_Guardevoir_1, + .descriptionPage2 = DexDescription_Guardevoir_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Gehweiher + .categoryName = _("WASSERGEHER"), + .height = 5, + .weight = 17, + .descriptionPage1 = DexDescription_Gehweiher_1, + .descriptionPage2 = DexDescription_Gehweiher_2, + .pokemonScale = 375, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Maskeregen + .categoryName = _("AUGE"), + .height = 8, + .weight = 36, + .descriptionPage1 = DexDescription_Maskeregen_1, + .descriptionPage2 = DexDescription_Maskeregen_2, + .pokemonScale = 378, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Knilz + .categoryName = _("PILZ"), + .height = 4, + .weight = 45, + .descriptionPage1 = DexDescription_Knilz_1, + .descriptionPage2 = DexDescription_Knilz_2, + .pokemonScale = 513, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kapilz + .categoryName = _("PILZ"), + .height = 12, + .weight = 392, + .descriptionPage1 = DexDescription_Kapilz_1, + .descriptionPage2 = DexDescription_Kapilz_2, + .pokemonScale = 324, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Bummelz + .categoryName = _("FAULPELZ"), + .height = 8, + .weight = 240, + .descriptionPage1 = DexDescription_Bummelz_1, + .descriptionPage2 = DexDescription_Bummelz_2, + .pokemonScale = 291, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Muntier + .categoryName = _("WILDAFFE"), + .height = 14, + .weight = 465, + .descriptionPage1 = DexDescription_Muntier_1, + .descriptionPage2 = DexDescription_Muntier_2, + .pokemonScale = 301, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Letarking + .categoryName = _("MÜSSIG"), + .height = 20, + .weight = 1305, + .descriptionPage1 = DexDescription_Letarking_1, + .descriptionPage2 = DexDescription_Letarking_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 300, + .trainerOffset = 1, + }, + { + // Nincada + .categoryName = _("VORBEREITER"), + .height = 5, + .weight = 55, + .descriptionPage1 = DexDescription_Nincada_1, + .descriptionPage2 = DexDescription_Nincada_2, + .pokemonScale = 405, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Ninjask + .categoryName = _("NINJA"), + .height = 8, + .weight = 120, + .descriptionPage1 = DexDescription_Ninjask_1, + .descriptionPage2 = DexDescription_Ninjask_2, + .pokemonScale = 383, + .pokemonOffset = 65527, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Ninjatom + .categoryName = _("HÄUTUNG"), + .height = 8, + .weight = 12, + .descriptionPage1 = DexDescription_Ninjatom_1, + .descriptionPage2 = DexDescription_Ninjatom_2, + .pokemonScale = 372, + .pokemonOffset = 65528, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Flurmel + .categoryName = _("FLÜSTER"), + .height = 6, + .weight = 163, + .descriptionPage1 = DexDescription_Flurmel_1, + .descriptionPage2 = DexDescription_Flurmel_2, + .pokemonScale = 373, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Krakeelo + .categoryName = _("LAUTHALS"), + .height = 10, + .weight = 405, + .descriptionPage1 = DexDescription_Krakeelo_1, + .descriptionPage2 = DexDescription_Krakeelo_2, + .pokemonScale = 356, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Krawumms + .categoryName = _("KRACH"), + .height = 15, + .weight = 840, + .descriptionPage1 = DexDescription_Krawumms_1, + .descriptionPage2 = DexDescription_Krawumms_2, + .pokemonScale = 284, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Makuhita + .categoryName = _("COURAGE"), + .height = 10, + .weight = 864, + .descriptionPage1 = DexDescription_Makuhita_1, + .descriptionPage2 = DexDescription_Makuhita_2, + .pokemonScale = 256, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Hariyama + .categoryName = _("ARMWURF"), + .height = 23, + .weight = 2538, + .descriptionPage1 = DexDescription_Hariyama_1, + .descriptionPage2 = DexDescription_Hariyama_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 343, + .trainerOffset = 7, + }, + { + // Azurill + .categoryName = _("GEPUNKTET"), + .height = 2, + .weight = 20, + .descriptionPage1 = DexDescription_Azurill_1, + .descriptionPage2 = DexDescription_Azurill_2, + .pokemonScale = 603, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Nasgnet + .categoryName = _("KOMPASS"), + .height = 10, + .weight = 970, + .descriptionPage1 = DexDescription_Nasgnet_1, + .descriptionPage2 = DexDescription_Nasgnet_2, + .pokemonScale = 256, + .pokemonOffset = 9, + .trainerScale = 289, + .trainerOffset = 3, + }, + { + // Eneco + .categoryName = _("KÄTZCHEN"), + .height = 6, + .weight = 110, + .descriptionPage1 = DexDescription_Eneco_1, + .descriptionPage2 = DexDescription_Eneco_2, + .pokemonScale = 492, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Enekoro + .categoryName = _("EINGEBILDET"), + .height = 11, + .weight = 326, + .descriptionPage1 = DexDescription_Enekoro_1, + .descriptionPage2 = DexDescription_Enekoro_2, + .pokemonScale = 322, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Zobiris + .categoryName = _("FINSTERNIS"), + .height = 5, + .weight = 110, + .descriptionPage1 = DexDescription_Zobiris_1, + .descriptionPage2 = DexDescription_Zobiris_2, + .pokemonScale = 451, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Flunkifer + .categoryName = _("SCHWINDLER"), + .height = 6, + .weight = 115, + .descriptionPage1 = DexDescription_Flunkifer_1, + .descriptionPage2 = DexDescription_Flunkifer_2, + .pokemonScale = 466, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Stollunior + .categoryName = _("EISENPANZER"), + .height = 4, + .weight = 600, + .descriptionPage1 = DexDescription_Stollunior_1, + .descriptionPage2 = DexDescription_Stollunior_2, + .pokemonScale = 419, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Stollrak + .categoryName = _("EISENPANZER"), + .height = 9, + .weight = 1200, + .descriptionPage1 = DexDescription_Stollrak_1, + .descriptionPage2 = DexDescription_Stollrak_2, + .pokemonScale = 275, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Stolloss + .categoryName = _("EISENPANZER"), + .height = 21, + .weight = 3600, + .descriptionPage1 = DexDescription_Stolloss_1, + .descriptionPage2 = DexDescription_Stolloss_2, + .pokemonScale = 256, + .pokemonOffset = 65535, + .trainerScale = 350, + .trainerOffset = 6, + }, + { + // Meditie + .categoryName = _("MEDITATION"), + .height = 6, + .weight = 112, + .descriptionPage1 = DexDescription_Meditie_1, + .descriptionPage2 = DexDescription_Meditie_2, + .pokemonScale = 465, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Meditalis + .categoryName = _("MEDITATION"), + .height = 13, + .weight = 315, + .descriptionPage1 = DexDescription_Meditalis_1, + .descriptionPage2 = DexDescription_Meditalis_2, + .pokemonScale = 298, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Frizelbliz + .categoryName = _("GEWITTER"), + .height = 6, + .weight = 152, + .descriptionPage1 = DexDescription_Frizelbliz_1, + .descriptionPage2 = DexDescription_Frizelbliz_2, + .pokemonScale = 290, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Voltenso + .categoryName = _("ENTLADUNG"), + .height = 15, + .weight = 402, + .descriptionPage1 = DexDescription_Voltenso_1, + .descriptionPage2 = DexDescription_Voltenso_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 257, + .trainerOffset = 0, + }, + { + // Plusle + .categoryName = _("JUBEL"), + .height = 4, + .weight = 42, + .descriptionPage1 = DexDescription_Plusle_1, + .descriptionPage2 = DexDescription_Plusle_2, + .pokemonScale = 515, + .pokemonOffset = 65527, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Minun + .categoryName = _("JUBEL"), + .height = 4, + .weight = 42, + .descriptionPage1 = DexDescription_Minun_1, + .descriptionPage2 = DexDescription_Minun_2, + .pokemonScale = 512, + .pokemonOffset = 65529, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Volbeat + .categoryName = _("LIBELLE"), + .height = 7, + .weight = 177, + .descriptionPage1 = DexDescription_Volbeat_1, + .descriptionPage2 = DexDescription_Volbeat_2, + .pokemonScale = 442, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Illumise + .categoryName = _("LIBELLE"), + .height = 6, + .weight = 177, + .descriptionPage1 = DexDescription_Illumise_1, + .descriptionPage2 = DexDescription_Illumise_2, + .pokemonScale = 572, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Roselia + .categoryName = _("DORN"), + .height = 3, + .weight = 20, + .descriptionPage1 = DexDescription_Roselia_1, + .descriptionPage2 = DexDescription_Roselia_2, + .pokemonScale = 677, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Schluppuck + .categoryName = _("MAGEN"), + .height = 4, + .weight = 103, + .descriptionPage1 = DexDescription_Schluppuck_1, + .descriptionPage2 = DexDescription_Schluppuck_2, + .pokemonScale = 593, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Schlukwech + .categoryName = _("GIFTBEUTEL"), + .height = 17, + .weight = 800, + .descriptionPage1 = DexDescription_Schlukwech_1, + .descriptionPage2 = DexDescription_Schlukwech_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 345, + .trainerOffset = 3, + }, + { + // Kanivanha + .categoryName = _("GNADENLOS"), + .height = 8, + .weight = 208, + .descriptionPage1 = DexDescription_Kanivanha_1, + .descriptionPage2 = DexDescription_Kanivanha_2, + .pokemonScale = 362, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Tohaido + .categoryName = _("BRUTAL"), + .height = 18, + .weight = 888, + .descriptionPage1 = DexDescription_Tohaido_1, + .descriptionPage2 = DexDescription_Tohaido_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 317, + .trainerOffset = 3, + }, + { + // Wailmer + .categoryName = _("KUGELWAL"), + .height = 20, + .weight = 1300, + .descriptionPage1 = DexDescription_Wailmer_1, + .descriptionPage2 = DexDescription_Wailmer_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 493, + .trainerOffset = 0, + }, + { + // Wailord + .categoryName = _("FLUTWAL"), + .height = 145, + .weight = 3980, + .descriptionPage1 = DexDescription_Wailord_1, + .descriptionPage2 = DexDescription_Wailord_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 1352, + .trainerOffset = 18, + }, + { + // Camaub + .categoryName = _("TAUBHEIT"), + .height = 7, + .weight = 240, + .descriptionPage1 = DexDescription_Camaub_1, + .descriptionPage2 = DexDescription_Camaub_2, + .pokemonScale = 342, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Camerupt + .categoryName = _("AUSBRUCH"), + .height = 19, + .weight = 2200, + .descriptionPage1 = DexDescription_Camerupt_1, + .descriptionPage2 = DexDescription_Camerupt_2, + .pokemonScale = 256, + .pokemonOffset = 7, + .trainerScale = 345, + .trainerOffset = 6, + }, + { + // Qurtel + .categoryName = _("KOHLE"), + .height = 5, + .weight = 804, + .descriptionPage1 = DexDescription_Qurtel_1, + .descriptionPage2 = DexDescription_Qurtel_2, + .pokemonScale = 390, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Spoink + .categoryName = _("SPRUNGFEDER"), + .height = 7, + .weight = 306, + .descriptionPage1 = DexDescription_Spoink_1, + .descriptionPage2 = DexDescription_Spoink_2, + .pokemonScale = 423, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Groink + .categoryName = _("MANIPULATOR"), + .height = 9, + .weight = 715, + .descriptionPage1 = DexDescription_Groink_1, + .descriptionPage2 = DexDescription_Groink_2, + .pokemonScale = 358, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Pandir + .categoryName = _("PUNKT-PANDA"), + .height = 11, + .weight = 50, + .descriptionPage1 = DexDescription_Pandir_1, + .descriptionPage2 = DexDescription_Pandir_2, + .pokemonScale = 321, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Knacklion + .categoryName = _("AMEISENLÖWE"), + .height = 7, + .weight = 150, + .descriptionPage1 = DexDescription_Knacklion_1, + .descriptionPage2 = DexDescription_Knacklion_2, + .pokemonScale = 298, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Vibrava + .categoryName = _("VIBRATION"), + .height = 11, + .weight = 153, + .descriptionPage1 = DexDescription_Vibrava_1, + .descriptionPage2 = DexDescription_Vibrava_2, + .pokemonScale = 370, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Libelldra + .categoryName = _("MYSTIK"), + .height = 20, + .weight = 820, + .descriptionPage1 = DexDescription_Libelldra_1, + .descriptionPage2 = DexDescription_Libelldra_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 268, + .trainerOffset = 1, + }, + { + // Tuska + .categoryName = _("KAKTUS"), + .height = 4, + .weight = 513, + .descriptionPage1 = DexDescription_Tuska_1, + .descriptionPage2 = DexDescription_Tuska_2, + .pokemonScale = 455, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Noktuska + .categoryName = _("VOGELSCHOCK"), + .height = 13, + .weight = 774, + .descriptionPage1 = DexDescription_Noktuska_1, + .descriptionPage2 = DexDescription_Noktuska_2, + .pokemonScale = 327, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Wablu + .categoryName = _("WOLLVOGEL"), + .height = 4, + .weight = 12, + .descriptionPage1 = DexDescription_Wablu_1, + .descriptionPage2 = DexDescription_Wablu_2, + .pokemonScale = 422, + .pokemonOffset = 65528, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Altaria + .categoryName = _("SUMMSEL"), + .height = 11, + .weight = 206, + .descriptionPage1 = DexDescription_Altaria_1, + .descriptionPage2 = DexDescription_Altaria_2, + .pokemonScale = 327, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sengo + .categoryName = _("FRETTKATZ"), + .height = 13, + .weight = 403, + .descriptionPage1 = DexDescription_Sengo_1, + .descriptionPage2 = DexDescription_Sengo_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Vipitis + .categoryName = _("REISSZAHN"), + .height = 27, + .weight = 525, + .descriptionPage1 = DexDescription_Vipitis_1, + .descriptionPage2 = DexDescription_Vipitis_2, + .pokemonScale = 275, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Lunastein + .categoryName = _("METEORIT"), + .height = 10, + .weight = 1680, + .descriptionPage1 = DexDescription_Lunastein_1, + .descriptionPage2 = DexDescription_Lunastein_2, + .pokemonScale = 300, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Sonnfel + .categoryName = _("METEORIT"), + .height = 12, + .weight = 1540, + .descriptionPage1 = DexDescription_Sonnfel_1, + .descriptionPage2 = DexDescription_Sonnfel_2, + .pokemonScale = 328, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Schmerbe + .categoryName = _("BARTHAAR"), + .height = 4, + .weight = 19, + .descriptionPage1 = DexDescription_Schmerbe_1, + .descriptionPage2 = DexDescription_Schmerbe_2, + .pokemonScale = 581, + .pokemonOffset = 65533, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Welsar + .categoryName = _("BARTHAAR"), + .height = 9, + .weight = 236, + .descriptionPage1 = DexDescription_Welsar_1, + .descriptionPage2 = DexDescription_Welsar_2, + .pokemonScale = 317, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Krebscorps + .categoryName = _("GROBIAN"), + .height = 6, + .weight = 115, + .descriptionPage1 = DexDescription_Krebscorps_1, + .descriptionPage2 = DexDescription_Krebscorps_2, + .pokemonScale = 484, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Krebutack + .categoryName = _("SCHLINGEL"), + .height = 11, + .weight = 328, + .descriptionPage1 = DexDescription_Krebutack_1, + .descriptionPage2 = DexDescription_Krebutack_2, + .pokemonScale = 365, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Puppance + .categoryName = _("LEHMPUPPE"), + .height = 5, + .weight = 215, + .descriptionPage1 = DexDescription_Puppance_1, + .descriptionPage2 = DexDescription_Puppance_2, + .pokemonScale = 457, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Lepumentas + .categoryName = _("LEHMPUPPE"), + .height = 15, + .weight = 1080, + .descriptionPage1 = DexDescription_Lepumentas_1, + .descriptionPage2 = DexDescription_Lepumentas_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 280, + .trainerOffset = 1, + }, + { + // Liliep + .categoryName = _("SEEANEMONE"), + .height = 10, + .weight = 238, + .descriptionPage1 = DexDescription_Liliep_1, + .descriptionPage2 = DexDescription_Liliep_2, + .pokemonScale = 305, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Wielie + .categoryName = _("RANKFÜSSER"), + .height = 15, + .weight = 604, + .descriptionPage1 = DexDescription_Wielie_1, + .descriptionPage2 = DexDescription_Wielie_2, + .pokemonScale = 267, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Anorith + .categoryName = _("KREBSSENIOR"), + .height = 7, + .weight = 125, + .descriptionPage1 = DexDescription_Anorith_1, + .descriptionPage2 = DexDescription_Anorith_2, + .pokemonScale = 296, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Armaldo + .categoryName = _("SCHILD"), + .height = 15, + .weight = 682, + .descriptionPage1 = DexDescription_Armaldo_1, + .descriptionPage2 = DexDescription_Armaldo_2, + .pokemonScale = 312, + .pokemonOffset = 3, + .trainerScale = 271, + .trainerOffset = 0, + }, + { + // Barschwa + .categoryName = _("FISCH"), + .height = 6, + .weight = 74, + .descriptionPage1 = DexDescription_Barschwa_1, + .descriptionPage2 = DexDescription_Barschwa_2, + .pokemonScale = 423, + .pokemonOffset = 65532, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Milotic + .categoryName = _("ZARTHEIT"), + .height = 62, + .weight = 1620, + .descriptionPage1 = DexDescription_Milotic_1, + .descriptionPage2 = DexDescription_Milotic_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 360, + .trainerOffset = 7, + }, + { + // Formeo + .categoryName = _("WETTER"), + .height = 3, + .weight = 8, + .descriptionPage1 = DexDescription_Formeo_1, + .descriptionPage2 = DexDescription_Formeo_2, + .pokemonScale = 435, + .pokemonOffset = 65531, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kecleon + .categoryName = _("FARBENSPIEL"), + .height = 10, + .weight = 220, + .descriptionPage1 = DexDescription_Kecleon_1, + .descriptionPage2 = DexDescription_Kecleon_2, + .pokemonScale = 316, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Shuppet + .categoryName = _("PUPPE"), + .height = 6, + .weight = 23, + .descriptionPage1 = DexDescription_Shuppet_1, + .descriptionPage2 = DexDescription_Shuppet_2, + .pokemonScale = 440, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Banette + .categoryName = _("MARIONETTE"), + .height = 11, + .weight = 125, + .descriptionPage1 = DexDescription_Banette_1, + .descriptionPage2 = DexDescription_Banette_2, + .pokemonScale = 262, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Zwirrlicht + .categoryName = _("REQUIEM"), + .height = 8, + .weight = 150, + .descriptionPage1 = DexDescription_Zwirrlicht_1, + .descriptionPage2 = DexDescription_Zwirrlicht_2, + .pokemonScale = 406, + .pokemonOffset = 65532, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Zwirrklop + .categoryName = _("WINK"), + .height = 16, + .weight = 306, + .descriptionPage1 = DexDescription_Zwirrklop_1, + .descriptionPage2 = DexDescription_Zwirrklop_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 299, + .trainerOffset = 1, + }, + { + // Tropius + .categoryName = _("OBST"), + .height = 20, + .weight = 1000, + .descriptionPage1 = DexDescription_Tropius_1, + .descriptionPage2 = DexDescription_Tropius_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 344, + .trainerOffset = 7, + }, + { + // Palimpalim + .categoryName = _("WINDSPIEL"), + .height = 6, + .weight = 10, + .descriptionPage1 = DexDescription_Palimpalim_1, + .descriptionPage2 = DexDescription_Palimpalim_2, + .pokemonScale = 505, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Absol + .categoryName = _("DESASTER"), + .height = 12, + .weight = 470, + .descriptionPage1 = DexDescription_Absol_1, + .descriptionPage2 = DexDescription_Absol_2, + .pokemonScale = 301, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Isso + .categoryName = _("STRAHLEKIND"), + .height = 6, + .weight = 140, + .descriptionPage1 = DexDescription_Isso_1, + .descriptionPage2 = DexDescription_Isso_2, + .pokemonScale = 484, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Schneppke + .categoryName = _("SCHNEEHUT"), + .height = 7, + .weight = 168, + .descriptionPage1 = DexDescription_Schneppke_1, + .descriptionPage2 = DexDescription_Schneppke_2, + .pokemonScale = 380, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Firnontor + .categoryName = _("ANTLITZ"), + .height = 15, + .weight = 2565, + .descriptionPage1 = DexDescription_Firnontor_1, + .descriptionPage2 = DexDescription_Firnontor_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 344, + .trainerOffset = 0, + }, + { + // Seemops + .categoryName = _("APPLAUS"), + .height = 8, + .weight = 395, + .descriptionPage1 = DexDescription_Seemops_1, + .descriptionPage2 = DexDescription_Seemops_2, + .pokemonScale = 315, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Seejong + .categoryName = _("SPIELBALL"), + .height = 11, + .weight = 876, + .descriptionPage1 = DexDescription_Seejong_1, + .descriptionPage2 = DexDescription_Seejong_2, + .pokemonScale = 338, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Walraisa + .categoryName = _("EISBRECHER"), + .height = 14, + .weight = 1506, + .descriptionPage1 = DexDescription_Walraisa_1, + .descriptionPage2 = DexDescription_Walraisa_2, + .pokemonScale = 316, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Perlu + .categoryName = _("MUSCHEL"), + .height = 4, + .weight = 525, + .descriptionPage1 = DexDescription_Perlu_1, + .descriptionPage2 = DexDescription_Perlu_2, + .pokemonScale = 691, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Aalabyss + .categoryName = _("TIEFSEE"), + .height = 17, + .weight = 270, + .descriptionPage1 = DexDescription_Aalabyss_1, + .descriptionPage2 = DexDescription_Aalabyss_2, + .pokemonScale = 307, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Saganabyss + .categoryName = _("SÜDSEE"), + .height = 18, + .weight = 226, + .descriptionPage1 = DexDescription_Saganabyss_1, + .descriptionPage2 = DexDescription_Saganabyss_2, + .pokemonScale = 278, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Relicanth + .categoryName = _("BESTAND"), + .height = 10, + .weight = 234, + .descriptionPage1 = DexDescription_Relicanth_1, + .descriptionPage2 = DexDescription_Relicanth_2, + .pokemonScale = 316, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Liebiskus + .categoryName = _("RENDEZVOUS"), + .height = 6, + .weight = 87, + .descriptionPage1 = DexDescription_Liebiskus_1, + .descriptionPage2 = DexDescription_Liebiskus_2, + .pokemonScale = 371, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Kindwurm + .categoryName = _("STEINHAUPT"), + .height = 6, + .weight = 421, + .descriptionPage1 = DexDescription_Kindwurm_1, + .descriptionPage2 = DexDescription_Kindwurm_2, + .pokemonScale = 448, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Draschel + .categoryName = _("DURCHSTEHER"), + .height = 11, + .weight = 1105, + .descriptionPage1 = DexDescription_Draschel_1, + .descriptionPage2 = DexDescription_Draschel_2, + .pokemonScale = 311, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Brutalanda + .categoryName = _("DRACHE"), + .height = 15, + .weight = 1026, + .descriptionPage1 = DexDescription_Brutalanda_1, + .descriptionPage2 = DexDescription_Brutalanda_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Tanhel + .categoryName = _("EISENKUGEL"), + .height = 6, + .weight = 952, + .descriptionPage1 = DexDescription_Tanhel_1, + .descriptionPage2 = DexDescription_Tanhel_2, + .pokemonScale = 414, + .pokemonOffset = 65535, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Metang + .categoryName = _("EISENKLAUE"), + .height = 12, + .weight = 2025, + .descriptionPage1 = DexDescription_Metang_1, + .descriptionPage2 = DexDescription_Metang_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Metagross + .categoryName = _("EISENFUSS"), + .height = 16, + .weight = 5500, + .descriptionPage1 = DexDescription_Metagross_1, + .descriptionPage2 = DexDescription_Metagross_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 447, + .trainerOffset = 9, + }, + { + // Regirock + .categoryName = _("STEINGIPFEL"), + .height = 17, + .weight = 2300, + .descriptionPage1 = DexDescription_Regirock_1, + .descriptionPage2 = DexDescription_Regirock_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 309, + .trainerOffset = 1, + }, + { + // Regice + .categoryName = _("EISBERG"), + .height = 18, + .weight = 1750, + .descriptionPage1 = DexDescription_Regice_1, + .descriptionPage2 = DexDescription_Regice_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 301, + .trainerOffset = 2, + }, + { + // Registeel + .categoryName = _("EISEN"), + .height = 19, + .weight = 2050, + .descriptionPage1 = DexDescription_Registeel_1, + .descriptionPage2 = DexDescription_Registeel_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 359, + .trainerOffset = 6, + }, + { + // Latias + .categoryName = _("ÄON"), + .height = 14, + .weight = 400, + .descriptionPage1 = DexDescription_Latias_1, + .descriptionPage2 = DexDescription_Latias_2, + .pokemonScale = 304, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Latios + .categoryName = _("ÄON"), + .height = 20, + .weight = 600, + .descriptionPage1 = DexDescription_Latios_1, + .descriptionPage2 = DexDescription_Latios_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 294, + .trainerOffset = 3, + }, + { + // Kyogre + .categoryName = _("SEEGRÜNDLER"), + .height = 45, + .weight = 3520, + .descriptionPage1 = DexDescription_Kyogre_1, + .descriptionPage2 = DexDescription_Kyogre_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 614, + .trainerOffset = 13, + }, + { + // Groudon + .categoryName = _("KONTINENT"), + .height = 35, + .weight = 9500, + .descriptionPage1 = DexDescription_Groudon_1, + .descriptionPage2 = DexDescription_Groudon_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 515, + .trainerOffset = 14, + }, + { + // Rayquaza + .categoryName = _("HIMMELHOCH"), + .height = 70, + .weight = 2065, + .descriptionPage1 = DexDescription_Rayquaza_1, + .descriptionPage2 = DexDescription_Rayquaza_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 448, + .trainerOffset = 12, + }, + { + // Jirachi + .categoryName = _("WÜNSCHER"), + .height = 3, + .weight = 11, + .descriptionPage1 = DexDescription_Jirachi_1, + .descriptionPage2 = DexDescription_Jirachi_2, + .pokemonScale = 608, + .pokemonOffset = 65528, + .trainerScale = 256, + .trainerOffset = 0, + }, + { + // Deoxys + .categoryName = _("DNS"), + .height = 17, + .weight = 608, + .descriptionPage1 = DexDescription_Deoxys_1, + .descriptionPage2 = DexDescription_Deoxys_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 290, + .trainerOffset = 2, + }, +}; diff --git a/src/data/pokedex_entries_en.h b/src/data/pokedex_entries_en.h new file mode 100644 index 000000000..86da3d67b --- /dev/null +++ b/src/data/pokedex_entries_en.h @@ -0,0 +1,9651 @@ +static const u8 DexDescription_Dummy_1[] = _( + "This is a newly discovered POKéMON.\n" + "It is currently under investigation."); +static const u8 DexDescription_Dummy_2[] = _( + "No detailed information is available\n" + "at this time."); + +static const u8 DexDescription_Bulbasaur_1[] = _( + "BULBASAUR can be seen napping in\n" + "bright sunlight.\n" + "There is a seed on its back."); +static const u8 DexDescription_Bulbasaur_2[] = _( + "By soaking up the sun’s rays, the seed\n" + "grows progressively larger."); + +static const u8 DexDescription_Ivysaur_1[] = _( + "There is a bud on this POKéMON’s back.\n" + "To support its weight, IVYSAUR’s legs\n" + "and trunk grow thick and strong."); +static const u8 DexDescription_Ivysaur_2[] = _( + "If it starts spending more time lying\n" + "in the sunlight, it’s a sign that the\n" + "bud will bloom into a large flower soon."); + +static const u8 DexDescription_Venusaur_1[] = _( + "There is a large flower on VENUSAUR’s\n" + "back. The flower is said to take on vivid\n" + "colors if it gets plenty of nutrition"); +static const u8 DexDescription_Venusaur_2[] = _( + "and sunlight. The flower’s aroma\n" + "soothes the emotions of people."); + +static const u8 DexDescription_Charmander_1[] = _( + "The flame that burns at the tip of its\n" + "tail is an indication of its emotions.\n" + "The flame wavers when CHARMANDER is"); +static const u8 DexDescription_Charmander_2[] = _( + "enjoying itself. If the POKéMON becomes\n" + "enraged, the flame burns fiercely."); + +static const u8 DexDescription_Charmeleon_1[] = _( + "CHARMELEON mercilessly destroys its\n" + "foes using its sharp claws.\n" + "If it encounters a strong foe, it turns"); +static const u8 DexDescription_Charmeleon_2[] = _( + "aggressive. In this excited state, the\n" + "flame at the tip of its tail flares with a\n" + "bluish white color."); + +static const u8 DexDescription_Charizard_1[] = _( + "CHARIZARD flies around the sky in\n" + "search of powerful opponents.\n" + "It breathes fire of such great heat"); +static const u8 DexDescription_Charizard_2[] = _( + "that it melts anything. However, it\n" + "never turns its fiery breath on any\n" + "opponent weaker than itself."); + +static const u8 DexDescription_Squirtle_1[] = _( + "SQUIRTLE’s shell is not merely used\n" + "for protection.\n" + "The shell’s rounded shape and the"); +static const u8 DexDescription_Squirtle_2[] = _( + "grooves on its surface help minimize\n" + "resistance in water, enabling this\n" + "POKéMON to swim at high speeds."); + +static const u8 DexDescription_Wartortle_1[] = _( + "Its tail is large and covered with a rich,\n" + "thick fur. The tail becomes increasingly\n" + "deeper in color as WARTORTLE ages."); +static const u8 DexDescription_Wartortle_2[] = _( + "The scratches on its shell are evidence\n" + "of this POKéMON’s toughness as a\n" + "battler."); + +static const u8 DexDescription_Blastoise_1[] = _( + "BLASTOISE has water spouts that\n" + "protrude from its shell. The water\n" + "spouts are very accurate."); +static const u8 DexDescription_Blastoise_2[] = _( + "They can shoot bullets of water with\n" + "enough accuracy to strike empty cans\n" + "from a distance of over 160 feet."); + +static const u8 DexDescription_Caterpie_1[] = _( + "CATERPIE has a voracious appetite.\n" + "It can devour leaves bigger than its\n" + "body right before your eyes."); +static const u8 DexDescription_Caterpie_2[] = _( + "From its antenna, this POKéMON releases\n" + "a terrifically strong odor."); + +static const u8 DexDescription_Metapod_1[] = _( + "The shell covering this POKéMON’s body\n" + "is as hard as an iron slab.\n" + "METAPOD does not move very much."); +static const u8 DexDescription_Metapod_2[] = _( + "It stays still because it is preparing\n" + "its soft innards for evolution inside\n" + "the hard shell."); + +static const u8 DexDescription_Butterfree_1[] = _( + "BUTTERFREE has a superior ability to\n" + "search for delicious honey from\n" + "flowers."); +static const u8 DexDescription_Butterfree_2[] = _( + "It can even search out, extract, and\n" + "carry honey from flowers that are\n" + "blooming over six miles from its nest."); + +static const u8 DexDescription_Weedle_1[] = _( + "WEEDLE has an extremely acute sense\n" + "of smell.\n" + "It is capable of distinguishing its"); +static const u8 DexDescription_Weedle_2[] = _( + "favorite kinds of leaves from those it\n" + "dislikes just by sniffing with its big\n" + "red proboscis (nose)."); + +static const u8 DexDescription_Kakuna_1[] = _( + "KAKUNA remains virtually immobile as it\n" + "clings to a tree. However, on the\n" + "inside, it is extremely busy as it"); +static const u8 DexDescription_Kakuna_2[] = _( + "prepares for its coming evolution.\n" + "This is evident from how hot the shell\n" + "becomes to the touch."); + +static const u8 DexDescription_Beedrill_1[] = _( + "BEEDRILL is extremely territorial.\n" + "No one should ever approach its nest -\n" + "this is for their own safety."); +static const u8 DexDescription_Beedrill_2[] = _( + "If angered, they will attack in a furious\n" + "swarm."); + +static const u8 DexDescription_Pidgey_1[] = _( + "PIDGEY has an extremely sharp sense\n" + "of direction.\n" + "It is capable of unerringly returning"); +static const u8 DexDescription_Pidgey_2[] = _( + "home to its nest, however far it may be\n" + "removed from its familiar surroundings."); + +static const u8 DexDescription_Pidgeotto_1[] = _( + "PIDGEOTTO claims a large area as its\n" + "own territory. This POKéMON flies\n" + "around, patrolling its living space."); +static const u8 DexDescription_Pidgeotto_2[] = _( + "If its territory is violated, it shows\n" + "no mercy in thoroughly punishing the\n" + "foe with its sharp claws."); + +static const u8 DexDescription_Pidgeot_1[] = _( + "This POKéMON has a dazzling plumage of\n" + "beautifully glossy feathers.\n" + "Many TRAINERS are captivated by the"); +static const u8 DexDescription_Pidgeot_2[] = _( + "striking beauty of the feathers on its\n" + "head, compelling them to choose PIDGEOT\n" + "as their POKéMON."); + +static const u8 DexDescription_Rattata_1[] = _( + "RATTATA is cautious in the extreme.\n" + "Even while it is asleep, it constantly\n" + "listens by moving its ears around."); +static const u8 DexDescription_Rattata_2[] = _( + "It is not picky about where it lives -\n" + "it will make its nest anywhere."); + +static const u8 DexDescription_Raticate_1[] = _( + "RATICATE’s sturdy fangs grow steadily.\n" + "To keep them ground down, it gnaws\n" + "on rocks and logs."); +static const u8 DexDescription_Raticate_2[] = _( + "It may even chew on the walls of\n" + "houses."); + +static const u8 DexDescription_Spearow_1[] = _( + "SPEAROW has a very loud cry that can\n" + "be heard over half a mile away.\n" + "If its high, keening cry is heard"); +static const u8 DexDescription_Spearow_2[] = _( + "echoing all around, it is a sign that\n" + "they are warning each other of danger."); + +static const u8 DexDescription_Fearow_1[] = _( + "FEAROW is recognized by its long neck\n" + "and elongated beak.\n" + "They are conveniently shaped for"); +static const u8 DexDescription_Fearow_2[] = _( + "catching prey in soil or water.\n" + "It deftly moves its long and skinny\n" + "beak to pluck prey."); + +static const u8 DexDescription_Ekans_1[] = _( + "EKANS curls itself up in a spiral while\n" + "it rests.\n" + "Assuming this position allows it to"); +static const u8 DexDescription_Ekans_2[] = _( + "quickly respond to a threat from any\n" + "direction with a glare from its upraised\n" + "head."); + +static const u8 DexDescription_Arbok_1[] = _( + "This POKéMON is terrifically strong in\n" + "order to constrict things with its body.\n" + "It can even flatten steel oil drums."); +static const u8 DexDescription_Arbok_2[] = _( + "Once ARBOK wraps its body around its\n" + "foe, escaping its crunching embrace is\n" + "impossible."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Pikachu_1[] = _( + "This POKéMON has electricity-storing\n" + "pouches on its cheeks. These appear to\n" + "become electrically charged during the"); +static const u8 DexDescription_Pikachu_2[] = _( + "night while PIKACHU sleeps.\n" + "It occasionally discharges electricity\n" + "when it is dozy after waking up."); +#else +static const u8 DexDescription_Pikachu_1[] = _( + "Whenever PIKACHU comes across\n" + "something new, it blasts it with a jolt\n" + "of electricity."); +static const u8 DexDescription_Pikachu_2[] = _( + "If you come across a blackened berry,\n" + "it’s evidence that this POKéMON\n" + "mistook the intensity of its charge."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Raichu_1[] = _( + "This POKéMON exudes a weak electrical\n" + "charge from all over its body that makes\n" + "it take on a slight glow in darkness."); +static const u8 DexDescription_Raichu_2[] = _( + "RAICHU searches for electricity by\n" + "planting its tail in the ground."); +#else +static const u8 DexDescription_Raichu_1[] = _( + "If the electrical sacks become\n" + "excessively charged, RAICHU plants its\n" + "tail in the ground and discharges."); +static const u8 DexDescription_Raichu_2[] = _( + "Scorched patches of ground will be\n" + "found near this POKéMON’s nest."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Sandshrew_1[] = _( + "SANDSHREW has a very dry hide that is\n" + "extremely tough. The POKéMON can roll\n" + "into a ball that repels any attack."); +static const u8 DexDescription_Sandshrew_2[] = _( + "At night, it burrows into the desert\n" + "sand to sleep."); +#else +static const u8 DexDescription_Sandshrew_1[] = _( + "SANDSHREW’s body is configured to\n" + "absorb water without waste, enabling it\n" + "to survive in an arid desert."); +static const u8 DexDescription_Sandshrew_2[] = _( + "This POKéMON curls up to protect itself\n" + "from its enemies."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Sandslash_1[] = _( + "SANDSLASH can roll up its body as if it\n" + "were a ball covered with large spikes.\n" + "In battle, this POKéMON will try to make"); +static const u8 DexDescription_Sandslash_2[] = _( + "the foe flinch by jabbing it with its\n" + "spines. It then leaps at the stunned\n" + "foe to tear wildly with its sharp claws."); +#else +static const u8 DexDescription_Sandslash_1[] = _( + "SANDSLASH’s body is covered by tough\n" + "spikes, which are hardened sections of\n" + "its hide. Once a year, the old spikes fall"); +static const u8 DexDescription_Sandslash_2[] = _( + "out, to be replaced with new spikes that\n" + "grow out from beneath the old ones."); +#endif + +static const u8 DexDescription_NidoranF_1[] = _( + "NIDORAN has barbs that secrete a\n" + "powerful poison. They are thought to\n" + "have developed as protection for this"); +static const u8 DexDescription_NidoranF_2[] = _( + "small-bodied POKéMON.\n" + "When enraged, it releases a horrible\n" + "toxin from its horn."); + +static const u8 DexDescription_Nidorina_1[] = _( + "When NIDORINA are with their friends or\n" + "family, they keep their barbs tucked\n" + "away to prevent hurting each other."); +static const u8 DexDescription_Nidorina_2[] = _( + "This POKéMON appears to become\n" + "nervous if separated from the others."); + +static const u8 DexDescription_Nidoqueen_1[] = _( + "NIDOQUEEN’s body is encased in\n" + "extremely hard scales. It is adept at\n" + "sending foes flying with harsh tackles."); +static const u8 DexDescription_Nidoqueen_2[] = _( + "This POKéMON is at its strongest when\n" + "it is defending its young."); + +static const u8 DexDescription_NidoranM_1[] = _( + "The male NIDORAN has developed\n" + "muscles for moving its ears. Thanks to\n" + "them, the ears can be freely moved in"); +static const u8 DexDescription_NidoranM_2[] = _( + "any direction. Even the slightest sound\n" + "does not escape this POKéMON’s notice."); + +static const u8 DexDescription_Nidorino_1[] = _( + "NIDORINO has a horn that is harder than\n" + "a diamond. If it senses a hostile\n" + "presence, all the barbs on its back"); +static const u8 DexDescription_Nidorino_2[] = _( + "bristle up at once, and it challenges\n" + "the foe with all its might."); + +static const u8 DexDescription_Nidoking_1[] = _( + "NIDOKING’s thick tail packs enormously\n" + "destructive power. With one swing, it\n" + "can topple a metal transmission tower."); +static const u8 DexDescription_Nidoking_2[] = _( + "Once this POKéMON goes on a rampage,\n" + "there is no stopping it."); + +static const u8 DexDescription_Clefairy_1[] = _( + "On every night of a full moon, groups of\n" + "this POKéMON come out to play.\n" + "When dawn arrives, the tired CLEFAIRY"); +static const u8 DexDescription_Clefairy_2[] = _( + "return to their quiet mountain retreats\n" + "and go to sleep nestled up against each\n" + "other."); + +static const u8 DexDescription_Clefable_1[] = _( + "CLEFABLE moves by skipping lightly as if\n" + "it were flying using its wings. Its\n" + "bouncy step lets it even walk on water."); +static const u8 DexDescription_Clefable_2[] = _( + "It is known to take strolls on lakes on\n" + "quiet, moonlit nights."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Vulpix_1[] = _( + "Inside VULPIX’s body burns a flame that\n" + "never goes out. During the daytime,\n" + "when the temperatures rise, this"); +static const u8 DexDescription_Vulpix_2[] = _( + "POKéMON releases flames from its mouth\n" + "to prevent its body from growing too\n" + "hot."); +#else +static const u8 DexDescription_Vulpix_1[] = _( + "At the time of its birth, VULPIX has one\n" + "white tail. The tail separates into six\n" + "if this POKéMON receives plenty of love"); +static const u8 DexDescription_Vulpix_2[] = _( + "from its TRAINER.\n" + "The six tails become magnificently\n" + "curled."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Ninetales_1[] = _( + "Legend has it that NINETALES came into\n" + "being when nine wizards possessing\n" + "sacred powers merged into one."); +static const u8 DexDescription_Ninetales_2[] = _( + "This POKéMON is highly intelligent - it\n" + "can understand human speech."); +#else +static const u8 DexDescription_Ninetales_1[] = _( + "NINETALES casts a sinister light from\n" + "its bright red eyes to gain total\n" + "control over its foe’s mind."); +static const u8 DexDescription_Ninetales_2[] = _( + "This POKéMON is said to live for a\n" + "thousand years."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Jigglypuff_1[] = _( + "When this POKéMON sings, it never\n" + "pauses to breathe. If it is in a battle\n" + "against an opponent that does not"); +static const u8 DexDescription_Jigglypuff_2[] = _( + "easily fall asleep, JIGGLYPUFF cannot\n" + "breathe, endangering its life."); +#else +static const u8 DexDescription_Jigglypuff_1[] = _( + "JIGGLYPUFF’s vocal chords can freely\n" + "adjust the wavelength of its voice.\n" + "This POKéMON uses this ability to sing"); +static const u8 DexDescription_Jigglypuff_2[] = _( + "at precisely the right wavelength to\n" + "make its foes most drowsy."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Wigglytuff_1[] = _( + "WIGGLYTUFF’s body is very flexible.\n" + "By inhaling deeply, this POKéMON can\n" + "inflate itself seemingly without end."); +static const u8 DexDescription_Wigglytuff_2[] = _( + "Once inflated, WIGGLYTUFF bounces\n" + "along lightly like a balloon."); +#else +static const u8 DexDescription_Wigglytuff_1[] = _( + "WIGGLYTUFF has large, saucerlike eyes.\n" + "The surfaces of its eyes are always\n" + "covered with a thin layer of tears."); +static const u8 DexDescription_Wigglytuff_2[] = _( + "If any dust gets in this POKéMON’s\n" + "eyes, it is quickly washed away."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Zubat_1[] = _( + "ZUBAT avoids sunlight because exposure\n" + "causes it to become unhealthy.\n" + "During the daytime, it stays in caves or"); +static const u8 DexDescription_Zubat_2[] = _( + "under the eaves of old houses, sleeping\n" + "while hanging upside down."); +#else +static const u8 DexDescription_Zubat_1[] = _( + "ZUBAT remains quietly unmoving in a\n" + "dark spot during the bright daylight\n" + "hours. It does so because prolonged"); +static const u8 DexDescription_Zubat_2[] = _( + "exposure to the sun causes its body to\n" + "become slightly burned."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Golbat_1[] = _( + "GOLBAT bites down on prey with its four\n" + "fangs and drinks the victim’s blood.\n" + "It becomes active on inky dark"); +static const u8 DexDescription_Golbat_2[] = _( + "moonless nights, flying around to\n" + "attack people and POKéMON."); +#else +static const u8 DexDescription_Golbat_1[] = _( + "GOLBAT loves to drink the blood of\n" + "living things. It is particularly active\n" + "in the pitch black of night."); +static const u8 DexDescription_Golbat_2[] = _( + "This POKéMON flits around in the night\n" + "skies, seeking fresh blood."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Oddish_1[] = _( + "ODDISH searches for fertile, nutrient-\n" + "rich soil, then plants itself.\n" + "During the daytime, while it is planted,"); +static const u8 DexDescription_Oddish_2[] = _( + "this POKéMON’s feet are thought to\n" + "change shape and become similar to\n" + "the roots of trees."); +#else +static const u8 DexDescription_Oddish_1[] = _( + "During the daytime, ODDISH buries\n" + "itself in soil to absorb nutrients from \n" + "the ground using its entire body."); +static const u8 DexDescription_Oddish_2[] = _( + "The more fertile the soil, the glossier\n" + "its leaves become."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Gloom_1[] = _( + "From its mouth GLOOM drips honey that\n" + "smells absolutely horrible.\n" + "Apparently, it loves the horrid stench."); +static const u8 DexDescription_Gloom_2[] = _( + "It sniffs the noxious fumes and then \n" + "drools even more of its honey."); +#else +static const u8 DexDescription_Gloom_1[] = _( + "GLOOM releases a foul fragrance from\n" + "the pistil of its flower. When faced\n" + "with danger, the stench worsens."); +static const u8 DexDescription_Gloom_2[] = _( + "If this POKéMON is feeling calm and\n" + "secure, it does not release its usual\n" + "stinky aroma."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Vileplume_1[] = _( + "VILEPLUME has the world’s largest\n" + "petals. They are used to attract prey\n" + "that are then doused with toxic spores."); +static const u8 DexDescription_Vileplume_2[] = _( + "Once the prey are immobilized, this\n" + "POKéMON catches and devours them."); +#else +static const u8 DexDescription_Vileplume_1[] = _( + "VILEPLUME’s toxic pollen triggers\n" + "atrocious allergy attacks. That’s why\n" + "it is advisable never to approach any"); +static const u8 DexDescription_Vileplume_2[] = _( + "attractive flowers in a jungle, however\n" + "pretty they may be."); +#endif + +#ifdef SAPPHIRE +#if REVISION >= 1 +static const u8 DexDescription_Paras_1[] = _( + "PARAS has parasitic mushrooms growing\n" + "on its back called tochukaso. They grow\n" + "large by drawing nutrients from this"); +static const u8 DexDescription_Paras_2[] = _( + "BUG/GRASS POKéMON host. They are\n" // Identify Paras as BUG/GRASS type rather than just BUG + "highly valued as a medicine for\n" + "extending life."); +#else +static const u8 DexDescription_Paras_1[] = _( + "PARAS has parasitic mushrooms growing\n" + "on its back called tochukaso. They grow\n" + "large by drawing nutrients from this"); +static const u8 DexDescription_Paras_2[] = _( + "BUG POKéMON host. They are highly\n" + "valued as a medicine for extending life."); +#endif +#else +#if REVISION >= 1 +static const u8 DexDescription_Paras_1[] = _( + "PARAS has parasitic mushrooms growing\n" + "on its back called tochukaso. They grow\n" + "large by drawing nutrients from this"); +static const u8 DexDescription_Paras_2[] = _( + "BUG/GRASS POKéMON host. They are\n" + "highly valued as a medicine for\n" + "extending life."); +#else +static const u8 DexDescription_Paras_1[] = _( + "PARAS has parasitic mushrooms growing\n" + "on its back called tochukaso. They grow\n" + "large by drawing nutrients from the BUG"); +static const u8 DexDescription_Paras_2[] = _( + "POKéMON host. They are highly valued as\n" + "a medicine for extending life."); +#endif +#endif + +static const u8 DexDescription_Parasect_1[] = _( + "PARASECT is known to infest large trees\n" + "en masse and drain nutrients from the\n" + "lower trunk and roots."); +static const u8 DexDescription_Parasect_2[] = _( + "When an infested tree dies, they move\n" + "onto another tree all at once."); + +static const u8 DexDescription_Venonat_1[] = _( + "VENONAT is said to have evolved with\n" + "a coat of thin, stiff hair that covers\n" + "its entire body for protection."); +static const u8 DexDescription_Venonat_2[] = _( + "It possesses large eyes that never fail\n" + "to spot even miniscule prey."); + +static const u8 DexDescription_Venomoth_1[] = _( + "VENOMOTH is nocturnal - it is a POKéMON\n" + "that only becomes active at night.\n" + "Its favorite prey are small insects"); +static const u8 DexDescription_Venomoth_2[] = _( + "that gather around streetlights,\n" + "attracted by the light in the darkness."); + +static const u8 DexDescription_Diglett_1[] = _( + "DIGLETT are raised in most farms.\n" + "The reason is simple - wherever this\n" + "POKéMON burrows, the soil is left"); +static const u8 DexDescription_Diglett_2[] = _( + "perfectly tilled for planting crops.\n" + "This soil is made ideal for growing\n" + "delicious vegetables."); + +static const u8 DexDescription_Dugtrio_1[] = _( + "DUGTRIO are actually triplets that\n" + "emerged from one body. As a result,\n" + "each triplet thinks exactly like the"); +static const u8 DexDescription_Dugtrio_2[] = _( + "other two triplets.\n" + "They work cooperatively to burrow\n" + "endlessly."); + +static const u8 DexDescription_Meowth_1[] = _( + "MEOWTH withdraws its sharp claws into\n" + "its paws to slinkily sneak about without\n" + "making any incriminating footsteps."); +static const u8 DexDescription_Meowth_2[] = _( + "For some reason, this POKéMON loves\n" + "shiny coins that glitter with light."); + +static const u8 DexDescription_Persian_1[] = _( + "PERSIAN has six bold whiskers that give\n" + "it a look of toughness. The whiskers \n" + "sense air movements to determine what"); +static const u8 DexDescription_Persian_2[] = _( + "is in the POKéMON’s surrounding\n" + "vicinity. It becomes docile if grabbed\n" + "by the whiskers."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Psyduck_1[] = _( + "If it uses its mysterious power,\n" + "PSYDUCK can’t remember having done so.\n" + "It apparently can’t form a memory of"); +static const u8 DexDescription_Psyduck_2[] = _( + "such an event because it goes into\n" + "an altered state that is much like\n" + "deep sleep."); +#else +static const u8 DexDescription_Psyduck_1[] = _( + "PSYDUCK uses a mysterious power.\n" + "When it does so, this POKéMON \n" + "generates brain waves that are"); +static const u8 DexDescription_Psyduck_2[] = _( + "supposedly only seen in sleepers.\n" + "This discovery spurred controversy\n" + "among scholars."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Golduck_1[] = _( + "GOLDUCK is the fastest swimmer among\n" + "all POKéMON. It swims effortlessly, even\n" + "in a rough, stormy sea."); +static const u8 DexDescription_Golduck_2[] = _( + "It sometimes rescues people from\n" + "wrecked ships floundering in high seas."); +#else +static const u8 DexDescription_Golduck_1[] = _( + "The webbed flippers on its forelegs and\n" + "hind legs and the streamlined body of\n" + "GOLDUCK give it frightening speed."); +static const u8 DexDescription_Golduck_2[] = _( + "This POKéMON is definitely much faster\n" + "than even the most athletic swimmer."); +#endif + +static const u8 DexDescription_Mankey_1[] = _( + "When MANKEY starts shaking and its\n" + "nasal breathing turns rough, it’s a sure\n" + "sign that it is becoming angry."); +static const u8 DexDescription_Mankey_2[] = _( + "However, because it goes into a\n" + "towering rage almost instantly, it is\n" + "impossible for anyone to flee its wrath."); + +static const u8 DexDescription_Primeape_1[] = _( + "When PRIMEAPE becomes furious, its\n" + "blood circulation is boosted. In turn,\n" + "its muscles are made even stronger."); +static const u8 DexDescription_Primeape_2[] = _( + "However, it also becomes much less\n" + "intelligent at the same time."); + +static const u8 DexDescription_Growlithe_1[] = _( + "GROWLITHE has a superb sense of smell.\n" + "Once it smells anything, this POKéMON\n" + "won’t forget the scent, no matter what."); +static const u8 DexDescription_Growlithe_2[] = _( + "It uses its advanced olfactory sense\n" + "to determine the emotions of other\n" + "living things."); + +static const u8 DexDescription_Arcanine_1[] = _( + "ARCANINE is known for its high speed.\n" + "It is said to be capable of running over\n" + "6,200 miles in a single day and night."); +static const u8 DexDescription_Arcanine_2[] = _( + "The fire that blazes wildly within this\n" + "POKéMON’s body is its source of power."); + +static const u8 DexDescription_Poliwag_1[] = _( + "POLIWAG has a very thin skin. It is\n" + "possible to see the POKéMON’s spiral\n" + "innards right through the skin."); +static const u8 DexDescription_Poliwag_2[] = _( + "Despite its thinness, however, the skin\n" + "is also very flexible. Even sharp fangs\n" + "bounce right off it."); + +static const u8 DexDescription_Poliwhirl_1[] = _( + "The surface of POLIWHIRL’s body is\n" + "always wet and slick with an oily fluid.\n" + "Because of this greasy covering, it can"); +static const u8 DexDescription_Poliwhirl_2[] = _( + "easily slip and slide out of the clutches\n" + "of any enemy in battle."); + +static const u8 DexDescription_Poliwrath_1[] = _( + "POLIWRATH’s highly developed, brawny\n" + "muscles never grow fatigued, however\n" + "much it exercises."); +static const u8 DexDescription_Poliwrath_2[] = _( + "It is so tirelessly strong, this POKéMON\n" + "can swim back and forth across the\n" + "Pacific Ocean without effort."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Abra_1[] = _( + "ABRA needs to sleep for eighteen hours\n" + "a day. If it doesn’t, this POKéMON loses\n" + "its ability to use telekinetic powers."); +static const u8 DexDescription_Abra_2[] = _( + "If it is attacked, ABRA escapes using\n" + "TELEPORT while it is still sleeping."); +#else +static const u8 DexDescription_Abra_1[] = _( + "ABRA sleeps for eighteen hours a day.\n" + "However, it can sense the presence of\n" + "foes even while it is sleeping."); +static const u8 DexDescription_Abra_2[] = _( + "In such a situation, this POKéMON\n" + "immediately teleports to safety."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Kadabra_1[] = _( + "KADABRA holds a silver spoon in its\n" + "hand. The spoon is used to amplify the\n" + "alpha waves in its brain."); +static const u8 DexDescription_Kadabra_2[] = _( + "Without the spoon, the POKéMON is said\n" + "to be limited to half the usual amount\n" + "of its telekinetic powers."); +#else +static const u8 DexDescription_Kadabra_1[] = _( + "KADABRA emits a peculiar alpha wave\n" + "if it develops a headache. Only those\n" + "people with a particularly strong"); +static const u8 DexDescription_Kadabra_2[] = _( + "psyche can hope to become a TRAINER\n" + "of this POKéMON."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Alakazam_1[] = _( + "ALAKAZAM’s brain continually grows,\n" + "infinitely multiplying brain cells.\n" + "This amazing brain gives this POKéMON"); +static const u8 DexDescription_Alakazam_2[] = _( + "an astoundingly high IQ of 5,000.\n" + "It has a thorough memory of everything\n" + "that has occurred in the world."); +#else +static const u8 DexDescription_Alakazam_1[] = _( + "ALAKAZAM’s brain continually grows,\n" + "making its head far too heavy to\n" + "support with its neck."); +static const u8 DexDescription_Alakazam_2[] = _( + "This POKéMON holds its head up using\n" + "its psychokinetic power instead."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Machop_1[] = _( + "MACHOP exercises by hefting around\n" + "a GRAVELER as if it were a barbell.\n" + "There are some MACHOP that travel"); +static const u8 DexDescription_Machop_2[] = _( + "the world in a quest to master all\n" + "kinds of martial arts."); +#else +static const u8 DexDescription_Machop_1[] = _( + "MACHOP’s muscles are special - they\n" + "never get sore no matter how much they\n" + "are used in exercise."); +static const u8 DexDescription_Machop_2[] = _( + "This POKéMON has sufficient power to\n" + "hurl a hundred adult humans."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Machoke_1[] = _( + "MACHOKE undertakes bodybuilding every\n" + "day even as it helps people with tough,\n" + "physically demanding labor."); +static const u8 DexDescription_Machoke_2[] = _( + "On its days off, this POKéMON heads to\n" + "the fields and mountains to exercise\n" + "and train."); +#else +static const u8 DexDescription_Machoke_1[] = _( + "MACHOKE’s thoroughly toned muscles\n" + "possess the hardness of steel.\n" + "This POKéMON has so much strength,"); +static const u8 DexDescription_Machoke_2[] = _( + "it can easily hold aloft a sumo wrestler\n" + "on just one finger."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Machamp_1[] = _( + "MACHAMP is known as the POKéMON that\n" + "has mastered every kind of martial arts.\n" + "If it grabs hold of the foe with its four"); +static const u8 DexDescription_Machamp_2[] = _( + "arms, the battle is all but over.\n" + "The hapless foe is thrown far over the\n" + "horizon."); +#else +static const u8 DexDescription_Machamp_1[] = _( + "MACHAMP has the power to hurl anything\n" + "aside. However, trying to do any work\n" + "requiring care and dexterity causes"); +static const u8 DexDescription_Machamp_2[] = _( + "its arms to get tangled.\n" + "This POKéMON tends to leap into action\n" + "before it thinks."); +#endif + +static const u8 DexDescription_Bellsprout_1[] = _( + "BELLSPROUT’s thin and flexible body\n" + "lets it bend and sway to avoid any\n" + "attack, however strong it may be."); +static const u8 DexDescription_Bellsprout_2[] = _( + "From its mouth, this POKéMON spits a\n" + "corrosive fluid that melts even iron."); + +static const u8 DexDescription_Weepinbell_1[] = _( + "WEEPINBELL has a large hook on its rear\n" + "end. At night, the POKéMON hooks on to\n" + "a tree branch and goes to sleep."); +static const u8 DexDescription_Weepinbell_2[] = _( + "If it moves around in its sleep, it may\n" + "wake up to find itself on the ground."); + +static const u8 DexDescription_Victreebel_1[] = _( + "VICTREEBEL has a long vine that\n" + "extends from its head. This vine is\n" + "waved and flicked about as if it were"); +static const u8 DexDescription_Victreebel_2[] = _( + "an animal to attract prey. When an\n" + "unsuspecting prey draws near, this\n" + "POKéMON swallows it whole."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Tentacool_1[] = _( + "TENTACOOL absorbs sunlight and\n" + "refracts it using water inside its body\n" + "to convert it into beam energy."); +static const u8 DexDescription_Tentacool_2[] = _( + "This POKéMON shoots beams from its\n" + "crystal-like eyes."); +#else +static const u8 DexDescription_Tentacool_1[] = _( + "TENTACOOL’s body is largely composed\n" + "of water. If it is removed from the\n" + "sea, it dries up like parchment."); +static const u8 DexDescription_Tentacool_2[] = _( + "If this POKéMON happens to become\n" + "dehydrated, put it back into the sea."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Tentacruel_1[] = _( + "TENTACRUEL has tentacles that can be\n" + "freely elongated and shortened at will.\n" + "It ensnares prey with its tentacles and"); +static const u8 DexDescription_Tentacruel_2[] = _( + "weakens the prey by dosing it with a\n" + "harsh toxin. It can catch up to 80\n" + "prey at the same time."); +#else +static const u8 DexDescription_Tentacruel_1[] = _( + "TENTACRUEL has large red orbs on its\n" + "head. The orbs glow before lashing the\n" + "vicinity with a harsh ultrasonic blast."); +static const u8 DexDescription_Tentacruel_2[] = _( + "This POKéMON’s outburst creates rough\n" + "waves around it."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Geodude_1[] = _( + "When GEODUDE sleeps deeply, it buries\n" + "itself halfway into the ground.\n" + "It will not awaken even if hikers step"); +static const u8 DexDescription_Geodude_2[] = _( + "on it unwittingly.\n" + "In the morning, this POKéMON rolls\n" + "downhill in search of food."); +#else +static const u8 DexDescription_Geodude_1[] = _( + "The longer a GEODUDE lives, the more\n" + "its edges are chipped and worn away,\n" + "making it more rounded in appearance."); +static const u8 DexDescription_Geodude_2[] = _( + "However, this POKéMON’s heart will\n" + "remain hard, craggy, and rough always."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Graveler_1[] = _( + "Rocks are GRAVELER’s favorite food.\n" + "This POKéMON will climb a mountain from\n" + "the base to the summit, crunchingly"); +static const u8 DexDescription_Graveler_2[] = _( + "feasting on rocks all the while.\n" + "Upon reaching the peak, it rolls back\n" + "down to the bottom."); +#else +static const u8 DexDescription_Graveler_1[] = _( + "GRAVELER grows by feeding on rocks.\n" + "Apparently, it prefers to eat rocks\n" + "that are covered in moss."); +static const u8 DexDescription_Graveler_2[] = _( + "This POKéMON eats its way through\n" + "a ton of rocks on a daily basis."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Golem_1[] = _( + "GOLEM is known for rolling down from\n" + "mountains. To prevent them from rolling\n" + "into the homes of people downhill,"); +static const u8 DexDescription_Golem_2[] = _( + "grooves have been dug into the sides of\n" + "mountains to serve as guideways for\n" + "diverting this POKéMON’s course."); +#else +static const u8 DexDescription_Golem_1[] = _( + "GOLEM live up on mountains.\n" + "If there is a large earthquake, these\n" + "POKéMON will come rolling down off"); +static const u8 DexDescription_Golem_2[] = _( + "the mountains en masse to the\n" + "foothills below."); +#endif + +static const u8 DexDescription_Ponyta_1[] = _( + "PONYTA is very weak at birth.\n" + "It can barely stand up.\n" + "This POKéMON becomes stronger by"); +static const u8 DexDescription_Ponyta_2[] = _( + "stumbling and falling to keep up with\n" + "its parent."); + +static const u8 DexDescription_Rapidash_1[] = _( + "RAPIDASH usually can be seen casually\n" + "cantering in the fields and plains.\n" + "However, when this POKéMON turns"); +static const u8 DexDescription_Rapidash_2[] = _( + "serious, its fiery manes flare and blaze\n" + "as it gallops its way up to 150 mph."); + +static const u8 DexDescription_Slowpoke_1[] = _( + "SLOWPOKE uses its tail to catch prey by\n" + "dipping it in water at the side of a\n" + "river."); +static const u8 DexDescription_Slowpoke_2[] = _( + "However, this POKéMON often forgets\n" + "what it’s doing and often spends entire\n" + "days just loafing at water’s edge."); + +static const u8 DexDescription_Slowbro_1[] = _( + "SLOWBRO’s tail has a SHELLDER firmly\n" + "attached with a bite. As a result, the\n" + "tail can’t be used for fishing anymore."); +static const u8 DexDescription_Slowbro_2[] = _( + "This causes SLOWBRO to grudgingly swim\n" + "and catch prey instead."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Magnemite_1[] = _( + "MAGNEMITE floats in the air by emitting\n" + "electromagnetic waves from the units\n" + "at its sides. These waves block gravity."); +static const u8 DexDescription_Magnemite_2[] = _( + "This POKéMON becomes incapable of\n" + "flight if its internal electrical supply\n" + "is depleted."); +#else +static const u8 DexDescription_Magnemite_1[] = _( + "MAGNEMITE attaches itself to power\n" + "lines to feed on electricity.\n" + "If your house has a power outage,"); +static const u8 DexDescription_Magnemite_2[] = _( + "check your circuit breakers. You may\n" + "find a large number of this POKéMON\n" + "clinging to the breaker box."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Magneton_1[] = _( + "MAGNETON emits a powerful magnetic\n" + "force that is fatal to electronics and\n" + "precision instruments. Because of"); +static const u8 DexDescription_Magneton_2[] = _( + "this, it is said that some towns warn\n" + "people to keep this POKéMON inside\n" + "a POKé BALL."); +#else +static const u8 DexDescription_Magneton_1[] = _( + "MAGNETON emits a powerful magnetic\n" + "force that is fatal to mechanical\n" + "devices. As a result, large cities sound"); +static const u8 DexDescription_Magneton_2[] = _( + "sirens to warn citizens of large-scale\n" + "outbreaks of this POKéMON."); +#endif + +static const u8 DexDescription_Farfetchd_1[] = _( + "FARFETCH’D is always seen with a stick\n" + "from a plant of some sort. Apparently,\n" + "there are good sticks and bad sticks."); +static const u8 DexDescription_Farfetchd_2[] = _( + "This POKéMON has been known to fight\n" + "with others over sticks."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Doduo_1[] = _( + "DODUO’s two heads contain completely\n" + "identical brains.\n" + "A scientific study reported that on"); +static const u8 DexDescription_Doduo_2[] = _( + "rare occasions, there will be examples\n" + "of this POKéMON possessing different\n" + "sets of brains."); +#else +static const u8 DexDescription_Doduo_1[] = _( + "DODUO’s two heads never sleep at the\n" + "same time.\n" + "Its two heads take turns sleeping,"); +static const u8 DexDescription_Doduo_2[] = _( + "so one head can always keep watch for\n" + "enemies while the other one sleeps."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Dodrio_1[] = _( + "Apparently, the heads aren’t the only\n" + "parts of the body that DODRIO has\n" + "three of."); +static const u8 DexDescription_Dodrio_2[] = _( + "It has three sets of hearts and lungs\n" + "as well, so it is capable of running long\n" + "distances without rest."); +#else +static const u8 DexDescription_Dodrio_1[] = _( + "Watch out if DODRIO’s three heads are\n" + "looking in three separate directions.\n" + "It’s a sure sign that it is on its guard."); +static const u8 DexDescription_Dodrio_2[] = _( + "Don’t go near this POKéMON if it’s being\n" + "wary - it may decide to peck you."); +#endif + +static const u8 DexDescription_Seel_1[] = _( + "SEEL hunts for prey in the frigid sea\n" + "underneath sheets of ice.\n" + "When it needs to breathe, it punches"); +static const u8 DexDescription_Seel_2[] = _( + "a hole through the ice with the\n" + "sharply protruding section of its head."); + +static const u8 DexDescription_Dewgong_1[] = _( + "DEWGONG loves to snooze on bitterly\n" + "cold ice.\n" + "The sight of this POKéMON sleeping on"); +static const u8 DexDescription_Dewgong_2[] = _( + "a glacier was mistakenly thought to be\n" + "a mermaid by a mariner long ago."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Grimer_1[] = _( + "GRIMER emerged from the sludge that\n" + "settled on a polluted seabed.\n" + "This POKéMON loves anything filthy."); +static const u8 DexDescription_Grimer_2[] = _( + "It constantly leaks a horribly germ-\n" + "infested fluid from all over its body."); +#else +static const u8 DexDescription_Grimer_1[] = _( + "GRIMER’s sludgy and rubbery body can\n" + "be forced through any opening, however\n" + "small it may be."); +static const u8 DexDescription_Grimer_2[] = _( + "This POKéMON enters sewer pipes to\n" + "drink filthy wastewater."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Muk_1[] = _( + "This POKéMON’s favorite food is\n" + "anything that is repugnantly filthy.\n" + "In dirty towns where people think"); +static const u8 DexDescription_Muk_2[] = _( + "nothing of throwing away litter on the\n" + "streets, MUK are certain to gather."); +#else +static const u8 DexDescription_Muk_1[] = _( + "From MUK’s body seeps a foul fluid that\n" + "gives off a nose-bendingly horrible\n" + "stench."); +static const u8 DexDescription_Muk_2[] = _( + "Just one drop of this POKéMON’s body\n" + "fluid can turn a pool stagnant and\n" + "rancid."); +#endif + +static const u8 DexDescription_Shellder_1[] = _( + "At night, this POKéMON uses its broad\n" + "tongue to burrow a hole in the seafloor\n" + "sand and then sleep in it."); +static const u8 DexDescription_Shellder_2[] = _( + "While it is sleeping, SHELLDER closes its\n" + "shell, but leaves its tongue hanging\n" + "out."); + +static const u8 DexDescription_Cloyster_1[] = _( + "CLOYSTER is capable of swimming in the\n" + "sea. It does so by swallowing water,\n" + "then jetting it out toward the rear."); +static const u8 DexDescription_Cloyster_2[] = _( + "This POKéMON shoots spikes from its\n" + "shell using the same system."); + +static const u8 DexDescription_Gastly_1[] = _( + "GASTLY is largely composed of gaseous\n" + "matter. When exposed to a strong wind,\n" + "the gaseous body quickly dwindles away."); +static const u8 DexDescription_Gastly_2[] = _( + "Groups of this POKéMON cluster under\n" + "the eaves of houses to escape the\n" + "ravages of wind."); + +static const u8 DexDescription_Haunter_1[] = _( + "HAUNTER is a dangerous POKéMON.\n" + "If one beckons you while floating in\n" + "darkness, you must never approach it."); +static const u8 DexDescription_Haunter_2[] = _( + "This POKéMON will try to lick you with its\n" + "tongue and steal your life away."); + +static const u8 DexDescription_Gengar_1[] = _( + "Sometimes, on a dark night, your shadow\n" + "thrown by a streetlight will suddenly\n" + "and startlingly overtake you."); +static const u8 DexDescription_Gengar_2[] = _( + "It is actually a GENGAR running past\n" + "you, pretending to be your shadow."); + +static const u8 DexDescription_Onix_1[] = _( + "ONIX has a magnet in its brain. It acts\n" + "as a compass so that this POKéMON does\n" + "not lose direction while it is tunneling."); +static const u8 DexDescription_Onix_2[] = _( + "As it grows older, its body becomes\n" + "increasingly rounder and smoother."); + +static const u8 DexDescription_Drowzee_1[] = _( + "If your nose becomes itchy while you\n" + "are sleeping, it’s a sure sign that one\n" + "of these POKéMON is standing above"); +static const u8 DexDescription_Drowzee_2[] = _( + "your pillow and trying to eat your dream\n" + "through your nostrils."); + +static const u8 DexDescription_Hypno_1[] = _( + "HYPNO holds a pendulum in its hand.\n" + "The arcing movement and glitter of the\n" + "pendulum lull the foe into a deep state"); +static const u8 DexDescription_Hypno_2[] = _( + "of hypnosis.\n" + "While this POKéMON searches for prey,\n" + "it polishes the pendulum."); + +static const u8 DexDescription_Krabby_1[] = _( + "KRABBY live on beaches, burrowed inside\n" + "holes dug into the sand.\n" + "On sandy beaches with little in the way"); +static const u8 DexDescription_Krabby_2[] = _( + "of food, these POKéMON can be seen\n" + "squabbling with each other over\n" + "territory."); + +static const u8 DexDescription_Kingler_1[] = _( + "KINGLER has an enormous, oversized\n" + "claw. It waves this huge claw in the\n" + "air to communicate with others."); +static const u8 DexDescription_Kingler_2[] = _( + "However, because the claw is so heavy,\n" + "the POKéMON quickly tires."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Voltorb_1[] = _( + "VOLTORB is extremely sensitive - it\n" + "explodes at the slightest of shocks.\n" + "It is rumored that it was first created"); +static const u8 DexDescription_Voltorb_2[] = _( + "when a POKé BALL was exposed to a\n" + "powerful pulse of energy."); +#else +static const u8 DexDescription_Voltorb_1[] = _( + "VOLTORB was first sighted at a company\n" + "that manufactures POKé BALLS.\n" + "The link between that sighting and"); +static const u8 DexDescription_Voltorb_2[] = _( + "the fact that this POKéMON looks very\n" + "similar to a POKé BALL remains a\n" + "mystery."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Electrode_1[] = _( + "One of ELECTRODE’s characteristics is\n" + "its attraction to electricity.\n" + "It is a problematical POKéMON that"); +static const u8 DexDescription_Electrode_2[] = _( + "congregates mostly at electrical\n" + "power plants to feed on electricity\n" + "that has just been generated."); +#else +static const u8 DexDescription_Electrode_1[] = _( + "ELECTRODE eats electricity in the\n" + "atmosphere. On days when lightning\n" + "strikes, you can see this POKéMON"); +static const u8 DexDescription_Electrode_2[] = _( + "exploding all over the place from\n" + "eating too much electricity."); +#endif + +static const u8 DexDescription_Exeggcute_1[] = _( + "This POKéMON consists of six eggs that\n" + "form a closely knit cluster. The six eggs\n" + "attract each other and spin around."); +static const u8 DexDescription_Exeggcute_2[] = _( + "When cracks increasingly appear on the\n" + "eggs, EXEGGCUTE is close to evolution."); + +static const u8 DexDescription_Exeggutor_1[] = _( + "EXEGGUTOR originally came from the\n" + "tropics. Its heads steadily grow larger\n" + "from exposure to strong sunlight."); +static const u8 DexDescription_Exeggutor_2[] = _( + "It is said that when the heads fall off,\n" + "they group together to form EXEGGCUTE."); + +static const u8 DexDescription_Cubone_1[] = _( + "CUBONE pines for the mother it will\n" + "never see again. Seeing a likeness of\n" + "its mother in the full moon, it cries."); +static const u8 DexDescription_Cubone_2[] = _( + "The stains on the skull the POKéMON\n" + "wears are made by the tears it sheds."); + +static const u8 DexDescription_Marowak_1[] = _( + "MAROWAK is the evolved form of a CUBONE\n" + "that has overcome its sadness at the\n" + "loss of its mother and grown tough."); +static const u8 DexDescription_Marowak_2[] = _( + "This POKéMON’s tempered and hardened\n" + "spirit is not easily broken."); + +static const u8 DexDescription_Hitmonlee_1[] = _( + "HITMONLEE’s legs freely contract and\n" + "stretch. Using these springlike legs, it\n" + "bowls over foes with devastating kicks."); +static const u8 DexDescription_Hitmonlee_2[] = _( + "After battle, it rubs down its legs and\n" + "loosens the muscles to overcome\n" + "fatigue."); + +static const u8 DexDescription_Hitmonchan_1[] = _( + "HITMONCHAN is said to possess the\n" + "spirit of a boxer who had been working\n" + "towards a world championship."); +static const u8 DexDescription_Hitmonchan_2[] = _( + "This POKéMON has an indomitable spirit\n" + "and will never give up in the face of\n" + "adversity."); + +static const u8 DexDescription_Lickitung_1[] = _( + "Whenever LICKITUNG comes across\n" + "something new, it will unfailingly give it\n" + "a lick. It does so because it memorizes"); +static const u8 DexDescription_Lickitung_2[] = _( + "things by texture and by taste.\n" + "It is somewhat put off by sour things."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Koffing_1[] = _( + "KOFFING embodies toxic substances.\n" + "It mixes the toxins with raw garbage to\n" + "set off a chemical reaction that"); +static const u8 DexDescription_Koffing_2[] = _( + "results in a terribly powerful poison\n" + "gas. The higher the temperature, the\n" + "more gas is concocted by this POKéMON."); +#else +static const u8 DexDescription_Koffing_1[] = _( + "If KOFFING becomes agitated, it raises\n" + "the toxicity of its internal gases and\n" + "jets them out from all over its body."); +static const u8 DexDescription_Koffing_2[] = _( + "This POKéMON may also overinflate its\n" + "round body, then explode."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Weezing_1[] = _( + "WEEZING alternately shrinks and\n" + "inflates its twin bodies to mix together\n" + "toxic gases inside."); +static const u8 DexDescription_Weezing_2[] = _( + "The more the gases are mixed, the more\n" + "powerful the toxins become. The\n" + "POKéMON also becomes more putrid."); +#else +static const u8 DexDescription_Weezing_1[] = _( + "WEEZING loves the gases given off by\n" + "rotted kitchen garbage. This POKéMON\n" + "will find a dirty, unkempt house and"); +static const u8 DexDescription_Weezing_2[] = _( + "make it its home. At night, when the\n" + "people in the house are asleep, it will\n" + "go through the trash."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Rhyhorn_1[] = _( + "RHYHORN’s brain is very small. It is so\n" + "dense, while on a run it forgets why it\n" + "started running in the first place."); +static const u8 DexDescription_Rhyhorn_2[] = _( + "It apparently remembers sometimes if it\n" + "demolishes something."); +#else +static const u8 DexDescription_Rhyhorn_1[] = _( + "RHYHORN runs in a straight line,\n" + "smashing everything in its path.\n" + "It is not bothered even if it rushes"); +static const u8 DexDescription_Rhyhorn_2[] = _( + "headlong into a block of steel.\n" + "This POKéMON may feel some pain from\n" + "the collision the next day, however."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Rhydon_1[] = _( + "RHYDON has a horn that serves as a\n" + "drill. It is used for destroying rocks\n" + "and boulders."); +static const u8 DexDescription_Rhydon_2[] = _( + "This POKéMON occasionally rams into\n" + "streams of magma, but the armor-like\n" + "hide prevents it from feeling the heat."); +#else +static const u8 DexDescription_Rhydon_1[] = _( + "RHYDON’s horn can crush even uncut\n" + "diamonds. One sweeping blow of its tail\n" + "can topple a building."); +static const u8 DexDescription_Rhydon_2[] = _( + "This POKéMON’s hide is extremely tough.\n" + "Even direct cannon hits don’t leave\n" + "a scratch."); +#endif + +static const u8 DexDescription_Chansey_1[] = _( + "CHANSEY lays nutritionally excellent\n" + "eggs on an everyday basis.\n" + "The eggs are so delicious, they are"); +static const u8 DexDescription_Chansey_2[] = _( + "easily and eagerly devoured by even\n" + "those people who have lost their\n" + "appetite."); + +static const u8 DexDescription_Tangela_1[] = _( + "TANGELA’s vines snap off easily if they\n" + "are grabbed. This happens without pain,\n" + "allowing it to make a quick getaway."); +static const u8 DexDescription_Tangela_2[] = _( + "The lost vines are replaced by newly\n" + "grown vines the very next day."); + +static const u8 DexDescription_Kangaskhan_1[] = _( + "If you come across a young KANGASKHAN\n" + "playing by itself, you must never\n" + "disturb it or attempt to catch it."); +static const u8 DexDescription_Kangaskhan_2[] = _( + "The baby POKéMON’s parent is sure to\n" + "be in the area, and it will become\n" + "violently enraged at you."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Horsea_1[] = _( + "If HORSEA senses danger, it will\n" + "reflexively spray a dense black ink\n" + "from its mouth and try to escape."); +static const u8 DexDescription_Horsea_2[] = _( + "This POKéMON swims by cleverly flapping\n" + "the fins on its back."); +#else +static const u8 DexDescription_Horsea_1[] = _( + "HORSEA eats small insects and moss off\n" + "of rocks. If the ocean current turns\n" + "fast, this POKéMON anchors itself by"); +static const u8 DexDescription_Horsea_2[] = _( + "wrapping its tail around rocks or coral\n" + "to prevent being washed away."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Seadra_1[] = _( + "SEADRA generates whirlpools by spinning\n" + "its body. The whirlpools are strong\n" + "enough to swallow even fishing boats."); +static const u8 DexDescription_Seadra_2[] = _( + "This POKéMON weakens prey with these\n" + "currents, then swallows it whole."); +#else +static const u8 DexDescription_Seadra_1[] = _( + "SEADRA sleeps after wriggling itself\n" + "between the branches of coral.\n" + "Those trying to harvest coral are"); +static const u8 DexDescription_Seadra_2[] = _( + "occasionally stung by this POKéMON’s\n" + "poison barbs if they fail to notice it."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Goldeen_1[] = _( + "GOLDEEN loves swimming wild and free\n" + "in rivers and ponds.\n" + "If one of these POKéMON is placed in an"); +static const u8 DexDescription_Goldeen_2[] = _( + "aquarium, it will shatter even the\n" + "thickest glass with one ram of its horn\n" + "and make its escape."); +#else +static const u8 DexDescription_Goldeen_1[] = _( + "GOLDEEN is a very beautiful POKéMON\n" + "with fins that billow elegantly in water.\n" + "However, don’t let your guard down"); +static const u8 DexDescription_Goldeen_2[] = _( + "around this POKéMON - it could ram you\n" + "powerfully with its horn."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Seaking_1[] = _( + "SEAKING is very protective of its eggs.\n" + "The male and female will take turns\n" + "patrolling around their nest and eggs."); +static const u8 DexDescription_Seaking_2[] = _( + "The guarding of eggs by these POKéMON\n" + "goes on for over a month."); +#else +static const u8 DexDescription_Seaking_1[] = _( + "In the autumn, SEAKING males can be\n" + "seen performing courtship dances in\n" + "riverbeds to woo females."); +static const u8 DexDescription_Seaking_2[] = _( + "During this season, this POKéMON’s body\n" + "coloration is at its most beautiful."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Staryu_1[] = _( + "STARYU apparently communicates with\n" + "the stars in the night sky by flashing\n" + "the red core at the center of its body."); +static const u8 DexDescription_Staryu_2[] = _( + "If parts of its body are torn, this\n" + "POKéMON simply regenerates the\n" + "missing pieces and limbs."); +#else +static const u8 DexDescription_Staryu_1[] = _( + "STARYU’s center section has an organ\n" + "called the core that shines bright red.\n" + "If you go to a beach toward the"); +static const u8 DexDescription_Staryu_2[] = _( + "end of summer, the glowing cores of\n" + "these POKéMON look like the stars\n" + "in the sky."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Starmie_1[] = _( + "STARMIE swims through water by\n" + "spinning its star-shaped body as if it\n" + "were a propeller on a ship."); +static const u8 DexDescription_Starmie_2[] = _( + "The core at the center of this\n" + "POKéMON’s body glows in seven colors."); +#else +static const u8 DexDescription_Starmie_1[] = _( + "STARMIE’s center section - the core -\n" + "glows brightly in seven colors.\n" + "Because of its luminous nature, this"); +static const u8 DexDescription_Starmie_2[] = _( + "POKéMON has been given the nickname\n" + "“the gem of the sea.”"); +#endif + +static const u8 DexDescription_Mrmime_1[] = _( + "MR. MIME is a master of pantomime.\n" + "Its gestures and motions convince\n" + "watchers that something unseeable"); +static const u8 DexDescription_Mrmime_2[] = _( + "actually exists. Once it is believed,\n" + "it will exist as if it were a real thing."); + +static const u8 DexDescription_Scyther_1[] = _( + "SCYTHER is blindingly fast. Its blazing\n" + "speed enhances the effectiveness of\n" + "the twin scythes on its forearms."); +static const u8 DexDescription_Scyther_2[] = _( + "This POKéMON’s scythes are so\n" + "effective, they can slice through thick\n" + "logs in one wicked stroke."); + +static const u8 DexDescription_Jynx_1[] = _( + "JYNX walks rhythmically, swaying and\n" + "shaking its hips as if it were dancing.\n" + "Its motions are so bouncingly alluring,"); +static const u8 DexDescription_Jynx_2[] = _( + "people seeing it are compelled to shake\n" + "their hips without giving any thought\n" + "to what they are doing."); + +static const u8 DexDescription_Electabuzz_1[] = _( + "When a storm arrives, gangs of this\n" + "POKéMON compete with each other to\n" + "scale heights that are likely to be"); +static const u8 DexDescription_Electabuzz_2[] = _( + "stricken by lightning bolts.\n" + "Some towns use ELECTABUZZ in place of\n" + "lightning rods."); + +static const u8 DexDescription_Magmar_1[] = _( + "In battle, MAGMAR blows out intensely\n" + "hot flames from all over its body to\n" + "intimidate its opponent."); +static const u8 DexDescription_Magmar_2[] = _( + "This POKéMON’s fiery bursts create\n" + "heat waves that ignite grass and trees\n" + "in its surroundings."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Pinsir_1[] = _( + "PINSIR has a pair of massive horns \n" + "Protruding from the surface of these\n" + "horns are thorns."); +static const u8 DexDescription_Pinsir_2[] = _( + "These thorns are driven deeply into the\n" + "foe’s body when the pincer closes,\n" + "making it tough for the foe to escape."); +#else +static const u8 DexDescription_Pinsir_1[] = _( + "PINSIR is astoundingly strong. It can\n" + "grip a foe weighing twice its weight\n" + "in its horns and easily lift it."); +static const u8 DexDescription_Pinsir_2[] = _( + "This POKéMON’s movements turn sluggish\n" + "in cold places."); +#endif + +static const u8 DexDescription_Tauros_1[] = _( + "This POKéMON is not satisfied unless\n" + "it is rampaging at all times.\n" + "If there is no opponent for TAUROS to"); +static const u8 DexDescription_Tauros_2[] = _( + "battle, it will charge at thick trees and\n" + "knock them down to calm itself."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Magikarp_1[] = _( + "MAGIKARP is virtually useless in battle\n" + "as it can only splash around.\n" + "As a result, it is considered to be weak."); +static const u8 DexDescription_Magikarp_2[] = _( + "However, it is actually a very hardy\n" + "POKéMON that can survive in any body of\n" + "water no matter how polluted it is."); +#else +static const u8 DexDescription_Magikarp_1[] = _( + "MAGIKARP is a pathetic excuse for a\n" + "POKéMON that is only capable of\n" + "flopping and splashing."); +static const u8 DexDescription_Magikarp_2[] = _( + "This behavior prompted scientists to\n" + "undertake research into it."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Gyarados_1[] = _( + "Once GYARADOS goes on a rampage, its\n" + "ferociously violent blood doesn’t calm\n" + "until it has burned everything down."); +static const u8 DexDescription_Gyarados_2[] = _( + "There are records of this POKéMON’s\n" + "rampages lasting a whole month."); +#else +static const u8 DexDescription_Gyarados_1[] = _( + "When MAGIKARP evolves into GYARADOS,\n" + "its brain cells undergo a structural\n" + "transformation. It is said that this"); +static const u8 DexDescription_Gyarados_2[] = _( + "transformation is to blame for this\n" + "POKéMON’s wildly violent nature."); +#endif + +static const u8 DexDescription_Lapras_1[] = _( + "People have driven LAPRAS almost to the\n" + "point of extinction. In the evenings,\n" + "this POKéMON is said to sing plaintively"); +static const u8 DexDescription_Lapras_2[] = _( + "as it seeks what few others of its kind\n" + "still remain."); + +static const u8 DexDescription_Ditto_1[] = _( + "DITTO rearranges its cell structure to\n" + "transform itself into other shapes.\n" + "However, if it tries to transform itself"); +static const u8 DexDescription_Ditto_2[] = _( + "into something by relying on its memory,\n" + "this POKéMON manages to get details\n" + "wrong."); + +static const u8 DexDescription_Eevee_1[] = _( + "EEVEE has an unstable genetic makeup\n" + "that suddenly mutates due to the\n" + "environment in which it lives."); +static const u8 DexDescription_Eevee_2[] = _( + "Radiation from various STONES causes\n" + "this POKéMON to evolve."); + +static const u8 DexDescription_Vaporeon_1[] = _( + "VAPOREON underwent a spontaneous\n" + "mutation and grew fins and gills that\n" + "allow it to live underwater."); +static const u8 DexDescription_Vaporeon_2[] = _( + "This POKéMON has the ability to freely\n" + "control water."); + +static const u8 DexDescription_Jolteon_1[] = _( + "JOLTEON’s cells generate a low level of\n" + "electricity. This power is amplified by\n" + "the static electricity of its fur,"); +static const u8 DexDescription_Jolteon_2[] = _( + "enabling the POKéMON to drop\n" + "thunderbolts. The bristling fur is made\n" + "of electrically charged needles."); + +static const u8 DexDescription_Flareon_1[] = _( + "FLAREON’s fluffy fur has a functional\n" + "purpose - it releases heat into the air\n" + "so that its body does not get"); +static const u8 DexDescription_Flareon_2[] = _( + "excessively hot.\n" + "This POKéMON’s body temperature can\n" + "rise to a maximum of 1,650 degrees F."); + +static const u8 DexDescription_Porygon_1[] = _( + "PORYGON is capable of reverting itself\n" + "entirely back to program data and\n" + "entering cyberspace."); +static const u8 DexDescription_Porygon_2[] = _( + "This POKéMON is copy-protected so it\n" + "cannot be duplicated by copying."); + +static const u8 DexDescription_Omanyte_1[] = _( + "OMANYTE is one of the ancient and long-\n" + "since-extinct POKéMON that have been\n" + "regenerated from fossils by people."); +static const u8 DexDescription_Omanyte_2[] = _( + "If attacked by an enemy, it withdraws\n" + "itself inside its hard shell."); + +static const u8 DexDescription_Omastar_1[] = _( + "OMASTAR uses its tentacles to capture\n" + "its prey. It is believed to have become\n" + "extinct because its shell grew too large"); +static const u8 DexDescription_Omastar_2[] = _( + "and heavy, causing its movements to\n" + "become too slow and ponderous."); + +static const u8 DexDescription_Kabuto_1[] = _( + "KABUTO is a POKéMON that has been\n" + "regenerated from a fossil. However, in\n" + "extremely rare cases, living examples"); +static const u8 DexDescription_Kabuto_2[] = _( + "have been discovered.\n" + "The POKéMON has not changed at all for\n" + "300 million years."); + +static const u8 DexDescription_Kabutops_1[] = _( + "KABUTOPS swam underwater to hunt for\n" + "its prey in ancient times.\n" + "The POKéMON was apparently evolving"); +static const u8 DexDescription_Kabutops_2[] = _( + "from being a water-dweller to living on\n" + "land as evident from the beginnings of\n" + "change in its gills and legs."); + +static const u8 DexDescription_Aerodactyl_1[] = _( + "AERODACTYL is a POKéMON from the age\n" + "of dinosaurs. It was regenerated from\n" + "genetic material extracted from amber."); +static const u8 DexDescription_Aerodactyl_2[] = _( + "It is imagined to have been the king of\n" + "the skies in ancient times."); + +static const u8 DexDescription_Snorlax_1[] = _( + "SNORLAX’s typical day consists of\n" + "nothing more than eating and sleeping.\n" + "It is such a docile POKéMON that there"); +static const u8 DexDescription_Snorlax_2[] = _( + "are children who use its expansive belly\n" + "as a place to play."); + +static const u8 DexDescription_Articuno_1[] = _( + "ARTICUNO is a legendary bird POKéMON\n" + "that can control ice.\n" + "The flapping of its wings chills the air."); +static const u8 DexDescription_Articuno_2[] = _( + "As a result, it is said that when this\n" + "POKéMON flies, snow will fall."); + +static const u8 DexDescription_Zapdos_1[] = _( + "ZAPDOS is a legendary bird POKéMON that\n" + "has the ability to control electricity.\n" + "It usually lives in thunderclouds."); +static const u8 DexDescription_Zapdos_2[] = _( + "The POKéMON gains power if it is\n" + "stricken by lightning bolts."); + +static const u8 DexDescription_Moltres_1[] = _( + "MOLTRES is a legendary bird POKéMON\n" + "that has the ability to control fire.\n" + "If this POKéMON is injured, it is said to"); +static const u8 DexDescription_Moltres_2[] = _( + "dip its body in the molten magma of a\n" + "volcano to burn and heal itself."); + +static const u8 DexDescription_Dratini_1[] = _( + "DRATINI continually molts and sloughs\n" + "off its old skin.\n" + "It does so because the life energy"); +static const u8 DexDescription_Dratini_2[] = _( + "within its body steadily builds to reach\n" + "uncontrollable levels."); + +static const u8 DexDescription_Dragonair_1[] = _( + "DRAGONAIR stores an enormous amount\n" + "of energy inside its body.\n" + "It is said to alter weather conditions"); +static const u8 DexDescription_Dragonair_2[] = _( + "in its vicinity by discharging energy\n" + "from the crystals on its neck and tail."); + +static const u8 DexDescription_Dragonite_1[] = _( + "DRAGONITE is capable of circling the\n" + "globe in just sixteen hours.\n" + "It is a kindhearted POKéMON that leads"); +static const u8 DexDescription_Dragonite_2[] = _( + "lost and foundering ships in a storm to\n" + "the safety of land."); + +static const u8 DexDescription_Mewtwo_1[] = _( + "MEWTWO is a POKéMON that was created\n" + "by genetic manipulation.\n" + "However, even though the scientific"); +static const u8 DexDescription_Mewtwo_2[] = _( + "power of humans created this POKéMON’s\n" + "body, they failed to endow MEWTWO with\n" + "a compassionate heart."); + +static const u8 DexDescription_Mew_1[] = _( + "MEW is said to possess the genetic\n" + "composition of all POKéMON.\n" + "It is capable of making itself invisible"); +static const u8 DexDescription_Mew_2[] = _( + "at will, so it entirely avoids notice even\n" + "if it approaches people."); + +static const u8 DexDescription_Chikorita_1[] = _( + "In battle, CHIKORITA waves its leaf\n" + "around to keep the foe at bay.\n" + "However, a sweet fragrance also wafts"); +static const u8 DexDescription_Chikorita_2[] = _( + "from the leaf, becalming the battling\n" + "POKéMON and creating a cozy, friendly\n" + "atmosphere all around."); + +static const u8 DexDescription_Bayleef_1[] = _( + "BAYLEEF’s neck is ringed by curled-up\n" + "leaves. Inside each tubular leaf is a\n" + "small shoot of a tree."); +static const u8 DexDescription_Bayleef_2[] = _( + "The fragrance of this shoot makes\n" + "people peppy."); + +static const u8 DexDescription_Meganium_1[] = _( + "The fragrance of MEGANIUM’s flower\n" + "soothes and calms emotions.\n" + "In battle, this POKéMON gives off more"); +static const u8 DexDescription_Meganium_2[] = _( + "of its becalming scent to blunt the\n" + "foe’s fighting spirit."); + +static const u8 DexDescription_Cyndaquil_1[] = _( + "CYNDAQUIL protects itself by flaring up\n" + "the flames on its back.\n" + "The flames are vigorous if the POKéMON"); +static const u8 DexDescription_Cyndaquil_2[] = _( + "is angry. However, if it is tired, the\n" + "flames splutter fitfully with incomplete\n" + "combustion."); + +static const u8 DexDescription_Quilava_1[] = _( + "QUILAVA keeps its foes at bay with the\n" + "intensity of its flames and gusts of\n" + "superheated air."); +static const u8 DexDescription_Quilava_2[] = _( + "This POKéMON applies its outstanding\n" + "nimbleness to dodge attacks even while\n" + "scorching the foe with flames."); + +static const u8 DexDescription_Typhlosion_1[] = _( + "TYPHLOSION obscures itself behind a\n" + "shimmering heat haze that it creates\n" + "using its intensely hot flames."); +static const u8 DexDescription_Typhlosion_2[] = _( + "This POKéMON creates blazing explosive\n" + "blasts that burn everything to cinders."); + +static const u8 DexDescription_Totodile_1[] = _( + "Despite the smallness of its body,\n" + "TOTODILE’s jaws are very powerful.\n" + "While the POKéMON may think it is just"); +static const u8 DexDescription_Totodile_2[] = _( + "playfully nipping, its bite has enough\n" + "power to cause serious injury."); + +static const u8 DexDescription_Croconaw_1[] = _( + "Once CROCONAW has clamped its jaws on\n" + "its foe, it will absolutely not let go.\n" + "Because the tips of its fangs are"); +static const u8 DexDescription_Croconaw_2[] = _( + "forked back like barbed fishhooks, they\n" + "become impossible to remove when \n" + "they have sunk in."); + +static const u8 DexDescription_Feraligatr_1[] = _( + "FERALIGATR intimidates its foes by\n" + "opening its huge mouth.\n" + "In battle, it will kick the ground hard"); +static const u8 DexDescription_Feraligatr_2[] = _( + "with its thick and powerful hind legs to\n" + "charge at the foe at an incredible\n" + "speed."); + +static const u8 DexDescription_Sentret_1[] = _( + "When SENTRET sleeps, it does so while\n" + "another stands guard. The sentry wakes\n" + "the others at the first sign of danger."); +static const u8 DexDescription_Sentret_2[] = _( + "When this POKéMON becomes separated\n" + "from its pack, it becomes incapable of\n" + "sleep due to fear."); + +static const u8 DexDescription_Furret_1[] = _( + "FURRET has a very slim build.\n" + "When under attack, it can slickly squirm\n" + "through narrow spaces and get away."); +static const u8 DexDescription_Furret_2[] = _( + "In spite of its short limbs, this\n" + "POKéMON is very nimble and fleet."); + +static const u8 DexDescription_Hoothoot_1[] = _( + "HOOTHOOT has an internal organ that\n" + "senses and tracks the earth’s rotation.\n" + "Using this special organ, this POKéMON"); +static const u8 DexDescription_Hoothoot_2[] = _( + "begins hooting at precisely the same\n" + "time every day."); + +static const u8 DexDescription_Noctowl_1[] = _( + "NOCTOWL never fails at catching prey in\n" + "darkness. This POKéMON owes its\n" + "success to its superior vision that"); +static const u8 DexDescription_Noctowl_2[] = _( + "allows it to see in minimal light, and to\n" + "its soft, supple wings that make no\n" + "sound in flight."); + +static const u8 DexDescription_Ledyba_1[] = _( + "LEDYBA secretes an aromatic fluid from\n" + "where its legs join its body. This fluid\n" + "is used for communicating with others."); +static const u8 DexDescription_Ledyba_2[] = _( + "This POKéMON conveys its feelings to\n" + "others by altering the fluid’s scent."); + +static const u8 DexDescription_Ledian_1[] = _( + "It is said that in lands with clean air,\n" + "where the stars fill the sky, there live\n" + "LEDIAN in countless numbers."); +static const u8 DexDescription_Ledian_2[] = _( + "There is a good reason for this - the\n" + "POKéMON uses the light of the stars\n" + "as its energy."); + +static const u8 DexDescription_Spinarak_1[] = _( + "The web spun by SPINARAK can be\n" + "considered its second nervous system.\n" + "It is said that this POKéMON can"); +static const u8 DexDescription_Spinarak_2[] = _( + "determine what kind of prey is touching\n" + "its web just by the tiny vibrations it\n" + "feels through the web’s strands."); + +static const u8 DexDescription_Ariados_1[] = _( + "ARIADOS’s feet are tipped with tiny\n" + "hooked claws that enable it to scuttle\n" + "on ceilings and vertical walls."); +static const u8 DexDescription_Ariados_2[] = _( + "This POKéMON constricts the foe with\n" + "thin and strong silk webbing."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Crobat_1[] = _( + "CROBAT sneaks up on its intended prey\n" + "using wings that barely make a sound.\n" + "This POKéMON rests by hanging on a"); +static const u8 DexDescription_Crobat_2[] = _( + "tree branch with its rear legs that\n" + "serve as wings."); +#else +static const u8 DexDescription_Crobat_1[] = _( + "If this POKéMON is flying by fluttering\n" + "only a pair of wings on either the\n" + "forelegs or hind legs, it’s proof that"); +static const u8 DexDescription_Crobat_2[] = _( + "CROBAT has been flying a long distance.\n" + "It switches the wings it uses if it is\n" + "tired."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Chinchou_1[] = _( + "CHINCHOU’s two antennas are filled with\n" + "cells that generate strong electricity.\n" + "This POKéMON’s cells create so much"); +static const u8 DexDescription_Chinchou_2[] = _( + "electrical power, it even makes itself\n" + "tingle slightly."); +#else +static const u8 DexDescription_Chinchou_1[] = _( + "CHINCHOU lets loose positive and\n" + "negative electrical charges from its\n" + "two antennas to make its prey faint."); +static const u8 DexDescription_Chinchou_2[] = _( + "This POKéMON flashes its electric\n" + "lights to exchange signals with others."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Lanturn_1[] = _( + "LANTURN is known to emit light.\n" + "If you peer down into the dark sea from\n" + "a ship at night, you can sometimes see"); +static const u8 DexDescription_Lanturn_2[] = _( + "this POKéMON’s light rising from the\n" + "depths where it swims. It gives the sea\n" + "an appearance of a starlit night."); +#else +static const u8 DexDescription_Lanturn_1[] = _( + "LANTURN is nicknamed “the deep-sea\n" + "star” for its illuminated antenna.\n" + "This POKéMON produces light by"); +static const u8 DexDescription_Lanturn_2[] = _( + "causing a chemical reaction between\n" + "bacteria and its bodily fluids inside\n" + "the antenna."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Pichu_1[] = _( + "When PICHU plays with others, it may\n" + "short out electricity with another\n" + "PICHU, creating a shower of sparks."); +static const u8 DexDescription_Pichu_2[] = _( + "In that event, this POKéMON will begin\n" + "crying, startled by the flash of sparks."); +#else +static const u8 DexDescription_Pichu_1[] = _( + "PICHU charges itself with electricity\n" + "more easily on days with thunderclouds\n" + "or when the air is very dry."); +static const u8 DexDescription_Pichu_2[] = _( + "You can hear the crackling of static\n" + "electricity coming off this POKéMON."); +#endif + +static const u8 DexDescription_Cleffa_1[] = _( + "On nights with many shooting stars,\n" + "CLEFFA can be seen dancing in a ring.\n" + "They dance through the night and stop"); +static const u8 DexDescription_Cleffa_2[] = _( + "only at the break of day, when these\n" + "POKéMON quench their thirst with the\n" + "morning dew."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Igglybuff_1[] = _( + "IGGLYBUFF has a soft and plushy body\n" + "that feels very much like a marshmallow.\n" + "From this body wafts a gently sweet"); +static const u8 DexDescription_Igglybuff_2[] = _( + "fragrance that soothes and calms the\n" + "emotions of its foes."); +#else +static const u8 DexDescription_Igglybuff_1[] = _( + "IGGLYBUFF’s vocal chords are not\n" + "sufficiently developed. It would hurt\n" + "its throat if it were to sing too much."); +static const u8 DexDescription_Igglybuff_2[] = _( + "This POKéMON gargles with freshwater\n" + "from a clean stream."); +#endif + +static const u8 DexDescription_Togepi_1[] = _( + "As its energy, TOGEPI uses the positive\n" + "emotions of compassion and pleasure\n" + "exuded by people and POKéMON."); +static const u8 DexDescription_Togepi_2[] = _( + "This POKéMON stores up feelings of\n" + "happiness inside its shell, then shares\n" + "them with others."); + +static const u8 DexDescription_Togetic_1[] = _( + "TOGETIC is said to be a POKéMON that\n" + "brings good fortune. When the POKéMON\n" + "spots someone who is pure of heart,"); +static const u8 DexDescription_Togetic_2[] = _( + "it is said to appear and share its\n" + "happiness with that person."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Natu_1[] = _( + "NATU has a highly developed jumping\n" + "ability. The POKéMON flaps and leaps\n" + "onto tree branches that are taller than"); +static const u8 DexDescription_Natu_2[] = _( + "grown-up people to pick at the tree’s\n" + "new shoots."); +#else +static const u8 DexDescription_Natu_1[] = _( + "NATU cannot fly because its wings are\n" + "not yet fully grown. If your eyes meet\n" + "with this POKéMON’s eyes, it will stare"); +static const u8 DexDescription_Natu_2[] = _( + "back intently at you. But if you move\n" + "even slightly, it will hop away to safety."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Xatu_1[] = _( + "XATU is known to stand motionless while\n" + "staring at the sun all day long.\n" + "Some people revere it as a mystical"); +static const u8 DexDescription_Xatu_2[] = _( + "POKéMON out of their belief that XATU\n" + "is in possession of the power to see\n" + "into the future."); +#else +static const u8 DexDescription_Xatu_1[] = _( + "XATU stands rooted and still in one\n" + "spot all day long. People believe that\n" + "this POKéMON does so out of fear of"); +static const u8 DexDescription_Xatu_2[] = _( + "the terrible things it has foreseen in\n" + "the future."); +#endif + +static const u8 DexDescription_Mareep_1[] = _( + "MAREEP’s fluffy coat of wool rubs\n" + "together and builds a static charge.\n" + "The more static electricity is charged,"); +static const u8 DexDescription_Mareep_2[] = _( + "the more brightly the lightbulb at the\n" + "tip of its tail grows."); + +static const u8 DexDescription_Flaaffy_1[] = _( + "FLAAFFY’s wool quality changes so that\n" + "it can generate a high amount of static\n" + "electricity with a small amount of wool."); +static const u8 DexDescription_Flaaffy_2[] = _( + "The bare and slick parts of its hide are\n" + "shielded against electricity."); + +static const u8 DexDescription_Ampharos_1[] = _( + "AMPHAROS gives off so much light that\n" + "it can be seen even from space.\n" + "People in the old days used the light of"); +static const u8 DexDescription_Ampharos_2[] = _( + "this POKéMON to send signals back and\n" + "forth with others far away."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Bellossom_1[] = _( + "A BELLOSSOM grows flowers more\n" + "beautifully if it has evolved from a\n" + "smelly GLOOM - the stinkier the better."); +static const u8 DexDescription_Bellossom_2[] = _( + "At night, this POKéMON closes its\n" + "petals and goes to sleep."); +#else +static const u8 DexDescription_Bellossom_1[] = _( + "When BELLOSSOM gets exposed to plenty\n" + "of sunlight, the leaves ringing its body\n" + "begin to spin around."); +static const u8 DexDescription_Bellossom_2[] = _( + "This POKéMON’s dancing is renowned in\n" + "the southern lands."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Marill_1[] = _( + "When fishing for food at the edge of a\n" + "fast-running stream, MARILL wraps its\n" + "tail around the trunk of a tree."); +static const u8 DexDescription_Marill_2[] = _( + "This POKéMON’s tail is flexible and\n" + "configured to stretch."); +#else +static const u8 DexDescription_Marill_1[] = _( + "MARILL’s oil-filled tail acts much like\n" + "a life preserver. If you see just its\n" + "tail bobbing on the water’s surface,"); +static const u8 DexDescription_Marill_2[] = _( + "it’s a sure indication that this POKéMON\n" + "is diving beneath the water to feed on\n" + "aquatic plants."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Azumarill_1[] = _( + "AZUMARILL can make balloons out of\n" + "air. It makes these air balloons if it\n" + "spots a drowning POKéMON."); +static const u8 DexDescription_Azumarill_2[] = _( + "The air balloons enable the POKéMON in\n" + "trouble to breathe."); +#else +static const u8 DexDescription_Azumarill_1[] = _( + "AZUMARILL’s long ears are indispensable\n" + "sensors. By focusing its hearing, this\n" + "POKéMON can identify what kinds of"); +static const u8 DexDescription_Azumarill_2[] = _( + "prey are around, even in rough and\n" + "fast-running rivers."); +#endif + +static const u8 DexDescription_Sudowoodo_1[] = _( + "SUDOWOODO camouflages itself as a tree\n" + "to avoid being attacked by enemies.\n" + "However, because the forelegs remain"); +static const u8 DexDescription_Sudowoodo_2[] = _( + "green throughout the year, the POKéMON\n" + "is easily identified as a fake during\n" + "the winter."); + +static const u8 DexDescription_Politoed_1[] = _( + "The curled hair on POLITOED’s head is\n" + "proof of its status as a king. It is said\n" + "that the longer and more curled the"); +static const u8 DexDescription_Politoed_2[] = _( + "hair, the more respect this POKéMON\n" + "earns from its peers."); + +static const u8 DexDescription_Hoppip_1[] = _( + "This POKéMON drifts and floats with the\n" + "wind. If it senses the approach of\n" + "strong winds, HOPPIP links its leaves"); +static const u8 DexDescription_Hoppip_2[] = _( + "with other HOPPIP to prepare against\n" + "being blown away."); + +static const u8 DexDescription_Skiploom_1[] = _( + "SKIPLOOM’s flower blossoms when the\n" + "temperature rises above 64 degrees F.\n" + "How much the flower opens depends on"); +static const u8 DexDescription_Skiploom_2[] = _( + "the temperature. For that reason, this\n" + "POKéMON is sometimes used as a\n" + "thermometer."); + +static const u8 DexDescription_Jumpluff_1[] = _( + "JUMPLUFF rides warm southern winds to\n" + "cross the sea and fly to foreign lands.\n" + "The POKéMON descends to the ground"); +static const u8 DexDescription_Jumpluff_2[] = _( + "when it encounters cold air while it is\n" + "floating."); + +static const u8 DexDescription_Aipom_1[] = _( + "AIPOM’s tail ends in a hand-like\n" + "appendage that can be cleverly\n" + "manipulated."); +static const u8 DexDescription_Aipom_2[] = _( + "However, because the POKéMON uses its\n" + "tail so much, its real hands have become\n" + "rather clumsy."); + +static const u8 DexDescription_Sunkern_1[] = _( + "SUNKERN tries to move as little as it\n" + "possibly can. It does so because it\n" + "tries to conserve all the nutrients it"); +static const u8 DexDescription_Sunkern_2[] = _( + "has stored in its body for its\n" + "evolution. It will not eat a thing, \n" + "subsisting only on morning dew."); + +static const u8 DexDescription_Sunflora_1[] = _( + "SUNFLORA converts solar energy into\n" + "nutrition. It moves around actively in\n" + "the daytime when it is warm."); +static const u8 DexDescription_Sunflora_2[] = _( + "It stops moving as soon as the sun goes\n" + "down for the night."); + +static const u8 DexDescription_Yanma_1[] = _( + "YANMA is capable of seeing 360 degrees\n" + "without having to move its eyes.\n" + "It is a great flier that is adept at"); +static const u8 DexDescription_Yanma_2[] = _( + "making sudden stops and turning midair.\n" + "This POKéMON uses its flying ability to\n" + "quickly chase down targeted prey."); + +static const u8 DexDescription_Wooper_1[] = _( + "WOOPER usually lives in water.\n" + "However, it occasionally comes out onto\n" + "land in search of food."); +static const u8 DexDescription_Wooper_2[] = _( + "On land, it coats its body with a gooey,\n" + "toxic film."); + +static const u8 DexDescription_Quagsire_1[] = _( + "QUAGSIRE hunts for food by leaving\n" + "its mouth wide open in water and waiting\n" + "for its prey to blunder in unaware."); +static const u8 DexDescription_Quagsire_2[] = _( + "Because the POKéMON does not move,\n" + "it does not get very hungry."); + +static const u8 DexDescription_Espeon_1[] = _( + "ESPEON is extremely loyal to any\n" + "TRAINER it considers to be worthy.\n" + "It is said that this POKéMON developed"); +static const u8 DexDescription_Espeon_2[] = _( + "its precognitive powers to protect its\n" + "TRAINER from harm."); + +static const u8 DexDescription_Umbreon_1[] = _( + "UMBREON evolved as a result of exposure\n" + "to the moon’s waves.\n" + "It hides silently in darkness and waits"); +static const u8 DexDescription_Umbreon_2[] = _( + "for its foes to make a move.\n" + "The rings on its body glow when it leaps\n" + "to attack."); + +static const u8 DexDescription_Murkrow_1[] = _( + "MURKROW was feared and loathed as the\n" + "alleged bearer of ill fortune.\n" + "This POKéMON shows strong interest in"); +static const u8 DexDescription_Murkrow_2[] = _( + "anything that sparkles or glitters.\n" + "It will even try to steal rings from\n" + "women."); + +static const u8 DexDescription_Slowking_1[] = _( + "SLOWKING undertakes research every\n" + "day in an effort to solve the mysteries\n" + "of the world."); +static const u8 DexDescription_Slowking_2[] = _( + "However, this POKéMON apparently\n" + "forgets everything it has learned if\n" + "the SHELLDER on its head comes off."); + +static const u8 DexDescription_Misdreavus_1[] = _( + "MISDREAVUS frightens people with a\n" + "creepy, sobbing cry. The POKéMON\n" + "apparently uses its red spheres to"); +static const u8 DexDescription_Misdreavus_2[] = _( + "absorb the fearful feelings of foes and\n" + "turn them into nutrition."); + +static const u8 DexDescription_Unown_1[] = _( + "This POKéMON is shaped like ancient\n" + "writing. It is a mystery as to which\n" + "came first, the ancient writings or the"); +static const u8 DexDescription_Unown_2[] = _( + "various UNOWN. Research into this\n" + "topic is ongoing but nothing is known."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Wobbuffet_1[] = _( + "WOBBUFFET does nothing but endure\n" + "attacks - it won’t attack on its own.\n" + "However, it won’t endure an attack on"); +static const u8 DexDescription_Wobbuffet_2[] = _( + "its tail. When that happens, the\n" + "POKéMON will try to take the foe with it\n" + "using DESTINY BOND."); +#else +static const u8 DexDescription_Wobbuffet_1[] = _( + "If two or more WOBBUFFET meet, they will\n" + "turn competitive and try to outdo each\n" + "other’s endurance."); +static const u8 DexDescription_Wobbuffet_2[] = _( + "However, they may try to see which one\n" + "can endure the longest without food.\n" + "TRAINERS need to beware of this habit."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Girafarig_1[] = _( + "GIRAFARIG’s rear head contains a tiny\n" + "brain that is too small for thinking.\n" + "However, the rear head doesn’t need to"); +static const u8 DexDescription_Girafarig_2[] = _( + "sleep, so it can keep watch over its\n" + "surroundings 24 hours a day."); +#else +static const u8 DexDescription_Girafarig_1[] = _( + "GIRAFARIG’s rear head also has a brain,\n" + "but it is small. The rear head attacks in\n" + "response to smells and sounds."); +static const u8 DexDescription_Girafarig_2[] = _( + "Approaching this POKéMON from behind\n" + "can cause the rear head to suddenly\n" + "lash out and bite."); +#endif + +static const u8 DexDescription_Pineco_1[] = _( + "PINECO hangs from a tree branch and\n" + "patiently waits for prey to come along.\n" + "If the POKéMON is disturbed while"); +static const u8 DexDescription_Pineco_2[] = _( + "eating by someone shaking its tree, it\n" + "drops down to the ground and explodes\n" + "with no warning."); + +static const u8 DexDescription_Forretress_1[] = _( + "FORRETRESS conceals itself inside its\n" + "hardened steel shell. The shell is opened\n" + "when the POKéMON is catching prey,"); +static const u8 DexDescription_Forretress_2[] = _( + "but it does so at such a quick pace\n" + "that the shell’s inside cannot be seen."); + +static const u8 DexDescription_Dunsparce_1[] = _( + "DUNSPARCE has a drill for its tail.\n" + "It uses this tail to burrow into the\n" + "ground backwards."); +static const u8 DexDescription_Dunsparce_2[] = _( + "This POKéMON is known to make its nest\n" + "in complex shapes deep under the\n" + "ground."); + +static const u8 DexDescription_Gligar_1[] = _( + "GLIGAR glides through the air without\n" + "a sound as if it were sliding.\n" + "This POKéMON hangs on to the face of"); +static const u8 DexDescription_Gligar_2[] = _( + "its foe using its clawed hind legs and\n" + "the large pincers on its forelegs, then\n" + "injects the prey with its poison barb."); + +static const u8 DexDescription_Steelix_1[] = _( + "STEELIX lives even further underground\n" + "than ONIX. This POKéMON is known to dig\n" + "towards the earth’s core."); +static const u8 DexDescription_Steelix_2[] = _( + "There are records of this POKéMON\n" + "reaching a depth of over six-tenths\n" + "of a mile underground."); + +static const u8 DexDescription_Snubbull_1[] = _( + "By baring its fangs and making a scary\n" + "face, SNUBBULL sends smaller POKéMON\n" + "scurrying away in terror."); +static const u8 DexDescription_Snubbull_2[] = _( + "However, this POKéMON seems a little\n" + "sad at making its foes flee."); + +static const u8 DexDescription_Granbull_1[] = _( + "GRANBULL has a particularly well-\n" + "developed lower jaw. The enormous fangs\n" + "are heavy, causing the POKéMON to tip"); +static const u8 DexDescription_Granbull_2[] = _( + "its head back for balance.\n" + "Unless it is startled, it will not try to\n" + "bite indiscriminately."); + +static const u8 DexDescription_Qwilfish_1[] = _( + "QWILFISH sucks in water, inflating\n" + "itself. This POKéMON uses the pressure\n" + "of the water it swallowed to shoot"); +static const u8 DexDescription_Qwilfish_2[] = _( + "toxic quills all at once from all over\n" + "its body. It finds swimming somewhat\n" + "challenging."); + +static const u8 DexDescription_Scizor_1[] = _( + "SCIZOR has a body with the hardness of\n" + "steel. It is not easily fazed by ordinary\n" + "sorts of attacks."); +static const u8 DexDescription_Scizor_2[] = _( + "This POKéMON flaps its wings to\n" + "regulate its body temperature."); + +static const u8 DexDescription_Shuckle_1[] = _( + "SHUCKLE quietly hides itself under\n" + "rocks, keeping its body concealed\n" + "inside its hard shell while eating"); +static const u8 DexDescription_Shuckle_2[] = _( + "berries it has stored away.\n" + "The berries mix with its body fluids to\n" + "become a juice."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Heracross_1[] = _( + "HERACROSS has sharp claws on its feet.\n" + "These are planted firmly into the\n" + "ground or the bark of a tree, giving the"); +static const u8 DexDescription_Heracross_2[] = _( + "POKéMON a secure and solid footing\n" + "to forcefully fling away foes with\n" + "its proud horn."); +#else +static const u8 DexDescription_Heracross_1[] = _( + "HERACROSS charges in a straight line at\n" + "its foe, slips beneath the foe’s grasp,\n" + "and then scoops up and hurls the"); +static const u8 DexDescription_Heracross_2[] = _( + "opponent with its mighty horn.\n" + "This POKéMON even has enough power\n" + "to topple a massive tree."); +#endif + +static const u8 DexDescription_Sneasel_1[] = _( + "SNEASEL scales trees by punching its\n" + "hooked claws into the bark.\n" + "This POKéMON seeks out unguarded"); +static const u8 DexDescription_Sneasel_2[] = _( + "nests and steals eggs for food while\n" + "the parents are away."); + +static const u8 DexDescription_Teddiursa_1[] = _( + "This POKéMON likes to lick its palms that\n" + "are sweetened by being soaked in honey.\n" + "TEDDIURSA concocts its own honey by"); +static const u8 DexDescription_Teddiursa_2[] = _( + "blending fruits and pollen collected by\n" + "BEEDRILL."); + +static const u8 DexDescription_Ursaring_1[] = _( + "In the forests inhabited by URSARING,\n" + "it is said that there are many streams\n" + "and towering trees where they"); +static const u8 DexDescription_Ursaring_2[] = _( + "gather food. This POKéMON walks\n" + "through its forest gathering food\n" + "every day."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Slugma_1[] = _( + "SLUGMA does not have any blood in its\n" + "body. Instead, intensely hot magma\n" + "circulates throughout this POKéMON’s"); +static const u8 DexDescription_Slugma_2[] = _( + "body, carrying essential nutrients and\n" + "oxygen to its organs."); +#else +static const u8 DexDescription_Slugma_1[] = _( + "Molten magma courses throughout\n" + "SLUGMA’s circulatory system.\n" + "If this POKéMON is chilled, the magma"); +static const u8 DexDescription_Slugma_2[] = _( + "cools and hardens. Its body turns\n" + "brittle and chunks fall off, reducing\n" + "its size."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Magcargo_1[] = _( + "MAGCARGO’s body temperature is\n" + "approximately 18,000 degrees F.\n" + "Water is vaporized on contact."); +static const u8 DexDescription_Magcargo_2[] = _( + "If this POKéMON is caught in the rain,\n" + "the raindrops instantly turn into\n" + "steam, cloaking the area in a thick fog."); +#else +static const u8 DexDescription_Magcargo_1[] = _( + "MAGCARGO’s shell is actually its skin\n" + "that hardened as a result of cooling.\n" + "Its shell is very brittle and fragile -"); +static const u8 DexDescription_Magcargo_2[] = _( + "just touching it causes it to crumble\n" + "apart. This POKéMON returns to its\n" + "original size by dipping itself in magma."); +#endif + +static const u8 DexDescription_Swinub_1[] = _( + "SWINUB roots for food by rubbing its\n" + "snout against the ground. Its favorite\n" + "food is a mushroom that grows under"); +static const u8 DexDescription_Swinub_2[] = _( + "the cover of dead grass.\n" + "This POKéMON occasionally roots out\n" + "hot springs."); + +static const u8 DexDescription_Piloswine_1[] = _( + "PILOSWINE is covered by a thick coat\n" + "of long hair that enables it to endure\n" + "the freezing cold."); +static const u8 DexDescription_Piloswine_2[] = _( + "This POKéMON uses its tusks to dig up\n" + "food that has been buried under ice."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Corsola_1[] = _( + "Clusters of CORSOLA congregate in warm\n" + "seas where they serve as ideal hiding\n" + "places for smaller POKéMON."); +static const u8 DexDescription_Corsola_2[] = _( + "When the water temperature falls, this\n" + "POKéMON migrates to the southern seas."); +#else +static const u8 DexDescription_Corsola_1[] = _( + "CORSOLA’s branches glitter very\n" + "beautifully in seven colors when they\n" + "catch sunlight."); +static const u8 DexDescription_Corsola_2[] = _( + "If any branch breaks off, this POKéMON\n" + "grows it back in just one night."); +#endif + +static const u8 DexDescription_Remoraid_1[] = _( + "REMORAID sucks in water, then expels it\n" + "at high velocity using its abdominal\n" + "muscles to shoot down flying prey."); +static const u8 DexDescription_Remoraid_2[] = _( + "When evolution draws near, this POKéMON\n" + "travels downstream from rivers."); + +static const u8 DexDescription_Octillery_1[] = _( + "OCTILLERY grabs onto its foe using\n" + "its tentacles. This POKéMON tries to\n" + "immobilize it before delivering the"); +static const u8 DexDescription_Octillery_2[] = _( + "finishing blow.\n" + "If the foe turns out to be too strong,\n" + "OCTILLERY spews ink to escape."); + +static const u8 DexDescription_Delibird_1[] = _( + "DELIBIRD carries its food bundled up\n" + "in its tail. There once was a famous\n" + "explorer who managed to reach the peak"); +static const u8 DexDescription_Delibird_2[] = _( + "of Mt. Everest thanks to one of these\n" + "POKéMON sharing its food."); + +static const u8 DexDescription_Mantine_1[] = _( + "On sunny days, schools of MANTINE can\n" + "be seen elegantly leaping over the\n" + "sea’s waves."); +static const u8 DexDescription_Mantine_2[] = _( + "This POKéMON is not bothered by the\n" + "REMORAID that hitches rides."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Skarmory_1[] = _( + "SKARMORY’s steel wings become tattered\n" + "and bashed in from repeated battles.\n" + "Once a year, the battered wings grow"); +static const u8 DexDescription_Skarmory_2[] = _( + "back completely, restoring the cutting\n" + "edges to their pristine state."); +#else +static const u8 DexDescription_Skarmory_1[] = _( + "SKARMORY is entirely encased in hard,\n" + "protective armor. This POKéMON flies at\n" + "close to 190 mph."); +static const u8 DexDescription_Skarmory_2[] = _( + "It slashes foes with its wings that\n" + "possess swordlike cutting edges."); +#endif + +static const u8 DexDescription_Houndour_1[] = _( + "HOUNDOUR hunt as a coordinated pack.\n" + "They communicate with each other using\n" + "a variety of cries to corner their prey."); +static const u8 DexDescription_Houndour_2[] = _( + "This POKéMON’s remarkable teamwork is\n" + "unparalleled."); + +static const u8 DexDescription_Houndoom_1[] = _( + "In a HOUNDOOM pack, the one with its\n" + "horns raked sharply towards the back\n" + "serves a leadership role."); +static const u8 DexDescription_Houndoom_2[] = _( + "These POKéMON choose their leader by\n" + "fighting amongst themselves."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Kingdra_1[] = _( + "KINGDRA sleeps on the seafloor where\n" + "it is otherwise devoid of life.\n" + "When a storm arrives, the POKéMON is"); +static const u8 DexDescription_Kingdra_2[] = _( + "said to awaken and wander about in\n" + "search of prey."); +#else +static const u8 DexDescription_Kingdra_1[] = _( + "KINGDRA lives at extreme ocean depths\n" + "that are otherwise uninhabited.\n" + "It has long been believed that the"); +static const u8 DexDescription_Kingdra_2[] = _( + "yawning of this POKéMON creates\n" + "spiraling ocean currents."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Phanpy_1[] = _( + "PHANPY uses its long nose to shower\n" + "itself. When others gather around, they\n" + "thoroughly douse each other with water."); +static const u8 DexDescription_Phanpy_2[] = _( + "These POKéMON can be seen drying their\n" + "soaking-wet bodies at the edge of\n" + "water."); +#else +static const u8 DexDescription_Phanpy_1[] = _( + "For its nest, PHANPY digs a vertical pit \n" + "in the ground at the edge of a river.\n" + "It marks the area around its nest with"); +static const u8 DexDescription_Phanpy_2[] = _( + "its trunk to let the others know that\n" + "the area has been claimed."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Donphan_1[] = _( + "If DONPHAN were to tackle with its hard\n" + "body, even a house could be destroyed.\n" + "Using its massive strength, the"); +static const u8 DexDescription_Donphan_2[] = _( + "POKéMON helps clear rock and mud slides\n" + "that block mountain trails."); +#else +static const u8 DexDescription_Donphan_1[] = _( + "DONPHAN’s favorite attack is curling\n" + "its body into a ball, then charging at\n" + "its foe while rolling at high speed."); +static const u8 DexDescription_Donphan_2[] = _( + "Once it starts rolling, this POKéMON\n" + "can’t stop very easily."); +#endif + +static const u8 DexDescription_Porygon2_1[] = _( + "PORYGON2 was created by humans using\n" + "the power of science. The man-made\n" + "POKéMON has been endowed with"); +static const u8 DexDescription_Porygon2_2[] = _( + "artificial intelligence that enables it\n" + "to learn new gestures and emotions\n" + "on its own."); + +static const u8 DexDescription_Stantler_1[] = _( + "STANTLER’s magnificent antlers were\n" + "traded at high prices as works of art.\n" + "As a result, this POKéMON was hunted"); +static const u8 DexDescription_Stantler_2[] = _( + "close to extinction by those who were\n" + "after the priceless antlers."); + +static const u8 DexDescription_Smeargle_1[] = _( + "SMEARGLE marks the boundaries of its\n" + "territory using a body fluid that leaks\n" + "out from the tip of its tail."); +static const u8 DexDescription_Smeargle_2[] = _( + "Over 5,000 different marks left by this\n" + "POKéMON have been found."); + +static const u8 DexDescription_Tyrogue_1[] = _( + "TYROGUE becomes stressed out if it\n" + "does not get to train every day.\n" + "When raising this POKéMON, the TRAINER"); +static const u8 DexDescription_Tyrogue_2[] = _( + "must establish and uphold various\n" + "training methods."); + +static const u8 DexDescription_Hitmontop_1[] = _( + "HITMONTOP spins on its head at high\n" + "speed, all the while delivering kicks.\n" + "This technique is a remarkable mix of"); +static const u8 DexDescription_Hitmontop_2[] = _( + "both offense and defense at the same\n" + "time. The POKéMON travels faster\n" + "spinning than it does walking."); + +static const u8 DexDescription_Smoochum_1[] = _( + "SMOOCHUM actively runs about, but\n" + "also falls quite often.\n" + "Whenever the chance arrives, it will"); +static const u8 DexDescription_Smoochum_2[] = _( + "look for its reflection to make sure its\n" + "face hasn’t become dirty."); + +static const u8 DexDescription_Elekid_1[] = _( + "ELEKID stores electricity in its body.\n" + "If it touches metal and accidentally\n" + "discharges all its built-up electricity,"); +static const u8 DexDescription_Elekid_2[] = _( + "this POKéMON begins swinging its arms\n" + "in circles to recharge itself."); + +static const u8 DexDescription_Magby_1[] = _( + "MAGBY’s state of health is determined\n" + "by observing the fire it breathes.\n" + "If the POKéMON is spouting yellow"); +static const u8 DexDescription_Magby_2[] = _( + "flames from its mouth, it is in good\n" + "health. When it is fatigued, black smoke\n" + "will be mixed in with the flames."); + +static const u8 DexDescription_Miltank_1[] = _( + "MILTANK gives over five gallons of milk\n" + "on a daily basis. Its sweet milk is\n" + "enjoyed by children and grown-ups alike."); +static const u8 DexDescription_Miltank_2[] = _( + "People who can’t drink milk turn it into\n" + "yogurt and eat it instead."); + +static const u8 DexDescription_Blissey_1[] = _( + "BLISSEY senses sadness with its fluffy\n" + "coat of fur. If it does so, this POKéMON\n" + "will rush over to the sad person,"); +static const u8 DexDescription_Blissey_2[] = _( + "however far they may be, to share an\n" + "egg of happiness that brings a smile\n" + "to any face."); + +static const u8 DexDescription_Raikou_1[] = _( + "RAIKOU embodies the speed of lightning.\n" + "The roars of this POKéMON send shock\n" + "waves shuddering through the air and"); +static const u8 DexDescription_Raikou_2[] = _( + "shake the ground as if lightning bolts\n" + "had come crashing down."); + +static const u8 DexDescription_Entei_1[] = _( + "ENTEI embodies the passion of magma.\n" + "This POKéMON is thought to have been\n" + "born in the eruption of a volcano."); +static const u8 DexDescription_Entei_2[] = _( + "It sends up massive bursts of fire that\n" + "utterly consume all that they touch."); + +static const u8 DexDescription_Suicune_1[] = _( + "SUICUNE embodies the compassion of\n" + "a pure spring of water. It runs across\n" + "the land with gracefulness."); +static const u8 DexDescription_Suicune_2[] = _( + "This POKéMON has the power to purify\n" + "dirty water."); + +static const u8 DexDescription_Larvitar_1[] = _( + "LARVITAR is born deep under the ground.\n" + "To come up to the surface, this POKéMON\n" + "must eat its way through the soil above."); +static const u8 DexDescription_Larvitar_2[] = _( + "Until it does so, LARVITAR cannot see\n" + "its parent’s face."); + +static const u8 DexDescription_Pupitar_1[] = _( + "PUPITAR creates a gas inside its body\n" + "that it compresses and forcefully\n" + "ejects to propel itself like a jet."); +static const u8 DexDescription_Pupitar_2[] = _( + "The body is very durable - it avoids\n" + "damage even if it hits solid steel."); + +static const u8 DexDescription_Tyranitar_1[] = _( + "TYRANITAR is so overwhelmingly\n" + "powerful, it can bring down a whole\n" + "mountain to make its nest."); +static const u8 DexDescription_Tyranitar_2[] = _( + "This POKéMON wanders about in\n" + "mountains seeking new opponents to\n" + "fight."); + +static const u8 DexDescription_Lugia_1[] = _( + "LUGIA’s wings pack devastating power -\n" + "a light fluttering of its wings can blow\n" + "apart regular houses."); +static const u8 DexDescription_Lugia_2[] = _( + "As a result, this POKéMON chooses to\n" + "live out of sight deep under the sea."); + +static const u8 DexDescription_HoOh_1[] = _( + "HO-OH’s feathers glow in seven colors\n" + "depending on the angle at which they\n" + "are struck by light."); +static const u8 DexDescription_HoOh_2[] = _( + "These feathers are said to bring\n" + "happiness to the bearers. This POKéMON\n" + "is said to live at the foot of a rainbow."); + +static const u8 DexDescription_Celebi_1[] = _( + "This POKéMON came from the future by\n" + "crossing over time.\n" + "It is thought that so long as CELEBI"); +static const u8 DexDescription_Celebi_2[] = _( + "appears, a bright and shining future\n" + "awaits us."); + +#ifdef SAPPHIRE +static const u8 DexDescription_Treecko_1[] = _( + "TREECKO is cool, calm, and collected -\n" + "it never panics under any situation.\n" + "If a bigger foe were to glare at this"); +static const u8 DexDescription_Treecko_2[] = _( + "POKéMON, it would glare right back\n" + "without conceding an inch of ground."); +#else +static const u8 DexDescription_Treecko_1[] = _( + "TREECKO has small hooks on the bottom\n" + "of its feet that enable it to scale\n" + "vertical walls."); +static const u8 DexDescription_Treecko_2[] = _( + "This POKéMON attacks by slamming foes\n" + "with its thick tail."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Grovyle_1[] = _( + "This POKéMON adeptly flies from branch\n" + "to branch in trees.\n" + "In a forest, no POKéMON can ever hope"); +static const u8 DexDescription_Grovyle_2[] = _( + "to catch a fleeing GROVYLE however\n" + "fast they may be."); +#else +static const u8 DexDescription_Grovyle_1[] = _( + "The leaves growing out of GROVYLE’s\n" + "body are convenient for camouflaging\n" + "it from enemies in the forest."); +static const u8 DexDescription_Grovyle_2[] = _( + "This POKéMON is a master at climbing\n" + "trees in jungles."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Sceptile_1[] = _( + "SCEPTILE has seeds growing on its back.\n" + "They are said to be bursting with\n" + "nutrients that revitalize trees."); +static const u8 DexDescription_Sceptile_2[] = _( + "This POKéMON raises the trees in a\n" + "forest with loving care."); +#else +static const u8 DexDescription_Sceptile_1[] = _( + "The leaves growing on SCEPTILE’s body\n" + "are very sharp edged. This POKéMON is\n" + "very agile - it leaps all over the"); +static const u8 DexDescription_Sceptile_2[] = _( + "branches of trees and jumps on its foe\n" + "from above or behind."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Torchic_1[] = _( + "TORCHIC has a place inside its body\n" + "where it keeps its flame. Give it a hug -\n" + "it will be glowing with warmth."); +static const u8 DexDescription_Torchic_2[] = _( + "This POKéMON is covered all over by a\n" + "fluffy coat of down."); +#else +static const u8 DexDescription_Torchic_1[] = _( + "TORCHIC sticks with its TRAINER,\n" + "following behind with unsteady\n" + "steps."); +static const u8 DexDescription_Torchic_2[] = _( + "This POKéMON breathes fire of over\n" + "1,800 degrees F, including fireballs\n" + "that leave the foe scorched black."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Combusken_1[] = _( + "COMBUSKEN battles with the intensely\n" + "hot flames it spews from its beak and\n" + "with outstandingly destructive kicks."); +static const u8 DexDescription_Combusken_2[] = _( + "This POKéMON’s cry is very loud and\n" + "distracting."); +#else +static const u8 DexDescription_Combusken_1[] = _( + "COMBUSKEN toughens up its legs and\n" + "thighs by running through fields and\n" + "mountains."); +static const u8 DexDescription_Combusken_2[] = _( + "This POKéMON’s legs possess both speed\n" + "and power, enabling it to dole out ten\n" + "kicks in one second."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Blaziken_1[] = _( + "BLAZIKEN has incredibly strong legs -\n" + "it can easily clear a 30-story building\n" + "in one leap."); +static const u8 DexDescription_Blaziken_2[] = _( + "This POKéMON’s blazing punches leave\n" + "its foes scorched and blackened."); +#else +static const u8 DexDescription_Blaziken_1[] = _( + "In battle, BLAZIKEN blows out intense\n" + "flames from its wrists and attacks foes\n" + "courageously."); +static const u8 DexDescription_Blaziken_2[] = _( + "The stronger the foe, the more\n" + "intensely this POKéMON’s wrists burn."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Mudkip_1[] = _( + "In water, MUDKIP breathes using the\n" + "gills on its cheeks.\n" + "If it is faced with a tight situation in"); +static const u8 DexDescription_Mudkip_2[] = _( + "battle, this POKéMON will unleash its\n" + "amazing power - it can crush rocks\n" + "bigger than itself."); +#else +static const u8 DexDescription_Mudkip_1[] = _( + "The fin on MUDKIP’s head acts as highly\n" + "sensitive radar. Using this fin to sense\n" + "movements of water and air, this"); +static const u8 DexDescription_Mudkip_2[] = _( + "POKéMON can determine what is taking\n" + "place around it without using its eyes."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Marshtomp_1[] = _( + "MARSHTOMP is much faster at traveling\n" + "through mud than it is at swimming.\n" + "This POKéMON’s hindquarters exhibit"); +static const u8 DexDescription_Marshtomp_2[] = _( + "obvious development, giving it the\n" + "ability to walk on just its hind legs."); +#else +static const u8 DexDescription_Marshtomp_1[] = _( + "The surface of MARSHTOMP’s body is\n" + "enveloped by a thin, sticky film that\n" + "enables it to live on land."); +static const u8 DexDescription_Marshtomp_2[] = _( + "This POKéMON plays in mud on beaches\n" + "when the ocean tide is low."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Swampert_1[] = _( + "SWAMPERT predicts storms by sensing\n" + "subtle differences in the sounds of\n" + "waves and tidal winds with its fins."); +static const u8 DexDescription_Swampert_2[] = _( + "If a storm is approaching, it piles up\n" + "boulders to protect itself."); +#else +static const u8 DexDescription_Swampert_1[] = _( + "SWAMPERT is very strong. It has enough\n" + "power to easily drag a boulder weighing\n" + "more than a ton."); +static const u8 DexDescription_Swampert_2[] = _( + "This POKéMON also has powerful vision\n" + "that lets it see even in murky water."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Poochyena_1[] = _( + "POOCHYENA is an omnivore - it will eat\n" + "anything. A distinguishing feature is\n" + "how large its fangs are compared to"); +static const u8 DexDescription_Poochyena_2[] = _( + "its body. This POKéMON tries to\n" + "intimidate its foes by making the hair\n" + "on its tail bristle out."); +#else +static const u8 DexDescription_Poochyena_1[] = _( + "At first sight, POOCHYENA takes a bite\n" + "at anything that moves.\n" + "This POKéMON chases after prey until"); +static const u8 DexDescription_Poochyena_2[] = _( + "the victim becomes exhausted.\n" + "However, it may turn tail if the prey\n" + "strikes back."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Mightyena_1[] = _( + "MIGHTYENA travel and act as a pack\n" + "in the wild. The memory of its life in the\n" + "wild compels the POKéMON to obey only"); +static const u8 DexDescription_Mightyena_2[] = _( + "those TRAINERS that it recognizes to\n" + "possess superior skill."); +#else +static const u8 DexDescription_Mightyena_1[] = _( + "MIGHTYENA gives obvious signals when\n" + "it is preparing to attack. It starts to\n" + "growl deeply and then flattens its body."); +static const u8 DexDescription_Mightyena_2[] = _( + "This POKéMON will bite savagely with its\n" + "sharply pointed fangs."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Zigzagoon_1[] = _( + "The hair on ZIGZAGOON’s back is \n" + "bristly. It rubs the hard back hair\n" + "against trees to leave its territorial"); +static const u8 DexDescription_Zigzagoon_2[] = _( + "markings.\n" + "This POKéMON may play dead to fool foes\n" + "in battle."); +#else +static const u8 DexDescription_Zigzagoon_1[] = _( + "ZIGZAGOON restlessly wanders\n" + "everywhere at all times. This POKéMON\n" + "does so because it is very curious."); +static const u8 DexDescription_Zigzagoon_2[] = _( + "It becomes interested in anything\n" + "that it happens to see."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Linoone_1[] = _( + "When hunting, LINOONE will make a\n" + "beeline straight for the prey at a full\n" + "run. While this POKéMON is capable of"); +static const u8 DexDescription_Linoone_2[] = _( + "topping 60 mph, it has to come to a\n" + "screeching halt before it can turn."); +#else +static const u8 DexDescription_Linoone_1[] = _( + "LINOONE always runs full speed and only\n" + "in straight lines. If facing an obstacle,\n" + "it makes a right-angle turn to evade it."); +static const u8 DexDescription_Linoone_2[] = _( + "This POKéMON is very challenged by\n" + "gently curving roads."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Wurmple_1[] = _( + "WURMPLE is targeted by SWELLOW as\n" + "prey. This POKéMON will try to resist by\n" + "pointing the spikes on its rear at the"); +static const u8 DexDescription_Wurmple_2[] = _( + "attacking predator.\n" + "It will weaken the foe by leaking poison\n" + "from the spikes."); +#else +static const u8 DexDescription_Wurmple_1[] = _( + "Using the spikes on its rear end, \n" + "WURMPLE peels the bark off trees and\n" + "feeds on the sap that oozes out."); +static const u8 DexDescription_Wurmple_2[] = _( + "This POKéMON’s feet are tipped with\n" + "suction pads that allow it to cling to\n" + "glass without slipping."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Silcoon_1[] = _( + "SILCOON was thought to endure hunger\n" + "and not consume anything before its\n" + "evolution. However, it is now thought"); +static const u8 DexDescription_Silcoon_2[] = _( + "that this POKéMON slakes its thirst by\n" + "drinking rainwater that collects on its\n" + "silk."); +#else +static const u8 DexDescription_Silcoon_1[] = _( + "SILCOON tethers itself to a tree branch\n" + "using silk to keep from falling. There, \n" + "this POKéMON hangs quietly while it"); +static const u8 DexDescription_Silcoon_2[] = _( + "awaits evolution.\n" + "It peers out of the silk cocoon through\n" + "a small hole."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Beautifly_1[] = _( + "BEAUTIFLY has a long mouth like a coiled\n" + "needle, which is very convenient for\n" + "collecting pollen from flowers."); +static const u8 DexDescription_Beautifly_2[] = _( + "This POKéMON rides the spring winds as\n" + "it flits around gathering pollen."); +#else +static const u8 DexDescription_Beautifly_1[] = _( + "BEAUTIFLY’s favorite food is the sweet\n" + "pollen of flowers. If you want to see\n" + "this POKéMON, just leave a potted"); +static const u8 DexDescription_Beautifly_2[] = _( + "flower by an open window. BEAUTIFLY\n" + "is sure to come looking for pollen."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Cascoon_1[] = _( + "If it is attacked, CASCOON remains\n" + "motionless however badly it may be\n" + "hurt. It does so because if it were to"); +static const u8 DexDescription_Cascoon_2[] = _( + "move, its body would be weak upon\n" + "evolution. This POKéMON will also not\n" + "forget the pain it endured."); +#else +static const u8 DexDescription_Cascoon_1[] = _( + "CASCOON makes its protective cocoon\n" + "by wrapping its body entirely with a\n" + "fine silk from its mouth. Once the silk"); +static const u8 DexDescription_Cascoon_2[] = _( + "goes around its body, it hardens.\n" + "This POKéMON prepares for its evolution\n" + "inside the cocoon."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Dustox_1[] = _( + "When DUSTOX flaps its wings, a fine\n" + "dust is scattered all over. This dust is\n" + "actually a powerful poison that will"); +static const u8 DexDescription_Dustox_2[] = _( + "even make a pro wrestler sick.\n" + "This POKéMON searches for food using\n" + "its antennae like radar."); +#else +static const u8 DexDescription_Dustox_1[] = _( + "DUSTOX is instinctively drawn to light.\n" + "Swarms of this POKéMON are attracted\n" + "by the bright lights of cities, where"); +static const u8 DexDescription_Dustox_2[] = _( + "they wreak havoc by stripping the\n" + "leaves off roadside trees for food."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Lotad_1[] = _( + "LOTAD is said to have dwelled on land\n" + "before. However, this POKéMON is\n" + "thought to have returned to water"); +static const u8 DexDescription_Lotad_2[] = _( + "because the leaf on its head grew large\n" + "and heavy. It now lives by floating\n" + "atop the water."); +#else +static const u8 DexDescription_Lotad_1[] = _( + "LOTAD live in ponds and lakes, where\n" + "they float on the surface.\n" + "It grows weak if its broad leaf dies."); +static const u8 DexDescription_Lotad_2[] = _( + "On rare occasions, this POKéMON travels\n" + "on land in search of clean water."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Lombre_1[] = _( + "LOMBRE’s entire body is covered by a\n" + "slippery, slimy film. It feels horribly\n" + "unpleasant to be touched by this"); +static const u8 DexDescription_Lombre_2[] = _( + "POKéMON’s hands.\n" + "LOMBRE is often mistaken for a human\n" + "child."); +#else +static const u8 DexDescription_Lombre_1[] = _( + "LOMBRE is nocturnal - it will get active\n" + "after dusk. It is also a mischief-maker.\n" + "When this POKéMON spots anglers,"); +static const u8 DexDescription_Lombre_2[] = _( + "it tugs on their fishing lines from\n" + "beneath the surface and enjoys their\n" + "consternation."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Ludicolo_1[] = _( + "Upon hearing an upbeat and cheerful\n" + "rhythm, the cells in LUDICOLO’s body\n" + "become very energetic and active."); +static const u8 DexDescription_Ludicolo_2[] = _( + "Even in battle, this POKéMON will\n" + "exhibit an amazing amount of power."); +#else +static const u8 DexDescription_Ludicolo_1[] = _( + "LUDICOLO begins dancing as soon as\n" + "it hears cheerful, festive music.\n" + "This POKéMON is said to appear when it"); +static const u8 DexDescription_Ludicolo_2[] = _( + "hears the singing of children on hiking\n" + "outings."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Seedot_1[] = _( + "SEEDOT looks exactly like an acorn\n" + "when it is dangling from a tree branch.\n" + "It startles other POKéMON by suddenly"); +static const u8 DexDescription_Seedot_2[] = _( + "moving.\n" + "This POKéMON polishes its body once a\n" + "day using leaves."); +#else +static const u8 DexDescription_Seedot_1[] = _( + "SEEDOT attaches itself to a tree\n" + "branch using the top of its head.\n" + "It sucks moisture from the tree while"); +static const u8 DexDescription_Seedot_2[] = _( + "hanging off the branch.\n" + "The more water it drinks, the glossier\n" + "this POKéMON’s body becomes."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Nuzleaf_1[] = _( + "This POKéMON pulls out the leaf on its\n" + "head and makes a flute with it.\n" + "The sound of NUZLEAF’s flute strikes"); +static const u8 DexDescription_Nuzleaf_2[] = _( + "fear and uncertainty in the hearts of\n" + "people lost in a forest."); +#else +static const u8 DexDescription_Nuzleaf_1[] = _( + "NUZLEAF live in densely overgrown\n" + "forests. They occasionally venture out\n" + "of the forest to startle people."); +static const u8 DexDescription_Nuzleaf_2[] = _( + "This POKéMON dislikes having its long\n" + "nose pinched."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Shiftry_1[] = _( + "SHIFTRY’s large fans generate awesome\n" + "gusts of wind at a speed close to 100\n" + "feet per second. The whipped-up wind"); +static const u8 DexDescription_Shiftry_2[] = _( + "blows anything away.\n" + "This POKéMON chooses to live quietly\n" + "deep in forests."); +#else +static const u8 DexDescription_Shiftry_1[] = _( + "SHIFTRY is a mysterious POKéMON that\n" + "is said to live atop towering trees \n" + "dating back over a thousand years."); +static const u8 DexDescription_Shiftry_2[] = _( + "It creates terrific windstorms with\n" + "the fans it holds."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Taillow_1[] = _( + "TAILLOW is young - it has only just\n" + "left its nest. As a result, it sometimes\n" + "becomes lonesome and cries at night."); +static const u8 DexDescription_Taillow_2[] = _( + "This POKéMON feeds on WURMPLE that\n" + "live in forests."); +#else +static const u8 DexDescription_Taillow_1[] = _( + "TAILLOW courageously stands its\n" + "ground against foes, however strong\n" + "they may be."); +static const u8 DexDescription_Taillow_2[] = _( + "This gutsy POKéMON will remain defiant\n" + "even after a loss. On the other hand,\n" + "it cries loudly if it becomes hungry."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Swellow_1[] = _( + "SWELLOW is very conscientious about\n" + "the upkeep of its glossy wings.\n" + "Once two SWELLOW are gathered, they"); +static const u8 DexDescription_Swellow_2[] = _( + "diligently take care of cleaning each\n" + "other’s wings."); +#else +static const u8 DexDescription_Swellow_1[] = _( + "SWELLOW flies high above our heads,\n" + "making graceful arcs in the sky.\n" + "This POKéMON dives at a steep angle as"); +static const u8 DexDescription_Swellow_2[] = _( + "soon as it spots its prey. The hapless\n" + "prey is tightly grasped by SWELLOW’s\n" + "clawed feet, preventing escape."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Wingull_1[] = _( + "WINGULL rides updrafts rising from the\n" + "sea by extending its long and narrow\n" + "wings to glide."); +static const u8 DexDescription_Wingull_2[] = _( + "This POKéMON’s long beak is useful for\n" + "catching prey."); +#else +static const u8 DexDescription_Wingull_1[] = _( + "WINGULL has the habit of carrying prey\n" + "and valuables in its beak and hiding\n" + "them in all sorts of locations."); +static const u8 DexDescription_Wingull_2[] = _( + "This POKéMON rides the winds and flies\n" + "as if it were skating across the sky."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Pelipper_1[] = _( + "PELIPPER searches for food while in\n" + "flight by skimming the wave tops.\n" + "This POKéMON dips its large bill in the"); +static const u8 DexDescription_Pelipper_2[] = _( + "sea to scoop up food, then swallows\n" + "everything in one big gulp."); +#else +static const u8 DexDescription_Pelipper_1[] = _( + "PELIPPER is a flying transporter that\n" + "carries small POKéMON and eggs inside\n" + "its massive bill."); +static const u8 DexDescription_Pelipper_2[] = _( + "This POKéMON builds its nest on steep\n" + "cliffs facing the sea."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Ralts_1[] = _( + "RALTS has the ability to sense the\n" + "emotions of people.\n" + "If its TRAINER is in a cheerful mood,"); +static const u8 DexDescription_Ralts_2[] = _( + "this POKéMON grows cheerful and joyous\n" + "in the same way."); +#else +static const u8 DexDescription_Ralts_1[] = _( + "RALTS senses the emotions of\n" + "people using the horns on its head.\n" + "This POKéMON rarely appears before"); +static const u8 DexDescription_Ralts_2[] = _( + "people. But when it does, it draws\n" + "closer if it senses that the person has\n" + "a positive disposition."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Kirlia_1[] = _( + "KIRLIA uses the horns on its head\n" + "to amplify its psychokinetic power.\n" + "When the POKéMON uses its power,"); +static const u8 DexDescription_Kirlia_2[] = _( + "the air around it becomes distorted,\n" + "creating mirages of nonexistent\n" + "scenery."); +#else +static const u8 DexDescription_Kirlia_1[] = _( + "It is said that a KIRLIA that is\n" + "exposed to the positive emotions of\n" + "its TRAINER grows beautiful."); +static const u8 DexDescription_Kirlia_2[] = _( + "This POKéMON controls psychokinetic\n" + "powers with its highly developed brain."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Gardevoir_1[] = _( + "GARDEVOIR has the psychokinetic\n" + "power to distort the dimensions and\n" + "create a small black hole."); +static const u8 DexDescription_Gardevoir_2[] = _( + "This POKéMON will try to protect its\n" + "TRAINER even at the risk of its own\n" + "life."); +#else +static const u8 DexDescription_Gardevoir_1[] = _( + "GARDEVOIR has the ability to read the\n" + "future. If it senses impending danger\n" + "to its TRAINER, this POKéMON is said to"); +static const u8 DexDescription_Gardevoir_2[] = _( + "unleash its psychokinetic energy at\n" + "full power."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Surskit_1[] = _( + "If SURSKIT senses danger, it secretes\n" + "a thick, sugary syrup from the tip of\n" + "its head."); +static const u8 DexDescription_Surskit_2[] = _( + "There are some POKéMON that love\n" + "eating this syrup."); +#else +static const u8 DexDescription_Surskit_1[] = _( + "From the tips of its feet, SURSKIT\n" + "secretes an oil that enables it to walk\n" + "on water as if it were skating."); +static const u8 DexDescription_Surskit_2[] = _( + "This POKéMON feeds on microscopic\n" + "organisms in ponds and lakes."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Masquerain_1[] = _( + "MASQUERAIN’s antennas have eyelike\n" + "patterns that usually give it an angry\n" + "look. If the “eyes” are droopy and"); +static const u8 DexDescription_Masquerain_2[] = _( + "appear sad, it is said to be a sign\n" + "that a heavy rainfall is on its way."); +#else +static const u8 DexDescription_Masquerain_1[] = _( + "MASQUERAIN intimidates enemies with\n" + "the eyelike patterns on its antennas.\n" + "This POKéMON flaps its four wings to"); +static const u8 DexDescription_Masquerain_2[] = _( + "freely fly in any direction - even\n" + "sideways and backwards - as if it were\n" + "a helicopter."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Shroomish_1[] = _( + "If SHROOMISH senses danger, it shakes\n" + "its body and scatters spores from the\n" + "top of its head."); +static const u8 DexDescription_Shroomish_2[] = _( + "This POKéMON’s spores are so toxic,\n" + "they make trees and weeds wilt."); +#else +static const u8 DexDescription_Shroomish_1[] = _( + "SHROOMISH live in damp soil in the dark\n" + "depths of forests. They are often\n" + "found keeping still under fallen leaves."); +static const u8 DexDescription_Shroomish_2[] = _( + "This POKéMON feeds on compost that\n" + "is made up of fallen, rotted leaves."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Breloom_1[] = _( + "The seeds ringing BRELOOM’s tail are\n" + "made of hardened toxic spores. It is\n" + "horrible to eat the seeds."); +static const u8 DexDescription_Breloom_2[] = _( + "Just taking a bite of this POKéMON’s\n" + "seed will cause your stomach to rumble."); +#else +static const u8 DexDescription_Breloom_1[] = _( + "BRELOOM closes in on its foe with light\n" + "and sprightly footwork, then throws\n" + "punches with its stretchy arms."); +static const u8 DexDescription_Breloom_2[] = _( + "This POKéMON’s fighting technique puts\n" + "boxers to shame."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Slakoth_1[] = _( + "SLAKOTH’s heart beats just once a\n" + "minute. Whatever happens, it is\n" + "content to loaf around motionless."); +static const u8 DexDescription_Slakoth_2[] = _( + "It is rare to see this POKéMON in\n" + "motion."); +#else +static const u8 DexDescription_Slakoth_1[] = _( + "SLAKOTH lolls around for over twenty\n" + "hours every day. Because it moves so\n" + "little, it does not need much food."); +static const u8 DexDescription_Slakoth_2[] = _( + "This POKéMON’s sole daily meal consists\n" + "of just three leaves."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Vigoroth_1[] = _( + "VIGOROTH is simply incapable of\n" + "remaining still. Even when it tries to\n" + "sleep, the blood in its veins grows"); +static const u8 DexDescription_Vigoroth_2[] = _( + "agitated, compelling this POKéMON to\n" + "run wild throughout the jungle before\n" + "it can settle down."); +#else +static const u8 DexDescription_Vigoroth_1[] = _( + "VIGOROTH is always itching and agitated\n" + "to go on a wild rampage. It simply can’t\n" + "tolerate sitting still for even a minute."); +static const u8 DexDescription_Vigoroth_2[] = _( + "This POKéMON’s stress level rises if it\n" + "can’t be moving constantly."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Slaking_1[] = _( + "Wherever SLAKING live, rings of over\n" + "a yard in diameter appear in grassy\n" + "fields. They are made by the POKéMON"); +static const u8 DexDescription_Slaking_2[] = _( + "as it eats all the grass within reach\n" + "while lying prone on the ground."); +#else +static const u8 DexDescription_Slaking_1[] = _( + "SLAKING spends all day lying down and\n" + "lolling about.\n" + "It eats grass growing within its reach."); +static const u8 DexDescription_Slaking_2[] = _( + "If it eats all the grass it can reach,\n" + "this POKéMON reluctantly moves to\n" + "another spot."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Nincada_1[] = _( + "NINCADA lives underground. It uses its\n" + "sharp claws to carve the roots of trees\n" + "and absorb moisture and nutrients."); +static const u8 DexDescription_Nincada_2[] = _( + "This POKéMON can’t withstand bright\n" + "sunlight so avoids it."); +#else +static const u8 DexDescription_Nincada_1[] = _( + "NINCADA lives underground for many\n" + "years in complete darkness.\n" + "This POKéMON absorbs nutrients from"); +static const u8 DexDescription_Nincada_2[] = _( + "the roots of trees. It stays motionless\n" + "as it waits for evolution."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Ninjask_1[] = _( + "If NINJASK is not trained properly,\n" + "it will refuse to obey the TRAINER and\n" + "cry loudly continuously."); +static const u8 DexDescription_Ninjask_2[] = _( + "Because of this quality, this POKéMON\n" + "is said to be one that puts the\n" + "TRAINER’s abilities to the test."); +#else +static const u8 DexDescription_Ninjask_1[] = _( + "NINJASK moves around at such a high\n" + "speed that it cannot be seen, even\n" + "while its crying can be clearly heard."); +static const u8 DexDescription_Ninjask_2[] = _( + "For that reason, this POKéMON was long\n" + "believed to be invisible."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Shedinja_1[] = _( + "SHEDINJA is a peculiar POKéMON.\n" + "It seems to appear unsought in a POKé\n" + "BALL after a NINCADA evolves."); +static const u8 DexDescription_Shedinja_2[] = _( + "This bizarre POKéMON is entirely\n" + "immobile - it doesn’t even breathe."); +#else +static const u8 DexDescription_Shedinja_1[] = _( + "SHEDINJA’s hard body doesn’t move -\n" + "not even a twitch. In fact, its body\n" + "appears to be merely a hollow shell."); +static const u8 DexDescription_Shedinja_2[] = _( + "It is believed that this POKéMON will\n" + "steal the spirit of anyone peering into\n" + "its hollow body from its back."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Whismur_1[] = _( + "WHISMUR is very timid. If it starts to\n" + "cry loudly, it becomes startled by its\n" + "own crying and cries even harder."); +static const u8 DexDescription_Whismur_2[] = _( + "When it finally stops crying, the\n" + "POKéMON goes to sleep, all tired out."); +#else +static const u8 DexDescription_Whismur_1[] = _( + "Normally, WHISMUR’s voice is very quiet -\n" + "it is barely audible even if one is\n" + "paying close attention."); +static const u8 DexDescription_Whismur_2[] = _( + "However, if this POKéMON senses danger,\n" + "it starts crying at an earsplitting\n" + "volume."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Loudred_1[] = _( + "LOUDRED shouts while stamping its feet.\n" + "After it finishes shouting, this\n" + "POKéMON becomes incapable of hearing"); +static const u8 DexDescription_Loudred_2[] = _( + "anything for a while. This is considered\n" + "to be a weak point."); +#else +static const u8 DexDescription_Loudred_1[] = _( + "LOUDRED’s bellowing can completely\n" + "decimate a wood-frame house. It uses\n" + "its voice to punish its foes."); +static const u8 DexDescription_Loudred_2[] = _( + "This POKéMON’s round ears serve as\n" + "loudspeakers."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Exploud_1[] = _( + "EXPLOUD communicates its feelings to\n" + "the others by emitting whistle-like\n" + "sounds from the tubes on its body."); +static const u8 DexDescription_Exploud_2[] = _( + "This POKéMON only raises its voice when\n" + "it is in battle."); +#else +static const u8 DexDescription_Exploud_1[] = _( + "EXPLOUD triggers earthquakes with the\n" + "tremors it creates by bellowing. If this\n" + "POKéMON violently inhales from the"); +static const u8 DexDescription_Exploud_2[] = _( + "ports on its body, it’s a sign that it is\n" + "preparing to let loose a huge bellow."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Makuhita_1[] = _( + "MAKUHITA has a tireless spirit -\n" + "it will never give up hope. It eats a lot\n" + "of food, gets plenty of sleep, and it"); +static const u8 DexDescription_Makuhita_2[] = _( + "trains very rigorously. By living that\n" + "way, this POKéMON packs its body with\n" + "energy."); +#else +static const u8 DexDescription_Makuhita_1[] = _( + "MAKUHITA is tenacious - it will keep\n" + "getting up and attacking its foe\n" + "however many times it is knocked down."); +static const u8 DexDescription_Makuhita_2[] = _( + "Every time it gets back up, this\n" + "POKéMON stores more energy in its body\n" + "for evolving."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Hariyama_1[] = _( + "HARIYAMA’s thick body may appear fat,\n" + "but it is actually a hunk of solid muscle.\n" + "If this POKéMON bears down and"); +static const u8 DexDescription_Hariyama_2[] = _( + "tightens all its muscles, its body\n" + "becomes as hard as a rock."); +#else +static const u8 DexDescription_Hariyama_1[] = _( + "HARIYAMA practices its straight-arm\n" + "slaps in any number of locations.\n" + "One hit of this POKéMON’s powerful,"); +static const u8 DexDescription_Hariyama_2[] = _( + "openhanded, straight-arm punches\n" + "could snap a telephone pole in two."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Azurill_1[] = _( + "AZURILL’s tail is large and bouncy.\n" + "It is packed full of the nutrients this\n" + "POKéMON needs to grow."); +static const u8 DexDescription_Azurill_2[] = _( + "AZURILL can be seen bouncing and\n" + "playing on its big, rubbery tail."); +#else +static const u8 DexDescription_Azurill_1[] = _( + "AZURILL spins its tail as if it were a\n" + "lasso, then hurls it far. The momentum\n" + "of the throw sends its body flying, too."); +static const u8 DexDescription_Azurill_2[] = _( + "Using this unique action, one of these\n" + "POKéMON managed to hurl itself a record\n" + "33 feet."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Nosepass_1[] = _( + "NOSEPASS had been said to be completely\n" + "unmoving, with its magnetic nose\n" + "pointed due north."); +static const u8 DexDescription_Nosepass_2[] = _( + "However, close observation has revealed\n" + "that the POKéMON actually moves by a\n" + "little over 3/8 of an inch every year."); +#else +static const u8 DexDescription_Nosepass_1[] = _( + "NOSEPASS’s magnetic nose is always\n" + "pointed to the north. If two of these\n" + "POKéMON meet, they cannot turn"); +static const u8 DexDescription_Nosepass_2[] = _( + "their faces to each other when they\n" + "are close because their magnetic noses\n" + "repel one another."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Skitty_1[] = _( + "SKITTY is known to chase around\n" + "playfully after its own tail. In the wild,\n" + "this POKéMON lives in holes in the trees"); +static const u8 DexDescription_Skitty_2[] = _( + "of forests. It is very popular as a pet\n" + "because of its adorable looks."); +#else +static const u8 DexDescription_Skitty_1[] = _( + "SKITTY has the habit of becoming\n" + "fascinated by moving objects and\n" + "chasing them around."); +static const u8 DexDescription_Skitty_2[] = _( + "This POKéMON is known to chase after\n" + "its own tail and become dizzy."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Delcatty_1[] = _( + "DELCATTY sleeps anywhere it wants\n" + "without keeping a permanent nest.\n" + "If other POKéMON approach it as it"); +static const u8 DexDescription_Delcatty_2[] = _( + "sleeps, this POKéMON will never fight -\n" + "it will just move away somewhere else."); +#else +static const u8 DexDescription_Delcatty_1[] = _( + "DELCATTY prefers to live an unfettered\n" + "existence in which it can do as it\n" + "pleases at its own pace."); +static const u8 DexDescription_Delcatty_2[] = _( + "Because this POKéMON eats and sleeps\n" + "whenever it decides, its daily routines\n" + "are completely random."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Sableye_1[] = _( + "SABLEYE digs the ground with sharpened\n" + "claws to find rocks that it eats.\n" + "Substances in the eaten rocks"); +static const u8 DexDescription_Sableye_2[] = _( + "crystallize and rise up to the POKéMON’s\n" + "body surface."); +#else +static const u8 DexDescription_Sableye_1[] = _( + "SABLEYE lead quiet lives deep inside\n" + "caverns. They are feared, however,\n" + "because these POKéMON are thought to"); +static const u8 DexDescription_Sableye_2[] = _( + "steal the spirits of people when their\n" + "eyes burn with a sinister glow in the\n" + "darkness."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Mawile_1[] = _( + "Don’t be taken in by this POKéMON’s\n" + "cute face - it’s very dangerous. MAWILE\n" + "fools the foe into letting down its"); +static const u8 DexDescription_Mawile_2[] = _( + "guard, then chomps down with its\n" + "massive jaws. The steel jaws are really\n" + "horns that have been transformed."); +#else +#if REVISION >= 1 +static const u8 DexDescription_Mawile_1[] = _( + "MAWILE’s huge jaws are actually steel\n" + "horns that have been transformed.\n" + "Its docile-looking face serves to lull"); +static const u8 DexDescription_Mawile_2[] = _( + "its foe into letting down its guard.\n" + "When the foe least expects it, MAWILE\n" // Correct spelling of MAWILE + "chomps it with its gaping jaws."); +#else +static const u8 DexDescription_Mawile_1[] = _( + "MAWHILE’s huge jaws are actually steel\n" + "horns that have been transformed.\n" + "Its docile-looking face serves to lull"); +static const u8 DexDescription_Mawile_2[] = _( + "its foe into letting down its guard.\n" + "When the foe least expects it, MAWHILE\n" + "chomps it with its gaping jaws."); +#endif +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Aron_1[] = _( + "ARON has a body of steel.\n" + "With one all-out charge, this POKéMON\n" + "can demolish even a heavy dump truck."); +static const u8 DexDescription_Aron_2[] = _( + "The destroyed dump truck then becomes\n" + "a handy meal for the POKéMON."); +#else +static const u8 DexDescription_Aron_1[] = _( + "This POKéMON has a body of steel.\n" + "To make its body, ARON feeds on\n" + "iron ore that it digs from mountains."); +static const u8 DexDescription_Aron_2[] = _( + "Occasionally, it causes major trouble by\n" + "eating bridges and rails."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Lairon_1[] = _( + "LAIRON feeds on iron contained in\n" + "rocks and water. It makes its nest on\n" + "mountains where iron ore is buried."); +static const u8 DexDescription_Lairon_2[] = _( + "As a result, the POKéMON often clashes\n" + "with humans mining the iron ore."); +#else +static const u8 DexDescription_Lairon_1[] = _( + "LAIRON tempers its steel body by\n" + "drinking highly nutritious mineral\n" + "springwater until it is bloated."); +static const u8 DexDescription_Lairon_2[] = _( + "This POKéMON makes its nest close to\n" + "springs of delicious water."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Aggron_1[] = _( + "AGGRON is surprisingly protective\n" + "of its environment. If its mountain\n" + "is ravaged by a landslide or a fire, this"); +static const u8 DexDescription_Aggron_2[] = _( + "POKéMON will haul topsoil to the area,\n" + "plant trees, and beautifully restore its\n" + "own territory."); +#else +static const u8 DexDescription_Aggron_1[] = _( + "AGGRON claims an entire mountain as its\n" + "own territory. It mercilessly beats up\n" + "anything that violates its environment."); +static const u8 DexDescription_Aggron_2[] = _( + "This POKéMON vigilantly patrols its\n" + "territory at all times."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Meditite_1[] = _( + "MEDITITE heightens its inner energy\n" + "through meditation. It survives on\n" + "just one berry a day."); +static const u8 DexDescription_Meditite_2[] = _( + "Minimal eating is another aspect of\n" + "this POKéMON’s training."); +#else +static const u8 DexDescription_Meditite_1[] = _( + "MEDITITE undertakes rigorous mental\n" + "training deep in the mountains.\n" + "However, whenever it meditates, this"); +static const u8 DexDescription_Meditite_2[] = _( + "POKéMON always loses its concentration\n" + "and focus. As a result, its training\n" + "never ends."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Medicham_1[] = _( + "Through the power of meditation,\n" + "MEDICHAM developed its sixth sense.\n" + "It gained the ability to use"); +static const u8 DexDescription_Medicham_2[] = _( + "psychokinetic powers. This POKéMON is\n" + "known to meditate for a whole month\n" + "without eating."); +#else +static const u8 DexDescription_Medicham_1[] = _( + "It is said that through meditation,\n" + "MEDICHAM heightens energy inside\n" + "its body and sharpens its sixth sense."); +static const u8 DexDescription_Medicham_2[] = _( + "This POKéMON hides its presence by\n" + "merging itself with fields and\n" + "mountains."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Electrike_1[] = _( + "ELECTRIKE runs faster than the human\n" + "eye can follow. The friction from\n" + "running is converted into electricity,"); +static const u8 DexDescription_Electrike_2[] = _( + "which is then stored in this POKéMON’s\n" + "fur."); +#else +static const u8 DexDescription_Electrike_1[] = _( + "ELECTRIKE stores electricity in its\n" + "long body hair. This POKéMON stimulates\n" + "its leg muscles with electric charges."); +static const u8 DexDescription_Electrike_2[] = _( + "These jolts of power give its legs\n" + "explosive acceleration performance."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Manectric_1[] = _( + "MANECTRIC discharges strong\n" + "electricity from its mane. The mane is\n" + "used for collecting electricity in the"); +static const u8 DexDescription_Manectric_2[] = _( + "atmosphere. This POKéMON creates\n" + "thunderclouds above its head."); +#else +static const u8 DexDescription_Manectric_1[] = _( + "MANECTRIC is constantly discharging\n" + "electricity from its mane. The sparks\n" + "sometimes ignite forest fires."); +static const u8 DexDescription_Manectric_2[] = _( + "When it enters a battle, this POKéMON\n" + "creates thunderclouds."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Plusle_1[] = _( + "When PLUSLE is cheering on its partner,\n" + "it flashes with electric sparks from all\n" + "over its body."); +static const u8 DexDescription_Plusle_2[] = _( + "If its partner loses, this POKéMON cries\n" + "loudly."); +#else +static const u8 DexDescription_Plusle_1[] = _( + "PLUSLE always acts as a cheerleader\n" + "for its partners. Whenever a teammate\n" + "puts out a good effort in battle, this"); +static const u8 DexDescription_Plusle_2[] = _( + "POKéMON shorts out its body to create\n" + "the crackling noises of sparks to show\n" + "its joy."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Minun_1[] = _( + "MINUN loves to cheer on its partner in\n" + "battle. It gives off sparks from its\n" + "body while it is doing so."); +static const u8 DexDescription_Minun_2[] = _( + "If its partner is in trouble, this\n" + "POKéMON gives off increasing amounts\n" + "of sparks."); +#else +static const u8 DexDescription_Minun_1[] = _( + "MINUN is more concerned about cheering\n" + "on its partners than its own safety.\n" + "It shorts out the electricity in its"); +static const u8 DexDescription_Minun_2[] = _( + "body to create brilliant showers of\n" + "sparks to cheer on its teammates."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Volbeat_1[] = _( + "VOLBEAT’s tail glows like a lightbulb.\n" + "With other VOLBEAT, it uses its tail to\n" + "draw geometric shapes in the night sky."); +static const u8 DexDescription_Volbeat_2[] = _( + "This POKéMON loves the sweet aroma\n" + "given off by ILLUMISE."); +#else +static const u8 DexDescription_Volbeat_1[] = _( + "With the arrival of night, VOLBEAT emits\n" + "light from its tail. It communicates with\n" + "others by adjusting the intensity and"); +static const u8 DexDescription_Volbeat_2[] = _( + "flashing of its light.\n" + "This POKéMON is attracted by the sweet\n" + "aroma of ILLUMISE."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Illumise_1[] = _( + "ILLUMISE leads a flight of illuminated\n" + "VOLBEAT to draw signs in the night sky.\n" + "This POKéMON is said to earn greater"); +static const u8 DexDescription_Illumise_2[] = _( + "respect from its peers by composing\n" + "more complex designs in the sky."); +#else +static const u8 DexDescription_Illumise_1[] = _( + "ILLUMISE attracts a swarm of VOLBEAT\n" + "using a sweet fragrance. Once the\n" + "VOLBEAT have gathered, this POKéMON"); +static const u8 DexDescription_Illumise_2[] = _( + "leads the lit-up swarm in drawing\n" + "geometric designs on the canvas of\n" + "the night sky."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Roselia_1[] = _( + "On extremely rare occasions, a ROSELIA\n" + "is said to appear with its flowers in\n" + "unusual colors."); +static const u8 DexDescription_Roselia_2[] = _( + "The thorns on this POKéMON’s head\n" + "contain a vicious poison."); +#else +static const u8 DexDescription_Roselia_1[] = _( + "ROSELIA shoots sharp thorns as\n" + "projectiles at any opponent that tries\n" + "to steal the flowers on its arms."); +static const u8 DexDescription_Roselia_2[] = _( + "The aroma of this POKéMON brings\n" + "serenity to living things."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Gulpin_1[] = _( + "Most of GULPIN’s body is made up of its\n" + "stomach - its heart and brain are very\n" + "small in comparison."); +static const u8 DexDescription_Gulpin_2[] = _( + "This POKéMON’s stomach contains\n" + "special enzymes that dissolve anything."); +#else +static const u8 DexDescription_Gulpin_1[] = _( + "Virtually all of GULPIN’s body is its\n" + "stomach. As a result, it can swallow\n" + "something its own size."); +static const u8 DexDescription_Gulpin_2[] = _( + "This POKéMON’s stomach contains a\n" + "special fluid that digests anything."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Swalot_1[] = _( + "SWALOT has no teeth, so what it\n" + "eats, it swallows whole, no matter what.\n" + "Its cavernous mouth yawns widely."); +static const u8 DexDescription_Swalot_2[] = _( + "An automobile tire could easily fit\n" + "inside this POKéMON’s mouth."); +#else +static const u8 DexDescription_Swalot_1[] = _( + "When SWALOT spots prey, it spurts out\n" + "a hideously toxic fluid from its pores\n" + "and sprays the target."); +static const u8 DexDescription_Swalot_2[] = _( + "Once the prey has weakened, this\n" + "POKéMON gulps it down whole with its\n" + "cavernous mouth."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Carvanha_1[] = _( + "If anything invades CARVANHA’s\n" + "territory, it will swarm and tear at the\n" + "intruder with its pointed fangs."); +static const u8 DexDescription_Carvanha_2[] = _( + "On its own, however, this POKéMON turns\n" + "suddenly timid."); +#else +static const u8 DexDescription_Carvanha_1[] = _( + "CARVANHA’s strongly developed jaws\n" + "and its sharply pointed fangs pack the\n" + "destructive power to rip out boat hulls."); +static const u8 DexDescription_Carvanha_2[] = _( + "Many boats have been attacked and\n" + "sunk by this POKéMON."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Sharpedo_1[] = _( + "SHARPEDO can swim at speeds of up to\n" + "75 mph by jetting seawater out of its\n" + "backside."); +static const u8 DexDescription_Sharpedo_2[] = _( + "This POKéMON’s drawback is its inability\n" + "to swim long distances."); +#else +static const u8 DexDescription_Sharpedo_1[] = _( + "Nicknamed “the bully of the sea,”\n" + "SHARPEDO is widely feared.\n" + "Its cruel fangs grow back immediately"); +static const u8 DexDescription_Sharpedo_2[] = _( + "if they snap off.\n" + "Just one of these POKéMON can\n" + "thoroughly tear apart a supertanker."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Wailmer_1[] = _( + "WAILMER can store water inside its body\n" + "to transform itself into a ball for\n" + "bouncing around on the ground."); +static const u8 DexDescription_Wailmer_2[] = _( + "By filling itself up with more water, this\n" + "POKéMON can elevate the height of its\n" + "bounces."); +#else +static const u8 DexDescription_Wailmer_1[] = _( + "WAILMER’s nostrils are located above\n" + "its eyes. This playful POKéMON loves\n" + "to startle people by forcefully snorting"); +static const u8 DexDescription_Wailmer_2[] = _( + "out seawater it stores inside its body\n" + "out of its nostrils."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Wailord_1[] = _( + "When chasing prey, WAILORD herds them\n" + "by leaping out of the water and making\n" + "a humongous splash."); +static const u8 DexDescription_Wailord_2[] = _( + "It is breathtaking to see this POKéMON\n" + "leaping out of the sea with others in\n" + "its pod."); +#else +static const u8 DexDescription_Wailord_1[] = _( + "WAILORD is the largest of all identified\n" + "POKéMON up to now.\n" + "This giant POKéMON swims languorously"); +static const u8 DexDescription_Wailord_2[] = _( + "in the vast open sea, eating massive\n" + "amounts of food at once with its\n" + "enormous mouth."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Numel_1[] = _( + "NUMEL stores magma of almost 2,200\n" + "degrees F within its body. If it gets\n" + "wet, the magma cools and hardens."); +static const u8 DexDescription_Numel_2[] = _( + "In that event, the POKéMON’s body\n" + "grows heavy and its movements become\n" + "sluggish."); +#else +static const u8 DexDescription_Numel_1[] = _( + "NUMEL is extremely dull witted - it\n" + "doesn’t notice being hit. However, it\n" + "can’t stand hunger for even a second."); +static const u8 DexDescription_Numel_2[] = _( + "This POKéMON’s body is a seething\n" + "cauldron of boiling magma."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Camerupt_1[] = _( + "The humps on CAMERUPT’s back are\n" + "formed by a transformation of its\n" + "bones. They sometimes blast out molten"); +static const u8 DexDescription_Camerupt_2[] = _( + "magma. This POKéMON apparently erupts\n" + "often when it is enraged."); +#else +static const u8 DexDescription_Camerupt_1[] = _( + "CAMERUPT has a volcano inside its body.\n" + "Magma of 18,000 degrees F courses\n" + "through its body."); +static const u8 DexDescription_Camerupt_2[] = _( + "Occasionally, the humps on this\n" + "POKéMON’s back erupt, spewing the\n" + "superheated magma."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Torkoal_1[] = _( + "TORKOAL generates energy by burning\n" + "coal. It grows weaker as the fire\n" + "dies down."); +static const u8 DexDescription_Torkoal_2[] = _( + "When it is preparing for battle, this\n" + "POKéMON burns more coal."); +#else +static const u8 DexDescription_Torkoal_1[] = _( + "TORKOAL digs through mountains in\n" + "search of coal. If it finds some, it fills\n" + "hollow spaces on its shell with the coal"); +static const u8 DexDescription_Torkoal_2[] = _( + "and burns it.\n" + "If it is attacked, this POKéMON spouts\n" + "thick black smoke to beat a retreat."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Spoink_1[] = _( + "SPOINK keeps a pearl on top of its head.\n" + "The pearl functions to amplify this\n" + "POKéMON’s psychokinetic powers."); +static const u8 DexDescription_Spoink_2[] = _( + "It is therefore on a constant search\n" + "for a bigger pearl."); +#else +static const u8 DexDescription_Spoink_1[] = _( + "SPOINK bounces around on its tail.\n" + "The shock of its bouncing makes its\n" + "heart pump. As a result, this POKéMON"); +static const u8 DexDescription_Spoink_2[] = _( + "cannot afford to stop bouncing - if it\n" + "stops, its heart will stop."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Grumpig_1[] = _( + "GRUMPIG uses the black pearls on its\n" + "body to wield its fantastic powers.\n" + "When it is doing so, it dances bizarrely."); +static const u8 DexDescription_Grumpig_2[] = _( + "This POKéMON’s black pearls are valuable\n" + "as works of art."); +#else +static const u8 DexDescription_Grumpig_1[] = _( + "GRUMPIG uses the black pearls on its\n" + "body to amplify its psychic power waves\n" + "for gaining total control over its foe."); +static const u8 DexDescription_Grumpig_2[] = _( + "When this POKéMON uses its special\n" + "power, its snorting breath grows\n" + "labored."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Spinda_1[] = _( + "No two SPINDA are said to have\n" + "identical spot patterns on their hides.\n" + "This POKéMON moves in a curious manner"); +static const u8 DexDescription_Spinda_2[] = _( + "as if it is stumbling in dizziness.\n" + "Its lurching movements can cause the\n" + "opponent to become confused."); +#else +static const u8 DexDescription_Spinda_1[] = _( + "All the SPINDA that exist in the\n" + "world are said to have utterly unique\n" + "spot patterns."); +static const u8 DexDescription_Spinda_2[] = _( + "The shaky, tottering steps of this\n" + "POKéMON give it the appearance of\n" + "dancing."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Trapinch_1[] = _( + "TRAPINCH is a patient hunter. It digs\n" + "an inescapable pit in a desert and waits\n" + "for its prey to come tumbling down."); +static const u8 DexDescription_Trapinch_2[] = _( + "This POKéMON can go a whole week\n" + "without access to any water."); +#else +static const u8 DexDescription_Trapinch_1[] = _( + "TRAPINCH’s nest is a sloped, bowl-like\n" + "pit dug in sand. This POKéMON patiently\n" + "waits for prey to tumble down the pit."); +static const u8 DexDescription_Trapinch_2[] = _( + "Its giant jaws have enough strength\n" + "to crush even boulders."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Vibrava_1[] = _( + "VIBRAVA’s wings have not yet\n" + "completed the process of growing.\n" + "Rather than flying long distances,"); +static const u8 DexDescription_Vibrava_2[] = _( + "they are more useful for generating\n" + "ultrasonic waves by vibrating."); +#else +static const u8 DexDescription_Vibrava_1[] = _( + "To make prey faint, VIBRAVA generates\n" + "ultrasonic waves by vigorously making\n" + "its two wings vibrate."); +static const u8 DexDescription_Vibrava_2[] = _( + "This POKéMON’s ultrasonic waves are so\n" + "powerful, they can bring on headaches\n" + "in people."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Flygon_1[] = _( + "FLYGON whips up a sandstorm by\n" + "flapping its wings. The wings create a\n" + "series of notes that sound like singing."); +static const u8 DexDescription_Flygon_2[] = _( + "Because the “singing” is the only thing\n" + "that can be heard in a sandstorm, this\n" + "POKéMON is said to be the desert spirit."); +#else +static const u8 DexDescription_Flygon_1[] = _( + "FLYGON is nicknamed “the elemental \n" + "spirit of the desert.” Because its\n" + "flapping wings whip up a cloud of sand,"); +static const u8 DexDescription_Flygon_2[] = _( + "this POKéMON is always enveloped in a\n" + "sandstorm while flying."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Cacnea_1[] = _( + "The more arid and harsh the\n" + "environment, the more pretty and\n" + "fragrant a flower CACNEA grows."); +static const u8 DexDescription_Cacnea_2[] = _( + "This POKéMON battles by wildly swinging\n" + "its thorny arms."); +#else +static const u8 DexDescription_Cacnea_1[] = _( + "CACNEA lives in arid locations such\n" + "as deserts. It releases a strong aroma\n" + "from its flower to attract prey."); +static const u8 DexDescription_Cacnea_2[] = _( + "When prey comes near, this POKéMON\n" + "shoots sharp thorns from its body to\n" + "bring the victim down."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Cacturne_1[] = _( + "If a traveler is going through a desert\n" + "in the thick of night, CACTURNE\n" + "will follow in a ragtag group."); +static const u8 DexDescription_Cacturne_2[] = _( + "The POKéMON are biding their time,\n" + "waiting for the traveler to tire and\n" + "become incapable of moving."); +#else +static const u8 DexDescription_Cacturne_1[] = _( + "During the daytime, CACTURNE remains\n" + "unmoving so that it does not lose any\n" + "moisture to the harsh desert sun."); +static const u8 DexDescription_Cacturne_2[] = _( + "This POKéMON becomes active at night\n" + "when the temperature drops."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Swablu_1[] = _( + "SWABLU loves to make things clean.\n" + "If it spots something dirty, it will wipe\n" + "and polish it with its cottony wings."); +static const u8 DexDescription_Swablu_2[] = _( + "If its wings become dirty, this POKéMON\n" + "finds a stream and showers itself."); +#else +static const u8 DexDescription_Swablu_1[] = _( + "SWABLU has light and fluffy wings that\n" + "are like cottony clouds. This POKéMON\n" + "is not frightened of people."); +static const u8 DexDescription_Swablu_2[] = _( + "It lands on the heads of people and\n" + "sits there like a cotton-fluff hat."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Altaria_1[] = _( + "ALTARIA sings in a gorgeous soprano.\n" + "Its wings are like cotton clouds.\n" + "This POKéMON catches updrafts with its"); +static const u8 DexDescription_Altaria_2[] = _( + "buoyant wings and soars way up into\n" + "the wild blue yonder."); +#else +static const u8 DexDescription_Altaria_1[] = _( + "ALTARIA dances and wheels through the\n" + "sky among billowing, cotton-like clouds.\n" + "By singing melodies in its crystal-clear"); +static const u8 DexDescription_Altaria_2[] = _( + "voice, this POKéMON makes its listeners\n" + "experience dreamy wonderment."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Zangoose_1[] = _( + "ZANGOOSE usually stays on all fours,\n" + "but when angered, it gets up on its\n" + "hind legs and extends its claws."); +static const u8 DexDescription_Zangoose_2[] = _( + "This POKéMON shares a bitter rivalry\n" + "with SEVIPER that dates back over\n" + "generations."); +#else +static const u8 DexDescription_Zangoose_1[] = _( + "Memories of battling its arch-rival\n" + "SEVIPER are etched into every cell of\n" + "ZANGOOSE’s body."); +static const u8 DexDescription_Zangoose_2[] = _( + "This POKéMON adroitly dodges attacks\n" + "with incredible agility."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Seviper_1[] = _( + "SEVIPER’s swordlike tail serves two\n" + "purposes - it slashes foes and douses\n" + "them with secreted poison."); +static const u8 DexDescription_Seviper_2[] = _( + "This POKéMON will not give up its long-\n" + "running blood feud with ZANGOOSE."); +#else +static const u8 DexDescription_Seviper_1[] = _( + "SEVIPER shares a generations-long\n" + "feud with ZANGOOSE. The scars on its\n" + "body are evidence of vicious battles."); +static const u8 DexDescription_Seviper_2[] = _( + "This POKéMON attacks using its sword-\n" + "edged tail."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Lunatone_1[] = _( + "LUNATONE becomes active around the\n" + "time of the full moon. Instead of\n" + "walking, it moves by floating in midair."); +static const u8 DexDescription_Lunatone_2[] = _( + "The POKéMON’s intimidating red eyes\n" + "cause all those who see it to become\n" + "transfixed with fear."); +#else +static const u8 DexDescription_Lunatone_1[] = _( + "LUNATONE was discovered at a location\n" + "where a meteorite fell. As a result, some\n" + "people theorize that this POKéMON"); +static const u8 DexDescription_Lunatone_2[] = _( + "came from space. However, no one has\n" + "been able to prove this theory so far."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Solrock_1[] = _( + "Sunlight is the source of SOLROCK’s\n" + "power. It is said to possess the ability\n" + "to read the emotions of others."); +static const u8 DexDescription_Solrock_2[] = _( + "This POKéMON gives off intense heat\n" + "while rotating its body."); +#else +static const u8 DexDescription_Solrock_1[] = _( + "SOLROCK is a new species of POKéMON\n" + "that is said to have fallen from space.\n" + "It floats in air and moves silently."); +static const u8 DexDescription_Solrock_2[] = _( + "In battle, this POKéMON releases\n" + "intensely bright light."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Barboach_1[] = _( + "BARBOACH’s body is covered with a\n" + "slimy film. If a foe grabs it, this\n" + "POKéMON just slips out of the enemy’s"); +static const u8 DexDescription_Barboach_2[] = _( + "grip.\n" + "This POKéMON grows weak if the slimy\n" + "coating dries up."); +#else +static const u8 DexDescription_Barboach_1[] = _( + "BARBOACH’s sensitive whiskers serve\n" + "as a superb radar system.\n" + "This POKéMON hides in mud, leaving only"); +static const u8 DexDescription_Barboach_2[] = _( + "its two whiskers exposed while it waits\n" + "for prey to come along."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Whiscash_1[] = _( + "If WHISCASH goes on a wild rampage,\n" + "it sets off a quake-like tremor with a\n" + "radius of over three miles."); +static const u8 DexDescription_Whiscash_2[] = _( + "This POKéMON has the ability to predict\n" + "real earthquakes."); +#else +static const u8 DexDescription_Whiscash_1[] = _( + "WHISCASH is extremely territorial.\n" + "Just one of these POKéMON will claim a\n" + "large pond as its exclusive territory."); +static const u8 DexDescription_Whiscash_2[] = _( + "If a foe approaches it, it thrashes\n" + "about and triggers a massive\n" + "earthquake."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Corphish_1[] = _( + "CORPHISH catches prey with its sharp\n" + "claws. It has no likes or dislikes when it\n" + "comes to food - it will eat anything."); +static const u8 DexDescription_Corphish_2[] = _( + "This POKéMON has no trouble living in\n" + "filthy water."); +#else +static const u8 DexDescription_Corphish_1[] = _( + "CORPHISH were originally foreign\n" + "POKéMON that were imported as pets.\n" + "They eventually turned up in the wild."); +static const u8 DexDescription_Corphish_2[] = _( + "This POKéMON is very hardy and has\n" + "greatly increased its population."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Crawdaunt_1[] = _( + "CRAWDAUNT molts (sheds) its shell\n" + "regularly. Immediately after molting,\n" + "its shell is soft and tender."); +static const u8 DexDescription_Crawdaunt_2[] = _( + "Until the shell hardens, this POKéMON\n" + "hides in its streambed burrow to avoid\n" + "attack from its foes."); +#else +static const u8 DexDescription_Crawdaunt_1[] = _( + "CRAWDAUNT has an extremely violent\n" + "nature that compels it to challenge\n" + "other living things to battle."); +static const u8 DexDescription_Crawdaunt_2[] = _( + "Other life-forms refuse to live in\n" + "ponds inhabited by this POKéMON,\n" + "making them desolate places."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Baltoy_1[] = _( + "As soon as it spots others of its kind,\n" + "BALTOY congregates with them and\n" + "then begins crying noisily in unison."); +static const u8 DexDescription_Baltoy_2[] = _( + "This POKéMON sleeps while cleverly\n" + "balancing itself on its one foot."); +#else +static const u8 DexDescription_Baltoy_1[] = _( + "BALTOY moves while spinning around on\n" + "its one foot. Primitive wall paintings\n" + "depicting this POKéMON living among"); +static const u8 DexDescription_Baltoy_2[] = _( + "people were discovered in some ancient\n" + "ruins."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Claydol_1[] = _( + "CLAYDOL is an enigma that appeared\n" + "from a clay statue made by an ancient\n" + "civilization dating back 20,000 years."); +static const u8 DexDescription_Claydol_2[] = _( + "This POKéMON shoots beams from both\n" + "its hands."); +#else +static const u8 DexDescription_Claydol_1[] = _( + "CLAYDOL are said to be dolls of mud made\n" + "by primitive humans and brought to life\n" + "by exposure to a mysterious ray."); +static const u8 DexDescription_Claydol_2[] = _( + "This POKéMON moves about while\n" + "levitating."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Lileep_1[] = _( + "LILEEP is an ancient POKéMON that was\n" + "regenerated from a fossil. It remains\n" + "permanently anchored to a rock."); +static const u8 DexDescription_Lileep_2[] = _( + "From its immobile perch, this POKéMON\n" + "intently scans for prey with its two\n" + "eyes."); +#else +static const u8 DexDescription_Lileep_1[] = _( + "LILEEP became extinct approximately\n" + "a hundred million years ago.\n" + "This ancient POKéMON attaches itself"); +static const u8 DexDescription_Lileep_2[] = _( + "to a rock on the seafloor and catches\n" + "approaching prey using tentacles \n" + "shaped like flower petals."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Cradily_1[] = _( + "CRADILY’s body serves as an anchor,\n" + "preventing it from being washed away in\n" + "rough seas."); +static const u8 DexDescription_Cradily_2[] = _( + "This POKéMON secretes a strong\n" + "digestive fluid from its tentacles."); +#else +static const u8 DexDescription_Cradily_1[] = _( + "CRADILY roams around the ocean floor\n" + "in search of food. This POKéMON freely\n" + "extends its tree trunk-like neck and"); +static const u8 DexDescription_Cradily_2[] = _( + "captures unwary prey using its eight\n" + "tentacles."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Anorith_1[] = _( + "ANORITH is said to be a type of \n" + "POKéMON predecessor, with eight wings\n" + "at the sides of its body."); +static const u8 DexDescription_Anorith_2[] = _( + "This POKéMON swam in the primordial sea\n" + "by undulating these eight wings."); +#else +static const u8 DexDescription_Anorith_1[] = _( + "ANORITH was regenerated from a\n" + "prehistoric fossil. This primitive\n" + "POKéMON once lived in warm seas."); +static const u8 DexDescription_Anorith_2[] = _( + "It grips its prey firmly between its\n" + "two large claws."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Armaldo_1[] = _( + "ARMALDO is a POKéMON species that\n" + "became extinct in prehistoric times.\n" + "This POKéMON is said to have walked on"); +static const u8 DexDescription_Armaldo_2[] = _( + "its hind legs, which would have been\n" + "more convenient for life on land."); +#else +static const u8 DexDescription_Armaldo_1[] = _( + "ARMALDO’s tough armor makes all attacks\n" + "bounce off. This POKéMON’s two\n" + "enormous claws can be freely extended"); +static const u8 DexDescription_Armaldo_2[] = _( + "or contracted. They have the power to\n" + "punch right through a steel slab."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Feebas_1[] = _( + "While FEEBAS’s body is in tatters,\n" + "it has a hardy and tenacious life force\n" + "that enables it to live anywhere."); +static const u8 DexDescription_Feebas_2[] = _( + "However, this POKéMON is also slow and\n" + "dimwitted, making it an easy catch."); +#else +static const u8 DexDescription_Feebas_1[] = _( + "FEEBAS’s fins are ragged and\n" + "tattered from the start of its life.\n" + "Because of its shoddy appearance, this"); +static const u8 DexDescription_Feebas_2[] = _( + "POKéMON is largely ignored.\n" + "It is capable of living in both the sea\n" + "and in rivers."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Milotic_1[] = _( + "MILOTIC live at the bottom of large\n" + "lakes. When this POKéMON’s body glows a\n" + "vivid pink, it releases a pulsing wave of"); +static const u8 DexDescription_Milotic_2[] = _( + "energy that brings soothing calm to\n" + "restless spirits."); +#else +static const u8 DexDescription_Milotic_1[] = _( + "MILOTIC is said to be the most\n" + "beautiful of all the POKéMON.\n" + "It has the power to becalm such"); +static const u8 DexDescription_Milotic_2[] = _( + "emotions as anger and hostility to quell\n" + "bitter feuding."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Castform_1[] = _( + "CASTFORM borrows the power of nature\n" + "to transform itself into the guises of\n" + "the sun, rain clouds, and snow clouds."); +static const u8 DexDescription_Castform_2[] = _( + "This POKéMON’s feelings change with the\n" + "weather."); +#else +static const u8 DexDescription_Castform_1[] = _( + "CASTFORM’s appearance changes with\n" + "the weather.\n" + "This POKéMON gained the ability to use"); +static const u8 DexDescription_Castform_2[] = _( + "the vast power of nature to protect\n" + "its tiny body."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Kecleon_1[] = _( + "KECLEON alters its body coloration to\n" + "blend in with its surroundings, allowing\n" + "it to sneak up on its prey unnoticed."); +static const u8 DexDescription_Kecleon_2[] = _( + "Then it lashes out with its long,\n" + "stretchy tongue to instantly ensnare\n" + "the unsuspecting target."); +#else +static const u8 DexDescription_Kecleon_1[] = _( + "KECLEON is capable of changing its body\n" + "colors at will to blend in with its\n" + "surroundings."); +static const u8 DexDescription_Kecleon_2[] = _( + "There is one exception - this POKéMON\n" + "can’t change the zigzag pattern on its\n" + "belly."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Shuppet_1[] = _( + "SHUPPET grows by feeding on dark\n" + "emotions, such as vengefulness and \n" + "envy, in the hearts of people."); +static const u8 DexDescription_Shuppet_2[] = _( + "It roams through cities in search of\n" + "grudges that taint people."); +#else +static const u8 DexDescription_Shuppet_1[] = _( + "SHUPPET is attracted by feelings\n" + "of jealousy and vindictiveness.\n" + "If someone develops strong feelings of"); +static const u8 DexDescription_Shuppet_2[] = _( + "vengeance, this POKéMON will appear\n" + "in a swarm and line up beneath the eaves\n" + "of that person’s home."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Banette_1[] = _( + "A cursed energy permeated the stuffing\n" + "of a discarded and forgotten plush doll,\n" + "giving it new life as BANETTE."); +static const u8 DexDescription_Banette_2[] = _( + "The POKéMON’s energy would escape if it\n" + "were to ever open its mouth."); +#else +static const u8 DexDescription_Banette_1[] = _( + "BANETTE generates energy for laying\n" + "strong curses by sticking pins into its\n" + "own body."); +static const u8 DexDescription_Banette_2[] = _( + "This POKéMON was originally a pitiful\n" + "plush doll that was thrown away."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Duskull_1[] = _( + "DUSKULL wanders lost among the deep\n" + "darkness of midnight. There is an oft-\n" + "told admonishment given to misbehaving"); +static const u8 DexDescription_Duskull_2[] = _( + "children that this POKéMON will spirit\n" + "away bad children who earn scoldings\n" + "from their mothers."); +#else +static const u8 DexDescription_Duskull_1[] = _( + "DUSKULL can pass through any wall no\n" + "matter how thick it may be.\n" + "Once this POKéMON chooses a target,"); +static const u8 DexDescription_Duskull_2[] = _( + "it will doggedly pursue the intended\n" + "victim until the break of dawn."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Dusclops_1[] = _( + "DUSCLOPS absorbs anything, however\n" + "large the object may be. This POKéMON\n" + "hypnotizes its foe by waving its hands"); +static const u8 DexDescription_Dusclops_2[] = _( + "in a macabre manner and by bringing its\n" + "single eye to bear. The hypnotized foe\n" + "is made to do DUSCLOPS’s bidding."); +#else +static const u8 DexDescription_Dusclops_1[] = _( + "DUSCLOPS’s body is completely hollow -\n" + "there is nothing at all inside.\n" + "It is said that its body is like a black"); +static const u8 DexDescription_Dusclops_2[] = _( + "hole. This POKéMON will absorb anything\n" + "into its body, but nothing will ever come\n" + "back out."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Tropius_1[] = _( + "Children of the southern tropics eat\n" + "as snacks the fruit that grows in\n" + "bunches around the neck of TROPIUS."); +static const u8 DexDescription_Tropius_2[] = _( + "This POKéMON flies by flapping the\n" + "leaves on its back as if they were\n" + "wings."); +#else +static const u8 DexDescription_Tropius_1[] = _( + "The bunches of fruit around TROPIUS’s\n" + "neck are very popular with children.\n" + "This POKéMON loves fruit, and eats it"); +static const u8 DexDescription_Tropius_2[] = _( + "continuously. Apparently, its love for\n" + "fruit resulted in its own outgrowth\n" + "of fruit."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Chimecho_1[] = _( + "In high winds, CHIMECHO cries as it\n" + "hangs from a tree branch or the eaves\n" + "of a building using a suction cup on its"); +static const u8 DexDescription_Chimecho_2[] = _( + "head.\n" + "This POKéMON plucks berries with its\n" + "long tail and eats them."); +#else +static const u8 DexDescription_Chimecho_1[] = _( + "CHIMECHO makes its cries echo\n" + "inside its hollow body. When this\n" + "POKéMON becomes enraged, its cries"); +static const u8 DexDescription_Chimecho_2[] = _( + "result in ultrasonic waves that have\n" + "the power to knock foes flying."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Absol_1[] = _( + "ABSOL has the ability to foretell the\n" + "coming of natural disasters.\n" + "It lives in a harsh, rugged mountain"); +static const u8 DexDescription_Absol_2[] = _( + "environment. This POKéMON very rarely\n" + "ventures down from the mountains."); +#else +static const u8 DexDescription_Absol_1[] = _( + "Every time ABSOL appears before people,\n" + "it is followed by a disaster such as an\n" + "earthquake or a tidal wave."); +static const u8 DexDescription_Absol_2[] = _( + "As a result, it came to be known as the\n" + "disaster POKéMON."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Wynaut_1[] = _( + "WYNAUT gather on moonlit nights to play\n" + "by squeezing up against each other.\n" + "By being squeezed, this POKéMON gains"); +static const u8 DexDescription_Wynaut_2[] = _( + "endurance and is trained to dole out\n" + "powerful counterattacks."); +#else +static const u8 DexDescription_Wynaut_1[] = _( + "WYNAUT can always be seen with a big,\n" + "happy smile on its face. Look at its tail\n" + "to determine if it is angry."); +static const u8 DexDescription_Wynaut_2[] = _( + "When angered, this POKéMON will be\n" + "slapping the ground with its tail."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Snorunt_1[] = _( + "SNORUNT survives by eating only snow\n" + "and ice.\n" + "Old folklore claims that a house visited"); +static const u8 DexDescription_Snorunt_2[] = _( + "by this POKéMON is sure to prosper for\n" + "many generations to come."); +#else +static const u8 DexDescription_Snorunt_1[] = _( + "SNORUNT live in regions with heavy\n" + "snowfall. In seasons without snow, such\n" + "as spring and summer, this POKéMON"); +static const u8 DexDescription_Snorunt_2[] = _( + "steals away to live quietly among\n" + "stalactites and stalagmites deep in\n" + "caverns."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Glalie_1[] = _( + "GLALIE has the ability to freely\n" + "control ice. For example, it can\n" + "instantly freeze its foe solid."); +static const u8 DexDescription_Glalie_2[] = _( + "After immobilizing its foe in ice, this\n" + "POKéMON enjoys eating it in leisurely\n" + "fashion."); +#else +static const u8 DexDescription_Glalie_1[] = _( + "GLALIE has a body made of rock, which it\n" + "hardens with an armor of ice.\n" + "This POKéMON has the ability to freeze"); +static const u8 DexDescription_Glalie_2[] = _( + "moisture in the atmosphere into any\n" + "shape it desires."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Spheal_1[] = _( + "SPHEAL always travels by rolling\n" + "around on its ball-like body. When the\n" + "season for ice floes arrives, this"); +static const u8 DexDescription_Spheal_2[] = _( + "POKéMON can be seen rolling about on\n" + "ice and crossing the sea."); +#else +static const u8 DexDescription_Spheal_1[] = _( + "SPHEAL is much faster rolling than \n" + "walking to get around. When groups of\n" + "this POKéMON eat, they all clap at once"); +static const u8 DexDescription_Spheal_2[] = _( + "to show their pleasure. Because of this,\n" + "their mealtimes are noisy."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Sealeo_1[] = _( + "SEALEO often balances and rolls\n" + "things on the tip of its nose. While the\n" + "POKéMON is rolling something, it checks"); +static const u8 DexDescription_Sealeo_2[] = _( + "the object’s aroma and texture to\n" + "determine whether it likes the object\n" + "or not."); +#else +static const u8 DexDescription_Sealeo_1[] = _( + "SEALEO has the habit of always juggling\n" + "on the tip of its nose anything it sees\n" + "for the first time."); +static const u8 DexDescription_Sealeo_2[] = _( + "This POKéMON occasionally entertains\n" + "itself by balancing and rolling a SPHEAL\n" + "on its nose."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Walrein_1[] = _( + "WALREIN swims all over in frigid\n" + "seawater while crushing icebergs with\n" + "its grand, imposing tusks."); +static const u8 DexDescription_Walrein_2[] = _( + "Its thick layer of blubber makes enemy\n" + "attacks bounce off harmlessly."); +#else +static const u8 DexDescription_Walrein_1[] = _( + "WALREIN’s two massively developed\n" + "tusks can totally shatter blocks of\n" + "ice weighing ten tons with one blow."); +static const u8 DexDescription_Walrein_2[] = _( + "This POKéMON’s thick coat of blubber\n" + "insulates it from subzero temperatures."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Clamperl_1[] = _( + "CLAMPERL grows while being protected\n" + "by its rock-hard shell. When its body\n" + "becomes too large to fit inside the"); +static const u8 DexDescription_Clamperl_2[] = _( + "shell, it is sure evidence that this\n" + "POKéMON is getting close to evolution."); +#else +static const u8 DexDescription_Clamperl_1[] = _( + "CLAMPERL’s sturdy shell is not only good\n" + "for protection - it is also used for\n" + "clamping and catching prey."); +static const u8 DexDescription_Clamperl_2[] = _( + "A fully grown CLAMPERL’s shell will be\n" + "scored with nicks and scratches all\n" + "over."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Huntail_1[] = _( + "HUNTAIL’s tail is shaped like a fish.\n" + "It uses the tail to attract prey, then\n" + "swallows the prey whole with its large,"); +static const u8 DexDescription_Huntail_2[] = _( + "gaping mouth.\n" + "This POKéMON swims by wiggling its\n" + "slender body like a snake."); +#else +static const u8 DexDescription_Huntail_1[] = _( + "HUNTAIL’s presence went unnoticed by\n" + "people for a long time because it lives\n" + "at extreme depths in the sea."); +static const u8 DexDescription_Huntail_2[] = _( + "This POKéMON’s eyes can see clearly\n" + "even in the murky dark depths of the\n" + "ocean."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Gorebyss_1[] = _( + "Although GOREBYSS is the very picture\n" + "of elegance and beauty while swimming,\n" + "it is also cruel. When it spots prey, this"); +static const u8 DexDescription_Gorebyss_2[] = _( + "POKéMON inserts its thin mouth into the\n" + "prey’s body and drains the prey of its\n" + "body fluids."); +#else +static const u8 DexDescription_Gorebyss_1[] = _( + "GOREBYSS lives in the southern seas\n" + "at extreme depths. Its body is built to\n" + "withstand the enormous pressure of"); +static const u8 DexDescription_Gorebyss_2[] = _( + "water at incredible depths. Because of\n" + "this, this POKéMON’s body is unharmed\n" + "by ordinary attacks."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Relicanth_1[] = _( + "RELICANTH is a rare species that was\n" + "discovered in deep-sea explorations.\n" + "This POKéMON’s body withstands the"); +static const u8 DexDescription_Relicanth_2[] = _( + "enormous water pressure of the ocean\n" + "depths. Its body is covered in tough\n" + "scales that are like craggy rocks."); +#else +static const u8 DexDescription_Relicanth_1[] = _( + "RELICANTH is a POKéMON species that\n" + "existed for a hundred million years\n" + "without ever changing its form."); +static const u8 DexDescription_Relicanth_2[] = _( + "This ancient POKéMON feeds on\n" + "microscopic organisms with its\n" + "toothless mouth."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Luvdisc_1[] = _( + "LUVDISC’s heart-shaped body is a\n" + "symbol of love and romance.\n" + "It is said that any couple meeting this"); +static const u8 DexDescription_Luvdisc_2[] = _( + "POKéMON is promised a loving\n" + "relationship that never ends."); +#else +static const u8 DexDescription_Luvdisc_1[] = _( + "LUVDISC live in shallow seas in the\n" + "tropics. This heart-shaped POKéMON\n" + "earned its name by swimming after"); +static const u8 DexDescription_Luvdisc_2[] = _( + "loving couples it spotted in the\n" + "ocean’s waves."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Bagon_1[] = _( + "BAGON harbors a never-ending dream of\n" + "one day soaring high among the clouds.\n" + "As if trying to dispel its frustration"); +static const u8 DexDescription_Bagon_2[] = _( + "over its inability to fly, this POKéMON\n" + "slams its hard head against huge rocks\n" + "and shatters them into pebbles."); +#else +static const u8 DexDescription_Bagon_1[] = _( + "BAGON has a dream of one day soaring\n" + "in the sky. In doomed efforts to fly,\n" + "this POKéMON hurls itself off cliffs."); +static const u8 DexDescription_Bagon_2[] = _( + "As a result of its dives, its head has \n" + "grown tough and as hard as tempered\n" + "steel."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Shelgon_1[] = _( + "Covering SHELGON’s body are outgrowths\n" + "much like bones. The shell is very hard\n" + "and bounces off enemy attacks."); +static const u8 DexDescription_Shelgon_2[] = _( + "When awaiting evolution, this POKéMON\n" + "hides away in a cavern."); +#else +static const u8 DexDescription_Shelgon_1[] = _( + "Inside SHELGON’s armor-like shell, cells\n" + "are in the midst of transformation\n" + "to create an entirely new body."); +static const u8 DexDescription_Shelgon_2[] = _( + "This POKéMON’s shell is extremely heavy,\n" + "making its movements sluggish."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Salamence_1[] = _( + "By evolving into SALAMENCE, this\n" + "POKéMON finally realizes its long-held\n" + "dream of growing wings."); +static const u8 DexDescription_Salamence_2[] = _( + "To express its joy, it flies and wheels\n" + "all over the sky while spouting flames\n" + "from its mouth."); +#else +static const u8 DexDescription_Salamence_1[] = _( + "SALAMENCE came about as a result of a\n" + "strong, long-held dream of growing\n" + "wings. It is said that this powerful"); +static const u8 DexDescription_Salamence_2[] = _( + "desire triggered a sudden mutation in\n" + "this POKéMON’s cells, causing it to\n" + "sprout its magnificent wings."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Beldum_1[] = _( + "BELDUM keeps itself floating by\n" + "generating a magnetic force that\n" + "repels earth’s natural magnetism."); +static const u8 DexDescription_Beldum_2[] = _( + "When it sleeps, this POKéMON anchors\n" + "itself to a cliff using the hooks on\n" + "its rear."); +#else +static const u8 DexDescription_Beldum_1[] = _( + "Instead of blood, a powerful magnetic\n" + "force courses throughout BELDUM’s\n" + "body. This POKéMON communicates with"); +static const u8 DexDescription_Beldum_2[] = _( + "others by sending controlled pulses of\n" + "magnetism."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Metang_1[] = _( + "When two BELDUM fuse together, METANG\n" + "is formed. The brains of the BELDUM are\n" + "joined by a magnetic nervous system."); +static const u8 DexDescription_Metang_2[] = _( + "This POKéMON turns its arms to the rear\n" + "for traveling at high speed."); +#else +static const u8 DexDescription_Metang_1[] = _( + "When two BELDUM fuse together, METANG\n" + "is formed. The brains of the BELDUM are\n" + "joined by a magnetic nervous system."); +static const u8 DexDescription_Metang_2[] = _( + "By linking its brains magnetically,\n" + "this POKéMON generates strong\n" + "psychokinetic power."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Metagross_1[] = _( + "METAGROSS is the result of two METANG\n" + "achieving fusion. When hunting, this\n" + "POKéMON pins the prey to the ground"); +static const u8 DexDescription_Metagross_2[] = _( + "under its massive body. It then eats\n" + "the helpless victim using the large \n" + "mouth on its stomach."); +#else +static const u8 DexDescription_Metagross_1[] = _( + "METAGROSS has four brains in total.\n" + "Combined, the four brains can breeze\n" + "through difficult calculations faster"); +static const u8 DexDescription_Metagross_2[] = _( + "than a supercomputer.\n" + "This POKéMON can float in the air by\n" + "tucking in its four legs."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Regirock_1[] = _( + "REGIROCK’s body is composed entirely of\n" + "rocks. Recently, a study made the\n" + "startling discovery that the rocks"); +static const u8 DexDescription_Regirock_2[] = _( + "were all unearthed from different\n" + "locations."); +#else +static const u8 DexDescription_Regirock_1[] = _( + "REGIROCK was sealed away by people\n" + "long ago. If this POKéMON’s body is\n" + "damaged in battle, it is said to seek"); +static const u8 DexDescription_Regirock_2[] = _( + "out suitable rocks on its own to repair\n" + "itself."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Regice_1[] = _( + "REGICE cloaks itself with frigid air of\n" + "negative 328 degrees F.\n" + "Things will freeze solid just by going"); +static const u8 DexDescription_Regice_2[] = _( + "near this POKéMON.\n" + "Its icy body is so cold, it will not melt\n" + "even if it is immersed in magma."); +#else +static const u8 DexDescription_Regice_1[] = _( + "REGICE’s body was made during an ice\n" + "age. The deep-frozen body can’t be\n" + "melted, even by fire."); +static const u8 DexDescription_Regice_2[] = _( + "This POKéMON controls frigid air of\n" + "minus 328 degrees F."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Registeel_1[] = _( + "REGISTEEL was imprisoned by people\n" + "in ancient times.\n" + "The metal composing its body is thought"); +static const u8 DexDescription_Registeel_2[] = _( + "to be a curious substance that is not\n" + "of this earth."); +#else +static const u8 DexDescription_Registeel_1[] = _( + "REGISTEEL has a body that is harder\n" + "than any kind of metal.\n" + "Its body is apparently hollow."); +static const u8 DexDescription_Registeel_2[] = _( + "No one has any idea what this POKéMON\n" + "eats."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Latias_1[] = _( + "LATIAS is highly intelligent and capable\n" + "of understanding human speech.\n" + "It is covered with a glass-like down."); +static const u8 DexDescription_Latias_2[] = _( + "The POKéMON enfolds its body with its\n" + "down and refracts light to alter its\n" + "appearance."); +#else +static const u8 DexDescription_Latias_1[] = _( + "LATIAS is highly sensitive to the\n" + "emotions of people. If it senses any\n" + "hostility, this POKéMON ruffles the"); +static const u8 DexDescription_Latias_2[] = _( + "feathers all over its body and cries\n" + "shrilly to intimidate the foe."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Latios_1[] = _( + "LATIOS will only open its heart to a\n" + "TRAINER with a compassionate spirit.\n" + "This POKéMON can fly faster than a jet"); +static const u8 DexDescription_Latios_2[] = _( + "plane by folding its forelegs to minimize\n" + "air resistance."); +#else +static const u8 DexDescription_Latios_1[] = _( + "LATIOS has the ability to make its foe\n" + "see an image of what it has seen or\n" + "imagines in its head."); +static const u8 DexDescription_Latios_2[] = _( + "This POKéMON is intelligent and\n" + "understands human speech."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Kyogre_1[] = _( + "KYOGRE is named in mythology as the\n" + "POKéMON that expanded the sea by\n" + "covering the land with torrential rains"); +static const u8 DexDescription_Kyogre_2[] = _( + "and towering tidal waves.\n" + "It took to sleep after a cataclysmic\n" + "battle with GROUDON."); +#else +static const u8 DexDescription_Kyogre_1[] = _( + "KYOGRE has the power to create massive\n" + "rain clouds that cover the entire sky\n" + "and bring about torrential downpours."); +static const u8 DexDescription_Kyogre_2[] = _( + "This POKéMON saved people who were\n" + "suffering from droughts."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Groudon_1[] = _( + "GROUDON has the power to scatter rain\n" + "clouds and make water evaporate with\n" + "light and heat."); +static const u8 DexDescription_Groudon_2[] = _( + "It came as a savior to people who had\n" + "been suffering from terrible floods."); +#else +static const u8 DexDescription_Groudon_1[] = _( + "GROUDON has long been described in \n" + "mythology as the POKéMON that raised\n" + "lands and expanded continents."); +static const u8 DexDescription_Groudon_2[] = _( + "This POKéMON took to sleep after a\n" + "cataclysmic battle with KYOGRE."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Rayquaza_1[] = _( + "RAYQUAZA is said to have lived for\n" + "hundreds of millions of years in the\n" + "earth’s ozone layer, above the clouds."); +static const u8 DexDescription_Rayquaza_2[] = _( + "Its existence had been completely\n" + "unknown because it lived so high in\n" + "the sky."); +#else +static const u8 DexDescription_Rayquaza_1[] = _( + "RAYQUAZA lived for hundreds of millions\n" + "of years in the earth’s ozone layer, \n" + "never descending to the ground."); +static const u8 DexDescription_Rayquaza_2[] = _( + "This POKéMON appears to feed on water\n" + "and particles in the atmosphere."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Jirachi_1[] = _( + "JIRACHI will awaken from its sleep of\n" + "a thousand years if you sing to it in a\n" + "voice of purity."); +static const u8 DexDescription_Jirachi_2[] = _( + "It is said to make true any wish that\n" + "people desire."); +#else +static const u8 DexDescription_Jirachi_1[] = _( + "A legend states that JIRACHI will make\n" + "true any wish that is written on notes\n" + "attached to its head when it awakens."); +static const u8 DexDescription_Jirachi_2[] = _( + "If this POKéMON senses danger, it will\n" + "fight without awakening."); +#endif + +#ifdef SAPPHIRE +static const u8 DexDescription_Deoxys_1[] = _( + "DEOXYS emerged from a virus that came\n" + "from space. It is highly intelligent and\n" + "wields psychokinetic powers."); +static const u8 DexDescription_Deoxys_2[] = _( + "This POKéMON shoots lasers from the\n" + "crystalline organ on its chest."); +#else +static const u8 DexDescription_Deoxys_1[] = _( + "The DNA of a space virus underwent a\n" + "sudden mutation upon exposure to a\n" + "laser beam and resulted in DEOXYS."); +static const u8 DexDescription_Deoxys_2[] = _( + "The crystalline organ on this POKéMON’s\n" + "chest appears to be its brain."); +#endif + +static const struct PokedexEntry gPokedexEntries[] = +{ + { //Dummy + .categoryName = _("UNKNOWN"), + .height = 0, + .weight = 0, + .descriptionPage1 = DexDescription_Dummy_1, + .descriptionPage2 = DexDescription_Dummy_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Bulbasaur + .categoryName = _("SEED"), + .height = 7, + .weight = 69, + .descriptionPage1 = DexDescription_Bulbasaur_1, + .descriptionPage2 = DexDescription_Bulbasaur_2, + .pokemonScale = 356, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Ivysaur + .categoryName = _("SEED"), + .height = 10, + .weight = 130, + .descriptionPage1 = DexDescription_Ivysaur_1, + .descriptionPage2 = DexDescription_Ivysaur_2, + .pokemonScale = 335, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Venusaur + .categoryName = _("SEED"), + .height = 20, + .weight = 1000, + .descriptionPage1 = DexDescription_Venusaur_1, + .descriptionPage2 = DexDescription_Venusaur_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 388, + .trainerOffset = 6, + }, + { //Charmander + .categoryName = _("LIZARD"), + .height = 6, + .weight = 85, + .descriptionPage1 = DexDescription_Charmander_1, + .descriptionPage2 = DexDescription_Charmander_2, + .pokemonScale = 444, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Charmeleon + .categoryName = _("FLAME"), + .height = 11, + .weight = 190, + .descriptionPage1 = DexDescription_Charmeleon_1, + .descriptionPage2 = DexDescription_Charmeleon_2, + .pokemonScale = 302, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Charizard + .categoryName = _("FLAME"), + .height = 17, + .weight = 905, + .descriptionPage1 = DexDescription_Charizard_1, + .descriptionPage2 = DexDescription_Charizard_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 302, + .trainerOffset = 3, + }, + { //Squirtle + .categoryName = _("TINY TURTLE"), + .height = 5, + .weight = 90, + .descriptionPage1 = DexDescription_Squirtle_1, + .descriptionPage2 = DexDescription_Squirtle_2, + .pokemonScale = 412, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Wartortle + .categoryName = _("TURTLE"), + .height = 10, + .weight = 225, + .descriptionPage1 = DexDescription_Wartortle_1, + .descriptionPage2 = DexDescription_Wartortle_2, + .pokemonScale = 332, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Blastoise + .categoryName = _("SHELLFISH"), + .height = 16, + .weight = 855, + .descriptionPage1 = DexDescription_Blastoise_1, + .descriptionPage2 = DexDescription_Blastoise_2, + .pokemonScale = 256, + .pokemonOffset = -1, + .trainerScale = 293, + .trainerOffset = 2, + }, + { //Caterpie + .categoryName = _("WORM"), + .height = 3, + .weight = 29, + .descriptionPage1 = DexDescription_Caterpie_1, + .descriptionPage2 = DexDescription_Caterpie_2, + .pokemonScale = 549, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Metapod + .categoryName = _("COCOON"), + .height = 7, + .weight = 99, + .descriptionPage1 = DexDescription_Metapod_1, + .descriptionPage2 = DexDescription_Metapod_2, + .pokemonScale = 350, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Butterfree + .categoryName = _("BUTTERFLY"), + .height = 11, + .weight = 320, + .descriptionPage1 = DexDescription_Butterfree_1, + .descriptionPage2 = DexDescription_Butterfree_2, + .pokemonScale = 312, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Weedle + .categoryName = _("HAIRY BUG"), + .height = 3, + .weight = 32, + .descriptionPage1 = DexDescription_Weedle_1, + .descriptionPage2 = DexDescription_Weedle_2, + .pokemonScale = 455, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Kakuna + .categoryName = _("COCOON"), + .height = 6, + .weight = 100, + .descriptionPage1 = DexDescription_Kakuna_1, + .descriptionPage2 = DexDescription_Kakuna_2, + .pokemonScale = 424, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Beedrill + .categoryName = _("POISON BEE"), + .height = 10, + .weight = 295, + .descriptionPage1 = DexDescription_Beedrill_1, + .descriptionPage2 = DexDescription_Beedrill_2, + .pokemonScale = 366, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Pidgey + .categoryName = _("TINY BIRD"), + .height = 3, + .weight = 18, + .descriptionPage1 = DexDescription_Pidgey_1, + .descriptionPage2 = DexDescription_Pidgey_2, + .pokemonScale = 508, + .pokemonOffset = -3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Pidgeotto + .categoryName = _("BIRD"), + .height = 11, + .weight = 300, + .descriptionPage1 = DexDescription_Pidgeotto_1, + .descriptionPage2 = DexDescription_Pidgeotto_2, + .pokemonScale = 331, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Pidgeot + .categoryName = _("BIRD"), + .height = 15, + .weight = 395, + .descriptionPage1 = DexDescription_Pidgeot_1, + .descriptionPage2 = DexDescription_Pidgeot_2, + .pokemonScale = 269, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Rattata + .categoryName = _("MOUSE"), + .height = 3, + .weight = 35, + .descriptionPage1 = DexDescription_Rattata_1, + .descriptionPage2 = DexDescription_Rattata_2, + .pokemonScale = 481, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Raticate + .categoryName = _("MOUSE"), + .height = 7, + .weight = 185, + .descriptionPage1 = DexDescription_Raticate_1, + .descriptionPage2 = DexDescription_Raticate_2, + .pokemonScale = 459, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Spearow + .categoryName = _("TINY BIRD"), + .height = 3, + .weight = 20, + .descriptionPage1 = DexDescription_Spearow_1, + .descriptionPage2 = DexDescription_Spearow_2, + .pokemonScale = 571, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Fearow + .categoryName = _("BEAK"), + .height = 12, + .weight = 380, + .descriptionPage1 = DexDescription_Fearow_1, + .descriptionPage2 = DexDescription_Fearow_2, + .pokemonScale = 278, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Ekans + .categoryName = _("SNAKE"), + .height = 20, + .weight = 69, + .descriptionPage1 = DexDescription_Ekans_1, + .descriptionPage2 = DexDescription_Ekans_2, + .pokemonScale = 298, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Arbok + .categoryName = _("COBRA"), + .height = 35, + .weight = 650, + .descriptionPage1 = DexDescription_Arbok_1, + .descriptionPage2 = DexDescription_Arbok_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 296, + .trainerOffset = 2, + }, + { //Pikachu + .categoryName = _("MOUSE"), + .height = 4, + .weight = 60, + .descriptionPage1 = DexDescription_Pikachu_1, + .descriptionPage2 = DexDescription_Pikachu_2, + .pokemonScale = 479, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Raichu + .categoryName = _("MOUSE"), + .height = 8, + .weight = 300, + .descriptionPage1 = DexDescription_Raichu_1, + .descriptionPage2 = DexDescription_Raichu_2, + .pokemonScale = 426, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Sandshrew + .categoryName = _("MOUSE"), + .height = 6, + .weight = 120, + .descriptionPage1 = DexDescription_Sandshrew_1, + .descriptionPage2 = DexDescription_Sandshrew_2, + .pokemonScale = 365, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Sandslash + .categoryName = _("MOUSE"), + .height = 10, + .weight = 295, + .descriptionPage1 = DexDescription_Sandslash_1, + .descriptionPage2 = DexDescription_Sandslash_2, + .pokemonScale = 341, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //NidoranF + .categoryName = _("POISON PIN"), + .height = 4, + .weight = 70, + .descriptionPage1 = DexDescription_NidoranF_1, + .descriptionPage2 = DexDescription_NidoranF_2, + .pokemonScale = 488, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Nidorina + .categoryName = _("POISON PIN"), + .height = 8, + .weight = 200, + .descriptionPage1 = DexDescription_Nidorina_1, + .descriptionPage2 = DexDescription_Nidorina_2, + .pokemonScale = 381, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Nidoqueen + .categoryName = _("DRILL"), + .height = 13, + .weight = 600, + .descriptionPage1 = DexDescription_Nidoqueen_1, + .descriptionPage2 = DexDescription_Nidoqueen_2, + .pokemonScale = 293, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //NidoranM + .categoryName = _("POISON PIN"), + .height = 5, + .weight = 90, + .descriptionPage1 = DexDescription_NidoranM_1, + .descriptionPage2 = DexDescription_NidoranM_2, + .pokemonScale = 511, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Nidorino + .categoryName = _("POISON PIN"), + .height = 9, + .weight = 195, + .descriptionPage1 = DexDescription_Nidorino_1, + .descriptionPage2 = DexDescription_Nidorino_2, + .pokemonScale = 408, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Nidoking + .categoryName = _("DRILL"), + .height = 14, + .weight = 620, + .descriptionPage1 = DexDescription_Nidoking_1, + .descriptionPage2 = DexDescription_Nidoking_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Clefairy + .categoryName = _("FAIRY"), + .height = 6, + .weight = 75, + .descriptionPage1 = DexDescription_Clefairy_1, + .descriptionPage2 = DexDescription_Clefairy_2, + .pokemonScale = 441, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Clefable + .categoryName = _("FAIRY"), + .height = 13, + .weight = 400, + .descriptionPage1 = DexDescription_Clefable_1, + .descriptionPage2 = DexDescription_Clefable_2, + .pokemonScale = 256, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Vulpix + .categoryName = _("FOX"), + .height = 6, + .weight = 99, + .descriptionPage1 = DexDescription_Vulpix_1, + .descriptionPage2 = DexDescription_Vulpix_2, + .pokemonScale = 542, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Ninetales + .categoryName = _("FOX"), + .height = 11, + .weight = 199, + .descriptionPage1 = DexDescription_Ninetales_1, + .descriptionPage2 = DexDescription_Ninetales_2, + .pokemonScale = 339, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Jigglypuff + .categoryName = _("BALLOON"), + .height = 5, + .weight = 55, + .descriptionPage1 = DexDescription_Jigglypuff_1, + .descriptionPage2 = DexDescription_Jigglypuff_2, + .pokemonScale = 433, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Wigglytuff + .categoryName = _("BALLOON"), + .height = 10, + .weight = 120, + .descriptionPage1 = DexDescription_Wigglytuff_1, + .descriptionPage2 = DexDescription_Wigglytuff_2, + .pokemonScale = 328, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Zubat + .categoryName = _("BAT"), + .height = 8, + .weight = 75, + .descriptionPage1 = DexDescription_Zubat_1, + .descriptionPage2 = DexDescription_Zubat_2, + .pokemonScale = 362, + .pokemonOffset = -5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Golbat + .categoryName = _("BAT"), + .height = 16, + .weight = 550, + .descriptionPage1 = DexDescription_Golbat_1, + .descriptionPage2 = DexDescription_Golbat_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Oddish + .categoryName = _("WEED"), + .height = 5, + .weight = 54, + .descriptionPage1 = DexDescription_Oddish_1, + .descriptionPage2 = DexDescription_Oddish_2, + .pokemonScale = 423, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Gloom + .categoryName = _("WEED"), + .height = 8, + .weight = 86, + .descriptionPage1 = DexDescription_Gloom_1, + .descriptionPage2 = DexDescription_Gloom_2, + .pokemonScale = 329, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Vileplume + .categoryName = _("FLOWER"), + .height = 12, + .weight = 186, + .descriptionPage1 = DexDescription_Vileplume_1, + .descriptionPage2 = DexDescription_Vileplume_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Paras + .categoryName = _("MUSHROOM"), + .height = 3, + .weight = 54, + .descriptionPage1 = DexDescription_Paras_1, + .descriptionPage2 = DexDescription_Paras_2, + .pokemonScale = 593, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Parasect + .categoryName = _("MUSHROOM"), + .height = 10, + .weight = 295, + .descriptionPage1 = DexDescription_Parasect_1, + .descriptionPage2 = DexDescription_Parasect_2, + .pokemonScale = 307, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Venonat + .categoryName = _("INSECT"), + .height = 10, + .weight = 300, + .descriptionPage1 = DexDescription_Venonat_1, + .descriptionPage2 = DexDescription_Venonat_2, + .pokemonScale = 360, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = -1, + }, + { //Venomoth + .categoryName = _("POISON MOTH"), + .height = 15, + .weight = 125, + .descriptionPage1 = DexDescription_Venomoth_1, + .descriptionPage2 = DexDescription_Venomoth_2, + .pokemonScale = 285, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 1, + }, + { //Diglett + .categoryName = _("MOLE"), + .height = 2, + .weight = 8, + .descriptionPage1 = DexDescription_Diglett_1, + .descriptionPage2 = DexDescription_Diglett_2, + .pokemonScale = 833, + .pokemonOffset = 25, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Dugtrio + .categoryName = _("MOLE"), + .height = 7, + .weight = 333, + .descriptionPage1 = DexDescription_Dugtrio_1, + .descriptionPage2 = DexDescription_Dugtrio_2, + .pokemonScale = 406, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Meowth + .categoryName = _("SCRATCH CAT"), + .height = 4, + .weight = 42, + .descriptionPage1 = DexDescription_Meowth_1, + .descriptionPage2 = DexDescription_Meowth_2, + .pokemonScale = 480, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Persian + .categoryName = _("CLASSY CAT"), + .height = 10, + .weight = 320, + .descriptionPage1 = DexDescription_Persian_1, + .descriptionPage2 = DexDescription_Persian_2, + .pokemonScale = 320, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Psyduck + .categoryName = _("DUCK"), + .height = 8, + .weight = 196, + .descriptionPage1 = DexDescription_Psyduck_1, + .descriptionPage2 = DexDescription_Psyduck_2, + .pokemonScale = 369, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Golduck + .categoryName = _("DUCK"), + .height = 17, + .weight = 766, + .descriptionPage1 = DexDescription_Golduck_1, + .descriptionPage2 = DexDescription_Golduck_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 273, + .trainerOffset = 1, + }, + { //Mankey + .categoryName = _("PIG MONKEY"), + .height = 5, + .weight = 280, + .descriptionPage1 = DexDescription_Mankey_1, + .descriptionPage2 = DexDescription_Mankey_2, + .pokemonScale = 404, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Primeape + .categoryName = _("PIG MONKEY"), + .height = 10, + .weight = 320, + .descriptionPage1 = DexDescription_Primeape_1, + .descriptionPage2 = DexDescription_Primeape_2, + .pokemonScale = 326, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Growlithe + .categoryName = _("PUPPY"), + .height = 7, + .weight = 190, + .descriptionPage1 = DexDescription_Growlithe_1, + .descriptionPage2 = DexDescription_Growlithe_2, + .pokemonScale = 346, + .pokemonOffset = 14, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Arcanine + .categoryName = _("LEGENDARY"), + .height = 19, + .weight = 1550, + .descriptionPage1 = DexDescription_Arcanine_1, + .descriptionPage2 = DexDescription_Arcanine_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 312, + .trainerOffset = 4, + }, + { //Poliwag + .categoryName = _("TADPOLE"), + .height = 6, + .weight = 124, + .descriptionPage1 = DexDescription_Poliwag_1, + .descriptionPage2 = DexDescription_Poliwag_2, + .pokemonScale = 369, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Poliwhirl + .categoryName = _("TADPOLE"), + .height = 10, + .weight = 200, + .descriptionPage1 = DexDescription_Poliwhirl_1, + .descriptionPage2 = DexDescription_Poliwhirl_2, + .pokemonScale = 288, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Poliwrath + .categoryName = _("TADPOLE"), + .height = 13, + .weight = 540, + .descriptionPage1 = DexDescription_Poliwrath_1, + .descriptionPage2 = DexDescription_Poliwrath_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Abra + .categoryName = _("PSI"), + .height = 9, + .weight = 195, + .descriptionPage1 = DexDescription_Abra_1, + .descriptionPage2 = DexDescription_Abra_2, + .pokemonScale = 363, + .pokemonOffset = 14, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Kadabra + .categoryName = _("PSI"), + .height = 13, + .weight = 565, + .descriptionPage1 = DexDescription_Kadabra_1, + .descriptionPage2 = DexDescription_Kadabra_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Alakazam + .categoryName = _("PSI"), + .height = 15, + .weight = 480, + .descriptionPage1 = DexDescription_Alakazam_1, + .descriptionPage2 = DexDescription_Alakazam_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Machop + .categoryName = _("SUPERPOWER"), + .height = 8, + .weight = 195, + .descriptionPage1 = DexDescription_Machop_1, + .descriptionPage2 = DexDescription_Machop_2, + .pokemonScale = 342, + .pokemonOffset = 14, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Machoke + .categoryName = _("SUPERPOWER"), + .height = 15, + .weight = 705, + .descriptionPage1 = DexDescription_Machoke_1, + .descriptionPage2 = DexDescription_Machoke_2, + .pokemonScale = 323, + .pokemonOffset = 9, + .trainerScale = 257, + .trainerOffset = 0, + }, + { //Machamp + .categoryName = _("SUPERPOWER"), + .height = 16, + .weight = 1300, + .descriptionPage1 = DexDescription_Machamp_1, + .descriptionPage2 = DexDescription_Machamp_2, + .pokemonScale = 280, + .pokemonOffset = 1, + .trainerScale = 269, + .trainerOffset = -1, + }, + { //Bellsprout + .categoryName = _("FLOWER"), + .height = 7, + .weight = 40, + .descriptionPage1 = DexDescription_Bellsprout_1, + .descriptionPage2 = DexDescription_Bellsprout_2, + .pokemonScale = 354, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Weepinbell + .categoryName = _("FLYCATCHER"), + .height = 10, + .weight = 64, + .descriptionPage1 = DexDescription_Weepinbell_1, + .descriptionPage2 = DexDescription_Weepinbell_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Victreebel + .categoryName = _("FLYCATCHER"), + .height = 17, + .weight = 155, + .descriptionPage1 = DexDescription_Victreebel_1, + .descriptionPage2 = DexDescription_Victreebel_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 312, + .trainerOffset = 3, + }, + { //Tentacool + .categoryName = _("JELLYFISH"), + .height = 9, + .weight = 455, + .descriptionPage1 = DexDescription_Tentacool_1, + .descriptionPage2 = DexDescription_Tentacool_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Tentacruel + .categoryName = _("JELLYFISH"), + .height = 16, + .weight = 550, + .descriptionPage1 = DexDescription_Tentacruel_1, + .descriptionPage2 = DexDescription_Tentacruel_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 312, + .trainerOffset = 1, + }, + { //Geodude + .categoryName = _("ROCK"), + .height = 4, + .weight = 200, + .descriptionPage1 = DexDescription_Geodude_1, + .descriptionPage2 = DexDescription_Geodude_2, + .pokemonScale = 347, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Graveler + .categoryName = _("ROCK"), + .height = 10, + .weight = 1050, + .descriptionPage1 = DexDescription_Graveler_1, + .descriptionPage2 = DexDescription_Graveler_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Golem + .categoryName = _("MEGATON"), + .height = 14, + .weight = 3000, + .descriptionPage1 = DexDescription_Golem_1, + .descriptionPage2 = DexDescription_Golem_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 296, + .trainerOffset = 2, + }, + { //Ponyta + .categoryName = _("FIRE HORSE"), + .height = 10, + .weight = 300, + .descriptionPage1 = DexDescription_Ponyta_1, + .descriptionPage2 = DexDescription_Ponyta_2, + .pokemonScale = 283, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Rapidash + .categoryName = _("FIRE HORSE"), + .height = 17, + .weight = 950, + .descriptionPage1 = DexDescription_Rapidash_1, + .descriptionPage2 = DexDescription_Rapidash_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 289, + .trainerOffset = 1, + }, + { //Slowpoke + .categoryName = _("DOPEY"), + .height = 12, + .weight = 360, + .descriptionPage1 = DexDescription_Slowpoke_1, + .descriptionPage2 = DexDescription_Slowpoke_2, + .pokemonScale = 256, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Slowbro + .categoryName = _("HERMIT CRAB"), + .height = 16, + .weight = 785, + .descriptionPage1 = DexDescription_Slowbro_1, + .descriptionPage2 = DexDescription_Slowbro_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 296, + .trainerOffset = 2, + }, + { //Magnemite + .categoryName = _("MAGNET"), + .height = 3, + .weight = 60, + .descriptionPage1 = DexDescription_Magnemite_1, + .descriptionPage2 = DexDescription_Magnemite_2, + .pokemonScale = 288, + .pokemonOffset = -9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Magneton + .categoryName = _("MAGNET"), + .height = 10, + .weight = 600, + .descriptionPage1 = DexDescription_Magneton_1, + .descriptionPage2 = DexDescription_Magneton_2, + .pokemonScale = 292, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Farfetchd + .categoryName = _("WILD DUCK"), + .height = 8, + .weight = 150, + .descriptionPage1 = DexDescription_Farfetchd_1, + .descriptionPage2 = DexDescription_Farfetchd_2, + .pokemonScale = 330, + .pokemonOffset = 2, + .trainerScale = 293, + .trainerOffset = 2, + }, + { //Doduo + .categoryName = _("TWIN BIRD"), + .height = 14, + .weight = 392, + .descriptionPage1 = DexDescription_Doduo_1, + .descriptionPage2 = DexDescription_Doduo_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 257, + .trainerOffset = -1, + }, + { //Dodrio + .categoryName = _("TRIPLE BIRD"), + .height = 18, + .weight = 852, + .descriptionPage1 = DexDescription_Dodrio_1, + .descriptionPage2 = DexDescription_Dodrio_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 268, + .trainerOffset = 0, + }, + { //Seel + .categoryName = _("SEA LION"), + .height = 11, + .weight = 900, + .descriptionPage1 = DexDescription_Seel_1, + .descriptionPage2 = DexDescription_Seel_2, + .pokemonScale = 297, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Dewgong + .categoryName = _("SEA LION"), + .height = 17, + .weight = 1200, + .descriptionPage1 = DexDescription_Dewgong_1, + .descriptionPage2 = DexDescription_Dewgong_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 275, + .trainerOffset = 0, + }, + { //Grimer + .categoryName = _("SLUDGE"), + .height = 9, + .weight = 300, + .descriptionPage1 = DexDescription_Grimer_1, + .descriptionPage2 = DexDescription_Grimer_2, + .pokemonScale = 258, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Muk + .categoryName = _("SLUDGE"), + .height = 12, + .weight = 300, + .descriptionPage1 = DexDescription_Muk_1, + .descriptionPage2 = DexDescription_Muk_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Shellder + .categoryName = _("BIVALVE"), + .height = 3, + .weight = 40, + .descriptionPage1 = DexDescription_Shellder_1, + .descriptionPage2 = DexDescription_Shellder_2, + .pokemonScale = 675, + .pokemonOffset = 24, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Cloyster + .categoryName = _("BIVALVE"), + .height = 15, + .weight = 1325, + .descriptionPage1 = DexDescription_Cloyster_1, + .descriptionPage2 = DexDescription_Cloyster_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 269, + .trainerOffset = 1, + }, + { //Gastly + .categoryName = _("GAS"), + .height = 13, + .weight = 1, + .descriptionPage1 = DexDescription_Gastly_1, + .descriptionPage2 = DexDescription_Gastly_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Haunter + .categoryName = _("GAS"), + .height = 16, + .weight = 1, + .descriptionPage1 = DexDescription_Haunter_1, + .descriptionPage2 = DexDescription_Haunter_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 293, + .trainerOffset = 2, + }, + { //Gengar + .categoryName = _("SHADOW"), + .height = 15, + .weight = 405, + .descriptionPage1 = DexDescription_Gengar_1, + .descriptionPage2 = DexDescription_Gengar_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 302, + .trainerOffset = 2, + }, + { //Onix + .categoryName = _("ROCK SNAKE"), + .height = 88, + .weight = 2100, + .descriptionPage1 = DexDescription_Onix_1, + .descriptionPage2 = DexDescription_Onix_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 515, + .trainerOffset = 14, + }, + { //Drowzee + .categoryName = _("HYPNOSIS"), + .height = 10, + .weight = 324, + .descriptionPage1 = DexDescription_Drowzee_1, + .descriptionPage2 = DexDescription_Drowzee_2, + .pokemonScale = 274, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Hypno + .categoryName = _("HYPNOSIS"), + .height = 16, + .weight = 756, + .descriptionPage1 = DexDescription_Hypno_1, + .descriptionPage2 = DexDescription_Hypno_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 257, + .trainerOffset = 0, + }, + { //Krabby + .categoryName = _("RIVER CRAB"), + .height = 4, + .weight = 65, + .descriptionPage1 = DexDescription_Krabby_1, + .descriptionPage2 = DexDescription_Krabby_2, + .pokemonScale = 469, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Kingler + .categoryName = _("PINCER"), + .height = 13, + .weight = 600, + .descriptionPage1 = DexDescription_Kingler_1, + .descriptionPage2 = DexDescription_Kingler_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Voltorb + .categoryName = _("BALL"), + .height = 5, + .weight = 104, + .descriptionPage1 = DexDescription_Voltorb_1, + .descriptionPage2 = DexDescription_Voltorb_2, + .pokemonScale = 364, + .pokemonOffset = -8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Electrode + .categoryName = _("BALL"), + .height = 12, + .weight = 666, + .descriptionPage1 = DexDescription_Electrode_1, + .descriptionPage2 = DexDescription_Electrode_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Exeggcute + .categoryName = _("EGG"), + .height = 4, + .weight = 25, + .descriptionPage1 = DexDescription_Exeggcute_1, + .descriptionPage2 = DexDescription_Exeggcute_2, + .pokemonScale = 489, + .pokemonOffset = -4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Exeggutor + .categoryName = _("COCONUT"), + .height = 20, + .weight = 1200, + .descriptionPage1 = DexDescription_Exeggutor_1, + .descriptionPage2 = DexDescription_Exeggutor_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 309, + .trainerOffset = 5, + }, + { //Cubone + .categoryName = _("LONELY"), + .height = 4, + .weight = 65, + .descriptionPage1 = DexDescription_Cubone_1, + .descriptionPage2 = DexDescription_Cubone_2, + .pokemonScale = 545, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Marowak + .categoryName = _("BONE KEEPER"), + .height = 10, + .weight = 450, + .descriptionPage1 = DexDescription_Marowak_1, + .descriptionPage2 = DexDescription_Marowak_2, + .pokemonScale = 293, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Hitmonlee + .categoryName = _("KICKING"), + .height = 15, + .weight = 498, + .descriptionPage1 = DexDescription_Hitmonlee_1, + .descriptionPage2 = DexDescription_Hitmonlee_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 259, + .trainerOffset = 1, + }, + { //Hitmonchan + .categoryName = _("PUNCHING"), + .height = 14, + .weight = 502, + .descriptionPage1 = DexDescription_Hitmonchan_1, + .descriptionPage2 = DexDescription_Hitmonchan_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 277, + .trainerOffset = 2, + }, + { //Lickitung + .categoryName = _("LICKING"), + .height = 12, + .weight = 655, + .descriptionPage1 = DexDescription_Lickitung_1, + .descriptionPage2 = DexDescription_Lickitung_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Koffing + .categoryName = _("POISON GAS"), + .height = 6, + .weight = 10, + .descriptionPage1 = DexDescription_Koffing_1, + .descriptionPage2 = DexDescription_Koffing_2, + .pokemonScale = 369, + .pokemonOffset = -1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Weezing + .categoryName = _("POISON GAS"), + .height = 12, + .weight = 95, + .descriptionPage1 = DexDescription_Weezing_1, + .descriptionPage2 = DexDescription_Weezing_2, + .pokemonScale = 305, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Rhyhorn + .categoryName = _("SPIKES"), + .height = 10, + .weight = 1150, + .descriptionPage1 = DexDescription_Rhyhorn_1, + .descriptionPage2 = DexDescription_Rhyhorn_2, + .pokemonScale = 267, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Rhydon + .categoryName = _("DRILL"), + .height = 19, + .weight = 1200, + .descriptionPage1 = DexDescription_Rhydon_1, + .descriptionPage2 = DexDescription_Rhydon_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 299, + .trainerOffset = 2, + }, + { //Chansey + .categoryName = _("EGG"), + .height = 11, + .weight = 346, + .descriptionPage1 = DexDescription_Chansey_1, + .descriptionPage2 = DexDescription_Chansey_2, + .pokemonScale = 257, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Tangela + .categoryName = _("VINE"), + .height = 10, + .weight = 350, + .descriptionPage1 = DexDescription_Tangela_1, + .descriptionPage2 = DexDescription_Tangela_2, + .pokemonScale = 304, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Kangaskhan + .categoryName = _("PARENT"), + .height = 22, + .weight = 800, + .descriptionPage1 = DexDescription_Kangaskhan_1, + .descriptionPage2 = DexDescription_Kangaskhan_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 387, + .trainerOffset = 8, + }, + { //Horsea + .categoryName = _("DRAGON"), + .height = 4, + .weight = 80, + .descriptionPage1 = DexDescription_Horsea_1, + .descriptionPage2 = DexDescription_Horsea_2, + .pokemonScale = 399, + .pokemonOffset = -1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Seadra + .categoryName = _("DRAGON"), + .height = 12, + .weight = 250, + .descriptionPage1 = DexDescription_Seadra_1, + .descriptionPage2 = DexDescription_Seadra_2, + .pokemonScale = 299, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Goldeen + .categoryName = _("GOLDFISH"), + .height = 6, + .weight = 150, + .descriptionPage1 = DexDescription_Goldeen_1, + .descriptionPage2 = DexDescription_Goldeen_2, + .pokemonScale = 379, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Seaking + .categoryName = _("GOLDFISH"), + .height = 13, + .weight = 390, + .descriptionPage1 = DexDescription_Seaking_1, + .descriptionPage2 = DexDescription_Seaking_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Staryu + .categoryName = _("STAR SHAPE"), + .height = 8, + .weight = 345, + .descriptionPage1 = DexDescription_Staryu_1, + .descriptionPage2 = DexDescription_Staryu_2, + .pokemonScale = 326, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Starmie + .categoryName = _("MYSTERIOUS"), + .height = 11, + .weight = 800, + .descriptionPage1 = DexDescription_Starmie_1, + .descriptionPage2 = DexDescription_Starmie_2, + .pokemonScale = 301, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Mrmime + .categoryName = _("BARRIER"), + .height = 13, + .weight = 545, + .descriptionPage1 = DexDescription_Mrmime_1, + .descriptionPage2 = DexDescription_Mrmime_2, + .pokemonScale = 258, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Scyther + .categoryName = _("MANTIS"), + .height = 15, + .weight = 560, + .descriptionPage1 = DexDescription_Scyther_1, + .descriptionPage2 = DexDescription_Scyther_2, + .pokemonScale = 256, + .pokemonOffset = 1, + .trainerScale = 293, + .trainerOffset = 2, + }, + { //Jynx + .categoryName = _("HUMAN SHAPE"), + .height = 14, + .weight = 406, + .descriptionPage1 = DexDescription_Jynx_1, + .descriptionPage2 = DexDescription_Jynx_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 300, + .trainerOffset = 1, + }, + { //Electabuzz + .categoryName = _("ELECTRIC"), + .height = 11, + .weight = 300, + .descriptionPage1 = DexDescription_Electabuzz_1, + .descriptionPage2 = DexDescription_Electabuzz_2, + .pokemonScale = 351, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Magmar + .categoryName = _("SPITFIRE"), + .height = 13, + .weight = 445, + .descriptionPage1 = DexDescription_Magmar_1, + .descriptionPage2 = DexDescription_Magmar_2, + .pokemonScale = 277, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Pinsir + .categoryName = _("STAG BEETLE"), + .height = 15, + .weight = 550, + .descriptionPage1 = DexDescription_Pinsir_1, + .descriptionPage2 = DexDescription_Pinsir_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 257, + .trainerOffset = 0, + }, + { //Tauros + .categoryName = _("WILD BULL"), + .height = 14, + .weight = 884, + .descriptionPage1 = DexDescription_Tauros_1, + .descriptionPage2 = DexDescription_Tauros_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Magikarp + .categoryName = _("FISH"), + .height = 9, + .weight = 100, + .descriptionPage1 = DexDescription_Magikarp_1, + .descriptionPage2 = DexDescription_Magikarp_2, + .pokemonScale = 310, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Gyarados + .categoryName = _("ATROCIOUS"), + .height = 65, + .weight = 2350, + .descriptionPage1 = DexDescription_Gyarados_1, + .descriptionPage2 = DexDescription_Gyarados_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 481, + .trainerOffset = 13, + }, + { //Lapras + .categoryName = _("TRANSPORT"), + .height = 25, + .weight = 2200, + .descriptionPage1 = DexDescription_Lapras_1, + .descriptionPage2 = DexDescription_Lapras_2, + .pokemonScale = 257, + .pokemonOffset = 10, + .trainerScale = 423, + .trainerOffset = 8, + }, + { //Ditto + .categoryName = _("TRANSFORM"), + .height = 3, + .weight = 40, + .descriptionPage1 = DexDescription_Ditto_1, + .descriptionPage2 = DexDescription_Ditto_2, + .pokemonScale = 633, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Eevee + .categoryName = _("EVOLUTION"), + .height = 3, + .weight = 65, + .descriptionPage1 = DexDescription_Eevee_1, + .descriptionPage2 = DexDescription_Eevee_2, + .pokemonScale = 476, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Vaporeon + .categoryName = _("BUBBLE JET"), + .height = 10, + .weight = 290, + .descriptionPage1 = DexDescription_Vaporeon_1, + .descriptionPage2 = DexDescription_Vaporeon_2, + .pokemonScale = 316, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Jolteon + .categoryName = _("LIGHTNING"), + .height = 8, + .weight = 245, + .descriptionPage1 = DexDescription_Jolteon_1, + .descriptionPage2 = DexDescription_Jolteon_2, + .pokemonScale = 283, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Flareon + .categoryName = _("FLAME"), + .height = 9, + .weight = 250, + .descriptionPage1 = DexDescription_Flareon_1, + .descriptionPage2 = DexDescription_Flareon_2, + .pokemonScale = 306, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Porygon + .categoryName = _("VIRTUAL"), + .height = 8, + .weight = 365, + .descriptionPage1 = DexDescription_Porygon_1, + .descriptionPage2 = DexDescription_Porygon_2, + .pokemonScale = 328, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Omanyte + .categoryName = _("SPIRAL"), + .height = 4, + .weight = 75, + .descriptionPage1 = DexDescription_Omanyte_1, + .descriptionPage2 = DexDescription_Omanyte_2, + .pokemonScale = 521, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Omastar + .categoryName = _("SPIRAL"), + .height = 10, + .weight = 350, + .descriptionPage1 = DexDescription_Omastar_1, + .descriptionPage2 = DexDescription_Omastar_2, + .pokemonScale = 307, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Kabuto + .categoryName = _("SHELLFISH"), + .height = 5, + .weight = 115, + .descriptionPage1 = DexDescription_Kabuto_1, + .descriptionPage2 = DexDescription_Kabuto_2, + .pokemonScale = 454, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Kabutops + .categoryName = _("SHELLFISH"), + .height = 13, + .weight = 405, + .descriptionPage1 = DexDescription_Kabutops_1, + .descriptionPage2 = DexDescription_Kabutops_2, + .pokemonScale = 271, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Aerodactyl + .categoryName = _("FOSSIL"), + .height = 18, + .weight = 590, + .descriptionPage1 = DexDescription_Aerodactyl_1, + .descriptionPage2 = DexDescription_Aerodactyl_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 302, + .trainerOffset = 4, + }, + { //Snorlax + .categoryName = _("SLEEPING"), + .height = 21, + .weight = 4600, + .descriptionPage1 = DexDescription_Snorlax_1, + .descriptionPage2 = DexDescription_Snorlax_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 423, + .trainerOffset = 11, + }, + { //Articuno + .categoryName = _("FREEZE"), + .height = 17, + .weight = 554, + .descriptionPage1 = DexDescription_Articuno_1, + .descriptionPage2 = DexDescription_Articuno_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 309, + .trainerOffset = 2, + }, + { //Zapdos + .categoryName = _("ELECTRIC"), + .height = 16, + .weight = 526, + .descriptionPage1 = DexDescription_Zapdos_1, + .descriptionPage2 = DexDescription_Zapdos_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 318, + .trainerOffset = 3, + }, + { //Moltres + .categoryName = _("FLAME"), + .height = 20, + .weight = 600, + .descriptionPage1 = DexDescription_Moltres_1, + .descriptionPage2 = DexDescription_Moltres_2, + .pokemonScale = 270, + .pokemonOffset = 0, + .trainerScale = 387, + .trainerOffset = 8, + }, + { //Dratini + .categoryName = _("DRAGON"), + .height = 18, + .weight = 33, + .descriptionPage1 = DexDescription_Dratini_1, + .descriptionPage2 = DexDescription_Dratini_2, + .pokemonScale = 256, + .pokemonOffset = 8, + .trainerScale = 386, + .trainerOffset = 6, + }, + { //Dragonair + .categoryName = _("DRAGON"), + .height = 40, + .weight = 165, + .descriptionPage1 = DexDescription_Dragonair_1, + .descriptionPage2 = DexDescription_Dragonair_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 411, + .trainerOffset = 5, + }, + { //Dragonite + .categoryName = _("DRAGON"), + .height = 22, + .weight = 2100, + .descriptionPage1 = DexDescription_Dragonite_1, + .descriptionPage2 = DexDescription_Dragonite_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 309, + .trainerOffset = 4, + }, + { //Mewtwo + .categoryName = _("GENETIC"), + .height = 20, + .weight = 1220, + .descriptionPage1 = DexDescription_Mewtwo_1, + .descriptionPage2 = DexDescription_Mewtwo_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 309, + .trainerOffset = 4, + }, + { //Mew + .categoryName = _("NEW SPECIES"), + .height = 4, + .weight = 40, + .descriptionPage1 = DexDescription_Mew_1, + .descriptionPage2 = DexDescription_Mew_2, + .pokemonScale = 457, + .pokemonOffset = -2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Chikorita + .categoryName = _("LEAF"), + .height = 9, + .weight = 64, + .descriptionPage1 = DexDescription_Chikorita_1, + .descriptionPage2 = DexDescription_Chikorita_2, + .pokemonScale = 512, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Bayleef + .categoryName = _("LEAF"), + .height = 12, + .weight = 158, + .descriptionPage1 = DexDescription_Bayleef_1, + .descriptionPage2 = DexDescription_Bayleef_2, + .pokemonScale = 296, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Meganium + .categoryName = _("HERB"), + .height = 18, + .weight = 1005, + .descriptionPage1 = DexDescription_Meganium_1, + .descriptionPage2 = DexDescription_Meganium_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 277, + .trainerOffset = 1, + }, + { //Cyndaquil + .categoryName = _("FIRE MOUSE"), + .height = 5, + .weight = 79, + .descriptionPage1 = DexDescription_Cyndaquil_1, + .descriptionPage2 = DexDescription_Cyndaquil_2, + .pokemonScale = 539, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Quilava + .categoryName = _("VOLCANO"), + .height = 9, + .weight = 190, + .descriptionPage1 = DexDescription_Quilava_1, + .descriptionPage2 = DexDescription_Quilava_2, + .pokemonScale = 329, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Typhlosion + .categoryName = _("VOLCANO"), + .height = 17, + .weight = 795, + .descriptionPage1 = DexDescription_Typhlosion_1, + .descriptionPage2 = DexDescription_Typhlosion_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 268, + .trainerOffset = 1, + }, + { //Totodile + .categoryName = _("BIG JAW"), + .height = 6, + .weight = 95, + .descriptionPage1 = DexDescription_Totodile_1, + .descriptionPage2 = DexDescription_Totodile_2, + .pokemonScale = 487, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Croconaw + .categoryName = _("BIG JAW"), + .height = 11, + .weight = 250, + .descriptionPage1 = DexDescription_Croconaw_1, + .descriptionPage2 = DexDescription_Croconaw_2, + .pokemonScale = 378, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Feraligatr + .categoryName = _("BIG JAW"), + .height = 23, + .weight = 888, + .descriptionPage1 = DexDescription_Feraligatr_1, + .descriptionPage2 = DexDescription_Feraligatr_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 342, + .trainerOffset = 7, + }, + { //Sentret + .categoryName = _("SCOUT"), + .height = 8, + .weight = 60, + .descriptionPage1 = DexDescription_Sentret_1, + .descriptionPage2 = DexDescription_Sentret_2, + .pokemonScale = 439, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Furret + .categoryName = _("LONG BODY"), + .height = 18, + .weight = 325, + .descriptionPage1 = DexDescription_Furret_1, + .descriptionPage2 = DexDescription_Furret_2, + .pokemonScale = 346, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Hoothoot + .categoryName = _("OWL"), + .height = 7, + .weight = 212, + .descriptionPage1 = DexDescription_Hoothoot_1, + .descriptionPage2 = DexDescription_Hoothoot_2, + .pokemonScale = 380, + .pokemonOffset = -2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Noctowl + .categoryName = _("OWL"), + .height = 16, + .weight = 408, + .descriptionPage1 = DexDescription_Noctowl_1, + .descriptionPage2 = DexDescription_Noctowl_2, + .pokemonScale = 278, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Ledyba + .categoryName = _("FIVE STAR"), + .height = 10, + .weight = 108, + .descriptionPage1 = DexDescription_Ledyba_1, + .descriptionPage2 = DexDescription_Ledyba_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Ledian + .categoryName = _("FIVE STAR"), + .height = 14, + .weight = 356, + .descriptionPage1 = DexDescription_Ledian_1, + .descriptionPage2 = DexDescription_Ledian_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Spinarak + .categoryName = _("STRING SPIT"), + .height = 5, + .weight = 85, + .descriptionPage1 = DexDescription_Spinarak_1, + .descriptionPage2 = DexDescription_Spinarak_2, + .pokemonScale = 414, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Ariados + .categoryName = _("LONG LEG"), + .height = 11, + .weight = 335, + .descriptionPage1 = DexDescription_Ariados_1, + .descriptionPage2 = DexDescription_Ariados_2, + .pokemonScale = 316, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Crobat + .categoryName = _("BAT"), + .height = 18, + .weight = 750, + .descriptionPage1 = DexDescription_Crobat_1, + .descriptionPage2 = DexDescription_Crobat_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 281, + .trainerOffset = 1, + }, + { //Chinchou + .categoryName = _("ANGLER"), + .height = 5, + .weight = 120, + .descriptionPage1 = DexDescription_Chinchou_1, + .descriptionPage2 = DexDescription_Chinchou_2, + .pokemonScale = 424, + .pokemonOffset = -2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Lanturn + .categoryName = _("LIGHT"), + .height = 12, + .weight = 225, + .descriptionPage1 = DexDescription_Lanturn_1, + .descriptionPage2 = DexDescription_Lanturn_2, + .pokemonScale = 269, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Pichu + .categoryName = _("TINY MOUSE"), + .height = 3, + .weight = 20, + .descriptionPage1 = DexDescription_Pichu_1, + .descriptionPage2 = DexDescription_Pichu_2, + .pokemonScale = 508, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Cleffa + .categoryName = _("STAR SHAPE"), + .height = 3, + .weight = 30, + .descriptionPage1 = DexDescription_Cleffa_1, + .descriptionPage2 = DexDescription_Cleffa_2, + .pokemonScale = 462, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Igglybuff + .categoryName = _("BALLOON"), + .height = 3, + .weight = 10, + .descriptionPage1 = DexDescription_Igglybuff_1, + .descriptionPage2 = DexDescription_Igglybuff_2, + .pokemonScale = 457, + .pokemonOffset = -1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Togepi + .categoryName = _("SPIKE BALL"), + .height = 3, + .weight = 15, + .descriptionPage1 = DexDescription_Togepi_1, + .descriptionPage2 = DexDescription_Togepi_2, + .pokemonScale = 507, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Togetic + .categoryName = _("HAPPINESS"), + .height = 6, + .weight = 32, + .descriptionPage1 = DexDescription_Togetic_1, + .descriptionPage2 = DexDescription_Togetic_2, + .pokemonScale = 424, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Natu + .categoryName = _("TINY BIRD"), + .height = 2, + .weight = 20, + .descriptionPage1 = DexDescription_Natu_1, + .descriptionPage2 = DexDescription_Natu_2, + .pokemonScale = 610, + .pokemonOffset = 25, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Xatu + .categoryName = _("MYSTIC"), + .height = 15, + .weight = 150, + .descriptionPage1 = DexDescription_Xatu_1, + .descriptionPage2 = DexDescription_Xatu_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 318, + .trainerOffset = 4, + }, + { //Mareep + .categoryName = _("WOOL"), + .height = 6, + .weight = 78, + .descriptionPage1 = DexDescription_Mareep_1, + .descriptionPage2 = DexDescription_Mareep_2, + .pokemonScale = 379, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Flaaffy + .categoryName = _("WOOL"), + .height = 8, + .weight = 133, + .descriptionPage1 = DexDescription_Flaaffy_1, + .descriptionPage2 = DexDescription_Flaaffy_2, + .pokemonScale = 372, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Ampharos + .categoryName = _("LIGHT"), + .height = 14, + .weight = 615, + .descriptionPage1 = DexDescription_Ampharos_1, + .descriptionPage2 = DexDescription_Ampharos_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Bellossom + .categoryName = _("FLOWER"), + .height = 4, + .weight = 58, + .descriptionPage1 = DexDescription_Bellossom_1, + .descriptionPage2 = DexDescription_Bellossom_2, + .pokemonScale = 472, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Marill + .categoryName = _("AQUA MOUSE"), + .height = 4, + .weight = 85, + .descriptionPage1 = DexDescription_Marill_1, + .descriptionPage2 = DexDescription_Marill_2, + .pokemonScale = 476, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Azumarill + .categoryName = _("AQUA RABBIT"), + .height = 8, + .weight = 285, + .descriptionPage1 = DexDescription_Azumarill_1, + .descriptionPage2 = DexDescription_Azumarill_2, + .pokemonScale = 448, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Sudowoodo + .categoryName = _("IMITATION"), + .height = 12, + .weight = 380, + .descriptionPage1 = DexDescription_Sudowoodo_1, + .descriptionPage2 = DexDescription_Sudowoodo_2, + .pokemonScale = 305, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Politoed + .categoryName = _("FROG"), + .height = 11, + .weight = 339, + .descriptionPage1 = DexDescription_Politoed_1, + .descriptionPage2 = DexDescription_Politoed_2, + .pokemonScale = 289, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Hoppip + .categoryName = _("COTTONWEED"), + .height = 4, + .weight = 5, + .descriptionPage1 = DexDescription_Hoppip_1, + .descriptionPage2 = DexDescription_Hoppip_2, + .pokemonScale = 562, + .pokemonOffset = -7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Skiploom + .categoryName = _("COTTONWEED"), + .height = 6, + .weight = 10, + .descriptionPage1 = DexDescription_Skiploom_1, + .descriptionPage2 = DexDescription_Skiploom_2, + .pokemonScale = 387, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Jumpluff + .categoryName = _("COTTONWEED"), + .height = 8, + .weight = 30, + .descriptionPage1 = DexDescription_Jumpluff_1, + .descriptionPage2 = DexDescription_Jumpluff_2, + .pokemonScale = 418, + .pokemonOffset = -4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Aipom + .categoryName = _("LONG TAIL"), + .height = 8, + .weight = 115, + .descriptionPage1 = DexDescription_Aipom_1, + .descriptionPage2 = DexDescription_Aipom_2, + .pokemonScale = 363, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Sunkern + .categoryName = _("SEED"), + .height = 3, + .weight = 18, + .descriptionPage1 = DexDescription_Sunkern_1, + .descriptionPage2 = DexDescription_Sunkern_2, + .pokemonScale = 541, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Sunflora + .categoryName = _("SUN"), + .height = 8, + .weight = 85, + .descriptionPage1 = DexDescription_Sunflora_1, + .descriptionPage2 = DexDescription_Sunflora_2, + .pokemonScale = 444, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Yanma + .categoryName = _("CLEAR WING"), + .height = 12, + .weight = 380, + .descriptionPage1 = DexDescription_Yanma_1, + .descriptionPage2 = DexDescription_Yanma_2, + .pokemonScale = 274, + .pokemonOffset = -1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Wooper + .categoryName = _("WATER FISH"), + .height = 4, + .weight = 85, + .descriptionPage1 = DexDescription_Wooper_1, + .descriptionPage2 = DexDescription_Wooper_2, + .pokemonScale = 479, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Quagsire + .categoryName = _("WATER FISH"), + .height = 14, + .weight = 750, + .descriptionPage1 = DexDescription_Quagsire_1, + .descriptionPage2 = DexDescription_Quagsire_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Espeon + .categoryName = _("SUN"), + .height = 9, + .weight = 265, + .descriptionPage1 = DexDescription_Espeon_1, + .descriptionPage2 = DexDescription_Espeon_2, + .pokemonScale = 363, + .pokemonOffset = 14, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Umbreon + .categoryName = _("MOONLIGHT"), + .height = 10, + .weight = 270, + .descriptionPage1 = DexDescription_Umbreon_1, + .descriptionPage2 = DexDescription_Umbreon_2, + .pokemonScale = 317, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Murkrow + .categoryName = _("DARKNESS"), + .height = 5, + .weight = 21, + .descriptionPage1 = DexDescription_Murkrow_1, + .descriptionPage2 = DexDescription_Murkrow_2, + .pokemonScale = 401, + .pokemonOffset = -8, + .trainerScale = 256, + .trainerOffset = 1, + }, + { //Slowking + .categoryName = _("ROYAL"), + .height = 20, + .weight = 795, + .descriptionPage1 = DexDescription_Slowking_1, + .descriptionPage2 = DexDescription_Slowking_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 309, + .trainerOffset = 5, + }, + { //Misdreavus + .categoryName = _("SCREECH"), + .height = 7, + .weight = 10, + .descriptionPage1 = DexDescription_Misdreavus_1, + .descriptionPage2 = DexDescription_Misdreavus_2, + .pokemonScale = 407, + .pokemonOffset = -8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Unown + .categoryName = _("SYMBOL"), + .height = 5, + .weight = 50, + .descriptionPage1 = DexDescription_Unown_1, + .descriptionPage2 = DexDescription_Unown_2, + .pokemonScale = 411, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Wobbuffet + .categoryName = _("PATIENT"), + .height = 13, + .weight = 285, + .descriptionPage1 = DexDescription_Wobbuffet_1, + .descriptionPage2 = DexDescription_Wobbuffet_2, + .pokemonScale = 274, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Girafarig + .categoryName = _("LONG NECK"), + .height = 15, + .weight = 415, + .descriptionPage1 = DexDescription_Girafarig_1, + .descriptionPage2 = DexDescription_Girafarig_2, + .pokemonScale = 281, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Pineco + .categoryName = _("BAGWORM"), + .height = 6, + .weight = 72, + .descriptionPage1 = DexDescription_Pineco_1, + .descriptionPage2 = DexDescription_Pineco_2, + .pokemonScale = 445, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Forretress + .categoryName = _("BAGWORM"), + .height = 12, + .weight = 1258, + .descriptionPage1 = DexDescription_Forretress_1, + .descriptionPage2 = DexDescription_Forretress_2, + .pokemonScale = 293, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Dunsparce + .categoryName = _("LAND SNAKE"), + .height = 15, + .weight = 140, + .descriptionPage1 = DexDescription_Dunsparce_1, + .descriptionPage2 = DexDescription_Dunsparce_2, + .pokemonScale = 316, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Gligar + .categoryName = _("FLYSCORPION"), + .height = 11, + .weight = 648, + .descriptionPage1 = DexDescription_Gligar_1, + .descriptionPage2 = DexDescription_Gligar_2, + .pokemonScale = 350, + .pokemonOffset = -1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Steelix + .categoryName = _("IRON SNAKE"), + .height = 92, + .weight = 4000, + .descriptionPage1 = DexDescription_Steelix_1, + .descriptionPage2 = DexDescription_Steelix_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 516, + .trainerOffset = 13, + }, + { //Snubbull + .categoryName = _("FAIRY"), + .height = 6, + .weight = 78, + .descriptionPage1 = DexDescription_Snubbull_1, + .descriptionPage2 = DexDescription_Snubbull_2, + .pokemonScale = 465, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Granbull + .categoryName = _("FAIRY"), + .height = 14, + .weight = 487, + .descriptionPage1 = DexDescription_Granbull_1, + .descriptionPage2 = DexDescription_Granbull_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Qwilfish + .categoryName = _("BALLOON"), + .height = 5, + .weight = 39, + .descriptionPage1 = DexDescription_Qwilfish_1, + .descriptionPage2 = DexDescription_Qwilfish_2, + .pokemonScale = 430, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Scizor + .categoryName = _("PINCER"), + .height = 18, + .weight = 1180, + .descriptionPage1 = DexDescription_Scizor_1, + .descriptionPage2 = DexDescription_Scizor_2, + .pokemonScale = 278, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Shuckle + .categoryName = _("MOLD"), + .height = 6, + .weight = 205, + .descriptionPage1 = DexDescription_Shuckle_1, + .descriptionPage2 = DexDescription_Shuckle_2, + .pokemonScale = 485, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Heracross + .categoryName = _("SINGLE HORN"), + .height = 15, + .weight = 540, + .descriptionPage1 = DexDescription_Heracross_1, + .descriptionPage2 = DexDescription_Heracross_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Sneasel + .categoryName = _("SHARP CLAW"), + .height = 9, + .weight = 280, + .descriptionPage1 = DexDescription_Sneasel_1, + .descriptionPage2 = DexDescription_Sneasel_2, + .pokemonScale = 413, + .pokemonOffset = -3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Teddiursa + .categoryName = _("LITTLE BEAR"), + .height = 6, + .weight = 88, + .descriptionPage1 = DexDescription_Teddiursa_1, + .descriptionPage2 = DexDescription_Teddiursa_2, + .pokemonScale = 455, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Ursaring + .categoryName = _("HIBERNATOR"), + .height = 18, + .weight = 1258, + .descriptionPage1 = DexDescription_Ursaring_1, + .descriptionPage2 = DexDescription_Ursaring_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Slugma + .categoryName = _("LAVA"), + .height = 7, + .weight = 350, + .descriptionPage1 = DexDescription_Slugma_1, + .descriptionPage2 = DexDescription_Slugma_2, + .pokemonScale = 329, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Magcargo + .categoryName = _("LAVA"), + .height = 8, + .weight = 550, + .descriptionPage1 = DexDescription_Magcargo_1, + .descriptionPage2 = DexDescription_Magcargo_2, + .pokemonScale = 332, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Swinub + .categoryName = _("PIG"), + .height = 4, + .weight = 65, + .descriptionPage1 = DexDescription_Swinub_1, + .descriptionPage2 = DexDescription_Swinub_2, + .pokemonScale = 324, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Piloswine + .categoryName = _("SWINE"), + .height = 11, + .weight = 558, + .descriptionPage1 = DexDescription_Piloswine_1, + .descriptionPage2 = DexDescription_Piloswine_2, + .pokemonScale = 306, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Corsola + .categoryName = _("CORAL"), + .height = 6, + .weight = 50, + .descriptionPage1 = DexDescription_Corsola_1, + .descriptionPage2 = DexDescription_Corsola_2, + .pokemonScale = 410, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Remoraid + .categoryName = _("JET"), + .height = 6, + .weight = 120, + .descriptionPage1 = DexDescription_Remoraid_1, + .descriptionPage2 = DexDescription_Remoraid_2, + .pokemonScale = 316, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Octillery + .categoryName = _("JET"), + .height = 9, + .weight = 285, + .descriptionPage1 = DexDescription_Octillery_1, + .descriptionPage2 = DexDescription_Octillery_2, + .pokemonScale = 296, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Delibird + .categoryName = _("DELIVERY"), + .height = 9, + .weight = 160, + .descriptionPage1 = DexDescription_Delibird_1, + .descriptionPage2 = DexDescription_Delibird_2, + .pokemonScale = 293, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Mantine + .categoryName = _("KITE"), + .height = 21, + .weight = 2200, + .descriptionPage1 = DexDescription_Mantine_1, + .descriptionPage2 = DexDescription_Mantine_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 342, + .trainerOffset = 7, + }, + { //Skarmory + .categoryName = _("ARMOR BIRD"), + .height = 17, + .weight = 505, + .descriptionPage1 = DexDescription_Skarmory_1, + .descriptionPage2 = DexDescription_Skarmory_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 271, + .trainerOffset = 1, + }, + { //Houndour + .categoryName = _("DARK"), + .height = 6, + .weight = 108, + .descriptionPage1 = DexDescription_Houndour_1, + .descriptionPage2 = DexDescription_Houndour_2, + .pokemonScale = 393, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Houndoom + .categoryName = _("DARK"), + .height = 14, + .weight = 350, + .descriptionPage1 = DexDescription_Houndoom_1, + .descriptionPage2 = DexDescription_Houndoom_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Kingdra + .categoryName = _("DRAGON"), + .height = 18, + .weight = 1520, + .descriptionPage1 = DexDescription_Kingdra_1, + .descriptionPage2 = DexDescription_Kingdra_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 287, + .trainerOffset = 0, + }, + { //Phanpy + .categoryName = _("LONG NOSE"), + .height = 5, + .weight = 335, + .descriptionPage1 = DexDescription_Phanpy_1, + .descriptionPage2 = DexDescription_Phanpy_2, + .pokemonScale = 465, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Donphan + .categoryName = _("ARMOR"), + .height = 11, + .weight = 1200, + .descriptionPage1 = DexDescription_Donphan_1, + .descriptionPage2 = DexDescription_Donphan_2, + .pokemonScale = 313, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Porygon2 + .categoryName = _("VIRTUAL"), + .height = 6, + .weight = 325, + .descriptionPage1 = DexDescription_Porygon2_1, + .descriptionPage2 = DexDescription_Porygon2_2, + .pokemonScale = 320, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Stantler + .categoryName = _("BIG HORN"), + .height = 14, + .weight = 712, + .descriptionPage1 = DexDescription_Stantler_1, + .descriptionPage2 = DexDescription_Stantler_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Smeargle + .categoryName = _("PAINTER"), + .height = 12, + .weight = 580, + .descriptionPage1 = DexDescription_Smeargle_1, + .descriptionPage2 = DexDescription_Smeargle_2, + .pokemonScale = 287, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Tyrogue + .categoryName = _("SCUFFLE"), + .height = 7, + .weight = 210, + .descriptionPage1 = DexDescription_Tyrogue_1, + .descriptionPage2 = DexDescription_Tyrogue_2, + .pokemonScale = 292, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Hitmontop + .categoryName = _("HANDSTAND"), + .height = 14, + .weight = 480, + .descriptionPage1 = DexDescription_Hitmontop_1, + .descriptionPage2 = DexDescription_Hitmontop_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 257, + .trainerOffset = 0, + }, + { //Smoochum + .categoryName = _("KISS"), + .height = 4, + .weight = 60, + .descriptionPage1 = DexDescription_Smoochum_1, + .descriptionPage2 = DexDescription_Smoochum_2, + .pokemonScale = 440, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Elekid + .categoryName = _("ELECTRIC"), + .height = 6, + .weight = 235, + .descriptionPage1 = DexDescription_Elekid_1, + .descriptionPage2 = DexDescription_Elekid_2, + .pokemonScale = 363, + .pokemonOffset = 14, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Magby + .categoryName = _("LIVE COAL"), + .height = 7, + .weight = 214, + .descriptionPage1 = DexDescription_Magby_1, + .descriptionPage2 = DexDescription_Magby_2, + .pokemonScale = 284, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Miltank + .categoryName = _("MILK COW"), + .height = 12, + .weight = 755, + .descriptionPage1 = DexDescription_Miltank_1, + .descriptionPage2 = DexDescription_Miltank_2, + .pokemonScale = 280, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Blissey + .categoryName = _("HAPPINESS"), + .height = 15, + .weight = 468, + .descriptionPage1 = DexDescription_Blissey_1, + .descriptionPage2 = DexDescription_Blissey_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 310, + .trainerOffset = 3, + }, + { //Raikou + .categoryName = _("THUNDER"), + .height = 19, + .weight = 1780, + .descriptionPage1 = DexDescription_Raikou_1, + .descriptionPage2 = DexDescription_Raikou_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 345, + .trainerOffset = 7, + }, + { //Entei + .categoryName = _("VOLCANO"), + .height = 21, + .weight = 1980, + .descriptionPage1 = DexDescription_Entei_1, + .descriptionPage2 = DexDescription_Entei_2, + .pokemonScale = 259, + .pokemonOffset = 0, + .trainerScale = 345, + .trainerOffset = 7, + }, + { //Suicune + .categoryName = _("AURORA"), + .height = 20, + .weight = 1870, + .descriptionPage1 = DexDescription_Suicune_1, + .descriptionPage2 = DexDescription_Suicune_2, + .pokemonScale = 269, + .pokemonOffset = 0, + .trainerScale = 345, + .trainerOffset = 7, + }, + { //Larvitar + .categoryName = _("ROCK SKIN"), + .height = 6, + .weight = 720, + .descriptionPage1 = DexDescription_Larvitar_1, + .descriptionPage2 = DexDescription_Larvitar_2, + .pokemonScale = 472, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Pupitar + .categoryName = _("HARD SHELL"), + .height = 12, + .weight = 1520, + .descriptionPage1 = DexDescription_Pupitar_1, + .descriptionPage2 = DexDescription_Pupitar_2, + .pokemonScale = 292, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Tyranitar + .categoryName = _("ARMOR"), + .height = 20, + .weight = 2020, + .descriptionPage1 = DexDescription_Tyranitar_1, + .descriptionPage2 = DexDescription_Tyranitar_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 345, + .trainerOffset = 7, + }, + { //Lugia + .categoryName = _("DIVING"), + .height = 52, + .weight = 2160, + .descriptionPage1 = DexDescription_Lugia_1, + .descriptionPage2 = DexDescription_Lugia_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 721, + .trainerOffset = 19, + }, + { //HoOh + .categoryName = _("RAINBOW"), + .height = 38, + .weight = 1990, + .descriptionPage1 = DexDescription_HoOh_1, + .descriptionPage2 = DexDescription_HoOh_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 610, + .trainerOffset = 17, + }, + { //Celebi + .categoryName = _("TIME TRAVEL"), + .height = 6, + .weight = 50, + .descriptionPage1 = DexDescription_Celebi_1, + .descriptionPage2 = DexDescription_Celebi_2, + .pokemonScale = 393, + .pokemonOffset = -10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Treecko + .categoryName = _("WOOD GECKO"), + .height = 5, + .weight = 50, + .descriptionPage1 = DexDescription_Treecko_1, + .descriptionPage2 = DexDescription_Treecko_2, + .pokemonScale = 541, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Grovyle + .categoryName = _("WOOD GECKO"), + .height = 9, + .weight = 216, + .descriptionPage1 = DexDescription_Grovyle_1, + .descriptionPage2 = DexDescription_Grovyle_2, + .pokemonScale = 360, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Sceptile + .categoryName = _("FOREST"), + .height = 17, + .weight = 522, + .descriptionPage1 = DexDescription_Sceptile_1, + .descriptionPage2 = DexDescription_Sceptile_2, + .pokemonScale = 256, + .pokemonOffset = -1, + .trainerScale = 275, + .trainerOffset = 2, + }, + { //Torchic + .categoryName = _("CHICK"), + .height = 4, + .weight = 25, + .descriptionPage1 = DexDescription_Torchic_1, + .descriptionPage2 = DexDescription_Torchic_2, + .pokemonScale = 566, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Combusken + .categoryName = _("YOUNG FOWL"), + .height = 9, + .weight = 195, + .descriptionPage1 = DexDescription_Combusken_1, + .descriptionPage2 = DexDescription_Combusken_2, + .pokemonScale = 343, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Blaziken + .categoryName = _("BLAZE"), + .height = 19, + .weight = 520, + .descriptionPage1 = DexDescription_Blaziken_1, + .descriptionPage2 = DexDescription_Blaziken_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 301, + .trainerOffset = 4, + }, + { //Mudkip + .categoryName = _("MUD FISH"), + .height = 4, + .weight = 76, + .descriptionPage1 = DexDescription_Mudkip_1, + .descriptionPage2 = DexDescription_Mudkip_2, + .pokemonScale = 535, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Marshtomp + .categoryName = _("MUD FISH"), + .height = 7, + .weight = 280, + .descriptionPage1 = DexDescription_Marshtomp_1, + .descriptionPage2 = DexDescription_Marshtomp_2, + .pokemonScale = 340, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Swampert + .categoryName = _("MUD FISH"), + .height = 15, + .weight = 819, + .descriptionPage1 = DexDescription_Swampert_1, + .descriptionPage2 = DexDescription_Swampert_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Poochyena + .categoryName = _("BITE"), + .height = 5, + .weight = 136, + .descriptionPage1 = DexDescription_Poochyena_1, + .descriptionPage2 = DexDescription_Poochyena_2, + .pokemonScale = 481, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Mightyena + .categoryName = _("BITE"), + .height = 10, + .weight = 370, + .descriptionPage1 = DexDescription_Mightyena_1, + .descriptionPage2 = DexDescription_Mightyena_2, + .pokemonScale = 362, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Zigzagoon + .categoryName = _("TINYRACCOON"), + .height = 4, + .weight = 175, + .descriptionPage1 = DexDescription_Zigzagoon_1, + .descriptionPage2 = DexDescription_Zigzagoon_2, + .pokemonScale = 560, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Linoone + .categoryName = _("RUSHING"), + .height = 5, + .weight = 325, + .descriptionPage1 = DexDescription_Linoone_1, + .descriptionPage2 = DexDescription_Linoone_2, + .pokemonScale = 321, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Wurmple + .categoryName = _("WORM"), + .height = 3, + .weight = 36, + .descriptionPage1 = DexDescription_Wurmple_1, + .descriptionPage2 = DexDescription_Wurmple_2, + .pokemonScale = 711, + .pokemonOffset = 24, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Silcoon + .categoryName = _("COCOON"), + .height = 6, + .weight = 100, + .descriptionPage1 = DexDescription_Silcoon_1, + .descriptionPage2 = DexDescription_Silcoon_2, + .pokemonScale = 431, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Beautifly + .categoryName = _("BUTTERFLY"), + .height = 10, + .weight = 284, + .descriptionPage1 = DexDescription_Beautifly_1, + .descriptionPage2 = DexDescription_Beautifly_2, + .pokemonScale = 298, + .pokemonOffset = -1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Cascoon + .categoryName = _("COCOON"), + .height = 7, + .weight = 115, + .descriptionPage1 = DexDescription_Cascoon_1, + .descriptionPage2 = DexDescription_Cascoon_2, + .pokemonScale = 391, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Dustox + .categoryName = _("POISON MOTH"), + .height = 12, + .weight = 316, + .descriptionPage1 = DexDescription_Dustox_1, + .descriptionPage2 = DexDescription_Dustox_2, + .pokemonScale = 269, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Lotad + .categoryName = _("WATER WEED"), + .height = 5, + .weight = 26, + .descriptionPage1 = DexDescription_Lotad_1, + .descriptionPage2 = DexDescription_Lotad_2, + .pokemonScale = 406, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Lombre + .categoryName = _("JOLLY"), + .height = 12, + .weight = 325, + .descriptionPage1 = DexDescription_Lombre_1, + .descriptionPage2 = DexDescription_Lombre_2, + .pokemonScale = 277, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Ludicolo + .categoryName = _("CAREFREE"), + .height = 15, + .weight = 550, + .descriptionPage1 = DexDescription_Ludicolo_1, + .descriptionPage2 = DexDescription_Ludicolo_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 268, + .trainerOffset = -1, + }, + { //Seedot + .categoryName = _("ACORN"), + .height = 5, + .weight = 40, + .descriptionPage1 = DexDescription_Seedot_1, + .descriptionPage2 = DexDescription_Seedot_2, + .pokemonScale = 472, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Nuzleaf + .categoryName = _("WILY"), + .height = 10, + .weight = 280, + .descriptionPage1 = DexDescription_Nuzleaf_1, + .descriptionPage2 = DexDescription_Nuzleaf_2, + .pokemonScale = 299, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Shiftry + .categoryName = _("WICKED"), + .height = 13, + .weight = 596, + .descriptionPage1 = DexDescription_Shiftry_1, + .descriptionPage2 = DexDescription_Shiftry_2, + .pokemonScale = 290, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Taillow + .categoryName = _("TINYSWALLOW"), + .height = 3, + .weight = 23, + .descriptionPage1 = DexDescription_Taillow_1, + .descriptionPage2 = DexDescription_Taillow_2, + .pokemonScale = 465, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Swellow + .categoryName = _("SWALLOW"), + .height = 7, + .weight = 198, + .descriptionPage1 = DexDescription_Swellow_1, + .descriptionPage2 = DexDescription_Swellow_2, + .pokemonScale = 428, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Wingull + .categoryName = _("SEAGULL"), + .height = 6, + .weight = 95, + .descriptionPage1 = DexDescription_Wingull_1, + .descriptionPage2 = DexDescription_Wingull_2, + .pokemonScale = 295, + .pokemonOffset = -2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Pelipper + .categoryName = _("WATER BIRD"), + .height = 12, + .weight = 280, + .descriptionPage1 = DexDescription_Pelipper_1, + .descriptionPage2 = DexDescription_Pelipper_2, + .pokemonScale = 288, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Ralts + .categoryName = _("FEELING"), + .height = 4, + .weight = 66, + .descriptionPage1 = DexDescription_Ralts_1, + .descriptionPage2 = DexDescription_Ralts_2, + .pokemonScale = 457, + .pokemonOffset = -3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Kirlia + .categoryName = _("EMOTION"), + .height = 8, + .weight = 202, + .descriptionPage1 = DexDescription_Kirlia_1, + .descriptionPage2 = DexDescription_Kirlia_2, + .pokemonScale = 354, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Gardevoir + .categoryName = _("EMBRACE"), + .height = 16, + .weight = 484, + .descriptionPage1 = DexDescription_Gardevoir_1, + .descriptionPage2 = DexDescription_Gardevoir_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Surskit + .categoryName = _("POND SKATER"), + .height = 5, + .weight = 17, + .descriptionPage1 = DexDescription_Surskit_1, + .descriptionPage2 = DexDescription_Surskit_2, + .pokemonScale = 375, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Masquerain + .categoryName = _("EYEBALL"), + .height = 8, + .weight = 36, + .descriptionPage1 = DexDescription_Masquerain_1, + .descriptionPage2 = DexDescription_Masquerain_2, + .pokemonScale = 378, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Shroomish + .categoryName = _("MUSHROOM"), + .height = 4, + .weight = 45, + .descriptionPage1 = DexDescription_Shroomish_1, + .descriptionPage2 = DexDescription_Shroomish_2, + .pokemonScale = 513, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Breloom + .categoryName = _("MUSHROOM"), + .height = 12, + .weight = 392, + .descriptionPage1 = DexDescription_Breloom_1, + .descriptionPage2 = DexDescription_Breloom_2, + .pokemonScale = 324, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Slakoth + .categoryName = _("SLACKER"), + .height = 8, + .weight = 240, + .descriptionPage1 = DexDescription_Slakoth_1, + .descriptionPage2 = DexDescription_Slakoth_2, + .pokemonScale = 291, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Vigoroth + .categoryName = _("WILD MONKEY"), + .height = 14, + .weight = 465, + .descriptionPage1 = DexDescription_Vigoroth_1, + .descriptionPage2 = DexDescription_Vigoroth_2, + .pokemonScale = 301, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Slaking + .categoryName = _("LAZY"), + .height = 20, + .weight = 1305, + .descriptionPage1 = DexDescription_Slaking_1, + .descriptionPage2 = DexDescription_Slaking_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 300, + .trainerOffset = 1, + }, + { //Nincada + .categoryName = _("TRAINEE"), + .height = 5, + .weight = 55, + .descriptionPage1 = DexDescription_Nincada_1, + .descriptionPage2 = DexDescription_Nincada_2, + .pokemonScale = 405, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Ninjask + .categoryName = _("NINJA"), + .height = 8, + .weight = 120, + .descriptionPage1 = DexDescription_Ninjask_1, + .descriptionPage2 = DexDescription_Ninjask_2, + .pokemonScale = 383, + .pokemonOffset = -9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Shedinja + .categoryName = _("SHED"), + .height = 8, + .weight = 12, + .descriptionPage1 = DexDescription_Shedinja_1, + .descriptionPage2 = DexDescription_Shedinja_2, + .pokemonScale = 372, + .pokemonOffset = -8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Whismur + .categoryName = _("WHISPER"), + .height = 6, + .weight = 163, + .descriptionPage1 = DexDescription_Whismur_1, + .descriptionPage2 = DexDescription_Whismur_2, + .pokemonScale = 373, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Loudred + .categoryName = _("BIG VOICE"), + .height = 10, + .weight = 405, + .descriptionPage1 = DexDescription_Loudred_1, + .descriptionPage2 = DexDescription_Loudred_2, + .pokemonScale = 356, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Exploud + .categoryName = _("LOUD NOISE"), + .height = 15, + .weight = 840, + .descriptionPage1 = DexDescription_Exploud_1, + .descriptionPage2 = DexDescription_Exploud_2, + .pokemonScale = 284, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Makuhita + .categoryName = _("GUTS"), + .height = 10, + .weight = 864, + .descriptionPage1 = DexDescription_Makuhita_1, + .descriptionPage2 = DexDescription_Makuhita_2, + .pokemonScale = 256, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Hariyama + .categoryName = _("ARM THRUST"), + .height = 23, + .weight = 2538, + .descriptionPage1 = DexDescription_Hariyama_1, + .descriptionPage2 = DexDescription_Hariyama_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 343, + .trainerOffset = 7, + }, + { //Azurill + .categoryName = _("POLKA DOT"), + .height = 2, + .weight = 20, + .descriptionPage1 = DexDescription_Azurill_1, + .descriptionPage2 = DexDescription_Azurill_2, + .pokemonScale = 603, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Nosepass + .categoryName = _("COMPASS"), + .height = 10, + .weight = 970, + .descriptionPage1 = DexDescription_Nosepass_1, + .descriptionPage2 = DexDescription_Nosepass_2, + .pokemonScale = 256, + .pokemonOffset = 9, + .trainerScale = 289, + .trainerOffset = 3, + }, + { //Skitty + .categoryName = _("KITTEN"), + .height = 6, + .weight = 110, + .descriptionPage1 = DexDescription_Skitty_1, + .descriptionPage2 = DexDescription_Skitty_2, + .pokemonScale = 492, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Delcatty + .categoryName = _("PRIM"), + .height = 11, + .weight = 326, + .descriptionPage1 = DexDescription_Delcatty_1, + .descriptionPage2 = DexDescription_Delcatty_2, + .pokemonScale = 322, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Sableye + .categoryName = _("DARKNESS"), + .height = 5, + .weight = 110, + .descriptionPage1 = DexDescription_Sableye_1, + .descriptionPage2 = DexDescription_Sableye_2, + .pokemonScale = 451, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Mawile + .categoryName = _("DECEIVER"), + .height = 6, + .weight = 115, + .descriptionPage1 = DexDescription_Mawile_1, + .descriptionPage2 = DexDescription_Mawile_2, + .pokemonScale = 466, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Aron + .categoryName = _("IRON ARMOR"), + .height = 4, + .weight = 600, + .descriptionPage1 = DexDescription_Aron_1, + .descriptionPage2 = DexDescription_Aron_2, + .pokemonScale = 419, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Lairon + .categoryName = _("IRON ARMOR"), + .height = 9, + .weight = 1200, + .descriptionPage1 = DexDescription_Lairon_1, + .descriptionPage2 = DexDescription_Lairon_2, + .pokemonScale = 275, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Aggron + .categoryName = _("IRON ARMOR"), + .height = 21, + .weight = 3600, + .descriptionPage1 = DexDescription_Aggron_1, + .descriptionPage2 = DexDescription_Aggron_2, + .pokemonScale = 256, + .pokemonOffset = -1, + .trainerScale = 350, + .trainerOffset = 6, + }, + { //Meditite + .categoryName = _("MEDITATE"), + .height = 6, + .weight = 112, + .descriptionPage1 = DexDescription_Meditite_1, + .descriptionPage2 = DexDescription_Meditite_2, + .pokemonScale = 465, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Medicham + .categoryName = _("MEDITATE"), + .height = 13, + .weight = 315, + .descriptionPage1 = DexDescription_Medicham_1, + .descriptionPage2 = DexDescription_Medicham_2, + .pokemonScale = 298, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Electrike + .categoryName = _("LIGHTNING"), + .height = 6, + .weight = 152, + .descriptionPage1 = DexDescription_Electrike_1, + .descriptionPage2 = DexDescription_Electrike_2, + .pokemonScale = 290, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Manectric + .categoryName = _("DISCHARGE"), + .height = 15, + .weight = 402, + .descriptionPage1 = DexDescription_Manectric_1, + .descriptionPage2 = DexDescription_Manectric_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 257, + .trainerOffset = 0, + }, + { //Plusle + .categoryName = _("CHEERING"), + .height = 4, + .weight = 42, + .descriptionPage1 = DexDescription_Plusle_1, + .descriptionPage2 = DexDescription_Plusle_2, + .pokemonScale = 515, + .pokemonOffset = -9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Minun + .categoryName = _("CHEERING"), + .height = 4, + .weight = 42, + .descriptionPage1 = DexDescription_Minun_1, + .descriptionPage2 = DexDescription_Minun_2, + .pokemonScale = 512, + .pokemonOffset = -7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Volbeat + .categoryName = _("FIREFLY"), + .height = 7, + .weight = 177, + .descriptionPage1 = DexDescription_Volbeat_1, + .descriptionPage2 = DexDescription_Volbeat_2, + .pokemonScale = 442, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Illumise + .categoryName = _("FIREFLY"), + .height = 6, + .weight = 177, + .descriptionPage1 = DexDescription_Illumise_1, + .descriptionPage2 = DexDescription_Illumise_2, + .pokemonScale = 572, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Roselia + .categoryName = _("THORN"), + .height = 3, + .weight = 20, + .descriptionPage1 = DexDescription_Roselia_1, + .descriptionPage2 = DexDescription_Roselia_2, + .pokemonScale = 677, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Gulpin + .categoryName = _("STOMACH"), + .height = 4, + .weight = 103, + .descriptionPage1 = DexDescription_Gulpin_1, + .descriptionPage2 = DexDescription_Gulpin_2, + .pokemonScale = 593, + .pokemonOffset = 23, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Swalot + .categoryName = _("POISON BAG"), + .height = 17, + .weight = 800, + .descriptionPage1 = DexDescription_Swalot_1, + .descriptionPage2 = DexDescription_Swalot_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 345, + .trainerOffset = 3, + }, + { //Carvanha + .categoryName = _("SAVAGE"), + .height = 8, + .weight = 208, + .descriptionPage1 = DexDescription_Carvanha_1, + .descriptionPage2 = DexDescription_Carvanha_2, + .pokemonScale = 362, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Sharpedo + .categoryName = _("BRUTAL"), + .height = 18, + .weight = 888, + .descriptionPage1 = DexDescription_Sharpedo_1, + .descriptionPage2 = DexDescription_Sharpedo_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 317, + .trainerOffset = 3, + }, + { //Wailmer + .categoryName = _("BALL WHALE"), + .height = 20, + .weight = 1300, + .descriptionPage1 = DexDescription_Wailmer_1, + .descriptionPage2 = DexDescription_Wailmer_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 493, + .trainerOffset = 0, + }, + { //Wailord + .categoryName = _("FLOAT WHALE"), + .height = 145, + .weight = 3980, + .descriptionPage1 = DexDescription_Wailord_1, + .descriptionPage2 = DexDescription_Wailord_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 1352, + .trainerOffset = 18, + }, + { //Numel + .categoryName = _("NUMB"), + .height = 7, + .weight = 240, + .descriptionPage1 = DexDescription_Numel_1, + .descriptionPage2 = DexDescription_Numel_2, + .pokemonScale = 342, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Camerupt + .categoryName = _("ERUPTION"), + .height = 19, + .weight = 2200, + .descriptionPage1 = DexDescription_Camerupt_1, + .descriptionPage2 = DexDescription_Camerupt_2, + .pokemonScale = 256, + .pokemonOffset = 7, + .trainerScale = 345, + .trainerOffset = 6, + }, + { //Torkoal + .categoryName = _("COAL"), + .height = 5, + .weight = 804, + .descriptionPage1 = DexDescription_Torkoal_1, + .descriptionPage2 = DexDescription_Torkoal_2, + .pokemonScale = 390, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Spoink + .categoryName = _("BOUNCE"), + .height = 7, + .weight = 306, + .descriptionPage1 = DexDescription_Spoink_1, + .descriptionPage2 = DexDescription_Spoink_2, + .pokemonScale = 423, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Grumpig + .categoryName = _("MANIPULATE"), + .height = 9, + .weight = 715, + .descriptionPage1 = DexDescription_Grumpig_1, + .descriptionPage2 = DexDescription_Grumpig_2, + .pokemonScale = 358, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Spinda + .categoryName = _("SPOT PANDA"), + .height = 11, + .weight = 50, + .descriptionPage1 = DexDescription_Spinda_1, + .descriptionPage2 = DexDescription_Spinda_2, + .pokemonScale = 321, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Trapinch + .categoryName = _("ANT PIT"), + .height = 7, + .weight = 150, + .descriptionPage1 = DexDescription_Trapinch_1, + .descriptionPage2 = DexDescription_Trapinch_2, + .pokemonScale = 298, + .pokemonOffset = 17, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Vibrava + .categoryName = _("VIBRATION"), + .height = 11, + .weight = 153, + .descriptionPage1 = DexDescription_Vibrava_1, + .descriptionPage2 = DexDescription_Vibrava_2, + .pokemonScale = 370, + .pokemonOffset = 11, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Flygon + .categoryName = _("MYSTIC"), + .height = 20, + .weight = 820, + .descriptionPage1 = DexDescription_Flygon_1, + .descriptionPage2 = DexDescription_Flygon_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 268, + .trainerOffset = 1, + }, + { //Cacnea + .categoryName = _("CACTUS"), + .height = 4, + .weight = 513, + .descriptionPage1 = DexDescription_Cacnea_1, + .descriptionPage2 = DexDescription_Cacnea_2, + .pokemonScale = 455, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Cacturne + .categoryName = _("SCARECROW"), + .height = 13, + .weight = 774, + .descriptionPage1 = DexDescription_Cacturne_1, + .descriptionPage2 = DexDescription_Cacturne_2, + .pokemonScale = 327, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Swablu + .categoryName = _("COTTON BIRD"), + .height = 4, + .weight = 12, + .descriptionPage1 = DexDescription_Swablu_1, + .descriptionPage2 = DexDescription_Swablu_2, + .pokemonScale = 422, + .pokemonOffset = -8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Altaria + .categoryName = _("HUMMING"), + .height = 11, + .weight = 206, + .descriptionPage1 = DexDescription_Altaria_1, + .descriptionPage2 = DexDescription_Altaria_2, + .pokemonScale = 327, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Zangoose + .categoryName = _("CAT FERRET"), + .height = 13, + .weight = 403, + .descriptionPage1 = DexDescription_Zangoose_1, + .descriptionPage2 = DexDescription_Zangoose_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Seviper + .categoryName = _("FANG SNAKE"), + .height = 27, + .weight = 525, + .descriptionPage1 = DexDescription_Seviper_1, + .descriptionPage2 = DexDescription_Seviper_2, + .pokemonScale = 275, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Lunatone + .categoryName = _("METEORITE"), + .height = 10, + .weight = 1680, + .descriptionPage1 = DexDescription_Lunatone_1, + .descriptionPage2 = DexDescription_Lunatone_2, + .pokemonScale = 300, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Solrock + .categoryName = _("METEORITE"), + .height = 12, + .weight = 1540, + .descriptionPage1 = DexDescription_Solrock_1, + .descriptionPage2 = DexDescription_Solrock_2, + .pokemonScale = 328, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Barboach + .categoryName = _("WHISKERS"), + .height = 4, + .weight = 19, + .descriptionPage1 = DexDescription_Barboach_1, + .descriptionPage2 = DexDescription_Barboach_2, + .pokemonScale = 581, + .pokemonOffset = -3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Whiscash + .categoryName = _("WHISKERS"), + .height = 9, + .weight = 236, + .descriptionPage1 = DexDescription_Whiscash_1, + .descriptionPage2 = DexDescription_Whiscash_2, + .pokemonScale = 317, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Corphish + .categoryName = _("RUFFIAN"), + .height = 6, + .weight = 115, + .descriptionPage1 = DexDescription_Corphish_1, + .descriptionPage2 = DexDescription_Corphish_2, + .pokemonScale = 484, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Crawdaunt + .categoryName = _("ROGUE"), + .height = 11, + .weight = 328, + .descriptionPage1 = DexDescription_Crawdaunt_1, + .descriptionPage2 = DexDescription_Crawdaunt_2, + .pokemonScale = 365, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Baltoy + .categoryName = _("CLAY DOLL"), + .height = 5, + .weight = 215, + .descriptionPage1 = DexDescription_Baltoy_1, + .descriptionPage2 = DexDescription_Baltoy_2, + .pokemonScale = 457, + .pokemonOffset = 21, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Claydol + .categoryName = _("CLAY DOLL"), + .height = 15, + .weight = 1080, + .descriptionPage1 = DexDescription_Claydol_1, + .descriptionPage2 = DexDescription_Claydol_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 280, + .trainerOffset = 1, + }, + { //Lileep + .categoryName = _("SEA LILY"), + .height = 10, + .weight = 238, + .descriptionPage1 = DexDescription_Lileep_1, + .descriptionPage2 = DexDescription_Lileep_2, + .pokemonScale = 305, + .pokemonOffset = 8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Cradily + .categoryName = _("BARNACLE"), + .height = 15, + .weight = 604, + .descriptionPage1 = DexDescription_Cradily_1, + .descriptionPage2 = DexDescription_Cradily_2, + .pokemonScale = 267, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Anorith + .categoryName = _("OLD SHRIMP"), + .height = 7, + .weight = 125, + .descriptionPage1 = DexDescription_Anorith_1, + .descriptionPage2 = DexDescription_Anorith_2, + .pokemonScale = 296, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Armaldo + .categoryName = _("PLATE"), + .height = 15, + .weight = 682, + .descriptionPage1 = DexDescription_Armaldo_1, + .descriptionPage2 = DexDescription_Armaldo_2, + .pokemonScale = 312, + .pokemonOffset = 3, + .trainerScale = 271, + .trainerOffset = 0, + }, + { //Feebas + .categoryName = _("FISH"), + .height = 6, + .weight = 74, + .descriptionPage1 = DexDescription_Feebas_1, + .descriptionPage2 = DexDescription_Feebas_2, + .pokemonScale = 423, + .pokemonOffset = -4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Milotic + .categoryName = _("TENDER"), + .height = 62, + .weight = 1620, + .descriptionPage1 = DexDescription_Milotic_1, + .descriptionPage2 = DexDescription_Milotic_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 360, + .trainerOffset = 7, + }, + { //Castform + .categoryName = _("WEATHER"), + .height = 3, + .weight = 8, + .descriptionPage1 = DexDescription_Castform_1, + .descriptionPage2 = DexDescription_Castform_2, + .pokemonScale = 435, + .pokemonOffset = -5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Kecleon + .categoryName = _("COLOR SWAP"), + .height = 10, + .weight = 220, + .descriptionPage1 = DexDescription_Kecleon_1, + .descriptionPage2 = DexDescription_Kecleon_2, + .pokemonScale = 316, + .pokemonOffset = 10, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Shuppet + .categoryName = _("PUPPET"), + .height = 6, + .weight = 23, + .descriptionPage1 = DexDescription_Shuppet_1, + .descriptionPage2 = DexDescription_Shuppet_2, + .pokemonScale = 440, + .pokemonOffset = 20, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Banette + .categoryName = _("MARIONETTE"), + .height = 11, + .weight = 125, + .descriptionPage1 = DexDescription_Banette_1, + .descriptionPage2 = DexDescription_Banette_2, + .pokemonScale = 262, + .pokemonOffset = 9, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Duskull + .categoryName = _("REQUIEM"), + .height = 8, + .weight = 150, + .descriptionPage1 = DexDescription_Duskull_1, + .descriptionPage2 = DexDescription_Duskull_2, + .pokemonScale = 406, + .pokemonOffset = -4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Dusclops + .categoryName = _("BECKON"), + .height = 16, + .weight = 306, + .descriptionPage1 = DexDescription_Dusclops_1, + .descriptionPage2 = DexDescription_Dusclops_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 299, + .trainerOffset = 1, + }, + { //Tropius + .categoryName = _("FRUIT"), + .height = 20, + .weight = 1000, + .descriptionPage1 = DexDescription_Tropius_1, + .descriptionPage2 = DexDescription_Tropius_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 344, + .trainerOffset = 7, + }, + { //Chimecho + .categoryName = _("WIND CHIME"), + .height = 6, + .weight = 10, + .descriptionPage1 = DexDescription_Chimecho_1, + .descriptionPage2 = DexDescription_Chimecho_2, + .pokemonScale = 505, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Absol + .categoryName = _("DISASTER"), + .height = 12, + .weight = 470, + .descriptionPage1 = DexDescription_Absol_1, + .descriptionPage2 = DexDescription_Absol_2, + .pokemonScale = 301, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Wynaut + .categoryName = _("BRIGHT"), + .height = 6, + .weight = 140, + .descriptionPage1 = DexDescription_Wynaut_1, + .descriptionPage2 = DexDescription_Wynaut_2, + .pokemonScale = 484, + .pokemonOffset = 19, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Snorunt + .categoryName = _("SNOW HAT"), + .height = 7, + .weight = 168, + .descriptionPage1 = DexDescription_Snorunt_1, + .descriptionPage2 = DexDescription_Snorunt_2, + .pokemonScale = 380, + .pokemonOffset = 15, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Glalie + .categoryName = _("FACE"), + .height = 15, + .weight = 2565, + .descriptionPage1 = DexDescription_Glalie_1, + .descriptionPage2 = DexDescription_Glalie_2, + .pokemonScale = 256, + .pokemonOffset = 3, + .trainerScale = 344, + .trainerOffset = 0, + }, + { //Spheal + .categoryName = _("CLAP"), + .height = 8, + .weight = 395, + .descriptionPage1 = DexDescription_Spheal_1, + .descriptionPage2 = DexDescription_Spheal_2, + .pokemonScale = 315, + .pokemonOffset = 16, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Sealeo + .categoryName = _("BALL ROLL"), + .height = 11, + .weight = 876, + .descriptionPage1 = DexDescription_Sealeo_1, + .descriptionPage2 = DexDescription_Sealeo_2, + .pokemonScale = 338, + .pokemonOffset = 13, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Walrein + .categoryName = _("ICE BREAK"), + .height = 14, + .weight = 1506, + .descriptionPage1 = DexDescription_Walrein_1, + .descriptionPage2 = DexDescription_Walrein_2, + .pokemonScale = 316, + .pokemonOffset = 4, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Clamperl + .categoryName = _("BIVALVE"), + .height = 4, + .weight = 525, + .descriptionPage1 = DexDescription_Clamperl_1, + .descriptionPage2 = DexDescription_Clamperl_2, + .pokemonScale = 691, + .pokemonOffset = 22, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Huntail + .categoryName = _("DEEP SEA"), + .height = 17, + .weight = 270, + .descriptionPage1 = DexDescription_Huntail_1, + .descriptionPage2 = DexDescription_Huntail_2, + .pokemonScale = 307, + .pokemonOffset = 1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Gorebyss + .categoryName = _("SOUTH SEA"), + .height = 18, + .weight = 226, + .descriptionPage1 = DexDescription_Gorebyss_1, + .descriptionPage2 = DexDescription_Gorebyss_2, + .pokemonScale = 278, + .pokemonOffset = 5, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Relicanth + .categoryName = _("LONGEVITY"), + .height = 10, + .weight = 234, + .descriptionPage1 = DexDescription_Relicanth_1, + .descriptionPage2 = DexDescription_Relicanth_2, + .pokemonScale = 316, + .pokemonOffset = 7, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Luvdisc + .categoryName = _("RENDEZVOUS"), + .height = 6, + .weight = 87, + .descriptionPage1 = DexDescription_Luvdisc_1, + .descriptionPage2 = DexDescription_Luvdisc_2, + .pokemonScale = 371, + .pokemonOffset = 2, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Bagon + .categoryName = _("ROCK HEAD"), + .height = 6, + .weight = 421, + .descriptionPage1 = DexDescription_Bagon_1, + .descriptionPage2 = DexDescription_Bagon_2, + .pokemonScale = 448, + .pokemonOffset = 18, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Shelgon + .categoryName = _("ENDURANCE"), + .height = 11, + .weight = 1105, + .descriptionPage1 = DexDescription_Shelgon_1, + .descriptionPage2 = DexDescription_Shelgon_2, + .pokemonScale = 311, + .pokemonOffset = 12, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Salamence + .categoryName = _("DRAGON"), + .height = 15, + .weight = 1026, + .descriptionPage1 = DexDescription_Salamence_1, + .descriptionPage2 = DexDescription_Salamence_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Beldum + .categoryName = _("IRON BALL"), + .height = 6, + .weight = 952, + .descriptionPage1 = DexDescription_Beldum_1, + .descriptionPage2 = DexDescription_Beldum_2, + .pokemonScale = 414, + .pokemonOffset = -1, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Metang + .categoryName = _("IRON CLAW"), + .height = 12, + .weight = 2025, + .descriptionPage1 = DexDescription_Metang_1, + .descriptionPage2 = DexDescription_Metang_2, + .pokemonScale = 256, + .pokemonOffset = 6, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Metagross + .categoryName = _("IRON LEG"), + .height = 16, + .weight = 5500, + .descriptionPage1 = DexDescription_Metagross_1, + .descriptionPage2 = DexDescription_Metagross_2, + .pokemonScale = 256, + .pokemonOffset = 4, + .trainerScale = 447, + .trainerOffset = 9, + }, + { //Regirock + .categoryName = _("ROCK PEAK"), + .height = 17, + .weight = 2300, + .descriptionPage1 = DexDescription_Regirock_1, + .descriptionPage2 = DexDescription_Regirock_2, + .pokemonScale = 256, + .pokemonOffset = 2, + .trainerScale = 309, + .trainerOffset = 1, + }, + { //Regice + .categoryName = _("ICEBERG"), + .height = 18, + .weight = 1750, + .descriptionPage1 = DexDescription_Regice_1, + .descriptionPage2 = DexDescription_Regice_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 301, + .trainerOffset = 2, + }, + { //Registeel + .categoryName = _("IRON"), + .height = 19, + .weight = 2050, + .descriptionPage1 = DexDescription_Registeel_1, + .descriptionPage2 = DexDescription_Registeel_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 359, + .trainerOffset = 6, + }, + { //Latias + .categoryName = _("EON"), + .height = 14, + .weight = 400, + .descriptionPage1 = DexDescription_Latias_1, + .descriptionPage2 = DexDescription_Latias_2, + .pokemonScale = 304, + .pokemonOffset = 3, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Latios + .categoryName = _("EON"), + .height = 20, + .weight = 600, + .descriptionPage1 = DexDescription_Latios_1, + .descriptionPage2 = DexDescription_Latios_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 294, + .trainerOffset = 3, + }, + { //Kyogre + .categoryName = _("SEA BASIN"), + .height = 45, + .weight = 3520, + .descriptionPage1 = DexDescription_Kyogre_1, + .descriptionPage2 = DexDescription_Kyogre_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 614, + .trainerOffset = 13, + }, + { //Groudon + .categoryName = _("CONTINENT"), + .height = 35, + .weight = 9500, + .descriptionPage1 = DexDescription_Groudon_1, + .descriptionPage2 = DexDescription_Groudon_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 515, + .trainerOffset = 14, + }, + { //Rayquaza + .categoryName = _("SKY HIGH"), + .height = 70, + .weight = 2065, + .descriptionPage1 = DexDescription_Rayquaza_1, + .descriptionPage2 = DexDescription_Rayquaza_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 448, + .trainerOffset = 12, + }, + { //Jirachi + .categoryName = _("WISH"), + .height = 3, + .weight = 11, + .descriptionPage1 = DexDescription_Jirachi_1, + .descriptionPage2 = DexDescription_Jirachi_2, + .pokemonScale = 608, + .pokemonOffset = -8, + .trainerScale = 256, + .trainerOffset = 0, + }, + { //Deoxys + .categoryName = _("DNA"), + .height = 17, + .weight = 608, + .descriptionPage1 = DexDescription_Deoxys_1, + .descriptionPage2 = DexDescription_Deoxys_2, + .pokemonScale = 256, + .pokemonOffset = 0, + .trainerScale = 290, + .trainerOffset = 2, + }, +}; diff --git a/src/data/pokedex_orders.h b/src/data/pokedex_orders.h new file mode 100644 index 000000000..736c0df6a --- /dev/null +++ b/src/data/pokedex_orders.h @@ -0,0 +1,1609 @@ +#if ENGLISH +static const u16 gPokedexOrder_Alphabetical[] = +{ + 387, + 388, + 389, + 390, + 391, + 392, + 393, + 394, + 395, + 396, + 397, + 398, + 399, + 400, + 401, + 402, + 403, + 404, + 405, + 406, + 407, + 408, + 409, + 410, + 411, + 63, // Abra + 359, // Absol + 142, // Aerodactyl + 306, // Aggron + 190, // Aipom + 65, // Alakazam + 334, // Altaria + 181, // Ampharos + 347, // Anorith + 24, // Arbok + 59, // Arcanine + 168, // Ariados + 348, // Armaldo + 304, // Aron + 144, // Articuno + 184, // Azumarill + 298, // Azurill + 371, // Bagon + 343, // Baltoy + 354, // Banette + 339, // Barboach + 153, // Bayleef + 267, // Beautifly + 15, // Beedrill + 374, // Beldum + 182, // Bellossom + 69, // Bellsprout + 9, // Blastoise + 257, // Blaziken + 242, // Blissey + 286, // Breloom + 1, // Bulbasaur + 12, // Butterfree + 331, // Cacnea + 332, // Cacturne + 323, // Camerupt + 318, // Carvanha + 268, // Cascoon + 351, // Castform + 10, // Caterpie + 251, // Celebi + 113, // Chansey + 6, // Charizard + 4, // Charmander + 5, // Charmeleon + 152, // Chikorita + 358, // Chimecho + 170, // Chinchou + 366, // Clamperl + 344, // Claydol + 36, // Clefable + 35, // Clefairy + 173, // Cleffa + 91, // Cloyster + 256, // Combusken + 341, // Corphish + 222, // Corsola + 346, // Cradily + 342, // Crawdaunt + 169, // Crobat + 159, // Croconaw + 104, // Cubone + 155, // Cyndaquil + 301, // Delcatty + 225, // Delibird + 386, // Deoxys + 87, // Dewgong + 50, // Diglett + 132, // Ditto + 85, // Dodrio + 84, // Doduo + 232, // Donphan + 148, // Dragonair + 149, // Dragonite + 147, // Dratini + 96, // Drowzee + 51, // Dugtrio + 206, // Dunsparce + 356, // Dusclops + 355, // Duskull + 269, // Dustox + 133, // Eevee + 23, // Ekans + 125, // Electabuzz + 309, // Electrike + 101, // Electrode + 239, // Elekid + 244, // Entei + 196, // Espeon + 102, // Exeggcute + 103, // Exeggutor + 295, // Exploud + 83, // Farfetch'd + 22, // Fearow + 349, // Feebas + 160, // Feraligatr + 180, // Flaaffy + 136, // Flareon + 330, // Flygon + 205, // Forretress + 162, // Furret + 282, // Gardevoir + 92, // Gastly + 94, // Gengar + 74, // Geodude + 203, // Girafarig + 362, // Glalie + 207, // Gligar + 44, // Gloom + 42, // Golbat + 118, // Goldeen + 55, // Golduck + 76, // Golem + 368, // Gorebyss + 210, // Granbull + 75, // Graveler + 88, // Grimer + 383, // Groudon + 253, // Grovyle + 58, // Growlithe + 326, // Grumpig + 316, // Gulpin + 130, // Gyarados + 297, // Hariyama + 93, // Haunter + 214, // Heracross + 107, // Hitmonchan + 106, // Hitmonlee + 237, // Hitmontop + 250, // Ho-Oh + 163, // Hoothoot + 187, // Hoppip + 116, // Horsea + 229, // Houndoom + 228, // Houndour + 367, // Huntail + 97, // Hypno + 174, // Igglybuff + 314, // Illumise + 2, // Ivysaur + 39, // Jigglypuff + 385, // Jirachi + 135, // Jolteon + 189, // Jumpluff + 124, // Jynx + 140, // Kabuto + 141, // Kabutops + 64, // Kadabra + 14, // Kakuna + 115, // Kangaskhan + 352, // Kecleon + 230, // Kingdra + 99, // Kingler + 281, // Kirlia + 109, // Koffing + 98, // Krabby + 382, // Kyogre + 305, // Lairon + 171, // Lanturn + 131, // Lapras + 246, // Larvitar + 380, // Latias + 381, // Latios + 166, // Ledian + 165, // Ledyba + 108, // Lickitung + 345, // Lileep + 264, // Linoone + 271, // Lombre + 270, // Lotad + 294, // Loudred + 272, // Ludicolo + 249, // Lugia + 337, // Lunatone + 370, // Luvdisc + 68, // Machamp + 67, // Machoke + 66, // Machop + 240, // Magby + 219, // Magcargo + 129, // Magikarp + 126, // Magmar + 81, // Magnemite + 82, // Magneton + 296, // Makuhita + 310, // Manectric + 56, // Mankey + 226, // Mantine + 179, // Mareep + 183, // Marill + 105, // Marowak + 259, // Marshtomp + 284, // Masquerain + 303, // Mawile + 308, // Medicham + 307, // Meditite + 154, // Meganium + 52, // Meowth + 376, // Metagross + 375, // Metang + 11, // Metapod + 151, // Mew + 150, // Mewtwo + 262, // Mightyena + 350, // Milotic + 241, // Miltank + 312, // Minun + 200, // Misdreavus + 146, // Moltres + 122, // Mr. mime + 258, // Mudkip + 89, // Muk + 198, // Murkrow + 177, // Natu + 34, // Nidoking + 31, // Nidoqueen + 29, // Nidoran? + 32, // Nidoran? + 30, // Nidorina + 33, // Nidorino + 290, // Nincada + 38, // Ninetales + 291, // Ninjask + 164, // Noctowl + 299, // Nosepass + 322, // Numel + 274, // Nuzleaf + 224, // Octillery + 43, // Oddish + 138, // Omanyte + 139, // Omastar + 95, // Onix + 46, // Paras + 47, // Parasect + 279, // Pelipper + 53, // Persian + 231, // Phanpy + 172, // Pichu + 18, // Pidgeot + 17, // Pidgeotto + 16, // Pidgey + 25, // Pikachu + 221, // Piloswine + 204, // Pineco + 127, // Pinsir + 311, // Plusle + 186, // Politoed + 60, // Poliwag + 61, // Poliwhirl + 62, // Poliwrath + 77, // Ponyta + 261, // Poochyena + 137, // Porygon + 233, // Porygon2 + 57, // Primeape + 54, // Psyduck + 247, // Pupitar + 195, // Quagsire + 156, // Quilava + 211, // Qwilfish + 26, // Raichu + 243, // Raikou + 280, // Ralts + 78, // Rapidash + 20, // Raticate + 19, // Rattata + 384, // Rayquaza + 378, // Regice + 377, // Regirock + 379, // Registeel + 369, // Relicanth + 223, // Remoraid + 112, // Rhydon + 111, // Rhyhorn + 315, // Roselia + 302, // Sableye + 373, // Salamence + 27, // Sandshrew + 28, // Sandslash + 254, // Sceptile + 212, // Scizor + 123, // Scyther + 117, // Seadra + 119, // Seaking + 364, // Sealeo + 273, // Seedot + 86, // Seel + 161, // Sentret + 336, // Seviper + 319, // Sharpedo + 292, // Shedinja + 372, // Shelgon + 90, // Shellder + 275, // Shiftry + 285, // Shroomish + 213, // Shuckle + 353, // Shuppet + 266, // Silcoon + 227, // Skarmory + 188, // Skiploom + 300, // Skitty + 289, // Slaking + 287, // Slakoth + 80, // Slowbro + 199, // Slowking + 79, // Slowpoke + 218, // Slugma + 235, // Smeargle + 238, // Smoochum + 215, // Sneasel + 143, // Snorlax + 361, // Snorunt + 209, // Snubbull + 338, // Solrock + 21, // Spearow + 363, // Spheal + 167, // Spinarak + 327, // Spinda + 325, // Spoink + 7, // Squirtle + 234, // Stantler + 121, // Starmie + 120, // Staryu + 208, // Steelix + 185, // Sudowoodo + 245, // Suicune + 192, // Sunflora + 191, // Sunkern + 283, // Surskit + 333, // Swablu + 317, // Swalot + 260, // Swampert + 277, // Swellow + 220, // Swinub + 276, // Taillow + 114, // Tangela + 128, // Tauros + 216, // Teddiursa + 72, // Tentacool + 73, // Tentacruel + 175, // Togepi + 176, // Togetic + 255, // Torchic + 324, // Torkoal + 158, // Totodile + 328, // Trapinch + 252, // Treecko + 357, // Tropius + 157, // Typhlosion + 248, // Tyranitar + 236, // Tyrogue + 197, // Umbreon + 201, // Unown + 217, // Ursaring + 134, // Vaporeon + 49, // Venomoth + 48, // Venonat + 3, // Venusaur + 329, // Vibrava + 71, // Victreebel + 288, // Vigoroth + 45, // Vileplume + 313, // Volbeat + 100, // Voltorb + 37, // Vulpix + 320, // Wailmer + 321, // Wailord + 365, // Walrein + 8, // Wartortle + 13, // Weedle + 70, // Weepinbell + 110, // Weezing + 340, // Whiscash + 293, // Whismur + 40, // Wigglytuff + 278, // Wingull + 202, // Wobbuffet + 194, // Wooper + 265, // Wurmple + 360, // Wynaut + 178, // Xatu + 193, // Yanma + 335, // Zangoose + 145, // Zapdos + 263, // Zigzagoon + 41, // Zubat +}; +#elif GERMAN +static const u16 gPokedexOrder_Alphabetical[] = { + 387, + 388, + 389, + 390, + 391, + 392, + 393, + 394, + 395, + 396, + 397, + 398, + 399, + 400, + 401, + 402, + 403, + 404, + 405, + 406, + 407, + 408, + 409, + 410, + 411, + 367, // Aalabyss + 63, // Abra + 359, // Absol + 142, // Aerodactyl + 93, // Alpollo + 334, // Altaria + 138, // Amonitas + 139, // Amoroso + 181, // Ampharos + 347, // Anorith + 134, // Aquana + 24, // Arbok + 168, // Ariados + 59, // Arkani + 144, // Arktos + 348, // Armaldo + 91, // Austos + 184, // Azumarill + 298, // Azurill + 211, // Baldorfish + 354, // Banette + 349, // Barschwa + 15, // Bibor + 3, // Bisaflor + 2, // Bisaknosp + 1, // Bisasam + 274, // Blanas + 135, // Blitza + 182, // Blubella + 48, // Bluzuk + 225, // Botogel + 373, // Brutalanda + 287, // Bummelz + 322, // Camaub + 323, // Camerupt + 251, // Celebi + 113, // Chaneira + 222, // Corasonn + 234, // Damhirplex + 386, // Deoxys + 248, // Despotar + 50, // Digda + 51, // Digdri + 132, // Ditto + 85, // Dodri + 84, // Dodu + 232, // Donphan + 148, // Dragonir + 149, // Dragoran + 372, // Draschel + 147, // Dratini + 44, // Duflor + 206, // Dummisel + 239, // Elekid + 125, // Elektek + 152, // Endivie + 300, // Eneco + 301, // Enekoro + 244, // Entei + 54, // Enton + 55, // Entoron + 133, // Evoli + 235, // Farbeagle + 194, // Felino + 155, // Feurigel + 261, // Fiffyen + 362, // Firnontor + 136, // Flamara + 79, // Flegmon + 255, // Flemmli + 174, // Fluffeluff + 303, // Flunkifer + 293, // Flurmel + 351, // Formeo + 205, // Forstellka + 309, // Frizelbliz + 58, // Fukano + 78, // Gallopa + 130, // Garados + 252, // Geckarbor + 283, // Gehweiher + 94, // Gengar + 75, // Georok + 76, // Geowaz + 264, // Geradaks + 254, // Gewaldro + 45, // Giflor + 203, // Girafarig + 4, // Glumanda + 6, // Glurak + 5, // Glutexo + 42, // Golbat + 118, // Goldini + 119, // Golking + 210, // Granbull + 190, // Griffel + 326, // Groink + 383, // Groudon + 282, // Guardevoir + 21, // Habitak + 297, // Hariyama + 242, // Heiteira + 250, // Ho-oh + 163, // Hoothoot + 187, // Hoppspross + 13, // Hornliu + 188, // Hubelupf + 229, // Hundemon + 228, // Hunduster + 258, // Hydropi + 97, // Hypno + 22, // Ibitak + 201, // Icognito + 156, // Igelavar + 169, // Iksbat + 314, // Illumise + 160, // Impergator + 360, // Isso + 385, // Jirachi + 87, // Jugong + 256, // Jungglut + 86, // Jurob + 140, // Kabuto + 141, // Kabutops + 64, // Kadabra + 115, // Kangama + 318, // Kanivanha + 286, // Kapilz + 237, // Kapoera + 272, // Kappalores + 158, // Karnimani + 129, // Karpador + 352, // Kecleon + 221, // Keifel + 106, // Kicklee + 371, // Kindwurm + 99, // Kingler + 281, // Kirlia + 74, // Kleinstein + 328, // Knacklion + 285, // Knilz + 69, // Knofensa + 105, // Knogga + 40, // Knuddeluff + 103, // Kokowei + 14, // Kokuna + 98, // Krabby + 294, // Krakeelo + 198, // Kramurx + 295, // Krawumms + 341, // Krebscorps + 342, // Krebutack + 238, // Kussilla + 382, // Kyogre + 80, // Lahmus + 170, // Lampi + 171, // Lanturn + 131, // Lapras + 246, // Larvitar + 199, // Laschoking + 380, // Latias + 381, // Latios + 146, // Lavados + 166, // Ledian + 165, // Ledyba + 101, // Lektrobal + 344, // Lepumentas + 289, // Letarking + 330, // Libelldra + 370, // Liebiskus + 345, // Liliep + 257, // Lohgock + 271, // Lombrero + 153, // Lorblatt + 270, // Loturzel + 249, // Lugia + 337, // Lunastein + 66, // Machollo + 68, // Machomei + 240, // Magby + 219, // Magcargo + 126, // Magmar + 262, // Magnayen + 81, // Magnetilo + 82, // Magneton + 296, // Makuhita + 226, // Mantax + 183, // Marill + 67, // Maschock + 284, // Maskeregen + 52, // Mauzi + 308, // Meditalis + 307, // Meditie + 154, // Meganie + 56, // Menki + 376, // Metagross + 375, // Metang + 151, // Mew + 150, // Mewtu + 350, // Milotic + 241, // Miltank + 312, // Minun + 185, // Mogelbaum + 259, // Moorabbel + 195, // Morlord + 288, // Muntier + 90, // Muschas + 43, // Myrapla + 197, // Nachtara + 299, // Nasgnet + 177, // Natu + 92, // Nebulak + 34, // Nidoking + 31, // Nidoqueen + 29, // Nidoran♀ + 32, // Nidoran♂ + 30, // Nidorina + 33, // Nidorino + 290, // Nincada + 291, // Ninjask + 292, // Ninjatom + 107, // Nockchan + 164, // Noctuh + 332, // Noktuska + 224, // Octillery + 49, // Omot + 95, // Onix + 102, // Owei + 358, // Palimpalim + 327, // Pandir + 268, // Panekon + 122, // Pantimos + 227, // Panzaeron + 267, // Papinella + 189, // Papungha + 46, // Paras + 47, // Parasek + 279, // Pelipper + 366, // Perlu + 231, // Phanpy + 172, // Pichu + 35, // Piepi + 173, // Pii + 25, // Pikachu + 127, // Pinsir + 36, // Pixi + 311, // Plusle + 77, // Ponita + 83, // Porenta + 137, // Porygon + 233, // Porygon2 + 213, // Pottrott + 196, // Psiana + 269, // Pudox + 39, // Pummeluff + 247, // Pupitar + 343, // Puppance + 62, // Quappo + 60, // Quapsel + 61, // Quaputzi + 186, // Quaxo + 220, // Quiekel + 324, // Qurtel + 236, // Rabauz + 26, // Raichu + 243, // Raikou + 57, // Rasaff + 19, // Rattfratz + 20, // Rattikarl + 10, // Raupy + 384, // Rayquaza + 378, // Regice + 377, // Regirock + 379, // Registeel + 143, // Relaxo + 369, // Relicanth + 223, // Remoraid + 253, // Reptain + 23, // Rettan + 111, // Rihorn + 112, // Rizeros + 315, // Roselia + 124, // Rossana + 11, // Safcon + 368, // Saganabyss + 273, // Samurzel + 28, // Sandamer + 27, // Sandan + 71, // Sarzenia + 266, // Schaloko + 212, // Scherox + 7, // Schiggy + 8, // Schillok + 317, // Schlukwech + 316, // Schluppuck + 108, // Schlurp + 339, // Schmerbe + 218, // Schneckmag + 361, // Schneppke + 276, // Schwalbini + 277, // Schwalboss + 230, // Seedraking + 364, // Seejong + 117, // Seemon + 363, // Seemops + 116, // Seeper + 335, // Sengo + 353, // Shuppet + 123, // Sichlor + 65, // Simsala + 214, // Skaraborn + 207, // Skorgla + 88, // Sleima + 89, // Sleimok + 12, // Smettbo + 110, // Smogmog + 109, // Smogon + 215, // Sniebel + 53, // Snobilikat + 209, // Snubbull + 338, // Sonnfel + 192, // Sonnflora + 191, // Sonnkern + 325, // Spoink + 208, // Stahlos + 121, // Starmie + 120, // Sterndu + 306, // Stolloss + 305, // Stollrak + 304, // Stollunior + 245, // Suicune + 260, // Sumpex + 114, // Tangela + 374, // Tanhel + 204, // Tannza + 17, // Tauboga + 18, // Tauboss + 16, // Taubsi + 128, // Tauros + 216, // Teddiursa + 275, // Tengulist + 72, // Tentacha + 73, // Tentoxa + 175, // Togepi + 176, // Togetic + 319, // Tohaido + 157, // Tornupto + 104, // Tragosso + 280, // Trasla + 96, // Traumato + 200, // Traunfugil + 357, // Tropius + 9, // Turtok + 331, // Tuska + 159, // Tyracroc + 70, // Ultrigaria + 217, // Ursaring + 329, // Vibrava + 336, // Vipitis + 313, // Volbeat + 310, // Voltenso + 179, // Voltilamm + 100, // Voltobal + 38, // Vulnona + 37, // Vulpix + 180, // Waaty + 333, // Wablu + 320, // Wailmer + 321, // Wailord + 365, // Walraisa + 265, // Waumpel + 167, // Webarak + 340, // Welsar + 346, // Wielie + 162, // Wiesenior + 161, // Wiesor + 278, // Wingull + 202, // Woingenau + 178, // Xatu + 193, // Yanma + 145, // Zapdos + 263, // Zigzachs + 302, // Zobiris + 41, // Zubat + 356, // Zwirrklop + 355, // Zwirrlicht +}; +#endif + +static const u16 gPokedexOrder_Weight[] = +{ + 92, // Gastly + 93, // Haunter + 187, // Hoppip + 50, // Diglett + 351, // Castform + 109, // Koffing + 174, // Igglybuff + 200, // Misdreavus + 358, // Chimecho + 188, // Skiploom + 385, // Jirachi + 333, // Swablu + 292, // Shedinja + 175, // Togepi + 283, // Surskit + 16, // Pidgey + 191, // Sunkern + 339, // Barboach + 172, // Pichu + 298, // Azurill + 315, // Roselia + 177, // Natu + 21, // Spearow + 198, // Murkrow + 353, // Shuppet + 276, // Taillow + 102, // Exeggcute + 255, // Torchic + 270, // Lotad + 10, // Caterpie + 189, // Jumpluff + 173, // Cleffa + 13, // Weedle + 176, // Togetic + 147, // Dratini + 19, // Rattata + 284, // Masquerain + 265, // Wurmple + 211, // Qwilfish + 151, // Mew + 90, // Shellder + 273, // Seedot + 132, // Ditto + 69, // Bellsprout + 311, // Plusle + 52, // Meowth + 312, // Minun + 285, // Shroomish + 251, // Celebi + 222, // Corsola + 252, // Treecko + 327, // Spinda + 201, // Unown + 46, // Paras + 43, // Oddish + 39, // Jigglypuff + 290, // Nincada + 182, // Bellossom + 81, // Magnemite + 25, // Pikachu + 238, // Smoochum + 161, // Sentret + 70, // Weepinbell + 152, // Chikorita + 220, // Swinub + 133, // Eevee + 98, // Krabby + 104, // Cubone + 280, // Ralts + 1, // Bulbasaur + 23, // Ekans + 29, // Nidoran? + 204, // Pineco + 349, // Feebas + 138, // Omanyte + 41, // Zubat + 35, // Clefairy + 258, // Mudkip + 209, // Snubbull + 179, // Mareep + 155, // Cyndaquil + 116, // Horsea + 4, // Charmander + 192, // Sunflora + 183, // Marill + 194, // Wooper + 167, // Spinarak + 44, // Gloom + 370, // Luvdisc + 216, // Teddiursa + 32, // Nidoran? + 7, // Squirtle + 278, // Wingull + 158, // Totodile + 110, // Weezing + 37, // Vulpix + 11, // Metapod + 266, // Silcoon + 129, // Magikarp + 14, // Kakuna + 316, // Gulpin + 100, // Voltorb + 165, // Ledyba + 228, // Houndour + 300, // Skitty + 302, // Sableye + 307, // Meditite + 341, // Corphish + 190, // Aipom + 268, // Cascoon + 303, // Mawile + 140, // Kabuto + 40, // Wigglytuff + 27, // Sandshrew + 223, // Remoraid + 291, // Ninjask + 170, // Chinchou + 60, // Poliwag + 347, // Anorith + 49, // Venomoth + 354, // Banette + 2, // Ivysaur + 180, // Flaaffy + 261, // Poochyena + 360, // Wynaut + 206, // Dunsparce + 178, // Xatu + 355, // Duskull + 83, // Farfetch'd + 328, // Trapinch + 118, // Goldeen + 309, // Electrike + 329, // Vibrava + 71, // Victreebel + 153, // Bayleef + 225, // Delibird + 293, // Whismur + 148, // Dragonair + 361, // Snorunt + 263, // Zigzagoon + 314, // Illumise + 313, // Volbeat + 20, // Raticate + 45, // Vileplume + 156, // Quilava + 5, // Charmeleon + 58, // Growlithe + 256, // Combusken + 66, // Machop + 63, // Abra + 33, // Nidorino + 54, // Psyduck + 277, // Swellow + 38, // Ninetales + 30, // Nidorina + 61, // Poliwhirl + 74, // Geodude + 281, // Kirlia + 213, // Shuckle + 334, // Altaria + 318, // Carvanha + 236, // Tyrogue + 163, // Hoothoot + 240, // Magby + 343, // Baltoy + 253, // Grovyle + 352, // Kecleon + 171, // Lanturn + 8, // Wartortle + 368, // Gorebyss + 369, // Relicanth + 239, // Elekid + 340, // Whiscash + 345, // Lileep + 322, // Numel + 287, // Slakoth + 135, // Jolteon + 159, // Croconaw + 136, // Flareon + 117, // Seadra + 196, // Espeon + 367, // Huntail + 197, // Umbreon + 259, // Marshtomp + 274, // Nuzleaf + 215, // Sneasel + 56, // Mankey + 279, // Pelipper + 267, // Beautifly + 224, // Octillery + 184, // Azumarill + 202, // Wobbuffet + 134, // Vaporeon + 28, // Sandslash + 47, // Parasect + 15, // Beedrill + 89, // Muk + 17, // Pidgeotto + 88, // Grimer + 26, // Raichu + 77, // Ponyta + 125, // Electabuzz + 48, // Venonat + 325, // Spoink + 356, // Dusclops + 308, // Medicham + 269, // Dustox + 53, // Persian + 12, // Butterfree + 57, // Primeape + 96, // Drowzee + 162, // Furret + 233, // Porygon2 + 271, // Lombre + 264, // Linoone + 301, // Delcatty + 342, // Crawdaunt + 51, // Dugtrio + 168, // Ariados + 231, // Phanpy + 186, // Politoed + 120, // Staryu + 113, // Chansey + 139, // Omastar + 114, // Tangela + 218, // Slugma + 229, // Houndoom + 166, // Ledian + 79, // Slowpoke + 137, // Porygon + 262, // Mightyena + 193, // Yanma + 22, // Fearow + 185, // Sudowoodo + 119, // Seaking + 286, // Breloom + 84, // Doduo + 18, // Pidgeot + 363, // Spheal + 36, // Clefable + 380, // Latias + 310, // Manectric + 335, // Zangoose + 141, // Kabutops + 94, // Gengar + 294, // Loudred + 124, // Jynx + 164, // Noctowl + 203, // Girafarig + 371, // Bagon + 126, // Magmar + 105, // Marowak + 72, // Tentacool + 288, // Vigoroth + 242, // Blissey + 359, // Absol + 65, // Alakazam + 237, // Hitmontop + 282, // Gardevoir + 210, // Granbull + 106, // Hitmonlee + 107, // Hitmonchan + 227, // Skarmory + 331, // Cacnea + 257, // Blaziken + 254, // Sceptile + 336, // Seviper + 366, // Clamperl + 145, // Zapdos + 214, // Heracross + 62, // Poliwrath + 122, // Mr. mime + 127, // Pinsir + 272, // Ludicolo + 73, // Tentacruel + 42, // Golbat + 219, // Magcargo + 144, // Articuno + 221, // Piloswine + 123, // Scyther + 64, // Kadabra + 235, // Smeargle + 142, // Aerodactyl + 275, // Shiftry + 99, // Kingler + 31, // Nidoqueen + 82, // Magneton + 304, // Aron + 381, // Latios + 146, // Moltres + 346, // Cradily + 386, // Deoxys + 181, // Ampharos + 34, // Nidoking + 207, // Gligar + 24, // Arbok + 108, // Lickitung + 101, // Electrode + 348, // Armaldo + 67, // Machoke + 234, // Stantler + 326, // Grumpig + 246, // Larvitar + 169, // Crobat + 195, // Quagsire + 241, // Miltank + 97, // Hypno + 55, // Golduck + 332, // Cacturne + 80, // Slowbro + 157, // Typhlosion + 199, // Slowking + 115, // Kangaskhan + 121, // Starmie + 317, // Swalot + 324, // Torkoal + 260, // Swampert + 330, // Flygon + 295, // Exploud + 85, // Dodrio + 9, // Blastoise + 296, // Makuhita + 364, // Sealeo + 128, // Tauros + 319, // Sharpedo + 160, // Feraligatr + 86, // Seel + 6, // Charizard + 78, // Rapidash + 374, // Beldum + 299, // Nosepass + 3, // Venusaur + 357, // Tropius + 154, // Meganium + 373, // Salamence + 75, // Graveler + 344, // Claydol + 372, // Shelgon + 111, // Rhyhorn + 212, // Scizor + 87, // Dewgong + 112, // Rhydon + 232, // Donphan + 103, // Exeggutor + 305, // Lairon + 150, // Mewtwo + 217, // Ursaring + 205, // Forretress + 68, // Machamp + 320, // Wailmer + 289, // Slaking + 91, // Cloyster + 365, // Walrein + 247, // Pupitar + 230, // Kingdra + 338, // Solrock + 59, // Arcanine + 350, // Milotic + 337, // Lunatone + 378, // Regice + 243, // Raikou + 245, // Suicune + 244, // Entei + 250, // Ho-Oh + 248, // Tyranitar + 375, // Metang + 379, // Registeel + 384, // Rayquaza + 95, // Onix + 149, // Dragonite + 249, // Lugia + 131, // Lapras + 323, // Camerupt + 226, // Mantine + 377, // Regirock + 130, // Gyarados + 297, // Hariyama + 362, // Glalie + 76, // Golem + 382, // Kyogre + 306, // Aggron + 321, // Wailord + 208, // Steelix + 143, // Snorlax + 376, // Metagross + 383, // Groudon +}; +static const u16 gPokedexOrder_Height[] = +{ + 50, // Diglett + 298, // Azurill + 177, // Natu + 13, // Weedle + 172, // Pichu + 173, // Cleffa + 175, // Togepi + 351, // Castform + 174, // Igglybuff + 10, // Caterpie + 276, // Taillow + 132, // Ditto + 133, // Eevee + 315, // Roselia + 21, // Spearow + 16, // Pidgey + 191, // Sunkern + 90, // Shellder + 19, // Rattata + 81, // Magnemite + 46, // Paras + 265, // Wurmple + 385, // Jirachi + 104, // Cubone + 258, // Mudkip + 194, // Wooper + 116, // Horsea + 52, // Meowth + 29, // Nidoran? + 220, // Swinub + 151, // Mew + 333, // Swablu + 304, // Aron + 311, // Plusle + 312, // Minun + 102, // Exeggcute + 25, // Pikachu + 182, // Bellossom + 316, // Gulpin + 263, // Zigzagoon + 285, // Shroomish + 138, // Omanyte + 331, // Cacnea + 98, // Krabby + 280, // Ralts + 187, // Hoppip + 255, // Torchic + 366, // Clamperl + 74, // Geodude + 183, // Marill + 339, // Barboach + 238, // Smoochum + 100, // Voltorb + 290, // Nincada + 302, // Sableye + 198, // Murkrow + 211, // Qwilfish + 7, // Squirtle + 252, // Treecko + 343, // Baltoy + 43, // Oddish + 270, // Lotad + 39, // Jigglypuff + 283, // Surskit + 155, // Cyndaquil + 140, // Kabuto + 264, // Linoone + 324, // Torkoal + 32, // Nidoran? + 167, // Spinarak + 56, // Mankey + 273, // Seedot + 261, // Poochyena + 231, // Phanpy + 201, // Unown + 170, // Chinchou + 233, // Porygon2 + 60, // Poliwag + 371, // Bagon + 349, // Feebas + 353, // Shuppet + 158, // Totodile + 251, // Celebi + 360, // Wynaut + 27, // Sandshrew + 358, // Chimecho + 370, // Luvdisc + 228, // Houndour + 266, // Silcoon + 309, // Electrike + 4, // Charmander + 307, // Meditite + 278, // Wingull + 223, // Remoraid + 341, // Corphish + 222, // Corsola + 314, // Illumise + 209, // Snubbull + 37, // Vulpix + 246, // Larvitar + 374, // Beldum + 293, // Whismur + 204, // Pineco + 239, // Elekid + 35, // Clefairy + 213, // Shuckle + 216, // Teddiursa + 14, // Kakuna + 300, // Skitty + 176, // Togetic + 118, // Goldeen + 303, // Mawile + 179, // Mareep + 188, // Skiploom + 109, // Koffing + 51, // Dugtrio + 268, // Cascoon + 322, // Numel + 347, // Anorith + 313, // Volbeat + 163, // Hoothoot + 328, // Trapinch + 325, // Spoink + 11, // Metapod + 69, // Bellsprout + 361, // Snorunt + 20, // Raticate + 259, // Marshtomp + 277, // Swellow + 240, // Magby + 58, // Growlithe + 200, // Misdreavus + 1, // Bulbasaur + 236, // Tyrogue + 218, // Slugma + 287, // Slakoth + 281, // Kirlia + 190, // Aipom + 135, // Jolteon + 30, // Nidorina + 184, // Azumarill + 292, // Shedinja + 66, // Machop + 291, // Ninjask + 284, // Masquerain + 355, // Duskull + 192, // Sunflora + 189, // Jumpluff + 120, // Staryu + 180, // Flaaffy + 363, // Spheal + 54, // Psyduck + 219, // Magcargo + 83, // Farfetch'd + 41, // Zubat + 137, // Porygon + 161, // Sentret + 318, // Carvanha + 44, // Gloom + 26, // Raichu + 129, // Magikarp + 215, // Sneasel + 305, // Lairon + 256, // Combusken + 224, // Octillery + 33, // Nidorino + 136, // Flareon + 225, // Delibird + 72, // Tentacool + 63, // Abra + 253, // Grovyle + 340, // Whiscash + 156, // Quilava + 196, // Espeon + 88, // Grimer + 152, // Chikorita + 326, // Grumpig + 299, // Nosepass + 53, // Persian + 262, // Mightyena + 48, // Venonat + 82, // Magneton + 77, // Ponyta + 296, // Makuhita + 337, // Lunatone + 28, // Sandslash + 96, // Drowzee + 114, // Tangela + 57, // Primeape + 165, // Ledyba + 40, // Wigglytuff + 47, // Parasect + 139, // Omastar + 294, // Loudred + 8, // Wartortle + 75, // Graveler + 197, // Umbreon + 345, // Lileep + 61, // Poliwhirl + 134, // Vaporeon + 15, // Beedrill + 105, // Marowak + 70, // Weepinbell + 369, // Relicanth + 111, // Rhyhorn + 2, // Ivysaur + 352, // Kecleon + 274, // Nuzleaf + 267, // Beautifly + 17, // Pidgeotto + 168, // Ariados + 86, // Seel + 186, // Politoed + 159, // Croconaw + 113, // Chansey + 354, // Banette + 232, // Donphan + 121, // Starmie + 5, // Charmeleon + 221, // Piloswine + 12, // Butterfree + 329, // Vibrava + 125, // Electabuzz + 342, // Crawdaunt + 301, // Delcatty + 334, // Altaria + 372, // Shelgon + 38, // Ninetales + 207, // Gligar + 364, // Sealeo + 327, // Spinda + 247, // Pupitar + 79, // Slowpoke + 338, // Solrock + 241, // Miltank + 22, // Fearow + 45, // Vileplume + 89, // Muk + 205, // Forretress + 185, // Sudowoodo + 359, // Absol + 193, // Yanma + 269, // Dustox + 108, // Lickitung + 235, // Smeargle + 171, // Lanturn + 101, // Electrode + 271, // Lombre + 286, // Breloom + 153, // Bayleef + 117, // Seadra + 110, // Weezing + 279, // Pelipper + 375, // Metang + 31, // Nidoqueen + 332, // Cacturne + 275, // Shiftry + 308, // Medicham + 335, // Zangoose + 141, // Kabutops + 99, // Kingler + 64, // Kadabra + 119, // Seaking + 36, // Clefable + 126, // Magmar + 202, // Wobbuffet + 92, // Gastly + 122, // Mr. mime + 62, // Poliwrath + 128, // Tauros + 380, // Latias + 181, // Ampharos + 288, // Vigoroth + 166, // Ledian + 76, // Golem + 365, // Walrein + 84, // Doduo + 229, // Houndoom + 34, // Nidoking + 124, // Jynx + 107, // Hitmonchan + 234, // Stantler + 210, // Granbull + 237, // Hitmontop + 195, // Quagsire + 344, // Claydol + 260, // Swampert + 242, // Blissey + 272, // Ludicolo + 295, // Exploud + 206, // Dunsparce + 127, // Pinsir + 91, // Cloyster + 67, // Machoke + 203, // Girafarig + 18, // Pidgeot + 178, // Xatu + 346, // Cradily + 106, // Hitmonlee + 49, // Venomoth + 94, // Gengar + 214, // Heracross + 362, // Glalie + 123, // Scyther + 373, // Salamence + 310, // Manectric + 348, // Armaldo + 65, // Alakazam + 97, // Hypno + 164, // Noctowl + 73, // Tentacruel + 356, // Dusclops + 145, // Zapdos + 42, // Golbat + 376, // Metagross + 282, // Gardevoir + 9, // Blastoise + 80, // Slowbro + 93, // Haunter + 68, // Machamp + 377, // Regirock + 317, // Swalot + 254, // Sceptile + 227, // Skarmory + 55, // Golduck + 386, // Deoxys + 71, // Victreebel + 78, // Rapidash + 6, // Charizard + 367, // Huntail + 87, // Dewgong + 144, // Articuno + 157, // Typhlosion + 142, // Aerodactyl + 368, // Gorebyss + 217, // Ursaring + 154, // Meganium + 378, // Regice + 212, // Scizor + 230, // Kingdra + 147, // Dratini + 85, // Dodrio + 319, // Sharpedo + 169, // Crobat + 162, // Furret + 59, // Arcanine + 243, // Raikou + 257, // Blaziken + 323, // Camerupt + 112, // Rhydon + 379, // Registeel + 23, // Ekans + 330, // Flygon + 357, // Tropius + 381, // Latios + 245, // Suicune + 146, // Moltres + 3, // Venusaur + 103, // Exeggutor + 199, // Slowking + 248, // Tyranitar + 289, // Slaking + 320, // Wailmer + 150, // Mewtwo + 306, // Aggron + 143, // Snorlax + 226, // Mantine + 244, // Entei + 149, // Dragonite + 115, // Kangaskhan + 297, // Hariyama + 160, // Feraligatr + 131, // Lapras + 336, // Seviper + 24, // Arbok + 383, // Groudon + 250, // Ho-Oh + 148, // Dragonair + 382, // Kyogre + 249, // Lugia + 350, // Milotic + 130, // Gyarados + 384, // Rayquaza + 95, // Onix + 208, // Steelix + 321, // Wailord +}; diff --git a/src/data/text/font0_widths.h b/src/data/text/font0_widths.h new file mode 100644 index 000000000..a461eea5b --- /dev/null +++ b/src/data/text/font0_widths.h @@ -0,0 +1,60 @@ +#if ENGLISH +#if REVISION >= 1 +static const u8 sFont0Widths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 4, 8, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 8, + 8, 8, 8, 8, 8, 8, 3, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 4, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 6, 7, 8, 7, 7, 8, 8, 4, + 7, 8, 8, 8, 8, 8, 7, 8, 7, 7, 7, 7, 7, 7, 8, 7, + 7, 7, 7, 7, 5, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 3, 5, 3, + 6, 6, 6, 3, 3, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, + 3, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, + 3, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 1, 1, +}; +#else +static const u8 sFont0Widths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 5, 8, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, + 7, 7, 7, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 3, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 7, 7, 8, 8, 6, + 7, 8, 8, 8, 8, 8, 7, 8, 7, 7, 7, 7, 7, 7, 8, 7, + 7, 7, 7, 7, 7, 7, 7, 8, 6, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 3, 5, 3, + 6, 6, 6, 3, 3, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, + 3, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, + 3, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 1, 1, +}; +#endif +#elif GERMAN +static const u8 sFont0Widths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, + 8, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 4, 8, + 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 6, 8, 6, 6, 8, + 8, 8, 8, 8, 8, 8, 3, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 4, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 6, 7, 8, 7, 7, 8, 8, 4, + 7, 8, 8, 8, 8, 8, 7, 8, 7, 7, 7, 7, 7, 7, 8, 7, + 7, 7, 7, 7, 5, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 3, 5, 3, + 6, 6, 6, 3, 3, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, + 3, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, + 3, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 1, 1, +}; +#endif diff --git a/src/data/text/font1_widths.h b/src/data/text/font1_widths.h new file mode 100644 index 000000000..7086628cb --- /dev/null +++ b/src/data/text/font1_widths.h @@ -0,0 +1,35 @@ +#if REVISION >= 1 || GERMAN +static const u8 sFont1Widths[] = { + 5, 3, 8, 8, 8, 8, 8, 8, 8, 4, 5, 4, 4, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 5, 8, 8, 8, 8, 8, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 5, 5, 5, + 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 8, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 8, 4, 5, 5, 5, 5, 4, 8, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 5, 6, 6, + 8, 7, 3, 5, 3, 3, 5, 4, 3, 6, 6, 6, 7, 7, 8, 5, + 5, 5, 3, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 4, 4, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 6, 6, 7, 7, 7, 7, 6, 7, 6, 6, 7, 6, + 7, 7, 7, 6, 7, 6, 7, 6, 7, 6, 6, 7, 6, 6, 3, 3, + 5, 5, 5, 5, 3, 3, 5, 5, 5, 5, 5, 5, +}; +#else +static const u8 sFont1Widths[] = { + 5, 3, 8, 8, 8, 8, 8, 8, 8, 4, 5, 4, 4, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 5, 8, 8, 8, 8, 8, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 5, + 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 8, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 8, 4, 5, 5, 5, 5, 4, 8, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, + 8, 7, 6, 5, 3, 3, 5, 4, 3, 6, 6, 6, 7, 7, 8, 5, + 5, 5, 3, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 4, 4, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 6, 6, 7, 7, 7, 7, 6, 7, 6, 6, 7, 6, + 7, 7, 7, 6, 7, 6, 7, 6, 7, 6, 6, 7, 6, 6, 3, 3, + 5, 5, 5, 5, 3, 3, 5, 5, 5, 5, 5, 5, +}; +#endif diff --git a/src/data/text/font3_widths.h b/src/data/text/font3_widths.h new file mode 100644 index 000000000..2d088f136 --- /dev/null +++ b/src/data/text/font3_widths.h @@ -0,0 +1,60 @@ +#if ENGLISH +#if REVISION >= 1 +static const u8 sFont3Widths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 4, 8, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 8, + 8, 8, 8, 8, 8, 8, 3, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 4, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 6, 7, 8, 7, 7, 8, 8, 4, + 7, 8, 8, 8, 8, 8, 7, 8, 7, 7, 7, 7, 7, 7, 8, 7, + 7, 7, 7, 7, 5, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 3, 5, 3, + 6, 6, 6, 3, 3, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, + 3, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, + 3, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 1, 1, +}; +#else +static const u8 sFont3Widths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 4, 8, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 4, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 6, 7, 8, 7, 7, 8, 8, 4, + 7, 8, 8, 8, 8, 8, 7, 8, 7, 7, 7, 7, 7, 7, 8, 7, + 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 3, 5, 3, + 6, 6, 6, 3, 3, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, + 3, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, + 3, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 1, 1, +}; +#endif +#elif GERMAN +static const u8 sFont3Widths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, + 8, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 4, 8, + 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 6, 8, 6, 6, 8, + 8, 8, 8, 8, 8, 8, 3, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 4, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 6, 7, 8, 7, 7, 8, 8, 4, + 7, 8, 8, 8, 8, 8, 7, 8, 7, 7, 7, 7, 7, 7, 8, 7, + 7, 7, 7, 7, 5, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 3, 5, 3, + 6, 6, 6, 3, 3, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, + 3, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, + 3, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 1, 1, +}; +#endif diff --git a/src/data/text/font4_widths.h b/src/data/text/font4_widths.h new file mode 100644 index 000000000..4c8149b76 --- /dev/null +++ b/src/data/text/font4_widths.h @@ -0,0 +1,35 @@ +#if REVISION >= 1 || GERMAN +static const u8 sFont4Widths[] = { + 5, 3, 8, 8, 8, 8, 8, 8, 8, 4, 5, 4, 4, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 5, 8, 8, 8, 8, 8, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 5, 5, 5, + 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 8, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 8, 4, 5, 5, 5, 5, 4, 8, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 5, 6, 6, + 8, 7, 3, 5, 3, 3, 5, 4, 3, 6, 6, 6, 7, 7, 8, 5, + 5, 5, 3, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 4, 4, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 6, 6, 7, 7, 7, 7, 6, 7, 6, 6, 7, 6, + 7, 7, 7, 6, 7, 6, 7, 6, 7, 6, 6, 7, 6, 6, 3, 3, + 5, 5, 5, 5, 3, 3, 5, 5, 5, 5, 5, 5, +}; +#else +static const u8 sFont4Widths[] = { + 5, 3, 8, 8, 8, 8, 8, 8, 8, 4, 5, 4, 4, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 5, 8, 8, 8, 8, 8, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 5, + 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 8, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 8, 4, 5, 5, 5, 5, 4, 8, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, + 8, 7, 6, 5, 3, 3, 5, 4, 3, 6, 6, 6, 7, 7, 8, 5, + 5, 5, 3, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 4, 4, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 6, 6, 7, 7, 7, 7, 6, 7, 6, 6, 7, 6, + 7, 7, 7, 6, 7, 6, 7, 6, 7, 6, 6, 7, 6, 6, 3, 3, + 5, 5, 5, 5, 3, 3, 5, 5, 5, 5, 5, 5, +}; +#endif diff --git a/src/data/text/type1_map.h b/src/data/text/type1_map.h new file mode 100644 index 000000000..ff22e560a --- /dev/null +++ b/src/data/text/type1_map.h @@ -0,0 +1,249 @@ +static const u8 sFontType1Map[] = { + 0xD4, 0xD4, + 0xD4, 0x31, + 0xD4, 0x32, + 0xD4, 0x33, + 0xD4, 0x34, + 0xD4, 0x35, + 0xD4, 0x36, + 0xD4, 0x37, + 0xD4, 0x38, + 0xD4, 0x39, + 0xD4, 0x3A, + 0xD4, 0x3B, + 0xD4, 0x3C, + 0xD4, 0x3D, + 0xD4, 0x3E, + 0xD4, 0x3F, + 0xD4, 0x40, + 0xD4, 0x41, + 0xD4, 0x42, + 0xD4, 0x43, + 0xD4, 0x44, + 0xD4, 0x45, + 0xD4, 0x46, + 0xD4, 0x47, + 0xD4, 0x48, + 0xD4, 0x49, + 0xD4, 0x4A, + 0xD4, 0x4B, + 0xD4, 0x4C, + 0xD4, 0x4D, + 0xD4, 0x4E, + 0xD4, 0x4F, + 0xD4, 0x50, + 0xD4, 0x51, + 0xD4, 0x52, + 0xD4, 0x53, + 0xD4, 0x54, + 0xD4, 0x55, + 0xD4, 0x56, + 0xD4, 0x57, + 0xD4, 0x58, + 0xD4, 0x59, + 0xD4, 0x5A, + 0xD4, 0x5B, + 0xD4, 0x5C, + 0xD4, 0x5D, + 0xD4, 0x5E, + 0xD4, 0x31, + 0xD4, 0x32, + 0xD4, 0x33, + 0xD4, 0x34, + 0xD4, 0x35, + 0xD4, 0x60, + 0xD4, 0x61, + 0xD4, 0x62, + 0x65, 0x36, + 0x65, 0x37, + 0x65, 0x38, + 0x65, 0x39, + 0x65, 0x3A, + 0x65, 0x3B, + 0x65, 0x3C, + 0x65, 0x3D, + 0x65, 0x3E, + 0x65, 0x3F, + 0x65, 0x40, + 0x65, 0x41, + 0x65, 0x42, + 0x65, 0x43, + 0x65, 0x44, + 0x65, 0x4A, + 0x65, 0x4B, + 0x65, 0x4C, + 0x65, 0x4D, + 0x65, 0x4E, + 0x64, 0x4A, + 0x64, 0x4B, + 0x64, 0x4C, + 0x64, 0x4D, + 0x64, 0x4E, + 0xD4, 0x5F, + 0xD4, 0x00, + 0xD4, 0x01, + 0xD4, 0x02, + 0xD4, 0x03, + 0xD4, 0x04, + 0xD4, 0x05, + 0xD4, 0x06, + 0xD4, 0x07, + 0xD4, 0x08, + 0xD4, 0x09, + 0xD4, 0x0A, + 0xD4, 0x0B, + 0xD4, 0x0C, + 0xD4, 0x0D, + 0xD4, 0x0E, + 0xD4, 0x0F, + 0xD4, 0x10, + 0xD4, 0x11, + 0xD4, 0x12, + 0xD4, 0x13, + 0xD4, 0x14, + 0xD4, 0x15, + 0xD4, 0x16, + 0xD4, 0x17, + 0xD4, 0x18, + 0xD4, 0x19, + 0xD4, 0x1A, + 0xD4, 0x1B, + 0xD4, 0x4D, + 0xD4, 0x1C, + 0xD4, 0x1D, + 0xD4, 0x1E, + 0xD4, 0x1F, + 0xD4, 0x20, + 0xD4, 0x21, + 0xD4, 0x22, + 0xD4, 0x23, + 0xD4, 0x24, + 0xD4, 0x25, + 0xD4, 0x58, + 0xD4, 0x26, + 0xD4, 0x27, + 0xD4, 0x28, + 0xD4, 0x29, + 0xD4, 0x2A, + 0xD4, 0x2B, + 0xD4, 0x69, + 0xD4, 0x30, + 0xD4, 0x6A, + 0xD4, 0x6B, + 0xD4, 0x74, + 0xD4, 0x2D, + 0xD4, 0x2E, + 0xD4, 0x2F, + 0x65, 0x05, + 0x65, 0x06, + 0x65, 0x07, + 0x65, 0x08, + 0x65, 0x09, + 0x65, 0x0A, + 0x65, 0x0B, + 0x65, 0x0C, + 0x65, 0x0D, + 0x65, 0x0E, + 0x65, 0x0F, + 0x65, 0x10, + 0x65, 0x11, + 0x65, 0x12, + 0x65, 0x13, + 0x65, 0x19, + 0x65, 0x1A, + 0x65, 0x1B, + 0x65, 0x4D, + 0x65, 0x1C, + 0x64, 0x19, + 0x64, 0x1A, + 0x64, 0x1B, + 0x64, 0x4D, + 0x64, 0x1C, + 0xD4, 0x2C, + 0xD4, 0x76, + 0xD4, 0x77, + 0xD4, 0x78, + 0xD4, 0x79, + 0xD4, 0x7A, + 0xD4, 0x7B, + 0xD4, 0x7C, + 0xD4, 0x7D, + 0xD4, 0x7E, + 0xD4, 0x7F, + 0xD4, 0x67, + 0xD4, 0x66, + 0xD4, 0x68, + 0xD4, 0x63, + 0xD4, 0xD2, + 0xD4, 0xD3, + 0xD4, 0xD0, + 0xD4, 0xD1, + 0xD4, 0xCE, + 0xD4, 0xCF, + 0xD4, 0x6F, + 0xD4, 0x75, + 0xD4, 0x70, + 0xD4, 0x72, + 0xD4, 0x71, + 0xD4, 0x73, + 0xD4, 0x80, + 0xD4, 0x81, + 0xD4, 0x82, + 0xD4, 0x83, + 0xD4, 0x84, + 0xD4, 0x85, + 0xD4, 0x86, + 0xD4, 0x87, + 0xD4, 0x88, + 0xD4, 0x89, + 0xD4, 0x8A, + 0xD4, 0x8B, + 0xD4, 0x8C, + 0xD4, 0x8D, + 0xD4, 0x8E, + 0xD4, 0x8F, + 0xD4, 0x90, + 0xD4, 0x91, + 0xD4, 0x92, + 0xD4, 0x93, + 0xD4, 0x94, + 0xD4, 0x95, + 0xD4, 0x96, + 0xD4, 0x97, + 0xD4, 0x98, + 0xD4, 0x99, + 0xD4, 0x9A, + 0xD4, 0x9B, + 0xD4, 0x9C, + 0xD4, 0x9D, + 0xD4, 0x9E, + 0xD4, 0x9F, + 0xD4, 0xA0, + 0xD4, 0xA1, + 0xD4, 0xA2, + 0xD4, 0xA3, + 0xD4, 0xA4, + 0xD4, 0xA5, + 0xD4, 0xA6, + 0xD4, 0xA7, + 0xD4, 0xA8, + 0xD4, 0xA9, + 0xD4, 0xAA, + 0xD4, 0xAB, + 0xD4, 0xAC, + 0xD4, 0xAD, + 0xD4, 0xAE, + 0xD4, 0xAF, + 0xD4, 0xB0, + 0xD4, 0xB1, + 0xD4, 0xB2, + 0xD4, 0xB3, + 0xD4, 0x6D, + 0xD4, 0xD5, + 0xD4, 0xD6, + 0xD4, 0xD7, + 0xD4, 0xD8, + 0xD4, 0xD9, + 0xD4, 0xDA, + 0xD4, 0xDB, +}; diff --git a/src/data/text/type3_map.h b/src/data/text/type3_map.h new file mode 100644 index 000000000..cb3694b39 --- /dev/null +++ b/src/data/text/type3_map.h @@ -0,0 +1,130 @@ +static const u8 sFontType3Map[] = { + 0x00, 0x10, + 0x01, 0x10, + 0x02, 0x10, + 0x03, 0x10, + 0x04, 0x11, + 0x05, 0x11, + 0x06, 0x11, + 0x07, 0x11, + 0x08, 0x12, + 0x09, 0x12, + 0x0A, 0x12, + 0x0B, 0x12, + 0x0C, 0x13, + 0x0D, 0x13, + 0x0E, 0x13, + 0x0F, 0x13, + 0x00, 0x14, + 0x01, 0x14, + 0x02, 0x14, + 0x03, 0x14, + 0x04, 0x15, + 0x05, 0x15, + 0x06, 0x15, + 0x07, 0x15, + 0x08, 0x16, + 0x09, 0x16, + 0x0A, 0x16, + 0x0B, 0x16, + 0x0C, 0x17, + 0x0D, 0x17, + 0x0E, 0x17, + 0x0F, 0x17, + 0x00, 0x18, + 0x01, 0x18, + 0x02, 0x18, + 0x03, 0x18, + 0x04, 0x19, + 0x05, 0x19, + 0x06, 0x19, + 0x07, 0x19, + 0x08, 0x1A, + 0x09, 0x1A, + 0x0A, 0x1A, + 0x0B, 0x1A, + 0x0C, 0x1B, + 0x0D, 0x1B, + 0x0E, 0x1B, + 0x0F, 0x1B, + 0x00, 0x1C, + 0x01, 0x1C, + 0x02, 0x1C, + 0x03, 0x1C, + 0x04, 0x1D, + 0x05, 0x1D, + 0x06, 0x1D, + 0x07, 0x1D, + 0x08, 0x1E, + 0x09, 0x1E, + 0x0A, 0x1E, + 0x0B, 0x1E, + 0x0C, 0x1F, + 0x0D, 0x1F, + 0x0E, 0x1F, + 0x0F, 0x1F, + 0x20, 0x24, + 0x20, 0x24, + 0x21, 0x24, + 0x21, 0x24, + 0x20, 0x24, + 0x20, 0x24, + 0x21, 0x24, + 0x21, 0x24, + 0x22, 0x25, + 0x22, 0x25, + 0x23, 0x25, + 0x23, 0x25, + 0x22, 0x25, + 0x22, 0x25, + 0x23, 0x25, + 0x23, 0x25, + 0x20, 0x24, + 0x20, 0x24, + 0x21, 0x24, + 0x21, 0x24, + 0x20, 0x24, + 0x20, 0x24, + 0x21, 0x24, + 0x21, 0x24, + 0x22, 0x25, + 0x22, 0x25, + 0x23, 0x25, + 0x23, 0x25, + 0x22, 0x25, + 0x22, 0x25, + 0x23, 0x25, + 0x23, 0x25, + 0x20, 0x26, + 0x20, 0x26, + 0x21, 0x26, + 0x21, 0x26, + 0x20, 0x26, + 0x20, 0x26, + 0x21, 0x26, + 0x21, 0x26, + 0x22, 0x27, + 0x22, 0x27, + 0x23, 0x27, + 0x23, 0x27, + 0x22, 0x27, + 0x22, 0x27, + 0x23, 0x27, + 0x23, 0x27, + 0x20, 0x26, + 0x20, 0x26, + 0x21, 0x26, + 0x21, 0x26, + 0x20, 0x26, + 0x20, 0x26, + 0x21, 0x26, + 0x21, 0x26, + 0x22, 0x27, + 0x22, 0x27, + 0x23, 0x27, + 0x23, 0x27, + 0x22, 0x27, + 0x22, 0x27, + 0x23, 0x27, + 0x23, 0x27, +}; diff --git a/src/daycare.c b/src/daycare.c new file mode 100644 index 000000000..cded18207 --- /dev/null +++ b/src/daycare.c @@ -0,0 +1,350 @@ +#include "global.h" +#include "daycare.h" +#include "pokemon.h" +#include "species.h" +#include "items.h" +#include "string_util.h" + +extern u8 gLastFieldPokeMenuOpened; + +u8 *GetMonNick(struct Pokemon *mon, u8 *dest) +{ + s8 nickname[POKEMON_NAME_LENGTH * 2]; + + GetMonData(mon, MON_DATA_NICKNAME, nickname); + return StringCopy10(dest, nickname); +} + +u8 *GetBoxMonNick(struct BoxPokemon *mon, u8 *dest) +{ + s8 nickname[POKEMON_NAME_LENGTH * 2]; + + GetBoxMonData(mon, MON_DATA_NICKNAME, nickname); + return StringCopy10(dest, nickname); +} + +u8 Daycare_CountPokemon(struct BoxPokemon *daycare_data) +{ + u8 i, count; + count = 0; + + for(i = 0;i <= 1;i++) + if(GetBoxMonData(daycare_data + i, MON_DATA_SPECIES) != 0) + count++; + + return count; +} + +void sub_8041324(struct BoxPokemon * box_pokemon, struct RecordMixing_UnknownStruct * void_pointer) +{ + u8 i; + u8 specCount; + specCount = 0; + for (i=0; i<2; i++) + { + if (GetBoxMonData(&box_pokemon[i], MON_DATA_SPECIES) != SPECIES_NONE) + { + specCount ++; + if (GetBoxMonData(&box_pokemon[i], MON_DATA_HELD_ITEM) == ITEM_NONE) + { + void_pointer->unk74[i] = 0; + } else + { + void_pointer->unk74[i] = 1; + } + } else + { + void_pointer->unk74[i] = 1; + } + } + void_pointer->unk70 = specCount; +} + +s8 Daycare_FindEmptySpot(struct BoxPokemon * daycare_data) +{ + u8 i; + + for(i = 0;i <= 1;i++) + if(GetBoxMonData(daycare_data + i, MON_DATA_SPECIES) == 0) + return i; + + return -1; +} + +/*void Daycare_SendPokemon(struct Pokemon * mon, struct BoxPokemon * daycare_data){ // unfinished + s8 empty_slot; + + empty_slot = Daycare_FindEmptySpot(daycare_data); + if(MonHasMail(mon) != 0){ // if the mon holds a mail? + u8 empty_slot_times_56 = empty_slot * 56; + u8 * something2 = ((u8 *) (daycare_data + 2)) + empty_slot_times_56 + 36; + StringCopy(something2, gSaveBlock2.playerName); + PadNameString(something2, 0xFC); + something2 += 8; + GetMonNick(mon, something2); + u8 pokerus = GetMonData(mon, MON_DATA_64); + something1 += (u8 * daycare_data) +}*/ + +__attribute__((naked)) +void Daycare_SendPokemon() +{ + // strange stack usage - happens because THUMB ARM only allows R0-R7 to be pushed/popped: + // all registers in reglist must be Lo registers, except that PUSH can include the LR, and POP can include the PC + // the ldm/stm section probably copies some struct, but I'm not sure how the code would look + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r9\n\ + mov r6, r8\n\ + push {r6,r7}\n\ + adds r7, r0, 0\n\ + mov r8, r1\n\ + mov r0, r8\n\ + bl Daycare_FindEmptySpot\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + mov r9, r4\n\ + adds r0, r7, 0\n\ + bl MonHasMail\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0804144A\n\ + lsls r0, r4, 24\n\ + asrs r0, 24\n\ + lsls r4, r0, 3\n\ + subs r4, r0\n\ + lsls r4, 3\n\ + adds r5, r4, 0\n\ + adds r5, 0xA0\n\ + add r5, r8\n\ + adds r6, r5, 0\n\ + adds r6, 0x24\n\ + ldr r1, _08041490 @ =gSaveBlock2\n\ + adds r0, r6, 0\n\ + bl StringCopy\n\ + adds r0, r6, 0\n\ + movs r1, 0xFC\n\ + bl PadNameString\n\ + adds r6, 0x8\n\ + adds r0, r7, 0\n\ + adds r1, r6, 0\n\ + bl GetMonNick\n\ + adds r0, r7, 0\n\ + movs r1, 0x40\n\ + bl GetMonData\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + add r4, r8\n\ + ldr r2, _08041494 @ =gSaveBlock1\n\ + lsls r1, r0, 3\n\ + adds r1, r0\n\ + lsls r1, 2\n\ + adds r1, r2\n\ + adds r4, 0xA0\n\ + ldr r0, _08041498 @ =0x00002b4c\n\ + adds r1, r0\n\ + ldm r1!, {r0,r2,r3}\n\ + stm r4!, {r0,r2,r3}\n\ + ldm r1!, {r0,r2,r3}\n\ + stm r4!, {r0,r2,r3}\n\ + ldm r1!, {r0,r2,r3}\n\ + stm r4!, {r0,r2,r3}\n\ + adds r0, r7, 0\n\ + bl TakeMailFromMon\n\ +_0804144A:\n\ + mov r2, r9\n\ + lsls r4, r2, 24\n\ + asrs r4, 24\n\ + lsls r5, r4, 2\n\ + adds r4, r5, r4\n\ + lsls r4, 4\n\ + add r4, r8\n\ + adds r0, r4, 0\n\ + adds r1, r7, 0\n\ + movs r2, 0x50\n\ + bl memcpy\n\ + adds r0, r4, 0\n\ + bl BoxMonRestorePP\n\ + movs r0, 0x88\n\ + lsls r0, 1\n\ + add r0, r8\n\ + adds r0, r5\n\ + movs r1, 0\n\ + str r1, [r0]\n\ + adds r0, r7, 0\n\ + bl ZeroMonData\n\ + bl party_compaction\n\ + bl CalculatePlayerPartyCount\n\ + pop {r3,r4}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_08041490: .4byte gSaveBlock2\n\ +_08041494: .4byte gSaveBlock1\n\ +_08041498: .4byte 0x00002b4c\n\ + .syntax divided\n"); +} + +void Daycare_SendPokemon_Special() +{ + Daycare_SendPokemon(gPlayerParty + gLastFieldPokeMenuOpened, gSaveBlock1.daycareData); +} + +void sub_80417F4(u8 *); + +void sub_80414C0(struct BoxPokemon * daycare_data) +{ + u32 second_species; + if((GetBoxMonData(&daycare_data[1], MON_DATA_SPECIES) != 0) && ((second_species = GetBoxMonData(&daycare_data[0], MON_DATA_SPECIES)) == 0)){ + daycare_data[0] = daycare_data[1]; + ZeroBoxMonData(&daycare_data[1]); + memcpy(daycare_data + 2, (u8 *) (daycare_data + 1) + 0x88, 0x38); + *((u32 *)(daycare_data) + 68) = *((u32 *)(daycare_data) + 69); + *((u32 *)(daycare_data) + 69) = second_species; + sub_80417F4((u8 *) (daycare_data + 1) + 0x88); + } +} + +u8 TryIncrementMonLevel(struct Pokemon *); +extern u16 word_2024E82; + +void sub_804151C(struct Pokemon * mon) +{ + s32 i; + u8 r6; + u16 temp; + + for(i = 0; i < 100; i++){ + if(TryIncrementMonLevel(mon) == FALSE) goto end; + + r6 = 1; + while((temp = sub_803B7C8(mon, r6)) != 0){ + r6 = 0; + if(temp == 0xffff){ + DeleteFirstMoveAndGiveMoveToMon(mon, word_2024E82); + } + } + } + + end: + + CalculateMonStats(mon); +} + +__attribute__((naked)) +u16 sub_8041570(struct BoxPokemon * daycare_data, u8 a2){ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r9\n\ + mov r6, r8\n\ + push {r6,r7}\n\ + sub sp, 0x68\n\ + adds r5, r0, 0\n\ + lsls r1, 24\n\ + lsrs r4, r1, 24\n\ + lsls r7, r4, 2\n\ + adds r0, r7, r4\n\ + lsls r0, 4\n\ + adds r6, r5, r0\n\ + ldr r1, _08041640 @ =gStringVar1\n\ + adds r0, r6, 0\n\ + bl GetBoxMonNick\n\ + adds r0, r6, 0\n\ + movs r1, 0xB\n\ + bl GetBoxMonData\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r9, r0\n\ + adds r0, r6, 0\n\ + mov r1, sp\n\ + bl sub_803B4B4\n\ + mov r0, sp\n\ + movs r1, 0x38\n\ + bl GetMonData\n\ + cmp r0, 0x64\n\ + beq _080415D8\n\ + mov r0, sp\n\ + movs r1, 0x19\n\ + bl GetMonData\n\ + movs r2, 0x88\n\ + lsls r2, 1\n\ + adds r1, r5, r2\n\ + adds r1, r7\n\ + ldr r1, [r1]\n\ + adds r0, r1\n\ + str r0, [sp, 0x64]\n\ + add r2, sp, 0x64\n\ + mov r0, sp\n\ + movs r1, 0x19\n\ + bl SetMonData\n\ + mov r0, sp\n\ + bl sub_804151C\n\ +_080415D8:\n\ + ldr r0, _08041644 @ =gPlayerParty\n\ + movs r1, 0xFA\n\ + lsls r1, 1\n\ + adds r1, r0\n\ + mov r8, r1\n\ + mov r0, r8\n\ + mov r1, sp\n\ + movs r2, 0x64\n\ + bl memcpy\n\ + lsls r0, r4, 3\n\ + subs r0, r4\n\ + lsls r1, r0, 3\n\ + adds r0, r5, r1\n\ + adds r0, 0xC0\n\ + ldrh r0, [r0]\n\ + cmp r0, 0\n\ + beq _08041610\n\ + adds r4, r1, 0\n\ + adds r4, 0xA0\n\ + adds r4, r5, r4\n\ + mov r0, r8\n\ + adds r1, r4, 0\n\ + bl GiveMailToMon2\n\ + adds r0, r4, 0\n\ + bl sub_80417F4\n\ +_08041610:\n\ + bl party_compaction\n\ + adds r0, r6, 0\n\ + bl ZeroBoxMonData\n\ + movs r2, 0x88\n\ + lsls r2, 1\n\ + adds r0, r5, r2\n\ + adds r0, r7\n\ + movs r1, 0\n\ + str r1, [r0]\n\ + adds r0, r5, 0\n\ + bl sub_80414C0\n\ + bl CalculatePlayerPartyCount\n\ + mov r0, r9\n\ + add sp, 0x68\n\ + pop {r3,r4}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ +_08041640: .4byte gStringVar1\n\ +_08041644: .4byte gPlayerParty\n\ + .syntax divided"); +} + +extern u8 gSpecialVar_0x8004; + +u16 sub_8041648() +{ + return sub_8041570(gSaveBlock1.daycareData, gSpecialVar_0x8004); +} + +u8 Daycare_GetLevelAfterSteps(struct BoxPokemon * mon, u32 steps){ + struct BoxPokemon temp = *mon; + u32 new_exp = GetBoxMonData(mon, MON_DATA_EXP) + steps; + SetBoxMonData(&temp, MON_DATA_EXP, (u8 *) &new_exp); + return GetLevelFromBoxMonExp(&temp); +} diff --git a/src/de_rom_8040FE0.c b/src/de_rom_8040FE0.c new file mode 100644 index 000000000..c618ebdb2 --- /dev/null +++ b/src/de_rom_8040FE0.c @@ -0,0 +1,272 @@ +#include "global.h" +#include "battle.h" + +#if GERMAN + +enum { + TRAINER_CLASS_NAME_LEADER = 25, + TRAINER_CLASS_NAME_SCHOOL_KID = 26, + TRAINER_CLASS_NAME_EXPERT = 30, + TRAINER_CLASS_NAME_POKEMON_TRAINER_3 = 46, +}; + +enum { + TRAINER_CLASS_LEADER_F = 26, + TRAINER_CLASS_ELITE_FOUR_F = 25, + TRAINER_CLASS_SCHOOL_KID_F = 30, + TRAINER_CLASS_BIRD_KEEPER = 46, + TRAINER_CLASS_MAY_1 = 61, + TRAINER_CLASS_MAY_2 = 62, + TRAINER_CLASS_MAY_3 = 63, +}; + +extern struct SecretBaseRecord gSecretBaseRecord; + +extern u8 gTrainerClassNames[][13]; +extern struct Trainer gTrainers[]; + +u8 *de_sub_8040FE0(u8 gender) { + if (gender) + { + gender++; + + } + + gender = TRAINER_CLASS_NAME_SCHOOL_KID; + return gTrainerClassNames[gender]; +} + +u8 *de_sub_8040FF4(u8 gender) { + if (gender) { + gender++; + } + + gender = TRAINER_CLASS_NAME_POKEMON_TRAINER_3; + return gTrainerClassNames[gender]; +} + +u8 *de_sub_804100C(u8 gender) { + if (gender) { + gender++; + } + + gender = TRAINER_CLASS_NAME_LEADER; + return gTrainerClassNames[gender]; +} + +#ifdef NONMATCHING + +u8 de_sub_81364AC(void); +u8 get_trainer_class_name_index(void); +u8 de_sub_81364F8(void); +u8 sub_8135FD8(void); + +u8 *de_sub_8041024(s32 arg0, u32 arg1) { + u8 nameIndex, trainerClass, gender; + struct Trainer *trainer; + u8 local2; + + switch (arg0) + { + case 0x400: + nameIndex = GetSecretBaseTrainerNameIndex(); + gender = gSecretBaseRecord.gender; + if (nameIndex == TRAINER_CLASS_NAME_SCHOOL_KID) + { + return de_sub_8040FE0(gender); + } + + return gTrainerClassNames[nameIndex]; + + case 0x100: + trainerClass = de_sub_81364AC(); + nameIndex = get_trainer_class_name_index(); + if (trainerClass == TRAINER_CLASS_SCHOOL_KID_F) + { + return de_sub_8040FE0(FEMALE); + } + if (trainerClass == TRAINER_CLASS_MAY_1 || trainerClass == TRAINER_CLASS_MAY_2 || trainerClass == TRAINER_CLASS_MAY_3) + { + return de_sub_8040FF4(FEMALE); + } + + return gTrainerClassNames[nameIndex]; + + case 0x800: + trainerClass = de_sub_81364F8(); + nameIndex = sub_8135FD8(); + if (trainerClass == TRAINER_CLASS_SCHOOL_KID_F) + { + return de_sub_8040FE0(FEMALE); + } + if (trainerClass == TRAINER_CLASS_MAY_1 || trainerClass == TRAINER_CLASS_MAY_2 || trainerClass == TRAINER_CLASS_MAY_3) + { + return de_sub_8040FF4(FEMALE); + } + + return gTrainerClassNames[nameIndex]; + + default: + trainer = &gTrainers[arg1]; + trainerClass = trainer->trainerClass; + local2 = sub_803FC58(arg1); + + if (trainerClass == TRAINER_CLASS_LEADER_F) + { + return de_sub_8040FE0(local2); + } + + if (trainerClass == TRAINER_CLASS_BIRD_KEEPER && local2 == FEMALE) + { + return de_sub_8040FF4(FEMALE); + } + + if (trainerClass == TRAINER_CLASS_ELITE_FOUR_F) + { + if (gTrainers[arg1].doubleBattle == TRUE) + { + return de_sub_804100C(FEMALE); + } + else + { + return de_sub_804100C(MALE); + } + } + + + return gTrainerClassNames[trainerClass]; + } +} +#else + +__attribute__((naked)) +void de_sub_8041024(void) { + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + adds r2, r0, 0\n\ + adds r6, r1, 0\n\ + movs r0, 0x80\n\ + lsls r0, 3\n\ + cmp r2, r0\n\ + beq _0804104A\n\ + cmp r2, r0\n\ + bgt _08041040\n\ + movs r0, 0x80\n\ + lsls r0, 1\n\ + cmp r2, r0\n\ + beq _08041064\n\ + b _0804109C\n\ +_08041040:\n\ + movs r0, 0x80\n\ + lsls r0, 4\n\ + cmp r2, r0\n\ + beq _08041086\n\ + b _0804109C\n\ +_0804104A:\n\ + bl GetSecretBaseTrainerNameIndex\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + ldr r0, _08041060 @ =0x02017000\n\ + ldrb r0, [r0, 0x1]\n\ + lsls r0, 27\n\ + lsrs r2, r0, 31\n\ + cmp r5, 0x1A\n\ + beq _080410B8\n\ + b _080410F8\n\ + .align 2, 0\n\ +_08041060: .4byte 0x02017000\n\ +_08041064:\n\ + bl de_sub_81364AC\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + bl get_trainer_class_name_index\n\ +_08041070:\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + cmp r4, 0x1E\n\ + beq _08041094\n\ + adds r0, r4, 0\n\ + subs r0, 0x3D\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x2\n\ + bls _080410CC\n\ + b _080410F8\n\ +_08041086:\n\ + bl de_sub_81364F8\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + bl sub_8135FD8\n\ + b _08041070\n\ +_08041094:\n\ + movs r0, 0x1\n\ + bl de_sub_8040FE0\n\ + b _08041102\n\ +_0804109C:\n\ + ldr r1, _080410C0 @ =gTrainers\n\ + lsls r4, r6, 2\n\ + adds r0, r4, r6\n\ + lsls r0, 3\n\ + adds r0, r1\n\ + ldrb r5, [r0, 0x1]\n\ + lsls r0, r6, 16\n\ + lsrs r0, 16\n\ + bl sub_803FC58\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + cmp r5, 0x1A\n\ + bne _080410C4\n\ +_080410B8:\n\ + adds r0, r2, 0\n\ + bl de_sub_8040FE0\n\ + b _08041102\n\ + .align 2, 0\n\ +_080410C0: .4byte gTrainers\n\ +_080410C4:\n\ + cmp r5, 0x2E\n\ + bne _080410D4\n\ + cmp r2, 0x1\n\ + bne _080410D4\n\ +_080410CC:\n\ + movs r0, 0x1\n\ + bl de_sub_8040FF4\n\ + b _08041102\n\ +_080410D4:\n\ + cmp r5, 0x19\n\ + bne _080410F8\n\ + ldr r0, _080410F4 @ =gTrainers\n\ + adds r1, r4, r6\n\ + lsls r1, 3\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x18]\n\ + movs r2, 0\n\ + cmp r0, 0x1\n\ + bne _080410EA\n\ + movs r2, 0x1\n\ +_080410EA:\n\ + adds r0, r2, 0\n\ + bl de_sub_804100C\n\ + b _08041102\n\ + .align 2, 0\n\ +_080410F4: .4byte gTrainers\n\ +_080410F8:\n\ + movs r0, 0xD\n\ + adds r1, r5, 0\n\ + muls r1, r0\n\ + ldr r0, _08041108 @ =gTrainerClassNames\n\ + adds r0, r1, r0\n\ +_08041102:\n\ + pop {r4-r6}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ +_08041108: .4byte gTrainerClassNames\n\ + .syntax divided\n"); +} +#endif + +u32 de_sub_804110C(u32 arg0, u32 arg1) { + return arg1; +} + +#endif diff --git a/src/decompress.c b/src/decompress.c index ebfd78ffb..d7f7087a7 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -1,14 +1,11 @@ #include "global.h" #include "decompress.h" +#include "data2.h" #include "species.h" -#include "asm.h" +#include "text.h" #define WRAM 0x02000000 -extern struct SpriteSheet gMonFrontPicTable[]; -extern struct SpriteSheet gMonBackPicTable[]; -extern void *gUnknown_081FAF4C[]; - void sub_800D238(const void *src, void *dest) { LZ77UnCompWram(src, dest); @@ -19,92 +16,94 @@ void LZDecompressVram(const void *src, void *dest) LZ77UnCompVram(src, dest); } -void LoadCompressedObjectPic(const struct SpriteSheet *a) +void LoadCompressedObjectPic(const struct CompressedSpriteSheet *src) { - struct SpriteSheet spriteSheet; - - LZ77UnCompWram(a->data, (void *)WRAM); - spriteSheet.data = (void *)WRAM; - spriteSheet.size = a->size; - spriteSheet.tag = a->tag; - LoadSpriteSheet(&spriteSheet); + struct SpriteSheet dest; + + LZ77UnCompWram(src->data, (void *)WRAM); + dest.data = (void *)WRAM; + dest.size = src->size; + dest.tag = src->tag; + LoadSpriteSheet(&dest); } -void LoadCompressedObjectPicOverrideBuffer(const struct SpriteSheet *a, void *buffer) +void LoadCompressedObjectPicOverrideBuffer(const struct CompressedSpriteSheet *src, void *buffer) { - struct SpriteSheet spriteSheet; - - LZ77UnCompWram(a->data, buffer); - spriteSheet.data = buffer; - spriteSheet.size = a->size; - spriteSheet.tag = a->tag; - LoadSpriteSheet(&spriteSheet); + struct SpriteSheet dest; + + LZ77UnCompWram(src->data, buffer); + dest.data = buffer; + dest.size = src->size; + dest.tag = src->tag; + LoadSpriteSheet(&dest); } -void LoadCompressedObjectPalette(const struct SpritePalette *a) +void LoadCompressedObjectPalette(const struct CompressedSpritePalette *src) { - struct SpritePalette spritePalette; - - LZ77UnCompWram(a->data, (void *)WRAM); - spritePalette.data = (void *)WRAM; - spritePalette.tag = a->tag; - LoadSpritePalette(&spritePalette); + struct SpritePalette dest; + + LZ77UnCompWram(src->data, (void *)WRAM); + dest.data = (void *)WRAM; + dest.tag = src->tag; + LoadSpritePalette(&dest); } -void LoadCompressedObjectPaletteOverrideBuffer(const struct SpritePalette *a, void *buffer) +void LoadCompressedObjectPaletteOverrideBuffer(const struct CompressedSpritePalette *a, void *buffer) { - struct SpritePalette spritePalette; - + struct SpritePalette dest; + LZ77UnCompWram(a->data, buffer); - spritePalette.data = buffer; - spritePalette.tag = a->tag; - LoadSpritePalette(&spritePalette); + dest.data = buffer; + dest.tag = a->tag; + LoadSpritePalette(&dest); } -void DecompressPicFromTable_2(const struct SpriteSheet *a, u8 b, u8 c, void *d, void *e, s32 f) +void DecompressPicFromTable_2(const struct CompressedSpriteSheet *src, u8 b, u8 c, void *d, void *buffer, s32 species) { - if (f > 412) - LZ77UnCompWram(gMonFrontPicTable[0].data, e); + if (species > SPECIES_EGG) + LZ77UnCompWram(gMonFrontPicTable[0].data, buffer); else - LZ77UnCompWram(a->data, e); + LZ77UnCompWram(src->data, buffer); } -void sub_800D334(const struct SpriteSheet *a, u32 b, u32 c, u32 d, void *dest, s32 f, u32 g) +void HandleLoadSpecialPokePic(const struct CompressedSpriteSheet *src, u32 b, u32 c, u32 d, void *dest, s32 species, u32 g) { - u32 unk; - + u32 frontOrBack; + + // gUnknown_081FAF4C appears to be a list of pointers to locations to store poke pics for back and front pic here. the first and third pointers are used for back while the others are used for front. if (dest == gUnknown_081FAF4C[0] || dest == gUnknown_081FAF4C[2]) - unk = 0; + frontOrBack = 0; // backPic else - unk = 1; - sub_800D378(a, b, c, d, dest, f, g, unk); + frontOrBack = 1; // frontPic + + LoadSpecialPokePic(src, b, c, d, dest, species, g, frontOrBack); } -void sub_800D378(const struct SpriteSheet *a, u32 b, u32 c, u32 d, void *dest, s32 f, u32 g, u32 h) +void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, u32 b, u32 c, u32 d, void *dest, s32 species, u32 g, u32 frontOrBack) { - u8 r7 = h; - - if (f == SPECIES_UNOWN) + u8 frontOrBack8 = frontOrBack; + + if (species == SPECIES_UNOWN) { - u16 r1 = (((g & 0x3000000) >> 18) | ((g & 0x30000) >> 12) | ((g & 0x300) >> 6) | (g & 3)) % 0x1C; - - if (r1 == 0) - r1 = SPECIES_UNOWN; + u16 i = (((g & 0x3000000) >> 18) | ((g & 0x30000) >> 12) | ((g & 0x300) >> 6) | (g & 3)) % 0x1C; + + // The other Unowns are separate from Unown A. + if (i == 0) + i = SPECIES_UNOWN; else - r1 += 412; - if (r7 == 0) - LZ77UnCompWram(gMonBackPicTable[r1].data, dest); + i += SPECIES_UNOWN_B - 1; + + if (frontOrBack8 == 0) + LZ77UnCompWram(gMonBackPicTable[i].data, dest); else - LZ77UnCompWram(gMonFrontPicTable[r1].data, dest); + LZ77UnCompWram(gMonFrontPicTable[i].data, dest); } + else if (species > SPECIES_EGG) // is species unknown? draw the ? icon + LZ77UnCompWram(gMonFrontPicTable[0].data, dest); else - { - if (f > 412) - LZ77UnCompWram(gMonFrontPicTable[0].data, dest); - else - LZ77UnCompWram(a->data, dest); - } - DrawSpindaSpots(f, g, dest, r7); + LZ77UnCompWram(src->data, dest); + + DrawSpindaSpots(species, g, dest, frontOrBack8); } void Unused_LZDecompressWramIndirect(const void **src, void *dest) diff --git a/src/decoration.c b/src/decoration.c new file mode 100644 index 000000000..9eba54ad7 --- /dev/null +++ b/src/decoration.c @@ -0,0 +1,4259 @@ +#include "global.h" +#include "main.h" +#include "map_object_constants.h" +#include "rom4.h" +#include "sound.h" +#include "songs.h" +#include "string_util.h" +#include "menu.h" +#include "menu_helpers.h" +#include "strings.h" +#include "script.h" +#include "palette.h" +#include "field_player_avatar.h" +#include "field_camera.h" +#include "field_fadetransition.h" +#include "fieldmap.h" +#include "metatile_behavior.h" +#include "event_data.h" +#include "field_weather.h" +#include "decoration.h" + +#if ENGLISH +const u8 DecorDesc_SMALL_DESK[] = _( + "A small desk built\n" + "for one."); + +const u8 DecorDesc_POKEMON_DESK[] = _( + "A small desk built in\n" + "the shape of a POKé\n" + "BALL."); + +const u8 DecorDesc_HEAVY_DESK[] = _( + "A large desk made\n" + "of steel. Put some\n" + "decorations on it."); + +const u8 DecorDesc_RAGGED_DESK[] = _( + "A large desk made\n" + "of wood. Put some\n" + "decorations on it."); + +const u8 DecorDesc_COMFORT_DESK[] = _( + "A large desk made\n" + "of leaves. Put some\n" + "decorations on it."); + +const u8 DecorDesc_PRETTY_DESK[] = _( + "A huge desk made\n" + "of glass. Holds lots\n" + "of decorations."); + +const u8 DecorDesc_BRICK_DESK[] = _( + "A huge desk made\n" + "of brick. Holds lots\n" + "of decorations."); + +const u8 DecorDesc_CAMP_DESK[] = _( + "A huge desk made\n" + "of logs. Put lots of\n" + "decorations on it."); + +const u8 DecorDesc_HARD_DESK[] = _( + "A huge desk made\n" + "of rocks. Holds\n" + "many decorations."); + +const u8 DecorDesc_SMALL_CHAIR[] = _( + "A small chair made\n" + "for one."); + +const u8 DecorDesc_POKEMON_CHAIR[] = _( + "A small chair built\n" + "in the shape of a\n" + "POKé BALL."); + +const u8 DecorDesc_HEAVY_CHAIR[] = _( + "A small chair made\n" + "of steel."); + +const u8 DecorDesc_PRETTY_CHAIR[] = _( + "A small chair made\n" + "of glass."); + +const u8 DecorDesc_COMFORT_CHAIR[] = _( + "A small chair made\n" + "of leaves."); + +const u8 DecorDesc_RAGGED_CHAIR[] = _( + "A small chair made\n" + "of wood."); + +const u8 DecorDesc_BRICK_CHAIR[] = _( + "A small chair made\n" + "of brick."); + +const u8 DecorDesc_CAMP_CHAIR[] = _( + "A small chair made\n" + "of logs."); + +const u8 DecorDesc_HARD_CHAIR[] = _( + "A small chair made\n" + "of rock."); + +const u8 DecorDesc_RED_PLANT[] = _( + "A vivid red potted\n" + "plant."); + +const u8 DecorDesc_TROPICAL_PLANT[] = _( + "A flowering tropical\n" + "plant in a pot."); + +const u8 DecorDesc_PRETTY_FLOWERS[] = _( + "A pot of cute\n" + "flowers."); + +const u8 DecorDesc_COLORFUL_PLANT[] = _( + "A large pot with\n" + "many colorful\n" + "flowers."); + +const u8 DecorDesc_BIG_PLANT[] = _( + "A large, umbrella-\n" + "shaped plant in a\n" + "big pot."); + +const u8 DecorDesc_GORGEOUS_PLANT[] = _( + "A large, impressive\n" + "plant in a big pot."); + +const u8 DecorDesc_RED_BRICK[] = _( + "A red-colored brick.\n" + "Decorations can be\n" + "placed on top."); + +const u8 DecorDesc_YELLOW_BRICK[] = _( + "A yellow-colored\n" + "brick. Put some\n" + "decorations on top."); + +const u8 DecorDesc_BLUE_BRICK[] = _( + "A blue-colored\n" + "brick. Put some\n" + "decorations on top."); + +const u8 DecorDesc_RED_BALLOON[] = _( + "A red balloon filled\n" + "with water. Bursts\n" + "if stepped on."); + +const u8 DecorDesc_BLUE_BALLOON[] = _( + "A blue balloon filled\n" + "with water. Bursts\n" + "if stepped on."); + +const u8 DecorDesc_YELLOW_BALLOON[] = _( + "A yellow balloon\n" + "filled with water.\n" + "Pops if stepped on."); + +const u8 DecorDesc_RED_TENT[] = _( + "A large red tent.\n" + "You can hide inside\n" + "it."); + +const u8 DecorDesc_BLUE_TENT[] = _( + "A large blue tent.\n" + "You can hide inside\n" + "it."); + +const u8 DecorDesc_SOLID_BOARD[] = _( + "Place over a hole to\n" + "cross to the other\n" + "side."); + +const u8 DecorDesc_SLIDE[] = _( + "Use to slide down\n" + "from the platform."); + +const u8 DecorDesc_FENCE_LENGTH[] = _( + "A small fence that\n" + "blocks passage."); + +const u8 DecorDesc_FENCE_WIDTH[] = _( + "A small fence that\n" + "blocks passage."); + +const u8 DecorDesc_TIRE[] = _( + "An old large tire.\n" + "Decorations can be\n" + "placed on top."); + +const u8 DecorDesc_STAND[] = _( + "A large pedestal\n" + "with steps."); + +const u8 DecorDesc_MUD_BALL[] = _( + "A large ball of mud.\n" + "Crumbles if stepped\n" + "on."); + +const u8 DecorDesc_BREAKABLE_DOOR[] = _( + "A weird door that\n" + "people can walk\n" + "right through."); + +const u8 DecorDesc_SAND_ORNAMENT[] = _( + "An ornament made\n" + "of sand. Crumbles if\n" + "touched."); + +const u8 DecorDesc_SILVER_SHIELD[] = _( + "Awarded for 50\n" + "straight wins at\n" + "the BATTLE TOWER."); + +const u8 DecorDesc_GOLD_SHIELD[] = _( + "Awarded for 100\n" + "straight wins at\n" + "the BATTLE TOWER."); + +const u8 DecorDesc_GLASS_ORNAMENT[] = _( + "A glass replica of\n" + "a famous sculpture\n" + "at the ART MUSEUM."); + +const u8 DecorDesc_TV[] = _( + "A small, gray-\n" + "colored toy TV."); + +const u8 DecorDesc_ROUND_TV[] = _( + "A toy TV modeled\n" + "in the image of a\n" + "SEEDOT."); + +const u8 DecorDesc_CUTE_TV[] = _( + "A toy TV modeled\n" + "in the image of a\n" + "SKITTY."); + +const u8 DecorDesc_GLITTER_MAT[] = _( + "An odd mat that\n" + "glitters if stepped\n" + "on."); + +const u8 DecorDesc_JUMP_MAT[] = _( + "A trick mat that\n" + "jumps when it is\n" + "stepped on."); + +const u8 DecorDesc_SPIN_MAT[] = _( + "A trick mat that\n" + "spins around when\n" + "stepped on."); + +const u8 DecorDesc_C_LOW_NOTE_MAT[] = _( + "A mat that plays\n" + "a low C note when\n" + "stepped on."); + +const u8 DecorDesc_D_NOTE_MAT[] = _( + "A mat that plays\n" + "a D note when\n" + "stepped on."); + +const u8 DecorDesc_E_NOTE_MAT[] = _( + "A mat that plays\n" + "an E note when\n" + "stepped on."); + +const u8 DecorDesc_F_NOTE_MAT[] = _( + "A mat that plays\n" + "an F note when\n" + "stepped on."); + +const u8 DecorDesc_G_NOTE_MAT[] = _( + "A mat that plays\n" + "a G note when\n" + "stepped on."); + +const u8 DecorDesc_A_NOTE_MAT[] = _( + "A mat that plays\n" + "an A note when\n" + "stepped on."); + +const u8 DecorDesc_B_NOTE_MAT[] = _( + "A mat that plays\n" + "a B note when\n" + "stepped on."); + +const u8 DecorDesc_C_HIGH_NOTE_MAT[] = _( + "A mat that plays\n" + "a high C note when\n" + "stepped on."); + +const u8 DecorDesc_SURF_MAT[] = _( + "A mat designed with\n" + "a SURF image.\n" + "Put items on top."); + +const u8 DecorDesc_THUNDER_MAT[] = _( + "A mat designed with\n" + "a THUNDER image.\n" + "Put items on top."); + +const u8 DecorDesc_FIRE_BLAST_MAT[] = _( + "A mat designed with\n" + "a FIRE BLAST image.\n" + "Put items on top."); + +const u8 DecorDesc_POWDER_SNOW_MAT[] = _( + "A mat with a POWDER\n" + "SNOW image design.\n" + "Put items on top."); + +const u8 DecorDesc_ATTRACT_MAT[] = _( + "A mat designed with\n" + "an ATTRACT image.\n" + "Put items on top."); + +const u8 DecorDesc_FISSURE_MAT[] = _( + "A mat designed with\n" + "a FISSURE image.\n" + "Put items on top."); + +const u8 DecorDesc_SPIKES_MAT[] = _( + "A mat designed with\n" + "a SPIKES image.\n" + "Put items on top."); + +const u8 DecorDesc_BALL_POSTER[] = _( + "A small poster\n" + "printed with POKé\n" + "BALLS."); + +const u8 DecorDesc_GREEN_POSTER[] = _( + "A small poster with\n" + "a TREECKO print."); + +const u8 DecorDesc_RED_POSTER[] = _( + "A small poster with\n" + "a TORCHIC print."); + +const u8 DecorDesc_BLUE_POSTER[] = _( + "A small poster with\n" + "a MUDKIP print."); + +const u8 DecorDesc_CUTE_POSTER[] = _( + "A small poster with\n" + "an AZURILL print."); + +const u8 DecorDesc_PIKA_POSTER[] = _( + "A large poster with\n" + "a PIKACHU and\n" + "PICHU print."); + +const u8 DecorDesc_LONG_POSTER[] = _( + "A large poster with\n" + "a SEVIPER print."); + +const u8 DecorDesc_SEA_POSTER[] = _( + "A large poster with\n" + "a RELICANTH print."); + +const u8 DecorDesc_SKY_POSTER[] = _( + "A large poster with\n" + "a WINGULL print."); + +const u8 DecorDesc_KISS_POSTER[] = _( + "A large poster with\n" + "a SMOOCHUM print."); + +const u8 DecorDesc_PICHU_DOLL[] = _( + "A PICHU doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_PIKACHU_DOLL[] = _( + "A PIKACHU doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_MARILL_DOLL[] = _( + "A MARILL doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_TOGEPI_DOLL[] = _( +#if REVISION >= 1 + "A TOGEPI doll.\n" +#else + "A TOPGEPI doll.\n" +#endif + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_CYNDAQUIL_DOLL[] = _( + "A CYNDAQUIL doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_CHIKORITA_DOLL[] = _( + "A CHIKORITA doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_TOTODILE_DOLL[] = _( + "A TOTODILE doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_JIGGLYPUFF_DOLL[] = _( + "A JIGGLYPUFF doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_MEOWTH_DOLL[] = _( + "A MEOWTH doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_CLEFAIRY_DOLL[] = _( + "A CLEFAIRY doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_DITTO_DOLL[] = _( + "A DITTO doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_SMOOCHUM_DOLL[] = _( + "A SMOOCHUM doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_TREECKO_DOLL[] = _( + "A TREECKO doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_TORCHIC_DOLL[] = _( + "A TORCHIC doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_MUDKIP_DOLL[] = _( + "A MUDKIP doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_DUSKULL_DOLL[] = _( + "A DUSKULL doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_WYNAUT_DOLL[] = _( + "A WYNAUT doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_BALTOY_DOLL[] = _( + "A BALTOY doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_KECLEON_DOLL[] = _( + "A KECLEON doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_AZURILL_DOLL[] = _( + "An AZURILL doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_SKITTY_DOLL[] = _( + "A SKITTY doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_SWABLU_DOLL[] = _( + "A SWABLU doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_GULPIN_DOLL[] = _( + "A GULPIN doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_LOTAD_DOLL[] = _( + "A LOTAD doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_SEEDOT_DOLL[] = _( + "A SEEDOT doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_PIKA_CUSHION[] = _( + "A PIKACHU cushion.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_ROUND_CUSHION[] = _( + "A MARILL cushion.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_KISS_CUSHION[] = _( + "A SMOOCHUM\n" + "cushion. Place it on\n" + "a mat or a desk."); + +const u8 DecorDesc_ZIGZAG_CUSHION[] = _( + "A ZIGZAGOON\n" + "cushion. Place it on\n" + "a mat or a desk."); + +const u8 DecorDesc_SPIN_CUSHION[] = _( + "A SPINDA cushion.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_DIAMOND_CUSHION[] = _( + "A SABLEYE cushion.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_BALL_CUSHION[] = _( + "A BALL cushion.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_GRASS_CUSHION[] = _( + "A grass-mark\n" + "cushion. Place it on\n" + "a mat or a desk."); + +const u8 DecorDesc_FIRE_CUSHION[] = _( + "A fire-mark\n" + "cushion. Place it on\n" + "a mat or a desk."); + +const u8 DecorDesc_WATER_CUSHION[] = _( + "A water-mark\n" + "cushion. Place it on\n" + "a mat or a desk."); + +const u8 DecorDesc_SNORLAX_DOLL[] = _( + "A large doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_RHYDON_DOLL[] = _( + "A large doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_LAPRAS_DOLL[] = _( + "A large doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_VENUSAUR_DOLL[] = _( + "A large doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_CHARIZARD_DOLL[] = _( + "A large doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_BLASTOISE_DOLL[] = _( + "A large doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_WAILMER_DOLL[] = _( + "A large doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_REGIROCK_DOLL[] = _( + "A large doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_REGICE_DOLL[] = _( + "A large doll.\n" + "Place it on a mat\n" + "or a desk."); + +const u8 DecorDesc_REGISTEEL_DOLL[] = _( + "A large doll.\n" + "Place it on a mat\n" + "or a desk."); +#elif GERMAN +#include "data/decoration/descriptions_de.h" +#endif + +const u16 DecorGfx_SMALL_DESK[] = { + 0x87 +}; + +const u16 DecorGfx_POKEMON_DESK[] = { + 0x8F +}; + +const u16 DecorGfx_HEAVY_DESK[] = { + 0x90, + 0x91, + 0x92, + 0x98, + 0x99, + 0x9A +}; + +const u16 DecorGfx_RAGGED_DESK[] = { + 0x93, + 0x94, + 0x95, + 0x9B, + 0x9C, + 0x9D +}; + +const u16 DecorGfx_COMFORT_DESK[] = { + 0x96, + 0x97, + 0xA3, + 0x9E, + 0x9F, + 0xAB +}; + +const u16 DecorGfx_PRETTY_DESK[] = { + 0xBD, + 0xBE, + 0xBF, + 0xC5, + 0xC6, + 0xC7, + 0xCD, + 0xCE, + 0xCF +}; + +const u16 DecorGfx_BRICK_DESK[] = { + 0xA0, + 0xA1, + 0xA2, + 0xA8, + 0xA9, + 0xAA, + 0xB0, + 0xB1, + 0xB2 +}; + +const u16 DecorGfx_CAMP_DESK[] = { + 0xA4, + 0xA5, + 0xA6, + 0xAC, + 0xAD, + 0xAE, + 0xB4, + 0xB5, + 0xB6 +}; + +const u16 DecorGfx_HARD_DESK[] = { + 0xA7, + 0xBB, + 0xBC, + 0xAF, + 0xC3, + 0xC4, + 0xB7, + 0xCB, + 0xCC +}; + +const u16 DecorGfx_SMALL_CHAIR[] = { + 0xB8 +}; + +const u16 DecorGfx_POKEMON_CHAIR[] = { + 0xB9 +}; + +const u16 DecorGfx_HEAVY_CHAIR[] = { + 0xBA +}; + +const u16 DecorGfx_PRETTY_CHAIR[] = { + 0xC0 +}; + +const u16 DecorGfx_COMFORT_CHAIR[] = { + 0xC1 +}; + +const u16 DecorGfx_RAGGED_CHAIR[] = { + 0xC2 +}; + +const u16 DecorGfx_BRICK_CHAIR[] = { + 0xC8 +}; + +const u16 DecorGfx_CAMP_CHAIR[] = { + 0xC9 +}; + +const u16 DecorGfx_HARD_CHAIR[] = { + 0xCA +}; + +const u16 DecorGfx_RED_PLANT[] = { + 0xD0, + 0xD8 +}; + +const u16 DecorGfx_TROPICAL_PLANT[] = { + 0xD2, + 0xDA +}; + +const u16 DecorGfx_PRETTY_FLOWERS[] = { + 0xD4, + 0xDC +}; + +const u16 DecorGfx_COLORFUL_PLANT[] = { + 0xE0, + 0xE2, + 0xE8, + 0xE9 +}; + +const u16 DecorGfx_BIG_PLANT[] = { + 0xE4, + 0xE6, + 0xEC, + 0xED +}; + +const u16 DecorGfx_GORGEOUS_PLANT[] = { + 0xF0, + 0xF2, + 0xF8, + 0xF9 +}; + +const u16 DecorGfx_RED_BRICK[] = { + 0x25, + 0x2D +}; + +const u16 DecorGfx_YELLOW_BRICK[] = { + 0x26, + 0x2E +}; + +const u16 DecorGfx_BLUE_BRICK[] = { + 0x27, + 0x2F +}; + +const u16 DecorGfx_RED_BALLOON[] = { + 0x138 +}; + +const u16 DecorGfx_BLUE_BALLOON[] = { + 0x13C +}; + +const u16 DecorGfx_YELLOW_BALLOON[] = { + 0x140 +}; + +const u16 DecorGfx_RED_TENT[] = { + 0x30, + 0x31, + 0x32, + 0x38, + 0x39, + 0x3A, + 0x40, + 0x41, + 0x3B +}; + +const u16 DecorGfx_BLUE_TENT[] = { + 0x48, + 0x49, + 0x68, + 0x50, + 0x51, + 0x70, + 0x58, + 0x59, + 0x69 +}; + +const u16 DecorGfx_SOLID_BOARD[] = { + 0x34, + 0x3C +}; + +const u16 DecorGfx_SLIDE[] = { + 0x35, + 0x36, + 0x3D, + 0x3E, + 0x63, + 0x64, + 0x6F, + 0x77 +}; + +const u16 DecorGfx_FENCE_LENGTH[] = { + 0x33 +}; + +const u16 DecorGfx_FENCE_WIDTH[] = { + 0x2C +}; + +const u16 DecorGfx_TIRE[] = { + 0x80, + 0x81, + 0x88, + 0x89 +}; + +const u16 DecorGfx_STAND[] = { + 0x6A, + 0x6B, + 0x6C, + 0x6D, + 0x72, + 0x73, + 0x74, + 0x75 +}; + +const u16 DecorGfx_MUD_BALL[] = { + 0x28 +}; + +const u16 DecorGfx_BREAKABLE_DOOR[] = { + 0x37, + 0x3F +}; + +const u16 DecorGfx_SAND_ORNAMENT[] = { + 0x85, + 0x8D +}; + +const u16 DecorGfx_SILVER_SHIELD[] = { + 0xD6, + 0xDE +}; + +const u16 DecorGfx_GOLD_SHIELD[] = { + 0x12E, + 0x136 +}; + +const u16 DecorGfx_GLASS_ORNAMENT[] = { + 0x82, + 0x8A +}; + +const u16 DecorGfx_TV[] = { + 0xF4 +}; + +const u16 DecorGfx_ROUND_TV[] = { + 0xF5 +}; + +const u16 DecorGfx_CUTE_TV[] = { + 0xF6 +}; + +const u16 DecorGfx_GLITTER_MAT[] = { + 0x60 +}; + +const u16 DecorGfx_JUMP_MAT[] = { + 0x61 +}; + +const u16 DecorGfx_SPIN_MAT[] = { + 0x62 +}; + +const u16 DecorGfx_C_LOW_NOTE_MAT[] = { + 0x78 +}; + +const u16 DecorGfx_D_NOTE_MAT[] = { + 0x79 +}; + +const u16 DecorGfx_E_NOTE_MAT[] = { + 0x7A +}; + +const u16 DecorGfx_F_NOTE_MAT[] = { + 0x7B +}; + +const u16 DecorGfx_G_NOTE_MAT[] = { + 0x7C +}; + +const u16 DecorGfx_A_NOTE_MAT[] = { + 0x7D +}; + +const u16 DecorGfx_B_NOTE_MAT[] = { + 0x7E +}; + +const u16 DecorGfx_C_HIGH_NOTE_MAT[] = { + 0xB3 +}; + +const u16 DecorGfx_SURF_MAT[] = { + 0x42, + 0x43, + 0x44, + 0x4A, + 0x4B, + 0x4C, + 0x52, + 0x53, + 0x54 +}; + +const u16 DecorGfx_THUNDER_MAT[] = { + 0x45, + 0x46, + 0x47, + 0x4D, + 0x4E, + 0x4F, + 0x55, + 0x56, + 0x57 +}; + +const u16 DecorGfx_FIRE_BLAST_MAT[] = { + 0x5A, + 0x5B, + 0x5C, + 0x5D, + 0x5E, + 0x5F, + 0x65, + 0x66, + 0x67 +}; + +const u16 DecorGfx_POWDER_SNOW_MAT[] = { + 0x100, + 0x101, + 0x102, + 0x108, + 0x109, + 0x10A, + 0x110, + 0x111, + 0x112 +}; + +const u16 DecorGfx_ATTRACT_MAT[] = { + 0x103, + 0x104, + 0x105, + 0x10B, + 0x10C, + 0x10D, + 0x113, + 0x114, + 0x115 +}; + +const u16 DecorGfx_FISSURE_MAT[] = { + 0x106, + 0x107, + 0x118, + 0x10E, + 0x10F, + 0x120, + 0x116, + 0x117, + 0x128 +}; + +const u16 DecorGfx_SPIKES_MAT[] = { + 0x119, + 0x11A, + 0x11B, + 0x121, + 0x122, + 0x123, + 0x129, + 0x12A, + 0x12B +}; + +const u16 DecorGfx_BALL_POSTER[] = { + 0x130 +}; + +const u16 DecorGfx_GREEN_POSTER[] = { + 0x131 +}; + +const u16 DecorGfx_RED_POSTER[] = { + 0x132 +}; + +const u16 DecorGfx_BLUE_POSTER[] = { + 0x133 +}; + +const u16 DecorGfx_CUTE_POSTER[] = { + 0x134 +}; + +const u16 DecorGfx_PIKA_POSTER[] = { + 0x11C, + 0x11D +}; + +const u16 DecorGfx_LONG_POSTER[] = { + 0x11E, + 0x11F +}; + +const u16 DecorGfx_SEA_POSTER[] = { + 0x124, + 0x125 +}; + +const u16 DecorGfx_SKY_POSTER[] = { + 0x126, + 0x127 +}; + +const u16 DecorGfx_KISS_POSTER[] = { + 0x12C, + 0x12D +}; + +const u16 DecorGfx_PICHU_DOLL[] = { + MAP_OBJ_GFX_PICHU_DOLL +}; + +const u16 DecorGfx_PIKACHU_DOLL[] = { + MAP_OBJ_GFX_PIKACHU_DOLL +}; + +const u16 DecorGfx_MARILL_DOLL[] = { + MAP_OBJ_GFX_MARILL_DOLL +}; + +const u16 DecorGfx_TOGEPI_DOLL[] = { + MAP_OBJ_GFX_TOGEPI_DOLL +}; + +const u16 DecorGfx_CYNDAQUIL_DOLL[] = { + MAP_OBJ_GFX_CYNDAQUIL_DOLL +}; + +const u16 DecorGfx_CHIKORITA_DOLL[] = { + MAP_OBJ_GFX_CHIKORITA_DOLL +}; + +const u16 DecorGfx_TOTODILE_DOLL[] = { + MAP_OBJ_GFX_TOTODILE_DOLL +}; + +const u16 DecorGfx_JIGGLYPUFF_DOLL[] = { + MAP_OBJ_GFX_JIGGLYPUFF_DOLL +}; + +const u16 DecorGfx_MEOWTH_DOLL[] = { + MAP_OBJ_GFX_MEOWTH_DOLL +}; + +const u16 DecorGfx_CLEFAIRY_DOLL[] = { + MAP_OBJ_GFX_CLEFAIRY_DOLL +}; + +const u16 DecorGfx_DITTO_DOLL[] = { + MAP_OBJ_GFX_DITTO_DOLL +}; + +const u16 DecorGfx_SMOOCHUM_DOLL[] = { + MAP_OBJ_GFX_SMOOCHUM_DOLL +}; + +const u16 DecorGfx_TREECKO_DOLL[] = { + MAP_OBJ_GFX_TREECKO_DOLL +}; + +const u16 DecorGfx_TORCHIC_DOLL[] = { + MAP_OBJ_GFX_TORCHIC_DOLL +}; + +const u16 DecorGfx_MUDKIP_DOLL[] = { + MAP_OBJ_GFX_MUDKIP_DOLL +}; + +const u16 DecorGfx_DUSKULL_DOLL[] = { + MAP_OBJ_GFX_DUSKULL_DOLL +}; + +const u16 DecorGfx_WYNAUT_DOLL[] = { + MAP_OBJ_GFX_WYNAUT_DOLL +}; + +const u16 DecorGfx_BALTOY_DOLL[] = { + MAP_OBJ_GFX_BALTOY_DOLL +}; + +const u16 DecorGfx_KECLEON_DOLL[] = { + MAP_OBJ_GFX_KECLEON_DOLL +}; + +const u16 DecorGfx_AZURILL_DOLL[] = { + MAP_OBJ_GFX_AZURILL_DOLL +}; + +const u16 DecorGfx_SKITTY_DOLL[] = { + MAP_OBJ_GFX_SKITTY_DOLL +}; + +const u16 DecorGfx_SWABLU_DOLL[] = { + MAP_OBJ_GFX_SWABLU_DOLL +}; + +const u16 DecorGfx_GULPIN_DOLL[] = { + MAP_OBJ_GFX_GULPIN_DOLL +}; + +const u16 DecorGfx_LOTAD_DOLL[] = { + MAP_OBJ_GFX_LOTAD_DOLL +}; + +const u16 DecorGfx_SEEDOT_DOLL[] = { + MAP_OBJ_GFX_SEEDOT_DOLL +}; + +const u16 DecorGfx_PIKA_CUSHION[] = { + MAP_OBJ_GFX_PIKA_CUSHION +}; + +const u16 DecorGfx_ROUND_CUSHION[] = { + MAP_OBJ_GFX_ROUND_CUSHION +}; + +const u16 DecorGfx_KISS_CUSHION[] = { + MAP_OBJ_GFX_KISS_CUSHION +}; + +const u16 DecorGfx_ZIGZAG_CUSHION[] = { + MAP_OBJ_GFX_ZIGZAG_CUSHION +}; + +const u16 DecorGfx_SPIN_CUSHION[] = { + MAP_OBJ_GFX_SPIN_CUSHION +}; + +const u16 DecorGfx_DIAMOND_CUSHION[] = { + MAP_OBJ_GFX_DIAMOND_CUSHION +}; + +const u16 DecorGfx_BALL_CUSHION[] = { + MAP_OBJ_GFX_BALL_CUSHION +}; + +const u16 DecorGfx_GRASS_CUSHION[] = { + MAP_OBJ_GFX_GRASS_CUSHION +}; + +const u16 DecorGfx_FIRE_CUSHION[] = { + MAP_OBJ_GFX_FIRE_CUSHION +}; + +const u16 DecorGfx_WATER_CUSHION[] = { + MAP_OBJ_GFX_WATER_CUSHION +}; + +const u16 DecorGfx_SNORLAX_DOLL[] = { + MAP_OBJ_GFX_BIG_SNORLAX_DOLL +}; + +const u16 DecorGfx_RHYDON_DOLL[] = { + MAP_OBJ_GFX_BIG_RHYDON_DOLL +}; + +const u16 DecorGfx_LAPRAS_DOLL[] = { + MAP_OBJ_GFX_BIG_LAPRAS_DOLL +}; + +const u16 DecorGfx_VENUSAUR_DOLL[] = { + MAP_OBJ_GFX_BIG_VENUSAUR_DOLL +}; + +const u16 DecorGfx_CHARIZARD_DOLL[] = { + MAP_OBJ_GFX_BIG_CHARIZARD_DOLL +}; + +const u16 DecorGfx_BLASTOISE_DOLL[] = { + MAP_OBJ_GFX_BIG_BLASTOISE_DOLL +}; + +const u16 DecorGfx_WAILMER_DOLL[] = { + MAP_OBJ_GFX_BIG_WAILMER_DOLL +}; + +const u16 DecorGfx_REGIROCK_DOLL[] = { + MAP_OBJ_GFX_BIG_REGIROCK_DOLL +}; + +const u16 DecorGfx_REGICE_DOLL[] = { + MAP_OBJ_GFX_BIG_REGICE_DOLL +}; + +const u16 DecorGfx_REGISTEEL_DOLL[] = { + MAP_OBJ_GFX_BIG_REGISTEEL_DOLL +}; + +#if ENGLISH +const struct Decoration gDecorations[] = { + {DECOR_NONE, _("SMALL DESK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_1x1, DECORCAT_DESK, 0, DecorDesc_SMALL_DESK, DecorGfx_SMALL_DESK}, + {DECOR_SMALL_DESK, _("SMALL DESK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_1x1, DECORCAT_DESK, 3000, DecorDesc_SMALL_DESK, DecorGfx_SMALL_DESK}, + {DECOR_POKEMON_DESK, _("POKéMON DESK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_1x1, DECORCAT_DESK, 3000, DecorDesc_POKEMON_DESK, DecorGfx_POKEMON_DESK}, + {DECOR_HEAVY_DESK, _("HEAVY DESK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_3x2, DECORCAT_DESK, 6000, DecorDesc_HEAVY_DESK, DecorGfx_HEAVY_DESK}, + {DECOR_RAGGED_DESK, _("RAGGED DESK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_3x2, DECORCAT_DESK, 6000, DecorDesc_RAGGED_DESK, DecorGfx_RAGGED_DESK}, + {DECOR_COMFORT_DESK, _("COMFORT DESK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_3x2, DECORCAT_DESK, 6000, DecorDesc_COMFORT_DESK, DecorGfx_COMFORT_DESK}, + {DECOR_PRETTY_DESK, _("PRETTY DESK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_3x3, DECORCAT_DESK, 9000, DecorDesc_PRETTY_DESK, DecorGfx_PRETTY_DESK}, + {DECOR_BRICK_DESK, _("BRICK DESK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_3x3, DECORCAT_DESK, 9000, DecorDesc_BRICK_DESK, DecorGfx_BRICK_DESK}, + {DECOR_CAMP_DESK, _("CAMP DESK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_3x3, DECORCAT_DESK, 9000, DecorDesc_CAMP_DESK, DecorGfx_CAMP_DESK}, + {DECOR_HARD_DESK, _("HARD DESK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_3x3, DECORCAT_DESK, 9000, DecorDesc_HARD_DESK, DecorGfx_HARD_DESK}, + {DECOR_SMALL_CHAIR, _("SMALL CHAIR"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_CHAIR, 2000, DecorDesc_SMALL_CHAIR, DecorGfx_SMALL_CHAIR}, + {DECOR_POKEMON_CHAIR, _("POKéMON CHAIR"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_CHAIR, 2000, DecorDesc_POKEMON_CHAIR, DecorGfx_POKEMON_CHAIR}, + {DECOR_HEAVY_CHAIR, _("HEAVY CHAIR"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_CHAIR, 2000, DecorDesc_HEAVY_CHAIR, DecorGfx_HEAVY_CHAIR}, + {DECOR_PRETTY_CHAIR, _("PRETTY CHAIR"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_CHAIR, 2000, DecorDesc_PRETTY_CHAIR, DecorGfx_PRETTY_CHAIR}, + {DECOR_COMFORT_CHAIR, _("COMFORT CHAIR"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_CHAIR, 2000, DecorDesc_COMFORT_CHAIR, DecorGfx_COMFORT_CHAIR}, + {DECOR_RAGGED_CHAIR, _("RAGGED CHAIR"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_CHAIR, 2000, DecorDesc_RAGGED_CHAIR, DecorGfx_RAGGED_CHAIR}, + {DECOR_BRICK_CHAIR, _("BRICK CHAIR"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_CHAIR, 2000, DecorDesc_BRICK_CHAIR, DecorGfx_BRICK_CHAIR}, + {DECOR_CAMP_CHAIR, _("CAMP CHAIR"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_CHAIR, 2000, DecorDesc_CAMP_CHAIR, DecorGfx_CAMP_CHAIR}, + {DECOR_HARD_CHAIR, _("HARD CHAIR"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_CHAIR, 2000, DecorDesc_HARD_CHAIR, DecorGfx_HARD_CHAIR}, + {DECOR_RED_PLANT, _("RED PLANT"), DECORPERM_BEHIND_FLOOR, DECORSHAPE_1x2, DECORCAT_PLANT, 3000, DecorDesc_RED_PLANT, DecorGfx_RED_PLANT}, + {DECOR_TROPICAL_PLANT, _("TROPICAL PLANT"), DECORPERM_BEHIND_FLOOR, DECORSHAPE_1x2, DECORCAT_PLANT, 3000, DecorDesc_TROPICAL_PLANT, DecorGfx_TROPICAL_PLANT}, + {DECOR_PRETTY_FLOWERS, _("PRETTY FLOWERS"), DECORPERM_BEHIND_FLOOR, DECORSHAPE_1x2, DECORCAT_PLANT, 3000, DecorDesc_PRETTY_FLOWERS, DecorGfx_PRETTY_FLOWERS}, + {DECOR_COLORFUL_PLANT, _("COLORFUL PLANT"), DECORPERM_BEHIND_FLOOR, DECORSHAPE_2x2, DECORCAT_PLANT, 5000, DecorDesc_COLORFUL_PLANT, DecorGfx_COLORFUL_PLANT}, + {DECOR_BIG_PLANT, _("BIG PLANT"), DECORPERM_BEHIND_FLOOR, DECORSHAPE_2x2, DECORCAT_PLANT, 5000, DecorDesc_BIG_PLANT, DecorGfx_BIG_PLANT}, + {DECOR_GORGEOUS_PLANT, _("GORGEOUS PLANT"), DECORPERM_BEHIND_FLOOR, DECORSHAPE_2x2, DECORCAT_PLANT, 5000, DecorDesc_GORGEOUS_PLANT, DecorGfx_GORGEOUS_PLANT}, + {DECOR_RED_BRICK, _("RED BRICK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_1x2, DECORCAT_ORNAMENT, 500, DecorDesc_RED_BRICK, DecorGfx_RED_BRICK}, + {DECOR_YELLOW_BRICK, _("YELLOW BRICK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_1x2, DECORCAT_ORNAMENT, 500, DecorDesc_YELLOW_BRICK, DecorGfx_YELLOW_BRICK}, + {DECOR_BLUE_BRICK, _("BLUE BRICK"), DECORPERM_SOLID_FLOOR, DECORSHAPE_1x2, DECORCAT_ORNAMENT, 500, DecorDesc_BLUE_BRICK, DecorGfx_BLUE_BRICK}, + {DECOR_RED_BALLOON, _("RED BALLOON"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_ORNAMENT, 500, DecorDesc_RED_BALLOON, DecorGfx_RED_BALLOON}, + {DECOR_BLUE_BALLOON, _("BLUE BALLOON"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_ORNAMENT, 500, DecorDesc_BLUE_BALLOON, DecorGfx_BLUE_BALLOON}, + {DECOR_YELLOW_BALLOON, _("YELLOW BALLOON"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_ORNAMENT, 500, DecorDesc_YELLOW_BALLOON, DecorGfx_YELLOW_BALLOON}, + {DECOR_RED_TENT, _("RED TENT"), DECORPERM_PASS_FLOOR, DECORSHAPE_3x3, DECORCAT_ORNAMENT, 10000, DecorDesc_RED_TENT, DecorGfx_RED_TENT}, + {DECOR_BLUE_TENT, _("BLUE TENT"), DECORPERM_PASS_FLOOR, DECORSHAPE_3x3, DECORCAT_ORNAMENT, 10000, DecorDesc_BLUE_TENT, DecorGfx_BLUE_TENT}, + {DECOR_SOLID_BOARD, _("SOLID BOARD"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x2, DECORCAT_ORNAMENT, 3000, DecorDesc_SOLID_BOARD, DecorGfx_SOLID_BOARD}, + {DECOR_SLIDE, _("SLIDE"), DECORPERM_PASS_FLOOR, DECORSHAPE_2x4, DECORCAT_ORNAMENT, 8000, DecorDesc_SLIDE, DecorGfx_SLIDE}, + {DECOR_FENCE_LENGTH, _("FENCE LENGTH"), DECORPERM_SOLID_FLOOR, DECORSHAPE_1x1, DECORCAT_ORNAMENT, 500, DecorDesc_FENCE_LENGTH, DecorGfx_FENCE_LENGTH}, + {DECOR_FENCE_WIDTH, _("FENCE WIDTH"), DECORPERM_SOLID_FLOOR, DECORSHAPE_1x1, DECORCAT_ORNAMENT, 500, DecorDesc_FENCE_WIDTH, DecorGfx_FENCE_WIDTH}, + {DECOR_TIRE, _("TIRE"), DECORPERM_SOLID_FLOOR, DECORSHAPE_2x2, DECORCAT_ORNAMENT, 800, DecorDesc_TIRE, DecorGfx_TIRE}, + {DECOR_STAND, _("STAND"), DECORPERM_PASS_FLOOR, DECORSHAPE_4x2, DECORCAT_ORNAMENT, 7000, DecorDesc_STAND, DecorGfx_STAND}, + {DECOR_MUD_BALL, _("MUD BALL"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_ORNAMENT, 200, DecorDesc_MUD_BALL, DecorGfx_MUD_BALL}, + {DECOR_BREAKABLE_DOOR, _("BREAKABLE DOOR"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x2, DECORCAT_ORNAMENT, 3000, DecorDesc_BREAKABLE_DOOR, DecorGfx_BREAKABLE_DOOR}, + {DECOR_SAND_ORNAMENT, _("SAND ORNAMENT"), DECORPERM_BEHIND_FLOOR, DECORSHAPE_1x2, DECORCAT_ORNAMENT, 3000, DecorDesc_SAND_ORNAMENT, DecorGfx_SAND_ORNAMENT}, + {DECOR_SILVER_SHIELD, _("SILVER SHIELD"), DECORPERM_BEHIND_FLOOR, DECORSHAPE_1x2, DECORCAT_ORNAMENT, 0, DecorDesc_SILVER_SHIELD, DecorGfx_SILVER_SHIELD}, + {DECOR_GOLD_SHIELD, _("GOLD SHIELD"), DECORPERM_BEHIND_FLOOR, DECORSHAPE_1x2, DECORCAT_ORNAMENT, 0, DecorDesc_GOLD_SHIELD, DecorGfx_GOLD_SHIELD}, + {DECOR_GLASS_ORNAMENT, _("GLASS ORNAMENT"), DECORPERM_BEHIND_FLOOR, DECORSHAPE_1x2, DECORCAT_ORNAMENT, 0, DecorDesc_GLASS_ORNAMENT, DecorGfx_GLASS_ORNAMENT}, + {DECOR_TV, _("TV"), DECORPERM_SOLID_FLOOR, DECORSHAPE_1x1, DECORCAT_ORNAMENT, 3000, DecorDesc_TV, DecorGfx_TV}, + {DECOR_ROUND_TV, _("ROUND TV"), DECORPERM_SOLID_FLOOR, DECORSHAPE_1x1, DECORCAT_ORNAMENT, 4000, DecorDesc_ROUND_TV, DecorGfx_ROUND_TV}, + {DECOR_CUTE_TV, _("CUTE TV"), DECORPERM_SOLID_FLOOR, DECORSHAPE_1x1, DECORCAT_ORNAMENT, 4000, DecorDesc_CUTE_TV, DecorGfx_CUTE_TV}, + {DECOR_GLITTER_MAT, _("GLITTER MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_MAT, 2000, DecorDesc_GLITTER_MAT, DecorGfx_GLITTER_MAT}, + {DECOR_JUMP_MAT, _("JUMP MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_MAT, 2000, DecorDesc_JUMP_MAT, DecorGfx_JUMP_MAT}, + {DECOR_SPIN_MAT, _("SPIN MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_MAT, 2000, DecorDesc_SPIN_MAT, DecorGfx_SPIN_MAT}, + {DECOR_C_LOW_NOTE_MAT, _("C Low NOTE MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_MAT, 500, DecorDesc_C_LOW_NOTE_MAT, DecorGfx_C_LOW_NOTE_MAT}, + {DECOR_D_NOTE_MAT, _("D NOTE MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_MAT, 500, DecorDesc_D_NOTE_MAT, DecorGfx_D_NOTE_MAT}, + {DECOR_E_NOTE_MAT, _("E NOTE MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_MAT, 500, DecorDesc_E_NOTE_MAT, DecorGfx_E_NOTE_MAT}, + {DECOR_F_NOTE_MAT, _("F NOTE MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_MAT, 500, DecorDesc_F_NOTE_MAT, DecorGfx_F_NOTE_MAT}, + {DECOR_G_NOTE_MAT, _("G NOTE MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_MAT, 500, DecorDesc_G_NOTE_MAT, DecorGfx_G_NOTE_MAT}, + {DECOR_A_NOTE_MAT, _("A NOTE MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_MAT, 500, DecorDesc_A_NOTE_MAT, DecorGfx_A_NOTE_MAT}, + {DECOR_B_NOTE_MAT, _("B NOTE MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_MAT, 500, DecorDesc_B_NOTE_MAT, DecorGfx_B_NOTE_MAT}, + {DECOR_C_HIGH_NOTE_MAT, _("C High NOTE MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_1x1, DECORCAT_MAT, 500, DecorDesc_C_HIGH_NOTE_MAT, DecorGfx_C_HIGH_NOTE_MAT}, + {DECOR_SURF_MAT, _("SURF MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_3x3, DECORCAT_MAT, 4000, DecorDesc_SURF_MAT, DecorGfx_SURF_MAT}, + {DECOR_THUNDER_MAT, _("THUNDER MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_3x3, DECORCAT_MAT, 4000, DecorDesc_THUNDER_MAT, DecorGfx_THUNDER_MAT}, + {DECOR_FIRE_BLAST_MAT, _("FIRE BLAST MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_3x3, DECORCAT_MAT, 4000, DecorDesc_FIRE_BLAST_MAT, DecorGfx_FIRE_BLAST_MAT}, + {DECOR_POWDER_SNOW_MAT, _("POWDER SNOW MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_3x3, DECORCAT_MAT, 4000, DecorDesc_POWDER_SNOW_MAT, DecorGfx_POWDER_SNOW_MAT}, + {DECOR_ATTRACT_MAT, _("ATTRACT MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_3x3, DECORCAT_MAT, 4000, DecorDesc_ATTRACT_MAT, DecorGfx_ATTRACT_MAT}, + {DECOR_FISSURE_MAT, _("FISSURE MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_3x3, DECORCAT_MAT, 4000, DecorDesc_FISSURE_MAT, DecorGfx_FISSURE_MAT}, + {DECOR_SPIKES_MAT, _("SPIKES MAT"), DECORPERM_PASS_FLOOR, DECORSHAPE_3x3, DECORCAT_MAT, 4000, DecorDesc_SPIKES_MAT, DecorGfx_SPIKES_MAT}, + {DECOR_BALL_POSTER, _("BALL POSTER"), DECORPERM_NA_WALL, DECORSHAPE_1x1, DECORCAT_POSTER, 1000, DecorDesc_BALL_POSTER, DecorGfx_BALL_POSTER}, + {DECOR_GREEN_POSTER, _("GREEN POSTER"), DECORPERM_NA_WALL, DECORSHAPE_1x1, DECORCAT_POSTER, 1000, DecorDesc_GREEN_POSTER, DecorGfx_GREEN_POSTER}, + {DECOR_RED_POSTER, _("RED POSTER"), DECORPERM_NA_WALL, DECORSHAPE_1x1, DECORCAT_POSTER, 1000, DecorDesc_RED_POSTER, DecorGfx_RED_POSTER}, + {DECOR_BLUE_POSTER, _("BLUE POSTER"), DECORPERM_NA_WALL, DECORSHAPE_1x1, DECORCAT_POSTER, 1000, DecorDesc_BLUE_POSTER, DecorGfx_BLUE_POSTER}, + {DECOR_CUTE_POSTER, _("CUTE POSTER"), DECORPERM_NA_WALL, DECORSHAPE_1x1, DECORCAT_POSTER, 1000, DecorDesc_CUTE_POSTER, DecorGfx_CUTE_POSTER}, + {DECOR_PIKA_POSTER, _("PIKA POSTER"), DECORPERM_NA_WALL, DECORSHAPE_2x1, DECORCAT_POSTER, 1500, DecorDesc_PIKA_POSTER, DecorGfx_PIKA_POSTER}, + {DECOR_LONG_POSTER, _("LONG POSTER"), DECORPERM_NA_WALL, DECORSHAPE_2x1, DECORCAT_POSTER, 1500, DecorDesc_LONG_POSTER, DecorGfx_LONG_POSTER}, + {DECOR_SEA_POSTER, _("SEA POSTER"), DECORPERM_NA_WALL, DECORSHAPE_2x1, DECORCAT_POSTER, 1500, DecorDesc_SEA_POSTER, DecorGfx_SEA_POSTER}, + {DECOR_SKY_POSTER, _("SKY POSTER"), DECORPERM_NA_WALL, DECORSHAPE_2x1, DECORCAT_POSTER, 1500, DecorDesc_SKY_POSTER, DecorGfx_SKY_POSTER}, + {DECOR_KISS_POSTER, _("KISS POSTER"), DECORPERM_NA_WALL, DECORSHAPE_2x1, DECORCAT_POSTER, 1500, DecorDesc_KISS_POSTER, DecorGfx_KISS_POSTER}, + {DECOR_PICHU_DOLL, _("PICHU DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_PICHU_DOLL, DecorGfx_PICHU_DOLL}, + {DECOR_PIKACHU_DOLL, _("PIKACHU DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_PIKACHU_DOLL, DecorGfx_PIKACHU_DOLL}, + {DECOR_MARILL_DOLL, _("MARILL DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_MARILL_DOLL, DecorGfx_MARILL_DOLL}, + {DECOR_TOGEPI_DOLL, _("TOGEPI DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_TOGEPI_DOLL, DecorGfx_TOGEPI_DOLL}, + {DECOR_CYNDAQUIL_DOLL, _("CYNDAQUIL DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_CYNDAQUIL_DOLL, DecorGfx_CYNDAQUIL_DOLL}, + {DECOR_CHIKORITA_DOLL, _("CHIKORITA DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_CHIKORITA_DOLL, DecorGfx_CHIKORITA_DOLL}, + {DECOR_TOTODILE_DOLL, _("TOTODILE DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_TOTODILE_DOLL, DecorGfx_TOTODILE_DOLL}, + {DECOR_JIGGLYPUFF_DOLL, _("JIGGLYPUFF DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_JIGGLYPUFF_DOLL, DecorGfx_JIGGLYPUFF_DOLL}, + {DECOR_MEOWTH_DOLL, _("MEOWTH DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_MEOWTH_DOLL, DecorGfx_MEOWTH_DOLL}, + {DECOR_CLEFAIRY_DOLL, _("CLEFAIRY DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_CLEFAIRY_DOLL, DecorGfx_CLEFAIRY_DOLL}, + {DECOR_DITTO_DOLL, _("DITTO DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_DITTO_DOLL, DecorGfx_DITTO_DOLL}, + {DECOR_SMOOCHUM_DOLL, _("SMOOCHUM DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_SMOOCHUM_DOLL, DecorGfx_SMOOCHUM_DOLL}, + {DECOR_TREECKO_DOLL, _("TREECKO DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_TREECKO_DOLL, DecorGfx_TREECKO_DOLL}, + {DECOR_TORCHIC_DOLL, _("TORCHIC DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_TORCHIC_DOLL, DecorGfx_TORCHIC_DOLL}, + {DECOR_MUDKIP_DOLL, _("MUDKIP DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_MUDKIP_DOLL, DecorGfx_MUDKIP_DOLL}, + {DECOR_DUSKULL_DOLL, _("DUSKULL DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_DUSKULL_DOLL, DecorGfx_DUSKULL_DOLL}, + {DECOR_WYNAUT_DOLL, _("WYNAUT DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_WYNAUT_DOLL, DecorGfx_WYNAUT_DOLL}, + {DECOR_BALTOY_DOLL, _("BALTOY DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_BALTOY_DOLL, DecorGfx_BALTOY_DOLL}, + {DECOR_KECLEON_DOLL, _("KECLEON DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_KECLEON_DOLL, DecorGfx_KECLEON_DOLL}, + {DECOR_AZURILL_DOLL, _("AZURILL DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_AZURILL_DOLL, DecorGfx_AZURILL_DOLL}, + {DECOR_SKITTY_DOLL, _("SKITTY DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_SKITTY_DOLL, DecorGfx_SKITTY_DOLL}, + {DECOR_SWABLU_DOLL, _("SWABLU DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_SWABLU_DOLL, DecorGfx_SWABLU_DOLL}, + {DECOR_GULPIN_DOLL, _("GULPIN DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_GULPIN_DOLL, DecorGfx_GULPIN_DOLL}, + {DECOR_LOTAD_DOLL, _("LOTAD DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_LOTAD_DOLL, DecorGfx_LOTAD_DOLL}, + {DECOR_SEEDOT_DOLL, _("SEEDOT DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_DOLL, 3000, DecorDesc_SEEDOT_DOLL, DecorGfx_SEEDOT_DOLL}, + {DECOR_PIKA_CUSHION, _("PIKA CUSHION"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_CUSHION, 2000, DecorDesc_PIKA_CUSHION, DecorGfx_PIKA_CUSHION}, + {DECOR_ROUND_CUSHION, _("ROUND CUSHION"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_CUSHION, 2000, DecorDesc_ROUND_CUSHION, DecorGfx_ROUND_CUSHION}, + {DECOR_KISS_CUSHION, _("KISS CUSHION"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_CUSHION, 2000, DecorDesc_KISS_CUSHION, DecorGfx_KISS_CUSHION}, + {DECOR_ZIGZAG_CUSHION, _("ZIGZAG CUSHION"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_CUSHION, 2000, DecorDesc_ZIGZAG_CUSHION, DecorGfx_ZIGZAG_CUSHION}, + {DECOR_SPIN_CUSHION, _("SPIN CUSHION"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_CUSHION, 2000, DecorDesc_SPIN_CUSHION, DecorGfx_SPIN_CUSHION}, + {DECOR_DIAMOND_CUSHION, _("DIAMOND CUSHION"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_CUSHION, 2000, DecorDesc_DIAMOND_CUSHION, DecorGfx_DIAMOND_CUSHION}, + {DECOR_BALL_CUSHION, _("BALL CUSHION"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_CUSHION, 2000, DecorDesc_BALL_CUSHION, DecorGfx_BALL_CUSHION}, + {DECOR_GRASS_CUSHION, _("GRASS CUSHION"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_CUSHION, 2000, DecorDesc_GRASS_CUSHION, DecorGfx_GRASS_CUSHION}, + {DECOR_FIRE_CUSHION, _("FIRE CUSHION"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_CUSHION, 2000, DecorDesc_FIRE_CUSHION, DecorGfx_FIRE_CUSHION}, + {DECOR_WATER_CUSHION, _("WATER CUSHION"), DECORPERM_SOLID_MAT, DECORSHAPE_1x1, DECORCAT_CUSHION, 2000, DecorDesc_WATER_CUSHION, DecorGfx_WATER_CUSHION}, + {DECOR_SNORLAX_DOLL, _("SNORLAX DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x2, DECORCAT_DOLL, 10000, DecorDesc_SNORLAX_DOLL, DecorGfx_SNORLAX_DOLL}, + {DECOR_RHYDON_DOLL, _("RHYDON DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x2, DECORCAT_DOLL, 10000, DecorDesc_RHYDON_DOLL, DecorGfx_RHYDON_DOLL}, + {DECOR_LAPRAS_DOLL, _("LAPRAS DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x2, DECORCAT_DOLL, 10000, DecorDesc_LAPRAS_DOLL, DecorGfx_LAPRAS_DOLL}, + {DECOR_VENUSAUR_DOLL, _("VENUSAUR DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x2, DECORCAT_DOLL, 10000, DecorDesc_VENUSAUR_DOLL, DecorGfx_VENUSAUR_DOLL}, + {DECOR_CHARIZARD_DOLL, _("CHARIZARD DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x2, DECORCAT_DOLL, 10000, DecorDesc_CHARIZARD_DOLL, DecorGfx_CHARIZARD_DOLL}, + {DECOR_BLASTOISE_DOLL, _("BLASTOISE DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x2, DECORCAT_DOLL, 10000, DecorDesc_BLASTOISE_DOLL, DecorGfx_BLASTOISE_DOLL}, + {DECOR_WAILMER_DOLL, _("WAILMER DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x2, DECORCAT_DOLL, 10000, DecorDesc_WAILMER_DOLL, DecorGfx_WAILMER_DOLL}, + {DECOR_REGIROCK_DOLL, _("REGIROCK DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x2, DECORCAT_DOLL, 10000, DecorDesc_REGIROCK_DOLL, DecorGfx_REGIROCK_DOLL}, + {DECOR_REGICE_DOLL, _("REGICE DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x2, DECORCAT_DOLL, 10000, DecorDesc_REGICE_DOLL, DecorGfx_REGICE_DOLL}, + {DECOR_REGISTEEL_DOLL, _("REGISTEEL DOLL"), DECORPERM_SOLID_MAT, DECORSHAPE_1x2, DECORCAT_DOLL, 10000, DecorDesc_REGISTEEL_DOLL, DecorGfx_REGISTEEL_DOLL} +}; +#elif GERMAN +#include "data/decoration/decorations.h" +#endif + +const u8 *const gUnknown_083EC5E4[] = { + SecretBaseText_Desk, + SecretBaseText_Chair, + SecretBaseText_Plant, + SecretBaseText_Ornament, + SecretBaseText_Mat, + SecretBaseText_Poster, + SecretBaseText_Doll, + SecretBaseText_Cushion +}; + +const struct MenuAction2 gUnknown_083EC604[] = { + {SecretBaseText_Decorate, sub_80FF160}, + {SecretBaseText_PutAway, sub_8100A0C}, + {SecretBaseText_Toss, sub_8101700}, + {gUnknownText_Exit, gpu_pal_decompress_alloc_tag_and_upload} +}; + +const u8 *const gUnknown_083EC624[] = { + SecretBaseText_PutOutDecor, + SecretBaseText_StoreChosenDecor, + SecretBaseText_ThrowAwayDecor, + gMenuText_GoBackToPrev +}; + +const struct MenuAction3 gUnknown_083EC634[] = { + {sub_80FF5BC, sub_80FF058}, + {sub_81017A0, sub_80FF058}, + {sub_81017A0, sub_80FF058}, + {sub_8109D04, sub_80FF058} +}; + +const u16 gUnknown_083EC654[] = {0x6318, 0x739C, 0x7FFF}; +const u8 gUnknown_083EC65A[] = _("{PALETTE 13}{STR_VAR_1}"); + +const u8 Unknown_3EC660[] = {0, 1, 2, 3}; +const u8 Unknown_3EC664[] = {0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13}; +const u8 Unknown_3EC670[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; +const u8 Unknown_3EC680[] = {0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21}; +const u8 Unknown_3EC68C[] = {0, 1, 2, 3, 4, 5, 6, 7}; +const u8 Unknown_3EC694[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; +const u8 Unknown_3EC6B4[] = {0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 29, 32, 33, 34, 35, 36, 37, 40, 41, 42, 43, 44, 45}; +const u8 Unknown_3EC6D8[] = {0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 29}; + +const u8 Unknown_3EC6F0[] = {0, 0, 0, 0}; +const u8 Unknown_3EC6F4[] = {0, 0, 1, 1, 0, 0, 1, 1}; +const u8 Unknown_3EC6FC[] = {0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2}; +const u8 Unknown_3EC708[] = {0, 0, 1, 1, 2, 2, 3, 3, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 4, 4, 5, 5, 6, 6, 7, 7}; +const u8 Unknown_3EC728[] = {0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3}; +const u8 Unknown_3EC738[] = {0, 0, 0, 0, 1, 1, 1, 1}; +const u8 Unknown_3EC740[] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2}; +const u8 Unknown_3EC74C[] = {0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 5, 5, 6, 6, 7, 7, 6, 6, 7, 7}; +const u8 Unknown_3EC76C[] = {0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 6, 6, 7, 7, 8, 8}; +const u8 Unknown_3EC790[] = {0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 3, 3, 4, 4, 5, 5}; + +const u8 Unknown_3EC7A8[] = {4, 5, 6, 7}; +const u8 Unknown_3EC7AC[] = {4, 5, 4, 5, 6, 7, 6, 7}; +const u8 Unknown_3EC7B4[] = {4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7}; +const u8 Unknown_3EC7C0[] = {4, 5, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 6, 7, 4, 5, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 6, 7}; +const u8 Unknown_3EC7E0[] = {4, 5, 4, 5, 6, 7, 6, 7, 4, 5, 4, 5, 6, 7, 6, 7}; +const u8 Unknown_3EC7F0[] = {4, 5, 6, 7, 4, 5, 6, 7}; +const u8 Unknown_3EC7F8[] = {4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7}; +const u8 Unknown_3EC804[] = {4, 5, 4, 5, 6, 7, 6, 7, 4, 5, 4, 5, 6, 7, 6, 7, 4, 5, 4, 5, 6, 7, 6, 7, 4, 5, 4, 5, 6, 7, 6, 7}; +const u8 Unknown_3EC824[] = {4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7}; +const u8 Unknown_3EC848[] = {4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7}; + +const struct UnkStruct_803EC860 gUnknown_083EC860[] = { + {Unknown_3EC660, Unknown_3EC6F0, Unknown_3EC7A8, 0x4}, + {Unknown_3EC68C, Unknown_3EC6F4, Unknown_3EC7AC, 0x8}, + {Unknown_3EC664, Unknown_3EC6FC, Unknown_3EC7B4, 0xc}, + {Unknown_3EC694, Unknown_3EC708, Unknown_3EC7C0, 0x20}, + {Unknown_3EC670, Unknown_3EC728, Unknown_3EC7E0, 0x10}, + {Unknown_3EC68C, Unknown_3EC738, Unknown_3EC7F0, 0x8}, + {Unknown_3EC680, Unknown_3EC740, Unknown_3EC7F8, 0xc}, + {Unknown_3EC694, Unknown_3EC74C, Unknown_3EC804, 0x20}, + {Unknown_3EC6B4, Unknown_3EC76C, Unknown_3EC824, 0x24}, + {Unknown_3EC6D8, Unknown_3EC790, Unknown_3EC848, 0x18} +}; + +const struct UnkStruct_083EC900 gUnknown_083EC900[] = { + {0, 1, 0x78, 0x4e}, + {1, 2, 0x80, 0x4e}, + {1, 3, 0x90, 0x56}, + {1, 3, 0x90, 0x46}, + {0, 2, 0x80, 0x46}, + {2, 2, 0x78, 0x46}, + {2, 3, 0x80, 0x56}, + {2, 3, 0x80, 0x36}, + {0, 3, 0x90, 0x46}, + {1, 3, 0x90, 0x46} +}; + +const union AnimCmd gSpriteAnim_83EC928[] = { + ANIMCMD_FRAME(.imageValue = 0, .duration = 0), + ANIMCMD_END +}; + +const union AnimCmd *const gSpriteAnimTable_83EC930[] = { + gSpriteAnim_83EC928 +}; + +const struct SpriteFrameImage gSpriteImageTable_83EC934[] = { + {.data = (u8 *)&gUnknown_02038900.image, .size = sizeof gUnknown_02038900.image} +}; + +const struct SpriteTemplate gSpriteTemplate_83EC93C = { + .tileTag = 0xffff, + .paletteTag = 3000, + .oam = &gUnknown_020391AC, + .anims = gSpriteAnimTable_83EC930, + .images = gSpriteImageTable_83EC934, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_81009A8 +}; + +const struct SpritePalette gUnknown_083EC954 = {.data = (u16 *)&gUnknown_02038900.palette, .tag = 3000}; + +const struct YesNoFuncTable gUnknown_083EC95C = {.yesFunc = sub_81000C4, .noFunc = sub_810065C}; +const struct YesNoFuncTable gUnknown_083EC964 = {.yesFunc = sub_810026C, .noFunc = sub_810065C}; +const struct YesNoFuncTable gUnknown_083EC96C[] = { + {.yesFunc = sub_80FFAB0, .noFunc = sub_80FFB08}, + {.yesFunc = sub_8100F88, .noFunc = sub_8100FB4} +}; + +const u8 gUnknown_083EC97C[] = {4, 4, 4, 4, 0, 3, 3, 0}; +const u8 gUnknown_083EC984[] = {4, 4, 4, 4, 0, 4, 3, 0}; + +const u16 gUnknown_083EC98C[] = INCBIN_U16("graphics/unknown/83EC98C.gbapal"); +const u16 Unknown_3EC9AC[] = INCBIN_U16("graphics/unknown/83EC9AC.gbapal"); +const struct YesNoFuncTable gUnknown_083EC9CC = {.yesFunc = sub_810153C, .noFunc = sub_8100EEC}; +const struct YesNoFuncTable gUnknown_083EC9D4 = {.yesFunc = sub_8101590, .noFunc = sub_8100EEC}; +const u32 gSpriteImage_83EC9DC[] = INCBIN_U32("graphics/unknown_sprites/83EC9DC.4bpp"); +const struct SpritePalette gUnknown_083ECA5C = {.data = gUnknown_083EC98C, .tag = 8}; +const struct SpritePalette gUnknown_083ECA64 = {.data = Unknown_3EC9AC, .tag = 8}; +const struct OamData gOamData_83ECA6C = { + .size = 1, .priority = 1 +}; + +const union AnimCmd gSpriteAnim_83ECA74[] = { + ANIMCMD_FRAME(.imageValue = 0, .duration = 0), + ANIMCMD_END +}; + +const union AnimCmd *const gSpriteAnimTable_83ECA7C[] = { + gSpriteAnim_83ECA74 +}; + +const struct SpriteFrameImage gSpriteImageTable_83ECA80[] = { + obj_frame_tiles(gSpriteImage_83EC9DC) +}; + +const struct SpriteTemplate gSpriteTemplate_83ECA88 = { + .tileTag = 0xffff, + .paletteTag = 8, + .oam = &gOamData_83ECA6C, + .anims = gSpriteAnimTable_83ECA7C, + .images = gSpriteImageTable_83ECA80, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_8101698 +}; + +const struct YesNoFuncTable gUnknown_083ECAA0 = {.yesFunc = sub_8101848, .noFunc = sub_80FED3C}; + +u8 *const unref_label_083ECAA8[] = {ewram}; + +// text + +extern u8 gUnknown_0815F399[]; + +void sub_80FE1DC(void) +{ + sub_80FE2B4(); + MenuDrawTextWindow(0, 0, 10, 9); + PrintMenuItems(1, 1, 4, (const struct MenuAction *)gUnknown_083EC604); + InitMenu(0, 1, 1, 4, gUnknown_020388D4, 9); +} + +void sub_80FE220(void) +{ + gUnknown_020388D4 = 0; + ScriptContext2_Enable(); + sub_80FE1DC(); + sub_80FE394(); +} + +void DecorationPC(u8 taskId) +{ + sub_80FE220(); + gTasks[taskId].func = Task_DecorationPCProcessMenuInput; +} + +void Task_SecretBasePC_Decoration(u8 taskId) +{ + DecorationPC(taskId); + ewram_1f000.items = gSaveBlock1.secretBases[0].decorations; + ewram_1f000.pos = gSaveBlock1.secretBases[0].decorationPos; + ewram_1f000.size = sizeof gSaveBlock1.secretBases[0].decorations; + ewram_1f000.isPlayerRoom = 0; +} + +void DoPlayerPCDecoration(u8 taskId) +{ + DecorationPC(taskId); + ewram_1f000.items = gSaveBlock1.playerRoomDecor; + ewram_1f000.pos = gSaveBlock1.playerRoomDecorPos; + ewram_1f000.size = sizeof gSaveBlock1.playerRoomDecor; + ewram_1f000.isPlayerRoom = 1; +} + +void sub_80FE2B4(void) +{ + u16 palettes[3]; + memcpy(palettes, gUnknown_083EC654, sizeof gUnknown_083EC654); + LoadPalette(&palettes[2], 0xdf, 2); + LoadPalette(&palettes[1], 0xd1, 2); + LoadPalette(&palettes[0], 0xd8, 2); +} + +void Task_DecorationPCProcessMenuInput(u8 taskId) +{ + if (!gPaletteFade.active) + { + if (gMain.newKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + gUnknown_020388D4 = MoveMenuCursor(-1); + sub_80FE394(); + } + if (gMain.newKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + gUnknown_020388D4 = MoveMenuCursor(1); + sub_80FE394(); + } + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + gUnknown_083EC604[gUnknown_020388D4].func(taskId); + } else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + gpu_pal_decompress_alloc_tag_and_upload(taskId); + } + } +} + +void sub_80FE394(void) +{ + MenuFillWindowRectWithBlankTile(2, 15, 27, 18); + MenuPrint(gUnknown_083EC624[gUnknown_020388D4], 2, 15); +} + +void gpu_pal_decompress_alloc_tag_and_upload(u8 taskId) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 10, 9); + MenuFillWindowRectWithBlankTile(2, 15, 27, 18); + FreeSpritePaletteByTag(6); + if (ewram_1f000.isPlayerRoom == 0) + { + ScriptContext1_SetupScript(gUnknown_0815F399); + DestroyTask(taskId); + } else + { + ReshowPlayerPC(taskId); + } +} + +void sub_80FE418(u8 taskId) +{ + sub_80FE5AC(taskId); +} + +void sub_80FE428(u8 taskId) +{ + InitMenu(0, 1, 1, 4, gUnknown_020388D4, 9); + sub_80FE394(); + gTasks[taskId].func = Task_DecorationPCProcessMenuInput; +} + +void sub_80FE470(u8 decoCat, u8 left, u8 top, u8 palIdx) // PrintDecorationCategorySelectionMenuString +{ + u8 *strptr; + u8 v0; + v0 = sub_8072CBC(); + // PALETTE {palIdx} + strptr = gStringVar4; + strptr[0] = EXT_CTRL_CODE_BEGIN; + strptr[1] = 5; + strptr[2] = palIdx; + strptr += 3; + strptr = StringCopy(strptr, gUnknown_083EC5E4[decoCat]); + strptr = sub_8072C14(strptr, sub_8134194(decoCat), 0x56, 1); + *strptr++ = 0xba; + strptr = sub_8072C14(strptr, gDecorationInventories[decoCat].size, 0x68, 1); + strptr[0] = EXT_CTRL_CODE_BEGIN; + strptr[1] = 5; + strptr[2] = v0; + strptr[3] = EOS; + MenuPrint(gStringVar4, left, top); +} + +void sub_80FE528(u8 taskId) // PrintDecorationCategorySelectionMenuStrings +{ + u8 decoCat; + MenuDrawTextWindow(0, 0, 14, 19); + for (decoCat=0; decoCat<8; decoCat++) + { + if (ewram_1f000.isPlayerRoom == 1 && gTasks[taskId].data[11] == 0 && decoCat != DECORCAT_DOLL && decoCat != DECORCAT_CUSHION) + { + sub_80FE470(decoCat, 1, 2 * decoCat + 1, 13); // Selectable + } else + { + sub_80FE470(decoCat, 1, 2 * decoCat + 1, 255); // Unselectable + } + } + MenuPrint(gUnknownText_Exit, 1, 17); +} + +void sub_80FE5AC(u8 taskId) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 29, 19); + sub_80FE528(taskId); + InitMenu(0, 1, 1, 9, gUnknown_020388F6, 13); + gTasks[taskId].func = sub_80FE604; +} + +void sub_80FE604(u8 taskId) +{ + if (!gPaletteFade.active) + { + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + } else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + gUnknown_020388F6 = GetMenuCursorPos(); + if (gUnknown_020388F6 != 8) + { + gUnknown_020388D5 = sub_8134194(gUnknown_020388F6); + if (gUnknown_020388D5) + { + sub_8134104(gUnknown_020388F6); + gUnknown_020388D0 = gDecorationInventories[gUnknown_020388F6].items; + sub_80FEF50(taskId); + sub_80F944C(); + sub_80F9480(gUnknown_020388F7, 8); + LoadScrollIndicatorPalette(); + gTasks[taskId].func = sub_80FE868; + } else + { + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 14, 19); + DisplayItemMessageOnField(taskId, gSecretBaseText_NoDecors, sub_80FE418, 0); + } + } else + { + sub_80FE728(taskId); + } + } else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + sub_80FE728(taskId); + } + } +} + +void sub_80FE728(u8 taskId) +{ + if (gTasks[taskId].data[11] != 3) + { + sub_80FE758(taskId); + } else + { + sub_8109DAC(taskId); + } +} + +void sub_80FE758(u8 taskId) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 14, 19); + if (gTasks[taskId].data[11] != 2) + { + sub_80FE1DC(); + MenuDisplayMessageBox(); + sub_80FE394(); + gTasks[taskId].func = Task_DecorationPCProcessMenuInput; + } else + { + sub_80B3068(taskId); + } +} + +void sub_80FE7A8(u8 taskId) +{ + gTasks[taskId].data[11] = 3; + gUnknown_020388F6 = 0; + sub_80FE5AC(taskId); +} + +void sub_80FE7D4(u8 *dest, u8 decClass) +{ + StringCopy(dest, gUnknown_083EC5E4[decClass]); +} + +void sub_80FE7EC(u8 taskId) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 29, 19); + + sub_80FEC94(taskId); + sub_80FECB8(gUnknown_020388F6); + +#if ENGLISH + MenuDrawTextWindow(15, 12, 29, 19); +#elif GERMAN + if ((gUnknown_020388F2 + gUnknown_020388F4) != gUnknown_020388D5) + { + MenuDrawTextWindow(15, 12, 29, 19); + } +#endif + + sub_80FECE0(gUnknown_020388F2 + gUnknown_020388F4); + InitMenu(0, 1, 2, gUnknown_020388F3 + 1, gUnknown_020388F2, 13); +} + +void sub_80FE868(u8 taskId) +{ + sub_80FE7EC(taskId); + gTasks[taskId].func = sub_80FE948; +} + +void sub_80FE894(u8 taskId /*r8*/, s8 cursorVector /*r5*/, s8 bgVector /*r7*/) +{ + int v0 /*r10*/; + u8 v1; + v0 = gUnknown_020388F2 + gUnknown_020388F4 == gUnknown_020388D5; + PlaySE(SE_SELECT); + if (cursorVector != 0) + { + gUnknown_020388F2 = MoveMenuCursor(cursorVector); + } + if (bgVector != 0) + { + v1 = gUnknown_020388F4; + gUnknown_020388F4 = v1 + bgVector; + sub_80FEABC(taskId, 1); + } + if (gUnknown_020388F2 + gUnknown_020388F4 != gUnknown_020388D5) + { + if (v0) + { + MenuDrawTextWindow(15, 12, 29, 19); + } + sub_80FECE0(gUnknown_020388F2 + gUnknown_020388F4); + } else + { + MenuZeroFillWindowRect(15, 12, 29, 19); + } +} + +void sub_80FE948(u8 taskId) +{ + if (!gPaletteFade.active) + { + if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + { + if (gUnknown_020388F2 != 0) + { + sub_80FE894(taskId, -1, 0); + } else if (gUnknown_020388F4 != 0) + { + sub_80FE894(taskId, 0, -1); + } + } + if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + { + if (gUnknown_020388F2 != gUnknown_020388F3) + { + sub_80FE894(taskId, 1, 0); + } else if (gUnknown_020388F4 + gUnknown_020388F2 != gUnknown_020388D5) + { + sub_80FE894(taskId, 0, 1); + } + } + if (gMain.newKeys & A_BUTTON) + { + HandleDestroyMenuCursors(); + PlaySE(SE_SELECT); + gUnknown_020388F5 = gUnknown_020388F2 + gUnknown_020388F4; + if (gUnknown_020388F5 == gUnknown_020388D5) + { + gUnknown_083EC634[gTasks[taskId].data[11]].func2(taskId); + } else + { + gUnknown_083EC634[gTasks[taskId].data[11]].func1(taskId); + } + } else if (gMain.newKeys & B_BUTTON) + { + HandleDestroyMenuCursors(); + PlaySE(SE_SELECT); + gUnknown_083EC634[gTasks[taskId].data[11]].func2(taskId); + } + } +} + +void sub_80FEABC(u8 taskId, u8 dummy1) +{ + u16 i; + u16 j; + u8 ni; + if (gUnknown_020388F4 != 0 || (DestroyVerticalScrollIndicator(0), gUnknown_020388F4 != 0)) + { + CreateVerticalScrollIndicators(0, 0x3c, 0x08); + } + if (gUnknown_020388F4 + 7 == gUnknown_020388D5) + { + DestroyVerticalScrollIndicator(1); + } + if (gUnknown_020388F4 + 7 < gUnknown_020388D5) + { + CreateVerticalScrollIndicators(1, 0x3c, 0x98); + } + for (i=gUnknown_020388F4; i<gUnknown_020388F4+8; i++) + { + ni = 2 * (i - gUnknown_020388F4) + 2; + if (gUnknown_020388F7[i - gUnknown_020388F4]) + { + sub_80F94F8(&gUnknown_020388F7[i - gUnknown_020388F4]); + } + if (i == gUnknown_020388D5) + { + sub_8072A18(gUnknownText_Exit, 0x08, 8 * ni, 0x68, 1); + break; + } + if (gUnknown_020388D0[i]) + { + if (ewram_1f000.isPlayerRoom == 1 && gUnknown_020388F6 != DECORCAT_DOLL && gUnknown_020388F6 != DECORCAT_CUSHION && gTasks[taskId].data[11] == 0) + { + StringCopy(gStringVar1, gDecorations[gUnknown_020388D0[i]].name); + sub_8072A18(gUnknown_083EC65A, 0x08, 8 * ni, 0x68, 1); + } else + { + sub_8072A18(gDecorations[gUnknown_020388D0[i]].name, 0x08, 8 * ni, 0x68, 1); + } + for (j=0; j<16; j++) + { + if (gUnknown_020388D6[j] - 1 == i) + { + sub_80F94A4(4, &gUnknown_020388F7[i - gUnknown_020388F4], 0x6c, (i - gUnknown_020388F4) * 16 + 24); + break; + } + } + for (j=0; j<12; j++) + { + if (gUnknown_020388E6[j] - 1 == i) + { + sub_80F94A4(5, &gUnknown_020388F7[i - gUnknown_020388F4], 0x6c, (i - gUnknown_020388F4) * 16 + 24); + break; + } + } + } + } +} + +void sub_80FEC94(u8 taskId) +{ + MenuDrawTextWindow(0, 0, 14, 19); + sub_80FEABC(taskId, 0); +} + +void sub_80FECB8(u8 decoCat) +{ + MenuDrawTextWindow(15, 0, 29, 3); + sub_80FE470(decoCat, 16, 1, 0xff); +} + +#if ENGLISH +void sub_80FECE0(u8 decoCat) +{ + sub_8072AB0(gDecorations[gUnknown_020388D0[decoCat]].description, 0x80, 0x68, 0x68, 0x30, 0x1); +} +#elif GERMAN +__attribute__((naked)) +void sub_80FECE0(u8 decoCat) +{ + asm(".syntax unified\n\ + push {lr}\n\ + sub sp, 0x8\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + ldr r0, _080FED18 @ =gUnknown_020388D5\n\ + ldrb r0, [r0]\n\ + cmp r2, r0\n\ + beq _080FED24\n\ + ldr r1, _080FED1C @ =gDecorations\n\ + ldr r0, _080FED20 @ =gUnknown_020388D0\n\ + ldr r0, [r0]\n\ + adds r0, r2\n\ + ldrb r0, [r0]\n\ + lsls r0, 5\n\ + adds r1, 0x18\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + movs r1, 0x30\n\ + str r1, [sp]\n\ + movs r1, 0x1\n\ + str r1, [sp, 0x4]\n\ + movs r1, 0x80\n\ + movs r2, 0x68\n\ + movs r3, 0x68\n\ + bl sub_8072AB0\n\ + movs r0, 0x1\n\ + b _080FED26\n\ + .align 2, 0\n\ +_080FED18: .4byte gUnknown_020388D5\n\ +_080FED1C: .4byte gDecorations\n\ +_080FED20: .4byte gUnknown_020388D0\n\ +_080FED24:\n\ + movs r0, 0\n\ +_080FED26:\n\ + add sp, 0x8\n\ + pop {r1}\n\ + bx r1\n\ + .syntax divided\n"); +} +#endif + +void sub_80FED1C(void) +{ + MenuZeroFillWindowRect(15, 0, 29, 3); + MenuZeroFillWindowRect(15, 12, 29, 19); +} + +void sub_80FED3C(u8 taskId) +{ + LoadScrollIndicatorPalette(); + gTasks[taskId].func = sub_80FE868; +} + +bool8 sub_80FED64(u8 a0) +{ + u8 i; + for (i=0; i<16; i++) + { + if (gUnknown_020388D6[i] == a0) + { + return TRUE; + } + } + return FALSE; +} + +void sub_80FED90(u8 taskId) +{ + u16 i; + u16 j; + u16 k; + u16 cnt; + cnt = 0; + for (i=0; i<16; i++) + { + gUnknown_020388D6[i] = 0; + if (i < 12) + { + gUnknown_020388E6[i] = 0; + } + } + for (i=0; i<16; i++) + { + if (gSaveBlock1.secretBases[0].decorations[i] != 0) + { + for (j=0; j<gDecorationInventories[gUnknown_020388F6].size; j++) + { + if (gUnknown_020388D0[j] == gSaveBlock1.secretBases[0].decorations[i]) + { + for (k=0; k<cnt && gUnknown_020388D6[k]!=j+1; k++); + if (k == cnt) + { + gUnknown_020388D6[cnt] = j+1; + cnt++; + break; + } + } + } + } + } + cnt = 0; + for (i=0; i<12; i++) + { + if (gSaveBlock1.playerRoomDecor[i] != 0) + { + for (j=0; j<gDecorationInventories[gUnknown_020388F6].size; j++) + { + if (gUnknown_020388D0[j] == gSaveBlock1.playerRoomDecor[i] && !sub_80FED64(j + 1)) + { + for (k=0; k<cnt && gUnknown_020388E6[k]!=j+1; k++); + if (k == cnt) + { + gUnknown_020388E6[cnt] = j+1; + cnt++; + break; + } + } + } + } + } +} + +void sub_80FEF28(void) +{ + if (gUnknown_020388D5 <= 7) + { + gUnknown_020388F3 = gUnknown_020388D5; + } else + { + gUnknown_020388F3 = 7; + } +} + +void sub_80FEF50(u8 taskId) +{ + sub_80FED90(taskId); + sub_80FEF28(); + gUnknown_020388F2 = 0; + gUnknown_020388F4 = 0; +} + +void sub_80FEF74(void) +{ + sub_80F9520(gUnknown_020388F7, 8); + DestroyVerticalScrollIndicator(0); + DestroyVerticalScrollIndicator(1); + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 14, 19); +} + +bool8 sub_80FEFA4(void) +{ + u16 i; + int v0; + for (i=0; i<16; i++) + { + v0 = gUnknown_020388F4 + gUnknown_020388F2 + 1; + if (gUnknown_020388D6[i] == v0 || (i < 12 && gUnknown_020388E6[i] == v0)) + { + return FALSE; + } + } + return TRUE; +} + +void sub_80FEFF4(u8 taskId) +{ + if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + { + LoadScrollIndicatorPalette(); + gTasks[taskId].func = sub_80FE868; + } +} + +void sub_80FF034(u8 taskId) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 14, 19); + sub_80FE5AC(taskId); +} + +void sub_80FF058(u8 taskId) +{ + sub_80F9520(gUnknown_020388F7, 8); + DestroyVerticalScrollIndicator(0); + DestroyVerticalScrollIndicator(1); + BuyMenuFreeMemory(); + gTasks[taskId].func = sub_80FF034; +} + +void sub_80FF098(u8 taskId) +{ + gUnknown_020388D5--; + if (gUnknown_020388F4 + 7 > gUnknown_020388D5 && gUnknown_020388F4 != 0) + { + gUnknown_020388F4--; + } + sub_8134104(gUnknown_020388F6); + sub_80FED90(taskId); + sub_80FEF28(); +} + +void sub_80FF0E0(u8 taskId) +{ + gTasks[taskId].data[3] = gSaveBlock1.pos.x; + gTasks[taskId].data[4] = gSaveBlock1.pos.y; + PlayerGetDestCoords(&gTasks[taskId].data[0], &gTasks[taskId].data[1]); +} + +void sub_80FF114(u8 taskId) +{ + DrawWholeMapView(); + warp1_set(gSaveBlock1.location.mapGroup, gSaveBlock1.location.mapNum, -1, gTasks[taskId].data[3], gTasks[taskId].data[4]); + warp_in(); +} +void sub_80FF160(u8 taskId) +{ + if (!sub_81341D4()) + { + DisplayItemMessageOnField(taskId, gSecretBaseText_NoDecors, sub_80FE428, 0); + } else + { + gTasks[taskId].data[11] = 0; + gUnknown_020388F6 = 0; + sub_80FE5AC(taskId); + } +} + +u16 sub_80FF1B0(u8 decoId, u8 a1) +{ + u16 retval; + retval = 0xffff; + + switch (decoId) + { + case DECOR_STAND: + retval = gUnknown_083EC97C[a1] << 12; + return retval; + case DECOR_SLIDE: + retval = gUnknown_083EC984[a1] << 12; + return retval; + default: + return retval; + } +} + +void sub_80FF1EC(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decIdx) +{ + u16 i; + u16 j; // r10 + u16 behavior; + u16 flags; // r8 + u16 v0; + u16 v1; + s16 x; + s16 decBottom; + + for (i=0; i<decHeight; i++) + { + decBottom = mapY - decHeight + 1 + i; + for (j=0; j<decWidth; j++) + { + x = mapX + j; + behavior = GetBehaviorByMetatileId(0x200 + gDecorations[decIdx].tiles[i * decWidth + j]); + if (sub_8057288(behavior) == 1 || (gDecorations[decIdx].permission != DECORPERM_PASS_FLOOR && (behavior >> 12))) + { + flags = 0xc00; + } else + { + flags = 0x000; + } + if (gDecorations[decIdx].permission != DECORPERM_NA_WALL && sub_80572B0(MapGridGetMetatileBehaviorAt(x, decBottom)) == 1) + { + v0 = 1; + } else + { + v0 = 0; + } + v1 = sub_80FF1B0(gDecorations[decIdx].id, i * decWidth + j); + if (v1 != 0xffff) + { + MapGridSetMetatileEntryAt(x, decBottom, (gDecorations[decIdx].tiles[i * decWidth + j] + (0x200 | v0)) | flags | v1); + } else + { + MapGridSetMetatileIdAt(x, decBottom, (gDecorations[decIdx].tiles[i * decWidth + j] + (0x200 | v0)) | flags); + } + } + } +} + +void sub_80FF394(u16 mapX, u16 mapY, u16 decIdx) +{ + switch (gDecorations[decIdx].shape) + { + case DECORSHAPE_1x1: + sub_80FF1EC(mapX, mapY, 1, 1, decIdx); + break; + case DECORSHAPE_2x1: + sub_80FF1EC(mapX, mapY, 2, 1, decIdx); + break; + case DECORSHAPE_3x1: // unused + sub_80FF1EC(mapX, mapY, 3, 1, decIdx); + break; + case DECORSHAPE_4x2: + sub_80FF1EC(mapX, mapY, 4, 2, decIdx); + break; + case DECORSHAPE_2x2: + sub_80FF1EC(mapX, mapY, 2, 2, decIdx); + break; + case DECORSHAPE_1x2: + sub_80FF1EC(mapX, mapY, 1, 2, decIdx); + break; + case DECORSHAPE_1x3: // unused + sub_80FF1EC(mapX, mapY, 1, 3, decIdx); + break; + case DECORSHAPE_2x4: + sub_80FF1EC(mapX, mapY, 2, 4, decIdx); + break; + case DECORSHAPE_3x3: + sub_80FF1EC(mapX, mapY, 3, 3, decIdx); + break; + case DECORSHAPE_3x2: + sub_80FF1EC(mapX, mapY, 3, 2, decIdx); + break; + } +} + +void sub_80FF474(void) +{ + u8 i; + u8 j; + for (i=0; i<14; i++) + { + if (FlagGet(i + 0xae) == 1) + { + FlagReset(i + 0xae); + for (j=0; j<gMapHeader.events->mapObjectCount; j++) + { + if (gMapHeader.events->mapObjects[j].flagId == i + 0xae) + { + break; + } + } + VarSet(0x3f20 + gMapHeader.events->mapObjects[j].graphicsId, gUnknown_02038900.decoration->tiles[0]); + gSpecialVar_0x8005 = gMapHeader.events->mapObjects[j].localId; + gSpecialVar_0x8006 = gUnknown_020391A4; + gSpecialVar_0x8007 = gUnknown_020391A6; + show_sprite(gSpecialVar_0x8005, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup); + sub_805C0F8(gSpecialVar_0x8005, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, gSpecialVar_0x8006, gSpecialVar_0x8007); + sub_805C78C(gSpecialVar_0x8005, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup); + break; + } + } +} + +bool8 sub_80FF58C/*IsThereRoomForMoreDecorations*/(void) +{ + u16 i; + for (i=0; i<ewram_1f000.size; i++) + { + if (ewram_1f000.items[i] == 0) + { + return TRUE; + } + } + return FALSE; +} + +void sub_80FF5BC(u8 taskId) +{ + if (ewram_1f000.isPlayerRoom == 1 && gUnknown_020388F6 != DECORCAT_DOLL && gUnknown_020388F6 != DECORCAT_CUSHION) + { + sub_80FEF74(); + sub_80FED1C(); + DisplayItemMessageOnField(taskId, gSecretBaseText_DecorCantPlace, sub_80FEFF4, 0); + } else if (sub_80FEFA4() == TRUE) + { + if (sub_80FF58C() == TRUE) + { + fade_screen(1, 0); + gTasks[taskId].data[2] = 0; + gTasks[taskId].func = sub_80FF6AC; + } else + { + sub_80FEF74(); + sub_80FED1C(); + ConvertIntToDecimalStringN(gStringVar1, ewram_1f000.size, STR_CONV_MODE_RIGHT_ALIGN, 2); + if (!ewram_1f000.isPlayerRoom) + { + StringExpandPlaceholders(gStringVar4, gSecretBaseText_NoMoreDecor); + } else + { + StringExpandPlaceholders(gStringVar4, gSecretBaseText_NoMoreDecor2); + } + DisplayItemMessageOnField(taskId, gStringVar4, sub_80FEFF4, 0); + } + } else + { + sub_80FEF74(); + sub_80FED1C(); + DisplayItemMessageOnField(taskId, gSecretBaseText_InUseAlready, sub_80FEFF4, 0); + } +} + +void sub_80FF6AC(u8 taskId) +{ + switch (gTasks[taskId].data[2]) + { + case 0: + if (!gPaletteFade.active) + { + sub_80FF0E0(taskId); + DestroyVerticalScrollIndicator(0); + DestroyVerticalScrollIndicator(1); + sub_80F9520(gUnknown_020388F7, 8); + BuyMenuFreeMemory(); + gTasks[taskId].data[2] = 1; + } + break; + case 1: + gPaletteFade.bufferTransferDisabled = 1; + AddDecorationIconObjectFromFieldObject(&gUnknown_02038900, gUnknown_020388D0[gUnknown_020388F5]); + sub_80FF960(taskId); + SetUpPlacingDecorationPlayerAvatar(taskId, &gUnknown_02038900); + pal_fill_black(); + gPaletteFade.bufferTransferDisabled = 0; + gTasks[taskId].data[2] = 2; + break; + case 2: + if (sub_807D770() == 1) + { + gTasks[taskId].data[12] = 0; + sub_810065C(taskId); + } + break; + } +} + +void AddDecorationIconObjectFromFieldObject(struct UnkStruct_02038900 * unk_02038900, u8 decoIdx) +{ + sub_80FEF74(); + sub_80FED1C(); + sub_81006D0(unk_02038900); + unk_02038900->decoration = &gDecorations[decoIdx]; + if (gDecorations[decoIdx].permission != DECORPERM_SOLID_MAT) + { + sub_81008BC(unk_02038900); + sub_8100930(unk_02038900->decoration->shape); + sub_8100874(unk_02038900); + sub_810070C(unk_02038900->palette, ((u16 *)gMapHeader.mapData->secondaryTileset->metatiles + 8 * unk_02038900->decoration->tiles[0])[7] >> 12); + LoadSpritePalette(&gUnknown_083EC954); + gUnknown_020391A8 = gSprites[gUnknown_03004880.unk4].data0; + gUnknown_03004880.unk4 = CreateSprite(&gSpriteTemplate_83EC93C, gUnknown_083EC900[unk_02038900->decoration->shape].x, gUnknown_083EC900[unk_02038900->decoration->shape].y, 0); + } else + { + gUnknown_020391A8 = gSprites[gUnknown_03004880.unk4].data0; + gUnknown_03004880.unk4 = AddPseudoFieldObject(unk_02038900->decoration->tiles[0], sub_81009A8, gUnknown_083EC900[unk_02038900->decoration->shape].x, gUnknown_083EC900[unk_02038900->decoration->shape].y, 1); + gSprites[gUnknown_03004880.unk4].oam.priority = 1; + } +} + +void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct UnkStruct_02038900 *unk_02038900) +{ + u8 v0; + v0 = 16 * (u8)gTasks[taskId].data[5] + gUnknown_083EC900[unk_02038900->decoration->shape].x - 8 * ((u8)gTasks[taskId].data[5] - 1); + if (unk_02038900->decoration->shape == DECORSHAPE_3x1 || unk_02038900->decoration->shape == DECORSHAPE_3x3 || unk_02038900->decoration->shape == DECORSHAPE_3x2) + { + v0 -= 8; + } + if (gSaveBlock2.playerGender == MALE) + { + gUnknown_020391A9 = AddPseudoFieldObject(0xc1, SpriteCallbackDummy, v0, 0x48, 0); + } else + { + gUnknown_020391A9 = AddPseudoFieldObject(0xc2, SpriteCallbackDummy, v0, 0x48, 0); + } + gSprites[gUnknown_020391A9].oam.priority = 1; + DestroySprite(&gSprites[gUnknown_020391A8]); + gUnknown_020391A8 = gUnknown_03004880.unk4; +} + +void sub_80FF960(u8 taskId) +{ + switch (gDecorations[gUnknown_020388D0[gUnknown_020388F5]].shape) + { + case DECORSHAPE_1x1: + gTasks[taskId].data[5] = 1; + gTasks[taskId].data[6] = 1; + break; + case DECORSHAPE_2x1: + gTasks[taskId].data[5] = 2; + gTasks[taskId].data[6] = 1; + break; + case DECORSHAPE_3x1: + gTasks[taskId].data[5] = 3; + gTasks[taskId].data[6] = 1; + break; + case DECORSHAPE_4x2: + gTasks[taskId].data[5] = 4; + gTasks[taskId].data[6] = 2; + break; + case DECORSHAPE_2x2: + gTasks[taskId].data[5] = 2; + gTasks[taskId].data[6] = 2; + break; + case DECORSHAPE_1x2: + gTasks[taskId].data[5] = 1; + gTasks[taskId].data[6] = 2; + break; + case DECORSHAPE_1x3: + gTasks[taskId].data[5] = 1; + gTasks[taskId].data[6] = 3; + gTasks[taskId].data[1]++; + break; + case DECORSHAPE_2x4: + gTasks[taskId].data[5] = 2; + gTasks[taskId].data[6] = 4; + break; + case DECORSHAPE_3x3: + gTasks[taskId].data[5] = 3; + gTasks[taskId].data[6] = 3; + break; + case DECORSHAPE_3x2: + gTasks[taskId].data[5] = 3; + gTasks[taskId].data[6] = 2; + break; + } +} + +void sub_80FFAB0(u8 taskId) +{ + gTasks[taskId].data[10] = 0; + gSprites[gUnknown_020391A8].data7 = 1; + gSprites[gUnknown_020391A9].data7 = 1; + sub_810045C(); + sub_8100038(taskId); +} + +void sub_80FFB08(u8 taskId) +{ + gTasks[taskId].data[10] = 0; + gSprites[gUnknown_020391A8].data7 = 1; + gSprites[gUnknown_020391A9].data7 = 1; + sub_810045C(); + DisplayItemMessageOnField(taskId, gSecretBaseText_CancelDecorating, sub_8100248, 0); +} + +bool8 sub_80FFB6C(u8 a0, u16 a1) +{ + if (sub_8057274(a0) != 1 || a1 != 0) + { + return FALSE; + } + return TRUE; +} + +bool8 sub_80FFB94(u8 taskId, s16 x, s16 y, u16 decoId) +{ + if (x == gTasks[taskId].data[3] + 7 && y == gTasks[taskId].data[4] + 7 && decoId != 0) + { + return FALSE; + } + return TRUE; +} + +bool8 sub_80FFBDC(u16 a0, const struct Decoration *decoration) +{ + if (sub_8057274(a0) != 1) + { + if (decoration->id == DECOR_SOLID_BOARD && sub_8057300(a0) == 1) + { + return TRUE; + } + if (sub_805729C(a0)) + { + return TRUE; + } + } + return FALSE; +} + +// When behaviorBy is set, it is masked by 0xf000. This is the step that fails to match when built. +#ifdef NONMATCHING +bool8 sub_80FFC24(u8 taskId, const struct Decoration *decoration) +{ + u8 i; + u8 j; + u8 behaviorAt; + u16 behaviorBy; + u8 mapY; + u8 mapX; + s16 curY; + s16 curX; + mapY = gTasks[taskId].data[6]; + mapX = gTasks[taskId].data[5]; + switch (decoration->permission) + { + case DECORPERM_SOLID_FLOOR: + case DECORPERM_PASS_FLOOR: + for (i=0; i<mapY; i++) + { + curY = gTasks[taskId].data[1] - i; + for (j=0; j<mapX; j++) + { + curX = gTasks[taskId].data[0] + j; + behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); + behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000; + if (!sub_80FFBDC(behaviorAt, decoration)) + { + return FALSE; + } + if (!sub_80FFB94(taskId, curX, curY, behaviorBy)) + { + return FALSE; + } + behaviorAt = GetFieldObjectIdByXYZ(curX, curY, 0); + if (behaviorAt != 0 && behaviorAt != 16) + { + return FALSE; + } + } + } + break; + case DECORPERM_BEHIND_FLOOR: + for (i=0; i<mapY-1; i++) + { + curY = gTasks[taskId].data[1] - i; + for (j=0; j<mapX; j++) + { + curX = gTasks[taskId].data[0] + j; + behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); + behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000; + if (!sub_805729C(behaviorAt) && !sub_80FFB6C(behaviorAt, behaviorBy)) + { + return FALSE; + } + if (!sub_80FFB94(taskId, curX, curY, behaviorBy)) + { + return FALSE; + } + if (GetFieldObjectIdByXYZ(curX, curY, 0) != 16) + { + return FALSE; + } + } + } + curY = gTasks[taskId].data[1] - mapY + 1; + for (j=0; j<mapX; j++) + { + curX = gTasks[taskId].data[0] + j; + behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); + behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[j]) & 0xf000; + if (!sub_805729C(behaviorAt) && !sub_80572B0(behaviorAt)) + { + return FALSE; + } + if (!sub_80FFB94(taskId, curX, curY, behaviorBy)) + { + return FALSE; + } + behaviorAt = GetFieldObjectIdByXYZ(curX, curY, 0); + if (behaviorAt != 0 && behaviorAt != 16) + { + return FALSE; + } + } + break; + case DECORPERM_NA_WALL: + for (i=0; i<mapY; i++) + { + curY = gTasks[taskId].data[1] - i; + for (j=0; j<mapX; j++) + { + curX = gTasks[taskId].data[0] + j; + if (!sub_80572B0(MapGridGetMetatileBehaviorAt(curX, curY))) + { + return FALSE; + } + if (MapGridGetMetatileIdAt(curX, curY + 1) == 0x28c) + { + return FALSE; + } + } + } + break; + case DECORPERM_SOLID_MAT: + curY = gTasks[taskId].data[1]; + for (j=0; j<mapX; j++) + { + curX = gTasks[taskId].data[0] + j; + behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); + if (decoration->shape == DECORSHAPE_1x2) + { + if (!sub_80572EC(behaviorAt)) + { + return FALSE; + } + } + else if (!sub_80572D8(behaviorAt)) + { + if (!sub_80572EC(behaviorAt)) + { + return FALSE; + } + } + if (GetFieldObjectIdByXYZ(curX, curY, 0) != 16) + { + return FALSE; + } + } + break; + } + return TRUE; +} +#else +__attribute__((naked)) +bool8 sub_80FFC24(u8 taskId, const struct Decoration *decoration) +{ + asm(".syntax unified\n" + "\tpush {r4-r7,lr}\n" + "\tmov r7, r10\n" + "\tmov r6, r9\n" + "\tmov r5, r8\n" + "\tpush {r5-r7}\n" + "\tsub sp, 0x24\n" + "\tstr r1, [sp]\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tmov r10, r0\n" + "\tldr r1, _080FFC60 @ =gTasks\n" + "\tlsls r0, 2\n" + "\tadd r0, r10\n" + "\tlsls r0, 3\n" + "\tadds r0, r1\n" + "\tldrb r2, [r0, 0x14]\n" + "\tstr r2, [sp, 0x4]\n" + "\tldrb r0, [r0, 0x12]\n" + "\tstr r0, [sp, 0x8]\n" + "\tldr r3, [sp]\n" + "\tldrb r0, [r3, 0x11]\n" + "\tadds r2, r1, 0\n" + "\tcmp r0, 0x4\n" + "\tbls _080FFC56\n" + "\tb _08100024\n" + "_080FFC56:\n" + "\tlsls r0, 2\n" + "\tldr r1, _080FFC64 @ =_080FFC68\n" + "\tadds r0, r1\n" + "\tldr r0, [r0]\n" + "\tmov pc, r0\n" + "\t.align 2, 0\n" + "_080FFC60: .4byte gTasks\n" + "_080FFC64: .4byte _080FFC68\n" + "\t.align 2, 0\n" + "_080FFC68:\n" + "\t.4byte _080FFC7C\n" + "\t.4byte _080FFC7C\n" + "\t.4byte _080FFD68\n" + "\t.4byte _080FFF1C\n" + "\t.4byte _080FFFA0\n" + "_080FFC7C:\n" + "\tmovs r6, 0\n" + "\tldr r0, [sp, 0x4]\n" + "\tcmp r6, r0\n" + "\tbcc _080FFC86\n" + "\tb _08100024\n" + "_080FFC86:\n" + "\tmov r1, r10\n" + "\tlsls r1, 2\n" + "\tstr r1, [sp, 0x1C]\n" + "_080FFC8C:\n" + "\tmov r2, r10\n" + "\tlsls r0, r2, 2\n" + "\tadd r0, r10\n" + "\tlsls r0, 3\n" + "\tldr r3, _080FFD64 @ =gTasks\n" + "\tadds r0, r3\n" + "\tldrh r0, [r0, 0xA]\n" + "\tsubs r0, r6\n" + "\tlsls r0, 16\n" + "\tlsrs r0, 16\n" + "\tmov r9, r0\n" + "\tmovs r7, 0\n" + "\tadds r6, 0x1\n" + "\tstr r6, [sp, 0x14]\n" + "\tldr r0, [sp, 0x8]\n" + "\tcmp r7, r0\n" + "\tbcs _080FFD56\n" + "\tmov r1, r9\n" + "\tlsls r1, 16\n" + "\tstr r1, [sp, 0xC]\n" + "\tasrs r1, 16\n" + "\tmov r9, r1\n" + "_080FFCB8:\n" + "\tldr r0, [sp, 0x1C]\n" + "\tadd r0, r10\n" + "\tlsls r0, 3\n" + "\tldr r2, _080FFD64 @ =gTasks\n" + "\tadds r0, r2\n" + "\tldrh r0, [r0, 0x8]\n" + "\tadds r0, r7\n" + "\tlsls r0, 16\n" + "\tmov r8, r0\n" + "\tasrs r6, r0, 16\n" + "\tadds r0, r6, 0\n" + "\tmov r1, r9\n" + "\tbl MapGridGetMetatileBehaviorAt\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tldr r3, [sp, 0x4]\n" + "\tldr r1, [sp, 0x14]\n" + "\tsubs r0, r3, r1\n" + "\tldr r2, [sp, 0x8]\n" + "\tadds r1, r0, 0\n" + "\tmuls r1, r2\n" + "\tadds r1, r7\n" + "\tldr r3, [sp]\n" + "\tldr r0, [r3, 0x1C]\n" + "\tlsls r1, 1\n" + "\tadds r1, r0\n" + "\tmovs r2, 0x80\n" + "\tlsls r2, 2\n" + "\tadds r0, r2, 0\n" + "\tldrh r1, [r1]\n" + "\tadds r0, r1\n" + "\tlsls r0, 16\n" + "\tlsrs r0, 16\n" + "\tbl GetBehaviorByMetatileId\n" + "\tmovs r3, 0xF0\n" + "\tlsls r3, 8\n" + "\tadds r1, r3, 0\n" + "\tadds r5, r1, 0\n" + "\tands r5, r0\n" + "\tadds r0, r4, 0\n" + "\tldr r1, [sp]\n" + "\tbl sub_80FFBDC\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbne _080FFD1A\n" + "\tb _080FFFF4\n" + "_080FFD1A:\n" + "\tmov r0, r10\n" + "\tadds r1, r6, 0\n" + "\tmov r2, r9\n" + "\tadds r3, r5, 0\n" + "\tbl sub_80FFB94\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbne _080FFD2E\n" + "\tb _080FFFF4\n" + "_080FFD2E:\n" + "\tmov r1, r8\n" + "\tlsrs r0, r1, 16\n" + "\tldr r2, [sp, 0xC]\n" + "\tlsrs r1, r2, 16\n" + "\tmovs r2, 0\n" + "\tbl GetFieldObjectIdByXYZ\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tcmp r4, 0\n" + "\tbeq _080FFD4A\n" + "\tcmp r4, 0x10\n" + "\tbeq _080FFD4A\n" + "\tb _080FFFF4\n" + "_080FFD4A:\n" + "\tadds r0, r7, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r7, r0, 24\n" + "\tldr r3, [sp, 0x8]\n" + "\tcmp r7, r3\n" + "\tbcc _080FFCB8\n" + "_080FFD56:\n" + "\tldr r1, [sp, 0x14]\n" + "\tlsls r0, r1, 24\n" + "\tlsrs r6, r0, 24\n" + "\tldr r2, [sp, 0x4]\n" + "\tcmp r6, r2\n" + "\tbcc _080FFC8C\n" + "\tb _08100024\n" + "\t.align 2, 0\n" + "_080FFD64: .4byte gTasks\n" + "_080FFD68:\n" + "\tmovs r6, 0\n" + "\tmov r3, r10\n" + "\tlsls r3, 2\n" + "\tstr r3, [sp, 0x1C]\n" + "\tldr r0, [sp, 0x4]\n" + "\tsubs r0, 0x1\n" + "\tstr r0, [sp, 0x18]\n" + "\tcmp r6, r0\n" + "\tbge _080FFE54\n" + "\tadds r0, r3, 0\n" + "\tadd r0, r10\n" + "\tlsls r0, 3\n" + "\tstr r0, [sp, 0x10]\n" + "_080FFD82:\n" + "\tldr r1, [sp, 0x10]\n" + "\tadds r0, r1, r2\n" + "\tldrh r0, [r0, 0xA]\n" + "\tsubs r0, r6\n" + "\tlsls r0, 16\n" + "\tlsrs r0, 16\n" + "\tmov r9, r0\n" + "\tmovs r7, 0\n" + "\tadds r6, 0x1\n" + "\tstr r6, [sp, 0x14]\n" + "\tldr r3, [sp, 0x8]\n" + "\tcmp r7, r3\n" + "\tbcs _080FFE48\n" + "\tlsls r0, 16\n" + "\tstr r0, [sp, 0x20]\n" + "_080FFDA0:\n" + "\tldr r1, [sp, 0x10]\n" + "\tadds r0, r1, r2\n" + "\tldrh r0, [r0, 0x8]\n" + "\tadds r0, r7\n" + "\tlsls r0, 16\n" + "\tmov r8, r0\n" + "\tasrs r6, r0, 16\n" + "\tmov r2, r9\n" + "\tlsls r1, r2, 16\n" + "\tadds r0, r6, 0\n" + "\tasrs r1, 16\n" + "\tbl MapGridGetMetatileBehaviorAt\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tldr r3, [sp, 0x4]\n" + "\tldr r1, [sp, 0x14]\n" + "\tsubs r0, r3, r1\n" + "\tldr r2, [sp, 0x8]\n" + "\tadds r1, r0, 0\n" + "\tmuls r1, r2\n" + "\tadds r1, r7\n" + "\tldr r3, [sp]\n" + "\tldr r0, [r3, 0x1C]\n" + "\tlsls r1, 1\n" + "\tadds r1, r0\n" + "\tmovs r2, 0x80\n" + "\tlsls r2, 2\n" + "\tadds r0, r2, 0\n" + "\tldrh r1, [r1]\n" + "\tadds r0, r1\n" + "\tlsls r0, 16\n" + "\tlsrs r0, 16\n" + "\tbl GetBehaviorByMetatileId\n" + "\tmovs r3, 0xF0\n" + "\tlsls r3, 8\n" + "\tadds r1, r3, 0\n" + "\tadds r5, r1, 0\n" + "\tands r5, r0\n" + "\tadds r0, r4, 0\n" + "\tbl sub_805729C\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbne _080FFE0C\n" + "\tadds r0, r4, 0\n" + "\tadds r1, r5, 0\n" + "\tbl sub_80FFB6C\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbne _080FFE0C\n" + "\tb _080FFFF4\n" + "_080FFE0C:\n" + "\tmov r0, r10\n" + "\tadds r1, r6, 0\n" + "\tldr r3, [sp, 0x20]\n" + "\tasrs r2, r3, 16\n" + "\tadds r3, r5, 0\n" + "\tbl sub_80FFB94\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbne _080FFE22\n" + "\tb _080FFFF4\n" + "_080FFE22:\n" + "\tmov r1, r8\n" + "\tlsrs r0, r1, 16\n" + "\tldr r2, [sp, 0x20]\n" + "\tlsrs r1, r2, 16\n" + "\tmovs r2, 0\n" + "\tbl GetFieldObjectIdByXYZ\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tcmp r0, 0x10\n" + "\tbeq _080FFE3A\n" + "\tb _080FFFF4\n" + "_080FFE3A:\n" + "\tadds r0, r7, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r7, r0, 24\n" + "\tldr r2, _080FFF18 @ =gTasks\n" + "\tldr r3, [sp, 0x8]\n" + "\tcmp r7, r3\n" + "\tbcc _080FFDA0\n" + "_080FFE48:\n" + "\tldr r1, [sp, 0x14]\n" + "\tlsls r0, r1, 24\n" + "\tlsrs r6, r0, 24\n" + "\tldr r3, [sp, 0x18]\n" + "\tcmp r6, r3\n" + "\tblt _080FFD82\n" + "_080FFE54:\n" + "\tldr r0, [sp, 0x1C]\n" + "\tadd r0, r10\n" + "\tlsls r0, 3\n" + "\tadds r0, r2\n" + "\tldrh r0, [r0, 0xA]\n" + "\tldr r1, [sp, 0x4]\n" + "\tsubs r0, r1\n" + "\tadds r0, 0x1\n" + "\tlsls r0, 16\n" + "\tlsrs r0, 16\n" + "\tmov r9, r0\n" + "\tmovs r7, 0\n" + "\tldr r3, [sp, 0x8]\n" + "\tcmp r7, r3\n" + "\tbcc _080FFE74\n" + "\tb _08100024\n" + "_080FFE74:\n" + "\tlsls r0, 16\n" + "\tstr r0, [sp, 0x20]\n" + "_080FFE78:\n" + "\tldr r0, [sp, 0x1C]\n" + "\tadd r0, r10\n" + "\tlsls r0, 3\n" + "\tldr r1, _080FFF18 @ =gTasks\n" + "\tadds r0, r1\n" + "\tldrh r0, [r0, 0x8]\n" + "\tadds r0, r7\n" + "\tlsls r0, 16\n" + "\tmov r8, r0\n" + "\tasrs r6, r0, 16\n" + "\tmov r2, r9\n" + "\tlsls r1, r2, 16\n" + "\tadds r0, r6, 0\n" + "\tasrs r1, 16\n" + "\tbl MapGridGetMetatileBehaviorAt\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tldr r3, [sp]\n" + "\tldr r0, [r3, 0x1C]\n" + "\tlsls r1, r7, 1\n" + "\tadds r1, r0\n" + "\tmovs r2, 0x80\n" + "\tlsls r2, 2\n" + "\tadds r0, r2, 0\n" + "\tldrh r1, [r1]\n" + "\tadds r0, r1\n" + "\tlsls r0, 16\n" + "\tlsrs r0, 16\n" + "\tbl GetBehaviorByMetatileId\n" + "\tmovs r3, 0xF0\n" + "\tlsls r3, 8\n" + "\tadds r1, r3, 0\n" + "\tadds r5, r1, 0\n" + "\tands r5, r0\n" + "\tadds r0, r4, 0\n" + "\tbl sub_805729C\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbne _080FFEDA\n" + "\tadds r0, r4, 0\n" + "\tbl sub_80572B0\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbne _080FFEDA\n" + "\tb _080FFFF4\n" + "_080FFEDA:\n" + "\tmov r0, r10\n" + "\tadds r1, r6, 0\n" + "\tldr r3, [sp, 0x20]\n" + "\tasrs r2, r3, 16\n" + "\tadds r3, r5, 0\n" + "\tbl sub_80FFB94\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbne _080FFEF0\n" + "\tb _080FFFF4\n" + "_080FFEF0:\n" + "\tmov r1, r8\n" + "\tlsrs r0, r1, 16\n" + "\tldr r2, [sp, 0x20]\n" + "\tlsrs r1, r2, 16\n" + "\tmovs r2, 0\n" + "\tbl GetFieldObjectIdByXYZ\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tcmp r4, 0\n" + "\tbeq _080FFF0A\n" + "\tcmp r4, 0x10\n" + "\tbne _080FFFF4\n" + "_080FFF0A:\n" + "\tadds r0, r7, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r7, r0, 24\n" + "\tldr r3, [sp, 0x8]\n" + "\tcmp r7, r3\n" + "\tbcc _080FFE78\n" + "\tb _08100024\n" + "\t.align 2, 0\n" + "_080FFF18: .4byte gTasks\n" + "_080FFF1C:\n" + "\tmovs r6, 0\n" + "\tldr r0, [sp, 0x4]\n" + "\tcmp r6, r0\n" + "\tbcc _080FFF26\n" + "\tb _08100024\n" + "_080FFF26:\n" + "\tmov r1, r10\n" + "\tlsls r0, r1, 2\n" + "\tadd r0, r10\n" + "\tlsls r1, r0, 3\n" + "\tldr r2, _080FFF9C @ =gTasks\n" + "\tadds r0, r1, r2\n" + "\tldrh r0, [r0, 0xA]\n" + "\tsubs r0, r6\n" + "\tlsls r0, 16\n" + "\tlsrs r0, 16\n" + "\tmov r9, r0\n" + "\tmovs r7, 0\n" + "\tldr r3, [sp, 0x8]\n" + "\tcmp r7, r3\n" + "\tbcs _080FFF8C\n" + "\tadds r0, r2, 0\n" + "\tadds r1, r0\n" + "\tmov r8, r1\n" + "\tmov r1, r9\n" + "\tlsls r0, r1, 16\n" + "\tasrs r5, r0, 16\n" + "_080FFF50:\n" + "\tmov r2, r8\n" + "\tldrh r0, [r2, 0x8]\n" + "\tadds r0, r7\n" + "\tlsls r0, 16\n" + "\tasrs r4, r0, 16\n" + "\tadds r0, r4, 0\n" + "\tadds r1, r5, 0\n" + "\tbl MapGridGetMetatileBehaviorAt\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tbl sub_80572B0\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbeq _080FFFF4\n" + "\tadds r0, r4, 0\n" + "\tadds r1, r5, 0x1\n" + "\tbl MapGridGetMetatileIdAt\n" + "\tmovs r1, 0xA3\n" + "\tlsls r1, 2\n" + "\tcmp r0, r1\n" + "\tbeq _080FFFF4\n" + "\tadds r0, r7, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r7, r0, 24\n" + "\tldr r3, [sp, 0x8]\n" + "\tcmp r7, r3\n" + "\tbcc _080FFF50\n" + "_080FFF8C:\n" + "\tadds r0, r6, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r6, r0, 24\n" + "\tldr r0, [sp, 0x4]\n" + "\tcmp r6, r0\n" + "\tbcc _080FFF26\n" + "\tb _08100024\n" + "\t.align 2, 0\n" + "_080FFF9C: .4byte gTasks\n" + "_080FFFA0:\n" + "\tmov r3, r10\n" + "\tlsls r1, r3, 2\n" + "\tadds r0, r1, r3\n" + "\tlsls r0, 3\n" + "\tadds r0, r2\n" + "\tldrh r0, [r0, 0xA]\n" + "\tmov r9, r0\n" + "\tmovs r7, 0\n" + "\tstr r1, [sp, 0x1C]\n" + "\tldr r0, [sp, 0x8]\n" + "\tcmp r7, r0\n" + "\tbcs _08100024\n" + "\tadds r6, r2, 0\n" + "\tmov r1, r9\n" + "\tlsls r1, 16\n" + "\tstr r1, [sp, 0x20]\n" + "_080FFFC0:\n" + "\tldr r0, [sp, 0x1C]\n" + "\tadd r0, r10\n" + "\tlsls r0, 3\n" + "\tadds r0, r6\n" + "\tldrh r0, [r0, 0x8]\n" + "\tadds r0, r7\n" + "\tlsls r0, 16\n" + "\tlsrs r5, r0, 16\n" + "\tasrs r0, 16\n" + "\tmov r2, r9\n" + "\tlsls r1, r2, 16\n" + "\tasrs r1, 16\n" + "\tbl MapGridGetMetatileBehaviorAt\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tldr r3, [sp]\n" + "\tldrb r0, [r3, 0x12]\n" + "\tcmp r0, 0x5\n" + "\tbne _080FFFF8\n" + "_080FFFE8:\n" + "\tadds r0, r4, 0\n" + "\tbl sub_80572EC\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbne _08100004\n" + "_080FFFF4:\n" + "\tmovs r0, 0\n" + "\tb _08100026\n" + "_080FFFF8:\n" + "\tadds r0, r4, 0\n" + "\tbl sub_80572D8\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbeq _080FFFE8\n" + "_08100004:\n" + "\tadds r0, r5, 0\n" + "\tldr r2, [sp, 0x20]\n" + "\tlsrs r1, r2, 16\n" + "\tmovs r2, 0\n" + "\tbl GetFieldObjectIdByXYZ\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tcmp r0, 0x10\n" + "\tbne _080FFFF4\n" + "\tadds r0, r7, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r7, r0, 24\n" + "\tldr r3, [sp, 0x8]\n" + "\tcmp r7, r3\n" + "\tbcc _080FFFC0\n" + "_08100024:\n" + "\tmovs r0, 0x1\n" + "_08100026:\n" + "\tadd sp, 0x24\n" + "\tpop {r3-r5}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tmov r10, r5\n" + "\tpop {r4-r7}\n" + "\tpop {r1}\n" + "\tbx r1\n" + ".syntax divided\n"); +} +#endif + +void sub_8100038(u8 taskId) +{ + if (sub_80FFC24(taskId, &gDecorations[gUnknown_020388D0[gUnknown_020388F5]]) == 1) + { + DisplayItemMessageOnField(taskId, gSecretBaseText_PlaceItHere, sub_81000A0, 0); + } else + { + PlaySE(SE_HAZURE); + DisplayItemMessageOnField(taskId, gSecretBaseText_CantBePlacedHere, sub_81006A8, 0); + } +} + +void sub_81000A0(u8 taskId) +{ + DisplayYesNoMenu(20, 8, 1); + DoYesNoFuncWithChoice(taskId, &gUnknown_083EC95C); +} + +void sub_81000C4(u8 taskId) +{ + MenuZeroFillWindowRect(0, 0, 29, 19); + sub_8100174(taskId); + if (gDecorations[gUnknown_020388D0[gUnknown_020388F5]].permission != DECORPERM_SOLID_MAT) + { + sub_80FF394(gTasks[taskId].data[0], gTasks[taskId].data[1], gUnknown_020388D0[gUnknown_020388F5]); + } else + { + gUnknown_020391A4 = gTasks[taskId].data[0] - 7; + gUnknown_020391A6 = gTasks[taskId].data[1] - 7; + ScriptContext1_SetupScript(gUnknown_081A2F7B); + } + gSprites[gUnknown_020391A8].pos1.y += 2; + sub_810028C(taskId); +} + +void sub_8100174(u8 taskId) +{ + u16 i; + for (i=0; i<ewram_1f000.size; i++) + { + if (ewram_1f000.items[i] == 0) + { + ewram_1f000.items[i] = gUnknown_020388D0[gUnknown_020388F5]; + ewram_1f000.pos[i] = ((gTasks[taskId].data[0] - 7) << 4) + (gTasks[taskId].data[1] - 7); + break; + } + } + if (!ewram_1f000.isPlayerRoom) + { + for (i=0; i<16; i++) + { + if (gUnknown_020388D6[i] == 0) + { + gUnknown_020388D6[i] = gUnknown_020388F5 + 1; + break; + } + } + } else + { + for (i=0; i<12; i++) + { + if (gUnknown_020388E6[i] == 0) + { + gUnknown_020388E6[i] = gUnknown_020388F5 + 1; + break; + } + } + } +} + +void sub_8100248(u8 taskId) +{ + DisplayYesNoMenu(20, 8, 1); + DoYesNoFuncWithChoice(taskId, &gUnknown_083EC964); +} + +void sub_810026C(u8 taskId) +{ + MenuZeroFillWindowRect(0, 0, 29, 19); + sub_810028C(taskId); +} + +void sub_810028C(u8 taskId) +{ + fade_screen(1, 0); + gTasks[taskId].data[2] = 0; + gTasks[taskId].func = c1_overworld_prev_quest; +} + +void c1_overworld_prev_quest(u8 taskId) +{ + switch (gTasks[taskId].data[2]) + { + case 0: + ScriptContext2_Enable(); + if (!gPaletteFade.active) + { + sub_80FF114(taskId); + gTasks[taskId].data[2] = 1; + } + break; + case 1: + sub_81016F4(); + FreeSpritePaletteByTag(0xbb8); + gFieldCallback = &sub_8100364; + SetMainCallback2(c2_exit_to_overworld_2_switch); + DestroyTask(taskId); + break; + } +} + +void sub_8100334(u8 taskId) +{ + if (sub_807D770() == 1) + { + gTasks[taskId].func = sub_80FE948; + } +} + +void sub_8100364(void) +{ + ScriptContext2_Enable(); + LoadScrollIndicatorPalette(); + pal_fill_black(); + sub_80FE7EC(CreateTask(sub_8100334, 8)); +} + +bool8 sub_810038C(u8 taskId) +{ + s16 *data; + data = gTasks[taskId].data; + if (gUnknown_020391AA == DIR_SOUTH && data[1] - data[6] - 6 < 0) + { + data[1]++; + return FALSE; + } else if (gUnknown_020391AA == DIR_NORTH && data[1] - 7 >= gMapHeader.mapData->height) + { + data[1]--; + return FALSE; + } else if (gUnknown_020391AA == DIR_WEST && data[0] - 7 < 0) + { + data[0]++; + return FALSE; + } else if (gUnknown_020391AA == DIR_EAST && data[0] + data[5] - 8 >= gMapHeader.mapData->width) + { + data[0]--; + return FALSE; + } + return TRUE; +} + +bool8 sub_8100430(void) +{ + if ((gMain.heldKeys & DPAD_ANY) != DPAD_UP && (gMain.heldKeys & DPAD_ANY) != DPAD_DOWN && (gMain.heldKeys & DPAD_ANY) != DPAD_LEFT && (gMain.heldKeys & DPAD_ANY) != DPAD_RIGHT) + { + return FALSE; + } + return TRUE; +} + +void sub_810045C(void) +{ + gUnknown_020391AA = 0; + gSprites[gUnknown_020391A8].data2 = 0; + gSprites[gUnknown_020391A8].data3 = 0; +} + +void sub_8100494(u8 taskId) +{ + if (!gSprites[gUnknown_020391A8].data4) + { + if (gTasks[taskId].data[10] == 1) + { + gUnknown_083EC96C[gTasks[taskId].data[12]].yesFunc(taskId); + return; + } else if (gTasks[taskId].data[10] == 2) + { + gUnknown_083EC96C[gTasks[taskId].data[12]].noFunc(taskId); + return; + } + if ((gMain.heldKeys & DPAD_ANY) == DPAD_UP) + { + gUnknown_020391AA = DIR_SOUTH; + gSprites[gUnknown_020391A8].data2 = 0; + gSprites[gUnknown_020391A8].data3 = -2; + gTasks[taskId].data[1]--; + } + if ((gMain.heldKeys & DPAD_ANY) == DPAD_DOWN) + { + gUnknown_020391AA = DIR_NORTH; + gSprites[gUnknown_020391A8].data2 = 0; + gSprites[gUnknown_020391A8].data3 = 2; + gTasks[taskId].data[1]++; + } + if ((gMain.heldKeys & DPAD_ANY) == DPAD_LEFT) + { + gUnknown_020391AA = DIR_WEST; + gSprites[gUnknown_020391A8].data2 = -2; + gSprites[gUnknown_020391A8].data3 = 0; + gTasks[taskId].data[0]--; + } + if ((gMain.heldKeys & DPAD_ANY) == DPAD_RIGHT) + { + gUnknown_020391AA = DIR_EAST; + gSprites[gUnknown_020391A8].data2 = 2; + gSprites[gUnknown_020391A8].data3 = 0; + gTasks[taskId].data[0]++; + } + if (!sub_8100430() || !sub_810038C(taskId)) + { + sub_810045C(); + } + } + if (gUnknown_020391AA) + { + gSprites[gUnknown_020391A8].data4++; + gSprites[gUnknown_020391A8].data4 &= 7; + } + if (!gTasks[taskId].data[10]) + { + if (gMain.newKeys & A_BUTTON) + { + gTasks[taskId].data[10] = A_BUTTON; + } + if (gMain.newKeys & B_BUTTON) + { + gTasks[taskId].data[10] = B_BUTTON; + } + } +} + +void sub_810065C(u8 taskId) +{ + MenuZeroFillWindowRect(0, 0, 29, 19); + gSprites[gUnknown_020391A8].data7 = 0; + gTasks[taskId].data[10] = 0; + gTasks[taskId].func = sub_8100494; +} + +void sub_81006A8(u8 taskId) +{ + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + { + sub_810065C(taskId); + } +} + +void sub_81006D0(struct UnkStruct_02038900 *unk_02038900) +{ + u16 i; + for (i=0; i<0x800; i++) + { + unk_02038900->image[i] = 0; + } + for (i=0; i<0x40; i++) + { + unk_02038900->tiles[i] = 0; + } +} + +void sub_810070C(u16 *a0, u16 a1) +{ + u16 i; + for (i=0; i<16; i++) + { + a0[i] = ((u16 *)gMapHeader.mapData->primaryTileset->palettes)[16 * a1 + i]; + } +} + +void sub_8100740(u8 *dest, u16 flags) +{ + u8 buffer[32]; + u16 mode; + u16 i; + mode = flags >> 10; + if (flags != 0) + { + flags &= 0x3ff; + } + for (i=0; i<32; i++) + { + buffer[i] = ((u8 *)gMapHeader.mapData->primaryTileset->tiles)[flags * 32 + i]; + } + switch (mode) + { + case 0: + for (i=0; i<32; i++) + { + dest[i] = buffer[i]; + } + break; + case 1: + for (i=0; i<8; i++) + { + dest[4*i] = (buffer[4*(i+1) - 1] >> 4) + ((buffer[4*(i+1) - 1] & 0xf) << 4); + dest[4*i + 1] = (buffer[4*(i+1) - 2] >> 4) + ((buffer[4*(i+1) - 2] & 0xf) << 4); + dest[4*i + 2] = (buffer[4*(i+1) - 3] >> 4) + ((buffer[4*(i+1) - 3] & 0xf) << 4); + dest[4*i + 3] = (buffer[4*(i+1) - 4] >> 4) + ((buffer[4*(i+1) - 4] & 0xf) << 4); + } + break; + case 2: + for (i=0; i<8; i++) + { + dest[4*i] = buffer[4*(7-i)]; + dest[4*i + 1] = buffer[4*(7-i) + 1]; + dest[4*i + 2] = buffer[4*(7-i) + 2]; + dest[4*i + 3] = buffer[4*(7-i) + 3]; + } + break; + case 3: + for (i=0; i<32; i++) + { + dest[i] = (buffer[31-i] >> 4) + ((buffer[31-i] & 0xf) << 4); + } + break; + } +} + +void sub_8100874(struct UnkStruct_02038900 *unk_02038900) +{ + u16 i; + for (i=0; i<0x40; i++) + sub_8100740(&unk_02038900->image[i * 32], unk_02038900->tiles[i]); +} + +u16 sub_810089C(u16 a0) +{ + return ((u16 *)gMapHeader.mapData->secondaryTileset->metatiles)[a0] & 0xfff; +} + +void sub_81008BC(struct UnkStruct_02038900 *unk_02038900) +{ + u8 i; + u8 shape; + shape = unk_02038900->decoration->shape; + for (i=0; i<gUnknown_083EC860[shape].size; i++) + { + unk_02038900->tiles[gUnknown_083EC860[shape].tiles[i]] = sub_810089C(unk_02038900->decoration->tiles[gUnknown_083EC860[shape].y[i]] * 8 + gUnknown_083EC860[shape].x[i]); + } +} + +void sub_8100930(u8 decoShape) +{ + gUnknown_020391AC.y = 0; + gUnknown_020391AC.affineMode = 0; + gUnknown_020391AC.objMode = 0; + gUnknown_020391AC.mosaic = 0; + gUnknown_020391AC.bpp = 0; + gUnknown_020391AC.shape = gUnknown_083EC900[decoShape].shape; + gUnknown_020391AC.x = 0; + gUnknown_020391AC.matrixNum = 0; + gUnknown_020391AC.size = gUnknown_083EC900[decoShape].size; + gUnknown_020391AC.tileNum = 0; + gUnknown_020391AC.priority = 1; + gUnknown_020391AC.paletteNum = 0; +} + +void sub_81009A8(struct Sprite *sprite) +{ + sprite->data2 = 0; + sprite->data3 = 0; + sprite->data4 = 0; + sprite->data5 = 0; + sprite->data6 = 0; + sprite->data7 = 0; + sprite->callback = sub_81009C0; +} + +void sub_81009C0(struct Sprite *sprite) +{ + if (sprite->data7 == 0) + { + if (sprite->data6 < 15) + { + sprite->invisible = 0; + } else + { + sprite->invisible = 1; + } + sprite->data6 = (sprite->data6 + 1) & 0x1f; + } else + { + sprite->invisible = 0; + } +} + +void sub_8100A0C(u8 taskId) +{ + if (sub_8100D38(taskId) == 1) + { + fade_screen(1, 0); + gTasks[taskId].data[2] = 0; + gTasks[taskId].func = sub_8100E70; + } else + { + DisplayItemMessageOnField(taskId, gSecretBaseText_NoDecorInUse, sub_80FE428, 0); + } +} + +void sub_8100A60(u8 a0) +{ + ewram_1f000.items[a0] = 0; + ewram_1f000.pos[a0] = 0; +} + +void sub_8100A7C(void) +{ + u16 i; + gSpecialVar_0x8005 = 0; + gScriptResult = 0; + if (gSpecialVar_0x8004 == gUnknown_02039234) + { + gScriptResult = 1; + } else if (gDecorations[ewram_1f000.items[gUnknown_020391B4[gSpecialVar_0x8004].decorId]].permission == DECORPERM_SOLID_MAT) + { + gSpecialVar_0x8005 = gUnknown_020391B4[gSpecialVar_0x8004].flagId; + sub_8100A60(gUnknown_020391B4[gSpecialVar_0x8004].decorId); + for (i=0; i<gMapHeader.events->mapObjectCount; i++) + { + if (gMapHeader.events->mapObjects[i].flagId == gSpecialVar_0x8005) + { + gSpecialVar_0x8006 = gMapHeader.events->mapObjects[i].localId; + break; + } + } + } +} + +void sub_8100B20(void) +{ + u8 i; + for (i=0; i<gMapHeader.events->mapObjectCount; i++) + { + if (gMapHeader.events->mapObjects[i].flagId == gSpecialVar_0x8004) + { + gSpecialVar_0x8005 = gMapHeader.events->mapObjects[i].localId; + break; + } + } +} + +void sub_8100B6C(void) +{ + u8 i; + u8 j; + u8 k; + u8 x; + u8 y; + u8 permission; + for (i=0; i<gUnknown_02039234; i++) + { + permission = gDecorations[ewram_1f000.items[gUnknown_020391B4[i].decorId]].permission; + x = ewram_1f000.pos[gUnknown_020391B4[i].decorId] >> 4; + y = ewram_1f000.pos[gUnknown_020391B4[i].decorId] & 0xf; + if (permission != DECORPERM_SOLID_MAT) + { + if (ewram_1f000.items[gUnknown_020391B4[i].decorId] == DECOR_SAND_ORNAMENT && MapGridGetMetatileIdAt(x + 7, y + 7) == 0x28c) + { + gUnknown_020391B4[i].height++; + } + for (j=0; j<gUnknown_020391B4[i].height; j++) + { + for (k=0; k<gUnknown_020391B4[i].width; k++) + { + MapGridSetMetatileEntryAt(x + 7 + k, y + 7 - j, ((u16 *)gMapHeader.mapData->map)[(x + k) + gMapHeader.mapData->width * (y - j)] | 0x3000); + } + } + sub_8100A60(gUnknown_020391B4[i].decorId); + } + } +} + +void sub_8100C88(u8 taskId) +{ + switch (gTasks[taskId].data[2]) + { + case 0: + sub_8100B6C(); + gTasks[taskId].data[2] = 1; + break; + case 1: + if (!gPaletteFade.active) + { + DrawWholeMapView(); + ScriptContext1_SetupScript(gUnknown_081A2F8A); + MenuZeroFillWindowRect(0, 0, 29, 19); + gTasks[taskId].data[2] = 2; + } + break; + case 2: + ScriptContext2_Enable(); + sub_80FED90(taskId); + pal_fill_black(); + gTasks[taskId].data[2] = 3; + break; + case 3: + if (sub_807D770() == 1) + { + gTasks[taskId].data[13] = -1; + DisplayItemMessageOnField(taskId, gSecretBaseText_DecorReturned, sub_81010F0, 0); + } + break; + } +} + +bool8 sub_8100D38(u8 taskId) +{ + u16 i; + for (i=0; i<ewram_1f000.size; i++) + { + if (ewram_1f000.items[i] != 0) + { + gTasks[taskId].data[13] = i; + return TRUE; + } + } + return FALSE; +} + +void SetUpPuttingAwayDecorationPlayerAvatar(void) +{ + player_get_direction_lower_nybble(); + MenuZeroFillWindowRect(0, 0, 29, 19); + gUnknown_020391A8 = gSprites[gUnknown_03004880.unk4].data0; + sub_81016C8(); + gUnknown_03004880.unk4 = CreateSprite(&gSpriteTemplate_83ECA88, 0x78, 0x50, 0); + if (gSaveBlock2.playerGender == MALE) + { + gUnknown_020391A9 = AddPseudoFieldObject(0xc1, SpriteCallbackDummy, 0x88, 0x48, 0); + } else + { + gUnknown_020391A9 = AddPseudoFieldObject(0xc2, SpriteCallbackDummy, 0x88, 0x48, 0); + } + gSprites[gUnknown_020391A9].oam.priority = 1; + DestroySprite(&gSprites[gUnknown_020391A8]); + gUnknown_020391A8 = gUnknown_03004880.unk4; + gSprites[gUnknown_020391A8].oam.priority = 1; +} + +void sub_8100E70(u8 taskId) +{ + s16 *data; + data = gTasks[taskId].data; + switch (data[2]) + { + case 0: + if (!gPaletteFade.active) + { + sub_80FF0E0(taskId); + data[2] = 1; + data[6] = 1; + data[5] = 1; + HandleDestroyMenuCursors(); + } + break; + case 1: + SetUpPuttingAwayDecorationPlayerAvatar(); + pal_fill_black(); + data[2] = 2; + break; + case 2: + if (sub_807D770() == TRUE) + { + data[12] = 1; + sub_8100EEC(taskId); + } + break; + } +} + +void sub_8100EEC(u8 taskId) +{ + MenuZeroFillWindowRect(0, 0, 29, 19); + gSprites[gUnknown_020391A8].data7 = 0; + gSprites[gUnknown_020391A8].invisible = 0; + gSprites[gUnknown_020391A8].callback = sub_8101698; + gSprites[gUnknown_020391A9].pos1.x = 0x88; + gSprites[gUnknown_020391A9].pos1.y = 0x48; + gTasks[taskId].data[10] = 0; + gTasks[taskId].func = sub_8100494; +} + +void sub_8100F88(u8 taskId) +{ + gTasks[taskId].data[10] = 0; + sub_810045C(); + sub_8101024(taskId); +} + +void sub_8100FB4(u8 taskId) +{ + gTasks[taskId].data[10] = 0; + sub_810045C(); + gSprites[gUnknown_020391A8].invisible = 0; + gSprites[gUnknown_020391A8].callback = SpriteCallbackDummy; + DisplayItemMessageOnField(taskId, gSecretBaseText_StopPuttingAwayDecor, sub_810156C, 0); +} + +void sub_8101024(u8 taskId) +{ + u8 mtBehavior; + s16 *data; + sub_8101460(taskId); + if (gUnknown_02039234 != 0) + { + DisplayItemMessageOnField(taskId, gSecretBaseText_ReturnDecor, sub_8101518, 0); + } else + { + data = gTasks[taskId].data; + mtBehavior = MapGridGetMetatileBehaviorAt(data[0], data[1]); + if (MetatileBehavior_IsSecretBasePC(mtBehavior) == TRUE || sub_805738C(mtBehavior) == TRUE) + { + gSprites[gUnknown_020391A8].invisible = 0; + gSprites[gUnknown_020391A8].callback = SpriteCallbackDummy; + DisplayItemMessageOnField(taskId, gSecretBaseText_StopPuttingAwayDecor, sub_810156C, 0); + } else + { + DisplayItemMessageOnField(taskId, gSecretBaseText_NoDecor, sub_81010F0, 0); + } + } +} + +void sub_81010F0(u8 taskId) +{ + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + { + sub_8100EEC(taskId); + } +} + +void sub_8101118(u8 decorIdx, struct UnkStruct_020391B4 *unk_020391B4) +{ + if (gDecorations[decorIdx].shape == DECORSHAPE_1x1) + { + unk_020391B4->width = 1; + unk_020391B4->height = 1; + } else if (gDecorations[decorIdx].shape == DECORSHAPE_2x1) + { + unk_020391B4->width = 2; + unk_020391B4->height = 1; + } else if (gDecorations[decorIdx].shape == DECORSHAPE_3x1) + { + unk_020391B4->width = 3; + unk_020391B4->height = 1; + } else if (gDecorations[decorIdx].shape == DECORSHAPE_4x2) + { + unk_020391B4->width = 4; + unk_020391B4->height = 2; + } else if (gDecorations[decorIdx].shape == DECORSHAPE_2x2) + { + unk_020391B4->width = 2; + unk_020391B4->height = 2; + } else if (gDecorations[decorIdx].shape == DECORSHAPE_1x2) + { + unk_020391B4->width = 1; + unk_020391B4->height = 2; + } else if (gDecorations[decorIdx].shape == DECORSHAPE_1x3) + { + unk_020391B4->width = 1; + unk_020391B4->height = 3; + } else if (gDecorations[decorIdx].shape == DECORSHAPE_2x4) + { + unk_020391B4->width = 2; + unk_020391B4->height = 4; + } else if (gDecorations[decorIdx].shape == DECORSHAPE_3x3) + { + unk_020391B4->width = 3; + unk_020391B4->height = 3; + } else if (gDecorations[decorIdx].shape == DECORSHAPE_3x2) + { + unk_020391B4->width = 3; + unk_020391B4->height = 2; + } +} + +void sub_8101198(u8 x, u8 y) +{ + gSprites[gUnknown_020391A8].invisible = 1; + gSprites[gUnknown_020391A8].callback = SpriteCallbackDummy; + gSprites[gUnknown_020391A9].pos1.x = 0x88 + x * 16; + gSprites[gUnknown_020391A9].pos1.y = 0x48 + y * 16; +} + +bool8 sub_8101200(u8 taskId, u8 decorIdx, struct UnkStruct_020391B4 *unk_020391B4) +{ + u8 x; + u8 y; + u8 xOff; + u8 yOff; + x = gTasks[taskId].data[0] - 7; + y = gTasks[taskId].data[1] - 7; + xOff = ewram_1f000.pos[decorIdx] >> 4; + yOff = ewram_1f000.pos[decorIdx] & 0xf; + if (ewram_1f000.items[decorIdx] == DECOR_SAND_ORNAMENT && MapGridGetMetatileIdAt(xOff + 7, yOff + 7) == 0x28c) + { + unk_020391B4->height--; + } + if (x >= xOff && x < xOff + unk_020391B4->width && y > yOff - unk_020391B4->height && y <= yOff) + { + sub_8101198(unk_020391B4->width - (x - xOff + 1), yOff - y); + return TRUE; + } + return FALSE; +} + +void sub_81012A0(void) +{ + u8 xOff; + u8 yOff; + u16 i; + xOff = ewram_1f000.pos[gUnknown_020391B4[gUnknown_02039234].decorId] >> 4; + yOff = ewram_1f000.pos[gUnknown_020391B4[gUnknown_02039234].decorId] & 0xf; + for (i=0; i<0x40; i++) + { + if (gSaveBlock1.mapObjectTemplates[i].x == xOff && gSaveBlock1.mapObjectTemplates[i].y == yOff && !FlagGet(gSaveBlock1.mapObjectTemplates[i].flagId)) + { + gUnknown_020391B4[gUnknown_02039234].flagId = gSaveBlock1.mapObjectTemplates[i].flagId; + break; + } + } +} + +bool8 sub_8101340(u8 taskId) +{ + u16 i; + for (i=0; i<ewram_1f000.size; i++) + { + if (ewram_1f000.items[i] != 0) + { + if (gDecorations[ewram_1f000.items[i]].permission == DECORPERM_SOLID_MAT) + { + sub_8101118(ewram_1f000.items[i], gUnknown_020391B4); + if (sub_8101200(taskId, i, gUnknown_020391B4) == TRUE) + { + gUnknown_020391B4->decorId = i; + sub_81012A0(); + gUnknown_02039234 = 1; + return TRUE; + } + } + } + } + return FALSE; +} + +void sub_81013B8(u8 a0, u8 a1, u8 a2, u8 a3) +{ + u8 i; + u8 xOff; + u8 yOff; + u8 decorIdx; + for (i=0; i<ewram_1f000.size; i++) + { + decorIdx = ewram_1f000.items[i]; + xOff = ewram_1f000.pos[i] >> 4; + yOff = ewram_1f000.pos[i] & 0xf; + if (decorIdx != 0 && gDecorations[decorIdx].permission == DECORPERM_SOLID_MAT && a0 <= xOff && a1 <= yOff && a2 >= xOff && a3 >= yOff) + { + gUnknown_020391B4[gUnknown_02039234].decorId = i; + sub_81012A0(); + gUnknown_02039234++; + } + } +} + +#ifdef NONMATCHING +void sub_8101460(u8 taskId) +{ + u8 i; + u8 xOff; + u8 yOff; + gUnknown_02039234 = 0; + if (sub_8101340(taskId) != TRUE) + { + for (i=0; i<ewram_1f000.size; i++) + { + if (ewram_1f000.items[i] == 0) // This is using the wrong register! + { + continue; + } + sub_8101118(ewram_1f000.items[i], gUnknown_020391B4); + if (sub_8101200(taskId, i, gUnknown_020391B4) == TRUE) + { + gUnknown_020391B4[0].decorId = i; + gUnknown_02039234++; + break; + } + } + if (gUnknown_02039234 != 0) + { + xOff = ewram_1f000.pos[gUnknown_020391B4[0].decorId] >> 4; + yOff = ewram_1f000.pos[gUnknown_020391B4[0].decorId] & 0xf; + sub_81013B8(xOff, yOff - gUnknown_020391B4[0].height + 1, xOff + gUnknown_020391B4[0].width - 1, yOff); + } + } +} +#else +__attribute__((naked)) +void sub_8101460(u8 taskId) +{ + asm(".syntax unified\n" + "\tpush {r4-r7,lr}\n" + "\tlsls r0, 24\n" + "\tlsrs r6, r0, 24\n" + "\tldr r4, _081014B8 @ =gUnknown_02039234\n" + "\tmovs r0, 0\n" + "\tstrb r0, [r4]\n" + "\tadds r0, r6, 0\n" + "\tbl sub_8101340\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tcmp r0, 0x1\n" + "\tbeq _08101504\n" + "\tmovs r5, 0\n" + "\tldr r0, _081014BC @ =ewram_1f000\n" + "\tldrb r1, [r0, 0x8]\n" + "\tcmp r5, r1\n" + "\tbcs _081014D2\n" + "\tadds r7, r4, 0\n" + "_08101486:\n" + "\tldr r0, [r0]\n" + "\tadds r0, r5\n" + "\tldrb r1, [r0] @ compiler incorrectly uses r0 for this and the next instruction\n" + "\tcmp r1, 0\n" + "\tbeq _081014C4\n" + "\tldr r4, _081014C0 @ =gUnknown_020391B4\n" + "\tadds r0, r1, 0\n" + "\tadds r1, r4, 0\n" + "\tbl sub_8101118\n" + "\tadds r0, r6, 0\n" + "\tadds r1, r5, 0\n" + "\tadds r2, r4, 0\n" + "\tbl sub_8101200\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tcmp r0, 0x1\n" + "\tbne _081014C4\n" + "\tstrb r5, [r4]\n" + "\tldrb r0, [r7]\n" + "\tadds r0, 0x1\n" + "\tstrb r0, [r7]\n" + "\tb _081014D2\n" + "\t.align 2, 0\n" + "_081014B8: .4byte gUnknown_02039234\n" + "_081014BC: .4byte 0x201f000\n" + "_081014C0: .4byte gUnknown_020391B4\n" + "_081014C4:\n" + "\tadds r0, r5, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r5, r0, 24\n" + "\tldr r0, _0810150C @ =ewram_1f000\n" + "\tldrb r1, [r0, 0x8]\n" + "\tcmp r5, r1\n" + "\tbcc _08101486\n" + "_081014D2:\n" + "\tldr r0, _08101510 @ =gUnknown_02039234\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0\n" + "\tbeq _08101504\n" + "\tldr r0, _0810150C @ =ewram_1f000\n" + "\tldr r2, _08101514 @ =gUnknown_020391B4\n" + "\tldrb r1, [r2]\n" + "\tldr r0, [r0, 0x4]\n" + "\tadds r0, r1\n" + "\tldrb r1, [r0]\n" + "\tlsrs r0, r1, 4\n" + "\tmovs r3, 0xF\n" + "\tands r3, r1\n" + "\tldrb r1, [r2, 0x2]\n" + "\tsubs r1, r3, r1\n" + "\tadds r1, 0x1\n" + "\tlsls r1, 24\n" + "\tlsrs r1, 24\n" + "\tldrb r2, [r2, 0x1]\n" + "\tadds r2, r0\n" + "\tsubs r2, 0x1\n" + "\tlsls r2, 24\n" + "\tlsrs r2, 24\n" + "\tbl sub_81013B8\n" + "_08101504:\n" + "\tpop {r4-r7}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.align 2, 0\n" + "_0810150C: .4byte 0x201f000\n" + "_08101510: .4byte gUnknown_02039234\n" + "_08101514: .4byte gUnknown_020391B4\n" + ".syntax divided\n"); +} +#endif + +void sub_8101518(u8 taskId) +{ + DisplayYesNoMenu(20, 8, 1); + DoYesNoFuncWithChoice(taskId, &gUnknown_083EC9CC); +} + +void sub_810153C(u8 taskId) +{ + fade_screen(1, 0); + gTasks[taskId].data[2] = 0; + gTasks[taskId].func = sub_8100C88; +} + +void sub_810156C(u8 taskId) +{ + DisplayYesNoMenu(20, 8, 1); + DoYesNoFuncWithChoice(taskId, &gUnknown_083EC9D4); +} + +void sub_8101590(u8 taskId) +{ + MenuZeroFillWindowRect(0, 0, 29, 19); + sub_81015B0(taskId); +} + +void sub_81015B0(u8 taskId) +{ + fade_screen(1, 0); + gTasks[taskId].data[2] = 0; + gTasks[taskId].func = sub_81015E0; +} + +void sub_81015E0(u8 taskId) +{ + switch (gTasks[taskId].data[2]) + { + case 0: + if (!gPaletteFade.active) + { + sub_80FF114(taskId); + gTasks[taskId].data[2] = 1; + } + break; + case 1: + sub_81016F4(); + gFieldCallback = sub_8101678; + SetMainCallback2(c2_exit_to_overworld_2_switch); + DestroyTask(taskId); + break; + } +} + +void sub_8101648(u8 taskId) +{ + if (sub_807D770() == TRUE) + { + gTasks[taskId].func = Task_DecorationPCProcessMenuInput; + } +} + +void sub_8101678(void) +{ + pal_fill_black(); + MenuDisplayMessageBox(); + sub_80FE220(); + CreateTask(sub_8101648, 8); +} + +void sub_8101698(struct Sprite *sprite) +{ + sprite->data0 = (sprite->data0 + 1) & 0x1f; + if (sprite->data0 >= 16) + { + sprite->invisible = TRUE; + } else + { + sprite->invisible = FALSE; + } +} + +void sub_81016C8(void) +{ + if (gSaveBlock2.playerGender == MALE) + { + LoadSpritePalette(&gUnknown_083ECA5C); + } else + { + LoadSpritePalette(&gUnknown_083ECA64); + } +} + +void sub_81016F4(void) +{ + FreeSpritePaletteByTag(8); +} + +void sub_8101700(u8 taskId) +{ + if (!sub_81341D4()) + { + DisplayItemMessageOnField(taskId, gSecretBaseText_NoDecors, sub_80FE428, 0); + } else + { + gTasks[taskId].data[11] = 1; + gUnknown_020388F6 = 0; + sub_80FE5AC(taskId); + } +} + +void sub_8101750(u8 taskId) +{ + if (!sub_81341D4()) + { + DisplayItemMessageOnField(taskId, gSecretBaseText_NoDecors, sub_80FE428, 0); + } else + { + gTasks[taskId].data[11] = 2; + gUnknown_020388F6 = 0; + sub_80FE5AC(taskId); + } +} + +void sub_81017A0(u8 taskId) +{ + sub_80FEF74(); + sub_80FED1C(); + if (sub_80FEFA4() == TRUE) + { + StringCopy(gStringVar1, gDecorations[gUnknown_020388D0[gUnknown_020388F5]].name); + StringExpandPlaceholders(gStringVar4, gSecretBaseText_WillBeDiscarded); + DisplayItemMessageOnField(taskId, gStringVar4, sub_8101824, 0); + } else + { + DisplayItemMessageOnField(taskId, gSecretBaseText_DecorInUse, sub_80FEFF4, 0); + } +} + +void sub_8101824(u8 taskId) +{ + DisplayYesNoMenu(20, 8, 1); + DoYesNoFuncWithChoice(taskId, &gUnknown_083ECAA0); +} + +void sub_8101848(u8 taskId) +{ + MenuZeroFillWindowRect(20, 8, 26, 14); + sub_8109A30(gUnknown_020388D0[gUnknown_020388F5]); + gUnknown_020388D0[gUnknown_020388F5] = DECOR_NONE; + sub_80FF098(taskId); + DisplayItemMessageOnField(taskId, gSecretBaseText_DecorThrownAway, sub_80FEFF4, 0); +} diff --git a/src/decoration_inventory.c b/src/decoration_inventory.c new file mode 100644 index 000000000..35ba7e228 --- /dev/null +++ b/src/decoration_inventory.c @@ -0,0 +1,169 @@ +// +// Created by Scott Norton on 6/5/17. +// + +#include "global.h" +#include "sprite.h" +#include "task.h" +#include "decoration.h" +#include "decoration_inventory.h" + +#define DECOR_INV(ptr) {.items = (u8 *)&ptr, .size = sizeof ptr} + +struct DecorationInventory const gDecorationInventories[] = { + DECOR_INV(gSaveBlock1.decorDesk), + DECOR_INV(gSaveBlock1.decorChair), + DECOR_INV(gSaveBlock1.decorPlant), + DECOR_INV(gSaveBlock1.decorOrnament), + DECOR_INV(gSaveBlock1.decorMat), + DECOR_INV(gSaveBlock1.decorPoster), + DECOR_INV(gSaveBlock1.decorDoll), + DECOR_INV(gSaveBlock1.decorCushion) +}; + +void ClearDecorationInventory(u8 invIdx) +{ + u8 i; + for (i=0; i<gDecorationInventories[invIdx].size; i++) + { + gDecorationInventories[invIdx].items[i] = DECOR_NONE; + } +} + +void ClearDecorationInventories(void) +{ + u8 i; + for (i=0; i<8; i++) + { + ClearDecorationInventory(i); + } +} + +s8 sub_8133F9C(u8 invIdx) +{ + s8 i; + for (i=0; i<(s8)gDecorationInventories[invIdx].size; i++) + { + if (gDecorationInventories[invIdx].items[i] == DECOR_NONE) + { + return i; + } + } + return -1; +} + +bool8 sub_8133FE4(u8 decorIdx) +{ + u8 invIdx; + u8 i; + invIdx = gDecorations[decorIdx].category; + for (i=0; i<gDecorationInventories[invIdx].size; i++) + { + if (gDecorationInventories[invIdx].items[i] == decorIdx) + { + return TRUE; + } + } + return FALSE; +} + +bool8 IsThereStorageSpaceForDecoration(u8 decorIdx) +{ + u8 invIdx; + s8 invSlot; + if (decorIdx == DECOR_NONE) + { + return FALSE; + } + invIdx = gDecorations[decorIdx].category; + invSlot = sub_8133F9C(invIdx); + if (invSlot == -1) + { + return FALSE; + } + gDecorationInventories[invIdx].items[invSlot] = decorIdx; + return TRUE; +} + +bool8 sub_8134074(u8 decorIdx) +{ + u8 invIdx; + if (decorIdx == DECOR_NONE) + { + return FALSE; + } + invIdx = gDecorations[decorIdx].category; + if (sub_8133F9C(invIdx) == -1) + { + return FALSE; + } + return TRUE; +} + +s8 sub_81340A8(u8 decorIdx) +{ + u8 i; + u8 invIdx; + i = 0; + if (decorIdx == DECOR_NONE) + { + return FALSE; + } + for (i=0; i<gDecorationInventories[gDecorations[decorIdx].category].size; i++) + { + invIdx = gDecorations[decorIdx].category; + if (gDecorationInventories[invIdx].items[i] == decorIdx) + { + gDecorationInventories[invIdx].items[i] = DECOR_NONE; + sub_8134104(invIdx); + return TRUE; + } + } + return FALSE; +} + +void sub_8134104(u8 invIdx) +{ + u8 i; + u8 j; + u8 tmp; + for (i=0; i<gDecorationInventories[invIdx].size; i++) + { + for (j=i+1; j<gDecorationInventories[invIdx].size; j++) + { + if (gDecorationInventories[invIdx].items[j] != 0 && (gDecorationInventories[invIdx].items[i] == DECOR_NONE || gDecorationInventories[invIdx].items[i] > gDecorationInventories[invIdx].items[j])) + { + tmp = gDecorationInventories[invIdx].items[i]; + gDecorationInventories[invIdx].items[i] = gDecorationInventories[invIdx].items[j]; + gDecorationInventories[invIdx].items[j] = tmp; + } + } + } +} + +u8 sub_8134194(u8 invIdx) +{ + u8 i; + u8 count; + count = 0; + for (i=0; i<gDecorationInventories[invIdx].size; i++) + { + if (gDecorationInventories[invIdx].items[i] != 0) + { + count++; + } + } + return count; +} + +u8 sub_81341D4(void) +{ + u8 i; + u8 count; + count = 0; + for (i=0; i<8; i++) + { + count += sub_8134194(i); + } + return count; +} diff --git a/src/dewford_trend.c b/src/dewford_trend.c index ae1397852..aaf4dd66a 100644 --- a/src/dewford_trend.c +++ b/src/dewford_trend.c @@ -1,26 +1,35 @@ #include "global.h" -#include "asm.h" +#include "dewford_trend.h" +#include "easy_chat.h" +#include "event_data.h" #include "link.h" #include "rng.h" -#include "flag.h" +#include "text.h" + +extern u8 unk_2000000[]; -extern struct EasyChatPair unk_2007800[5]; -extern struct EasyChatPair unk_2007900[5]; extern u16 gScriptResult; extern u16 gSpecialVar_0x8004; -void sub_80FA17C(void) +static void sub_80FA46C(struct EasyChatPair *s, u16 b, u8 c); +static bool8 sub_80FA670(struct EasyChatPair *a, struct EasyChatPair *b, u8 c); +static void sub_80FA740(struct EasyChatPair *s); +static bool8 SB1ContainsWords(u16 *a); +static bool8 IsEasyChatPairEqual(u16 *words1, u16 *words2); +static s16 sub_80FA828(struct EasyChatPair *a, u16 b); + +void InitDewfordTrend(void) { u16 i; - for(i = 0; i < 5; i++) + for (i = 0; i < 5; i++) { - gSaveBlock1.easyChatPairs[i].words[0] = sub_80EB72C(10); + gSaveBlock1.easyChatPairs[i].words[0] = sub_80EB72C(EC_GROUP_CONDITIONS); - if(Random() & 1) - gSaveBlock1.easyChatPairs[i].words[1] = sub_80EB72C(12); + if (Random() & 1) + gSaveBlock1.easyChatPairs[i].words[1] = sub_80EB72C(EC_GROUP_LIFESTYLE); else - gSaveBlock1.easyChatPairs[i].words[1] = sub_80EB72C(13); + gSaveBlock1.easyChatPairs[i].words[1] = sub_80EB72C(EC_GROUP_HOBBIES); gSaveBlock1.easyChatPairs[i].unk1_6 = Random() & 1; sub_80FA740(&gSaveBlock1.easyChatPairs[i]); @@ -28,255 +37,74 @@ void sub_80FA17C(void) sub_80FA46C(gSaveBlock1.easyChatPairs, 5, 0); } -#ifdef NONMATCHING -void sub_80FA220(u16 a) +void UpdateDewfordTrendPerDay(u16 a) { u16 i; - u32 sp0; - u32 sp4; - if(a != 0) + if (a != 0) { - sp0 = a * 5; + u32 sp0 = a * 5; - for(i = 0; i < 5; i++) + for (i = 0; i < 5; i++) { //_080FA24A - u32 r2 = sp0; u32 r4; + u32 r2 = sp0; + struct EasyChatPair *r5 = &gSaveBlock1.easyChatPairs[i]; - if(gSaveBlock1.easyChatPairs[i].unk1_6 == 0) + if (r5->unk1_6 == 0) { - if(gSaveBlock1.easyChatPairs[i].unk0_0 >= r2) + if (r5->unk0_0 >= (u16)r2) { - gSaveBlock1.easyChatPairs[i].unk0_0 -= r2; - if(gSaveBlock1.easyChatPairs[i].unk0_0 == 0) - gSaveBlock1.easyChatPairs[i].unk1_6 = 1; + r5->unk0_0 -= r2; + if (r5->unk0_0 == 0) + r5->unk1_6 = 1; continue; } //_080FA290 - r2 -= gSaveBlock1.easyChatPairs[i].unk0_0; - gSaveBlock1.easyChatPairs[i].unk1_6 = 1; + r2 -= r5->unk0_0; + r5->unk0_0 = 0; + r5->unk1_6 = 1; } //_080FA2A0 - r4 = gSaveBlock1.easyChatPairs[i].unk0_0 + r2; - if(r4 > gSaveBlock1.easyChatPairs[i].unk0_7) + r4 = r5->unk0_0 + r2; + if ((u16)r4 > r5->unk0_7) { - sp4 = r4 % gSaveBlock1.easyChatPairs[i].unk0_7; - r4 = r4 / gSaveBlock1.easyChatPairs[i].unk0_7; + u32 sp4 = r4 % r5->unk0_7; + r4 = r4 / r5->unk0_7; - if(r4 == 0) - gSaveBlock1.easyChatPairs[i].unk1_6 = 1; + r5->unk1_6 = r4 ^ 1; + if (r5->unk1_6) + r5->unk0_0 = sp4; else - gSaveBlock1.easyChatPairs[i].unk1_6 = 0; - - - if(gSaveBlock1.easyChatPairs[i].unk1_6) - { - gSaveBlock1.easyChatPairs[i].unk0_0 += sp4; - continue; - } //_080FA2FA - gSaveBlock1.easyChatPairs[i].unk0_7 -= sp4; - continue; + r5->unk0_0 = r5->unk0_7 - sp4; } - //_080FA310 - gSaveBlock1.easyChatPairs[i].unk0_0 = r4; + else + { + //_080FA310 + r5->unk0_0 = r4; - if(gSaveBlock1.easyChatPairs[i].unk0_0 == gSaveBlock1.easyChatPairs[i].unk0_7) - gSaveBlock1.easyChatPairs[i].unk1_6 = 0; + if (r5->unk0_0 == r5->unk0_7) + r5->unk1_6 = 0; + } } sub_80FA46C(gSaveBlock1.easyChatPairs, 5, 0); } //_080FA34E } -#else -__attribute__((naked)) -void sub_80FA220(u16 a) -{ - 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, 0x8\n\ - lsls r0, 16\n\ - lsrs r1, r0, 16\n\ - cmp r1, 0\n\ - bne _080FA236\n\ - b _080FA34E\n\ -_080FA236:\n\ - lsls r0, r1, 2\n\ - adds r0, r1\n\ - str r0, [sp]\n\ - movs r0, 0\n\ - mov r10, r0\n\ - movs r1, 0x7F\n\ - mov r9, r1\n\ - movs r2, 0x80\n\ - negs r2, r2\n\ - mov r8, r2\n\ -_080FA24A:\n\ - ldr r2, [sp]\n\ - mov r4, r10\n\ - lsls r0, r4, 3\n\ - ldr r1, _080FA28C @ =gSaveBlock1 + 0x2DD4\n\ - adds r5, r0, r1\n\ - ldrb r6, [r5, 0x1]\n\ - movs r0, 0x40\n\ - ands r0, r6\n\ - cmp r0, 0\n\ - bne _080FA2A0\n\ - ldrb r4, [r5]\n\ - lsls r3, r4, 25\n\ - lsrs r1, r3, 25\n\ - lsls r0, r2, 16\n\ - lsrs r0, 16\n\ - cmp r1, r0\n\ - bcc _080FA290\n\ - adds r0, r1, 0\n\ - subs r0, r2\n\ - mov r2, r9\n\ - ands r0, r2\n\ - mov r1, r8\n\ - ands r1, r4\n\ - orrs r1, r0\n\ - strb r1, [r5]\n\ - movs r0, 0x7F\n\ - ands r1, r0\n\ - cmp r1, 0\n\ - bne _080FA336\n\ - movs r0, 0x40\n\ - orrs r0, r6\n\ - b _080FA334\n\ - .align 2, 0\n\ -_080FA28C: .4byte gSaveBlock1 + 0x2DD4\n\ -_080FA290:\n\ - lsrs r0, r3, 25\n\ - subs r2, r0\n\ - mov r0, r8\n\ - ands r0, r4\n\ - strb r0, [r5]\n\ - movs r0, 0x40\n\ - orrs r0, r6\n\ - strb r0, [r5, 0x1]\n\ -_080FA2A0:\n\ - ldrb r7, [r5]\n\ - lsls r0, r7, 25\n\ - lsrs r0, 25\n\ - adds r4, r0, r2\n\ - ldrh r0, [r5]\n\ - lsls r6, r0, 18\n\ - lsls r0, r4, 16\n\ - lsrs r0, 16\n\ - lsrs r1, r6, 25\n\ - cmp r0, r1\n\ - bls _080FA310\n\ - adds r0, r4, 0\n\ - bl __umodsi3\n\ - adds r3, r0, 0\n\ - lsrs r1, r6, 25\n\ - adds r0, r4, 0\n\ - str r3, [sp, 0x4]\n\ - bl __udivsi3\n\ - adds r4, r0, 0\n\ - movs r0, 0x1\n\ - eors r4, r0\n\ - ands r4, r0\n\ - lsls r2, r4, 6\n\ - ldrb r0, [r5, 0x1]\n\ - movs r4, 0x41\n\ - negs r4, r4\n\ - adds r1, r4, 0\n\ - ands r0, r1\n\ - orrs r0, r2\n\ - strb r0, [r5, 0x1]\n\ - movs r1, 0x40\n\ - ands r0, r1\n\ - ldr r3, [sp, 0x4]\n\ - cmp r0, 0\n\ - beq _080FA2FA\n\ - adds r1, r3, 0\n\ - mov r0, r9\n\ - ands r1, r0\n\ - mov r0, r8\n\ - ands r0, r7\n\ - orrs r0, r1\n\ - strb r0, [r5]\n\ - b _080FA336\n\ -_080FA2FA:\n\ - ldrh r0, [r5]\n\ - lsls r0, 18\n\ - lsrs r0, 25\n\ - subs r0, r3\n\ - mov r1, r9\n\ - ands r0, r1\n\ - mov r1, r8\n\ - ands r1, r7\n\ - orrs r1, r0\n\ - strb r1, [r5]\n\ - b _080FA336\n\ -_080FA310:\n\ - mov r2, r9\n\ - ands r4, r2\n\ - mov r0, r8\n\ - ands r0, r7\n\ - orrs r0, r4\n\ - strb r0, [r5]\n\ - lsls r0, 25\n\ - ldrh r1, [r5]\n\ - lsls r1, 18\n\ - lsrs r0, 25\n\ - lsrs r1, 25\n\ - cmp r0, r1\n\ - bne _080FA336\n\ - ldrb r0, [r5, 0x1]\n\ - movs r4, 0x41\n\ - negs r4, r4\n\ - adds r1, r4, 0\n\ - ands r0, r1\n\ -_080FA334:\n\ - strb r0, [r5, 0x1]\n\ -_080FA336:\n\ - mov r0, r10\n\ - adds r0, 0x1\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - mov r10, r0\n\ - cmp r0, 0x4\n\ - bls _080FA24A\n\ - ldr r0, _080FA360 @ =gSaveBlock1 + 0x2DD4\n\ - movs r1, 0x5\n\ - movs r2, 0\n\ - bl sub_80FA46C\n\ -_080FA34E:\n\ - add sp, 0x8\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\ - .align 2, 0\n\ -_080FA360: .4byte gSaveBlock1 + 0x2DD4\n\ - .syntax divided\n"); -} -#endif - bool8 sub_80FA364(u16 *a) { struct EasyChatPair s = {0}; u16 i; - if(!SB1ContainsWords(a)) + if (!SB1ContainsWords(a)) { - if(!FlagGet(SYS_POPWORD_INPUT)) + if (!FlagGet(SYS_POPWORD_INPUT)) { FlagSet(SYS_POPWORD_INPUT); - if(!FlagGet(SYS_MIX_RECORD)) + if (!FlagGet(SYS_MIX_RECORD)) { gSaveBlock1.easyChatPairs[0].words[0] = a[0]; gSaveBlock1.easyChatPairs[0].words[1] = a[1]; @@ -290,13 +118,13 @@ bool8 sub_80FA364(u16 *a) s.unk1_6 = 1; sub_80FA740(&s); - for(i = 0; i < 5; i++) + for (i = 0; i < 5; i++) { - if(sub_80FA670(&s, &gSaveBlock1.easyChatPairs[i], 0)) + if (sub_80FA670(&s, &gSaveBlock1.easyChatPairs[i], 0)) { u16 r3 = 4; - while(r3 > i) + while (r3 > i) { gSaveBlock1.easyChatPairs[r3] = gSaveBlock1.easyChatPairs[r3 - 1]; r3--; @@ -311,17 +139,17 @@ bool8 sub_80FA364(u16 *a) return 0; } -void sub_80FA46C(struct EasyChatPair *s, u16 b, u8 c) +static void sub_80FA46C(struct EasyChatPair *s, u16 b, u8 c) { u16 h; - for(h = 0; h < b; h++) + for (h = 0; h < b; h++) { u16 i; - for(i = h + 1; i < b; i++) + for (i = h + 1; i < b; i++) { - if(sub_80FA670(&s[i], &s[h], c)) + if (sub_80FA670(&s[i], &s[h], c)) { struct EasyChatPair temp; @@ -333,8 +161,7 @@ void sub_80FA46C(struct EasyChatPair *s, u16 b, u8 c) } } -#ifdef NONMATCHING -void sub_80FA4E4(u8 *a, u32 b) +void sub_80FA4E4(void *a, u32 b, u8 unused) { u16 i; u16 j; @@ -343,165 +170,37 @@ void sub_80FA4E4(u8 *a, u32 b) struct EasyChatPair *dst; u16 players = GetLinkPlayerCount(); - for(i = 0; i < players; i++) - memcpy(&unk_2007800[i * 5], a + i * b, 40); - - //_080FA520 - - src = unk_2007800; - //dst = unk_2007900 - dst = (u8 *)src + 0x100; //ToDo: Get this part to match - + for (i = 0; i < players; i++) + memcpy(&ARRAY_2007800[i * 5], (u8 *)a + i * b, 40); + src = ARRAY_2007800; + dst = ARRAY_2007900; r7 = 0; - //_080FA530 - for(i = 0; i < players; i++) + for (i = 0; i < players; i++) { - for(j = 0; j < 5; j++) + for (j = 0; j < 5; j++) { s16 foo = sub_80FA828(src, r7); - if(foo < 0) + if (foo < 0) { *(dst++) = *src; r7++; } - //_080FA558 else { - if(unk_2007900[foo].unk0_0 < src->unk0_0) + if (ARRAY_2007900[foo].unk0_0 < src->unk0_0) { - unk_2007900[foo] = *src; + ARRAY_2007900[foo] = *src; } } - //_080FA572 src++; } } - //_080FA588 - sub_80FA46C(unk_2007900, r7, 2); - src = unk_2007900; + sub_80FA46C(ARRAY_2007900, r7, 2); + src = ARRAY_2007900; dst = gSaveBlock1.easyChatPairs; - for(i = 0; i < 5; i++) + for (i = 0; i < 5; i++) *(dst++) = *(src++); } -#else -__attribute__((naked)) -void sub_80FA4E4(struct EasyChatPair *a, u32 b, u8 c) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - sub sp, 0x4\n\ - adds r6, r0, 0\n\ - adds r5, r1, 0\n\ - bl GetLinkPlayerCount\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - movs r4, 0\n\ - cmp r4, r8\n\ - bcs _080FA520\n\ -_080FA500:\n\ - lsls r0, r4, 2\n\ - adds r0, r4\n\ - lsls r0, 3\n\ - ldr r1, _080FA554 @ =0x02007800\n\ - adds r0, r1\n\ - adds r1, r4, 0\n\ - muls r1, r5\n\ - adds r1, r6, r1\n\ - movs r2, 0x28\n\ - bl memcpy\n\ - adds r0, r4, 0x1\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - cmp r4, r8\n\ - bcc _080FA500\n\ -_080FA520:\n\ - ldr r5, _080FA554 @ =0x02007800\n\ - movs r0, 0x80\n\ - lsls r0, 1\n\ - adds r3, r5, r0\n\ - movs r7, 0\n\ - movs r4, 0\n\ - cmp r4, r8\n\ - bcs _080FA588\n\ -_080FA530:\n\ - movs r6, 0\n\ -_080FA532:\n\ - adds r0, r5, 0\n\ - adds r1, r7, 0\n\ - str r3, [sp]\n\ - bl sub_80FA828\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - ldr r3, [sp]\n\ - cmp r0, 0\n\ - bge _080FA558\n\ - ldr r0, [r5]\n\ - ldr r1, [r5, 0x4]\n\ - stm r3!, {r0,r1}\n\ - adds r0, r7, 0x1\n\ - lsls r0, 16\n\ - lsrs r7, r0, 16\n\ - b _080FA572\n\ - .align 2, 0\n\ -_080FA554: .4byte 0x02007800\n\ -_080FA558:\n\ - lsls r1, r0, 3\n\ - ldr r0, _080FA5B4 @ =0x02007900\n\ - adds r2, r1, r0\n\ - ldrb r1, [r2]\n\ - lsls r1, 25\n\ - ldrb r0, [r5]\n\ - lsls r0, 25\n\ - cmp r1, r0\n\ - bcs _080FA572\n\ - ldr r0, [r5]\n\ - ldr r1, [r5, 0x4]\n\ - str r0, [r2]\n\ - str r1, [r2, 0x4]\n\ -_080FA572:\n\ - adds r5, 0x8\n\ - adds r0, r6, 0x1\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ - cmp r6, 0x4\n\ - bls _080FA532\n\ - adds r0, r4, 0x1\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - cmp r4, r8\n\ - bcc _080FA530\n\ -_080FA588:\n\ - ldr r4, _080FA5B4 @ =0x02007900\n\ - adds r0, r4, 0\n\ - adds r1, r7, 0\n\ - movs r2, 0x2\n\ - bl sub_80FA46C\n\ - adds r5, r4, 0\n\ - ldr r3, _080FA5B8 @ =gSaveBlock1 + 0x2DD4\n\ - movs r4, 0\n\ -_080FA59A:\n\ - ldm r5!, {r0,r1}\n\ - stm r3!, {r0,r1}\n\ - adds r0, r4, 0x1\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - cmp r4, 0x4\n\ - bls _080FA59A\n\ - add sp, 0x4\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_080FA5B4: .4byte 0x02007900\n\ -_080FA5B8: .4byte gSaveBlock1 + 0x2DD4\n\ - .syntax divided\n"); -} -#endif void sub_80FA5BC(void) { @@ -528,65 +227,65 @@ void sub_80FA648(void) gScriptResult = (gSaveBlock1.easyChatPairs[0].words[0] + gSaveBlock1.easyChatPairs[0].words[1]) & 7; } -bool8 sub_80FA670(struct EasyChatPair *a, struct EasyChatPair *b, u8 c) +static bool8 sub_80FA670(struct EasyChatPair *a, struct EasyChatPair *b, u8 c) { - switch(c) + switch (c) { case 0: - if(a->unk0_0 > b->unk0_0) + if (a->unk0_0 > b->unk0_0) return 1; - if(a->unk0_0 < b->unk0_0) + if (a->unk0_0 < b->unk0_0) return 0; - if(a->unk0_7 > b->unk0_7) + if (a->unk0_7 > b->unk0_7) return 1; - if(a->unk0_7 < b->unk0_7) + if (a->unk0_7 < b->unk0_7) return 0; break; case 1: - if(a->unk0_7 > b->unk0_7) + if (a->unk0_7 > b->unk0_7) return 1; - if(a->unk0_7 < b->unk0_7) + if (a->unk0_7 < b->unk0_7) return 0; - if(a->unk0_0 > b->unk0_0) + if (a->unk0_0 > b->unk0_0) return 1; - if(a->unk0_0 < b->unk0_0) + if (a->unk0_0 < b->unk0_0) return 0; break; case 2: - if(a->unk0_0 > b->unk0_0) + if (a->unk0_0 > b->unk0_0) return 1; - if(a->unk0_0 < b->unk0_0) + if (a->unk0_0 < b->unk0_0) return 0; - if(a->unk0_7 > b->unk0_7) + if (a->unk0_7 > b->unk0_7) return 1; - if(a->unk0_7 < b->unk0_7) + if (a->unk0_7 < b->unk0_7) return 0; - if(a->unk2 > b->unk2) + if (a->unk2 > b->unk2) return 1; - if(a->unk2 < b->unk2) + if (a->unk2 < b->unk2) return 0; - if(a->words[0] > b->words[0]) + if (a->words[0] > b->words[0]) return 1; - if(a->words[0] < b->words[0]) + if (a->words[0] < b->words[0]) return 0; - if(a->words[1] > b->words[1]) + if (a->words[1] > b->words[1]) return 1; - if(a->words[1] < b->words[1]) + if (a->words[1] < b->words[1]) return 0; return 1; } return Random() & 1; } -void sub_80FA740(struct EasyChatPair *s) +static void sub_80FA740(struct EasyChatPair *s) { u16 r4; r4 = Random() % 98; - if(r4 > 50) + if (r4 > 50) { r4 = Random() % 98; - if(r4 > 80) + if (r4 > 80) r4 = Random() % 98; } s->unk0_7 = r4 + 30; @@ -594,38 +293,38 @@ void sub_80FA740(struct EasyChatPair *s) s->unk2 = Random(); } -bool8 SB1ContainsWords(u16 *a) +static bool8 SB1ContainsWords(u16 *a) { u16 i; - for(i = 0; i < 5; i++) + for (i = 0; i < 5; i++) { - if(IsEasyChatPairEqual(a, gSaveBlock1.easyChatPairs[i].words) != 0) + if (IsEasyChatPairEqual(a, gSaveBlock1.easyChatPairs[i].words) != 0) return TRUE; } return FALSE; } -bool8 IsEasyChatPairEqual(u16 *words1, u16 *words2) +static bool8 IsEasyChatPairEqual(u16 *words1, u16 *words2) { u16 i; - for(i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { - if(*(words1++) != *(words2++)) + if (*(words1++) != *(words2++)) return FALSE; } return TRUE; } -s16 sub_80FA828(struct EasyChatPair *a, u16 b) +static s16 sub_80FA828(struct EasyChatPair *a, u16 b) { s16 i; - struct EasyChatPair *s = unk_2007900; + struct EasyChatPair *s = ARRAY_2007900; - for(i = 0; i < b; i++) + for (i = 0; i < b; i++) { - if(IsEasyChatPairEqual(a->words, s->words)) + if (IsEasyChatPairEqual(a->words, s->words)) return i; s++; } diff --git a/src/diploma.c b/src/diploma.c index 8fabe3a2f..ba7de58aa 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -1,5 +1,5 @@ #include "global.h" -#include "asm.h" +#include "diploma.h" #include "main.h" #include "menu.h" #include "palette.h" @@ -7,16 +7,10 @@ #include "rom4.h" #include "sprite.h" #include "string_util.h" +#include "strings2.h" #include "task.h" #include "text.h" - -extern u8 gDiplomaTiles[]; -extern u8 gDiplomaTilemap[]; -extern u8 gDiplomaPalettes[]; -extern u8 gStringVar1[]; -extern u8 gOtherText_NationalDex[]; -extern u8 gOtherText_HoennDex[]; -extern u8 gOtherText_DiplomaCertificationGameFreak[]; +#include "unknown_task.h" static void VBlankCB(void); static void MainCB2(void); @@ -25,6 +19,15 @@ static void Task_DiplomaWaitForKeyPress(u8); static void Task_DiplomaFadeOut(u8); static void DisplayDiplomaText(void); +static const u16 gDiplomaPalettes[][16] = +{ + INCBIN_U16("graphics/misc/diploma_national.gbapal"), + INCBIN_U16("graphics/misc/diploma_hoenn.gbapal"), +}; + +static const u8 gDiplomaTilemap[] = INCBIN_U8("graphics/misc/diploma_map.bin.lz"); +static const u8 gDiplomaTiles[] = INCBIN_U8("graphics/misc/diploma.4bpp.lz"); + static void VBlankCB(void) { LoadOam(); @@ -35,9 +38,9 @@ static void VBlankCB(void) void sub_8145D88(void) { u32 savedIme; - + SetVBlankCallback(NULL); - + REG_DISPCNT = 0; REG_BG3CNT = 0; REG_BG2CNT = 0; @@ -51,14 +54,14 @@ void sub_8145D88(void) REG_BG1VOFS = 0; REG_BG0HOFS = 0; REG_BG0VOFS = 0; - + DmaFill16(3, 0, VRAM, VRAM_SIZE); DmaFill32(3, 0, OAM, OAM_SIZE); DmaFill16(3, 0, PLTT, PLTT_SIZE); - + LZ77UnCompVram(gDiplomaTiles, (void *)VRAM); LZ77UnCompVram(gDiplomaTilemap, (void *)(VRAM + 0x3000)); - + remove_some_task(); ResetTasks(); ResetSpriteData(); @@ -69,22 +72,22 @@ void sub_8145D88(void) InitMenuWindow(&gWindowConfig_81E6CE4); DisplayDiplomaText(); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - + savedIme = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; REG_IME = savedIme; REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; - + SetVBlankCallback(VBlankCB); SetMainCallback2(MainCB2); - + REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; - REG_BG3CNT = 0x4603; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(6) | BGCNT_16COLOR | BGCNT_TXT512x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; - + CreateTask(Task_DiplomaFadeIn, 0); } @@ -98,13 +101,13 @@ static void MainCB2(void) static void Task_DiplomaFadeIn(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) gTasks[taskId].func = Task_DiplomaWaitForKeyPress; } static void Task_DiplomaWaitForKeyPress(u8 taskId) { - if(gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); gTasks[taskId].func = Task_DiplomaFadeOut; @@ -113,7 +116,7 @@ static void Task_DiplomaWaitForKeyPress(u8 taskId) static void Task_DiplomaFadeOut(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { DestroyTask(taskId); SetMainCallback2(sub_80546F0); @@ -122,7 +125,7 @@ static void Task_DiplomaFadeOut(u8 taskId) static void DisplayDiplomaText(void) { - if(sub_8090FF4()) + if (sub_8090FF4()) { REG_BG3HOFS = 256; StringCopy(gStringVar1, gOtherText_NationalDex); diff --git a/src/easy_chat.c b/src/easy_chat.c new file mode 100644 index 000000000..cc2cd7030 --- /dev/null +++ b/src/easy_chat.c @@ -0,0 +1,482 @@ +#include "global.h" +#include "easy_chat.h" +#include "data2.h" +#include "event_data.h" +#include "field_message_box.h" +#include "pokedex.h" +#include "rng.h" +#include "string_util.h" +#include "strings.h" +#include "strings2.h" +#include "text.h" + +static bool8 sub_80EB680(u16 *, u16, u16, u16); +static u16 sub_80EB9D8(void); +static u16 sub_80EB960(void); + +extern void *gEasyChatGroupWords[]; +extern const u8 gEasyChatGroupSizes[]; + +extern u16 gSpecialVar_0x8004; + +#ifdef NONMATCHING +u8 *sub_80EB3FC(u8 *dst, u16 word) { + int group, wordIndex; + u8 *src; + u16 i; + + + if (sub_80EB37C(word)) + { + return StringCopy(dst, gOtherText_ThreeQuestions); + } + + if (word != 0xFFFF) + { + group = word >> 9; + wordIndex = word & 0x1FF; + switch (group) + { + case EC_GROUP_POKEMON: // 0 + case EC_GROUP_POKEMON_2: // 21 + dst = StringCopy(dst, gSpeciesNames[wordIndex]); + break; + + case EC_GROUP_MOVE_1: // 18 + case EC_GROUP_MOVE_2: // 19 + dst = StringCopy(dst, gMoveNames[wordIndex]); + break; + + default: + src = gEasyChatGroupWords[group]; + + i = wordIndex - 1; + while (i != 0xFFFF) + { + while (*src++ != EOS) + { + } + i--; + } + dst = StringCopy(dst, src); + break; + } + } + + dst[0] = EOS; + return dst; +} +#endif + +u8 *ConvertEasyChatWordsToString(u8 *dst, u16 *words, u16 arg2, u16 arg3) { + u16 i; + u16 n; + + const u16 i1 = arg2 - 1; + + for (i = 0; i < arg3; i++) + { + u16 word; + + for (n = 0; n < i1; n++) + { + dst = sub_80EB3FC(dst, words[0]); + + if (words[0] != 0xFFFF) + { + dst[0] = CHAR_SPACE; + dst++; + } + + words++; + } + + word = words[0]; + words++; + dst = sub_80EB3FC(dst, word); + + dst[0] = 0xFE; + dst++; + } + + dst--; + dst[0] = EOS; + + return dst; +} + +u8 *sub_80EB544(u8 *dst, u16 *words, u16 arg2, u16 arg3) { + u16 i; + u16 n; + + const u16 i1 = arg2 - 1; + + for (i = 0; i < arg3; i++) + { + u16 word; + + for (n = 0; n < i1; n++) + { + dst = sub_80EB3FC(dst, words[0]); + + if (words[0] != 0xFFFF) + { + dst[0] = CHAR_SPACE; + dst++; + } + + words++; + } + + word = words[0]; + words++; + dst = sub_80EB3FC(dst, word); + + // Only difference with ConvertEasyChatWordsToString + dst[0] = (i == 0) ? 0xFE : 0xFA; + dst++; + } + + dst--; + dst[0] = EOS; + + return dst; +} + + +u16 unref_sub_80EB5E0(u16 arg0) { + u8 *chars; + u16 i; + u16 strlen; + int group, word; + + + if (arg0 == 0xFFFF) + { + return 0; + } + + group = arg0 >> 9; + word = arg0 & 0x1FF; + switch (group) + { + case EC_GROUP_POKEMON: // 0 + case EC_GROUP_POKEMON_2: // 21 + chars = (u8 *) gSpeciesNames[word]; + break; + + case EC_GROUP_MOVE_1: // 18 + case EC_GROUP_MOVE_2: // 19 + chars = gMoveNames[word]; + break; + + default: + chars = gEasyChatGroupWords[group]; + + i = word - 1; + while (i != 0xFFFF) + { + while (*chars++ != EOS) + { + } + i--; + } + break; + } + + strlen = 0; + while (*chars != EOS) + { + chars++; + strlen += 1; + } + + return strlen; +} + +static bool8 sub_80EB680(u16 *arg0, u16 arg1, u16 arg2, u16 arg3) { + return FALSE; +} + +void unref_sub_80EB684(u8 arg0, u16 arg1) { + u16 *ptr; + u16 c; + + // FIXME: find actual tv shows used + switch (arg0) + { + case 5: + c = 6; + ptr = (u16*)((void *)&gSaveBlock1.tvShows[arg1] + 0x04); + break; + case 7: + c = 2; + ptr = (u16*)((void *)&gSaveBlock1.tvShows[arg1] + 0x1C); + break; + case 8: + c = 1; + ptr = (u16*)((void *)&gSaveBlock1.tvShows[arg1] + 0x02); + break; + + default: + return; + } + + c -= 1; + while (c != 0xFFFF) + { + *ptr = -1; + ptr++; + c -= 1; + } +} + +void sub_80EB6FC(u16 *arg0, u16 arg1) { + u16 i; + + for (i = arg1 - 1; i != 0xFFFF; i--) + { + *arg0 = 0xFFFF; + arg0++; + } + +} + +u16 sub_80EB72C(u16 group) { + u16 local1; + + local1 = Random() % gEasyChatGroupSizes[group]; + + if (group == EC_GROUP_POKEMON || + group == EC_GROUP_POKEMON_2 || + group == EC_GROUP_MOVE_1 || + group == EC_GROUP_MOVE_2) + { + local1 = ((u16 *) gEasyChatGroupWords[group])[local1]; + } + + + return ((group & 0x7F) << 9) | (local1 & 0x1FF); +} + +u16 sub_80EB784(u16 group) { + if (!sub_80EAD7C(group)) + { + return -1; + } + + if (group != EC_GROUP_POKEMON) + { + if (group == EC_GROUP_TRENDY_SAYING) + { + return sub_80EB960(); + } + } + else + { + return sub_80EB9D8(); + } + + return sub_80EB72C(group); +} + +void sub_80EB7C4(void) { + u16 *words; + u16 arg1, arg2; + + + switch (gSpecialVar_0x8004) + { + case 0: + words = gSaveBlock1.unk2B1C; + arg1 = 2; + arg2 = 2; + break; + + case 1: + words = gSaveBlock1.unk2B28; + if (sub_80EB680(gSaveBlock1.unk2B28, 3, 2, 20)) + { + arg1 = 2; + arg2 = 3; + } + else + { + arg1 = 3; + arg2 = 2; + } + break; + + case 2: + words = gSaveBlock1.unk2B34; + arg1 = 3; + arg2 = 2; + break; + + case 3: + words = gSaveBlock1.unk2B40; + arg1 = 3; + arg2 = 2; + break; + + default: + return; + } + + ConvertEasyChatWordsToString(gStringVar4, words, arg1, arg2); + ShowFieldAutoScrollMessage(gStringVar4); +} + +void sub_80EB83C(void) { + u16 group, local2; + + if (Random() & 1) + { + group = EC_GROUP_HOBBIES; + } + else + { + group = EC_GROUP_LIFESTYLE; + } + + local2 = sub_80EB784(group); + sub_80EB3FC(gStringVar2, local2); +} + +u8 sub_80EB868(u8 arg0) { + int offset; + int index; + + index = arg0 / 8; + offset = arg0 & 7; + return (gSaveBlock1.unk2D8C[index] >> offset) & 1; +} + +void sub_80EB890(u8 arg0) { + int offset; + int index; + + if (arg0 > 32) + { + return; + } + + index = arg0 / 8; + offset = arg0 & 7; + gSaveBlock1.unk2D8C[index] |= 1 << offset; +} + +u8 sub_80EB8C0(void) { + u8 i, retval; + + i = 0; + retval = 0; + for (; i < 33; i++) + { + if (sub_80EB868(i)) + { + retval += 1; + } + } + + return retval; +} + +u16 sub_80EB8EC(void) { + u16 i; + u16 local1, local2; + + local1 = sub_80EB8C0(); + if (local1 == 33) + { + return -1; + } + + local2 = Random() % (33 - local1); + + for (i = 0; i <= 0x20; i++) + { + if (sub_80EB868(i) == 0) + { + if (local2 == 0) + { + sub_80EB890(i); + return (i & 0x1FF) | 0x2800; + } + + local2--; + } + } + + return -1; +} + +static u16 sub_80EB960(void) { + u16 i; + u16 local1; + + local1 = sub_80EB8C0(); + if (local1 == 0) + { + return -1; + } + + local1 = Random() % local1; + + for (i = 0; i <= 0x20; i++) + { + if (sub_80EB868(i)) + { + if (local1 == 0) + { + return (i & 0x1FF) | 0x2800; + } + + local1--; + } + } + + return -1; +} + +u8 sub_80EB9C8(void) { + return IsNationalPokedexEnabled(); +} + +static u16 sub_80EB9D8(void) { + u16 *speciesList; + u16 local1; + u16 i; + + local1 = sub_80EAE88(0); + + if (local1 == 0) + { + return -1; + } + + local1 = Random() % local1; + speciesList = (u16 *) gEasyChatGroupWords[EC_GROUP_POKEMON]; + + for (i = 0; i < gEasyChatGroupSizes[EC_GROUP_POKEMON]; i++) + { + const u16 dexNum = SpeciesToNationalPokedexNum(*speciesList); + + const u8 local2 = GetNationalPokedexFlag(dexNum, 0); + + if (local2) + { + if (local1 == 0) + { + return *speciesList & 0x1FF; + } + + local1--; + } + + speciesList++; + } + + return -1; +} + diff --git a/src/egg_hatch.c b/src/egg_hatch.c new file mode 100644 index 000000000..32fbe1547 --- /dev/null +++ b/src/egg_hatch.c @@ -0,0 +1,52 @@ +#include "global.h" +#include "pokemon.h" + +void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp) { + u16 species; + u32 personality, pokerus; + u8 i, friendship, language, gameMet, markings; + u16 moves[4]; + u32 ivs[6]; + + + species = GetMonData(egg, MON_DATA_SPECIES); + + for (i = 0; i < 4; i++) + { + moves[i] = GetMonData(egg, MON_DATA_MOVE1 + i); + } + + personality = GetMonData(egg, MON_DATA_PERSONALITY); + + for (i = 0; i < 6; i++) + { + ivs[i] = GetMonData(egg, MON_DATA_HP_IV + i); + } + + gameMet = GetMonData(egg, MON_DATA_MET_GAME); + markings = GetMonData(egg, MON_DATA_MARKINGS); + pokerus = GetMonData(egg, MON_DATA_POKERUS); + + CreateMon(temp, species, 5, 32, TRUE, personality, 0, 0); + + for (i = 0; i < 4; i++) + { + SetMonData(temp, MON_DATA_MOVE1 + i, (const u8 *) &moves[i]); + } + + for (i = 0; i < 6; i++) + { + SetMonData(temp, MON_DATA_HP_IV + i, (const u8 *) &ivs[i]); + } + + language = GAME_LANGUAGE; + SetMonData(temp, MON_DATA_LANGUAGE, &language); + SetMonData(temp, MON_DATA_MET_GAME, &gameMet); + SetMonData(temp, MON_DATA_MARKINGS, &markings); + + friendship = 120; + SetMonData(temp, MON_DATA_FRIENDSHIP, &friendship); + SetMonData(temp, MON_DATA_POKERUS, (const u8 *) &pokerus); + + *egg = *temp; +} diff --git a/src/event_data.c b/src/event_data.c new file mode 100644 index 000000000..c6aecf13c --- /dev/null +++ b/src/event_data.c @@ -0,0 +1,168 @@ +#include "global.h" +#include "event_data.h" +#include "pokedex.h" + +#define TEMP_FLAGS_SIZE 0x4 +#define TEMP_UPPER_FLAGS_SIZE 0x8 +#define TEMP_VARS_SIZE 0x20 + +extern u8 gUnknown_0202E8E2[16]; +extern u16 *gSpecialVars[]; + +void InitEventData(void) +{ + memset(gSaveBlock1.flags, 0, sizeof(gSaveBlock1.flags)); + memset(gSaveBlock1.vars, 0, sizeof(gSaveBlock1.vars)); + memset(gUnknown_0202E8E2, 0, sizeof(gUnknown_0202E8E2)); +} + +void ClearTempFieldEventData(void) +{ + memset(gSaveBlock1.flags, 0, TEMP_FLAGS_SIZE); + memset(gSaveBlock1.vars, 0, TEMP_VARS_SIZE); + FlagReset(SYS_ENC_UP_ITEM); + FlagReset(SYS_ENC_DOWN_ITEM); + FlagReset(SYS_USE_STRENGTH); + FlagReset(SYS_CTRL_OBJ_DELETE); +} + +// probably had different flag splits at one point. +void ClearUpperFlags(void) +{ + memset(gSaveBlock1.flags + 0x118, 0, TEMP_UPPER_FLAGS_SIZE); +} + +void DisableNationalPokedex(void) +{ + u16 *nationalDexVar = GetVarPointer(VAR_NATIONAL_DEX); + gSaveBlock2.pokedex.nationalMagic = 0; + *nationalDexVar = 0; + FlagReset(SYS_NATIONAL_DEX); +} + +void EnableNationalPokedex(void) +{ + u16 *nationalDexVar = GetVarPointer(VAR_NATIONAL_DEX); + gSaveBlock2.pokedex.nationalMagic = 0xDA; + *nationalDexVar = 0x302; + FlagSet(SYS_NATIONAL_DEX); + gSaveBlock2.pokedex.unknown1 = 1; + gSaveBlock2.pokedex.order = 0; + sub_808C0A0(); +} + +bool32 IsNationalPokedexEnabled(void) +{ + if (gSaveBlock2.pokedex.nationalMagic == 0xDA && VarGet(VAR_NATIONAL_DEX) == 0x302 && FlagGet(SYS_NATIONAL_DEX)) + return TRUE; + else + return FALSE; +} + +void DisableMysteryGift(void) +{ + FlagReset(SYS_EXDATA_ENABLE); +} + +void EnableMysteryGift(void) +{ + FlagSet(SYS_EXDATA_ENABLE); +} + +bool32 IsMysteryGiftEnabled(void) +{ + return FlagGet(SYS_EXDATA_ENABLE); +} + +void DisableResetRTC(void) +{ + VarSet(VAR_RESET_RTC_ENABLE, 0); + FlagReset(SYS_RESET_RTC_ENABLE); +} + +void EnableResetRTC(void) +{ + VarSet(VAR_RESET_RTC_ENABLE, 0x920); + FlagSet(SYS_RESET_RTC_ENABLE); +} + +bool32 CanResetRTC(void) +{ + if (FlagGet(SYS_RESET_RTC_ENABLE) && VarGet(VAR_RESET_RTC_ENABLE) == 0x920) + return TRUE; + else + return FALSE; +} + +u16 *GetVarPointer(u16 id) +{ + if (id < 0x4000) + return NULL; + + if ((s16)id >= 0) + return &gSaveBlock1.vars[id - 0x4000]; + + return gSpecialVars[id - 0x8000]; +} + +u16 VarGet(u16 id) +{ + u16 *ptr = GetVarPointer(id); + if (!ptr) + return id; + return *ptr; +} + +bool8 VarSet(u16 id, u16 value) +{ + u16 *ptr = GetVarPointer(id); + if (!ptr) + return FALSE; + *ptr = value; + return TRUE; +} + +u8 VarGetFieldObjectGraphicsId(u8 id) +{ + return VarGet(0x4010 + id); +} + +u8 *GetFlagPointer(u16 id) +{ + if (id == 0) + return 0; + + if (id < 0x4000) + return &gSaveBlock1.flags[id / 8]; + + return &gUnknown_0202E8E2[(id - 0x4000) / 8]; +} + +u8 FlagSet(u16 id) +{ + u8 *ptr = GetFlagPointer(id); + if (ptr) + *ptr |= 1 << (id & 7); + return 0; +} + +u8 FlagReset(u16 id) +{ + u8 *ptr = GetFlagPointer(id); + if (ptr) + *ptr &= ~(1 << (id & 7)); + return 0; +} + +bool8 FlagGet(u16 id) +{ + u8 *ptr = GetFlagPointer(id); + + if (!ptr) + return FALSE; + + if (!(((*ptr) >> (id & 7)) & 1)) + return FALSE; + + return TRUE; +} diff --git a/src/field_camera.c b/src/field_camera.c index c55d8e2a3..1aed1549b 100644 --- a/src/field_camera.c +++ b/src/field_camera.c @@ -1,14 +1,12 @@ #include "global.h" #include "field_camera.h" -#include "asm.h" #include "berry.h" #include "field_player_avatar.h" -#include "asm_fieldmap.h" +#include "fieldmap.h" +#include "rotating_gate.h" #include "sprite.h" #include "text.h" -extern u16 gBGTilemapBuffers[4][0x400]; - extern u8 gUnknown_0202E854; @@ -27,16 +25,6 @@ extern s16 gUnknown_0300059A; extern u8 gUnknown_0300059C; extern void (*gUnknown_030005A0)(void); -struct CameraSomething -{ - void (*callback)(struct CameraSomething *); - u32 unk4; - s32 unk8; - s32 unkC; - s32 unk10; - s32 unk14; -}; - extern struct CameraSomething gUnknown_03004880; extern u16 gUnknown_03004898; extern u16 gUnknown_0300489C; @@ -91,8 +79,8 @@ void sub_8057A58(void) *gBGVOffsetRegs[2] = gUnknown_03000590.unk1 + gUnknown_0300059A + 8; *gBGHOffsetRegs[3] = gUnknown_03000590.unk0 + gUnknown_03000598; *gBGVOffsetRegs[3] = gUnknown_03000590.unk1 + gUnknown_0300059A + 8; - - if(gUnknown_03000590.unk4) + + if (gUnknown_03000590.unk4) { DmaCopy16(3, gBGTilemapBuffers[1], (void *)(VRAM + 0xE800), 0x800); DmaCopy16(3, gBGTilemapBuffers[2], (void *)(VRAM + 0xE000), 0x800); @@ -119,17 +107,17 @@ static void DrawWholeMapViewInternal(int x, int y, struct MapData *mapData) u8 j; u32 r6; u8 temp; - - for(i = 0; i < 32; i += 2) + + for (i = 0; i < 32; i += 2) { temp = gUnknown_03000590.unk3 + i; - if(temp >= 32) + if (temp >= 32) temp -= 32; r6 = temp * 32; - for(j = 0; j < 32; j += 2) + for (j = 0; j < 32; j += 2) { temp = gUnknown_03000590.unk2 + j; - if(temp >= 32) + if (temp >= 32) temp -= 32; DrawMetatileAt(mapData, r6 + temp, x + j / 2, y + i / 2); } @@ -139,14 +127,14 @@ static void DrawWholeMapViewInternal(int x, int y, struct MapData *mapData) static void RedrawMapSlicesForCameraUpdate(struct UnknownStruct *a, int x, int y) { struct MapData *mapData = gMapHeader.mapData; - - if(x > 0) + + if (x > 0) RedrawMapSliceWest(a, mapData); - if(x < 0) + if (x < 0) RedrawMapSliceEast(a, mapData); - if(y > 0) + if (y > 0) RedrawMapSliceNorth(a, mapData); - if(y < 0) + if (y < 0) RedrawMapSliceSouth(a, mapData); a->unk4 = TRUE; } @@ -156,15 +144,15 @@ static void RedrawMapSliceNorth(struct UnknownStruct *a, struct MapData *mapData u8 i; u8 temp; u32 r7; - + temp = a->unk3 + 28; - if(temp >= 32) + if (temp >= 32) temp -= 32; r7 = temp * 32; - for(i = 0; i < 32; i += 2) + for (i = 0; i < 32; i += 2) { temp = a->unk2 + i; - if(temp >= 32) + if (temp >= 32) temp -= 32; DrawMetatileAt(mapData, r7 + temp, gSaveBlock1.pos.x + i / 2, gSaveBlock1.pos.y + 14); } @@ -175,11 +163,11 @@ static void RedrawMapSliceSouth(struct UnknownStruct *a, struct MapData *mapData u8 i; u8 temp; u32 r7 = a->unk3 * 32; - - for(i = 0; i < 32; i += 2) + + for (i = 0; i < 32; i += 2) { temp = a->unk2 + i; - if(temp >= 32) + if (temp >= 32) temp -= 32; DrawMetatileAt(mapData, r7 + temp, gSaveBlock1.pos.x + i / 2, gSaveBlock1.pos.y); } @@ -190,11 +178,11 @@ static void RedrawMapSliceEast(struct UnknownStruct *a, struct MapData *mapData) u8 i; u8 temp; u32 r6 = a->unk2; - - for(i = 0; i < 32; i += 2) + + for (i = 0; i < 32; i += 2) { temp = a->unk3 + i; - if(temp >= 32) + if (temp >= 32) temp -= 32; DrawMetatileAt(mapData, temp * 32 + r6, gSaveBlock1.pos.x, gSaveBlock1.pos.y + i / 2); } @@ -205,13 +193,13 @@ static void RedrawMapSliceWest(struct UnknownStruct *a, struct MapData *mapData) u8 i; u8 temp; u8 r5 = a->unk2 + 28; - - if(r5 >= 32) + + if (r5 >= 32) r5 -= 32; - for(i = 0; i < 32; i += 2) + for (i = 0; i < 32; i += 2) { temp = a->unk3 + i; - if(temp >= 32) + if (temp >= 32) temp -= 32; DrawMetatileAt(mapData, temp * 32 + r5, gSaveBlock1.pos.x + 14, gSaveBlock1.pos.y + i / 2); } @@ -220,8 +208,8 @@ static void RedrawMapSliceWest(struct UnknownStruct *a, struct MapData *mapData) void CurrentMapDrawMetatileAt(int a, int b) { int offset = MapPosToBgTilemapOffset(&gUnknown_03000590, a, b); - - if(offset >= 0) + + if (offset >= 0) { DrawMetatileAt(gMapHeader.mapData, offset, a, b); gUnknown_03000590.unk4 = TRUE; @@ -231,8 +219,8 @@ void CurrentMapDrawMetatileAt(int a, int b) void DrawDoorMetatileAt(int x, int y, u16 *arr) { int offset = MapPosToBgTilemapOffset(&gUnknown_03000590, x, y); - - if(offset >= 0) + + if (offset >= 0) { DrawMetatile(1, arr, offset); gUnknown_03000590.unk4 = TRUE; @@ -243,10 +231,10 @@ static void DrawMetatileAt(struct MapData *mapData, u16 b, int c, int d) { u16 metatileId = MapGridGetMetatileIdAt(c, d); u16 *metatiles; - - if(metatileId > 1024) + + if (metatileId > 1024) metatileId = 0; - if(metatileId < 512) + if (metatileId < 512) metatiles = mapData->primaryTileset->metatiles; else { @@ -258,56 +246,56 @@ static void DrawMetatileAt(struct MapData *mapData, u16 b, int c, int d) static void DrawMetatile(s32 a, u16 *b, u16 c) { - switch(a) + switch (a) { - case 2: - gBGTilemapBuffers[3][c] = b[0]; - gBGTilemapBuffers[3][c + 1] = b[1]; - gBGTilemapBuffers[3][c + 0x20] = b[2]; - gBGTilemapBuffers[3][c + 0x21] = b[3]; - - gBGTilemapBuffers[2][c] = 0; - gBGTilemapBuffers[2][c + 1] = 0; - gBGTilemapBuffers[2][c + 0x20] = 0; - gBGTilemapBuffers[2][c + 0x21] = 0; - - gBGTilemapBuffers[1][c] = b[4]; - gBGTilemapBuffers[1][c + 1] = b[5]; - gBGTilemapBuffers[1][c + 0x20] = b[6]; - gBGTilemapBuffers[1][c + 0x21] = b[7]; - break; - case 1: - gBGTilemapBuffers[3][c] = b[0]; - gBGTilemapBuffers[3][c + 1] = b[1]; - gBGTilemapBuffers[3][c + 0x20] = b[2]; - gBGTilemapBuffers[3][c + 0x21] = b[3]; - - gBGTilemapBuffers[2][c] = b[4]; - gBGTilemapBuffers[2][c + 1] = b[5]; - gBGTilemapBuffers[2][c + 0x20] = b[6]; - gBGTilemapBuffers[2][c + 0x21] = b[7]; - - gBGTilemapBuffers[1][c] = 0; - gBGTilemapBuffers[1][c + 1] = 0; - gBGTilemapBuffers[1][c + 0x20] = 0; - gBGTilemapBuffers[1][c + 0x21] = 0; - break; - case 0: - gBGTilemapBuffers[3][c] = 0x3014; - gBGTilemapBuffers[3][c + 1] = 0x3014; - gBGTilemapBuffers[3][c + 0x20] = 0x3014; - gBGTilemapBuffers[3][c + 0x21] = 0x3014; - - gBGTilemapBuffers[2][c] = b[0]; - gBGTilemapBuffers[2][c + 1] = b[1]; - gBGTilemapBuffers[2][c + 0x20] = b[2]; - gBGTilemapBuffers[2][c + 0x21] = b[3]; - - gBGTilemapBuffers[1][c] = b[4]; - gBGTilemapBuffers[1][c + 1] = b[5]; - gBGTilemapBuffers[1][c + 0x20] = b[6]; - gBGTilemapBuffers[1][c + 0x21] = b[7]; - break; + case 2: + gBGTilemapBuffers[3][c] = b[0]; + gBGTilemapBuffers[3][c + 1] = b[1]; + gBGTilemapBuffers[3][c + 0x20] = b[2]; + gBGTilemapBuffers[3][c + 0x21] = b[3]; + + gBGTilemapBuffers[2][c] = 0; + gBGTilemapBuffers[2][c + 1] = 0; + gBGTilemapBuffers[2][c + 0x20] = 0; + gBGTilemapBuffers[2][c + 0x21] = 0; + + gBGTilemapBuffers[1][c] = b[4]; + gBGTilemapBuffers[1][c + 1] = b[5]; + gBGTilemapBuffers[1][c + 0x20] = b[6]; + gBGTilemapBuffers[1][c + 0x21] = b[7]; + break; + case 1: + gBGTilemapBuffers[3][c] = b[0]; + gBGTilemapBuffers[3][c + 1] = b[1]; + gBGTilemapBuffers[3][c + 0x20] = b[2]; + gBGTilemapBuffers[3][c + 0x21] = b[3]; + + gBGTilemapBuffers[2][c] = b[4]; + gBGTilemapBuffers[2][c + 1] = b[5]; + gBGTilemapBuffers[2][c + 0x20] = b[6]; + gBGTilemapBuffers[2][c + 0x21] = b[7]; + + gBGTilemapBuffers[1][c] = 0; + gBGTilemapBuffers[1][c + 1] = 0; + gBGTilemapBuffers[1][c + 0x20] = 0; + gBGTilemapBuffers[1][c + 0x21] = 0; + break; + case 0: + gBGTilemapBuffers[3][c] = 0x3014; + gBGTilemapBuffers[3][c + 1] = 0x3014; + gBGTilemapBuffers[3][c + 0x20] = 0x3014; + gBGTilemapBuffers[3][c + 0x21] = 0x3014; + + gBGTilemapBuffers[2][c] = b[0]; + gBGTilemapBuffers[2][c + 1] = b[1]; + gBGTilemapBuffers[2][c + 0x20] = b[2]; + gBGTilemapBuffers[2][c + 0x21] = b[3]; + + gBGTilemapBuffers[1][c] = b[4]; + gBGTilemapBuffers[1][c + 1] = b[5]; + gBGTilemapBuffers[1][c + 0x20] = b[6]; + gBGTilemapBuffers[1][c + 0x21] = b[7]; + break; } } @@ -315,25 +303,25 @@ static s32 MapPosToBgTilemapOffset(struct UnknownStruct *a, s32 x, s32 y) { x -= gSaveBlock1.pos.x; x *= 2; - if(x >= 32 || x < 0) + if (x >= 32 || x < 0) return -1; x = x + a->unk2; - if(x >= 32) + if (x >= 32) x -= 32; - + y = (y - gSaveBlock1.pos.y) * 2; - if(y >= 32 || y < 0) + if (y >= 32 || y < 0) return -1; y = y + a->unk3; - if(y >= 32) + if (y >= 32) y -= 32; - + return y * 32 + x; } static void CameraUpdateCallback(struct CameraSomething *a) { - if(a->unk4 != 0) + if (a->unk4 != 0) { a->unk8 = gSprites[a->unk4].data2; a->unkC = gSprites[a->unk4].data3; @@ -352,7 +340,7 @@ void ResetCameraUpdateInfo(void) u32 InitCameraUpdateCallback(u8 a) { - if(gUnknown_03004880.unk4 != 0) + if (gUnknown_03004880.unk4 != 0) DestroySprite(&gSprites[gUnknown_03004880.unk4]); gUnknown_03004880.unk4 = AddCameraObject(a); gUnknown_03004880.callback = CameraUpdateCallback; @@ -367,8 +355,8 @@ void CameraUpdate(void) int r1; int r7; int r8; - - if(gUnknown_03004880.callback != NULL) + + if (gUnknown_03004880.callback != NULL) gUnknown_03004880.callback(&gUnknown_03004880); r7 = gUnknown_03004880.unk8; r8 = gUnknown_03004880.unkC; @@ -376,43 +364,43 @@ void CameraUpdate(void) deltaY = 0; r1 = gUnknown_03004880.unk10; r0 = gUnknown_03004880.unk14; - - - if(r1 == 0 && r7 != 0) + + + if (r1 == 0 && r7 != 0) { - if(r7 > 0) + if (r7 > 0) deltaX = 1; else deltaX = -1; } - if(r0 == 0 && r8 != 0) + if (r0 == 0 && r8 != 0) { - if(r8 > 0) + if (r8 > 0) deltaY = 1; else deltaY = -1; } - if(r1 != 0 && r1 == -r7) + if (r1 != 0 && r1 == -r7) { - if(r7 > 0) + if (r7 > 0) deltaX = 1; else deltaX = -1; } - if(r0 != 0 && r0 == -r8) + if (r0 != 0 && r0 == -r8) { - if(r8 > 0) + if (r8 > 0) deltaX = 1; else deltaX = -1; } - + gUnknown_03004880.unk10 += r7; - gUnknown_03004880.unk10 = gUnknown_03004880.unk10 - 16 * (gUnknown_03004880.unk10 / 16); + gUnknown_03004880.unk10 = gUnknown_03004880.unk10 - 16 * (gUnknown_03004880.unk10 / 16); gUnknown_03004880.unk14 += r8; gUnknown_03004880.unk14 = gUnknown_03004880.unk14 - 16 * (gUnknown_03004880.unk14 / 16); - - if(deltaX != 0 || deltaY != 0) + + if (deltaX != 0 || deltaY != 0) { CameraMove(deltaX, deltaY); UpdateFieldObjectsForCameraUpdate(deltaX, deltaY); @@ -421,7 +409,7 @@ void CameraUpdate(void) tilemap_move_something(&gUnknown_03000590, deltaX * 2, deltaY * 2); RedrawMapSlicesForCameraUpdate(&gUnknown_03000590, deltaX * 2, deltaY * 2); } - + coords8_add(&gUnknown_03000590, r7, r8); gUnknown_0300489C -= r7; gUnknown_03004898 -= r8; @@ -467,7 +455,7 @@ void UpdateCameraPanning(void) static void CameraPanningCB_PanAhead(void) { u8 var; - + if (gUnknown_0202E854 == 0) { InstallCameraPanAheadCallback(); @@ -484,7 +472,7 @@ static void CameraPanningCB_PanAhead(void) { gUnknown_0300059C = 0; } - + var = player_get_direction_upper_nybble(); if (var == 2) { diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c new file mode 100644 index 000000000..2d8140be5 --- /dev/null +++ b/src/field_control_avatar.c @@ -0,0 +1,875 @@ +#include "global.h" +#include "field_control_avatar.h" +#include "battle_setup.h" +#include "bike.h" +#include "coord_event_weather.h" +#include "daycare.h" +#include "event_data.h" +#include "field_fadetransition.h" +#include "field_player_avatar.h" +#include "field_poison.h" +#include "field_specials.h" +#include "fieldmap.h" +#include "flags.h" +#include "item_menu.h" +#include "metatile_behavior.h" +#include "rom4.h" +#include "safari_zone.h" +#include "script.h" +#include "secret_base.h" +#include "songs.h" +#include "sound.h" +#include "start_menu.h" +#include "trainer_see.h" +#include "vars.h" +#include "wild_encounter.h" + +struct Coords32 +{ + s32 x; + s32 y; +}; + +extern u16 gScriptLastTalked; +extern u16 gScriptFacing; +extern struct LinkPlayerMapObject gLinkPlayerMapObjects[]; +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u8 gUnknown_0202E8C0; +extern u16 gUnknown_0202E8C2; + +//scripts +extern u8 gUnknown_081A2C51[]; +extern u8 gUnknown_0815281E[]; +extern u8 gUnknown_08152C39[]; +extern u8 gUnknown_0815F36C[]; +extern u8 gUnknown_0815F43A[]; +extern u8 gUnknown_081A0009[]; +extern u8 gUnknown_081C6C02[]; +extern u8 HiddenItemScript[]; +extern u8 Event_TV[]; +extern u8 gUnknown_081A0009[]; +extern u8 ClosedSootopolisGymDoorScript[]; +extern u8 gUnknown_081A4363[]; +extern u8 gUnknown_081C346A[]; +extern u8 gUnknown_081616E1[]; +extern u8 Event_WorldMap[]; +extern u8 Event_RunningShoesManual[]; +extern u8 PictureBookShelfScript[]; +extern u8 BookshelfScript[]; +extern u8 PokemonCenterBookshelfScript[]; +extern u8 VaseScript[]; +extern u8 TrashCanScript[]; +extern u8 ShopShelfScript[]; +extern u8 BlueprintScript[]; +extern u8 gUnknown_0815F36C[]; +extern u8 gUnknown_0815F43A[]; +extern u8 gUnknown_0815F523[]; +extern u8 gUnknown_0815F528[]; +extern u8 UseSurfScript[]; +extern u8 UseWaterfallScript[]; +extern u8 CannotUseWaterfallScript[]; +extern u8 UseDiveScript[]; +extern u8 UnderwaterUseDiveScript[]; +extern u8 GraniteCave_B1F_EventScript_1C6BC5[]; +extern u8 gUnknown_081A14B8[]; +extern u8 Event_EggHatch[]; +extern u8 gUnknown_0815FD0D[]; +extern u8 gUnknown_081C6BDE[]; + +static void player_get_pos_to_and_height(struct MapPosition *); +static void player_get_next_pos_and_height(struct MapPosition *); +static u16 cur_mapdata_block_role_at_player_pos(int); +static bool8 sub_80681F0(struct MapPosition *position, u16 b, u8 c); +static u8 *TryGetScriptOnPressingA(struct MapPosition *position, u8 b, u8 c); +static u8 *sub_8068364(struct MapPosition *, u8, u8); +static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *, u8, u8 c); +static u8 *sub_8068500(struct MapPosition *, u8, u8); +static u8 *TryGetFieldMoveScript(struct MapPosition *, u8, u8); +static bool32 sub_8068770(void); +static bool32 sub_80687A4(void); +static bool8 sub_80687E4(struct MapPosition *, u16, u16); +static void happiness_algorithm_step(void); +static bool8 overworld_poison_step(void); +static bool8 is_it_battle_time_3(u16); +static bool8 mapheader_run_first_tag2_script_list_match_conditionally(struct MapPosition *, u16, u8); +static bool8 sub_8068B30(u16); +static bool8 is_non_stair_warp_tile(u16, u8); +static s8 map_warp_check_packed(struct MapHeader *, struct MapPosition *); +static void sub_8068C30(struct MapHeader *, s8, struct MapPosition *); +static bool8 map_warp_consider_2_to_inside(struct MapPosition *, u16, u8); +static s8 map_warp_check(struct MapHeader *, u16, u16, u8); +static u8 *mapheader_trigger_activate_at(struct MapHeader *, u16, u16, u8); +static struct BgEvent *FindInvisibleMapObjectByPosition(struct MapHeader *, u16, u16, u8); + +void FieldClearPlayerInput(struct FieldInput *input) +{ + input->pressedAButton = 0; + input->input_field_0_1 = 0; + input->pressedStartButton = 0; + input->pressedSelectButton = 0; + input->input_field_0_4 = 0; + input->input_field_0_5 = 0; + input->input_field_0_6 = 0; + input->pressedBButton = 0; + input->input_field_1_0 = 0; + input->input_field_1_1 = 0; + input->input_field_1_2 = 0; + input->input_field_1_3 = 0; + input->dpadDirection = 0; +} + +void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys) +{ + u8 r6 = gPlayerAvatar.running1; + u8 r9 = gPlayerAvatar.running2; + bool8 forcedMove = MetatileBehavior_IsMoveTile(cur_mapdata_block_role_at_player_pos(r9)); + + if ((r6 == 2 && forcedMove == FALSE) || r6 == 0) + { + if (GetPlayerSpeed() != 4) + { + if (newKeys & START_BUTTON) + input->pressedStartButton = TRUE; + if (newKeys & SELECT_BUTTON) + input->pressedSelectButton = TRUE; + if (newKeys & A_BUTTON) + input->pressedAButton = TRUE; + if (newKeys & B_BUTTON) + input->pressedBButton = TRUE; + } + if (heldKeys & (DPAD_UP | DPAD_DOWN | DPAD_LEFT | DPAD_RIGHT)) + { + input->input_field_0_4 = TRUE; + input->input_field_0_5 = TRUE; + } + } + if (forcedMove == FALSE) + { + if (r6 == 2 && r9 == 2) + input->input_field_0_6 = TRUE; + if (forcedMove == FALSE && r6 == 2) + input->input_field_0_1 = TRUE; + } + if (heldKeys & DPAD_UP) + input->dpadDirection = DIR_NORTH; + else if (heldKeys & DPAD_DOWN) + input->dpadDirection = DIR_SOUTH; + else if (heldKeys & DPAD_LEFT) + input->dpadDirection = DIR_WEST; + else if (heldKeys & DPAD_RIGHT) + input->dpadDirection = DIR_EAST; +} + +int sub_8068024(struct FieldInput *input) +{ + struct MapPosition position; + u8 r6; + u16 r4; + + r6 = player_get_direction_lower_nybble(); + player_get_pos_to_and_height(&position); + r4 = MapGridGetMetatileBehaviorAt(position.x, position.y); + if (CheckTrainers() == TRUE) + return TRUE; + if (mapheader_run_first_tag2_script_list_match() == 1) + return TRUE; + if (input->pressedBButton && sub_80687A4() == 1) + return TRUE; + if (input->input_field_0_6) + { + IncrementGameStat(5); + if (sub_80687E4(&position, r4, r6) == 1) + return TRUE; + } + if (input->input_field_0_1 && is_it_battle_time_3(r4) == 1) + return TRUE; + if (input->input_field_0_4 && input->dpadDirection == r6) + { + if (mapheader_run_first_tag2_script_list_match_conditionally(&position, r4, r6) == 1) + return TRUE; + } + player_get_next_pos_and_height(&position); + r4 = MapGridGetMetatileBehaviorAt(position.x, position.y); + if (input->pressedAButton && sub_80681F0(&position, r4, r6) == 1) + return TRUE; + if (input->input_field_0_5 && input->dpadDirection == r6) + { + if (map_warp_consider_2_to_inside(&position, r4, r6) == 1) + return TRUE; + } + if (input->pressedAButton && sub_8068770() == 1) + return TRUE; + if (input->pressedStartButton) + { + PlaySE(SE_WIN_OPEN); + sub_8071310(); + return TRUE; + } + if (input->pressedSelectButton && sub_80A6D1C() == 1) + return TRUE; + return FALSE; +} + +static void player_get_pos_to_and_height(struct MapPosition *position) +{ + PlayerGetDestCoords(&position->x, &position->y); + position->height = PlayerGetZCoord(); +} + +static void player_get_next_pos_and_height(struct MapPosition *position) +{ + s16 x, y; + + GetXYCoordsOneStepInFrontOfPlayer(&position->x, &position->y); + PlayerGetDestCoords(&x, &y); + if (MapGridGetZCoordAt(x, y) != 0) + position->height = PlayerGetZCoord(); + else + position->height = 0; +} + +static u16 cur_mapdata_block_role_at_player_pos(int unused) +{ + s16 x, y; + + PlayerGetDestCoords(&x, &y); + return MapGridGetMetatileBehaviorAt(x, y); +} + +static bool8 sub_80681F0(struct MapPosition *position, u16 b, u8 c) +{ + u8 *script = TryGetScriptOnPressingA(position, b, c); + + if (script == NULL) + return FALSE; + + if (script != gUnknown_0815281E + && script != gUnknown_08152C39 + && script != gUnknown_0815F36C + && script != gUnknown_0815F43A + && script != gUnknown_081A0009) + PlaySE(5); + + ScriptContext1_SetupScript(script); + return TRUE; +} + +static u8 *TryGetScriptOnPressingA(struct MapPosition *position, u8 b, u8 c) +{ + u8 *script; + + script = sub_8068364(position, b, c); + if (script != NULL) + return script; + script = TryGetInvisibleMapObjectScript(position, b, c); + if (script != NULL) + return script; + script = sub_8068500(position, b, c); + if (script != NULL) + return script; + script = TryGetFieldMoveScript(position, b, c); + if (script != NULL) + return script; + + return NULL; +} + +u8 *sub_80682A8(struct MapPosition *position, u8 unused, u8 c) +{ + u8 r3; + s32 i; + + if (!MetatileBehavior_IsCounter(MapGridGetMetatileBehaviorAt(position->x, position->y))) + r3 = GetFieldObjectIdByXYZ(position->x, position->y, position->height); + else + r3 = GetFieldObjectIdByXYZ(position->x + gUnknown_0821664C[c].x, position->y + gUnknown_0821664C[c].y, position->height); + if (r3 == 16 || gMapObjects[r3].localId == 0xFF) + return NULL; + for (i = 0; i < 4; i++) + { + if (gLinkPlayerMapObjects[i].active == TRUE && gLinkPlayerMapObjects[i].mapObjId == r3) + return NULL; + } + gSelectedMapObject = r3; + gScriptLastTalked = gMapObjects[r3].localId; + gScriptFacing = c; + return GetFieldObjectScriptPointerByFieldObjectId(r3); +} + +static u8 *sub_8068364(struct MapPosition *position, u8 b, u8 c) +{ + u8 r3; + u8 *script; + + r3 = GetFieldObjectIdByXYZ(position->x, position->y, position->height); + if (r3 == 16 || gMapObjects[r3].localId == 0xFF) + { + if (MetatileBehavior_IsCounter(b) != TRUE) + return NULL; + r3 = GetFieldObjectIdByXYZ(position->x + gUnknown_0821664C[c].x, position->y + gUnknown_0821664C[c].y, position->height); + if (r3 == 16 || gMapObjects[r3].localId == 0xFF) + return NULL; + } + //_080683E8 + gSelectedMapObject = r3; + gScriptLastTalked = gMapObjects[r3].localId; + gScriptFacing = c; + script = GetFieldObjectScriptPointerByFieldObjectId(r3); + script = GetRamScript(gScriptLastTalked, script); + return script; +} + +static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *position, u8 unused, u8 c) +{ + struct BgEvent *bgEvent = FindInvisibleMapObjectByPosition(&gMapHeader, position->x - 7, position->y - 7, position->height); + + if (bgEvent == NULL) + return NULL; + if (bgEvent->bgUnion.script == NULL) + return gUnknown_081C6C02; + switch (bgEvent->kind) + { + case 0: + default: + return bgEvent->bgUnion.script; + case 1: + if (c != 2) + return NULL; + break; + case 2: + if (c != 1) + return NULL; + break; + case 3: + if (c != 4) + return NULL; + break; + case 4: + if (c != 3) + return NULL; + break; + case 5: + case 6: + case 7: + gSpecialVar_0x8004 = ((u32)bgEvent->bgUnion.script >> 16) + 0x258; + gSpecialVar_0x8005 = (u32)bgEvent->bgUnion.script; + if (FlagGet(gSpecialVar_0x8004) == TRUE) + return NULL; + return HiddenItemScript; + case 8: + if (c == 2) + { + gSpecialVar_0x8004 = (u32)bgEvent->bgUnion.script; + if (sub_80BC050()) + return gUnknown_081A2C51; + } + return NULL; + } + return bgEvent->bgUnion.script; +} + +static u8 *sub_8068500(struct MapPosition *position, u8 b, u8 c) +{ + s8 height; + + if (MetatileBehavior_IsPlayerFacingTVScreen(b, c) == TRUE) + return Event_TV; + if (MetatileBehavior_IsPC(b) == TRUE) + return gUnknown_081A0009; + if (MetatileBehavior_IsClosedSootopolisGymDoor(b) == TRUE) + return ClosedSootopolisGymDoorScript; + if (is_tile_x84(b) == TRUE) + return gUnknown_081A4363; + if (MetatileBehavior_IsPokeblockFeeder(b) == TRUE) + return gUnknown_081C346A; + if (MetatileBehavior_IsTrickHousePuzzleDoor(b) == TRUE) + return gUnknown_081616E1; + if (MetatileBehavior_IsRegionMap(b) == TRUE) + return Event_WorldMap; + if (sub_805791C(b) == TRUE) + return Event_RunningShoesManual; + if (MetatileBehavior_IsPictureBookShelf(b) == TRUE) + return PictureBookShelfScript; + if (MetatileBehavior_IsBookShelf(b) == TRUE) + return BookshelfScript; + if (MetatileBehavior_IsPokeCenterBookShelf(b) == TRUE) + return PokemonCenterBookshelfScript; + if (MetatileBehavior_IsVase(b) == TRUE) + return VaseScript; + if (MetatileBehavior_IsTrashCan(b) == TRUE) + return TrashCanScript; + if (MetatileBehavior_IsShopShelf(b) == TRUE) + return ShopShelfScript; + if (MetatileBehavior_IsBlueprint(b) == TRUE) + return BlueprintScript; + height = position->height; + if (height == MapGridGetZCoordAt(position->x, position->y)) + { + if (MetatileBehavior_IsSecretBasePC(b) == TRUE) + return gUnknown_0815F36C; + if (sub_805724C(b) == TRUE) + return gUnknown_0815F43A; + if (sub_8057364(b) == TRUE) + return gUnknown_0815F523; + if (sub_8057378(b) == TRUE) + return gUnknown_0815F528; + } + return NULL; +} + +static u8 *TryGetFieldMoveScript(struct MapPosition *unused1, u8 b, u8 unused2) +{ + if (FlagGet(BADGE05_GET) == TRUE && PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE) + return UseSurfScript; + if (MetatileBehavior_IsWaterfall(b) == TRUE) + { + if (FlagGet(BADGE08_GET) == TRUE && IsPlayerSurfingNorth() == TRUE) + return UseWaterfallScript; + else + return CannotUseWaterfallScript; + } + return NULL; +} + +static bool32 sub_8068770(void) +{ + if (FlagGet(BADGE07_GET) && sub_8068F18() == 2) + { + ScriptContext1_SetupScript(UseDiveScript); + return TRUE; + } + return FALSE; +} + +static bool32 sub_80687A4(void) +{ + if (FlagGet(BADGE07_GET) && gMapHeader.mapType == 5 && sub_8068F18() == 1) + { + ScriptContext1_SetupScript(UnderwaterUseDiveScript); + return TRUE; + } + return FALSE; +} + +static bool8 sub_80687E4(struct MapPosition *position, u16 b, u16 unused) +{ + if (mapheader_trigger_activate_at__run_now(position) == TRUE) + return TRUE; + if (sub_8068A64(position, b) == TRUE) + return TRUE; + if (sub_8068870(b) == TRUE) + return TRUE; + if (sub_8068894() == TRUE) + return TRUE; + if (UpdateRepelCounter() == TRUE) + return TRUE; + return FALSE; +} + +bool8 mapheader_trigger_activate_at__run_now(struct MapPosition *position) +{ + u8 *script = mapheader_trigger_activate_at(&gMapHeader, position->x - 7, position->y - 7, position->height); + + if (script == NULL) + return FALSE; + ScriptContext1_SetupScript(script); + return TRUE; +} + +//can be u8, u16, or u32 +bool8 sub_8068870(u16 a) +{ + if (MetatileBehavior_IsCrackedFloorHole(a)) + { + ScriptContext1_SetupScript(GraniteCave_B1F_EventScript_1C6BC5); + return TRUE; + } + return FALSE; +} + +bool8 sub_8068894(void) +{ + sub_8082B78(); + happiness_algorithm_step(); + if (overworld_poison_step() == TRUE) + { + ScriptContext1_SetupScript(gUnknown_081A14B8); + return TRUE; + } + if (sub_80422A0()) + { + IncrementGameStat(13); + ScriptContext1_SetupScript(Event_EggHatch); + return TRUE; + } + if (SafariZoneTakeStep() == TRUE) + return TRUE; + if (CountSSTidalStep(1) == TRUE) + { + ScriptContext1_SetupScript(gUnknown_0815FD0D); + return TRUE; + } + return FALSE; +} + +void unref_sub_80688F8(void) +{ + VarSet(VAR_HAPPINESS_STEP_COUNTER, 0); +} + +static void happiness_algorithm_step(void) +{ + u16 *ptr = GetVarPointer(VAR_HAPPINESS_STEP_COUNTER); + int i; + + (*ptr)++; + (*ptr) %= 128; + if (*ptr == 0) + { + struct Pokemon *pkmn = gPlayerParty; + + for (i = 5; i >= 0; i--) + { + AdjustFriendship(pkmn, 5); + pkmn++; + } + } +} + +void overworld_poison_timer_set(void) +{ + VarSet(VAR_POISON_STEP_COUNTER, 0); +} + +static bool8 overworld_poison_step(void) +{ + u16 *ptr; + + if (gMapHeader.mapType != 9) + { + ptr = GetVarPointer(VAR_POISON_STEP_COUNTER); + (*ptr)++; + (*ptr) %= 4; + if (*ptr == 0) + { + switch (overworld_poison()) + { + case 0: + return FALSE; + case 1: + return FALSE; + case 2: + return TRUE; + } + } + } + return FALSE; +} + +void prev_quest_postbuffer_cursor_backup_reset(void) +{ + gUnknown_0202E8C0 = 0; +} + +static bool8 is_it_battle_time_3(u16 a) +{ + if (gUnknown_0202E8C0 < 4) + { + gUnknown_0202E8C0++; + gUnknown_0202E8C2 = a; + return FALSE; + } + if (StandardWildEncounter(a, gUnknown_0202E8C2) == TRUE) + { + gUnknown_0202E8C0 = 0; + gUnknown_0202E8C2 = a; + return TRUE; + } + else + { + gUnknown_0202E8C2 = a; + return FALSE; + } +} + +static bool8 mapheader_run_first_tag2_script_list_match_conditionally(struct MapPosition *position, u16 b, u8 c) +{ + s8 r6 = map_warp_check_packed(&gMapHeader, position); + + if (is_non_stair_warp_tile(b, c) == TRUE && r6 != -1) + { + walkrun_find_lowest_active_bit_in_bitfield(); + sub_8068C30(&gMapHeader, r6, position); + sub_8080E88(); + return TRUE; + } + return FALSE; +} + +bool8 sub_8068A64(struct MapPosition *position, u16 b) +{ + s8 r4 = map_warp_check_packed(&gMapHeader, position); + + if (r4 != -1 && sub_8068B30(b) == TRUE) + { + walkrun_find_lowest_active_bit_in_bitfield(); + sub_8068C30(&gMapHeader, r4, position); + if (MetatileBehavior_IsEscalator(b) == TRUE) + { + sub_8080F2C(b); + return TRUE; + } + if (MetatileBehavior_IsLavaridgeB1FWarp(b) == TRUE) + { + sub_8080F48(); + return TRUE; + } + if (MetatileBehavior_IsLavaridge1FWarp(b) == TRUE) + { + sub_8080F58(); + return TRUE; + } + if (MetatileBehavior_IsAquaHideoutWarp(b) == TRUE) + { + sub_8080F68(); + return TRUE; + } + if (MetatileBehavior_IsMtPyreHole(b) == TRUE) + { + ScriptContext1_SetupScript(gUnknown_081C6BDE); + return TRUE; + } + sub_8080E88(); + return TRUE; + } + return FALSE; +} + +static bool8 sub_8068B30(u16 a) +{ + if (MetatileBehavior_IsWarpDoor(a) != TRUE + && MetatileBehavior_IsLadder(a) != TRUE + && MetatileBehavior_IsEscalator(a) != TRUE + && MetatileBehavior_IsNonAnimDoor(a) != TRUE + && MetatileBehavior_IsLavaridgeB1FWarp(a) != TRUE + && MetatileBehavior_IsLavaridge1FWarp(a) != TRUE + && MetatileBehavior_IsAquaHideoutWarp(a) != TRUE + && MetatileBehavior_IsMtPyreHole(a) != TRUE) + return FALSE; + return TRUE; +} + +static bool8 is_non_stair_warp_tile(u16 a, u8 b) +{ + switch (b) + { + case 2: + return MetatileBehavior_IsNorthArrowWarp(a); + case 1: + return MetatileBehavior_IsSouthArrowWarp(a); + case 3: + return MetatileBehavior_IsWestArrowWarp(a); + case 4: + return MetatileBehavior_IsEastArrowWarp(a); + } + return FALSE; +} + +static s8 map_warp_check_packed(struct MapHeader *mapHeader, struct MapPosition *position) +{ + return map_warp_check(mapHeader, position->x - 7, position->y - 7, position->height); +} + +static void sub_8068C30(struct MapHeader *unused, s8 b, struct MapPosition *position) +{ + struct WarpEvent *warpEvent = &gMapHeader.events->warps[b]; + + if (warpEvent->mapNum == 0x7F) + { + copy_saved_warp2_bank_and_enter_x_to_warp1(warpEvent->mapGroup); + } + else + { + struct MapHeader *mapHeader; + + warp1_set_2(warpEvent->unk7, warpEvent->mapNum, warpEvent->mapGroup); + sub_80535C4(position->x, position->y); + mapHeader = get_mapheader_by_bank_and_number(warpEvent->unk7, warpEvent->mapNum); + if (mapHeader->events->warps[warpEvent->mapGroup].mapNum == 0x7F) + saved_warp2_set(mapHeader->events->warps[b].mapGroup, gSaveBlock1.location.mapGroup, gSaveBlock1.location.mapNum, b); + } +} + +static bool8 map_warp_consider_2_to_inside(struct MapPosition *position, u16 b, u8 c) +{ + s8 r4; + + if (c == 2) + { + if (sub_80571C0(b) == TRUE) + { + sub_80BC038(position, gMapHeader.events); + return TRUE; + } + if (MetatileBehavior_IsWarpDoor(b) == TRUE) + { + r4 = map_warp_check_packed(&gMapHeader, position); + if (r4 != -1 && sub_8068B30(b) == TRUE) + { + walkrun_find_lowest_active_bit_in_bitfield(); + sub_8068C30(&gMapHeader, r4, position); + sub_8080EF0(); + return TRUE; + } + } + } + return FALSE; +} + +static s8 map_warp_check(struct MapHeader *mapHeader, u16 b, u16 c, u8 d) +{ + s32 i; + struct WarpEvent *warpEvent = mapHeader->events->warps; + u8 warpCount = mapHeader->events->warpCount; + + for (i = 0; i < warpCount; i++, warpEvent++) + { + if ((u16)warpEvent->x == b && (u16)warpEvent->y == c) + { + if ((u8)warpEvent->warpId == d || (u8)warpEvent->warpId == 0) + return i; + } + } + return -1; +} + +static u8 *trigger_activate(struct CoordEvent *coordEvent) +{ + if (coordEvent != NULL) + { + if (coordEvent->script == NULL) + { + DoCoordEventWeather(coordEvent->trigger); + return NULL; + } + if (coordEvent->trigger == 0) + { + ScriptContext2_RunNewScript(coordEvent->script); + return NULL; + } + if (VarGet(coordEvent->trigger) == (u8)coordEvent->index) + return coordEvent->script; + } + return NULL; +} + +static u8 *mapheader_trigger_activate_at(struct MapHeader *mapHeader, u16 b, u16 c, u8 d) +{ + s32 i; + struct CoordEvent *coordEvents = mapHeader->events->coordEvents; + u8 coordEventCount = mapHeader->events->coordEventCount; + u8 *script; + + for (i = 0; i < coordEventCount; i++) + { + if ((u16)coordEvents[i].x == b && (u16)coordEvents[i].y == c) + { + if (coordEvents[i].unk4 == d || coordEvents[i].unk4 == 0) + { + script = trigger_activate(&coordEvents[i]); + if (script != NULL) + return script; + } + } + } + return NULL; +} + +u8 *sub_8068E24(struct MapPosition *position) +{ + return mapheader_trigger_activate_at(&gMapHeader, position->x - 7, position->y - 7, position->height); +} + +static struct BgEvent *FindInvisibleMapObjectByPosition(struct MapHeader *mapHeader, u16 b, u16 c, u8 d) +{ + u8 i; + struct BgEvent *bgEvents = mapHeader->events->bgEvents; + u8 bgEventCount = mapHeader->events->bgEventCount; + + for (i = 0; i < bgEventCount; i++) + { + if ((u16)bgEvents[i].x == b && (u16)bgEvents[i].y == c) + { + if (bgEvents[i].unk4 == d || bgEvents[i].unk4 == 0) + return &bgEvents[i]; + } + } + return NULL; +} + +int dive_warp(struct MapPosition *position, u16 b) +{ + if (gMapHeader.mapType == 5 && sub_805750C(b) == 0) + { + if (sub_80538B0(position->x - 7, position->y - 7)) + { + walkrun_find_lowest_active_bit_in_bitfield(); + sp13E_warp_to_last_warp(); + PlaySE(SE_W291); + return TRUE; + } + } + else if (sub_80574EC(b) == TRUE) + { + if (sub_80538D0(position->x - 7, position->y - 7)) + { + walkrun_find_lowest_active_bit_in_bitfield(); + sp13E_warp_to_last_warp(); + PlaySE(SE_W291); + return TRUE; + } + } + return FALSE; +} + +u8 sub_8068F18(void) +{ + s16 x, y; + u8 r5; + + PlayerGetDestCoords(&x, &y); + r5 = MapGridGetMetatileBehaviorAt(x, y); + if (gMapHeader.mapType == 5 && sub_805750C(r5) == 0) + { + if (sub_80538B0(x - 7, y - 7) == TRUE) + return 1; + } + else if (sub_80574EC(r5) == TRUE) + { + if (sub_80538D0(x - 7, y - 7) == TRUE) + return 2; + } + return 0; +} + +u8 *GetFieldObjectScriptPointerForComparison(void) +{ + u8 r4; + struct MapPosition position; + + r4 = player_get_direction_upper_nybble(); + player_get_next_pos_and_height(&position); + return sub_8068364(&position, MapGridGetMetatileBehaviorAt(position.x, position.y), r4); +} + +int sub_8068FEC(void) +{ + struct MapPosition position; + + player_get_direction_upper_nybble(); //unnecessary + player_get_pos_to_and_height(&position); + MapGridGetMetatileBehaviorAt(position.x, position.y); //unnecessary + sub_8068C30(&gMapHeader, map_warp_check_packed(&gMapHeader, &position), &position); + return 0; +} diff --git a/src/field_door.c b/src/field_door.c index ff0537c42..791ed4c94 100644 --- a/src/field_door.c +++ b/src/field_door.c @@ -1,21 +1,9 @@ #include "global.h" -#include "asm.h" -#include "task.h" +#include "field_door.h" #include "field_camera.h" - -struct DoorGraphics -{ - u16 metatileNum; - u8 unk2; - void *tiles; - void *palette; -}; - -struct DoorAnimFrame -{ - u8 time; - u16 offset; -}; +#include "fieldmap.h" +#include "metatile_behavior.h" +#include "task.h" extern struct DoorAnimFrame gDoorOpenAnimFrames[]; extern struct DoorAnimFrame gDoorCloseAnimFrames[]; @@ -30,7 +18,7 @@ static void door_build_blockdef(u16 *a, u16 b, u8 *c) { int i; u16 unk; - + for (i = 0; i < 4; i++) { unk = *(c++) << 12; @@ -46,7 +34,7 @@ static void door_build_blockdef(u16 *a, u16 b, u8 *c) static void DrawCurrentDoorAnimFrame(u32 x, u32 y, u8 *c) { u16 arr[8]; - + door_build_blockdef(arr, 0x3F8, c); DrawDoorMetatileAt(x, y - 1, arr); door_build_blockdef(arr, 0x3FC, c + 4); @@ -102,7 +90,7 @@ static void Task_AnimateDoor(u8 taskId) u16 *taskData = gTasks[taskId].data; struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(taskData[TD_FRAMELIST] << 16 | taskData[TD_FRAMELIST + 1]); struct DoorGraphics *gfx = (struct DoorGraphics *)(taskData[TD_GFX] << 16 | taskData[TD_GFX + 1]); - + if (sub_8058464(gfx, frames, taskData) == FALSE) DestroyTask(taskId); } @@ -133,16 +121,16 @@ static s8 StartDoorAnimationTask(struct DoorGraphics *gfx, struct DoorAnimFrame { u8 taskId = CreateTask(Task_AnimateDoor, 0x50); s16 *taskData = gTasks[taskId].data; - + taskData[TD_X] = x; taskData[TD_Y] = y; - + taskData[TD_FRAMELIST + 1] = (u32)frames; taskData[TD_FRAMELIST] = (u32)frames >> 16; - + taskData[TD_GFX + 1] = (u32)gfx; taskData[TD_GFX] = (u32)gfx >> 16; - + return taskId; } } diff --git a/src/field_effect.c b/src/field_effect.c index fe586fcb6..889664dfa 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -1,16 +1,425 @@ #include "global.h" -#include "field_effect.h" -#include "weather.h" +#include "data2.h" +#include "script.h" +#include "trig.h" +#include "main.h" +#include "field_weather.h" +#include "decompress.h" #include "sprite.h" +#include "menu.h" +#include "palette.h" +#include "text.h" +#include "rom4.h" +#include "task.h" +#include "sound.h" +#include "songs.h" +#include "decoration.h" +#include "field_player_avatar.h" +#include "field_map_obj_helpers.h" +#include "field_map_obj.h" +#include "metatile_behavior.h" +#include "field_camera.h" +#include "field_effect.h" +#include "field_fadetransition.h" +#include "fieldmap.h" +#include "field_map_obj.h" +#include "util.h" +#include "field_effect_helpers.h" + +#define subsprite_table(ptr) {.subsprites = ptr, .subspriteCount = (sizeof ptr) / (sizeof(struct Subsprite))} + +const u32 gSpriteImage_839DC14[] = INCBIN_U32("graphics/birch_speech/birch.4bpp"); +const u16 gBirchPalette[16] = INCBIN_U16("graphics/birch_speech/birch.gbapal"); +const u32 gSpriteImage_839E434[] = INCBIN_U32("graphics/misc/pokeball_glow.4bpp"); +const u16 gFieldEffectObjectPalette4[16] = INCBIN_U16("graphics/field_effect_objects/palettes/04.gbapal"); +const u32 gSpriteImage_839E474[] = INCBIN_U32("graphics/misc/pokecenter_monitor/0.4bpp"); +const u32 gSpriteImage_839E534[] = INCBIN_U32("graphics/misc/pokecenter_monitor/1.4bpp"); +const u32 gSpriteImage_839E5F4[] = INCBIN_U32("graphics/misc/big_hof_monitor.4bpp"); +const u32 gSpriteImage_839E7F4[] = INCBIN_U32("graphics/misc/small_hof_monitor.4bpp"); +const u16 gFieldEffectObjectPalette5[16] = INCBIN_U16("graphics/field_effect_objects/palettes/05.gbapal"); + +// Graphics for the lights streaking past your Pokemon when it uses a field move. +const u32 gFieldMoveStreaksTiles[] = INCBIN_U32("graphics/misc/field_move_streaks.4bpp"); +const u16 gFieldMoveStreaksPalette[16] = INCBIN_U16("graphics/misc/field_move_streaks.gbapal"); +const u16 gFieldMoveStreaksTilemap[] = INCBIN_U16("graphics/misc/field_move_streaks_map.bin"); + +// The following light streaks effect is used when the map is dark (e.g. a cave). +const u32 gDarknessFieldMoveStreaksTiles[] = INCBIN_U32("graphics/misc/darkness_field_move_streaks.4bpp"); +const u16 gDarknessFieldMoveStreaksPalette[16] = INCBIN_U16("graphics/misc/darkness_field_move_streaks.gbapal"); +const u16 gDarknessFieldMoveStreaksTilemap[] = INCBIN_U16("graphics/misc/darkness_field_move_streaks_map.bin"); + +bool8 (*const gFieldEffectScriptFuncs[])(u8 **, u32 *) = { + FieldEffectCmd_loadtiles, + FieldEffectCmd_loadfadedpal, + FieldEffectCmd_loadpal, + FieldEffectCmd_callnative, + FieldEffectCmd_end, + FieldEffectCmd_loadgfx_callnative, + FieldEffectCmd_loadtiles_callnative, + FieldEffectCmd_loadfadedpal_callnative, +}; + +const struct OamData gOamData_839F0F4 = {.size = 3}; +const struct OamData gOamData_839F0FC = {.size = 0}; +const struct OamData gOamData_839F104 = {.size = 1}; + +const struct SpriteFrameImage gSpriteImageTable_839F10C[] = { + obj_frame_tiles(gSpriteImage_839DC14) +}; +const struct SpritePalette gUnknown_0839F114 = {.data = gBirchPalette, .tag = 0x1006}; + +const union AnimCmd gSpriteAnim_839F11C[] = { + ANIMCMD_FRAME(.imageValue = 0, .duration = 1), + ANIMCMD_END +}; + +const union AnimCmd *const gSpriteAnimTable_839F124[] = { + gSpriteAnim_839F11C +}; + +const struct SpriteTemplate gSpriteTemplate_839F128 = { + .tileTag = 0xffff, + .paletteTag = 4102, + .oam = &gOamData_839F0F4, + .anims = (const union AnimCmd *const *)&gSpriteAnimTable_839F124, + .images = gSpriteImageTable_839F10C, + .affineAnims = (const union AffineAnimCmd *const *)&gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +const struct SpritePalette gFieldEffectObjectPaletteInfo4 = {.data = gFieldEffectObjectPalette4, .tag = 0x1007}; +const struct SpritePalette gFieldEffectObjectPaletteInfo5 = {.data = gFieldEffectObjectPalette5, .tag = 0x1010}; +const struct OamData gOamData_839F150 = { + .shape = 1, + .size = 2 +}; + +const struct SpriteFrameImage gSpriteImageTable_839F158[] = { + obj_frame_tiles(gSpriteImage_839E434) +}; + +const struct SpriteFrameImage gSpriteImageTable_839F160[] = { + obj_frame_tiles(gSpriteImage_839E474), + obj_frame_tiles(gSpriteImage_839E534) +}; + +const struct SpriteFrameImage gSpriteImageTable_839F170[] = { + obj_frame_tiles(gSpriteImage_839E5F4) +}; + +const struct SpriteFrameImage gSpriteImageTable_839F178[] = { + {.data = (u8 *)gSpriteImage_839E7F4, .size = 0x200} // the macro breaks down here +}; + +const struct Subsprite Unknown_39F180[] = { + {.x = -12, .y = -8, .priority = 2, .tileOffset = 0, .shape = 1, .size = 0}, + {.x = 4, .y = -8, .priority = 2, .tileOffset = 2, .shape = 0, .size = 0}, + {.x = -12, .y = 0, .priority = 2, .tileOffset = 3, .shape = 1, .size = 0}, + {.x = 4, .y = 0, .priority = 2, .tileOffset = 5, .shape = 0, .size = 0} +}; + +const struct SubspriteTable gUnknown_0839F1A0 = subsprite_table(Unknown_39F180); + +const struct Subsprite Unknown_39F1A8[] = { + {.x = -32, .y = -8, .priority = 2, .tileOffset = 0, .shape = 1, .size = 1}, + {.x = 0, .y = -8, .priority = 2, .tileOffset = 4, .shape = 1, .size = 1}, + {.x = -32, .y = 0, .priority = 2, .tileOffset = 8, .shape = 1, .size = 1}, + {.x = 0, .y = 0, .priority = 2, .tileOffset = 12, .shape = 1, .size = 1} +}; + +const struct SubspriteTable gUnknown_0839F1C8 = subsprite_table(Unknown_39F1A8); + +const union AnimCmd gSpriteAnim_839F1D0[] = { + ANIMCMD_FRAME(.imageValue = 0, .duration = 1), + ANIMCMD_JUMP(0) +}; + +const union AnimCmd gSpriteAnim_839F1D8[] = { + ANIMCMD_FRAME(.imageValue = 0, .duration = 16), + ANIMCMD_FRAME(.imageValue = 1, .duration = 16), + ANIMCMD_FRAME(.imageValue = 0, .duration = 16), + ANIMCMD_FRAME(.imageValue = 1, .duration = 16), + ANIMCMD_FRAME(.imageValue = 0, .duration = 16), + ANIMCMD_FRAME(.imageValue = 1, .duration = 16), + ANIMCMD_FRAME(.imageValue = 0, .duration = 16), + ANIMCMD_FRAME(.imageValue = 1, .duration = 16), + ANIMCMD_END +}; + +const union AnimCmd *const gSpriteAnimTable_839F1FC[] = { + gSpriteAnim_839F1D0, + gSpriteAnim_839F1D8 +}; + +const union AnimCmd *const gSpriteAnimTable_839F204[] = { + gSpriteAnim_839F1D0 +}; + +const struct SpriteTemplate gSpriteTemplate_839F208 = { + .tileTag = 0xffff, + .paletteTag = 4103, + .oam = &gOamData_839F0FC, + .anims = gSpriteAnimTable_839F1FC, + .images = gSpriteImageTable_839F158, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_PokeballGlow +}; + + +const struct SpriteTemplate gSpriteTemplate_839F220 = { + .tileTag = 0xffff, + .paletteTag = 4100, + .oam = &gOamData_839F104, + .anims = gSpriteAnimTable_839F1FC, + .images = gSpriteImageTable_839F160, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_PokecenterMonitor +}; + + +const struct SpriteTemplate gSpriteTemplate_839F238 = { + .tileTag = 0xffff, + .paletteTag = 4112, + .oam = &gOamData_839F104, + .anims = gSpriteAnimTable_839F204, + .images = gSpriteImageTable_839F170, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_HallOfFameMonitor +}; + + +const struct SpriteTemplate gSpriteTemplate_839F250 = { + .tileTag = 0xffff, + .paletteTag = 4112, + .oam = &gOamData_839F150, + .anims = gSpriteAnimTable_839F204, + .images = gSpriteImageTable_839F178, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_HallOfFameMonitor +}; + +void (*const gUnknown_0839F268[])(struct Task *) = { + PokecenterHealEffect_0, + PokecenterHealEffect_1, + PokecenterHealEffect_2, + PokecenterHealEffect_3 +}; + +void (*const gUnknown_0839F278[])(struct Task *) = { + HallOfFameRecordEffect_0, + HallOfFameRecordEffect_1, + HallOfFameRecordEffect_2, + HallOfFameRecordEffect_3 +}; -typedef bool8 (*FldEffCmd)(u8 **, u32 *); +void (*const gUnknown_0839F288[])(struct Sprite *) = { + PokeballGlowEffect_0, + PokeballGlowEffect_1, + PokeballGlowEffect_2, + PokeballGlowEffect_3, + PokeballGlowEffect_4, + PokeballGlowEffect_5, + PokeballGlowEffect_6, + PokeballGlowEffect_7 +}; + +const struct Coords16 gUnknown_0839F2A8[] = { + {.x = 0, .y = 0}, + {.x = 6, .y = 0}, + {.x = 0, .y = 4}, + {.x = 6, .y = 4}, + {.x = 0, .y = 8}, + {.x = 6, .y = 8} +}; + +const u8 gUnknown_0839F2C0[] = {16, 12, 8, 0}; +const u8 gUnknown_0839F2C4[] = {16, 12, 8, 0}; +const u8 gUnknown_0839F2C8[] = { 0, 0, 0, 0}; + +bool8 (*const gUnknown_0839F2CC[])(struct Task *) = { + sub_80867AC, + sub_8086854, + sub_8086870, + sub_80868E4, + sub_808699C, + sub_80869B8, + sub_80869F8 +}; + +bool8 (*const gUnknown_0839F2E8[])(struct Task *) = { + sub_8086AA0, + sub_8086AC0, + sub_8086B30, + sub_8086B54, + sub_8086B64, + sub_8086B88 +}; + +bool8 (*const gUnknown_0839F300[])(struct Task *) = { + sub_8086CF4, + sub_8086D70, + sub_8086DB0, + sub_8086E10, + sub_8086E50, + sub_8086EB0, + sub_8086ED4 +}; + +bool8 (*const gUnknown_0839F31C[])(struct Task *, struct MapObject *) = { + sub_8086FB0, + waterfall_1_do_anim_probably, + waterfall_2_wait_anim_finish_probably, + sub_8087030, + sub_8087058 +}; + +bool8 (*const gUnknown_0839F330[])(struct Task *) = { + sub_8087124, + dive_2_unknown, + dive_3_unknown +}; + +bool8 (*const gUnknown_0839F33C[])(struct Task *, struct MapObject *, struct Sprite *) = { + sub_808722C, + sub_8087264, + sub_8087298, + sub_80872E4, + sub_80873D8, + sub_80873F4 +}; + +bool8 (*const gUnknown_0839F354[])(struct Task *, struct MapObject *, struct Sprite *) = { + sub_80874CC, + sub_80874FC, + sub_8087548, + sub_808759C +}; + +bool8 (*const gUnknown_0839F364[])(struct Task *, struct MapObject *, struct Sprite *) = { + sub_80876C8, + sub_80876F8, + sub_8087774, + sub_80877AC, + sub_80877D4 +}; + +void (*const gUnknown_0839F378[])(struct Task *) = { + sub_80878F4, + sub_8087914 +}; + +const u8 gUnknown_0839F380[] = {1, 3, 4, 2, 1}; + +void (*const gUnknown_0839F388[])(struct Task *) = { + sub_8087AA4, + sub_8087AC8 +}; + +void (*const gUnknown_0839F390[])(struct Task *) = { + sub_8087BEC, + sub_8087C14, + sub_8087CA4, + sub_8087D78 +}; + +void (*const gUnknown_0839F3A0[])(struct Task *) = { + sub_8087E4C, + sub_8087ED8, + sub_8087FDC +}; + +void (*const gUnknown_0839F3AC[])(struct Task *) = { + sub_8088150, + sub_80881C0, + sub_8088228, + sub_80882B4, + sub_80882E4, + sub_8088338, + sub_8088380 +}; + +void (*const gUnknown_0839F3C8[])(struct Task *) = { + sub_80884AC, + sub_80884E8, + sub_8088554, + sub_80885A8, + sub_80885D8, + sub_808860C, + sub_808862C +}; + +void (*const gUnknown_0839F3E4[])(struct Task *) = { + sub_8088984, + sub_80889E4, + sub_8088A30, + sub_8088A78, + sub_8088AF4 +}; + +void (*const gUnknown_0839F3F8[])(struct Task *) = { + sub_8088CA0, + sub_8088CF8, + sub_8088D3C, + sub_8088D94, + sub_8088DD8, + sub_8088E2C, + sub_8088EB4, + sub_8088F10, + sub_8088F30 +}; + +const union AffineAnimCmd SpriteAffineAnim_839F41C[] = { + AFFINEANIMCMD_FRAME(8, 8, -30, 0), + AFFINEANIMCMD_FRAME(28, 28, 0, 30), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd SpriteAffineAnim_839F434[] = { + AFFINEANIMCMD_FRAME(256, 256, 64, 0), + AFFINEANIMCMD_FRAME(-10, -10, 0, 22), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd *const gSpriteAffineAnimTable_0839F44C[] = { + SpriteAffineAnim_839F41C, + SpriteAffineAnim_839F434 +}; + +void (*const gUnknown_0839F454[])(struct Task *) = { + sub_80892A0, + sub_8089354, + sub_80893C0, + sub_8089414, + sub_808948C, + sub_80894C4, + fishE +}; + +const s16 gUnknown_0839F470[] = { + -2, + -4, + -5, + -6, + -7, + -8, + -8, + -8, + -7, + -7, + -6, + -5, + -3, + -2, + 0, + 2, + 4, + 8 +}; static u8 sActiveList[32]; extern u8 *gFieldEffectScriptPointers[]; -extern FldEffCmd gFieldEffectScriptFuncs[]; - u32 FieldEffectStart(u8 id) { u8 *script; @@ -206,3 +615,2790 @@ bool8 FieldEffectActiveListContains(u8 id) return TRUE; return FALSE; } + +u8 CreateTrainerSprite_BirchSpeech(u8 gender, s16 x, s16 y, u8 subpriority, u8 *buffer) +{ + struct SpriteTemplate spriteTemplate; + LoadCompressedObjectPaletteOverrideBuffer(&gTrainerFrontPicPaletteTable[gender], buffer); + LoadCompressedObjectPicOverrideBuffer(&gTrainerFrontPicTable[gender], buffer); + spriteTemplate.tileTag = gTrainerFrontPicTable[gender].tag; + spriteTemplate.paletteTag = gTrainerFrontPicPaletteTable[gender].tag; + spriteTemplate.oam = &gOamData_839F0F4; + spriteTemplate.anims = gDummySpriteAnimTable; + spriteTemplate.images = NULL; + spriteTemplate.affineAnims = gDummySpriteAffineAnimTable; + spriteTemplate.callback = SpriteCallbackDummy; + return CreateSprite(&spriteTemplate, x, y, subpriority); +} + +void LoadTrainerGfx_TrainerCard(u8 gender, u16 palOffset, u8 *dest) +{ + LZDecompressVram(gTrainerFrontPicTable[gender].data, dest); + LoadCompressedPalette(gTrainerFrontPicPaletteTable[gender].data, palOffset, 0x20); +} + +u8 CreateBirchSprite(s16 x, s16 y, u8 subpriority) +{ + LoadSpritePalette(&gUnknown_0839F114); + return CreateSprite(&gSpriteTemplate_839F128, x, y, subpriority); +} + +u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority) +{ + DecompressPicFromTable_2(&gMonFrontPicTable[species], gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, gUnknown_081FAF4C[3], gUnknown_081FAF4C[3], species); + LoadCompressedObjectPalette(&gMonPaletteTable[species]); + GetMonSpriteTemplate_803C56C(species, 3); + gUnknown_02024E8C.paletteTag = gMonPaletteTable[0].tag; + sub_807DE38(IndexOfSpritePaletteTag(gMonPaletteTable[0].tag) + 0x10); + return CreateSprite(&gUnknown_02024E8C, x, y, subpriority); +} + +u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subpriority) +{ + const struct CompressedSpritePalette *spritePalette; + + HandleLoadSpecialPokePic(&gMonFrontPicTable[species], gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, (u32)gUnknown_081FAF4C[3] /* this is actually u8* or something, pointing to ewram */, gUnknown_081FAF4C[3], species, g); + spritePalette = sub_80409C8(species, d, g); + LoadCompressedObjectPalette(spritePalette); + GetMonSpriteTemplate_803C56C(species, 3); + gUnknown_02024E8C.paletteTag = spritePalette->tag; + sub_807DE38(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10); + return CreateSprite(&gUnknown_02024E8C, x, y, subpriority); +} + +void FreeResourcesAndDestroySprite(struct Sprite *sprite) +{ + sub_807DE68(); + FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum)); + if (sprite->oam.affineMode != 0) + { + FreeOamMatrix(sprite->oam.matrixNum); + } + DestroySprite(sprite); +} + +#ifdef NONMATCHING +void MultiplyInvertedPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) +{ + int curRed; + int curGreen; + int curBlue; + + curRed = gPlttBufferUnfaded[i] & 0x1f; + curGreen = (gPlttBufferUnfaded[i] & (0x1f << 5)) >> 5; + curBlue = (gPlttBufferUnfaded[i] & (0x1f << 10)) >> 10; + curRed += (((0x1f - curRed) * r) >> 4); + curGreen += (((0x1f - curGreen) * g) >> 4); + curBlue += (((0x1f - curBlue) * b) >> 4); + gPlttBufferFaded[i] = RGB(curRed, curGreen, curBlue); +} + +void MultiplyPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) +{ + int curRed; + int curGreen; + int curBlue; + + curRed = gPlttBufferUnfaded[i] & 0x1f; + curGreen = (gPlttBufferUnfaded[i] & (0x1f << 5)) >> 5; + curBlue = (gPlttBufferUnfaded[i] & (0x1f << 10)) >> 10; + curRed -= ((curRed * r) >> 4); + curGreen -= ((curGreen * g) >> 4); + curBlue -= ((curBlue * b) >> 4); + gPlttBufferFaded[i] = RGB(curRed, curGreen, curBlue); +} +#else +__attribute__((naked)) +void MultiplyInvertedPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) +{ + asm(".syntax unified\n" + "\tpush {r4-r7,lr}\n" + "\tmov r7, r9\n" + "\tmov r6, r8\n" + "\tpush {r6,r7}\n" + "\tlsls r0, 16\n" + "\tlsls r1, 24\n" + "\tlsrs r1, 24\n" + "\tlsls r2, 24\n" + "\tlsrs r2, 24\n" + "\tlsls r3, 24\n" + "\tlsrs r3, 24\n" + "\tldr r4, _08085D00 @ =gPlttBufferUnfaded\n" + "\tlsrs r0, 15\n" + "\tadds r4, r0, r4\n" + "\tldrh r4, [r4]\n" + "\tmovs r5, 0x1F\n" + "\tmov r9, r5\n" + "\tmov r8, r4\n" + "\tmov r6, r8\n" + "\tands r6, r5\n" + "\tmov r8, r6\n" + "\tmovs r6, 0xF8\n" + "\tlsls r6, 2\n" + "\tands r6, r4\n" + "\tlsrs r6, 5\n" + "\tmovs r5, 0xF8\n" + "\tlsls r5, 7\n" + "\tands r4, r5\n" + "\tlsrs r4, 10\n" + "\tmov r7, r9\n" + "\tmov r5, r8\n" + "\tsubs r7, r5\n" + "\tmov r12, r7\n" + "\tmov r7, r12\n" + "\tmuls r7, r1\n" + "\tadds r1, r7, 0\n" + "\tasrs r1, 4\n" + "\tadd r8, r1\n" + "\tmov r5, r9\n" + "\tsubs r1, r5, r6\n" + "\tmuls r1, r2\n" + "\tasrs r1, 4\n" + "\tadds r6, r1\n" + "\tsubs r5, r4\n" + "\tmov r9, r5\n" + "\tmov r1, r9\n" + "\tmuls r1, r3\n" + "\tasrs r1, 4\n" + "\tadds r4, r1\n" + "\tmov r7, r8\n" + "\tlsls r7, 16\n" + "\tlsls r6, 21\n" + "\torrs r6, r7\n" + "\tlsls r4, 26\n" + "\torrs r4, r6\n" + "\tlsrs r4, 16\n" + "\tldr r1, _08085D04 @ =gPlttBufferFaded\n" + "\tadds r0, r1\n" + "\tstrh r4, [r0]\n" + "\tpop {r3,r4}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tpop {r4-r7}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.align 2, 0\n" + "_08085D00: .4byte gPlttBufferUnfaded\n" + "_08085D04: .4byte gPlttBufferFaded\n" + ".syntax divided"); +} + +__attribute__((naked)) +void MultiplyPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) +{ + asm(".syntax unified\n" + "\tpush {r4-r6,lr}\n" + "\tmov r6, r8\n" + "\tpush {r6}\n" + "\tlsls r0, 16\n" + "\tlsls r1, 24\n" + "\tlsrs r1, 24\n" + "\tlsls r2, 24\n" + "\tlsrs r2, 24\n" + "\tlsls r3, 24\n" + "\tlsrs r3, 24\n" + "\tldr r4, _08085D78 @ =gPlttBufferUnfaded\n" + "\tlsrs r0, 15\n" + "\tadds r4, r0, r4\n" + "\tldrh r4, [r4]\n" + "\tmovs r5, 0x1F\n" + "\tmov r8, r5\n" + "\tmov r6, r8\n" + "\tands r6, r4\n" + "\tmov r8, r6\n" + "\tmovs r5, 0xF8\n" + "\tlsls r5, 2\n" + "\tands r5, r4\n" + "\tlsrs r5, 5\n" + "\tmovs r6, 0xF8\n" + "\tlsls r6, 7\n" + "\tands r4, r6\n" + "\tlsrs r4, 10\n" + "\tmov r6, r8\n" + "\tmuls r6, r1\n" + "\tadds r1, r6, 0\n" + "\tasrs r1, 4\n" + "\tmov r6, r8\n" + "\tsubs r6, r1\n" + "\tadds r1, r5, 0\n" + "\tmuls r1, r2\n" + "\tasrs r1, 4\n" + "\tsubs r5, r1\n" + "\tadds r1, r4, 0\n" + "\tmuls r1, r3\n" + "\tasrs r1, 4\n" + "\tsubs r4, r1\n" + "\tlsls r6, 16\n" + "\tlsls r5, 21\n" + "\torrs r5, r6\n" + "\tlsls r4, 26\n" + "\torrs r4, r5\n" + "\tlsrs r4, 16\n" + "\tldr r1, _08085D7C @ =gPlttBufferFaded\n" + "\tadds r0, r1\n" + "\tstrh r4, [r0]\n" + "\tpop {r3}\n" + "\tmov r8, r3\n" + "\tpop {r4-r6}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.align 2, 0\n" + "_08085D78: .4byte gPlttBufferUnfaded\n" + "_08085D7C: .4byte gPlttBufferFaded\n" + ".syntax divided"); +} +#endif + +void Task_PokecenterHeal(u8 taskId); +u8 CreatePokeballGlowSprite(s16, s16, s16, u16); +u8 PokecenterHealEffectHelper(s16, s16); + +bool8 FldEff_PokecenterHeal(void) +{ + u8 nPokemon; + struct Task *task; + + nPokemon = CalculatePlayerPartyCount(); + task = &gTasks[CreateTask(Task_PokecenterHeal, 0xff)]; + task->data[1] = nPokemon; + task->data[2] = 0x5d; + task->data[3] = 0x24; + task->data[4] = 0x7c; + task->data[5] = 0x18; + return FALSE; +} + +void Task_PokecenterHeal(u8 taskId) +{ + struct Task *task; + task = &gTasks[taskId]; + gUnknown_0839F268[task->data[0]](task); +} + +void PokecenterHealEffect_0(struct Task *task) +{ + task->data[0]++; + task->data[6] = CreatePokeballGlowSprite(task->data[1], task->data[2], task->data[3], 1); + task->data[7] = PokecenterHealEffectHelper(task->data[4], task->data[5]); +} + +void PokecenterHealEffect_1(struct Task *task) +{ + if (gSprites[task->data[6]].data0 > 1) + { + gSprites[task->data[7]].data0++; + task->data[0]++; + } +} + +void PokecenterHealEffect_2(struct Task *task) +{ + if (gSprites[task->data[6]].data0 > 4) + { + task->data[0]++; + } +} + +void PokecenterHealEffect_3(struct Task *task) +{ + if (gSprites[task->data[6]].data0 > 6) + { + DestroySprite(&gSprites[task->data[6]]); + FieldEffectActiveListRemove(FLDEFF_POKECENTER_HEAL); + DestroyTask(FindTaskIdByFunc(Task_PokecenterHeal)); + } +} + +void Task_HallOfFameRecord(u8 taskId); +void HallOfFameRecordEffectHelper(s16, s16, s16, u8); + +bool8 FldEff_HallOfFameRecord(void) +{ + u8 nPokemon; + struct Task *task; + + nPokemon = CalculatePlayerPartyCount(); + task = &gTasks[CreateTask(Task_HallOfFameRecord, 0xff)]; + task->data[1] = nPokemon; + task->data[2] = 0x75; + task->data[3] = 0x34; + return FALSE; +} + +void Task_HallOfFameRecord(u8 taskId) +{ + struct Task *task; + task = &gTasks[taskId]; + gUnknown_0839F278[task->data[0]](task); +} + +void HallOfFameRecordEffect_0(struct Task *task) +{ + u8 taskId; + task->data[0]++; + task->data[6] = CreatePokeballGlowSprite(task->data[1], task->data[2], task->data[3], 0); + taskId = FindTaskIdByFunc(Task_HallOfFameRecord); + HallOfFameRecordEffectHelper(taskId, 0x78, 0x18, 0); + HallOfFameRecordEffectHelper(taskId, 0x28, 0x08, 1); + HallOfFameRecordEffectHelper(taskId, 0x48, 0x08, 1); + HallOfFameRecordEffectHelper(taskId, 0xa8, 0x08, 1); + HallOfFameRecordEffectHelper(taskId, 0xc8, 0x08, 1); +} + +void HallOfFameRecordEffect_1(struct Task *task) +{ + if (gSprites[task->data[6]].data0 > 1) + { + task->data[15]++; // was this ever initialized? is this ever used? + task->data[0]++; + } +} + +void HallOfFameRecordEffect_2(struct Task *task) +{ + if (gSprites[task->data[6]].data0 > 4) + { + task->data[0]++; + } +} + +void HallOfFameRecordEffect_3(struct Task *task) +{ + if (gSprites[task->data[6]].data0 > 6) + { + DestroySprite(&gSprites[task->data[6]]); + FieldEffectActiveListRemove(FLDEFF_HALL_OF_FAME_RECORD); + DestroyTask(FindTaskIdByFunc(Task_HallOfFameRecord)); + } +} + +void SpriteCB_PokeballGlowEffect(struct Sprite *); + +u8 CreatePokeballGlowSprite(s16 data6, s16 x, s16 y, u16 data5) +{ + u8 spriteId; + struct Sprite *sprite; + spriteId = CreateInvisibleSprite(SpriteCB_PokeballGlowEffect); + sprite = &gSprites[spriteId]; + sprite->pos2.x = x; + sprite->pos2.y = y; + sprite->data5 = data5; + sprite->data6 = data6; + sprite->data7 = spriteId; + return spriteId; +} + +void SpriteCB_PokeballGlowEffect(struct Sprite *sprite) +{ + gUnknown_0839F288[sprite->data0](sprite); +} + +void PokeballGlowEffect_0(struct Sprite *sprite) +{ + u8 endSpriteId; + if (sprite->data1 == 0 || (--sprite->data1) == 0) + { + sprite->data1 = 25; + endSpriteId = CreateSpriteAtEnd(&gSpriteTemplate_839F208, gUnknown_0839F2A8[sprite->data2].x + sprite->pos2.x, gUnknown_0839F2A8[sprite->data2].y + sprite->pos2.y, 0); + gSprites[endSpriteId].oam.priority = 2; + gSprites[endSpriteId].data0 = sprite->data7; + sprite->data2++; + sprite->data6--; + PlaySE(SE_BOWA); + } + if (sprite->data6 == 0) + { + sprite->data1 = 32; + sprite->data0++; + } +} + +void PokeballGlowEffect_1(struct Sprite *sprite) +{ + if ((--sprite->data1) == 0) + { + sprite->data0++; + sprite->data1 = 8; + sprite->data2 = 0; + sprite->data3 = 0; + if (sprite->data5) + { + PlayFanfare(BGM_ME_ASA); + } + } +} + +void PokeballGlowEffect_2(struct Sprite *sprite) +{ + u8 phase; + if ((--sprite->data1) == 0) + { + sprite->data1 = 8; + sprite->data2++; + sprite->data2 &= 3; + if (sprite->data2 == 0) + { + sprite->data3++; + } + } + phase = (sprite->data2 + 3) & 3; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x108, gUnknown_0839F2C0[phase], gUnknown_0839F2C4[phase], gUnknown_0839F2C8[phase]); + phase = (sprite->data2 + 2) & 3; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x106, gUnknown_0839F2C0[phase], gUnknown_0839F2C4[phase], gUnknown_0839F2C8[phase]); + phase = (sprite->data2 + 1) & 3; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x102, gUnknown_0839F2C0[phase], gUnknown_0839F2C4[phase], gUnknown_0839F2C8[phase]); + phase = sprite->data2; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x105, gUnknown_0839F2C0[phase], gUnknown_0839F2C4[phase], gUnknown_0839F2C8[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x103, gUnknown_0839F2C0[phase], gUnknown_0839F2C4[phase], gUnknown_0839F2C8[phase]); + if (sprite->data3 > 2) + { + sprite->data0++; + sprite->data1 = 8; + sprite->data2 = 0; + } +} + +void PokeballGlowEffect_3(struct Sprite *sprite) +{ + u8 phase; + if ((--sprite->data1) == 0) + { + sprite->data1 = 8; + sprite->data2++; + sprite->data2 &= 3; + if (sprite->data2 == 3) + { + sprite->data0++; + sprite->data1 = 30; + } + } + phase = sprite->data2; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x108, gUnknown_0839F2C0[phase], gUnknown_0839F2C4[phase], gUnknown_0839F2C8[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x106, gUnknown_0839F2C0[phase], gUnknown_0839F2C4[phase], gUnknown_0839F2C8[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x102, gUnknown_0839F2C0[phase], gUnknown_0839F2C4[phase], gUnknown_0839F2C8[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x105, gUnknown_0839F2C0[phase], gUnknown_0839F2C4[phase], gUnknown_0839F2C8[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x103, gUnknown_0839F2C0[phase], gUnknown_0839F2C4[phase], gUnknown_0839F2C8[phase]); +} + +void PokeballGlowEffect_4(struct Sprite *sprite) +{ + if ((--sprite->data1) == 0) + { + sprite->data0++; + } +} + +void PokeballGlowEffect_5(struct Sprite *sprite) +{ + sprite->data0++; +} + +void PokeballGlowEffect_6(struct Sprite *sprite) +{ + if (sprite->data5 == 0 || IsFanfareTaskInactive()) + { + sprite->data0++; + } +} + +void PokeballGlowEffect_7(struct Sprite *sprite) +{ +} + +void SpriteCB_PokeballGlow(struct Sprite *sprite) +{ + if (gSprites[sprite->data0].data0 > 4) + { + FieldEffectFreeGraphicsResources(sprite); + } +} + +u8 PokecenterHealEffectHelper(s16 x, s16 y) +{ + u8 spriteIdAtEnd; + struct Sprite *sprite; + spriteIdAtEnd = CreateSpriteAtEnd(&gSpriteTemplate_839F220, x, y, 0); + sprite = &gSprites[spriteIdAtEnd]; + sprite->oam.priority = 2; + sprite->invisible = 1; + SetSubspriteTables(sprite, &gUnknown_0839F1A0); + return spriteIdAtEnd; +} + +void SpriteCB_PokecenterMonitor(struct Sprite *sprite) +{ + if (sprite->data0 != 0) + { + sprite->data0 = 0; + sprite->invisible = 0; + StartSpriteAnim(sprite, 1); + } + if (sprite->animEnded) + { + FieldEffectFreeGraphicsResources(sprite); + } +} + +void HallOfFameRecordEffectHelper(s16 a0, s16 a1, s16 a2, u8 a3) +{ + u8 spriteIdAtEnd; + if (!a3) + { + spriteIdAtEnd = CreateSpriteAtEnd(&gSpriteTemplate_839F238, a1, a2, 0); + SetSubspriteTables(&gSprites[spriteIdAtEnd], &gUnknown_0839F1C8); + } else + { + spriteIdAtEnd = CreateSpriteAtEnd(&gSpriteTemplate_839F250, a1, a2, 0); + } + gSprites[spriteIdAtEnd].invisible = 1; + gSprites[spriteIdAtEnd].data0 = a0; +} + +void SpriteCB_HallOfFameMonitor(struct Sprite *sprite) +{ + if (gTasks[sprite->data0].data[15]) + { + if (sprite->data1 == 0 || (--sprite->data1) == 0) + { + sprite->data1 = 16; + sprite->invisible ^= 1; + } + sprite->data2++; + } + if (sprite->data2 > 127) + { + FieldEffectFreeGraphicsResources(sprite); + } +} + +void mapldr_080842E8(void); +void mapldr_08084390(void); +void task00_8084310(u8); +void c3_080843F8(u8); + +void sub_80865BC(void) +{ + SetMainCallback2(c2_exit_to_overworld_2_switch); + gFieldCallback = mapldr_080842E8; +} + +void mapldr_080842E8(void) +{ + pal_fill_black(); + CreateTask(task00_8084310, 0); + ScriptContext2_Enable(); + FreezeMapObjects(); + gFieldCallback = NULL; +} + +void task00_8084310(u8 taskId) +{ + struct Task *task; + task = &gTasks[taskId]; + if (!task->data[0]) + { + if (!sub_807D770()) + { + return; + } + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; + if ((int)gUnknown_0202FF84[0] > 5) + { + gUnknown_0202FF84[0] = 0; + } + FieldEffectStart(FLDEFF_USE_FLY); + task->data[0]++; + } + if (!FieldEffectActiveListContains(FLDEFF_USE_FLY)) + { + flag_var_implications_of_teleport_(); + warp_in(); + SetMainCallback2(CB2_LoadMap); + gFieldCallback = mapldr_08084390; + DestroyTask(taskId); + } +} + +void mapldr_08084390(void) +{ + sub_8053E90(); + pal_fill_black(); + CreateTask(c3_080843F8, 0); + gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 1; + if (gPlayerAvatar.flags & 0x08) + { + FieldObjectTurn(&gMapObjects[gPlayerAvatar.mapObjectId], DIR_WEST); + } + ScriptContext2_Enable(); + FreezeMapObjects(); + gFieldCallback = NULL; +} + +void c3_080843F8(u8 taskId) +{ + struct Task *task; + task = &gTasks[taskId]; + if (task->data[0] == 0) + { + if (gPaletteFade.active) + { + return; + } + FieldEffectStart(FLDEFF_FLY_IN); + task->data[0]++; + } + if (!FieldEffectActiveListContains(FLDEFF_FLY_IN)) + { + ScriptContext2_Disable(); + UnfreezeMapObjects(); + DestroyTask(taskId); + } +} + +extern void pal_fill_for_map_transition(void); +void sub_8086774(u8); +extern void CameraObjectReset2(void); +extern void CameraObjectReset1(void); + +void sub_8086748(void) +{ + sub_8053E90(); + pal_fill_for_map_transition(); + ScriptContext2_Enable(); + FreezeMapObjects(); + CreateTask(sub_8086774, 0); + gFieldCallback = NULL; +} + +void sub_8086774(u8 taskId) +{ + struct Task *task; + task = &gTasks[taskId]; + while (gUnknown_0839F2CC[task->data[0]](task)); // return code signifies whether to continue blocking here +} + +bool8 sub_80867AC(struct Task *task) // gUnknown_0839F2CC[0] +{ + struct MapObject *playerObject; + struct Sprite *playerSprite; + playerObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + playerSprite = &gSprites[gPlayerAvatar.spriteId]; + CameraObjectReset2(); + gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 1; + gPlayerAvatar.unk6 = 1; + FieldObjectSetSpecialAnim(playerObject, GetFaceDirectionAnimId(player_get_direction_lower_nybble())); + task->data[4] = playerSprite->subspriteMode; + playerObject->mapobj_bit_26 = 1; + playerSprite->oam.priority = 1; + playerSprite->subspriteMode = 2; + task->data[0]++; + return TRUE; +} + +bool8 sub_8086854(struct Task *task) // gUnknown_0839F2CC[1] +{ + if (sub_807D770()) + { + task->data[0]++; + } + return FALSE; +} + +bool8 sub_8086870(struct Task *task) // gUnknown_0839F2CC[2] +{ + struct Sprite *sprite; + s16 centerToCornerVecY; + sprite = &gSprites[gPlayerAvatar.spriteId]; + centerToCornerVecY = -(sprite->centerToCornerVecY << 1); + sprite->pos2.y = -(sprite->pos1.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY + centerToCornerVecY); + task->data[1] = 1; + task->data[2] = 0; + gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 0; + PlaySE(SE_RU_HYUU); + task->data[0]++; + return FALSE; +} + +bool8 sub_80868E4(struct Task *task) +{ + struct MapObject *mapObject; + struct Sprite *sprite; + + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + sprite = &gSprites[gPlayerAvatar.spriteId]; + sprite->pos2.y += task->data[1]; + if (task->data[1] < 8) + { + task->data[2] += task->data[1]; + if (task->data[2] & 0xf) + { + task->data[1] <<= 1; + } + } + if (task->data[3] == 0 && sprite->pos2.y >= -16) + { + task->data[3]++; + mapObject->mapobj_bit_26 = 0; + sprite->subspriteMode = task->data[4]; + mapObject->mapobj_bit_2 = 1; + } + if (sprite->pos2.y >= 0) + { + PlaySE(SE_W070); + mapObject->mapobj_bit_3 = 1; + mapObject->mapobj_bit_5 = 1; + sprite->pos2.y = 0; + task->data[0]++; + } + return FALSE; +} + +bool8 sub_808699C(struct Task *task) +{ + task->data[0]++; + task->data[1] = 4; + task->data[2] = 0; + SetCameraPanningCallback(NULL); + return TRUE; +} + +bool8 sub_80869B8(struct Task *task) +{ + SetCameraPanning(0, task->data[1]); + task->data[1] = -task->data[1]; + task->data[2]++; + if ((task->data[2] & 3) == 0) + { + task->data[1] >>= 1; + } + if (task->data[1] == 0) + { + task->data[0]++; + } + return FALSE; +} + +bool8 sub_80869F8(struct Task *task) +{ + gPlayerAvatar.unk6 = 0; + ScriptContext2_Disable(); + CameraObjectReset1(); + UnfreezeMapObjects(); + InstallCameraPanAheadCallback(); + DestroyTask(FindTaskIdByFunc(sub_8086774)); + return FALSE; +} + +void sub_8086A68(u8); +extern void sub_80B4824(u8); +extern void sub_8053FF8(void); +extern void fade_8080918(void); + +void sub_8086B98(struct Task *); +void sub_8086BE4(struct Task *); +void sub_8086C30(void); +void sub_8086C40(void); +bool8 sub_8054034(void); +void sub_8086C94(void); +void sub_80B483C(void); +void sub_8086CBC(u8); + +void sub_8086A2C(u8 a0, u8 priority) +{ + u8 taskId; + taskId = CreateTask(sub_8086A68, priority); + gTasks[taskId].data[1] = 0; + if (a0 == 0x6a) + { + gTasks[taskId].data[1] = 1; + } +} + +void sub_8086A68(u8 taskId) +{ + struct Task *task; + task = &gTasks[taskId]; + while (gUnknown_0839F2E8[task->data[0]](task)); +} + +bool8 sub_8086AA0(struct Task *task) +{ + FreezeMapObjects(); + CameraObjectReset2(); + sub_80B4824(task->data[1]); + task->data[0]++; + return FALSE; +} + +bool8 sub_8086AC0(struct Task *task) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(mapObject) || FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(player_get_direction_lower_nybble())); + task->data[0]++; + task->data[2] = 0; + task->data[3] = 0; + if ((u8)task->data[1] == 0) + { + task->data[0] = 4; + } + PlaySE(SE_ESUKA); + } + return FALSE; +} + +bool8 sub_8086B30(struct Task *task) +{ + sub_8086B98(task); + if (task->data[2] > 3) + { + sub_8086C30(); + task->data[0]++; + } + return FALSE; +} + +bool8 sub_8086B54(struct Task *task) +{ + sub_8086B98(task); + sub_8086C40(); + return FALSE; +} + +bool8 sub_8086B64(struct Task *task) +{ + sub_8086BE4(task); + if (task->data[2] > 3) + { + sub_8086C30(); + task->data[0]++; + } + return FALSE; +} + +bool8 sub_8086B88(struct Task *task) +{ + sub_8086BE4(task); + sub_8086C40(); + return FALSE; +} + +void sub_8086B98(struct Task *task) +{ + struct Sprite *sprite; + sprite = &gSprites[gPlayerAvatar.spriteId]; + sprite->pos2.x = Cos(0x84, task->data[2]); + sprite->pos2.y = Sin(0x94, task->data[2]); + task->data[3]++; + if (task->data[3] & 1) + { + task->data[2]++; + } +} + +void sub_8086BE4(struct Task *task) +{ + struct Sprite *sprite; + sprite = &gSprites[gPlayerAvatar.spriteId]; + sprite->pos2.x = Cos(0x7c, task->data[2]); + sprite->pos2.y = Sin(0x76, task->data[2]); + task->data[3]++; + if (task->data[3] & 1) + { + task->data[2]++; + } +} + +void sub_8086C30(void) +{ + sub_8053FF8(); + fade_8080918(); +} + +void sub_8086C40(void) +{ + if (!gPaletteFade.active && sub_8054034() == TRUE) + { + sub_80B483C(); + warp_in(); + gFieldCallback = sub_8086C94; + SetMainCallback2(CB2_LoadMap); + DestroyTask(FindTaskIdByFunc(sub_8086A68)); + } +} + +void sub_8086C94(void) +{ + sub_8053E90(); + pal_fill_for_map_transition(); + ScriptContext2_Enable(); + CreateTask(sub_8086CBC, 0); + gFieldCallback = NULL; +} + +void sub_8086CBC(u8 taskId) +{ + struct Task *task; + task = &gTasks[taskId]; + while (gUnknown_0839F300[task->data[0]](task)); +} + +bool8 sub_8086CF4(struct Task *task) +{ + struct MapObject *mapObject; + s16 x; + s16 y; + u8 behavior; + CameraObjectReset2(); + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(DIR_EAST)); + PlayerGetDestCoords(&x, &y); + behavior = MapGridGetMetatileBehaviorAt(x, y); + task->data[0]++; + task->data[1] = 16; + if (behavior == 0x6b) + { + behavior = 1; + task->data[0] = 3; + } else + { + behavior = 0; + } + sub_80B4824(behavior); + return TRUE; +} + +bool8 sub_8086D70(struct Task *task) +{ + struct Sprite *sprite; + sprite = &gSprites[gPlayerAvatar.spriteId]; + sprite->pos2.x = Cos(0x84, task->data[1]); + sprite->pos2.y = Sin(0x94, task->data[1]); + task->data[0]++; + return FALSE; +} + +bool8 sub_8086DB0(struct Task *task) +{ + struct Sprite *sprite; + sprite = &gSprites[gPlayerAvatar.spriteId]; + sprite->pos2.x = Cos(0x84, task->data[1]); + sprite->pos2.y = Sin(0x94, task->data[1]); + task->data[2]++; + if (task->data[2] & 1) + { + task->data[1]--; + } + if (task->data[1] == 0) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + task->data[0] = 5; + } + return FALSE; +} + +bool8 sub_8086E10(struct Task *task) +{ + struct Sprite *sprite; + sprite = &gSprites[gPlayerAvatar.spriteId]; + sprite->pos2.x = Cos(0x7c, task->data[1]); + sprite->pos2.y = Sin(0x76, task->data[1]); + task->data[0]++; + return FALSE; +} + +bool8 sub_8086E50(struct Task *task) +{ + struct Sprite *sprite; + sprite = &gSprites[gPlayerAvatar.spriteId]; + sprite->pos2.x = Cos(0x7c, task->data[1]); + sprite->pos2.y = Sin(0x76, task->data[1]); + task->data[2]++; + if (task->data[2] & 1) + { + task->data[1]--; + } + if (task->data[1] == 0) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + task->data[0]++; + } + return FALSE; +} + +extern bool8 sub_80B4850(void); + +bool8 sub_8086EB0(struct Task *task) +{ + if (sub_80B4850()) + { + return FALSE; + } + sub_80B483C(); + task->data[0]++; + return TRUE; +} + +bool8 sub_8086ED4(struct Task *task) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + CameraObjectReset1(); + ScriptContext2_Disable(); + FieldObjectSetSpecialAnim(mapObject, GetGoSpeed0AnimId(DIR_EAST)); + DestroyTask(FindTaskIdByFunc(sub_8086CBC)); + } + return FALSE; +} + +void sub_8086F64(u8); + +bool8 FldEff_UseWaterfall(void) +{ + u8 taskId; + taskId = CreateTask(sub_8086F64, 0xff); + gTasks[taskId].data[1] = gUnknown_0202FF84[0]; + sub_8086F64(taskId); + return FALSE; +} + +void sub_8086F64(u8 taskId) +{ + while (gUnknown_0839F31C[gTasks[taskId].data[0]](&gTasks[taskId], &gMapObjects[gPlayerAvatar.mapObjectId])); +} + +bool8 sub_8086FB0(struct Task *task, struct MapObject *mapObject) +{ + ScriptContext2_Enable(); + gPlayerAvatar.unk6 = 1; + task->data[0]++; + return FALSE; +} + +bool8 waterfall_1_do_anim_probably(struct Task *task, struct MapObject *mapObject) +{ + ScriptContext2_Enable(); + if (!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(mapObject)) + { + FieldObjectClearAnimIfSpecialAnimFinished(mapObject); + gUnknown_0202FF84[0] = task->data[1]; + FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); + task->data[0]++; + } + return FALSE; +} + +bool8 waterfall_2_wait_anim_finish_probably(struct Task *task, struct MapObject *mapObject) +{ + if (FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON)) + { + return FALSE; + } + task->data[0]++; + return TRUE; +} + +bool8 sub_8087030(struct Task *task, struct MapObject *mapObject) +{ + FieldObjectSetSpecialAnim(mapObject, GetSimpleGoAnimId(DIR_NORTH)); + task->data[0]++; + return FALSE; +} + +bool8 sub_8087058(struct Task *task, struct MapObject *mapObject) +{ + if (!FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + return FALSE; + } + if (MetatileBehavior_IsWaterfall(mapObject->mapobj_unk_1E)) + { + task->data[0] = 3; + return TRUE; + } + ScriptContext2_Disable(); + gPlayerAvatar.unk6 = 0; + DestroyTask(FindTaskIdByFunc(sub_8086F64)); + FieldEffectActiveListRemove(FLDEFF_USE_WATERFALL); + return FALSE; +} + +void Task_Dive(u8); +extern int dive_warp(struct MapPosition *, u16); + +bool8 FldEff_UseDive(void) +{ + u8 taskId; + taskId = CreateTask(Task_Dive, 0xff); + gTasks[taskId].data[15] = gUnknown_0202FF84[0]; + gTasks[taskId].data[14] = gUnknown_0202FF84[1]; + Task_Dive(taskId); + return FALSE; +} + +void Task_Dive(u8 taskId) +{ + while (gUnknown_0839F330[gTasks[taskId].data[0]](&gTasks[taskId])); +} + +bool8 sub_8087124(struct Task *task) +{ + gPlayerAvatar.unk6 = 1; + task->data[0]++; + return FALSE; +} + +bool8 dive_2_unknown(struct Task *task) +{ + ScriptContext2_Enable(); + gUnknown_0202FF84[0] = task->data[15]; + FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); + task->data[0]++; + return FALSE; +} + +bool8 dive_3_unknown(struct Task *task) +{ + struct MapPosition mapPosition; + PlayerGetDestCoords(&mapPosition.x, &mapPosition.y); + if (!FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON)) + { + dive_warp(&mapPosition, gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E); + DestroyTask(FindTaskIdByFunc(Task_Dive)); + FieldEffectActiveListRemove(FLDEFF_USE_DIVE); + } + return FALSE; +} + +void sub_80871D0(u8); +void mapldr_080851BC(void); + +void sub_80871B8(u8 priority) +{ + CreateTask(sub_80871D0, priority); +} + +void sub_80871D0(u8 taskId) +{ + while (gUnknown_0839F33C[gTasks[taskId].data[0]](&gTasks[taskId], &gMapObjects[gPlayerAvatar.mapObjectId], &gSprites[gPlayerAvatar.spriteId])); +} + +bool8 sub_808722C(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + FreezeMapObjects(); + CameraObjectReset2(); + SetCameraPanningCallback(NULL); + gPlayerAvatar.unk6 = 1; + mapObject->mapobj_bit_26 = 1; + task->data[1] = 1; + task->data[0]++; + return TRUE; +} + +bool8 sub_8087264(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + SetCameraPanning(0, task->data[1]); + task->data[1] = -task->data[1]; + task->data[2]++; + if (task->data[2] > 7) + { + task->data[2] = 0; + task->data[0]++; + } + return FALSE; +} + +bool8 sub_8087298(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->pos2.y = 0; + task->data[3] = 1; + gUnknown_0202FF84[0] = mapObject->coords2.x; + gUnknown_0202FF84[1] = mapObject->coords2.y; + gUnknown_0202FF84[2] = sprite->subpriority - 1; + gUnknown_0202FF84[3] = sprite->oam.priority; + FieldEffectStart(FLDEFF_LAVARIDGE_GYM_WARP); + PlaySE(SE_W153); + task->data[0]++; + return TRUE; +} + +bool8 sub_80872E4(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + s16 centerToCornerVecY; + SetCameraPanning(0, task->data[1]); + if (task->data[1] = -task->data[1], ++task->data[2] <= 17) + { + if (!(task->data[2] & 1) && (task->data[1] <= 3)) + { + task->data[1] <<= 1; + } + } else if (!(task->data[2] & 4) && (task->data[1] > 0)) + { + task->data[1] >>= 1; + } + if (task->data[2] > 6) + { + centerToCornerVecY = -(sprite->centerToCornerVecY << 1); + if (sprite->pos2.y > -(sprite->pos1.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY + centerToCornerVecY)) + { + sprite->pos2.y -= task->data[3]; + if (task->data[3] <= 7) + { + task->data[3]++; + } + } else + { + task->data[4] = 1; + } + } + if (task->data[5] == 0 && sprite->pos2.y < -0x10) + { + task->data[5]++; + mapObject->mapobj_bit_26 = 1; + sprite->oam.priority = 1; + sprite->subspriteMode = 2; + } + if (task->data[1] == 0 && task->data[4] != 0) + { + task->data[0]++; + } + return FALSE; +} + +bool8 sub_80873D8(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8053FF8(); + fade_8080918(); + task->data[0]++; + return FALSE; +} + +bool8 sub_80873F4(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + if (!gPaletteFade.active && sub_8054034() == TRUE) + { + warp_in(); + gFieldCallback = mapldr_080851BC; + SetMainCallback2(CB2_LoadMap); + DestroyTask(FindTaskIdByFunc(sub_80871D0)); + } + return FALSE; +} + +void sub_8087470(u8); +extern u8 sub_80608A4(u8); + +void mapldr_080851BC(void) +{ + sub_8053E90(); + pal_fill_for_map_transition(); + ScriptContext2_Enable(); + gFieldCallback = NULL; + CreateTask(sub_8087470, 0); +} + +void sub_8087470(u8 taskId) +{ + while (gUnknown_0839F354[gTasks[taskId].data[0]](&gTasks[taskId], &gMapObjects[gPlayerAvatar.mapObjectId], &gSprites[gPlayerAvatar.spriteId])); +} + +bool8 sub_80874CC(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + CameraObjectReset2(); + FreezeMapObjects(); + gPlayerAvatar.unk6 = 1; + mapObject->mapobj_bit_13 = 1; + task->data[0]++; + return FALSE; +} + +bool8 sub_80874FC(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_807D770()) + { + gUnknown_0202FF84[0] = mapObject->coords2.x; + gUnknown_0202FF84[1] = mapObject->coords2.y; + gUnknown_0202FF84[2] = sprite->subpriority - 1; + gUnknown_0202FF84[3] = sprite->oam.priority; + task->data[1] = FieldEffectStart(FLDEFF_POP_OUT_OF_ASH); + task->data[0]++; + } + return FALSE; +} + +bool8 sub_8087548(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite = &gSprites[task->data[1]]; + if (sprite->animCmdIndex > 1) + { + task->data[0]++; + mapObject->mapobj_bit_13 = 0; + CameraObjectReset1(); + PlaySE(SE_W091); + FieldObjectSetSpecialAnim(mapObject, sub_80608A4(DIR_EAST)); + } + return FALSE; +} + +bool8 sub_808759C(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + gPlayerAvatar.unk6 = 0; + ScriptContext2_Disable(); + UnfreezeMapObjects(); + DestroyTask(FindTaskIdByFunc(sub_8087470)); + } + return FALSE; +} + +extern void sub_8060470(s16 *x, s16 *y, s16 dx, s16 dy); +extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[36]; + +u8 FldEff_LavaridgeGymWarp(void) +{ + u8 spriteId; + sub_8060470((s16 *)&gUnknown_0202FF84[0], (s16 *)&gUnknown_0202FF84[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[33], gUnknown_0202FF84[0], gUnknown_0202FF84[1], gUnknown_0202FF84[2]); + gSprites[spriteId].oam.priority = gUnknown_0202FF84[3]; + gSprites[spriteId].coordOffsetEnabled = 1; + return spriteId; +} + +void sub_8087638(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + FieldEffectStop(sprite, FLDEFF_LAVARIDGE_GYM_WARP); + } +} + +void sub_808766C(u8); + +void sub_8087654(u8 priority) +{ + CreateTask(sub_808766C, priority); +} + +void sub_808766C(u8 taskId) +{ + while(gUnknown_0839F364[gTasks[taskId].data[0]](&gTasks[taskId], &gMapObjects[gPlayerAvatar.mapObjectId], &gSprites[gPlayerAvatar.spriteId])); +} + +bool8 sub_80876C8(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + FreezeMapObjects(); + CameraObjectReset2(); + gPlayerAvatar.unk6 = 1; + mapObject->mapobj_bit_26 = 1; + task->data[0]++; + return FALSE; +} + +bool8 sub_80876F8(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + if (task->data[1] > 3) + { + gUnknown_0202FF84[0] = mapObject->coords2.x; + gUnknown_0202FF84[1] = mapObject->coords2.y; + gUnknown_0202FF84[2] = sprite->subpriority - 1; + gUnknown_0202FF84[3] = sprite->oam.priority; + task->data[1] = FieldEffectStart(FLDEFF_POP_OUT_OF_ASH); + task->data[0]++; + } else + { + task->data[1]++; + FieldObjectSetSpecialAnim(mapObject, GetStepInPlaceDelay4AnimId(mapObject->mapobj_unk_18)); + PlaySE(SE_FU_ZUZUZU); + } + } + return FALSE; +} + +bool8 sub_8087774(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + if (gSprites[task->data[1]].animCmdIndex == 2) + { + mapObject->mapobj_bit_13 = 1; + task->data[0]++; + } + return FALSE; +} + +bool8 sub_80877AC(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + if (!FieldEffectActiveListContains(FLDEFF_POP_OUT_OF_ASH)) + { + sub_8053FF8(); + fade_8080918(); + task->data[0]++; + } + return FALSE; +} + +void sub_80878C4(u8); +void mapldr_080859D4(void); + +bool8 sub_80877D4(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) +{ + if (!gPaletteFade.active && sub_8054034() == TRUE) + { + warp_in(); + gFieldCallback = sub_8086748; + SetMainCallback2(CB2_LoadMap); + DestroyTask(FindTaskIdByFunc(sub_808766C)); + } + return FALSE; +} + +u8 FldEff_PopOutOfAsh(void) +{ + u8 spriteId; + sub_8060470((s16 *)&gUnknown_0202FF84[0], (s16 *)&gUnknown_0202FF84[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[32], gUnknown_0202FF84[0], gUnknown_0202FF84[1], gUnknown_0202FF84[2]); + gSprites[spriteId].oam.priority = gUnknown_0202FF84[3]; + gSprites[spriteId].coordOffsetEnabled = 1; + return spriteId; +} + +void sub_808788C(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + FieldEffectStop(sprite, FLDEFF_POP_OUT_OF_ASH); + } +} + +void sub_80878A8(void) +{ + ScriptContext2_Enable(); + FreezeMapObjects(); + CreateTask(sub_80878C4, 0x50); +} + +void sub_80878C4(u8 taskId) +{ + gUnknown_0839F378[gTasks[taskId].data[0]](&gTasks[taskId]); +} + +void sub_80878F4(struct Task *task) +{ + task->data[0]++; + task->data[14] = 64; + task->data[15] = player_get_direction_lower_nybble(); +} + +void sub_8087914(struct Task *task) +{ + struct MapObject *mapObject; + u8 unknown_0839F380[5]; + memcpy(unknown_0839F380, gUnknown_0839F380, sizeof gUnknown_0839F380); + if (task->data[14] != 0 && (--task->data[14]) == 0) + { + sub_8053FF8(); + fade_8080918(); + } + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(mapObject) || FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + if (task->data[14] == 0 && !gPaletteFade.active && sub_8054034() == TRUE) + { + FieldObjectSetDirection(mapObject, task->data[15]); + sub_8053678(); + warp_in(); + gFieldCallback = mapldr_080859D4; + SetMainCallback2(CB2_LoadMap); + DestroyTask(FindTaskIdByFunc(sub_80878C4)); + } else if (task->data[1] == 0 || (--task->data[1]) == 0) + { + FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(unknown_0839F380[mapObject->mapobj_unk_18])); + if (task->data[2] < 12) + { + task->data[2]++; + } + task->data[1] = 8 >> (task->data[2] >> 2); + } + } +} + +void sub_8087A74(u8); + +void mapldr_080859D4(void) +{ + sub_8053E90(); + pal_fill_for_map_transition(); + ScriptContext2_Enable(); + FreezeMapObjects(); + gFieldCallback = NULL; + gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 1; + CreateTask(sub_8087A74, 0); +} + +void sub_8087A74(u8 taskId) +{ + gUnknown_0839F388[gTasks[taskId].data[0]](&gTasks[taskId]); +} + +void sub_8087AA4(struct Task *task) +{ + if (sub_807D770()) + { + task->data[0]++; + task->data[15] = player_get_direction_lower_nybble(); + } +} + +void sub_8087AC8(struct Task *task) +{ + struct MapObject *mapObject; + u8 unknown_0839F380[5]; + memcpy(unknown_0839F380, gUnknown_0839F380, sizeof gUnknown_0839F380); + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (task->data[1] == 0 || (--task->data[1]) == 0) + { + if (FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(mapObject) && !FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + return; + } + if (task->data[2] >= 32 && task->data[15] == player_get_direction_lower_nybble()) + { + mapObject->mapobj_bit_13 = 0; + ScriptContext2_Disable(); + UnfreezeMapObjects(); + DestroyTask(FindTaskIdByFunc(sub_8087A74)); + return; + } + FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(unknown_0839F380[mapObject->mapobj_unk_18])); + if (task->data[2] < 32) + { + task->data[2]++; + } + task->data[1] = task->data[2] >> 2; + } + mapObject->mapobj_bit_13 ^= 1; +} + +void sub_8087BBC(u8); +void mapldr_08085D88(void); + +void sub_8087BA8(void) +{ + CreateTask(sub_8087BBC, 0); +} + +void sub_8087BBC(u8 taskId) +{ + gUnknown_0839F390[gTasks[taskId].data[0]](&gTasks[taskId]); +} + +void sub_8087BEC(struct Task *task) +{ + ScriptContext2_Enable(); + FreezeMapObjects(); + CameraObjectReset2(); + task->data[15] = player_get_direction_lower_nybble(); + task->data[0]++; +} + +void sub_8087C14(struct Task *task) +{ + struct MapObject *mapObject; + u8 unknown_0839F380[5]; + memcpy(unknown_0839F380, gUnknown_0839F380, sizeof gUnknown_0839F380); + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (task->data[1] == 0 || (--task->data[1]) == 0) + { + FieldObjectTurn(mapObject, unknown_0839F380[mapObject->mapobj_unk_18]); + task->data[1] = 8; + task->data[2]++; + } + if (task->data[2] > 7 && task->data[15] == mapObject->mapobj_unk_18) + { + task->data[0]++; + task->data[1] = 4; + task->data[2] = 8; + task->data[3] = 1; + PlaySE(SE_TK_WARPIN); + } +} + +void sub_8087CA4(struct Task *task) +{ + struct MapObject *mapObject; + struct Sprite *sprite; + u8 unknown_0839F380[5]; + memcpy(unknown_0839F380, gUnknown_0839F380, sizeof gUnknown_0839F380); + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + sprite = &gSprites[gPlayerAvatar.spriteId]; + if ((--task->data[1]) <= 0) + { + task->data[1] = 4; + FieldObjectTurn(mapObject, unknown_0839F380[mapObject->mapobj_unk_18]); + } + sprite->pos1.y -= task->data[3]; + task->data[4] += task->data[3]; + if ((--task->data[2]) <= 0 && (task->data[2] = 4, task->data[3] < 8)) + { + task->data[3] <<= 1; + } + if (task->data[4] > 8 && (sprite->oam.priority = 1, sprite->subspriteMode != 0)) + { + sprite->subspriteMode = 2; + } + if (task->data[4] >= 0xa8) + { + task->data[0]++; + sub_8053FF8(); + fade_8080918(); + } +} + +void sub_8087D78(struct Task *task) +{ + if (!gPaletteFade.active && sub_8054034() == TRUE) + { + sub_8053570(); + warp_in(); + SetMainCallback2(CB2_LoadMap); + gFieldCallback = mapldr_08085D88; + DestroyTask(FindTaskIdByFunc(sub_8087BBC)); + } +} + +void sub_8087E1C(u8); + +void mapldr_08085D88(void) +{ + sub_8053E90(); + pal_fill_for_map_transition(); + ScriptContext2_Enable(); + FreezeMapObjects(); + gFieldCallback = NULL; + gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 1; + CameraObjectReset2(); + CreateTask(sub_8087E1C, 0); +} + +void sub_8087E1C(u8 taskId) +{ + gUnknown_0839F3A0[gTasks[taskId].data[0]](&gTasks[taskId]); +} + +void sub_8087E4C(struct Task *task) +{ + struct Sprite *sprite; + s16 centerToCornerVecY; + if (sub_807D770()) + { + sprite = &gSprites[gPlayerAvatar.spriteId]; + centerToCornerVecY = -(sprite->centerToCornerVecY << 1); + sprite->pos2.y = -(sprite->pos1.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY + centerToCornerVecY); + gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 0; + task->data[0]++; + task->data[1] = 8; + task->data[2] = 1; + task->data[14] = sprite->subspriteMode; + task->data[15] = player_get_direction_lower_nybble(); + PlaySE(SE_TK_WARPIN); + } +} + +void sub_8087ED8(struct Task *task) +{ + u8 unknown_0839F380[5]; + struct MapObject *mapObject; + struct Sprite *sprite; + memcpy(unknown_0839F380, gUnknown_0839F380, sizeof gUnknown_0839F380); + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + sprite = &gSprites[gPlayerAvatar.spriteId]; + if ((sprite->pos2.y += task->data[1]) >= -8) + { + if (task->data[13] == 0) + { + task->data[13]++; + mapObject->mapobj_bit_2 = 1; + sprite->subspriteMode = task->data[14]; + } + } else + { + sprite->oam.priority = 1; + if (sprite->subspriteMode != 0) + { + sprite->subspriteMode = 2; + } + } + if (sprite->pos2.y >= -0x30 && task->data[1] > 1 && !(sprite->pos2.y & 1)) + { + task->data[1]--; + } + if ((--task->data[2]) == 0) + { + task->data[2] = 4; + FieldObjectTurn(mapObject, unknown_0839F380[mapObject->mapobj_unk_18]); + } + if (sprite->pos2.y >= 0) + { + sprite->pos2.y = 0; + task->data[0]++; + task->data[1] = 1; + task->data[2] = 0; + } +} + +void sub_8087FDC(struct Task *task) +{ + u8 unknown_0839F380[5]; + struct MapObject *mapObject; + memcpy(unknown_0839F380, gUnknown_0839F380, sizeof gUnknown_0839F380); + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if ((--task->data[1]) == 0) + { + FieldObjectTurn(mapObject, unknown_0839F380[mapObject->mapobj_unk_18]); + task->data[1] = 8; + if ((++task->data[2]) > 4 && task->data[14] == mapObject->mapobj_unk_18) + { + ScriptContext2_Disable(); + CameraObjectReset1(); + UnfreezeMapObjects(); + DestroyTask(FindTaskIdByFunc(sub_8087E1C)); + } + } +} + +void sub_8088120(u8); +void sub_808847C(u8); +u8 sub_8088830(u32, u32, u32); +void sub_80883DC(void); +void sub_808843C(u16); +void sub_8088890(struct Sprite *); + +bool8 FldEff_FieldMoveShowMon(void) +{ + u8 taskId; + if (is_light_level_1_2_3_5_or_6(sav1_map_get_light_level()) == TRUE) + { + taskId = CreateTask(sub_8088120, 0xff); + } else + { + taskId = CreateTask(sub_808847C, 0xff); + } + gTasks[taskId].data[15] = sub_8088830(gUnknown_0202FF84[0], gUnknown_0202FF84[1], gUnknown_0202FF84[2]); + return FALSE; +} + +bool8 FldEff_FieldMoveShowMonInit(void) +{ + struct Pokemon *pokemon; + u32 flag = gUnknown_0202FF84[0] & 0x80000000; + pokemon = &gPlayerParty[(u8)gUnknown_0202FF84[0]]; + gUnknown_0202FF84[0] = GetMonData(pokemon, MON_DATA_SPECIES); + gUnknown_0202FF84[1] = GetMonData(pokemon, MON_DATA_OT_ID); + gUnknown_0202FF84[2] = GetMonData(pokemon, MON_DATA_PERSONALITY); + gUnknown_0202FF84[0] |= flag; + FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON); + FieldEffectActiveListRemove(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); + return FALSE; +} + +void sub_8088120(u8 taskId) +{ + gUnknown_0839F3AC[gTasks[taskId].data[0]](&gTasks[taskId]); +} + +void sub_8088150(struct Task *task) +{ + task->data[11] = REG_WININ; + task->data[12] = REG_WINOUT; + StoreWordInTwoHalfwords(&task->data[13], (u32)gMain.vblankCallback); + task->data[1] = 0xf0f1; + task->data[2] = 0x5051; + task->data[3] = 0x3f; + task->data[4] = 0x3e; + REG_WIN0H = task->data[1]; + REG_WIN0V = task->data[2]; + REG_WININ = task->data[3]; + REG_WINOUT = task->data[4]; + SetVBlankCallback(sub_80883DC); + task->data[0]++; +} + +void sub_80881C0(struct Task *task) +{ + u16 offset; + u16 delta; + offset = ((REG_BG0CNT >> 2) << 14); + delta = ((REG_BG0CNT >> 8) << 11); + CpuCopy16(gFieldMoveStreaksTiles, (void *)(VRAM + offset), 0x200); + CpuFill32(0, (void *)(VRAM + delta), 0x800); + LoadPalette(gFieldMoveStreaksPalette, 0xf0, 0x20); + sub_808843C(delta); + task->data[0]++; +} + +void sub_8088228(struct Task *task) +{ + s16 v0; + s16 v2; + s16 v3; + task->data[5] -= 16; + v0 = ((u16)task->data[1] >> 8); + v2 = ((u16)task->data[2] >> 8); + v3 = ((u16)task->data[2] & 0xff); + v0 -= 16; + v2 -= 2; + v3 += 2; + if (v0 < 0) + { + v0 = 0; + } + if (v2 < 0x28) + { + v2 = 0x28; + } + if (v3 > 0x78) + { + v3 = 0x78; + } + task->data[1] = (v0 << 8) | (task->data[1] & 0xff); + task->data[2] = (v2 << 8) | v3; + if (v0 == 0 && v2 == 0x28 && v3 == 0x78) + { + gSprites[task->data[15]].callback = sub_8088890; + task->data[0]++; + } +} + +void sub_80882B4(struct Task *task) +{ + task->data[5] -= 16; + if (gSprites[task->data[15]].data7) + { + task->data[0]++; + } +} + +void sub_80882E4(struct Task *task) +{ + s16 v2; + s16 v3; + task->data[5] -= 16; + v2 = (task->data[2] >> 8); + v3 = (task->data[2] & 0xff); + v2 += 6; + v3 -= 6; + if (v2 > 0x50) + { + v2 = 0x50; + } + if (v3 < 0x51) + { + v3 = 0x51; + } + task->data[2] = (v2 << 8) | v3; + if (v2 == 0x50 && v3 == 0x51) + { + task->data[0]++; + } +} + +void sub_8088338(struct Task *task) +{ + u16 bg0cnt; + bg0cnt = (REG_BG0CNT >> 8) << 11; + CpuFill32(0, (void *)VRAM + bg0cnt, 0x800); + task->data[1] = 0xf1; + task->data[2] = 0xa1; + task->data[3] = task->data[11]; + task->data[4] = task->data[12]; + task->data[0]++; +} + +void sub_8088380(struct Task *task) +{ + IntrCallback callback; + LoadWordFromTwoHalfwords((u16 *)&task->data[13], (u32 *)&callback); + SetVBlankCallback(callback); + SetUpWindowConfig(&gWindowConfig_81E6CE4); + InitMenuWindow(&gWindowConfig_81E6CE4); + FreeResourcesAndDestroySprite(&gSprites[task->data[15]]); + FieldEffectActiveListRemove(FLDEFF_FIELD_MOVE_SHOW_MON); + DestroyTask(FindTaskIdByFunc(sub_8088120)); +} + +void sub_80883DC(void) +{ + struct Task *task; + IntrCallback callback; + task = &gTasks[FindTaskIdByFunc(sub_8088120)]; + LoadWordFromTwoHalfwords((u16 *)&task->data[13], (u32 *)&callback); + callback(); + REG_WIN0H = task->data[1]; + REG_WIN0V = task->data[2]; + REG_WININ = task->data[3]; + REG_WINOUT = task->data[4]; + REG_BG0HOFS = task->data[5]; + REG_BG0VOFS = task->data[6]; +} + +void sub_808843C(u16 offs) +{ + u16 i; + u16 *dest; + dest = (u16 *)(VRAM + 0x140 + offs); + for (i=0; i<0x140; i++, dest++) + { + *dest = gFieldMoveStreaksTilemap[i] | 0xf000; + } +} + +void sub_80886B0(void); +bool8 sub_8088708(struct Task *); +void sub_80886F8(struct Task *); +bool8 sub_80887C0(struct Task *); + +void sub_808847C(u8 taskId) +{ + gUnknown_0839F3C8[gTasks[taskId].data[0]](&gTasks[taskId]); +} + +void sub_80884AC(struct Task *task) +{ + REG_BG0HOFS = task->data[1]; + REG_BG0VOFS = task->data[2]; + StoreWordInTwoHalfwords((u16 *)&task->data[13], (u32)gMain.vblankCallback); + SetVBlankCallback(sub_80886B0); + task->data[0]++; +} + +void sub_80884E8(struct Task *task) +{ + u16 offset; + u16 delta; + offset = ((REG_BG0CNT >> 2) << 14); + delta = ((REG_BG0CNT >> 8) << 11); + task->data[12] = delta; + CpuCopy16(gDarknessFieldMoveStreaksTiles, (void *)(VRAM + offset), 0x80); + CpuFill32(0, (void *)(VRAM + delta), 0x800); + LoadPalette(gDarknessFieldMoveStreaksPalette, 0xf0, 0x20); + task->data[0]++; +} + +void sub_8088554(struct Task *task) +{ + if (sub_8088708(task)) + { + REG_WIN1H = 0x00f0; + REG_WIN1V = 0x2878; + gSprites[task->data[15]].callback = sub_8088890; + task->data[0]++; + } + sub_80886F8(task); +} + +void sub_80885A8(struct Task *task) +{ + sub_80886F8(task); + if (gSprites[task->data[15]].data7) + { + task->data[0]++; + } +} + +void sub_80885D8(struct Task *task) +{ + sub_80886F8(task); + task->data[3] = task->data[1] & 7; + task->data[4] = 0; + REG_WIN1H = 0xffff; + REG_WIN1V = 0xffff; + task->data[0]++; +} + +void sub_808860C(struct Task *task) +{ + sub_80886F8(task); + if (sub_80887C0(task)) + { + task->data[0]++; + } +} + +void sub_808862C(struct Task *task) +{ + IntrCallback intrCallback; + u16 bg0cnt; + bg0cnt = (REG_BG0CNT >> 8) << 11; + CpuFill32(0, (void *)VRAM + bg0cnt, 0x800); + LoadWordFromTwoHalfwords((u16 *)&task->data[13], (u32 *)&intrCallback); + SetVBlankCallback(intrCallback); + SetUpWindowConfig(&gWindowConfig_81E6CE4); + InitMenuWindow(&gWindowConfig_81E6CE4); + FreeResourcesAndDestroySprite(&gSprites[task->data[15]]); + FieldEffectActiveListRemove(FLDEFF_FIELD_MOVE_SHOW_MON); + DestroyTask(FindTaskIdByFunc(sub_808847C)); +} + +void sub_80886B0(void) +{ + IntrCallback intrCallback; + struct Task *task; + task = &gTasks[FindTaskIdByFunc(sub_808847C)]; + LoadWordFromTwoHalfwords((u16 *)&task->data[13], (u32 *)&intrCallback); + intrCallback(); + REG_BG0HOFS = task->data[1]; + REG_BG0VOFS = task->data[2]; +} + +void sub_80886F8(struct Task *task) +{ + task->data[1] -= 16; + task->data[3] += 16; +} + +#ifdef NONMATCHING +bool8 sub_8088708(struct Task *task) +{ + u16 i; + u16 srcOffs; + u16 dstOffs; + u16 *dest; + if (task->data[4] >= 32) + { + return TRUE; + } + dstOffs = (task->data[3] >> 3) & 0x1f; + if (dstOffs >= task->data[4]) + { + dstOffs = (32 - dstOffs) & 0x1f; + srcOffs = (32 - task->data[4]) & 0x1f; + dest = (u16 *)(VRAM + 0x140 + (u16)task->data[12]); + for (i=0; i<10; i++) + { + dest[dstOffs + i * 32] = gDarknessFieldMoveStreaksTilemap[srcOffs + i * 32] | 0xf000; + dest[((dstOffs + 1) & 0x1f) + i * 32] = gDarknessFieldMoveStreaksTilemap[((srcOffs + 1) & 0x1f) + i * 32] | 0xf000; + } + task->data[4] += 2; + } + return FALSE; +} +#else +__attribute__((naked)) +bool8 sub_8088708(struct Task *task) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmov r7, r10\n" + "\tmov r6, r9\n" + "\tmov r5, r8\n" + "\tpush {r5-r7}\n" + "\tsub sp, 0x4\n" + "\tadds r5, r0, 0\n" + "\tldrh r2, [r5, 0x10]\n" + "\tmovs r1, 0x10\n" + "\tldrsh r0, [r5, r1]\n" + "\tcmp r0, 0x1F\n" + "\tble _08088724\n" + "\tmovs r0, 0x1\n" + "\tb _080887A8\n" + "_08088724:\n" + "\tldrh r0, [r5, 0xE]\n" + "\tlsls r0, 16\n" + "\tasrs r3, r0, 19\n" + "\tmovs r1, 0x1F\n" + "\tands r3, r1\n" + "\tmovs r4, 0x10\n" + "\tldrsh r0, [r5, r4]\n" + "\tcmp r3, r0\n" + "\tblt _080887A6\n" + "\tmovs r0, 0x20\n" + "\tsubs r3, r0, r3\n" + "\tands r3, r1\n" + "\tsubs r0, r2\n" + "\tmov r12, r0\n" + "\tmov r7, r12\n" + "\tands r7, r1\n" + "\tmov r12, r7\n" + "\tldrh r0, [r5, 0x20]\n" + "\tldr r1, _080887B8 @ =0x06000140\n" + "\tadds r1, r0\n" + "\tmov r8, r1\n" + "\tmovs r4, 0\n" + "\tldr r7, _080887BC @ =gDarknessFieldMoveStreaksTilemap\n" + "\tmov r10, r7\n" + "\tmovs r0, 0xF0\n" + "\tlsls r0, 8\n" + "\tmov r9, r0\n" + "\tadds r1, r3, 0x1\n" + "\tmovs r0, 0x1F\n" + "\tands r1, r0\n" + "\tstr r1, [sp]\n" + "\tmov r6, r12\n" + "\tadds r6, 0x1\n" + "\tands r6, r0\n" + "_08088768:\n" + "\tlsls r1, r4, 5\n" + "\tadds r2, r1, r3\n" + "\tlsls r2, 1\n" + "\tadd r2, r8\n" + "\tmov r7, r12\n" + "\tadds r0, r7, r1\n" + "\tlsls r0, 1\n" + "\tadd r0, r10\n" + "\tldrh r0, [r0]\n" + "\tmov r7, r9\n" + "\torrs r0, r7\n" + "\tstrh r0, [r2]\n" + "\tldr r0, [sp]\n" + "\tadds r2, r1, r0\n" + "\tlsls r2, 1\n" + "\tadd r2, r8\n" + "\tadds r1, r6, r1\n" + "\tlsls r1, 1\n" + "\tadd r1, r10\n" + "\tldrh r0, [r1]\n" + "\tmov r1, r9\n" + "\torrs r0, r1\n" + "\tstrh r0, [r2]\n" + "\tadds r0, r4, 0x1\n" + "\tlsls r0, 16\n" + "\tlsrs r4, r0, 16\n" + "\tcmp r4, 0x9\n" + "\tbls _08088768\n" + "\tldrh r0, [r5, 0x10]\n" + "\tadds r0, 0x2\n" + "\tstrh r0, [r5, 0x10]\n" + "_080887A6:\n" + "\tmovs r0, 0\n" + "_080887A8:\n" + "\tadd sp, 0x4\n" + "\tpop {r3-r5}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tmov r10, r5\n" + "\tpop {r4-r7}\n" + "\tpop {r1}\n" + "\tbx r1\n" + "\t.align 2, 0\n" + "_080887B8: .4byte 0x06000140\n" + "_080887BC: .4byte gDarknessFieldMoveStreaksTilemap"); +} +#endif + +bool8 sub_80887C0(struct Task *task) +{ + u16 i; + u16 dstOffs; + u16 *dest; + if (task->data[4] >= 32) + { + return TRUE; + } + dstOffs = task->data[3] >> 3; + if (dstOffs >= task->data[4]) + { + dstOffs = (task->data[1] >> 3) & 0x1f; + dest = (u16 *)(VRAM + 0x140 + (u16)task->data[12]); + for (i=0; i<10; i++) + { + dest[dstOffs + i * 32] = 0xf000; + dest[((dstOffs + 1) & 0x1f) + i * 32] = 0xf000; + } + task->data[4] += 2; + } + return FALSE; +} + +u8 sub_8088830(u32 a0, u32 a1, u32 a2) +{ + u16 v0; + u8 monSprite; + struct Sprite *sprite; + v0 = (a0 & 0x80000000) >> 16; + a0 &= 0x7fffffff; + monSprite = CreateMonSprite_FieldMove(a0, a1, a2, 0x140, 0x50, 0); + sprite = &gSprites[monSprite]; + sprite->callback = SpriteCallbackDummy; + sprite->oam.priority = 0; + sprite->data0 = a0; + sprite->data6 = v0; + return monSprite; +} + +void sub_80888D4(struct Sprite *); + +void sub_8088890(struct Sprite *sprite) +{ + if ((sprite->pos1.x -= 20) <= 0x78) + { + sprite->pos1.x = 0x78; + sprite->data1 = 30; + sprite->callback = sub_80888D4; + if (sprite->data6) + { + PlayCry2(sprite->data0, 0, 0x7d, 0xa); + } else + { + PlayCry1(sprite->data0, 0); + } + } +} + +void sub_80888F0(struct Sprite *); + +void sub_80888D4(struct Sprite *sprite) +{ + if ((--sprite->data1) == 0) + { + sprite->callback = sub_80888F0; + } +} + +void sub_80888F0(struct Sprite *sprite) +{ + if (sprite->pos1.x < -0x40) + { + sprite->data7 = 1; + } else + { + sprite->pos1.x -= 20; + } +} + +void sub_8088954(u8); + +u8 FldEff_UseSurf(void) +{ + u8 taskId; + taskId = CreateTask(sub_8088954, 0xff); + gTasks[taskId].data[15] = gUnknown_0202FF84[0]; + sav1_reset_battle_music_maybe(); + sub_8053FB0(0x016d); + return FALSE; +} + +void sub_8088954(u8 taskId) +{ + gUnknown_0839F3E4[gTasks[taskId].data[0]](&gTasks[taskId]); +} + +void sub_8088984(struct Task *task) +{ + ScriptContext2_Enable(); + FreezeMapObjects(); + gPlayerAvatar.unk6 = 1; + SetPlayerAvatarStateMask(8); + PlayerGetDestCoords(&task->data[1], &task->data[2]); + MoveCoords(gMapObjects[gPlayerAvatar.mapObjectId].placeholder18, &task->data[1], &task->data[2]); + task->data[0]++; +} + +void sub_80889E4(struct Task *task) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(mapObject) || FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + sub_8059BF4(); + FieldObjectSetSpecialAnim(mapObject, 0x39); + task->data[0]++; + } +} + +void sub_8088A30(struct Task *task) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (FieldObjectCheckIfSpecialAnimFinishedOrInactive(mapObject)) + { + gUnknown_0202FF84[0] = task->data[15] | 0x80000000; + FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); + task->data[0]++; + } +} + +void sub_8088A78(struct Task *task) +{ + struct MapObject *mapObject; + if (!FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON)) + { + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + sub_805B980(mapObject, GetPlayerAvatarGraphicsIdByStateId(3)); + FieldObjectClearAnimIfSpecialAnimFinished(mapObject); + FieldObjectSetSpecialAnim(mapObject, sub_80608D0(mapObject->placeholder18)); + gUnknown_0202FF84[0] = task->data[1]; + gUnknown_0202FF84[1] = task->data[2]; + gUnknown_0202FF84[2] = gPlayerAvatar.mapObjectId; + mapObject->mapobj_unk_1A = FieldEffectStart(FLDEFF_SURF_BLOB); + task->data[0]++; + } +} + +void sub_8088AF4(struct Task *task) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + gPlayerAvatar.unk6 = 0; + gPlayerAvatar.flags &= 0xdf; + FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(mapObject->placeholder18)); + sub_8127ED0(mapObject->mapobj_unk_1A, 1); + UnfreezeMapObjects(); + ScriptContext2_Disable(); + FieldEffectActiveListRemove(FLDEFF_USE_SURF); + DestroyTask(FindTaskIdByFunc(sub_8088954)); + } +} + +void sub_8088BC4(struct Sprite *); + +u8 FldEff_NPCFlyOut(void) +{ + u8 spriteId; + struct Sprite *sprite; + spriteId = CreateSprite(gFieldEffectObjectTemplatePointers[26], 0x78, 0, 1); + sprite = &gSprites[spriteId]; + sprite->oam.paletteNum = 0; + sprite->oam.priority = 1; + sprite->callback = sub_8088BC4; + sprite->data1 = gUnknown_0202FF84[0]; + PlaySE(SE_W019); + return spriteId; +} + +void sub_8088BC4(struct Sprite *sprite) +{ + struct Sprite *npcSprite; + sprite->pos2.x = Cos(sprite->data2, 0x8c); + sprite->pos2.y = Sin(sprite->data2, 0x48); + sprite->data2 = (sprite->data2 + 4) & 0xff; + if (sprite->data0) + { + npcSprite = &gSprites[sprite->data1]; + npcSprite->coordOffsetEnabled = 0; + npcSprite->pos1.x = sprite->pos1.x + sprite->pos2.x; + npcSprite->pos1.y = sprite->pos1.y + sprite->pos2.y - 8; + npcSprite->pos2.x = 0; + npcSprite->pos2.y = 0; + } + if (sprite->data2 >= 0x80) + { + FieldEffectStop(sprite, FLDEFF_NPCFLY_OUT); + } +} + +void sub_8088C70(u8); +extern void sub_8127EFC(u8, u8); +u8 sub_8088F60(void); +bool8 sub_8088FA4(u8); +void sub_8088FC0(u8); +void sub_8088FFC(u8, u8); +void sub_8089018(struct Sprite *); +void sub_80890D8(struct Sprite *); + +u8 FldEff_UseFly(void) +{ + u8 taskId; + taskId = CreateTask(sub_8088C70, 0xfe); + gTasks[taskId].data[1] = gUnknown_0202FF84[0]; + return 0; +} + +void sub_8088C70(u8 taskId) +{ + gUnknown_0839F3F8[gTasks[taskId].data[0]](&gTasks[taskId]); +} + +void sub_8088CA0(struct Task *task) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(mapObject) || FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + task->data[15] = gPlayerAvatar.flags; + gPlayerAvatar.unk6 = 0x01; + SetPlayerAvatarStateMask(1); + sub_8059BF4(); + FieldObjectSetSpecialAnim(mapObject, 0x39); + task->data[0]++; + } +} + +void sub_8088CF8(struct Task *task) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + task->data[0]++; + gUnknown_0202FF84[0] = task->data[1]; + FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); + } +} + +void sub_8088D3C(struct Task *task) +{ + struct MapObject *mapObject; + if (!FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON)) + { + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (task->data[15] & 0x08) + { + sub_8127ED0(mapObject->mapobj_unk_1A, 2); + sub_8127EFC(mapObject->mapobj_unk_1A, 0); + } + task->data[1] = sub_8088F60(); + task->data[0]++; + } +} + +void sub_8088D94(struct Task *task) +{ + if (sub_8088FA4(task->data[1])) + { + task->data[0]++; + task->data[2] = 16; + SetPlayerAvatarTransitionFlags(0x01); + FieldObjectSetSpecialAnim(&gMapObjects[gPlayerAvatar.mapObjectId], 0x02); + } +} + +void sub_8088DD8(struct Task *task) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if ((task->data[2] == 0 || (--task->data[2]) == 0) && FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + task->data[0]++; + PlaySE(SE_W019); + sub_8088FC0(task->data[1]); + } +} + +void sub_8088E2C(struct Task *task) +{ + struct MapObject *mapObject; + if ((++task->data[2]) >= 8) + { + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + sub_805B980(mapObject, GetPlayerAvatarGraphicsIdByStateId(0x03)); + StartSpriteAnim(&gSprites[mapObject->spriteId], 0x16); + mapObject->mapobj_bit_12 = 1; + FieldObjectSetSpecialAnim(mapObject, 0x48); + if (task->data[15] & 0x08) + { + DestroySprite(&gSprites[mapObject->mapobj_unk_1A]); + } + task->data[0]++; + task->data[2] = 0; + } +} + +void sub_8088EB4(struct Task *task) +{ + struct MapObject *mapObject; + if ((++task->data[2]) >= 10) + { + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + FieldObjectClearAnimIfSpecialAnimActive(mapObject); + mapObject->mapobj_bit_12 = 0; + mapObject->mapobj_bit_22 = 0; + sub_8088FFC(task->data[1], mapObject->spriteId); + CameraObjectReset2(); + task->data[0]++; + } +} + +void sub_8088F10(struct Task *task) +{ + if (sub_8088FA4(task->data[1])) + { + fade_8080918(); + task->data[0]++; + } +} + +void sub_8088F30(struct Task *task) +{ + if (!gPaletteFade.active) + { + FieldEffectActiveListRemove(FLDEFF_USE_FLY); + DestroyTask(FindTaskIdByFunc(sub_8088C70)); + } +} + +u8 sub_8088F60(void) +{ + u8 spriteId; + struct Sprite *sprite; + spriteId = CreateSprite(gFieldEffectObjectTemplatePointers[26], 0xff, 0xb4, 0x1); + sprite = &gSprites[spriteId]; + sprite->oam.paletteNum = 0; + sprite->oam.priority = 1; + sprite->callback = sub_8089018; + return spriteId; +} + +u8 sub_8088FA4(u8 spriteId) +{ + return gSprites[spriteId].data7; +} + +void sub_8088FC0(u8 spriteId) +{ + struct Sprite *sprite; + sprite = &gSprites[spriteId]; + sprite->callback = sub_80890D8; + sprite->pos1.x = 0x78; + sprite->pos1.y = 0x00; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + memset(&sprite->data0, 0, 8 * sizeof(u16) /* zero all data cells */); + sprite->data6 = 0x40; +} + +void sub_8088FFC(u8 a0, u8 a1) +{ + gSprites[a0].data6 = a1; +} + +void sub_8089018(struct Sprite *sprite) +{ + if (sprite->data7 == 0) + { + if (sprite->data0 == 0) + { + sprite->oam.affineMode = 3; + sprite->affineAnims = gSpriteAffineAnimTable_0839F44C; + InitSpriteAffineAnim(sprite); + StartSpriteAffineAnim(sprite, 0); + sprite->pos1.x = 0x76; + sprite->pos1.y = -0x30; + sprite->data0++; + sprite->data1 = 0x40; + sprite->data2 = 0x100; + } + sprite->data1 += (sprite->data2 >> 8); + sprite->pos2.x = Cos(sprite->data1, 0x78); + sprite->pos2.y = Sin(sprite->data1, 0x78); + if (sprite->data2 < 0x800) + { + sprite->data2 += 0x60; + } + if (sprite->data1 > 0x81) + { + sprite->data7++; + sprite->oam.affineMode = 0; + FreeOamMatrix(sprite->oam.matrixNum); + CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, 0); + } + } +} + +void sub_80890D8(struct Sprite *sprite) +{ + struct Sprite *sprite1; + sprite->pos2.x = Cos(sprite->data2, 0x8c); + sprite->pos2.y = Sin(sprite->data2, 0x48); + sprite->data2 = (sprite->data2 + 4) & 0xff; + if (sprite->data6 != 0x40) + { + sprite1 = &gSprites[sprite->data6]; + sprite1->coordOffsetEnabled = 0; + sprite1->pos1.x = sprite->pos1.x + sprite->pos2.x; + sprite1->pos1.y = sprite->pos1.y + sprite->pos2.y - 8; + sprite1->pos2.x = 0; + sprite1->pos2.y = 0; + } + if (sprite->data2 >= 0x80) + { + sprite->data7 = 1; + } +} + +void sub_808914C(struct Sprite *sprite) +{ + if (sprite->data7 == 0) + { + if (sprite->data0 == 0) + { + sprite->oam.affineMode = 3; + sprite->affineAnims = gSpriteAffineAnimTable_0839F44C; + InitSpriteAffineAnim(sprite); + StartSpriteAffineAnim(sprite, 1); + sprite->pos1.x = 0x5e; + sprite->pos1.y = -0x20; + sprite->data0++; + sprite->data1 = 0xf0; + sprite->data2 = 0x800; + sprite->data4 = 0x80; + } + sprite->data1 += sprite->data2 >> 8; + sprite->data3 += sprite->data2 >> 8; + sprite->data1 &= 0xff; + sprite->pos2.x = Cos(sprite->data1, 0x20); + sprite->pos2.y = Sin(sprite->data1, 0x78); + if (sprite->data2 > 0x100) + { + sprite->data2 -= sprite->data4; + } + if (sprite->data4 < 0x100) + { + sprite->data4 += 24; + } + if (sprite->data2 < 0x100) + { + sprite->data2 = 0x100; + } + if (sprite->data3 >= 60) + { + sprite->data7++; + sprite->oam.affineMode = 0; + FreeOamMatrix(sprite->oam.matrixNum); + sprite->invisible = 1; + } + } +} + +void sub_8089230(u8 spriteId) +{ + sub_8088FC0(spriteId); + gSprites[spriteId].callback = sub_808914C; +} + +void sub_8089270(u8); + +u8 FldEff_FlyIn(void) +{ + CreateTask(sub_8089270, 0xfe); + return 0; +} + +void sub_8089270(u8 taskId) +{ + gUnknown_0839F454[gTasks[taskId].data[0]](&gTasks[taskId]); +} + +void sub_80892A0(struct Task *task) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + if (!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(mapObject) || FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) + { + task->data[0]++; + task->data[2] = 17; + task->data[15] = gPlayerAvatar.flags; + gPlayerAvatar.unk6 = 1; + SetPlayerAvatarStateMask(0x01); + if (task->data[15] & 0x08) + { + sub_8127ED0(mapObject->mapobj_unk_1A, 0); + } + sub_805B980(mapObject, GetPlayerAvatarGraphicsIdByStateId(0x3)); + CameraObjectReset2(); + FieldObjectTurn(mapObject, DIR_WEST); + StartSpriteAnim(&gSprites[mapObject->spriteId], 0x16); + mapObject->mapobj_bit_13 = 0; + task->data[1] = sub_8088F60(); + sub_8088FC0(task->data[1]); + sub_8088FFC(task->data[1], mapObject->spriteId); + } +} + +void sub_8089354(struct Task *task) +{ + struct MapObject *mapObject; + struct Sprite *sprite; + if (task->data[2] == 0 || (--task->data[2]) == 0) + { + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + sprite = &gSprites[mapObject->spriteId]; + sub_8088FFC(task->data[1], 0x40); + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + task->data[0]++; + task->data[2] = 0; + } +} + +void sub_80893C0(struct Task *task) +{ + s16 unknown_0839F470[18]; + struct Sprite *sprite; + memcpy(unknown_0839F470, gUnknown_0839F470, sizeof gUnknown_0839F470); + sprite = &gSprites[gPlayerAvatar.spriteId]; + sprite->pos2.y = unknown_0839F470[task->data[2]]; + if ((++task->data[2]) >= 18) + { + task->data[0]++; + } +} + +void sub_8089414(struct Task *task) +{ + struct MapObject *mapObject; + struct Sprite *sprite; + if (sub_8088FA4(task->data[1])) + { + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + sprite = &gSprites[mapObject->spriteId]; + mapObject->mapobj_bit_12 = 0; + sub_805C058(mapObject, mapObject->coords2.x, mapObject->coords2.y); + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->coordOffsetEnabled = 1; + sub_8059BF4(); + FieldObjectSetSpecialAnim(mapObject, 0x39); + task->data[0]++; + } +} + +void sub_808948C(struct Task *task) +{ + if (FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[gPlayerAvatar.mapObjectId])) + { + task->data[0]++; + sub_8089230(task->data[1]); + } +} + +void sub_80894C4(struct Task *task) +{ + if (sub_8088FA4(task->data[1])) + { + DestroySprite(&gSprites[task->data[1]]); + task->data[0]++; + task->data[1] = 0x10; + } +} + +void fishE(struct Task *task) +{ + u8 state; + struct MapObject *mapObject; + if ((--task->data[1]) == 0) + { + mapObject = &gMapObjects[gPlayerAvatar.mapObjectId]; + state = 0; + if (task->data[15] & 0x08) + { + state = 3; + sub_8127ED0(mapObject->mapobj_unk_1A, 1); + } + sub_805B980(mapObject, GetPlayerAvatarGraphicsIdByStateId(state)); + FieldObjectTurn(mapObject, DIR_SOUTH); + gPlayerAvatar.flags = task->data[15]; + gPlayerAvatar.unk6 = 0; + FieldEffectActiveListRemove(FLDEFF_FLY_IN); + DestroyTask(FindTaskIdByFunc(sub_8089270)); + } +} diff --git a/src/field_fadetransition.c b/src/field_fadetransition.c new file mode 100644 index 000000000..364d55e51 --- /dev/null +++ b/src/field_fadetransition.c @@ -0,0 +1,87 @@ +#include "global.h" +#include "gba/syscall.h" +#include "field_fadetransition.h" +#include "field_player_avatar.h" +#include "field_weather.h" +#include "fldeff_flash.h" +#include "global.fieldmap.h" +#include "rom4.h" +#include "script.h" +#include "task.h" + +extern u16 gPlttBufferFaded[]; + +void palette_bg_fill_white(void) +{ + u32 source_color = 0x7fff7fff; + CpuFastSet(&source_color, gPlttBufferFaded, 0x100 | (1 << 24)); +} + +void palette_bg_fill_black(void) +{ + u32 source_color = 0; + CpuFastSet(&source_color, gPlttBufferFaded, 0x100 | (1 << 24)); +} + +void pal_fill_for_map_transition(void) +{ + u8 map_light = get_map_light_from_warp0(); + switch (fade_type_for_given_maplight_pair(map_light, sav1_map_get_light_level())) + { + case 0: + fade_screen(0, 0); + palette_bg_fill_black(); + break; + case 1: + fade_screen(2, 0); + palette_bg_fill_white(); + } +} + +void pal_fill_black(void) +{ + fade_screen(0, 0); + palette_bg_fill_black(); +} + +void fade_8080918(void) +{ + u8 light_level = sav1_map_get_light_level(); + switch (sub_810CDB8(light_level, warp1_get_mapheader()->mapType)) + { + case 0: + fade_screen(1, 0); + break; + case 1: + fade_screen(3, 0); + } +} + +void sub_8080958(u8 arg) +{ + sub_8059B88(!arg); +} + +void task0A_asap_script_env_2_enable_and_set_ctx_running(u8 taskID) +{ + if (sub_8080E70() == 1) + { + DestroyTask(taskID); + EnableBothScriptContexts(); + } +} + +void sub_8080990(void) +{ + ScriptContext2_Enable(); + sub_8053E90(); + pal_fill_black(); + CreateTask(&task0A_asap_script_env_2_enable_and_set_ctx_running, 0x0a); +} + +void sub_80809B0(void) +{ + ScriptContext2_Enable(); + pal_fill_black(); + CreateTask(&task0A_asap_script_env_2_enable_and_set_ctx_running, 0x0a); +} diff --git a/src/field_ground_effect.c b/src/field_ground_effect.c new file mode 100644 index 000000000..42862d0ff --- /dev/null +++ b/src/field_ground_effect.c @@ -0,0 +1,240 @@ +#include "global.h" +#include "field_ground_effect.h" +#include "fieldmap.h" +#include "metatile_behavior.h" + +extern u32 gUnknown_08376008[]; + +void GetAllGroundEffectFlags_OnSpawn(struct MapObject *mapObj, u32 *flags) +{ + FieldObjectUpdateMetatileBehaviors(mapObj); + GetGroundEffectFlags_Reflection(mapObj, flags); + GetGroundEffectFlags_TallGrassOnSpawn(mapObj, flags); + GetGroundEffectFlags_LongGrassOnSpawn(mapObj, flags); + GetGroundEffectFlags_SandPile(mapObj, flags); + GetGroundEffectFlags_ShallowFlowingWater(mapObj, flags); + GetGroundEffectFlags_ShortGrass(mapObj, flags); + GetGroundEffectFlags_HotSprings(mapObj, flags); +} + +void GetAllGroundEffectFlags_OnBeginStep(struct MapObject *mapObj, u32 *flags) +{ + FieldObjectUpdateMetatileBehaviors(mapObj); + GetGroundEffectFlags_Reflection(mapObj, flags); + GetGroundEffectFlags_TallGrassOnBeginStep(mapObj, flags); + GetGroundEffectFlags_LongGrassOnBeginStep(mapObj, flags); + GetGroundEffectFlags_Tracks(mapObj, flags); + GetGroundEffectFlags_SandPile(mapObj, flags); + GetGroundEffectFlags_ShallowFlowingWater(mapObj, flags); + GetGroundEffectFlags_Puddle(mapObj, flags); + GetGroundEffectFlags_ShortGrass(mapObj, flags); + GetGroundEffectFlags_HotSprings(mapObj, flags); +} + +void GetAllGroundEffectFlags_OnFinishStep(struct MapObject *mapObj, u32 *flags) +{ + FieldObjectUpdateMetatileBehaviors(mapObj); + GetGroundEffectFlags_ShallowFlowingWater(mapObj, flags); + GetGroundEffectFlags_SandPile(mapObj, flags); + GetGroundEffectFlags_Puddle(mapObj, flags); + GetGroundEffectFlags_Ripple(mapObj, flags); + GetGroundEffectFlags_ShortGrass(mapObj, flags); + GetGroundEffectFlags_HotSprings(mapObj, flags); + GetGroundEffectFlags_Seaweed(mapObj, flags); + GetGroundEffectFlags_JumpLanding(mapObj, flags); +} + +void FieldObjectUpdateMetatileBehaviors(struct MapObject *mapObj) +{ + mapObj->mapobj_unk_1F = MapGridGetMetatileBehaviorAt(mapObj->coords3.x, mapObj->coords3.y); + mapObj->mapobj_unk_1E = MapGridGetMetatileBehaviorAt(mapObj->coords2.x, mapObj->coords2.y); +} + +void GetGroundEffectFlags_Reflection(struct MapObject *mapObj, u32 *flags) +{ + u32 reflectionFlags[2] = { 0x00000020, 0x00000010 }; + u8 type = FieldObjectCheckForReflectiveSurface(mapObj); + + if (type) + { + if (!mapObj->mapobj_bit_17) + { + mapObj->mapobj_bit_17 = 0; + mapObj->mapobj_bit_17 = 1; + *flags |= reflectionFlags[type - 1]; + } + } + else + { + mapObj->mapobj_bit_17 = 0; + } +} + +void GetGroundEffectFlags_TallGrassOnSpawn(struct MapObject *mapObj, u32 *flags) +{ + if (MetatileBehavior_IsTallGrass(mapObj->mapobj_unk_1E)) + *flags |= 0x1; +} + +void GetGroundEffectFlags_TallGrassOnBeginStep(struct MapObject *mapObj, u32 *flags) +{ + if (MetatileBehavior_IsTallGrass(mapObj->mapobj_unk_1E)) + *flags |= 0x2; +} + +void GetGroundEffectFlags_LongGrassOnSpawn(struct MapObject *mapObj, u32 *flags) +{ + if (MetatileBehavior_IsLongGrass(mapObj->mapobj_unk_1E)) + *flags |= 0x4; +} + +void GetGroundEffectFlags_LongGrassOnBeginStep(struct MapObject *mapObj, u32 *flags) +{ + if (MetatileBehavior_IsLongGrass(mapObj->mapobj_unk_1E)) + *flags |= 0x8; +} + +void GetGroundEffectFlags_Tracks(struct MapObject *mapObj, u32 *flags) +{ + if (MetatileBehavior_IsDeepSand(mapObj->mapobj_unk_1F)) + { + *flags |= 0x100; + } + else if (MetatileBehavior_IsSandOrDeepSand(mapObj->mapobj_unk_1F) + || MetatileBehavior_IsUnusedFootprintMetatile(mapObj->mapobj_unk_1F)) + { + *flags |= 0x80; + } +} + +void GetGroundEffectFlags_SandPile(struct MapObject *mapObj, u32 *flags) +{ + if (MetatileBehavior_IsDeepSand(mapObj->mapobj_unk_1E) + && MetatileBehavior_IsDeepSand(mapObj->mapobj_unk_1F)) + { + if (!mapObj->mapobj_bit_20) + { + mapObj->mapobj_bit_20 = 0; + mapObj->mapobj_bit_20 = 1; + *flags |= 0x800; + } + } + else + { + mapObj->mapobj_bit_20 = 0; + } +} + +void GetGroundEffectFlags_ShallowFlowingWater(struct MapObject *mapObj, u32 *flags) +{ + if ((MetatileBehavior_IsShallowFlowingWater(mapObj->mapobj_unk_1E) && MetatileBehavior_IsShallowFlowingWater(mapObj->mapobj_unk_1F)) + || (MetatileBehavior_IsPacifidlogLog(mapObj->mapobj_unk_1E) && MetatileBehavior_IsPacifidlogLog(mapObj->mapobj_unk_1F))) + { + if (!mapObj->mapobj_bit_19) + { + mapObj->mapobj_bit_19 = 0; + mapObj->mapobj_bit_19 = 1; + *flags |= 0x40; + } + } + else + { + mapObj->mapobj_bit_19 = 0; + } +} + +void GetGroundEffectFlags_Puddle(struct MapObject *mapObj, u32 *flags) +{ + if (MetatileBehavior_IsPuddle(mapObj->mapobj_unk_1E) + && MetatileBehavior_IsPuddle(mapObj->mapobj_unk_1F)) + { + *flags |= 0x400; + } +} + +void GetGroundEffectFlags_Ripple(struct MapObject *mapObj, u32 *flags) +{ + if (MetatileBehavior_HasRipples(mapObj->mapobj_unk_1E)) + *flags |= 0x200; +} + +void GetGroundEffectFlags_ShortGrass(struct MapObject *mapObj, u32 *flags) +{ + if (MetatileBehavior_IsShortGrass(mapObj->mapobj_unk_1E) + && MetatileBehavior_IsShortGrass(mapObj->mapobj_unk_1F)) + { + if (!mapObj->mapobj_bit_18) + { + mapObj->mapobj_bit_18 = 0; + mapObj->mapobj_bit_18 = 1; + *flags |= 0x20000; + } + } + else + { + mapObj->mapobj_bit_18 = 0; + } +} + +void GetGroundEffectFlags_HotSprings(struct MapObject *mapObj, u32 *flags) +{ + if (MetatileBehavior_IsHotSprings(mapObj->mapobj_unk_1E) + && MetatileBehavior_IsHotSprings(mapObj->mapobj_unk_1F)) + { + if (!mapObj->mapobj_bit_21) + { + mapObj->mapobj_bit_21 = 0; + mapObj->mapobj_bit_21 = 1; + *flags |= 0x40000; + } + } + else + { + mapObj->mapobj_bit_21 = 0; + } +} + +void GetGroundEffectFlags_Seaweed(struct MapObject *mapObj, u32 *flags) +{ + if (MetatileBehavior_IsSeaweed(mapObj->mapobj_unk_1E)) + *flags |= 0x80000; +} + +void GetGroundEffectFlags_JumpLanding(struct MapObject *mapObj, u32 *flags) +{ + typedef bool8 (*MetatileFunc)(u8); + + static const MetatileFunc metatileFuncs[] = + { + MetatileBehavior_IsTallGrass, + MetatileBehavior_IsLongGrass, + MetatileBehavior_IsPuddle, + MetatileBehavior_IsSurfableWaterOrUnderwater, + MetatileBehavior_IsShallowFlowingWater, + MetatileBehavior_IsATile, + }; + + static const u32 jumpLandingFlags[] = + { + 0x00001000, // Landing in tall grass + 0x00002000, // Landing in long grass + 0x00004000, // Landing on puddle + 0x00008000, // Landing on surfable water or underwater + 0x00004000, // Landing on shallow flowing water + 0x00010000, // Landing on any other type of ground + }; + + if (mapObj->mapobj_bit_5 && !mapObj->mapobj_bit_25) + { + u8 i; + + for (i = 0; i < 6; i++) + { + if (metatileFuncs[i](mapObj->mapobj_unk_1E)) + { + *flags |= jumpLandingFlags[i]; + return; + } + } + } +} diff --git a/src/field_map_obj.c b/src/field_map_obj.c new file mode 100755 index 000000000..d94c97ff3 --- /dev/null +++ b/src/field_map_obj.c @@ -0,0 +1,8473 @@ +#include "global.h" +#include "field_map_obj.h" +#include "berry.h" +#include "event_data.h" +#include "field_camera.h" +#include "field_effect.h" +#include "field_effect_helpers.h" +#include "field_ground_effect.h" +#include "field_map_obj_helpers.h" +#include "field_player_avatar.h" +#include "fieldmap.h" +#include "palette.h" +#include "rng.h" +#include "rom4.h" +#include "sprite.h" +#include "metatile_behavior.h" +#include "map_constants.h" +#include "map_object_constants.h" +#include "trainer_see.h" + +// rodata + +const u8 gUnknown_0830FD14[] = {1, 1, 6, 7, 8, 9, 6, 7, 8, 9, 11, 11, 0, 0, 0, 0}; + +void ObjectCB_CameraObject(struct Sprite *sprite); +const struct SpriteTemplate gSpriteTemplate_830FD24 = {0, 0xFFFF, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, ObjectCB_CameraObject}; + +void CameraObject_0(struct Sprite *); +void CameraObject_1(struct Sprite *); +void CameraObject_2(struct Sprite *); +void (*const gCameraObjectFuncs[])(struct Sprite *) = { + CameraObject_0, + CameraObject_1, + CameraObject_2, +}; + +const u32 gMapObjectPic_BrendanNormal_0[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/00.4bpp"); +const u32 gMapObjectPic_BrendanNormal_1[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/01.4bpp"); +const u32 gMapObjectPic_BrendanNormal_2[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/02.4bpp"); +const u32 gMapObjectPic_BrendanNormal_3[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/03.4bpp"); +const u32 gMapObjectPic_BrendanNormal_4[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/04.4bpp"); +const u32 gMapObjectPic_BrendanNormal_5[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/05.4bpp"); +const u32 gMapObjectPic_BrendanNormal_6[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/06.4bpp"); +const u32 gMapObjectPic_BrendanNormal_7[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/07.4bpp"); +const u32 gMapObjectPic_BrendanNormal_8[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/08.4bpp"); +const u32 gMapObjectPic_BrendanNormal_9[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/09.4bpp"); +const u32 gMapObjectPic_BrendanNormal_10[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/10.4bpp"); +const u32 gMapObjectPic_BrendanNormal_11[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/11.4bpp"); +const u32 gMapObjectPic_BrendanNormal_12[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/12.4bpp"); +const u32 gMapObjectPic_BrendanNormal_13[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/13.4bpp"); +const u32 gMapObjectPic_BrendanNormal_14[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/14.4bpp"); +const u32 gMapObjectPic_BrendanNormal_15[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/15.4bpp"); +const u32 gMapObjectPic_BrendanNormal_16[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/16.4bpp"); +const u32 gMapObjectPic_BrendanNormal_17[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/normal/17.4bpp"); +const u16 gMapObjectPalette8[] = INCBIN_U16("graphics/map_objects/palettes/08.gbapal"); +const u16 NullPalette_8310F68[16] = {}; +const u16 NullPalette_8310F88[16] = {}; +const u16 NullPalette_8310FA8[16] = {}; +const u16 NullPalette_8310FC8[16] = {}; +const u16 NullPalette_8310FE8[16] = {}; +const u16 NullPalette_8311008[16] = {}; +const u16 NullPalette_8311028[16] = {}; +const u16 NullPalette_8311048[16] = {}; +const u16 NullPalette_8311068[16] = {}; +const u16 NullPalette_8311088[16] = {}; +const u16 NullPalette_83110A8[16] = {}; +const u16 NullPalette_83110C8[16] = {}; +const u16 NullPalette_83110E8[16] = {}; +const u16 NullPalette_8311108[16] = {}; +const u16 NullPalette_8311128[16] = {}; +const u16 gMapObjectPalette9[] = INCBIN_U16("graphics/map_objects/palettes/09.gbapal"); +const u16 gMapObjectPalette10[] = INCBIN_U16("graphics/map_objects/palettes/10.gbapal"); +const u32 gMapObjectPic_BrendanFieldMove_0[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/field_move/0.4bpp"); +const u32 gMapObjectPic_BrendanFieldMove_1[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/field_move/1.4bpp"); +const u32 gMapObjectPic_BrendanFieldMove_2[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/field_move/2.4bpp"); +const u32 gMapObjectPic_BrendanFieldMove_3[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/field_move/3.4bpp"); +const u32 gMapObjectPic_BrendanFieldMove_4[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/field_move/4.4bpp"); +const u32 gMapObjectPic_BrendanSurfing_0[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/surfing/0.4bpp"); +const u32 gMapObjectPic_BrendanSurfing_3[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/surfing/3.4bpp"); +const u32 gMapObjectPic_BrendanSurfing_1[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/surfing/1.4bpp"); +const u32 gMapObjectPic_BrendanSurfing_4[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/surfing/4.4bpp"); +const u32 gMapObjectPic_BrendanSurfing_2[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/surfing/2.4bpp"); +const u32 gMapObjectPic_BrendanSurfing_5[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/surfing/5.4bpp"); +const u32 gMapObjectPic_BrendanMachBike_0[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/mach_bike/0.4bpp"); +const u32 gMapObjectPic_BrendanMachBike_1[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/mach_bike/1.4bpp"); +const u32 gMapObjectPic_BrendanMachBike_2[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/mach_bike/2.4bpp"); +const u32 gMapObjectPic_BrendanMachBike_3[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/mach_bike/3.4bpp"); +const u32 gMapObjectPic_BrendanMachBike_4[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/mach_bike/4.4bpp"); +const u32 gMapObjectPic_BrendanMachBike_5[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/mach_bike/5.4bpp"); +const u32 gMapObjectPic_BrendanMachBike_6[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/mach_bike/6.4bpp"); +const u32 gMapObjectPic_BrendanMachBike_7[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/mach_bike/7.4bpp"); +const u32 gMapObjectPic_BrendanMachBike_8[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/mach_bike/8.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_0[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/00.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_1[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/01.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_2[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/02.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_3[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/03.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_4[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/04.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_5[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/05.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_6[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/06.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_7[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/07.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_8[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/08.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_9[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/09.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_10[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/10.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_11[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/11.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_12[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/12.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_13[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/13.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_14[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/14.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_15[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/15.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_16[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/16.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_17[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/17.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_18[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/18.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_19[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/19.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_20[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/20.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_21[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/21.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_22[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/22.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_23[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/23.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_24[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/24.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_25[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/25.4bpp"); +const u32 gMapObjectPic_BrendanAcroBike_26[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/acro_bike/26.4bpp"); +const u32 gMapObjectPic_BrendanFishing_0[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/00.4bpp"); +const u32 gMapObjectPic_BrendanFishing_1[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/01.4bpp"); +const u32 gMapObjectPic_BrendanFishing_2[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/02.4bpp"); +const u32 gMapObjectPic_BrendanFishing_3[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/03.4bpp"); +const u32 gMapObjectPic_BrendanFishing_4[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/04.4bpp"); +const u32 gMapObjectPic_BrendanFishing_5[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/05.4bpp"); +const u32 gMapObjectPic_BrendanFishing_6[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/06.4bpp"); +const u32 gMapObjectPic_BrendanFishing_7[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/07.4bpp"); +const u32 gMapObjectPic_BrendanFishing_8[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/08.4bpp"); +const u32 gMapObjectPic_BrendanFishing_9[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/09.4bpp"); +const u32 gMapObjectPic_BrendanFishing_10[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/10.4bpp"); +const u32 gMapObjectPic_BrendanFishing_11[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/fishing/11.4bpp"); +const u32 gMapObjectPic_BrendanWatering_0[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/watering/0.4bpp"); +const u32 gMapObjectPic_BrendanWatering_3[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/watering/3.4bpp"); +const u32 gMapObjectPic_BrendanWatering_1[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/watering/1.4bpp"); +const u32 gMapObjectPic_BrendanWatering_4[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/watering/4.4bpp"); +const u32 gMapObjectPic_BrendanWatering_2[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/watering/2.4bpp"); +const u32 gMapObjectPic_BrendanWatering_5[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/watering/5.4bpp"); +const u32 gMapObjectPic_BrendanDecorating[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/decorating.4bpp"); +const u32 gMapObjectPic_MayDecorating[] = INCBIN_U32("graphics/map_objects/pics/people/may/decorating.4bpp"); +const u32 gMapObjectPic_BrendanUnderwater_0[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/underwater/0.4bpp"); +const u32 gMapObjectPic_BrendanUnderwater_1[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/underwater/1.4bpp"); +const u32 gMapObjectPic_BrendanUnderwater_2[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/underwater/2.4bpp"); +const u32 gMapObjectPic_BrendanUnderwater_3[] = INCBIN_U32("graphics/map_objects/pics/people/brendan/underwater/3.4bpp"); +const u32 gMapObjectPic_MayUnderwater_0[] = INCBIN_U32("graphics/map_objects/pics/people/may/underwater/0.4bpp"); +const u32 gMapObjectPic_MayUnderwater_1[] = INCBIN_U32("graphics/map_objects/pics/people/may/underwater/1.4bpp"); +const u32 gMapObjectPic_MayUnderwater_2[] = INCBIN_U32("graphics/map_objects/pics/people/may/underwater/2.4bpp"); +const u32 gMapObjectPic_MayUnderwater_3[] = INCBIN_U32("graphics/map_objects/pics/people/may/underwater/3.4bpp"); +const u16 gMapObjectPalette11[] = INCBIN_U16("graphics/map_objects/palettes/11.gbapal"); +const u32 gMapObjectPic_MayNormal_0[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/00.4bpp"); +const u32 gMapObjectPic_MayNormal_1[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/01.4bpp"); +const u32 gMapObjectPic_MayNormal_2[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/02.4bpp"); +const u32 gMapObjectPic_MayNormal_3[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/03.4bpp"); +const u32 gMapObjectPic_MayNormal_4[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/04.4bpp"); +const u32 gMapObjectPic_MayNormal_5[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/05.4bpp"); +const u32 gMapObjectPic_MayNormal_6[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/06.4bpp"); +const u32 gMapObjectPic_MayNormal_7[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/07.4bpp"); +const u32 gMapObjectPic_MayNormal_8[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/08.4bpp"); +const u32 gMapObjectPic_MayNormal_9[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/09.4bpp"); +const u32 gMapObjectPic_MayNormal_10[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/10.4bpp"); +const u32 gMapObjectPic_MayNormal_11[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/11.4bpp"); +const u32 gMapObjectPic_MayNormal_12[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/12.4bpp"); +const u32 gMapObjectPic_MayNormal_13[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/13.4bpp"); +const u32 gMapObjectPic_MayNormal_14[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/14.4bpp"); +const u32 gMapObjectPic_MayNormal_15[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/15.4bpp"); +const u32 gMapObjectPic_MayNormal_16[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/16.4bpp"); +const u32 gMapObjectPic_MayNormal_17[] = INCBIN_U32("graphics/map_objects/pics/people/may/normal/17.4bpp"); +const u16 gMapObjectPalette17[] = INCBIN_U16("graphics/map_objects/palettes/17.gbapal"); +const u16 gMapObjectPalette18[] = INCBIN_U16("graphics/map_objects/palettes/18.gbapal"); +const u16 NullPalette_831B7E8[16] = {}; +const u16 NullPalette_831B808[16] = {}; +const u16 NullPalette_831B828[16] = {}; +const u16 NullPalette_831B848[16] = {}; +const u16 NullPalette_831B868[16] = {}; +const u16 NullPalette_831B888[16] = {}; +const u16 NullPalette_831B8A8[16] = {}; +const u16 NullPalette_831B8C8[16] = {}; +const u16 NullPalette_831B8E8[16] = {}; +const u16 NullPalette_831B908[16] = {}; +const u16 NullPalette_831B928[16] = {}; +const u16 NullPalette_831B948[16] = {}; +const u16 NullPalette_831B968[16] = {}; +const u16 NullPalette_831B988[16] = {}; +const u32 gMapObjectPic_MayMachBike_0[] = INCBIN_U32("graphics/map_objects/pics/people/may/mach_bike/0.4bpp"); +const u32 gMapObjectPic_MayMachBike_1[] = INCBIN_U32("graphics/map_objects/pics/people/may/mach_bike/1.4bpp"); +const u32 gMapObjectPic_MayMachBike_2[] = INCBIN_U32("graphics/map_objects/pics/people/may/mach_bike/2.4bpp"); +const u32 gMapObjectPic_MayMachBike_3[] = INCBIN_U32("graphics/map_objects/pics/people/may/mach_bike/3.4bpp"); +const u32 gMapObjectPic_MayMachBike_4[] = INCBIN_U32("graphics/map_objects/pics/people/may/mach_bike/4.4bpp"); +const u32 gMapObjectPic_MayMachBike_5[] = INCBIN_U32("graphics/map_objects/pics/people/may/mach_bike/5.4bpp"); +const u32 gMapObjectPic_MayMachBike_6[] = INCBIN_U32("graphics/map_objects/pics/people/may/mach_bike/6.4bpp"); +const u32 gMapObjectPic_MayMachBike_7[] = INCBIN_U32("graphics/map_objects/pics/people/may/mach_bike/7.4bpp"); +const u32 gMapObjectPic_MayMachBike_8[] = INCBIN_U32("graphics/map_objects/pics/people/may/mach_bike/8.4bpp"); +const u32 gMapObjectPic_MayAcroBike_0[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/00.4bpp"); +const u32 gMapObjectPic_MayAcroBike_1[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/01.4bpp"); +const u32 gMapObjectPic_MayAcroBike_2[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/02.4bpp"); +const u32 gMapObjectPic_MayAcroBike_3[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/03.4bpp"); +const u32 gMapObjectPic_MayAcroBike_4[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/04.4bpp"); +const u32 gMapObjectPic_MayAcroBike_5[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/05.4bpp"); +const u32 gMapObjectPic_MayAcroBike_6[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/06.4bpp"); +const u32 gMapObjectPic_MayAcroBike_7[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/07.4bpp"); +const u32 gMapObjectPic_MayAcroBike_8[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/08.4bpp"); +const u32 gMapObjectPic_MayAcroBike_9[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/09.4bpp"); +const u32 gMapObjectPic_MayAcroBike_10[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/10.4bpp"); +const u32 gMapObjectPic_MayAcroBike_11[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/11.4bpp"); +const u32 gMapObjectPic_MayAcroBike_12[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/12.4bpp"); +const u32 gMapObjectPic_MayAcroBike_13[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/13.4bpp"); +const u32 gMapObjectPic_MayAcroBike_14[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/14.4bpp"); +const u32 gMapObjectPic_MayAcroBike_15[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/15.4bpp"); +const u32 gMapObjectPic_MayAcroBike_16[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/16.4bpp"); +const u32 gMapObjectPic_MayAcroBike_17[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/17.4bpp"); +const u32 gMapObjectPic_MayAcroBike_18[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/18.4bpp"); +const u32 gMapObjectPic_MayAcroBike_19[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/19.4bpp"); +const u32 gMapObjectPic_MayAcroBike_20[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/20.4bpp"); +const u32 gMapObjectPic_MayAcroBike_21[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/21.4bpp"); +const u32 gMapObjectPic_MayAcroBike_22[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/22.4bpp"); +const u32 gMapObjectPic_MayAcroBike_23[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/23.4bpp"); +const u32 gMapObjectPic_MayAcroBike_24[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/24.4bpp"); +const u32 gMapObjectPic_MayAcroBike_25[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/25.4bpp"); +const u32 gMapObjectPic_MayAcroBike_26[] = INCBIN_U32("graphics/map_objects/pics/people/may/acro_bike/26.4bpp"); +const u32 gMapObjectPic_MaySurfing_0[] = INCBIN_U32("graphics/map_objects/pics/people/may/surfing/0.4bpp"); +const u32 gMapObjectPic_MaySurfing_3[] = INCBIN_U32("graphics/map_objects/pics/people/may/surfing/3.4bpp"); +const u32 gMapObjectPic_MaySurfing_1[] = INCBIN_U32("graphics/map_objects/pics/people/may/surfing/1.4bpp"); +const u32 gMapObjectPic_MaySurfing_4[] = INCBIN_U32("graphics/map_objects/pics/people/may/surfing/4.4bpp"); +const u32 gMapObjectPic_MaySurfing_2[] = INCBIN_U32("graphics/map_objects/pics/people/may/surfing/2.4bpp"); +const u32 gMapObjectPic_MaySurfing_5[] = INCBIN_U32("graphics/map_objects/pics/people/may/surfing/5.4bpp"); +const u32 gMapObjectPic_MayFieldMove_0[] = INCBIN_U32("graphics/map_objects/pics/people/may/field_move/0.4bpp"); +const u32 gMapObjectPic_MayFieldMove_1[] = INCBIN_U32("graphics/map_objects/pics/people/may/field_move/1.4bpp"); +const u32 gMapObjectPic_MayFieldMove_2[] = INCBIN_U32("graphics/map_objects/pics/people/may/field_move/2.4bpp"); +const u32 gMapObjectPic_MayFieldMove_3[] = INCBIN_U32("graphics/map_objects/pics/people/may/field_move/3.4bpp"); +const u32 gMapObjectPic_MayFieldMove_4[] = INCBIN_U32("graphics/map_objects/pics/people/may/field_move/4.4bpp"); +const u32 gMapObjectPic_MayFishing_0[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/00.4bpp"); +const u32 gMapObjectPic_MayFishing_1[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/01.4bpp"); +const u32 gMapObjectPic_MayFishing_2[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/02.4bpp"); +const u32 gMapObjectPic_MayFishing_3[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/03.4bpp"); +const u32 gMapObjectPic_MayFishing_4[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/04.4bpp"); +const u32 gMapObjectPic_MayFishing_5[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/05.4bpp"); +const u32 gMapObjectPic_MayFishing_6[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/06.4bpp"); +const u32 gMapObjectPic_MayFishing_7[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/07.4bpp"); +const u32 gMapObjectPic_MayFishing_8[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/08.4bpp"); +const u32 gMapObjectPic_MayFishing_9[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/09.4bpp"); +const u32 gMapObjectPic_MayFishing_10[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/10.4bpp"); +const u32 gMapObjectPic_MayFishing_11[] = INCBIN_U32("graphics/map_objects/pics/people/may/fishing/11.4bpp"); +const u32 gMapObjectPic_MayWatering_0[] = INCBIN_U32("graphics/map_objects/pics/people/may/watering/0.4bpp"); +const u32 gMapObjectPic_MayWatering_3[] = INCBIN_U32("graphics/map_objects/pics/people/may/watering/3.4bpp"); +const u32 gMapObjectPic_MayWatering_1[] = INCBIN_U32("graphics/map_objects/pics/people/may/watering/1.4bpp"); +const u32 gMapObjectPic_MayWatering_4[] = INCBIN_U32("graphics/map_objects/pics/people/may/watering/4.4bpp"); +const u32 gMapObjectPic_MayWatering_2[] = INCBIN_U32("graphics/map_objects/pics/people/may/watering/2.4bpp"); +const u32 gMapObjectPic_MayWatering_5[] = INCBIN_U32("graphics/map_objects/pics/people/may/watering/5.4bpp"); +const u16 gMapObjectPalette0[] = INCBIN_U16("graphics/map_objects/palettes/00.gbapal"); +const u16 gMapObjectPalette1[] = INCBIN_U16("graphics/map_objects/palettes/01.gbapal"); +const u16 gMapObjectPalette2[] = INCBIN_U16("graphics/map_objects/palettes/02.gbapal"); +const u16 gMapObjectPalette3[] = INCBIN_U16("graphics/map_objects/palettes/03.gbapal"); +const u16 gMapObjectPalette4[] = INCBIN_U16("graphics/map_objects/palettes/04.gbapal"); +const u16 gMapObjectPalette5[] = INCBIN_U16("graphics/map_objects/palettes/05.gbapal"); +const u16 gMapObjectPalette6[] = INCBIN_U16("graphics/map_objects/palettes/06.gbapal"); +const u16 gMapObjectPalette7[] = INCBIN_U16("graphics/map_objects/palettes/07.gbapal"); +const u32 gMapObjectPic_LittleBoy1_0[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_1/0.4bpp"); +const u32 gMapObjectPic_LittleBoy1_1[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_1/1.4bpp"); +const u32 gMapObjectPic_LittleBoy1_2[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_1/2.4bpp"); +const u32 gMapObjectPic_LittleBoy1_3[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_1/3.4bpp"); +const u32 gMapObjectPic_LittleBoy1_4[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_1/4.4bpp"); +const u32 gMapObjectPic_LittleBoy1_5[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_1/5.4bpp"); +const u32 gMapObjectPic_LittleBoy1_6[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_1/6.4bpp"); +const u32 gMapObjectPic_LittleBoy1_7[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_1/7.4bpp"); +const u32 gMapObjectPic_LittleBoy1_8[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_1/8.4bpp"); +const u32 gMapObjectPic_LittleGirl1_0[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_1/0.4bpp"); +const u32 gMapObjectPic_LittleGirl1_1[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_1/1.4bpp"); +const u32 gMapObjectPic_LittleGirl1_2[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_1/2.4bpp"); +const u32 gMapObjectPic_LittleGirl1_3[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_1/3.4bpp"); +const u32 gMapObjectPic_LittleGirl1_4[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_1/4.4bpp"); +const u32 gMapObjectPic_LittleGirl1_5[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_1/5.4bpp"); +const u32 gMapObjectPic_LittleGirl1_6[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_1/6.4bpp"); +const u32 gMapObjectPic_LittleGirl1_7[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_1/7.4bpp"); +const u32 gMapObjectPic_LittleGirl1_8[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_1/8.4bpp"); +const u32 gMapObjectPic_Boy1_0[] = INCBIN_U32("graphics/map_objects/pics/people/boy_1/0.4bpp"); +const u32 gMapObjectPic_Boy1_1[] = INCBIN_U32("graphics/map_objects/pics/people/boy_1/1.4bpp"); +const u32 gMapObjectPic_Boy1_2[] = INCBIN_U32("graphics/map_objects/pics/people/boy_1/2.4bpp"); +const u32 gMapObjectPic_Boy1_3[] = INCBIN_U32("graphics/map_objects/pics/people/boy_1/3.4bpp"); +const u32 gMapObjectPic_Boy1_4[] = INCBIN_U32("graphics/map_objects/pics/people/boy_1/4.4bpp"); +const u32 gMapObjectPic_Boy1_5[] = INCBIN_U32("graphics/map_objects/pics/people/boy_1/5.4bpp"); +const u32 gMapObjectPic_Boy1_6[] = INCBIN_U32("graphics/map_objects/pics/people/boy_1/6.4bpp"); +const u32 gMapObjectPic_Boy1_7[] = INCBIN_U32("graphics/map_objects/pics/people/boy_1/7.4bpp"); +const u32 gMapObjectPic_Boy1_8[] = INCBIN_U32("graphics/map_objects/pics/people/boy_1/8.4bpp"); +const u32 gMapObjectPic_Girl1_0[] = INCBIN_U32("graphics/map_objects/pics/people/girl_1/0.4bpp"); +const u32 gMapObjectPic_Girl1_1[] = INCBIN_U32("graphics/map_objects/pics/people/girl_1/1.4bpp"); +const u32 gMapObjectPic_Girl1_2[] = INCBIN_U32("graphics/map_objects/pics/people/girl_1/2.4bpp"); +const u32 gMapObjectPic_Girl1_3[] = INCBIN_U32("graphics/map_objects/pics/people/girl_1/3.4bpp"); +const u32 gMapObjectPic_Girl1_4[] = INCBIN_U32("graphics/map_objects/pics/people/girl_1/4.4bpp"); +const u32 gMapObjectPic_Girl1_5[] = INCBIN_U32("graphics/map_objects/pics/people/girl_1/5.4bpp"); +const u32 gMapObjectPic_Girl1_6[] = INCBIN_U32("graphics/map_objects/pics/people/girl_1/6.4bpp"); +const u32 gMapObjectPic_Girl1_7[] = INCBIN_U32("graphics/map_objects/pics/people/girl_1/7.4bpp"); +const u32 gMapObjectPic_Girl1_8[] = INCBIN_U32("graphics/map_objects/pics/people/girl_1/8.4bpp"); +const u32 gMapObjectPic_Boy2_0[] = INCBIN_U32("graphics/map_objects/pics/people/boy_2/0.4bpp"); +const u32 gMapObjectPic_Boy2_1[] = INCBIN_U32("graphics/map_objects/pics/people/boy_2/1.4bpp"); +const u32 gMapObjectPic_Boy2_2[] = INCBIN_U32("graphics/map_objects/pics/people/boy_2/2.4bpp"); +const u32 gMapObjectPic_Boy2_3[] = INCBIN_U32("graphics/map_objects/pics/people/boy_2/3.4bpp"); +const u32 gMapObjectPic_Boy2_4[] = INCBIN_U32("graphics/map_objects/pics/people/boy_2/4.4bpp"); +const u32 gMapObjectPic_Boy2_5[] = INCBIN_U32("graphics/map_objects/pics/people/boy_2/5.4bpp"); +const u32 gMapObjectPic_Boy2_6[] = INCBIN_U32("graphics/map_objects/pics/people/boy_2/6.4bpp"); +const u32 gMapObjectPic_Boy2_7[] = INCBIN_U32("graphics/map_objects/pics/people/boy_2/7.4bpp"); +const u32 gMapObjectPic_Boy2_8[] = INCBIN_U32("graphics/map_objects/pics/people/boy_2/8.4bpp"); +const u32 gMapObjectPic_Girl2_0[] = INCBIN_U32("graphics/map_objects/pics/people/girl_2/0.4bpp"); +const u32 gMapObjectPic_Girl2_1[] = INCBIN_U32("graphics/map_objects/pics/people/girl_2/1.4bpp"); +const u32 gMapObjectPic_Girl2_2[] = INCBIN_U32("graphics/map_objects/pics/people/girl_2/2.4bpp"); +const u32 gMapObjectPic_Girl2_3[] = INCBIN_U32("graphics/map_objects/pics/people/girl_2/3.4bpp"); +const u32 gMapObjectPic_Girl2_4[] = INCBIN_U32("graphics/map_objects/pics/people/girl_2/4.4bpp"); +const u32 gMapObjectPic_Girl2_5[] = INCBIN_U32("graphics/map_objects/pics/people/girl_2/5.4bpp"); +const u32 gMapObjectPic_Girl2_6[] = INCBIN_U32("graphics/map_objects/pics/people/girl_2/6.4bpp"); +const u32 gMapObjectPic_Girl2_7[] = INCBIN_U32("graphics/map_objects/pics/people/girl_2/7.4bpp"); +const u32 gMapObjectPic_Girl2_8[] = INCBIN_U32("graphics/map_objects/pics/people/girl_2/8.4bpp"); +const u32 gMapObjectPic_LittleBoy2_0[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_2/0.4bpp"); +const u32 gMapObjectPic_LittleBoy2_1[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_2/1.4bpp"); +const u32 gMapObjectPic_LittleBoy2_2[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_2/2.4bpp"); +const u32 gMapObjectPic_LittleBoy2_3[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_2/3.4bpp"); +const u32 gMapObjectPic_LittleBoy2_4[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_2/4.4bpp"); +const u32 gMapObjectPic_LittleBoy2_5[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_2/5.4bpp"); +const u32 gMapObjectPic_LittleBoy2_6[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_2/6.4bpp"); +const u32 gMapObjectPic_LittleBoy2_7[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_2/7.4bpp"); +const u32 gMapObjectPic_LittleBoy2_8[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_2/8.4bpp"); +const u32 gMapObjectPic_LittleGirl2_0[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_2/0.4bpp"); +const u32 gMapObjectPic_LittleGirl2_1[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_2/1.4bpp"); +const u32 gMapObjectPic_LittleGirl2_2[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_2/2.4bpp"); +const u32 gMapObjectPic_LittleGirl2_3[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_2/3.4bpp"); +const u32 gMapObjectPic_LittleGirl2_4[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_2/4.4bpp"); +const u32 gMapObjectPic_LittleGirl2_5[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_2/5.4bpp"); +const u32 gMapObjectPic_LittleGirl2_6[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_2/6.4bpp"); +const u32 gMapObjectPic_LittleGirl2_7[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_2/7.4bpp"); +const u32 gMapObjectPic_LittleGirl2_8[] = INCBIN_U32("graphics/map_objects/pics/people/little_girl_2/8.4bpp"); +const u32 gMapObjectPic_Boy3_0[] = INCBIN_U32("graphics/map_objects/pics/people/boy_3/0.4bpp"); +const u32 gMapObjectPic_Boy3_1[] = INCBIN_U32("graphics/map_objects/pics/people/boy_3/1.4bpp"); +const u32 gMapObjectPic_Boy3_2[] = INCBIN_U32("graphics/map_objects/pics/people/boy_3/2.4bpp"); +const u32 gMapObjectPic_Boy3_3[] = INCBIN_U32("graphics/map_objects/pics/people/boy_3/3.4bpp"); +const u32 gMapObjectPic_Boy3_4[] = INCBIN_U32("graphics/map_objects/pics/people/boy_3/4.4bpp"); +const u32 gMapObjectPic_Boy3_5[] = INCBIN_U32("graphics/map_objects/pics/people/boy_3/5.4bpp"); +const u32 gMapObjectPic_Boy3_6[] = INCBIN_U32("graphics/map_objects/pics/people/boy_3/6.4bpp"); +const u32 gMapObjectPic_Boy3_7[] = INCBIN_U32("graphics/map_objects/pics/people/boy_3/7.4bpp"); +const u32 gMapObjectPic_Boy3_8[] = INCBIN_U32("graphics/map_objects/pics/people/boy_3/8.4bpp"); +const u32 gMapObjectPic_Girl3_0[] = INCBIN_U32("graphics/map_objects/pics/people/girl_3/0.4bpp"); +const u32 gMapObjectPic_Girl3_1[] = INCBIN_U32("graphics/map_objects/pics/people/girl_3/1.4bpp"); +const u32 gMapObjectPic_Girl3_2[] = INCBIN_U32("graphics/map_objects/pics/people/girl_3/2.4bpp"); +const u32 gMapObjectPic_Girl3_3[] = INCBIN_U32("graphics/map_objects/pics/people/girl_3/3.4bpp"); +const u32 gMapObjectPic_Girl3_4[] = INCBIN_U32("graphics/map_objects/pics/people/girl_3/4.4bpp"); +const u32 gMapObjectPic_Girl3_5[] = INCBIN_U32("graphics/map_objects/pics/people/girl_3/5.4bpp"); +const u32 gMapObjectPic_Girl3_6[] = INCBIN_U32("graphics/map_objects/pics/people/girl_3/6.4bpp"); +const u32 gMapObjectPic_Girl3_7[] = INCBIN_U32("graphics/map_objects/pics/people/girl_3/7.4bpp"); +const u32 gMapObjectPic_Girl3_8[] = INCBIN_U32("graphics/map_objects/pics/people/girl_3/8.4bpp"); +const u32 gMapObjectPic_Boy4_0[] = INCBIN_U32("graphics/map_objects/pics/people/boy_4/0.4bpp"); +const u32 gMapObjectPic_Boy4_1[] = INCBIN_U32("graphics/map_objects/pics/people/boy_4/1.4bpp"); +const u32 gMapObjectPic_Boy4_2[] = INCBIN_U32("graphics/map_objects/pics/people/boy_4/2.4bpp"); +const u32 gMapObjectPic_Boy4_3[] = INCBIN_U32("graphics/map_objects/pics/people/boy_4/3.4bpp"); +const u32 gMapObjectPic_Boy4_4[] = INCBIN_U32("graphics/map_objects/pics/people/boy_4/4.4bpp"); +const u32 gMapObjectPic_Boy4_5[] = INCBIN_U32("graphics/map_objects/pics/people/boy_4/5.4bpp"); +const u32 gMapObjectPic_Boy4_6[] = INCBIN_U32("graphics/map_objects/pics/people/boy_4/6.4bpp"); +const u32 gMapObjectPic_Boy4_7[] = INCBIN_U32("graphics/map_objects/pics/people/boy_4/7.4bpp"); +const u32 gMapObjectPic_Boy4_8[] = INCBIN_U32("graphics/map_objects/pics/people/boy_4/8.4bpp"); +const u32 gMapObjectPic_Woman1_0[] = INCBIN_U32("graphics/map_objects/pics/people/woman_1/0.4bpp"); +const u32 gMapObjectPic_Woman1_1[] = INCBIN_U32("graphics/map_objects/pics/people/woman_1/1.4bpp"); +const u32 gMapObjectPic_Woman1_2[] = INCBIN_U32("graphics/map_objects/pics/people/woman_1/2.4bpp"); +const u32 gMapObjectPic_Woman1_3[] = INCBIN_U32("graphics/map_objects/pics/people/woman_1/3.4bpp"); +const u32 gMapObjectPic_Woman1_4[] = INCBIN_U32("graphics/map_objects/pics/people/woman_1/4.4bpp"); +const u32 gMapObjectPic_Woman1_5[] = INCBIN_U32("graphics/map_objects/pics/people/woman_1/5.4bpp"); +const u32 gMapObjectPic_Woman1_6[] = INCBIN_U32("graphics/map_objects/pics/people/woman_1/6.4bpp"); +const u32 gMapObjectPic_Woman1_7[] = INCBIN_U32("graphics/map_objects/pics/people/woman_1/7.4bpp"); +const u32 gMapObjectPic_Woman1_8[] = INCBIN_U32("graphics/map_objects/pics/people/woman_1/8.4bpp"); +const u32 gMapObjectPic_FatMan_0[] = INCBIN_U32("graphics/map_objects/pics/people/fat_man/0.4bpp"); +const u32 gMapObjectPic_FatMan_1[] = INCBIN_U32("graphics/map_objects/pics/people/fat_man/1.4bpp"); +const u32 gMapObjectPic_FatMan_2[] = INCBIN_U32("graphics/map_objects/pics/people/fat_man/2.4bpp"); +const u32 gMapObjectPic_FatMan_3[] = INCBIN_U32("graphics/map_objects/pics/people/fat_man/3.4bpp"); +const u32 gMapObjectPic_FatMan_4[] = INCBIN_U32("graphics/map_objects/pics/people/fat_man/4.4bpp"); +const u32 gMapObjectPic_FatMan_5[] = INCBIN_U32("graphics/map_objects/pics/people/fat_man/5.4bpp"); +const u32 gMapObjectPic_FatMan_6[] = INCBIN_U32("graphics/map_objects/pics/people/fat_man/6.4bpp"); +const u32 gMapObjectPic_FatMan_7[] = INCBIN_U32("graphics/map_objects/pics/people/fat_man/7.4bpp"); +const u32 gMapObjectPic_FatMan_8[] = INCBIN_U32("graphics/map_objects/pics/people/fat_man/8.4bpp"); +const u32 gMapObjectPic_Woman2_0[] = INCBIN_U32("graphics/map_objects/pics/people/woman_2/0.4bpp"); +const u32 gMapObjectPic_Woman2_1[] = INCBIN_U32("graphics/map_objects/pics/people/woman_2/1.4bpp"); +const u32 gMapObjectPic_Woman2_2[] = INCBIN_U32("graphics/map_objects/pics/people/woman_2/2.4bpp"); +const u32 gMapObjectPic_Woman2_3[] = INCBIN_U32("graphics/map_objects/pics/people/woman_2/3.4bpp"); +const u32 gMapObjectPic_Woman2_4[] = INCBIN_U32("graphics/map_objects/pics/people/woman_2/4.4bpp"); +const u32 gMapObjectPic_Woman2_5[] = INCBIN_U32("graphics/map_objects/pics/people/woman_2/5.4bpp"); +const u32 gMapObjectPic_Woman2_6[] = INCBIN_U32("graphics/map_objects/pics/people/woman_2/6.4bpp"); +const u32 gMapObjectPic_Woman2_7[] = INCBIN_U32("graphics/map_objects/pics/people/woman_2/7.4bpp"); +const u32 gMapObjectPic_Woman2_8[] = INCBIN_U32("graphics/map_objects/pics/people/woman_2/8.4bpp"); +const u32 gMapObjectPic_Man1_0[] = INCBIN_U32("graphics/map_objects/pics/people/man_1/0.4bpp"); +const u32 gMapObjectPic_Man1_1[] = INCBIN_U32("graphics/map_objects/pics/people/man_1/1.4bpp"); +const u32 gMapObjectPic_Man1_2[] = INCBIN_U32("graphics/map_objects/pics/people/man_1/2.4bpp"); +const u32 gMapObjectPic_Man1_3[] = INCBIN_U32("graphics/map_objects/pics/people/man_1/3.4bpp"); +const u32 gMapObjectPic_Man1_4[] = INCBIN_U32("graphics/map_objects/pics/people/man_1/4.4bpp"); +const u32 gMapObjectPic_Man1_5[] = INCBIN_U32("graphics/map_objects/pics/people/man_1/5.4bpp"); +const u32 gMapObjectPic_Man1_6[] = INCBIN_U32("graphics/map_objects/pics/people/man_1/6.4bpp"); +const u32 gMapObjectPic_Man1_7[] = INCBIN_U32("graphics/map_objects/pics/people/man_1/7.4bpp"); +const u32 gMapObjectPic_Man1_8[] = INCBIN_U32("graphics/map_objects/pics/people/man_1/8.4bpp"); +const u32 gMapObjectPic_Woman3_0[] = INCBIN_U32("graphics/map_objects/pics/people/woman_3/0.4bpp"); +const u32 gMapObjectPic_Woman3_1[] = INCBIN_U32("graphics/map_objects/pics/people/woman_3/1.4bpp"); +const u32 gMapObjectPic_Woman3_2[] = INCBIN_U32("graphics/map_objects/pics/people/woman_3/2.4bpp"); +const u32 gMapObjectPic_Woman3_3[] = INCBIN_U32("graphics/map_objects/pics/people/woman_3/3.4bpp"); +const u32 gMapObjectPic_Woman3_4[] = INCBIN_U32("graphics/map_objects/pics/people/woman_3/4.4bpp"); +const u32 gMapObjectPic_Woman3_5[] = INCBIN_U32("graphics/map_objects/pics/people/woman_3/5.4bpp"); +const u32 gMapObjectPic_Woman3_6[] = INCBIN_U32("graphics/map_objects/pics/people/woman_3/6.4bpp"); +const u32 gMapObjectPic_Woman3_7[] = INCBIN_U32("graphics/map_objects/pics/people/woman_3/7.4bpp"); +const u32 gMapObjectPic_Woman3_8[] = INCBIN_U32("graphics/map_objects/pics/people/woman_3/8.4bpp"); +const u32 gMapObjectPic_OldMan1_0[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_1/0.4bpp"); +const u32 gMapObjectPic_OldMan1_1[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_1/1.4bpp"); +const u32 gMapObjectPic_OldMan1_2[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_1/2.4bpp"); +const u32 gMapObjectPic_OldMan1_3[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_1/3.4bpp"); +const u32 gMapObjectPic_OldMan1_4[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_1/4.4bpp"); +const u32 gMapObjectPic_OldMan1_5[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_1/5.4bpp"); +const u32 gMapObjectPic_OldMan1_6[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_1/6.4bpp"); +const u32 gMapObjectPic_OldMan1_7[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_1/7.4bpp"); +const u32 gMapObjectPic_OldMan1_8[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_1/8.4bpp"); +const u32 gMapObjectPic_OldWoman1_0[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_1/0.4bpp"); +const u32 gMapObjectPic_OldWoman1_1[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_1/1.4bpp"); +const u32 gMapObjectPic_OldWoman1_2[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_1/2.4bpp"); +const u32 gMapObjectPic_OldWoman1_3[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_1/3.4bpp"); +const u32 gMapObjectPic_OldWoman1_4[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_1/4.4bpp"); +const u32 gMapObjectPic_OldWoman1_5[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_1/5.4bpp"); +const u32 gMapObjectPic_OldWoman1_6[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_1/6.4bpp"); +const u32 gMapObjectPic_OldWoman1_7[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_1/7.4bpp"); +const u32 gMapObjectPic_OldWoman1_8[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_1/8.4bpp"); +const u32 gMapObjectPic_Man2_0[] = INCBIN_U32("graphics/map_objects/pics/people/man_2/0.4bpp"); +const u32 gMapObjectPic_Man2_1[] = INCBIN_U32("graphics/map_objects/pics/people/man_2/1.4bpp"); +const u32 gMapObjectPic_Man2_2[] = INCBIN_U32("graphics/map_objects/pics/people/man_2/2.4bpp"); +const u32 gMapObjectPic_Man2_3[] = INCBIN_U32("graphics/map_objects/pics/people/man_2/3.4bpp"); +const u32 gMapObjectPic_Man2_4[] = INCBIN_U32("graphics/map_objects/pics/people/man_2/4.4bpp"); +const u32 gMapObjectPic_Man2_5[] = INCBIN_U32("graphics/map_objects/pics/people/man_2/5.4bpp"); +const u32 gMapObjectPic_Man2_6[] = INCBIN_U32("graphics/map_objects/pics/people/man_2/6.4bpp"); +const u32 gMapObjectPic_Man2_7[] = INCBIN_U32("graphics/map_objects/pics/people/man_2/7.4bpp"); +const u32 gMapObjectPic_Man2_8[] = INCBIN_U32("graphics/map_objects/pics/people/man_2/8.4bpp"); +const u32 gMapObjectPic_Woman4_0[] = INCBIN_U32("graphics/map_objects/pics/people/woman_4/0.4bpp"); +const u32 gMapObjectPic_Woman4_1[] = INCBIN_U32("graphics/map_objects/pics/people/woman_4/1.4bpp"); +const u32 gMapObjectPic_Woman4_2[] = INCBIN_U32("graphics/map_objects/pics/people/woman_4/2.4bpp"); +const u32 gMapObjectPic_Woman4_3[] = INCBIN_U32("graphics/map_objects/pics/people/woman_4/3.4bpp"); +const u32 gMapObjectPic_Woman4_4[] = INCBIN_U32("graphics/map_objects/pics/people/woman_4/4.4bpp"); +const u32 gMapObjectPic_Woman4_5[] = INCBIN_U32("graphics/map_objects/pics/people/woman_4/5.4bpp"); +const u32 gMapObjectPic_Woman4_6[] = INCBIN_U32("graphics/map_objects/pics/people/woman_4/6.4bpp"); +const u32 gMapObjectPic_Woman4_7[] = INCBIN_U32("graphics/map_objects/pics/people/woman_4/7.4bpp"); +const u32 gMapObjectPic_Woman4_8[] = INCBIN_U32("graphics/map_objects/pics/people/woman_4/8.4bpp"); +const u32 gMapObjectPic_Man3_0[] = INCBIN_U32("graphics/map_objects/pics/people/man_3/0.4bpp"); +const u32 gMapObjectPic_Man3_1[] = INCBIN_U32("graphics/map_objects/pics/people/man_3/1.4bpp"); +const u32 gMapObjectPic_Man3_2[] = INCBIN_U32("graphics/map_objects/pics/people/man_3/2.4bpp"); +const u32 gMapObjectPic_Man3_3[] = INCBIN_U32("graphics/map_objects/pics/people/man_3/3.4bpp"); +const u32 gMapObjectPic_Man3_4[] = INCBIN_U32("graphics/map_objects/pics/people/man_3/4.4bpp"); +const u32 gMapObjectPic_Man3_5[] = INCBIN_U32("graphics/map_objects/pics/people/man_3/5.4bpp"); +const u32 gMapObjectPic_Man3_6[] = INCBIN_U32("graphics/map_objects/pics/people/man_3/6.4bpp"); +const u32 gMapObjectPic_Man3_7[] = INCBIN_U32("graphics/map_objects/pics/people/man_3/7.4bpp"); +const u32 gMapObjectPic_Man3_8[] = INCBIN_U32("graphics/map_objects/pics/people/man_3/8.4bpp"); +const u32 gMapObjectPic_Woman5_0[] = INCBIN_U32("graphics/map_objects/pics/people/woman_5/0.4bpp"); +const u32 gMapObjectPic_Woman5_1[] = INCBIN_U32("graphics/map_objects/pics/people/woman_5/1.4bpp"); +const u32 gMapObjectPic_Woman5_2[] = INCBIN_U32("graphics/map_objects/pics/people/woman_5/2.4bpp"); +const u32 gMapObjectPic_Woman5_3[] = INCBIN_U32("graphics/map_objects/pics/people/woman_5/3.4bpp"); +const u32 gMapObjectPic_Woman5_4[] = INCBIN_U32("graphics/map_objects/pics/people/woman_5/4.4bpp"); +const u32 gMapObjectPic_Woman5_5[] = INCBIN_U32("graphics/map_objects/pics/people/woman_5/5.4bpp"); +const u32 gMapObjectPic_Woman5_6[] = INCBIN_U32("graphics/map_objects/pics/people/woman_5/6.4bpp"); +const u32 gMapObjectPic_Woman5_7[] = INCBIN_U32("graphics/map_objects/pics/people/woman_5/7.4bpp"); +const u32 gMapObjectPic_Woman5_8[] = INCBIN_U32("graphics/map_objects/pics/people/woman_5/8.4bpp"); +const u32 gMapObjectPic_Cook_0[] = INCBIN_U32("graphics/map_objects/pics/people/cook/0.4bpp"); +const u32 gMapObjectPic_Cook_1[] = INCBIN_U32("graphics/map_objects/pics/people/cook/1.4bpp"); +const u32 gMapObjectPic_Cook_2[] = INCBIN_U32("graphics/map_objects/pics/people/cook/2.4bpp"); +const u32 gMapObjectPic_Woman6_0[] = INCBIN_U32("graphics/map_objects/pics/people/woman_6/0.4bpp"); +const u32 gMapObjectPic_Woman6_1[] = INCBIN_U32("graphics/map_objects/pics/people/woman_6/1.4bpp"); +const u32 gMapObjectPic_Woman6_2[] = INCBIN_U32("graphics/map_objects/pics/people/woman_6/2.4bpp"); +const u32 gMapObjectPic_Woman6_3[] = INCBIN_U32("graphics/map_objects/pics/people/woman_6/3.4bpp"); +const u32 gMapObjectPic_Woman6_4[] = INCBIN_U32("graphics/map_objects/pics/people/woman_6/4.4bpp"); +const u32 gMapObjectPic_Woman6_5[] = INCBIN_U32("graphics/map_objects/pics/people/woman_6/5.4bpp"); +const u32 gMapObjectPic_Woman6_6[] = INCBIN_U32("graphics/map_objects/pics/people/woman_6/6.4bpp"); +const u32 gMapObjectPic_Woman6_7[] = INCBIN_U32("graphics/map_objects/pics/people/woman_6/7.4bpp"); +const u32 gMapObjectPic_Woman6_8[] = INCBIN_U32("graphics/map_objects/pics/people/woman_6/8.4bpp"); +const u32 gMapObjectPic_OldMan2_0[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_2/0.4bpp"); +const u32 gMapObjectPic_OldMan2_1[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_2/1.4bpp"); +const u32 gMapObjectPic_OldMan2_2[] = INCBIN_U32("graphics/map_objects/pics/people/old_man_2/2.4bpp"); +const u32 gMapObjectPic_OldWoman2_0[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_2/0.4bpp"); +const u32 gMapObjectPic_OldWoman2_1[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_2/1.4bpp"); +const u32 gMapObjectPic_OldWoman2_2[] = INCBIN_U32("graphics/map_objects/pics/people/old_woman_2/2.4bpp"); +const u32 gMapObjectPic_Camper_0[] = INCBIN_U32("graphics/map_objects/pics/people/camper/0.4bpp"); +const u32 gMapObjectPic_Camper_1[] = INCBIN_U32("graphics/map_objects/pics/people/camper/1.4bpp"); +const u32 gMapObjectPic_Camper_2[] = INCBIN_U32("graphics/map_objects/pics/people/camper/2.4bpp"); +const u32 gMapObjectPic_Camper_3[] = INCBIN_U32("graphics/map_objects/pics/people/camper/3.4bpp"); +const u32 gMapObjectPic_Camper_4[] = INCBIN_U32("graphics/map_objects/pics/people/camper/4.4bpp"); +const u32 gMapObjectPic_Camper_5[] = INCBIN_U32("graphics/map_objects/pics/people/camper/5.4bpp"); +const u32 gMapObjectPic_Camper_6[] = INCBIN_U32("graphics/map_objects/pics/people/camper/6.4bpp"); +const u32 gMapObjectPic_Camper_7[] = INCBIN_U32("graphics/map_objects/pics/people/camper/7.4bpp"); +const u32 gMapObjectPic_Camper_8[] = INCBIN_U32("graphics/map_objects/pics/people/camper/8.4bpp"); +const u32 gMapObjectPic_Picnicker_0[] = INCBIN_U32("graphics/map_objects/pics/people/picnicker/0.4bpp"); +const u32 gMapObjectPic_Picnicker_1[] = INCBIN_U32("graphics/map_objects/pics/people/picnicker/1.4bpp"); +const u32 gMapObjectPic_Picnicker_2[] = INCBIN_U32("graphics/map_objects/pics/people/picnicker/2.4bpp"); +const u32 gMapObjectPic_Picnicker_3[] = INCBIN_U32("graphics/map_objects/pics/people/picnicker/3.4bpp"); +const u32 gMapObjectPic_Picnicker_4[] = INCBIN_U32("graphics/map_objects/pics/people/picnicker/4.4bpp"); +const u32 gMapObjectPic_Picnicker_5[] = INCBIN_U32("graphics/map_objects/pics/people/picnicker/5.4bpp"); +const u32 gMapObjectPic_Picnicker_6[] = INCBIN_U32("graphics/map_objects/pics/people/picnicker/6.4bpp"); +const u32 gMapObjectPic_Picnicker_7[] = INCBIN_U32("graphics/map_objects/pics/people/picnicker/7.4bpp"); +const u32 gMapObjectPic_Picnicker_8[] = INCBIN_U32("graphics/map_objects/pics/people/picnicker/8.4bpp"); +const u32 gMapObjectPic_Man4_0[] = INCBIN_U32("graphics/map_objects/pics/people/man_4/0.4bpp"); +const u32 gMapObjectPic_Man4_1[] = INCBIN_U32("graphics/map_objects/pics/people/man_4/1.4bpp"); +const u32 gMapObjectPic_Man4_2[] = INCBIN_U32("graphics/map_objects/pics/people/man_4/2.4bpp"); +const u32 gMapObjectPic_Man4_3[] = INCBIN_U32("graphics/map_objects/pics/people/man_4/3.4bpp"); +const u32 gMapObjectPic_Man4_4[] = INCBIN_U32("graphics/map_objects/pics/people/man_4/4.4bpp"); +const u32 gMapObjectPic_Man4_5[] = INCBIN_U32("graphics/map_objects/pics/people/man_4/5.4bpp"); +const u32 gMapObjectPic_Man4_6[] = INCBIN_U32("graphics/map_objects/pics/people/man_4/6.4bpp"); +const u32 gMapObjectPic_Man4_7[] = INCBIN_U32("graphics/map_objects/pics/people/man_4/7.4bpp"); +const u32 gMapObjectPic_Man4_8[] = INCBIN_U32("graphics/map_objects/pics/people/man_4/8.4bpp"); +const u32 gMapObjectPic_Woman7_0[] = INCBIN_U32("graphics/map_objects/pics/people/woman_7/0.4bpp"); +const u32 gMapObjectPic_Woman7_1[] = INCBIN_U32("graphics/map_objects/pics/people/woman_7/1.4bpp"); +const u32 gMapObjectPic_Woman7_2[] = INCBIN_U32("graphics/map_objects/pics/people/woman_7/2.4bpp"); +const u32 gMapObjectPic_Woman7_3[] = INCBIN_U32("graphics/map_objects/pics/people/woman_7/3.4bpp"); +const u32 gMapObjectPic_Woman7_4[] = INCBIN_U32("graphics/map_objects/pics/people/woman_7/4.4bpp"); +const u32 gMapObjectPic_Woman7_5[] = INCBIN_U32("graphics/map_objects/pics/people/woman_7/5.4bpp"); +const u32 gMapObjectPic_Woman7_6[] = INCBIN_U32("graphics/map_objects/pics/people/woman_7/6.4bpp"); +const u32 gMapObjectPic_Woman7_7[] = INCBIN_U32("graphics/map_objects/pics/people/woman_7/7.4bpp"); +const u32 gMapObjectPic_Woman7_8[] = INCBIN_U32("graphics/map_objects/pics/people/woman_7/8.4bpp"); +const u32 gMapObjectPic_Youngster_0[] = INCBIN_U32("graphics/map_objects/pics/people/youngster/0.4bpp"); +const u32 gMapObjectPic_Youngster_1[] = INCBIN_U32("graphics/map_objects/pics/people/youngster/1.4bpp"); +const u32 gMapObjectPic_Youngster_2[] = INCBIN_U32("graphics/map_objects/pics/people/youngster/2.4bpp"); +const u32 gMapObjectPic_Youngster_3[] = INCBIN_U32("graphics/map_objects/pics/people/youngster/3.4bpp"); +const u32 gMapObjectPic_Youngster_4[] = INCBIN_U32("graphics/map_objects/pics/people/youngster/4.4bpp"); +const u32 gMapObjectPic_Youngster_5[] = INCBIN_U32("graphics/map_objects/pics/people/youngster/5.4bpp"); +const u32 gMapObjectPic_Youngster_6[] = INCBIN_U32("graphics/map_objects/pics/people/youngster/6.4bpp"); +const u32 gMapObjectPic_Youngster_7[] = INCBIN_U32("graphics/map_objects/pics/people/youngster/7.4bpp"); +const u32 gMapObjectPic_Youngster_8[] = INCBIN_U32("graphics/map_objects/pics/people/youngster/8.4bpp"); +const u32 gMapObjectPic_BugCatcher_0[] = INCBIN_U32("graphics/map_objects/pics/people/bug_catcher/0.4bpp"); +const u32 gMapObjectPic_BugCatcher_1[] = INCBIN_U32("graphics/map_objects/pics/people/bug_catcher/1.4bpp"); +const u32 gMapObjectPic_BugCatcher_2[] = INCBIN_U32("graphics/map_objects/pics/people/bug_catcher/2.4bpp"); +const u32 gMapObjectPic_BugCatcher_3[] = INCBIN_U32("graphics/map_objects/pics/people/bug_catcher/3.4bpp"); +const u32 gMapObjectPic_BugCatcher_4[] = INCBIN_U32("graphics/map_objects/pics/people/bug_catcher/4.4bpp"); +const u32 gMapObjectPic_BugCatcher_5[] = INCBIN_U32("graphics/map_objects/pics/people/bug_catcher/5.4bpp"); +const u32 gMapObjectPic_BugCatcher_6[] = INCBIN_U32("graphics/map_objects/pics/people/bug_catcher/6.4bpp"); +const u32 gMapObjectPic_BugCatcher_7[] = INCBIN_U32("graphics/map_objects/pics/people/bug_catcher/7.4bpp"); +const u32 gMapObjectPic_BugCatcher_8[] = INCBIN_U32("graphics/map_objects/pics/people/bug_catcher/8.4bpp"); +const u32 gMapObjectPic_PsychicM_0[] = INCBIN_U32("graphics/map_objects/pics/people/psychic_m/0.4bpp"); +const u32 gMapObjectPic_PsychicM_1[] = INCBIN_U32("graphics/map_objects/pics/people/psychic_m/1.4bpp"); +const u32 gMapObjectPic_PsychicM_2[] = INCBIN_U32("graphics/map_objects/pics/people/psychic_m/2.4bpp"); +const u32 gMapObjectPic_PsychicM_3[] = INCBIN_U32("graphics/map_objects/pics/people/psychic_m/3.4bpp"); +const u32 gMapObjectPic_PsychicM_4[] = INCBIN_U32("graphics/map_objects/pics/people/psychic_m/4.4bpp"); +const u32 gMapObjectPic_PsychicM_5[] = INCBIN_U32("graphics/map_objects/pics/people/psychic_m/5.4bpp"); +const u32 gMapObjectPic_PsychicM_6[] = INCBIN_U32("graphics/map_objects/pics/people/psychic_m/6.4bpp"); +const u32 gMapObjectPic_PsychicM_7[] = INCBIN_U32("graphics/map_objects/pics/people/psychic_m/7.4bpp"); +const u32 gMapObjectPic_PsychicM_8[] = INCBIN_U32("graphics/map_objects/pics/people/psychic_m/8.4bpp"); +const u32 gMapObjectPic_SchoolKidM_0[] = INCBIN_U32("graphics/map_objects/pics/people/school_kid_m/0.4bpp"); +const u32 gMapObjectPic_SchoolKidM_1[] = INCBIN_U32("graphics/map_objects/pics/people/school_kid_m/1.4bpp"); +const u32 gMapObjectPic_SchoolKidM_2[] = INCBIN_U32("graphics/map_objects/pics/people/school_kid_m/2.4bpp"); +const u32 gMapObjectPic_SchoolKidM_3[] = INCBIN_U32("graphics/map_objects/pics/people/school_kid_m/3.4bpp"); +const u32 gMapObjectPic_SchoolKidM_4[] = INCBIN_U32("graphics/map_objects/pics/people/school_kid_m/4.4bpp"); +const u32 gMapObjectPic_SchoolKidM_5[] = INCBIN_U32("graphics/map_objects/pics/people/school_kid_m/5.4bpp"); +const u32 gMapObjectPic_SchoolKidM_6[] = INCBIN_U32("graphics/map_objects/pics/people/school_kid_m/6.4bpp"); +const u32 gMapObjectPic_SchoolKidM_7[] = INCBIN_U32("graphics/map_objects/pics/people/school_kid_m/7.4bpp"); +const u32 gMapObjectPic_SchoolKidM_8[] = INCBIN_U32("graphics/map_objects/pics/people/school_kid_m/8.4bpp"); +const u32 gMapObjectPic_Maniac_0[] = INCBIN_U32("graphics/map_objects/pics/people/maniac/0.4bpp"); +const u32 gMapObjectPic_Maniac_1[] = INCBIN_U32("graphics/map_objects/pics/people/maniac/1.4bpp"); +const u32 gMapObjectPic_Maniac_2[] = INCBIN_U32("graphics/map_objects/pics/people/maniac/2.4bpp"); +const u32 gMapObjectPic_Maniac_3[] = INCBIN_U32("graphics/map_objects/pics/people/maniac/3.4bpp"); +const u32 gMapObjectPic_Maniac_4[] = INCBIN_U32("graphics/map_objects/pics/people/maniac/4.4bpp"); +const u32 gMapObjectPic_Maniac_5[] = INCBIN_U32("graphics/map_objects/pics/people/maniac/5.4bpp"); +const u32 gMapObjectPic_Maniac_6[] = INCBIN_U32("graphics/map_objects/pics/people/maniac/6.4bpp"); +const u32 gMapObjectPic_Maniac_7[] = INCBIN_U32("graphics/map_objects/pics/people/maniac/7.4bpp"); +const u32 gMapObjectPic_Maniac_8[] = INCBIN_U32("graphics/map_objects/pics/people/maniac/8.4bpp"); +const u32 gMapObjectPic_HexManiac_0[] = INCBIN_U32("graphics/map_objects/pics/people/hex_maniac/0.4bpp"); +const u32 gMapObjectPic_HexManiac_1[] = INCBIN_U32("graphics/map_objects/pics/people/hex_maniac/1.4bpp"); +const u32 gMapObjectPic_HexManiac_2[] = INCBIN_U32("graphics/map_objects/pics/people/hex_maniac/2.4bpp"); +const u32 gMapObjectPic_HexManiac_3[] = INCBIN_U32("graphics/map_objects/pics/people/hex_maniac/3.4bpp"); +const u32 gMapObjectPic_HexManiac_4[] = INCBIN_U32("graphics/map_objects/pics/people/hex_maniac/4.4bpp"); +const u32 gMapObjectPic_HexManiac_5[] = INCBIN_U32("graphics/map_objects/pics/people/hex_maniac/5.4bpp"); +const u32 gMapObjectPic_HexManiac_6[] = INCBIN_U32("graphics/map_objects/pics/people/hex_maniac/6.4bpp"); +const u32 gMapObjectPic_HexManiac_7[] = INCBIN_U32("graphics/map_objects/pics/people/hex_maniac/7.4bpp"); +const u32 gMapObjectPic_HexManiac_8[] = INCBIN_U32("graphics/map_objects/pics/people/hex_maniac/8.4bpp"); +const u32 gMapObjectPic_Woman8_0[] = INCBIN_U32("graphics/map_objects/pics/people/woman_8/0.4bpp"); +const u32 gMapObjectPic_Woman8_1[] = INCBIN_U32("graphics/map_objects/pics/people/woman_8/1.4bpp"); +const u32 gMapObjectPic_Woman8_2[] = INCBIN_U32("graphics/map_objects/pics/people/woman_8/2.4bpp"); +const u32 gMapObjectPic_Woman8_3[] = INCBIN_U32("graphics/map_objects/pics/people/woman_8/3.4bpp"); +const u32 gMapObjectPic_Woman8_4[] = INCBIN_U32("graphics/map_objects/pics/people/woman_8/4.4bpp"); +const u32 gMapObjectPic_Woman8_5[] = INCBIN_U32("graphics/map_objects/pics/people/woman_8/5.4bpp"); +const u32 gMapObjectPic_Woman8_6[] = INCBIN_U32("graphics/map_objects/pics/people/woman_8/6.4bpp"); +const u32 gMapObjectPic_Woman8_7[] = INCBIN_U32("graphics/map_objects/pics/people/woman_8/7.4bpp"); +const u32 gMapObjectPic_Woman8_8[] = INCBIN_U32("graphics/map_objects/pics/people/woman_8/8.4bpp"); +const u32 gMapObjectPic_SwimmerM_0[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_m/0.4bpp"); +const u32 gMapObjectPic_SwimmerM_1[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_m/1.4bpp"); +const u32 gMapObjectPic_SwimmerM_2[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_m/2.4bpp"); +const u32 gMapObjectPic_SwimmerM_3[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_m/3.4bpp"); +const u32 gMapObjectPic_SwimmerM_4[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_m/4.4bpp"); +const u32 gMapObjectPic_SwimmerM_5[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_m/5.4bpp"); +const u32 gMapObjectPic_SwimmerM_6[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_m/6.4bpp"); +const u32 gMapObjectPic_SwimmerM_7[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_m/7.4bpp"); +const u32 gMapObjectPic_SwimmerM_8[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_m/8.4bpp"); +const u32 gMapObjectPic_SwimmerF_0[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_f/0.4bpp"); +const u32 gMapObjectPic_SwimmerF_1[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_f/1.4bpp"); +const u32 gMapObjectPic_SwimmerF_2[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_f/2.4bpp"); +const u32 gMapObjectPic_SwimmerF_3[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_f/3.4bpp"); +const u32 gMapObjectPic_SwimmerF_4[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_f/4.4bpp"); +const u32 gMapObjectPic_SwimmerF_5[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_f/5.4bpp"); +const u32 gMapObjectPic_SwimmerF_6[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_f/6.4bpp"); +const u32 gMapObjectPic_SwimmerF_7[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_f/7.4bpp"); +const u32 gMapObjectPic_SwimmerF_8[] = INCBIN_U32("graphics/map_objects/pics/people/swimmer_f/8.4bpp"); +const u32 gMapObjectPic_BlackBelt_0[] = INCBIN_U32("graphics/map_objects/pics/people/black_belt/0.4bpp"); +const u32 gMapObjectPic_BlackBelt_1[] = INCBIN_U32("graphics/map_objects/pics/people/black_belt/1.4bpp"); +const u32 gMapObjectPic_BlackBelt_2[] = INCBIN_U32("graphics/map_objects/pics/people/black_belt/2.4bpp"); +const u32 gMapObjectPic_BlackBelt_3[] = INCBIN_U32("graphics/map_objects/pics/people/black_belt/3.4bpp"); +const u32 gMapObjectPic_BlackBelt_4[] = INCBIN_U32("graphics/map_objects/pics/people/black_belt/4.4bpp"); +const u32 gMapObjectPic_BlackBelt_5[] = INCBIN_U32("graphics/map_objects/pics/people/black_belt/5.4bpp"); +const u32 gMapObjectPic_BlackBelt_6[] = INCBIN_U32("graphics/map_objects/pics/people/black_belt/6.4bpp"); +const u32 gMapObjectPic_BlackBelt_7[] = INCBIN_U32("graphics/map_objects/pics/people/black_belt/7.4bpp"); +const u32 gMapObjectPic_BlackBelt_8[] = INCBIN_U32("graphics/map_objects/pics/people/black_belt/8.4bpp"); +const u32 gMapObjectPic_Beauty_0[] = INCBIN_U32("graphics/map_objects/pics/people/beauty/0.4bpp"); +const u32 gMapObjectPic_Beauty_1[] = INCBIN_U32("graphics/map_objects/pics/people/beauty/1.4bpp"); +const u32 gMapObjectPic_Beauty_2[] = INCBIN_U32("graphics/map_objects/pics/people/beauty/2.4bpp"); +const u32 gMapObjectPic_Beauty_3[] = INCBIN_U32("graphics/map_objects/pics/people/beauty/3.4bpp"); +const u32 gMapObjectPic_Beauty_4[] = INCBIN_U32("graphics/map_objects/pics/people/beauty/4.4bpp"); +const u32 gMapObjectPic_Beauty_5[] = INCBIN_U32("graphics/map_objects/pics/people/beauty/5.4bpp"); +const u32 gMapObjectPic_Beauty_6[] = INCBIN_U32("graphics/map_objects/pics/people/beauty/6.4bpp"); +const u32 gMapObjectPic_Beauty_7[] = INCBIN_U32("graphics/map_objects/pics/people/beauty/7.4bpp"); +const u32 gMapObjectPic_Beauty_8[] = INCBIN_U32("graphics/map_objects/pics/people/beauty/8.4bpp"); +const u32 gMapObjectPic_Scientist1_0[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_1/0.4bpp"); +const u32 gMapObjectPic_Scientist1_1[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_1/1.4bpp"); +const u32 gMapObjectPic_Scientist1_2[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_1/2.4bpp"); +const u32 gMapObjectPic_Scientist1_3[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_1/3.4bpp"); +const u32 gMapObjectPic_Scientist1_4[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_1/4.4bpp"); +const u32 gMapObjectPic_Scientist1_5[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_1/5.4bpp"); +const u32 gMapObjectPic_Scientist1_6[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_1/6.4bpp"); +const u32 gMapObjectPic_Scientist1_7[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_1/7.4bpp"); +const u32 gMapObjectPic_Scientist1_8[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_1/8.4bpp"); +const u32 gMapObjectPic_Lass_0[] = INCBIN_U32("graphics/map_objects/pics/people/lass/0.4bpp"); +const u32 gMapObjectPic_Lass_1[] = INCBIN_U32("graphics/map_objects/pics/people/lass/1.4bpp"); +const u32 gMapObjectPic_Lass_2[] = INCBIN_U32("graphics/map_objects/pics/people/lass/2.4bpp"); +const u32 gMapObjectPic_Lass_3[] = INCBIN_U32("graphics/map_objects/pics/people/lass/3.4bpp"); +const u32 gMapObjectPic_Lass_4[] = INCBIN_U32("graphics/map_objects/pics/people/lass/4.4bpp"); +const u32 gMapObjectPic_Lass_5[] = INCBIN_U32("graphics/map_objects/pics/people/lass/5.4bpp"); +const u32 gMapObjectPic_Lass_6[] = INCBIN_U32("graphics/map_objects/pics/people/lass/6.4bpp"); +const u32 gMapObjectPic_Lass_7[] = INCBIN_U32("graphics/map_objects/pics/people/lass/7.4bpp"); +const u32 gMapObjectPic_Lass_8[] = INCBIN_U32("graphics/map_objects/pics/people/lass/8.4bpp"); +const u32 gMapObjectPic_Gentleman_0[] = INCBIN_U32("graphics/map_objects/pics/people/gentleman/0.4bpp"); +const u32 gMapObjectPic_Gentleman_1[] = INCBIN_U32("graphics/map_objects/pics/people/gentleman/1.4bpp"); +const u32 gMapObjectPic_Gentleman_2[] = INCBIN_U32("graphics/map_objects/pics/people/gentleman/2.4bpp"); +const u32 gMapObjectPic_Gentleman_3[] = INCBIN_U32("graphics/map_objects/pics/people/gentleman/3.4bpp"); +const u32 gMapObjectPic_Gentleman_4[] = INCBIN_U32("graphics/map_objects/pics/people/gentleman/4.4bpp"); +const u32 gMapObjectPic_Gentleman_5[] = INCBIN_U32("graphics/map_objects/pics/people/gentleman/5.4bpp"); +const u32 gMapObjectPic_Gentleman_6[] = INCBIN_U32("graphics/map_objects/pics/people/gentleman/6.4bpp"); +const u32 gMapObjectPic_Gentleman_7[] = INCBIN_U32("graphics/map_objects/pics/people/gentleman/7.4bpp"); +const u32 gMapObjectPic_Gentleman_8[] = INCBIN_U32("graphics/map_objects/pics/people/gentleman/8.4bpp"); +const u32 gMapObjectPic_Sailor_0[] = INCBIN_U32("graphics/map_objects/pics/people/sailor/0.4bpp"); +const u32 gMapObjectPic_Sailor_1[] = INCBIN_U32("graphics/map_objects/pics/people/sailor/1.4bpp"); +const u32 gMapObjectPic_Sailor_2[] = INCBIN_U32("graphics/map_objects/pics/people/sailor/2.4bpp"); +const u32 gMapObjectPic_Sailor_3[] = INCBIN_U32("graphics/map_objects/pics/people/sailor/3.4bpp"); +const u32 gMapObjectPic_Sailor_4[] = INCBIN_U32("graphics/map_objects/pics/people/sailor/4.4bpp"); +const u32 gMapObjectPic_Sailor_5[] = INCBIN_U32("graphics/map_objects/pics/people/sailor/5.4bpp"); +const u32 gMapObjectPic_Sailor_6[] = INCBIN_U32("graphics/map_objects/pics/people/sailor/6.4bpp"); +const u32 gMapObjectPic_Sailor_7[] = INCBIN_U32("graphics/map_objects/pics/people/sailor/7.4bpp"); +const u32 gMapObjectPic_Sailor_8[] = INCBIN_U32("graphics/map_objects/pics/people/sailor/8.4bpp"); +const u32 gMapObjectPic_Fisherman_0[] = INCBIN_U32("graphics/map_objects/pics/people/fisherman/0.4bpp"); +const u32 gMapObjectPic_Fisherman_1[] = INCBIN_U32("graphics/map_objects/pics/people/fisherman/1.4bpp"); +const u32 gMapObjectPic_Fisherman_2[] = INCBIN_U32("graphics/map_objects/pics/people/fisherman/2.4bpp"); +const u32 gMapObjectPic_Fisherman_3[] = INCBIN_U32("graphics/map_objects/pics/people/fisherman/3.4bpp"); +const u32 gMapObjectPic_Fisherman_4[] = INCBIN_U32("graphics/map_objects/pics/people/fisherman/4.4bpp"); +const u32 gMapObjectPic_Fisherman_5[] = INCBIN_U32("graphics/map_objects/pics/people/fisherman/5.4bpp"); +const u32 gMapObjectPic_Fisherman_6[] = INCBIN_U32("graphics/map_objects/pics/people/fisherman/6.4bpp"); +const u32 gMapObjectPic_Fisherman_7[] = INCBIN_U32("graphics/map_objects/pics/people/fisherman/7.4bpp"); +const u32 gMapObjectPic_Fisherman_8[] = INCBIN_U32("graphics/map_objects/pics/people/fisherman/8.4bpp"); +const u32 gMapObjectPic_RunningTriathleteM_0[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_m/0.4bpp"); +const u32 gMapObjectPic_RunningTriathleteM_1[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_m/1.4bpp"); +const u32 gMapObjectPic_RunningTriathleteM_2[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_m/2.4bpp"); +const u32 gMapObjectPic_RunningTriathleteM_3[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_m/3.4bpp"); +const u32 gMapObjectPic_RunningTriathleteM_4[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_m/4.4bpp"); +const u32 gMapObjectPic_RunningTriathleteM_5[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_m/5.4bpp"); +const u32 gMapObjectPic_RunningTriathleteM_6[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_m/6.4bpp"); +const u32 gMapObjectPic_RunningTriathleteM_7[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_m/7.4bpp"); +const u32 gMapObjectPic_RunningTriathleteM_8[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_m/8.4bpp"); +const u32 gMapObjectPic_RunningTriathleteF_0[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_f/0.4bpp"); +const u32 gMapObjectPic_RunningTriathleteF_1[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_f/1.4bpp"); +const u32 gMapObjectPic_RunningTriathleteF_2[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_f/2.4bpp"); +const u32 gMapObjectPic_RunningTriathleteF_3[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_f/3.4bpp"); +const u32 gMapObjectPic_RunningTriathleteF_4[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_f/4.4bpp"); +const u32 gMapObjectPic_RunningTriathleteF_5[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_f/5.4bpp"); +const u32 gMapObjectPic_RunningTriathleteF_6[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_f/6.4bpp"); +const u32 gMapObjectPic_RunningTriathleteF_7[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_f/7.4bpp"); +const u32 gMapObjectPic_RunningTriathleteF_8[] = INCBIN_U32("graphics/map_objects/pics/people/running_triathlete_f/8.4bpp"); +const u32 gMapObjectPic_TuberF_0[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_f/0.4bpp"); +const u32 gMapObjectPic_TuberF_1[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_f/1.4bpp"); +const u32 gMapObjectPic_TuberF_2[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_f/2.4bpp"); +const u32 gMapObjectPic_TuberF_3[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_f/3.4bpp"); +const u32 gMapObjectPic_TuberF_4[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_f/4.4bpp"); +const u32 gMapObjectPic_TuberF_5[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_f/5.4bpp"); +const u32 gMapObjectPic_TuberF_6[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_f/6.4bpp"); +const u32 gMapObjectPic_TuberF_7[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_f/7.4bpp"); +const u32 gMapObjectPic_TuberF_8[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_f/8.4bpp"); +const u32 gMapObjectPic_TuberM_0[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m/0.4bpp"); +const u32 gMapObjectPic_TuberM_1[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m/1.4bpp"); +const u32 gMapObjectPic_TuberM_2[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m/2.4bpp"); +const u32 gMapObjectPic_TuberM_3[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m/3.4bpp"); +const u32 gMapObjectPic_TuberM_4[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m/4.4bpp"); +const u32 gMapObjectPic_TuberM_5[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m/5.4bpp"); +const u32 gMapObjectPic_TuberM_6[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m/6.4bpp"); +const u32 gMapObjectPic_TuberM_7[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m/7.4bpp"); +const u32 gMapObjectPic_TuberM_8[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m/8.4bpp"); +const u32 gMapObjectPic_Hiker_0[] = INCBIN_U32("graphics/map_objects/pics/people/hiker/0.4bpp"); +const u32 gMapObjectPic_Hiker_1[] = INCBIN_U32("graphics/map_objects/pics/people/hiker/1.4bpp"); +const u32 gMapObjectPic_Hiker_2[] = INCBIN_U32("graphics/map_objects/pics/people/hiker/2.4bpp"); +const u32 gMapObjectPic_Hiker_3[] = INCBIN_U32("graphics/map_objects/pics/people/hiker/3.4bpp"); +const u32 gMapObjectPic_Hiker_4[] = INCBIN_U32("graphics/map_objects/pics/people/hiker/4.4bpp"); +const u32 gMapObjectPic_Hiker_5[] = INCBIN_U32("graphics/map_objects/pics/people/hiker/5.4bpp"); +const u32 gMapObjectPic_Hiker_6[] = INCBIN_U32("graphics/map_objects/pics/people/hiker/6.4bpp"); +const u32 gMapObjectPic_Hiker_7[] = INCBIN_U32("graphics/map_objects/pics/people/hiker/7.4bpp"); +const u32 gMapObjectPic_Hiker_8[] = INCBIN_U32("graphics/map_objects/pics/people/hiker/8.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteM_0[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_m/0.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteM_1[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_m/1.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteM_2[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_m/2.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteM_3[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_m/3.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteM_4[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_m/4.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteM_5[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_m/5.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteM_6[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_m/6.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteM_7[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_m/7.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteM_8[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_m/8.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteF_0[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_f/0.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteF_1[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_f/1.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteF_2[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_f/2.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteF_3[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_f/3.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteF_4[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_f/4.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteF_5[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_f/5.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteF_6[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_f/6.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteF_7[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_f/7.4bpp"); +const u32 gMapObjectPic_CyclingTriathleteF_8[] = INCBIN_U32("graphics/map_objects/pics/people/cycling_triathlete_f/8.4bpp"); +const u32 gMapObjectPic_Man5_0[] = INCBIN_U32("graphics/map_objects/pics/people/man_5/0.4bpp"); +const u32 gMapObjectPic_Man5_1[] = INCBIN_U32("graphics/map_objects/pics/people/man_5/1.4bpp"); +const u32 gMapObjectPic_Man5_2[] = INCBIN_U32("graphics/map_objects/pics/people/man_5/2.4bpp"); +const u32 gMapObjectPic_Man5_3[] = INCBIN_U32("graphics/map_objects/pics/people/man_5/3.4bpp"); +const u32 gMapObjectPic_Man5_4[] = INCBIN_U32("graphics/map_objects/pics/people/man_5/4.4bpp"); +const u32 gMapObjectPic_Man5_5[] = INCBIN_U32("graphics/map_objects/pics/people/man_5/5.4bpp"); +const u32 gMapObjectPic_Man5_6[] = INCBIN_U32("graphics/map_objects/pics/people/man_5/6.4bpp"); +const u32 gMapObjectPic_Man5_7[] = INCBIN_U32("graphics/map_objects/pics/people/man_5/7.4bpp"); +const u32 gMapObjectPic_Man5_8[] = INCBIN_U32("graphics/map_objects/pics/people/man_5/8.4bpp"); +const u32 gMapObjectPic_Man6_0[] = INCBIN_U32("graphics/map_objects/pics/people/man_6/0.4bpp"); +const u32 gMapObjectPic_Man6_1[] = INCBIN_U32("graphics/map_objects/pics/people/man_6/1.4bpp"); +const u32 gMapObjectPic_Man6_2[] = INCBIN_U32("graphics/map_objects/pics/people/man_6/2.4bpp"); +const u32 gMapObjectPic_Man6_3[] = INCBIN_U32("graphics/map_objects/pics/people/man_6/3.4bpp"); +const u32 gMapObjectPic_Man6_4[] = INCBIN_U32("graphics/map_objects/pics/people/man_6/4.4bpp"); +const u32 gMapObjectPic_Man6_5[] = INCBIN_U32("graphics/map_objects/pics/people/man_6/5.4bpp"); +const u32 gMapObjectPic_Man6_6[] = INCBIN_U32("graphics/map_objects/pics/people/man_6/6.4bpp"); +const u32 gMapObjectPic_Man6_7[] = INCBIN_U32("graphics/map_objects/pics/people/man_6/7.4bpp"); +const u32 gMapObjectPic_Man6_8[] = INCBIN_U32("graphics/map_objects/pics/people/man_6/8.4bpp"); +const u32 gMapObjectPic_Nurse_0[] = INCBIN_U32("graphics/map_objects/pics/people/nurse/0.4bpp"); +const u32 gMapObjectPic_Nurse_1[] = INCBIN_U32("graphics/map_objects/pics/people/nurse/1.4bpp"); +const u32 gMapObjectPic_Nurse_2[] = INCBIN_U32("graphics/map_objects/pics/people/nurse/2.4bpp"); +const u32 gMapObjectPic_Nurse_3[] = INCBIN_U32("graphics/map_objects/pics/people/nurse/3.4bpp"); +const u32 gMapObjectPic_Nurse_4[] = INCBIN_U32("graphics/map_objects/pics/people/nurse/4.4bpp"); +const u32 gMapObjectPic_Nurse_5[] = INCBIN_U32("graphics/map_objects/pics/people/nurse/5.4bpp"); +const u32 gMapObjectPic_Nurse_6[] = INCBIN_U32("graphics/map_objects/pics/people/nurse/6.4bpp"); +const u32 gMapObjectPic_Nurse_7[] = INCBIN_U32("graphics/map_objects/pics/people/nurse/7.4bpp"); +const u32 gMapObjectPic_Nurse_8[] = INCBIN_U32("graphics/map_objects/pics/people/nurse/8.4bpp"); +const u32 gMapObjectPic_Nurse_9[] = INCBIN_U32("graphics/map_objects/pics/people/nurse/9.4bpp"); +const u32 gMapObjectPic_ItemBall[] = INCBIN_U32("graphics/map_objects/pics/misc/item_ball.4bpp"); +const u32 gMapObjectPic_ProfBirch_0[] = INCBIN_U32("graphics/map_objects/pics/people/prof_birch/0.4bpp"); +const u32 gMapObjectPic_ProfBirch_1[] = INCBIN_U32("graphics/map_objects/pics/people/prof_birch/1.4bpp"); +const u32 gMapObjectPic_ProfBirch_2[] = INCBIN_U32("graphics/map_objects/pics/people/prof_birch/2.4bpp"); +const u32 gMapObjectPic_ProfBirch_3[] = INCBIN_U32("graphics/map_objects/pics/people/prof_birch/3.4bpp"); +const u32 gMapObjectPic_ProfBirch_4[] = INCBIN_U32("graphics/map_objects/pics/people/prof_birch/4.4bpp"); +const u32 gMapObjectPic_ProfBirch_5[] = INCBIN_U32("graphics/map_objects/pics/people/prof_birch/5.4bpp"); +const u32 gMapObjectPic_ProfBirch_6[] = INCBIN_U32("graphics/map_objects/pics/people/prof_birch/6.4bpp"); +const u32 gMapObjectPic_ProfBirch_7[] = INCBIN_U32("graphics/map_objects/pics/people/prof_birch/7.4bpp"); +const u32 gMapObjectPic_ProfBirch_8[] = INCBIN_U32("graphics/map_objects/pics/people/prof_birch/8.4bpp"); +const u32 gMapObjectPic_ReporterM_0[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_m/0.4bpp"); +const u32 gMapObjectPic_ReporterM_1[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_m/1.4bpp"); +const u32 gMapObjectPic_ReporterM_2[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_m/2.4bpp"); +const u32 gMapObjectPic_ReporterM_3[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_m/3.4bpp"); +const u32 gMapObjectPic_ReporterM_4[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_m/4.4bpp"); +const u32 gMapObjectPic_ReporterM_5[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_m/5.4bpp"); +const u32 gMapObjectPic_ReporterM_6[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_m/6.4bpp"); +const u32 gMapObjectPic_ReporterM_7[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_m/7.4bpp"); +const u32 gMapObjectPic_ReporterM_8[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_m/8.4bpp"); +const u32 gMapObjectPic_ReporterF_0[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_f/0.4bpp"); +const u32 gMapObjectPic_ReporterF_1[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_f/1.4bpp"); +const u32 gMapObjectPic_ReporterF_2[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_f/2.4bpp"); +const u32 gMapObjectPic_ReporterF_3[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_f/3.4bpp"); +const u32 gMapObjectPic_ReporterF_4[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_f/4.4bpp"); +const u32 gMapObjectPic_ReporterF_5[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_f/5.4bpp"); +const u32 gMapObjectPic_ReporterF_6[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_f/6.4bpp"); +const u32 gMapObjectPic_ReporterF_7[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_f/7.4bpp"); +const u32 gMapObjectPic_ReporterF_8[] = INCBIN_U32("graphics/map_objects/pics/people/reporter_f/8.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan1_0[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_1/0.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan1_1[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_1/1.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan1_2[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_1/2.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan1_3[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_1/3.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan1_4[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_1/4.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan1_5[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_1/5.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan1_6[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_1/6.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan1_7[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_1/7.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan1_8[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_1/8.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan2_0[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_2/0.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan2_1[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_2/1.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan2_2[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_2/2.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan2_3[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_2/3.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan2_4[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_2/4.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan2_5[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_2/5.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan2_6[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_2/6.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan2_7[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_2/7.4bpp"); +const u32 gMapObjectPic_MauvilleOldMan2_8[] = INCBIN_U32("graphics/map_objects/pics/people/mauville_old_man_2/8.4bpp"); +const u32 gMapObjectPic_MartEmployee_0[] = INCBIN_U32("graphics/map_objects/pics/people/mart_employee/0.4bpp"); +const u32 gMapObjectPic_MartEmployee_1[] = INCBIN_U32("graphics/map_objects/pics/people/mart_employee/1.4bpp"); +const u32 gMapObjectPic_MartEmployee_2[] = INCBIN_U32("graphics/map_objects/pics/people/mart_employee/2.4bpp"); +const u32 gMapObjectPic_MartEmployee_3[] = INCBIN_U32("graphics/map_objects/pics/people/mart_employee/3.4bpp"); +const u32 gMapObjectPic_MartEmployee_4[] = INCBIN_U32("graphics/map_objects/pics/people/mart_employee/4.4bpp"); +const u32 gMapObjectPic_MartEmployee_5[] = INCBIN_U32("graphics/map_objects/pics/people/mart_employee/5.4bpp"); +const u32 gMapObjectPic_MartEmployee_6[] = INCBIN_U32("graphics/map_objects/pics/people/mart_employee/6.4bpp"); +const u32 gMapObjectPic_MartEmployee_7[] = INCBIN_U32("graphics/map_objects/pics/people/mart_employee/7.4bpp"); +const u32 gMapObjectPic_MartEmployee_8[] = INCBIN_U32("graphics/map_objects/pics/people/mart_employee/8.4bpp"); +const u32 gMapObjectPic_RooftopSaleWoman_0[] = INCBIN_U32("graphics/map_objects/pics/people/rooftop_sale_woman/0.4bpp"); +const u32 gMapObjectPic_RooftopSaleWoman_1[] = INCBIN_U32("graphics/map_objects/pics/people/rooftop_sale_woman/1.4bpp"); +const u32 gMapObjectPic_RooftopSaleWoman_2[] = INCBIN_U32("graphics/map_objects/pics/people/rooftop_sale_woman/2.4bpp"); +const u32 gMapObjectPic_RooftopSaleWoman_3[] = INCBIN_U32("graphics/map_objects/pics/people/rooftop_sale_woman/3.4bpp"); +const u32 gMapObjectPic_RooftopSaleWoman_4[] = INCBIN_U32("graphics/map_objects/pics/people/rooftop_sale_woman/4.4bpp"); +const u32 gMapObjectPic_RooftopSaleWoman_5[] = INCBIN_U32("graphics/map_objects/pics/people/rooftop_sale_woman/5.4bpp"); +const u32 gMapObjectPic_RooftopSaleWoman_6[] = INCBIN_U32("graphics/map_objects/pics/people/rooftop_sale_woman/6.4bpp"); +const u32 gMapObjectPic_RooftopSaleWoman_7[] = INCBIN_U32("graphics/map_objects/pics/people/rooftop_sale_woman/7.4bpp"); +const u32 gMapObjectPic_RooftopSaleWoman_8[] = INCBIN_U32("graphics/map_objects/pics/people/rooftop_sale_woman/8.4bpp"); +const u32 gMapObjectPic_Teala_0[] = INCBIN_U32("graphics/map_objects/pics/people/teala/0.4bpp"); +const u32 gMapObjectPic_Teala_1[] = INCBIN_U32("graphics/map_objects/pics/people/teala/1.4bpp"); +const u32 gMapObjectPic_Teala_2[] = INCBIN_U32("graphics/map_objects/pics/people/teala/2.4bpp"); +const u32 gMapObjectPic_Teala_3[] = INCBIN_U32("graphics/map_objects/pics/people/teala/3.4bpp"); +const u32 gMapObjectPic_Teala_4[] = INCBIN_U32("graphics/map_objects/pics/people/teala/4.4bpp"); +const u32 gMapObjectPic_Teala_5[] = INCBIN_U32("graphics/map_objects/pics/people/teala/5.4bpp"); +const u32 gMapObjectPic_Teala_6[] = INCBIN_U32("graphics/map_objects/pics/people/teala/6.4bpp"); +const u32 gMapObjectPic_Teala_7[] = INCBIN_U32("graphics/map_objects/pics/people/teala/7.4bpp"); +const u32 gMapObjectPic_Teala_8[] = INCBIN_U32("graphics/map_objects/pics/people/teala/8.4bpp"); +const u32 gMapObjectPic_Artist_0[] = INCBIN_U32("graphics/map_objects/pics/people/artist/0.4bpp"); +const u32 gMapObjectPic_Artist_1[] = INCBIN_U32("graphics/map_objects/pics/people/artist/1.4bpp"); +const u32 gMapObjectPic_Artist_2[] = INCBIN_U32("graphics/map_objects/pics/people/artist/2.4bpp"); +const u32 gMapObjectPic_Artist_3[] = INCBIN_U32("graphics/map_objects/pics/people/artist/3.4bpp"); +const u32 gMapObjectPic_Artist_4[] = INCBIN_U32("graphics/map_objects/pics/people/artist/4.4bpp"); +const u32 gMapObjectPic_Artist_5[] = INCBIN_U32("graphics/map_objects/pics/people/artist/5.4bpp"); +const u32 gMapObjectPic_Artist_6[] = INCBIN_U32("graphics/map_objects/pics/people/artist/6.4bpp"); +const u32 gMapObjectPic_Artist_7[] = INCBIN_U32("graphics/map_objects/pics/people/artist/7.4bpp"); +const u32 gMapObjectPic_Artist_8[] = INCBIN_U32("graphics/map_objects/pics/people/artist/8.4bpp"); +const u32 gMapObjectPic_Cameraman_0[] = INCBIN_U32("graphics/map_objects/pics/people/cameraman/0.4bpp"); +const u32 gMapObjectPic_Cameraman_1[] = INCBIN_U32("graphics/map_objects/pics/people/cameraman/1.4bpp"); +const u32 gMapObjectPic_Cameraman_2[] = INCBIN_U32("graphics/map_objects/pics/people/cameraman/2.4bpp"); +const u32 gMapObjectPic_Cameraman_3[] = INCBIN_U32("graphics/map_objects/pics/people/cameraman/3.4bpp"); +const u32 gMapObjectPic_Cameraman_4[] = INCBIN_U32("graphics/map_objects/pics/people/cameraman/4.4bpp"); +const u32 gMapObjectPic_Cameraman_5[] = INCBIN_U32("graphics/map_objects/pics/people/cameraman/5.4bpp"); +const u32 gMapObjectPic_Cameraman_6[] = INCBIN_U32("graphics/map_objects/pics/people/cameraman/6.4bpp"); +const u32 gMapObjectPic_Cameraman_7[] = INCBIN_U32("graphics/map_objects/pics/people/cameraman/7.4bpp"); +const u32 gMapObjectPic_Cameraman_8[] = INCBIN_U32("graphics/map_objects/pics/people/cameraman/8.4bpp"); +const u32 gMapObjectPic_Scientist2_0[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_2/0.4bpp"); +const u32 gMapObjectPic_Scientist2_1[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_2/1.4bpp"); +const u32 gMapObjectPic_Scientist2_2[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_2/2.4bpp"); +const u32 gMapObjectPic_Scientist2_3[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_2/3.4bpp"); +const u32 gMapObjectPic_Scientist2_4[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_2/4.4bpp"); +const u32 gMapObjectPic_Scientist2_5[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_2/5.4bpp"); +const u32 gMapObjectPic_Scientist2_6[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_2/6.4bpp"); +const u32 gMapObjectPic_Scientist2_7[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_2/7.4bpp"); +const u32 gMapObjectPic_Scientist2_8[] = INCBIN_U32("graphics/map_objects/pics/people/scientist_2/8.4bpp"); +const u32 gMapObjectPic_Man7_0[] = INCBIN_U32("graphics/map_objects/pics/people/man_7/0.4bpp"); +const u32 gMapObjectPic_Man7_1[] = INCBIN_U32("graphics/map_objects/pics/people/man_7/1.4bpp"); +const u32 gMapObjectPic_Man7_2[] = INCBIN_U32("graphics/map_objects/pics/people/man_7/2.4bpp"); +const u32 gMapObjectPic_Man7_3[] = INCBIN_U32("graphics/map_objects/pics/people/man_7/3.4bpp"); +const u32 gMapObjectPic_Man7_4[] = INCBIN_U32("graphics/map_objects/pics/people/man_7/4.4bpp"); +const u32 gMapObjectPic_Man7_5[] = INCBIN_U32("graphics/map_objects/pics/people/man_7/5.4bpp"); +const u32 gMapObjectPic_Man7_6[] = INCBIN_U32("graphics/map_objects/pics/people/man_7/6.4bpp"); +const u32 gMapObjectPic_Man7_7[] = INCBIN_U32("graphics/map_objects/pics/people/man_7/7.4bpp"); +const u32 gMapObjectPic_Man7_8[] = INCBIN_U32("graphics/map_objects/pics/people/man_7/8.4bpp"); +const u32 gMapObjectPic_AquaMemberM_0[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_m/0.4bpp"); +const u32 gMapObjectPic_AquaMemberM_1[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_m/1.4bpp"); +const u32 gMapObjectPic_AquaMemberM_2[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_m/2.4bpp"); +const u32 gMapObjectPic_AquaMemberM_3[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_m/3.4bpp"); +const u32 gMapObjectPic_AquaMemberM_4[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_m/4.4bpp"); +const u32 gMapObjectPic_AquaMemberM_5[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_m/5.4bpp"); +const u32 gMapObjectPic_AquaMemberM_6[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_m/6.4bpp"); +const u32 gMapObjectPic_AquaMemberM_7[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_m/7.4bpp"); +const u32 gMapObjectPic_AquaMemberM_8[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_m/8.4bpp"); +const u32 gMapObjectPic_AquaMemberF_0[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_f/0.4bpp"); +const u32 gMapObjectPic_AquaMemberF_1[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_f/1.4bpp"); +const u32 gMapObjectPic_AquaMemberF_2[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_f/2.4bpp"); +const u32 gMapObjectPic_AquaMemberF_3[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_f/3.4bpp"); +const u32 gMapObjectPic_AquaMemberF_4[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_f/4.4bpp"); +const u32 gMapObjectPic_AquaMemberF_5[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_f/5.4bpp"); +const u32 gMapObjectPic_AquaMemberF_6[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_f/6.4bpp"); +const u32 gMapObjectPic_AquaMemberF_7[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_f/7.4bpp"); +const u32 gMapObjectPic_AquaMemberF_8[] = INCBIN_U32("graphics/map_objects/pics/people/aqua_member_f/8.4bpp"); +const u32 gMapObjectPic_MagmaMemberM_0[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_m/0.4bpp"); +const u32 gMapObjectPic_MagmaMemberM_1[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_m/1.4bpp"); +const u32 gMapObjectPic_MagmaMemberM_2[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_m/2.4bpp"); +const u32 gMapObjectPic_MagmaMemberM_3[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_m/3.4bpp"); +const u32 gMapObjectPic_MagmaMemberM_4[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_m/4.4bpp"); +const u32 gMapObjectPic_MagmaMemberM_5[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_m/5.4bpp"); +const u32 gMapObjectPic_MagmaMemberM_6[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_m/6.4bpp"); +const u32 gMapObjectPic_MagmaMemberM_7[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_m/7.4bpp"); +const u32 gMapObjectPic_MagmaMemberM_8[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_m/8.4bpp"); +const u32 gMapObjectPic_MagmaMemberF_0[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_f/0.4bpp"); +const u32 gMapObjectPic_MagmaMemberF_1[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_f/1.4bpp"); +const u32 gMapObjectPic_MagmaMemberF_2[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_f/2.4bpp"); +const u32 gMapObjectPic_MagmaMemberF_3[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_f/3.4bpp"); +const u32 gMapObjectPic_MagmaMemberF_4[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_f/4.4bpp"); +const u32 gMapObjectPic_MagmaMemberF_5[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_f/5.4bpp"); +const u32 gMapObjectPic_MagmaMemberF_6[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_f/6.4bpp"); +const u32 gMapObjectPic_MagmaMemberF_7[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_f/7.4bpp"); +const u32 gMapObjectPic_MagmaMemberF_8[] = INCBIN_U32("graphics/map_objects/pics/people/magma_member_f/8.4bpp"); +const u32 gMapObjectPic_Sidney_0[] = INCBIN_U32("graphics/map_objects/pics/people/sidney/0.4bpp"); +const u32 gMapObjectPic_Sidney_1[] = INCBIN_U32("graphics/map_objects/pics/people/sidney/1.4bpp"); +const u32 gMapObjectPic_Sidney_2[] = INCBIN_U32("graphics/map_objects/pics/people/sidney/2.4bpp"); +const u32 gMapObjectPic_Phoebe_0[] = INCBIN_U32("graphics/map_objects/pics/people/phoebe/0.4bpp"); +const u32 gMapObjectPic_Phoebe_1[] = INCBIN_U32("graphics/map_objects/pics/people/phoebe/1.4bpp"); +const u32 gMapObjectPic_Phoebe_2[] = INCBIN_U32("graphics/map_objects/pics/people/phoebe/2.4bpp"); +const u32 gMapObjectPic_Glacia_0[] = INCBIN_U32("graphics/map_objects/pics/people/glacia/0.4bpp"); +const u32 gMapObjectPic_Glacia_1[] = INCBIN_U32("graphics/map_objects/pics/people/glacia/1.4bpp"); +const u32 gMapObjectPic_Glacia_2[] = INCBIN_U32("graphics/map_objects/pics/people/glacia/2.4bpp"); +const u32 gMapObjectPic_Drake_0[] = INCBIN_U32("graphics/map_objects/pics/people/drake/0.4bpp"); +const u32 gMapObjectPic_Drake_1[] = INCBIN_U32("graphics/map_objects/pics/people/drake/1.4bpp"); +const u32 gMapObjectPic_Drake_2[] = INCBIN_U32("graphics/map_objects/pics/people/drake/2.4bpp"); +const u32 gMapObjectPic_Roxanne_0[] = INCBIN_U32("graphics/map_objects/pics/people/roxanne/0.4bpp"); +const u32 gMapObjectPic_Roxanne_1[] = INCBIN_U32("graphics/map_objects/pics/people/roxanne/1.4bpp"); +const u32 gMapObjectPic_Roxanne_2[] = INCBIN_U32("graphics/map_objects/pics/people/roxanne/2.4bpp"); +const u32 gMapObjectPic_Brawly_0[] = INCBIN_U32("graphics/map_objects/pics/people/brawly/0.4bpp"); +const u32 gMapObjectPic_Brawly_1[] = INCBIN_U32("graphics/map_objects/pics/people/brawly/1.4bpp"); +const u32 gMapObjectPic_Brawly_2[] = INCBIN_U32("graphics/map_objects/pics/people/brawly/2.4bpp"); +const u32 gMapObjectPic_Wattson_0[] = INCBIN_U32("graphics/map_objects/pics/people/wattson/0.4bpp"); +const u32 gMapObjectPic_Wattson_1[] = INCBIN_U32("graphics/map_objects/pics/people/wattson/1.4bpp"); +const u32 gMapObjectPic_Wattson_2[] = INCBIN_U32("graphics/map_objects/pics/people/wattson/2.4bpp"); +const u32 gMapObjectPic_Flannery_0[] = INCBIN_U32("graphics/map_objects/pics/people/flannery/0.4bpp"); +const u32 gMapObjectPic_Flannery_1[] = INCBIN_U32("graphics/map_objects/pics/people/flannery/1.4bpp"); +const u32 gMapObjectPic_Flannery_2[] = INCBIN_U32("graphics/map_objects/pics/people/flannery/2.4bpp"); +const u32 gMapObjectPic_Norman_0[] = INCBIN_U32("graphics/map_objects/pics/people/norman/0.4bpp"); +const u32 gMapObjectPic_Norman_1[] = INCBIN_U32("graphics/map_objects/pics/people/norman/1.4bpp"); +const u32 gMapObjectPic_Norman_2[] = INCBIN_U32("graphics/map_objects/pics/people/norman/2.4bpp"); +const u32 gMapObjectPic_Norman_3[] = INCBIN_U32("graphics/map_objects/pics/people/norman/3.4bpp"); +const u32 gMapObjectPic_Norman_4[] = INCBIN_U32("graphics/map_objects/pics/people/norman/4.4bpp"); +const u32 gMapObjectPic_Norman_5[] = INCBIN_U32("graphics/map_objects/pics/people/norman/5.4bpp"); +const u32 gMapObjectPic_Norman_6[] = INCBIN_U32("graphics/map_objects/pics/people/norman/6.4bpp"); +const u32 gMapObjectPic_Norman_7[] = INCBIN_U32("graphics/map_objects/pics/people/norman/7.4bpp"); +const u32 gMapObjectPic_Norman_8[] = INCBIN_U32("graphics/map_objects/pics/people/norman/8.4bpp"); +const u32 gMapObjectPic_Winona_0[] = INCBIN_U32("graphics/map_objects/pics/people/winona/0.4bpp"); +const u32 gMapObjectPic_Winona_1[] = INCBIN_U32("graphics/map_objects/pics/people/winona/1.4bpp"); +const u32 gMapObjectPic_Winona_2[] = INCBIN_U32("graphics/map_objects/pics/people/winona/2.4bpp"); +const u32 gMapObjectPic_Liza_0[] = INCBIN_U32("graphics/map_objects/pics/people/liza/0.4bpp"); +const u32 gMapObjectPic_Liza_1[] = INCBIN_U32("graphics/map_objects/pics/people/liza/1.4bpp"); +const u32 gMapObjectPic_Liza_2[] = INCBIN_U32("graphics/map_objects/pics/people/liza/2.4bpp"); +const u32 gMapObjectPic_Tate_0[] = INCBIN_U32("graphics/map_objects/pics/people/tate/0.4bpp"); +const u32 gMapObjectPic_Tate_1[] = INCBIN_U32("graphics/map_objects/pics/people/tate/1.4bpp"); +const u32 gMapObjectPic_Tate_2[] = INCBIN_U32("graphics/map_objects/pics/people/tate/2.4bpp"); +const u32 gMapObjectPic_Wallace_0[] = INCBIN_U32("graphics/map_objects/pics/people/wallace/0.4bpp"); +const u32 gMapObjectPic_Wallace_1[] = INCBIN_U32("graphics/map_objects/pics/people/wallace/1.4bpp"); +const u32 gMapObjectPic_Wallace_2[] = INCBIN_U32("graphics/map_objects/pics/people/wallace/2.4bpp"); +const u32 gMapObjectPic_Wallace_3[] = INCBIN_U32("graphics/map_objects/pics/people/wallace/3.4bpp"); +const u32 gMapObjectPic_Wallace_4[] = INCBIN_U32("graphics/map_objects/pics/people/wallace/4.4bpp"); +const u32 gMapObjectPic_Wallace_5[] = INCBIN_U32("graphics/map_objects/pics/people/wallace/5.4bpp"); +const u32 gMapObjectPic_Wallace_6[] = INCBIN_U32("graphics/map_objects/pics/people/wallace/6.4bpp"); +const u32 gMapObjectPic_Wallace_7[] = INCBIN_U32("graphics/map_objects/pics/people/wallace/7.4bpp"); +const u32 gMapObjectPic_Wallace_8[] = INCBIN_U32("graphics/map_objects/pics/people/wallace/8.4bpp"); +const u32 gMapObjectPic_Steven_0[] = INCBIN_U32("graphics/map_objects/pics/people/steven/0.4bpp"); +const u32 gMapObjectPic_Steven_1[] = INCBIN_U32("graphics/map_objects/pics/people/steven/1.4bpp"); +const u32 gMapObjectPic_Steven_2[] = INCBIN_U32("graphics/map_objects/pics/people/steven/2.4bpp"); +const u32 gMapObjectPic_Steven_3[] = INCBIN_U32("graphics/map_objects/pics/people/steven/3.4bpp"); +const u32 gMapObjectPic_Steven_4[] = INCBIN_U32("graphics/map_objects/pics/people/steven/4.4bpp"); +const u32 gMapObjectPic_Steven_5[] = INCBIN_U32("graphics/map_objects/pics/people/steven/5.4bpp"); +const u32 gMapObjectPic_Steven_6[] = INCBIN_U32("graphics/map_objects/pics/people/steven/6.4bpp"); +const u32 gMapObjectPic_Steven_7[] = INCBIN_U32("graphics/map_objects/pics/people/steven/7.4bpp"); +const u32 gMapObjectPic_Steven_8[] = INCBIN_U32("graphics/map_objects/pics/people/steven/8.4bpp"); +const u32 gMapObjectPic_Wally_0[] = INCBIN_U32("graphics/map_objects/pics/people/wally/0.4bpp"); +const u32 gMapObjectPic_Wally_1[] = INCBIN_U32("graphics/map_objects/pics/people/wally/1.4bpp"); +const u32 gMapObjectPic_Wally_2[] = INCBIN_U32("graphics/map_objects/pics/people/wally/2.4bpp"); +const u32 gMapObjectPic_Wally_3[] = INCBIN_U32("graphics/map_objects/pics/people/wally/3.4bpp"); +const u32 gMapObjectPic_Wally_4[] = INCBIN_U32("graphics/map_objects/pics/people/wally/4.4bpp"); +const u32 gMapObjectPic_Wally_5[] = INCBIN_U32("graphics/map_objects/pics/people/wally/5.4bpp"); +const u32 gMapObjectPic_Wally_6[] = INCBIN_U32("graphics/map_objects/pics/people/wally/6.4bpp"); +const u32 gMapObjectPic_Wally_7[] = INCBIN_U32("graphics/map_objects/pics/people/wally/7.4bpp"); +const u32 gMapObjectPic_Wally_8[] = INCBIN_U32("graphics/map_objects/pics/people/wally/8.4bpp"); +const u32 gMapObjectPic_LittleBoy3_0[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_3/0.4bpp"); +const u32 gMapObjectPic_LittleBoy3_1[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_3/1.4bpp"); +const u32 gMapObjectPic_LittleBoy3_2[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_3/2.4bpp"); +const u32 gMapObjectPic_LittleBoy3_3[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_3/3.4bpp"); +const u32 gMapObjectPic_LittleBoy3_4[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_3/4.4bpp"); +const u32 gMapObjectPic_LittleBoy3_5[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_3/5.4bpp"); +const u32 gMapObjectPic_LittleBoy3_6[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_3/6.4bpp"); +const u32 gMapObjectPic_LittleBoy3_7[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_3/7.4bpp"); +const u32 gMapObjectPic_LittleBoy3_8[] = INCBIN_U32("graphics/map_objects/pics/people/little_boy_3/8.4bpp"); +const u32 gMapObjectPic_HotSpringsOldWoman_0[] = INCBIN_U32("graphics/map_objects/pics/people/hot_springs_old_woman/0.4bpp"); +const u32 gMapObjectPic_HotSpringsOldWoman_1[] = INCBIN_U32("graphics/map_objects/pics/people/hot_springs_old_woman/1.4bpp"); +const u32 gMapObjectPic_HotSpringsOldWoman_2[] = INCBIN_U32("graphics/map_objects/pics/people/hot_springs_old_woman/2.4bpp"); +const u32 gMapObjectPic_HotSpringsOldWoman_3[] = INCBIN_U32("graphics/map_objects/pics/people/hot_springs_old_woman/3.4bpp"); +const u32 gMapObjectPic_HotSpringsOldWoman_4[] = INCBIN_U32("graphics/map_objects/pics/people/hot_springs_old_woman/4.4bpp"); +const u32 gMapObjectPic_HotSpringsOldWoman_5[] = INCBIN_U32("graphics/map_objects/pics/people/hot_springs_old_woman/5.4bpp"); +const u32 gMapObjectPic_HotSpringsOldWoman_6[] = INCBIN_U32("graphics/map_objects/pics/people/hot_springs_old_woman/6.4bpp"); +const u32 gMapObjectPic_HotSpringsOldWoman_7[] = INCBIN_U32("graphics/map_objects/pics/people/hot_springs_old_woman/7.4bpp"); +const u32 gMapObjectPic_HotSpringsOldWoman_8[] = INCBIN_U32("graphics/map_objects/pics/people/hot_springs_old_woman/8.4bpp"); +const u32 gMapObjectPic_LatiasLatios_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/latias_latios/0.4bpp"); +const u32 gMapObjectPic_LatiasLatios_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/latias_latios/1.4bpp"); +const u32 gMapObjectPic_LatiasLatios_2[] = INCBIN_U32("graphics/map_objects/pics/pokemon/latias_latios/2.4bpp"); +const u32 gMapObjectPic_Boy5_0[] = INCBIN_U32("graphics/map_objects/pics/people/boy_5/0.4bpp"); +const u32 gMapObjectPic_Boy5_1[] = INCBIN_U32("graphics/map_objects/pics/people/boy_5/1.4bpp"); +const u32 gMapObjectPic_Boy5_2[] = INCBIN_U32("graphics/map_objects/pics/people/boy_5/2.4bpp"); +const u32 gMapObjectPic_ContestJudge_0[] = INCBIN_U32("graphics/map_objects/pics/people/contest_judge/0.4bpp"); +const u32 gMapObjectPic_ContestJudge_1[] = INCBIN_U32("graphics/map_objects/pics/people/contest_judge/1.4bpp"); +const u32 gMapObjectPic_ContestJudge_2[] = INCBIN_U32("graphics/map_objects/pics/people/contest_judge/2.4bpp"); +const u32 gMapObjectPic_ContestJudge_3[] = INCBIN_U32("graphics/map_objects/pics/people/contest_judge/3.4bpp"); +const u32 gMapObjectPic_ContestJudge_4[] = INCBIN_U32("graphics/map_objects/pics/people/contest_judge/4.4bpp"); +const u32 gMapObjectPic_ContestJudge_5[] = INCBIN_U32("graphics/map_objects/pics/people/contest_judge/5.4bpp"); +const u32 gMapObjectPic_ContestJudge_6[] = INCBIN_U32("graphics/map_objects/pics/people/contest_judge/6.4bpp"); +const u32 gMapObjectPic_ContestJudge_7[] = INCBIN_U32("graphics/map_objects/pics/people/contest_judge/7.4bpp"); +const u32 gMapObjectPic_ContestJudge_8[] = INCBIN_U32("graphics/map_objects/pics/people/contest_judge/8.4bpp"); +const u32 gMapObjectPic_Archie_0[] = INCBIN_U32("graphics/map_objects/pics/people/archie/0.4bpp"); +const u32 gMapObjectPic_Archie_1[] = INCBIN_U32("graphics/map_objects/pics/people/archie/1.4bpp"); +const u32 gMapObjectPic_Archie_2[] = INCBIN_U32("graphics/map_objects/pics/people/archie/2.4bpp"); +const u32 gMapObjectPic_Archie_3[] = INCBIN_U32("graphics/map_objects/pics/people/archie/3.4bpp"); +const u32 gMapObjectPic_Archie_4[] = INCBIN_U32("graphics/map_objects/pics/people/archie/4.4bpp"); +const u32 gMapObjectPic_Archie_5[] = INCBIN_U32("graphics/map_objects/pics/people/archie/5.4bpp"); +const u32 gMapObjectPic_Archie_6[] = INCBIN_U32("graphics/map_objects/pics/people/archie/6.4bpp"); +const u32 gMapObjectPic_Archie_7[] = INCBIN_U32("graphics/map_objects/pics/people/archie/7.4bpp"); +const u32 gMapObjectPic_Archie_8[] = INCBIN_U32("graphics/map_objects/pics/people/archie/8.4bpp"); +const u32 gMapObjectPic_Maxie_0[] = INCBIN_U32("graphics/map_objects/pics/people/maxie/0.4bpp"); +const u32 gMapObjectPic_Maxie_1[] = INCBIN_U32("graphics/map_objects/pics/people/maxie/1.4bpp"); +const u32 gMapObjectPic_Maxie_2[] = INCBIN_U32("graphics/map_objects/pics/people/maxie/2.4bpp"); +const u32 gMapObjectPic_Maxie_3[] = INCBIN_U32("graphics/map_objects/pics/people/maxie/3.4bpp"); +const u32 gMapObjectPic_Maxie_4[] = INCBIN_U32("graphics/map_objects/pics/people/maxie/4.4bpp"); +const u32 gMapObjectPic_Maxie_5[] = INCBIN_U32("graphics/map_objects/pics/people/maxie/5.4bpp"); +const u32 gMapObjectPic_Maxie_6[] = INCBIN_U32("graphics/map_objects/pics/people/maxie/6.4bpp"); +const u32 gMapObjectPic_Maxie_7[] = INCBIN_U32("graphics/map_objects/pics/people/maxie/7.4bpp"); +const u32 gMapObjectPic_Maxie_8[] = INCBIN_U32("graphics/map_objects/pics/people/maxie/8.4bpp"); +const u32 gMapObjectPic_Kyogre_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/kyogre/0.4bpp"); +const u32 gMapObjectPic_Kyogre_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/kyogre/1.4bpp"); +const u32 gMapObjectPic_Groudon_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/groudon/0.4bpp"); +const u32 gMapObjectPic_Groudon_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/groudon/1.4bpp"); +const u32 gMapObjectPic_Regi[] = INCBIN_U32("graphics/map_objects/pics/pokemon/regi.4bpp"); +const u32 gMapObjectPic_Skitty_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/skitty/0.4bpp"); +const u32 gMapObjectPic_Skitty_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/skitty/1.4bpp"); +const u32 gMapObjectPic_Skitty_2[] = INCBIN_U32("graphics/map_objects/pics/pokemon/skitty/2.4bpp"); +const u32 gMapObjectPic_Kecleon_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/kecleon/0.4bpp"); +const u32 gMapObjectPic_Kecleon_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/kecleon/1.4bpp"); +const u32 gMapObjectPic_Kecleon_2[] = INCBIN_U32("graphics/map_objects/pics/pokemon/kecleon/2.4bpp"); +const u32 gMapObjectPic_Rayquaza_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/rayquaza/0.4bpp"); +const u32 gMapObjectPic_Rayquaza_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/rayquaza/1.4bpp"); +const u32 gMapObjectPic_Zigzagoon_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/zigzagoon/0.4bpp"); +const u32 gMapObjectPic_Zigzagoon_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/zigzagoon/1.4bpp"); +const u32 gMapObjectPic_Zigzagoon_2[] = INCBIN_U32("graphics/map_objects/pics/pokemon/zigzagoon/2.4bpp"); +const u32 gMapObjectPic_Pikachu_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/pikachu/0.4bpp"); +const u32 gMapObjectPic_Pikachu_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/pikachu/1.4bpp"); +const u32 gMapObjectPic_Pikachu_2[] = INCBIN_U32("graphics/map_objects/pics/pokemon/pikachu/2.4bpp"); +const u32 gMapObjectPic_Azumarill_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/azumarill/0.4bpp"); +const u32 gMapObjectPic_Azumarill_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/azumarill/1.4bpp"); +const u32 gMapObjectPic_Azumarill_2[] = INCBIN_U32("graphics/map_objects/pics/pokemon/azumarill/2.4bpp"); +const u32 gMapObjectPic_Wingull_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/wingull/0.4bpp"); +const u32 gMapObjectPic_Wingull_3[] = INCBIN_U32("graphics/map_objects/pics/pokemon/wingull/3.4bpp"); +const u32 gMapObjectPic_Wingull_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/wingull/1.4bpp"); +const u32 gMapObjectPic_Wingull_4[] = INCBIN_U32("graphics/map_objects/pics/pokemon/wingull/4.4bpp"); +const u32 gMapObjectPic_Wingull_2[] = INCBIN_U32("graphics/map_objects/pics/pokemon/wingull/2.4bpp"); +const u32 gMapObjectPic_Wingull_5[] = INCBIN_U32("graphics/map_objects/pics/pokemon/wingull/5.4bpp"); +const u32 gMapObjectPic_TuberMSwimming_0[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m_swimming/0.4bpp"); +const u32 gMapObjectPic_TuberMSwimming_1[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m_swimming/1.4bpp"); +const u32 gMapObjectPic_TuberMSwimming_2[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m_swimming/2.4bpp"); +const u32 gMapObjectPic_TuberMSwimming_3[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m_swimming/3.4bpp"); +const u32 gMapObjectPic_TuberMSwimming_4[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m_swimming/4.4bpp"); +const u32 gMapObjectPic_TuberMSwimming_5[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m_swimming/5.4bpp"); +const u32 gMapObjectPic_TuberMSwimming_6[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m_swimming/6.4bpp"); +const u32 gMapObjectPic_TuberMSwimming_7[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m_swimming/7.4bpp"); +const u32 gMapObjectPic_TuberMSwimming_8[] = INCBIN_U32("graphics/map_objects/pics/people/tuber_m_swimming/8.4bpp"); +const u32 gMapObjectPic_Azurill_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/azurill/0.4bpp"); +const u32 gMapObjectPic_Azurill_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/azurill/1.4bpp"); +const u32 gMapObjectPic_Azurill_2[] = INCBIN_U32("graphics/map_objects/pics/pokemon/azurill/2.4bpp"); +const u32 gMapObjectPic_Mom_0[] = INCBIN_U32("graphics/map_objects/pics/people/mom/0.4bpp"); +const u32 gMapObjectPic_Mom_1[] = INCBIN_U32("graphics/map_objects/pics/people/mom/1.4bpp"); +const u32 gMapObjectPic_Mom_2[] = INCBIN_U32("graphics/map_objects/pics/people/mom/2.4bpp"); +const u32 gMapObjectPic_Mom_3[] = INCBIN_U32("graphics/map_objects/pics/people/mom/3.4bpp"); +const u32 gMapObjectPic_Mom_4[] = INCBIN_U32("graphics/map_objects/pics/people/mom/4.4bpp"); +const u32 gMapObjectPic_Mom_5[] = INCBIN_U32("graphics/map_objects/pics/people/mom/5.4bpp"); +const u32 gMapObjectPic_Mom_6[] = INCBIN_U32("graphics/map_objects/pics/people/mom/6.4bpp"); +const u32 gMapObjectPic_Mom_7[] = INCBIN_U32("graphics/map_objects/pics/people/mom/7.4bpp"); +const u32 gMapObjectPic_Mom_8[] = INCBIN_U32("graphics/map_objects/pics/people/mom/8.4bpp"); +const u16 gMapObjectPalette22[] = INCBIN_U16("graphics/map_objects/palettes/22.gbapal"); +const u16 gMapObjectPalette23[] = INCBIN_U16("graphics/map_objects/palettes/23.gbapal"); +const u16 gMapObjectPalette24[] = INCBIN_U16("graphics/map_objects/palettes/24.gbapal"); +const u16 gMapObjectPalette25[] = INCBIN_U16("graphics/map_objects/palettes/25.gbapal"); +const u32 gMapObjectPic_UnusedNatuDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/unused_natu_doll.4bpp"); +const u32 gMapObjectPic_UnusedMagnemiteDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/unused_magnemite_doll.4bpp"); +const u32 gMapObjectPic_UnusedSquirtleDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/unused_squirtle_doll.4bpp"); +const u32 gMapObjectPic_UnusedWooperDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/unused_wooper_doll.4bpp"); +const u32 gMapObjectPic_UnusedPikachuDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/unused_pikachu_doll.4bpp"); +const u32 gMapObjectPic_UnusedPorygon2Doll[] = INCBIN_U32("graphics/map_objects/pics/dolls/unused_porygon2_doll.4bpp"); +const u32 gMapObjectPic_PichuDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/pichu_doll.4bpp"); +const u32 gMapObjectPic_PikachuDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/pikachu_doll.4bpp"); +const u32 gMapObjectPic_MarillDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/marill_doll.4bpp"); +const u32 gMapObjectPic_TogepiDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/togepi_doll.4bpp"); +const u32 gMapObjectPic_CyndaquilDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/cyndaquil_doll.4bpp"); +const u32 gMapObjectPic_ChikoritaDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/chikorita_doll.4bpp"); +const u32 gMapObjectPic_TotodileDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/totodile_doll.4bpp"); +const u32 gMapObjectPic_JigglypuffDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/jigglypuff_doll.4bpp"); +const u32 gMapObjectPic_MeowthDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/meowth_doll.4bpp"); +const u32 gMapObjectPic_ClefairyDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/clefairy_doll.4bpp"); +const u32 gMapObjectPic_DittoDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/ditto_doll.4bpp"); +const u32 gMapObjectPic_SmoochumDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/smoochum_doll.4bpp"); +const u32 gMapObjectPic_TreeckoDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/treecko_doll.4bpp"); +const u32 gMapObjectPic_TorchicDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/torchic_doll.4bpp"); +const u32 gMapObjectPic_MudkipDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/mudkip_doll.4bpp"); +const u32 gMapObjectPic_DuskullDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/duskull_doll.4bpp"); +const u32 gMapObjectPic_WynautDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/wynaut_doll.4bpp"); +const u32 gMapObjectPic_BaltoyDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/baltoy_doll.4bpp"); +const u32 gMapObjectPic_KecleonDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/kecleon_doll.4bpp"); +const u32 gMapObjectPic_AzurillDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/azurill_doll.4bpp"); +const u32 gMapObjectPic_SkittyDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/skitty_doll.4bpp"); +const u32 gMapObjectPic_SwabluDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/swablu_doll.4bpp"); +const u32 gMapObjectPic_GulpinDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/gulpin_doll.4bpp"); +const u32 gMapObjectPic_LotadDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/lotad_doll.4bpp"); +const u32 gMapObjectPic_SeedotDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/seedot_doll.4bpp"); +const u32 gMapObjectPic_PikaCushion[] = INCBIN_U32("graphics/map_objects/pics/cushions/pika_cushion.4bpp"); +const u32 gMapObjectPic_RoundCushion[] = INCBIN_U32("graphics/map_objects/pics/cushions/round_cushion.4bpp"); +const u32 gMapObjectPic_KissCushion[] = INCBIN_U32("graphics/map_objects/pics/cushions/kiss_cushion.4bpp"); +const u32 gMapObjectPic_ZigzagCushion[] = INCBIN_U32("graphics/map_objects/pics/cushions/zigzag_cushion.4bpp"); +const u32 gMapObjectPic_SpinCushion[] = INCBIN_U32("graphics/map_objects/pics/cushions/spin_cushion.4bpp"); +const u32 gMapObjectPic_DiamondCushion[] = INCBIN_U32("graphics/map_objects/pics/cushions/diamond_cushion.4bpp"); +const u32 gMapObjectPic_BallCushion[] = INCBIN_U32("graphics/map_objects/pics/cushions/ball_cushion.4bpp"); +const u32 gMapObjectPic_GrassCushion[] = INCBIN_U32("graphics/map_objects/pics/cushions/grass_cushion.4bpp"); +const u32 gMapObjectPic_FireCushion[] = INCBIN_U32("graphics/map_objects/pics/cushions/fire_cushion.4bpp"); +const u32 gMapObjectPic_WaterCushion[] = INCBIN_U32("graphics/map_objects/pics/cushions/water_cushion.4bpp"); +const u32 gMapObjectPic_BigSnorlaxDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/big_snorlax_doll.4bpp"); +const u32 gMapObjectPic_BigRhydonDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/big_rhydon_doll.4bpp"); +const u32 gMapObjectPic_BigLaprasDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/big_lapras_doll.4bpp"); +const u32 gMapObjectPic_BigVenusaurDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/big_venusaur_doll.4bpp"); +const u32 gMapObjectPic_BigCharizardDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/big_charizard_doll.4bpp"); +const u32 gMapObjectPic_BigBlastoiseDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/big_blastoise_doll.4bpp"); +const u32 gMapObjectPic_BigWailmerDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/big_wailmer_doll.4bpp"); +const u32 gMapObjectPic_BigRegirockDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/big_regirock_doll.4bpp"); +const u32 gMapObjectPic_BigRegiceDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/big_regice_doll.4bpp"); +const u32 gMapObjectPic_BigRegisteelDoll[] = INCBIN_U32("graphics/map_objects/pics/dolls/big_registeel_doll.4bpp"); +const u32 gMapObjectPic_CuttableTree_0[] = INCBIN_U32("graphics/map_objects/pics/misc/cuttable_tree/0.4bpp"); +const u32 gMapObjectPic_CuttableTree_1[] = INCBIN_U32("graphics/map_objects/pics/misc/cuttable_tree/1.4bpp"); +const u32 gMapObjectPic_CuttableTree_2[] = INCBIN_U32("graphics/map_objects/pics/misc/cuttable_tree/2.4bpp"); +const u32 gMapObjectPic_CuttableTree_3[] = INCBIN_U32("graphics/map_objects/pics/misc/cuttable_tree/3.4bpp"); +const u32 gMapObjectPic_BreakableRock_0[] = INCBIN_U32("graphics/map_objects/pics/misc/breakable_rock/0.4bpp"); +const u32 gMapObjectPic_BreakableRock_1[] = INCBIN_U32("graphics/map_objects/pics/misc/breakable_rock/1.4bpp"); +const u32 gMapObjectPic_BreakableRock_2[] = INCBIN_U32("graphics/map_objects/pics/misc/breakable_rock/2.4bpp"); +const u32 gMapObjectPic_BreakableRock_3[] = INCBIN_U32("graphics/map_objects/pics/misc/breakable_rock/3.4bpp"); +const u32 gMapObjectPic_PushableBoulder[] = INCBIN_U32("graphics/map_objects/pics/misc/pushable_boulder.4bpp"); +const u32 gMapObjectPic_MrBrineysBoat_0[] = INCBIN_U32("graphics/map_objects/pics/misc/mr_brineys_boat/0.4bpp"); +const u32 gMapObjectPic_MrBrineysBoat_1[] = INCBIN_U32("graphics/map_objects/pics/misc/mr_brineys_boat/1.4bpp"); +const u32 gMapObjectPic_MrBrineysBoat_2[] = INCBIN_U32("graphics/map_objects/pics/misc/mr_brineys_boat/2.4bpp"); +const u32 gMapObjectPic_Fossil[] = INCBIN_U32("graphics/map_objects/pics/misc/fossil.4bpp"); +const u32 gMapObjectPic_SubmarineShadow[] = INCBIN_U32("graphics/map_objects/pics/misc/submarine_shadow.4bpp"); +const u16 gMapObjectPalette26[] = INCBIN_U16("graphics/map_objects/palettes/26.gbapal"); +const u32 gMapObjectPic_Truck[] = INCBIN_U32("graphics/map_objects/pics/misc/truck.4bpp"); +const u16 gMapObjectPalette14[] = INCBIN_U16("graphics/map_objects/palettes/14.gbapal"); +const u32 gMapObjectPic_MachokeCarryingBox_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/machoke_carrying_box/0.4bpp"); +const u32 gMapObjectPic_MachokeCarryingBox_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/machoke_carrying_box/1.4bpp"); +const u32 gMapObjectPic_MachokeCarryingBox_2[] = INCBIN_U32("graphics/map_objects/pics/pokemon/machoke_carrying_box/2.4bpp"); +const u32 gMapObjectPic_MachokeFacingAway_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/machoke_facing_away/0.4bpp"); +const u32 gMapObjectPic_MachokeFacingAway_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/machoke_facing_away/1.4bpp"); +const u16 gMapObjectPalette15[] = INCBIN_U16("graphics/map_objects/palettes/15.gbapal"); +const u32 gMapObjectPic_BirchsBag[] = INCBIN_U32("graphics/map_objects/pics/misc/birchs_bag.4bpp"); +const u32 gMapObjectPic_Poochyena_0[] = INCBIN_U32("graphics/map_objects/pics/pokemon/poochyena/0.4bpp"); +const u32 gMapObjectPic_Poochyena_1[] = INCBIN_U32("graphics/map_objects/pics/pokemon/poochyena/1.4bpp"); +const u32 gMapObjectPic_Poochyena_2[] = INCBIN_U32("graphics/map_objects/pics/pokemon/poochyena/2.4bpp"); +const u32 gMapObjectPic_Poochyena_3[] = INCBIN_U32("graphics/map_objects/pics/pokemon/poochyena/3.4bpp"); +const u32 gMapObjectPic_Poochyena_4[] = INCBIN_U32("graphics/map_objects/pics/pokemon/poochyena/4.4bpp"); +const u32 gMapObjectPic_Poochyena_5[] = INCBIN_U32("graphics/map_objects/pics/pokemon/poochyena/5.4bpp"); +const u32 gMapObjectPic_Poochyena_6[] = INCBIN_U32("graphics/map_objects/pics/pokemon/poochyena/6.4bpp"); +const u32 gMapObjectPic_Poochyena_7[] = INCBIN_U32("graphics/map_objects/pics/pokemon/poochyena/7.4bpp"); +const u32 gMapObjectPic_Poochyena_8[] = INCBIN_U32("graphics/map_objects/pics/pokemon/poochyena/8.4bpp"); +const u16 gMapObjectPalette16[] = INCBIN_U16("graphics/map_objects/palettes/16.gbapal"); +const u32 gMapObjectPic_CableCar[] = INCBIN_U32("graphics/map_objects/pics/misc/cable_car.4bpp"); +const u16 gMapObjectPalette20[] = INCBIN_U16("graphics/map_objects/palettes/20.gbapal"); +const u32 gMapObjectPic_SSTidal[] = INCBIN_U32("graphics/map_objects/pics/misc/ss_tidal.4bpp"); +const u16 gMapObjectPalette21[] = INCBIN_U16("graphics/map_objects/palettes/21.gbapal"); +const u32 gFieldEffectPic_BerryTreeGrowthSparkle_0[] = INCBIN_U32("graphics/field_effect_objects/pics/berry_tree_growth_sparkle/0.4bpp"); +const u32 gFieldEffectPic_BerryTreeGrowthSparkle_1[] = INCBIN_U32("graphics/field_effect_objects/pics/berry_tree_growth_sparkle/1.4bpp"); +const u32 gFieldEffectPic_BerryTreeGrowthSparkle_2[] = INCBIN_U32("graphics/field_effect_objects/pics/berry_tree_growth_sparkle/2.4bpp"); +const u32 gFieldEffectPic_BerryTreeGrowthSparkle_3[] = INCBIN_U32("graphics/field_effect_objects/pics/berry_tree_growth_sparkle/3.4bpp"); +const u32 gFieldEffectPic_BerryTreeGrowthSparkle_4[] = INCBIN_U32("graphics/field_effect_objects/pics/berry_tree_growth_sparkle/4.4bpp"); +const u32 gFieldEffectPic_BerryTreeGrowthSparkle_5[] = INCBIN_U32("graphics/field_effect_objects/pics/berry_tree_growth_sparkle/5.4bpp"); +const u32 gMapObjectPic_BerryTreeDirtPile[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/dirt_pile.4bpp"); +const u32 gMapObjectPic_BerryTreeSprout_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/sprout/0.4bpp"); +const u32 gMapObjectPic_BerryTreeSprout_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/sprout/1.4bpp"); +const u32 gMapObjectPic_PechaBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pecha/0.4bpp"); +const u32 gMapObjectPic_PechaBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pecha/1.4bpp"); +const u32 gMapObjectPic_PechaBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pecha/2.4bpp"); +const u32 gMapObjectPic_PechaBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pecha/3.4bpp"); +const u32 gMapObjectPic_PechaBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pecha/4.4bpp"); +const u32 gMapObjectPic_PechaBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pecha/5.4bpp"); +const u32 gMapObjectPic_KelpsyBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/kelpsy/0.4bpp"); +const u32 gMapObjectPic_KelpsyBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/kelpsy/1.4bpp"); +const u32 gMapObjectPic_KelpsyBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/kelpsy/2.4bpp"); +const u32 gMapObjectPic_KelpsyBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/kelpsy/3.4bpp"); +const u32 gMapObjectPic_KelpsyBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/kelpsy/4.4bpp"); +const u32 gMapObjectPic_KelpsyBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/kelpsy/5.4bpp"); +const u32 gMapObjectPic_WepearBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wepear/0.4bpp"); +const u32 gMapObjectPic_WepearBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wepear/1.4bpp"); +const u32 gMapObjectPic_WepearBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wepear/2.4bpp"); +const u32 gMapObjectPic_WepearBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wepear/3.4bpp"); +const u32 gMapObjectPic_WepearBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wepear/4.4bpp"); +const u32 gMapObjectPic_WepearBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wepear/5.4bpp"); +const u32 gMapObjectPic_IapapaBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/iapapa/0.4bpp"); +const u32 gMapObjectPic_IapapaBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/iapapa/1.4bpp"); +const u32 gMapObjectPic_IapapaBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/iapapa/2.4bpp"); +const u32 gMapObjectPic_IapapaBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/iapapa/3.4bpp"); +const u32 gMapObjectPic_IapapaBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/iapapa/4.4bpp"); +const u32 gMapObjectPic_IapapaBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/iapapa/5.4bpp"); +const u32 gMapObjectPic_CheriBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cheri/0.4bpp"); +const u32 gMapObjectPic_CheriBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cheri/1.4bpp"); +const u32 gMapObjectPic_CheriBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cheri/2.4bpp"); +const u32 gMapObjectPic_CheriBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cheri/3.4bpp"); +const u32 gMapObjectPic_CheriBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cheri/4.4bpp"); +const u32 gMapObjectPic_CheriBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cheri/5.4bpp"); +const u32 gMapObjectPic_FigyBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/figy/0.4bpp"); +const u32 gMapObjectPic_FigyBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/figy/1.4bpp"); +const u32 gMapObjectPic_FigyBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/figy/2.4bpp"); +const u32 gMapObjectPic_FigyBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/figy/3.4bpp"); +const u32 gMapObjectPic_FigyBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/figy/4.4bpp"); +const u32 gMapObjectPic_FigyBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/figy/5.4bpp"); +const u32 gMapObjectPic_MagoBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/mago/0.4bpp"); +const u32 gMapObjectPic_MagoBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/mago/1.4bpp"); +const u32 gMapObjectPic_MagoBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/mago/2.4bpp"); +const u32 gMapObjectPic_MagoBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/mago/3.4bpp"); +const u32 gMapObjectPic_MagoBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/mago/4.4bpp"); +const u32 gMapObjectPic_MagoBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/mago/5.4bpp"); +const u32 gMapObjectPic_LumBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lum/0.4bpp"); +const u32 gMapObjectPic_LumBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lum/1.4bpp"); +const u32 gMapObjectPic_LumBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lum/2.4bpp"); +const u32 gMapObjectPic_LumBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lum/3.4bpp"); +const u32 gMapObjectPic_LumBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lum/4.4bpp"); +const u32 gMapObjectPic_LumBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lum/5.4bpp"); +const u32 gMapObjectPic_RazzBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/razz/0.4bpp"); +const u32 gMapObjectPic_RazzBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/razz/1.4bpp"); +const u32 gMapObjectPic_RazzBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/razz/2.4bpp"); +const u32 gMapObjectPic_RazzBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/razz/3.4bpp"); +const u32 gMapObjectPic_RazzBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/razz/4.4bpp"); +const u32 gMapObjectPic_RazzBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/razz/5.4bpp"); +const u32 gMapObjectPic_GrepaBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/grepa/0.4bpp"); +const u32 gMapObjectPic_GrepaBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/grepa/1.4bpp"); +const u32 gMapObjectPic_GrepaBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/grepa/2.4bpp"); +const u32 gMapObjectPic_GrepaBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/grepa/3.4bpp"); +const u32 gMapObjectPic_GrepaBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/grepa/4.4bpp"); +const u32 gMapObjectPic_GrepaBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/grepa/5.4bpp"); +const u32 gMapObjectPic_RabutaBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rabuta/0.4bpp"); +const u32 gMapObjectPic_RabutaBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rabuta/1.4bpp"); +const u32 gMapObjectPic_RabutaBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rabuta/2.4bpp"); +const u32 gMapObjectPic_RabutaBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rabuta/3.4bpp"); +const u32 gMapObjectPic_RabutaBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rabuta/4.4bpp"); +const u32 gMapObjectPic_RabutaBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rabuta/5.4bpp"); +const u32 gMapObjectPic_NomelBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/nomel/0.4bpp"); +const u32 gMapObjectPic_NomelBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/nomel/1.4bpp"); +const u32 gMapObjectPic_NomelBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/nomel/2.4bpp"); +const u32 gMapObjectPic_NomelBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/nomel/3.4bpp"); +const u32 gMapObjectPic_NomelBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/nomel/4.4bpp"); +const u32 gMapObjectPic_NomelBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/nomel/5.4bpp"); +const u32 gMapObjectPic_LeppaBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/leppa/0.4bpp"); +const u32 gMapObjectPic_LeppaBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/leppa/1.4bpp"); +const u32 gMapObjectPic_LeppaBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/leppa/2.4bpp"); +const u32 gMapObjectPic_LeppaBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/leppa/3.4bpp"); +const u32 gMapObjectPic_LeppaBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/leppa/4.4bpp"); +const u32 gMapObjectPic_LeppaBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/leppa/5.4bpp"); +const u32 gMapObjectPic_LiechiBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/liechi/0.4bpp"); +const u32 gMapObjectPic_LiechiBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/liechi/1.4bpp"); +const u32 gMapObjectPic_LiechiBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/liechi/2.4bpp"); +const u32 gMapObjectPic_LiechiBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/liechi/3.4bpp"); +const u32 gMapObjectPic_LiechiBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/liechi/4.4bpp"); +const u32 gMapObjectPic_LiechiBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/liechi/5.4bpp"); +const u32 gMapObjectPic_HondewBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/hondew/0.4bpp"); +const u32 gMapObjectPic_HondewBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/hondew/1.4bpp"); +const u32 gMapObjectPic_HondewBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/hondew/2.4bpp"); +const u32 gMapObjectPic_HondewBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/hondew/3.4bpp"); +const u32 gMapObjectPic_HondewBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/hondew/4.4bpp"); +const u32 gMapObjectPic_HondewBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/hondew/5.4bpp"); +const u32 gMapObjectPic_AguavBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aguav/0.4bpp"); +const u32 gMapObjectPic_AguavBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aguav/1.4bpp"); +const u32 gMapObjectPic_AguavBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aguav/2.4bpp"); +const u32 gMapObjectPic_AguavBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aguav/3.4bpp"); +const u32 gMapObjectPic_AguavBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aguav/4.4bpp"); +const u32 gMapObjectPic_AguavBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aguav/5.4bpp"); +const u32 gMapObjectPic_WikiBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wiki/0.4bpp"); +const u32 gMapObjectPic_WikiBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wiki/1.4bpp"); +const u32 gMapObjectPic_WikiBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wiki/2.4bpp"); +const u32 gMapObjectPic_WikiBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wiki/3.4bpp"); +const u32 gMapObjectPic_WikiBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wiki/4.4bpp"); +const u32 gMapObjectPic_WikiBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/wiki/5.4bpp"); +const u32 gMapObjectPic_PomegBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pomeg/0.4bpp"); +const u32 gMapObjectPic_PomegBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pomeg/1.4bpp"); +const u32 gMapObjectPic_PomegBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pomeg/2.4bpp"); +const u32 gMapObjectPic_PomegBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pomeg/3.4bpp"); +const u32 gMapObjectPic_PomegBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pomeg/4.4bpp"); +const u32 gMapObjectPic_PomegBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pomeg/5.4bpp"); +const u32 gMapObjectPic_RawstBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rawst/0.4bpp"); +const u32 gMapObjectPic_RawstBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rawst/1.4bpp"); +const u32 gMapObjectPic_RawstBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rawst/2.4bpp"); +const u32 gMapObjectPic_RawstBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rawst/3.4bpp"); +const u32 gMapObjectPic_RawstBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rawst/4.4bpp"); +const u32 gMapObjectPic_RawstBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/rawst/5.4bpp"); +const u32 gMapObjectPic_SpelonBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/spelon/0.4bpp"); +const u32 gMapObjectPic_SpelonBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/spelon/1.4bpp"); +const u32 gMapObjectPic_SpelonBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/spelon/2.4bpp"); +const u32 gMapObjectPic_SpelonBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/spelon/3.4bpp"); +const u32 gMapObjectPic_SpelonBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/spelon/4.4bpp"); +const u32 gMapObjectPic_SpelonBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/spelon/5.4bpp"); +const u32 gMapObjectPic_ChestoBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/chesto/0.4bpp"); +const u32 gMapObjectPic_ChestoBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/chesto/1.4bpp"); +const u32 gMapObjectPic_ChestoBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/chesto/2.4bpp"); +const u32 gMapObjectPic_ChestoBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/chesto/3.4bpp"); +const u32 gMapObjectPic_ChestoBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/chesto/4.4bpp"); +const u32 gMapObjectPic_ChestoBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/chesto/5.4bpp"); +const u32 gMapObjectPic_OranBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/oran/0.4bpp"); +const u32 gMapObjectPic_OranBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/oran/1.4bpp"); +const u32 gMapObjectPic_OranBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/oran/2.4bpp"); +const u32 gMapObjectPic_OranBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/oran/3.4bpp"); +const u32 gMapObjectPic_OranBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/oran/4.4bpp"); +const u32 gMapObjectPic_OranBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/oran/5.4bpp"); +const u32 gMapObjectPic_PersimBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/persim/0.4bpp"); +const u32 gMapObjectPic_PersimBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/persim/1.4bpp"); +const u32 gMapObjectPic_PersimBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/persim/2.4bpp"); +const u32 gMapObjectPic_PersimBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/persim/3.4bpp"); +const u32 gMapObjectPic_PersimBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/persim/4.4bpp"); +const u32 gMapObjectPic_PersimBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/persim/5.4bpp"); +const u32 gMapObjectPic_SitrusBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/sitrus/0.4bpp"); +const u32 gMapObjectPic_SitrusBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/sitrus/1.4bpp"); +const u32 gMapObjectPic_SitrusBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/sitrus/2.4bpp"); +const u32 gMapObjectPic_SitrusBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/sitrus/3.4bpp"); +const u32 gMapObjectPic_SitrusBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/sitrus/4.4bpp"); +const u32 gMapObjectPic_SitrusBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/sitrus/5.4bpp"); +const u32 gMapObjectPic_AspearBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aspear/0.4bpp"); +const u32 gMapObjectPic_AspearBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aspear/1.4bpp"); +const u32 gMapObjectPic_AspearBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aspear/2.4bpp"); +const u32 gMapObjectPic_AspearBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aspear/3.4bpp"); +const u32 gMapObjectPic_AspearBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aspear/4.4bpp"); +const u32 gMapObjectPic_AspearBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/aspear/5.4bpp"); +const u32 gMapObjectPic_PamtreBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pamtre/0.4bpp"); +const u32 gMapObjectPic_PamtreBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pamtre/1.4bpp"); +const u32 gMapObjectPic_PamtreBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pamtre/2.4bpp"); +const u32 gMapObjectPic_PamtreBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pamtre/3.4bpp"); +const u32 gMapObjectPic_PamtreBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pamtre/4.4bpp"); +const u32 gMapObjectPic_PamtreBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/pamtre/5.4bpp"); +const u32 gMapObjectPic_CornnBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cornn/0.4bpp"); +const u32 gMapObjectPic_CornnBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cornn/1.4bpp"); +const u32 gMapObjectPic_CornnBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cornn/2.4bpp"); +const u32 gMapObjectPic_CornnBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cornn/3.4bpp"); +const u32 gMapObjectPic_CornnBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cornn/4.4bpp"); +const u32 gMapObjectPic_CornnBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/cornn/5.4bpp"); +const u32 gMapObjectPic_LansatBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lansat/0.4bpp"); +const u32 gMapObjectPic_LansatBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lansat/1.4bpp"); +const u32 gMapObjectPic_LansatBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lansat/2.4bpp"); +const u32 gMapObjectPic_LansatBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lansat/3.4bpp"); +const u32 gMapObjectPic_LansatBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lansat/4.4bpp"); +const u32 gMapObjectPic_LansatBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/lansat/5.4bpp"); +const u32 gMapObjectPic_DurinBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/durin/0.4bpp"); +const u32 gMapObjectPic_DurinBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/durin/1.4bpp"); +const u32 gMapObjectPic_DurinBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/durin/2.4bpp"); +const u32 gMapObjectPic_DurinBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/durin/3.4bpp"); +const u32 gMapObjectPic_DurinBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/durin/4.4bpp"); +const u32 gMapObjectPic_DurinBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/durin/5.4bpp"); +const u32 gMapObjectPic_TamatoBerryTree_0[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/tamato/0.4bpp"); +const u32 gMapObjectPic_TamatoBerryTree_1[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/tamato/1.4bpp"); +const u32 gMapObjectPic_TamatoBerryTree_2[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/tamato/2.4bpp"); +const u32 gMapObjectPic_TamatoBerryTree_3[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/tamato/3.4bpp"); +const u32 gMapObjectPic_TamatoBerryTree_4[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/tamato/4.4bpp"); +const u32 gMapObjectPic_TamatoBerryTree_5[] = INCBIN_U32("graphics/map_objects/pics/berry_trees/tamato/5.4bpp"); +const u32 gFieldEffectPic_SurfBlob_0[] = INCBIN_U32("graphics/field_effect_objects/pics/surf_blob/0.4bpp"); +const u32 gFieldEffectPic_SurfBlob_1[] = INCBIN_U32("graphics/field_effect_objects/pics/surf_blob/1.4bpp"); +const u32 gFieldEffectPic_SurfBlob_2[] = INCBIN_U32("graphics/field_effect_objects/pics/surf_blob/2.4bpp"); +const u32 gMapObjectPic_QuintyPlump_0[] = INCBIN_U32("graphics/map_objects/pics/people/quinty_plump/0.4bpp"); +const u32 gMapObjectPic_QuintyPlump_1[] = INCBIN_U32("graphics/map_objects/pics/people/quinty_plump/1.4bpp"); +const u32 gMapObjectPic_QuintyPlump_2[] = INCBIN_U32("graphics/map_objects/pics/people/quinty_plump/2.4bpp"); +const u32 gMapObjectPic_QuintyPlump_3[] = INCBIN_U32("graphics/map_objects/pics/people/quinty_plump/3.4bpp"); +const u32 gMapObjectPic_QuintyPlump_4[] = INCBIN_U32("graphics/map_objects/pics/people/quinty_plump/4.4bpp"); +const u32 gMapObjectPic_QuintyPlump_5[] = INCBIN_U32("graphics/map_objects/pics/people/quinty_plump/5.4bpp"); +const u32 gMapObjectPic_QuintyPlump_6[] = INCBIN_U32("graphics/map_objects/pics/people/quinty_plump/6.4bpp"); +const u16 gMapObjectPalette12[] = INCBIN_U16("graphics/map_objects/palettes/12.gbapal"); +const u16 gMapObjectPalette13[] = INCBIN_U16("graphics/map_objects/palettes/13.gbapal"); + +const u32 gFieldEffectPic_ShadowSmall[] = INCBIN_U32("graphics/field_effect_objects/pics/shadow_small.4bpp"); +const u32 gFieldEffectPic_ShadowMedium[] = INCBIN_U32("graphics/field_effect_objects/pics/shadow_medium.4bpp"); +const u32 gFieldEffectPic_ShadowLarge[] = INCBIN_U32("graphics/field_effect_objects/pics/shadow_large.4bpp"); +const u32 gFieldEffectPic_ShadowExtraLarge[] = INCBIN_U32("graphics/field_effect_objects/pics/shadow_extra_large.4bpp"); +const u32 filler_8368A08[0x48] = {}; +const u32 gFieldEffectPic_CutGrass[] = INCBIN_U32("graphics/field_effect_objects/pics/cut_grass.4bpp"); +const u32 FieldEffectPic_CutGrass_Copy[] = INCBIN_U32("graphics/field_effect_objects/pics/cut_grass.4bpp"); +const u16 gFieldEffectObjectPalette6[] = INCBIN_U16("graphics/field_effect_objects/palettes/06.gbapal"); +const u32 gFieldEffectPic_Ripple_0[] = INCBIN_U32("graphics/field_effect_objects/pics/ripple/0.4bpp"); +const u32 gFieldEffectPic_Ripple_1[] = INCBIN_U32("graphics/field_effect_objects/pics/ripple/1.4bpp"); +const u32 gFieldEffectPic_Ripple_2[] = INCBIN_U32("graphics/field_effect_objects/pics/ripple/2.4bpp"); +const u32 gFieldEffectPic_Ripple_3[] = INCBIN_U32("graphics/field_effect_objects/pics/ripple/3.4bpp"); +const u32 gFieldEffectPic_Ripple_4[] = INCBIN_U32("graphics/field_effect_objects/pics/ripple/4.4bpp"); +const u32 gFieldEffectPic_Ash_0[] = INCBIN_U32("graphics/field_effect_objects/pics/ash/0.4bpp"); +const u32 gFieldEffectPic_Ash_1[] = INCBIN_U32("graphics/field_effect_objects/pics/ash/1.4bpp"); +const u32 gFieldEffectPic_Ash_2[] = INCBIN_U32("graphics/field_effect_objects/pics/ash/2.4bpp"); +const u32 gFieldEffectPic_Ash_3[] = INCBIN_U32("graphics/field_effect_objects/pics/ash/3.4bpp"); +const u32 gFieldEffectPic_Ash_4[] = INCBIN_U32("graphics/field_effect_objects/pics/ash/4.4bpp"); +const u32 gFieldEffectPic_Arrow_0[] = INCBIN_U32("graphics/field_effect_objects/pics/arrow/0.4bpp"); +const u32 gFieldEffectPic_Arrow_1[] = INCBIN_U32("graphics/field_effect_objects/pics/arrow/1.4bpp"); +const u32 gFieldEffectPic_Arrow_2[] = INCBIN_U32("graphics/field_effect_objects/pics/arrow/2.4bpp"); +const u32 gFieldEffectPic_Arrow_3[] = INCBIN_U32("graphics/field_effect_objects/pics/arrow/3.4bpp"); +const u32 gFieldEffectPic_Arrow_4[] = INCBIN_U32("graphics/field_effect_objects/pics/arrow/4.4bpp"); +const u32 gFieldEffectPic_Arrow_5[] = INCBIN_U32("graphics/field_effect_objects/pics/arrow/5.4bpp"); +const u32 gFieldEffectPic_Arrow_6[] = INCBIN_U32("graphics/field_effect_objects/pics/arrow/6.4bpp"); +const u32 gFieldEffectPic_Arrow_7[] = INCBIN_U32("graphics/field_effect_objects/pics/arrow/7.4bpp"); +const u16 gFieldEffectObjectPalette0[] = INCBIN_U16("graphics/field_effect_objects/palettes/00.gbapal"); +const u16 gFieldEffectObjectPalette1[] = INCBIN_U16("graphics/field_effect_objects/palettes/01.gbapal"); +const u32 gFieldEffectPic_Dust_0[] = INCBIN_U32("graphics/field_effect_objects/pics/dust/0.4bpp"); +const u32 gFieldEffectPic_Dust_1[] = INCBIN_U32("graphics/field_effect_objects/pics/dust/1.4bpp"); +const u32 gFieldEffectPic_Dust_2[] = INCBIN_U32("graphics/field_effect_objects/pics/dust/2.4bpp"); +const u32 unknown_8369588[] = INCBIN_U32("graphics/field_effect_objects/unknown.bin"); +const u32 gFieldEffectPic_JumpTallGrass_0[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_tall_grass/0.4bpp"); +const u32 gFieldEffectPic_JumpTallGrass_1[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_tall_grass/1.4bpp"); +const u32 gFieldEffectPic_JumpTallGrass_2[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_tall_grass/2.4bpp"); +const u32 gFieldEffectPic_JumpTallGrass_3[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_tall_grass/3.4bpp"); +const u32 UnusedGrass0[] = INCBIN_U32("graphics/field_effect_objects/pics/unused_grass/0.4bpp"); +const u32 UnusedGrass1[] = INCBIN_U32("graphics/field_effect_objects/pics/unused_grass/1.4bpp"); +const u32 UnusedGrass2[] = INCBIN_U32("graphics/field_effect_objects/pics/unused_grass/2.4bpp"); +const u32 UnusedGrass3[] = INCBIN_U32("graphics/field_effect_objects/pics/unused_grass/3.4bpp"); +const u32 gFieldEffectPic_JumpLongGrass_0[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_long_grass/0.4bpp"); +const u32 gFieldEffectPic_JumpLongGrass_1[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_long_grass/1.4bpp"); +const u32 gFieldEffectPic_JumpLongGrass_2[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_long_grass/2.4bpp"); +const u32 gFieldEffectPic_JumpLongGrass_3[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_long_grass/3.4bpp"); +const u32 gFieldEffectPic_JumpLongGrass_4[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_long_grass/4.4bpp"); +const u32 UnusedGrassLong[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_long_grass/unused.4bpp"); +const u32 gFieldEffectPic_JumpLongGrass_5[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_long_grass/5.4bpp"); +const u32 gFieldEffectPic_Unknown17_0[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_17/0.4bpp"); +const u32 gFieldEffectPic_Unknown17_1[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_17/1.4bpp"); +const u32 gFieldEffectPic_Unknown17_2[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_17/2.4bpp"); +const u32 gFieldEffectPic_Unknown17_3[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_17/3.4bpp"); +const u32 gFieldEffectPic_Unknown17_4[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_17/4.4bpp"); +const u32 gFieldEffectPic_Unknown17_5[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_17/5.4bpp"); +const u32 gFieldEffectPic_Unknown17_6[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_17/6.4bpp"); +const u32 gFieldEffectPic_Unknown17_7[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_17/7.4bpp"); +const u32 gFieldEffectPic_Unknown18_0[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_18/0.4bpp"); +const u32 gFieldEffectPic_Unknown18_1[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_18/1.4bpp"); +const u32 gFieldEffectPic_Unknown18_2[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_18/2.4bpp"); +const u32 gFieldEffectPic_Unknown18_3[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_18/3.4bpp"); +const u32 gFieldEffectPic_LongGrass_0[] = INCBIN_U32("graphics/field_effect_objects/pics/long_grass/0.4bpp"); +const u32 gFieldEffectPic_LongGrass_1[] = INCBIN_U32("graphics/field_effect_objects/pics/long_grass/1.4bpp"); +const u32 gFieldEffectPic_LongGrass_2[] = INCBIN_U32("graphics/field_effect_objects/pics/long_grass/2.4bpp"); +const u32 gFieldEffectPic_LongGrass_3[] = INCBIN_U32("graphics/field_effect_objects/pics/long_grass/3.4bpp"); +const u32 gFieldEffectPic_TallGrass_0[] = INCBIN_U32("graphics/field_effect_objects/pics/tall_grass/0.4bpp"); +const u32 gFieldEffectPic_TallGrass_1[] = INCBIN_U32("graphics/field_effect_objects/pics/tall_grass/1.4bpp"); +const u32 gFieldEffectPic_TallGrass_2[] = INCBIN_U32("graphics/field_effect_objects/pics/tall_grass/2.4bpp"); +const u32 gFieldEffectPic_TallGrass_3[] = INCBIN_U32("graphics/field_effect_objects/pics/tall_grass/3.4bpp"); +const u32 gFieldEffectPic_TallGrass_4[] = INCBIN_U32("graphics/field_effect_objects/pics/tall_grass/4.4bpp"); +const u32 gFieldEffectPic_ShortGrass_0[] = INCBIN_U32("graphics/field_effect_objects/pics/short_grass/0.4bpp"); +const u32 gFieldEffectPic_ShortGrass_1[] = INCBIN_U32("graphics/field_effect_objects/pics/short_grass/1.4bpp"); +const u32 gFieldEffectPic_SandFootprints_0[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_footprints/0.4bpp"); +const u32 gFieldEffectPic_SandFootprints_1[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_footprints/1.4bpp"); +const u32 gFieldEffectPic_DeepSandFootprints_0[] = INCBIN_U32("graphics/field_effect_objects/pics/deep_sand_footprints/0.4bpp"); +const u32 gFieldEffectPic_DeepSandFootprints_1[] = INCBIN_U32("graphics/field_effect_objects/pics/deep_sand_footprints/1.4bpp"); +const u32 gFieldEffectPic_BikeTireTracks_0[] = INCBIN_U32("graphics/field_effect_objects/pics/bike_tire_tracks/0.4bpp"); +const u32 gFieldEffectPic_BikeTireTracks_1[] = INCBIN_U32("graphics/field_effect_objects/pics/bike_tire_tracks/1.4bpp"); +const u32 gFieldEffectPic_BikeTireTracks_2[] = INCBIN_U32("graphics/field_effect_objects/pics/bike_tire_tracks/2.4bpp"); +const u32 gFieldEffectPic_BikeTireTracks_3[] = INCBIN_U32("graphics/field_effect_objects/pics/bike_tire_tracks/3.4bpp"); +const u32 gFieldEffectPic_Unknown19_0[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_19/0.4bpp"); +const u32 gFieldEffectPic_Unknown19_1[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_19/1.4bpp"); +const u32 gFieldEffectPic_Unknown19_2[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_19/2.4bpp"); +const u32 gFieldEffectPic_Unknown19_3[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_19/3.4bpp"); +const u32 gFieldEffectPic_SandPile_0[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_pile/0.4bpp"); +const u32 gFieldEffectPic_SandPile_1[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_pile/1.4bpp"); +const u32 gFieldEffectPic_SandPile_2[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_pile/2.4bpp"); +const u32 gFieldEffectPic_JumpBigSplash_0[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_big_splash/0.4bpp"); +const u32 gFieldEffectPic_JumpBigSplash_1[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_big_splash/1.4bpp"); +const u32 gFieldEffectPic_JumpBigSplash_2[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_big_splash/2.4bpp"); +const u32 gFieldEffectPic_JumpBigSplash_3[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_big_splash/3.4bpp"); +const u32 gFieldEffectPic_Splash_0[] = INCBIN_U32("graphics/field_effect_objects/pics/splash/0.4bpp"); +const u32 gFieldEffectPic_Splash_1[] = INCBIN_U32("graphics/field_effect_objects/pics/splash/1.4bpp"); +const u32 gFieldEffectPic_JumpSmallSplash_0[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_small_splash/0.4bpp"); +const u32 gFieldEffectPic_JumpSmallSplash_1[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_small_splash/1.4bpp"); +const u32 gFieldEffectPic_JumpSmallSplash_2[] = INCBIN_U32("graphics/field_effect_objects/pics/jump_small_splash/2.4bpp"); +const u32 gFieldEffectPic_Unknown20_0[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_20/0.4bpp"); +const u32 gFieldEffectPic_Unknown20_1[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_20/1.4bpp"); +const u32 gFieldEffectPic_Unknown20_2[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_20/2.4bpp"); +const u32 gFieldEffectPic_Unknown20_3[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_20/3.4bpp"); +const u32 gFieldEffectPic_Unknown20_4[] = INCBIN_U32("graphics/field_effect_objects/pics/unknown_20/4.4bpp"); +const u32 gFieldEffectPic_TreeDisguise_0[] = INCBIN_U32("graphics/field_effect_objects/pics/tree_disguise/0.4bpp"); +const u32 gFieldEffectPic_TreeDisguise_1[] = INCBIN_U32("graphics/field_effect_objects/pics/tree_disguise/1.4bpp"); +const u32 gFieldEffectPic_TreeDisguise_2[] = INCBIN_U32("graphics/field_effect_objects/pics/tree_disguise/2.4bpp"); +const u32 gFieldEffectPic_TreeDisguise_3[] = INCBIN_U32("graphics/field_effect_objects/pics/tree_disguise/3.4bpp"); +const u32 gFieldEffectPic_TreeDisguise_4[] = INCBIN_U32("graphics/field_effect_objects/pics/tree_disguise/4.4bpp"); +const u32 gFieldEffectPic_TreeDisguise_5[] = INCBIN_U32("graphics/field_effect_objects/pics/tree_disguise/5.4bpp"); +const u32 gFieldEffectPic_TreeDisguise_6[] = INCBIN_U32("graphics/field_effect_objects/pics/tree_disguise/6.4bpp"); +const u32 gFieldEffectPic_MountainDisguise_0[] = INCBIN_U32("graphics/field_effect_objects/pics/mountain_disguise/0.4bpp"); +const u32 gFieldEffectPic_MountainDisguise_1[] = INCBIN_U32("graphics/field_effect_objects/pics/mountain_disguise/1.4bpp"); +const u32 gFieldEffectPic_MountainDisguise_2[] = INCBIN_U32("graphics/field_effect_objects/pics/mountain_disguise/2.4bpp"); +const u32 gFieldEffectPic_MountainDisguise_3[] = INCBIN_U32("graphics/field_effect_objects/pics/mountain_disguise/3.4bpp"); +const u32 gFieldEffectPic_MountainDisguise_4[] = INCBIN_U32("graphics/field_effect_objects/pics/mountain_disguise/4.4bpp"); +const u32 gFieldEffectPic_MountainDisguise_5[] = INCBIN_U32("graphics/field_effect_objects/pics/mountain_disguise/5.4bpp"); +const u32 gFieldEffectPic_MountainDisguise_6[] = INCBIN_U32("graphics/field_effect_objects/pics/mountain_disguise/6.4bpp"); +const u32 gFieldEffectPic_SandDisguise_0[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_disguise/0.4bpp"); +const u32 gFieldEffectPic_SandDisguise_1[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_disguise/1.4bpp"); +const u32 gFieldEffectPic_SandDisguise_2[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_disguise/2.4bpp"); +const u32 gFieldEffectPic_SandDisguise_3[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_disguise/3.4bpp"); +const u32 gFieldEffectPic_SandDisguise_4[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_disguise/4.4bpp"); +const u32 gFieldEffectPic_SandDisguise_5[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_disguise/5.4bpp"); +const u32 gFieldEffectPic_SandDisguise_6[] = INCBIN_U32("graphics/field_effect_objects/pics/sand_disguise/6.4bpp"); +const u32 gFieldEffectPic_HotSpringsWater[] = INCBIN_U32("graphics/field_effect_objects/pics/hot_springs_water.4bpp"); +const u16 gFieldEffectObjectPalette2[] = INCBIN_U16("graphics/field_effect_objects/palettes/02.gbapal"); +const u32 gFieldEffectPic_PopOutOfAsh_0[] = INCBIN_U32("graphics/field_effect_objects/pics/pop_out_of_ash/0.4bpp"); +const u32 gFieldEffectPic_PopOutOfAsh_1[] = INCBIN_U32("graphics/field_effect_objects/pics/pop_out_of_ash/1.4bpp"); +const u32 gFieldEffectPic_PopOutOfAsh_2[] = INCBIN_U32("graphics/field_effect_objects/pics/pop_out_of_ash/2.4bpp"); +const u32 gFieldEffectPic_PopOutOfAsh_3[] = INCBIN_U32("graphics/field_effect_objects/pics/pop_out_of_ash/3.4bpp"); +const u32 gFieldEffectPic_PopOutOfAsh_4[] = INCBIN_U32("graphics/field_effect_objects/pics/pop_out_of_ash/4.4bpp"); +const u32 gFieldEffectPic_LavaridgeGymWarp_0[] = INCBIN_U32("graphics/field_effect_objects/pics/lavaridge_gym_warp/0.4bpp"); +const u32 gFieldEffectPic_LavaridgeGymWarp_1[] = INCBIN_U32("graphics/field_effect_objects/pics/lavaridge_gym_warp/1.4bpp"); +const u32 gFieldEffectPic_LavaridgeGymWarp_2[] = INCBIN_U32("graphics/field_effect_objects/pics/lavaridge_gym_warp/2.4bpp"); +const u32 gFieldEffectPic_LavaridgeGymWarp_3[] = INCBIN_U32("graphics/field_effect_objects/pics/lavaridge_gym_warp/3.4bpp"); +const u32 gFieldEffectPic_LavaridgeGymWarp_4[] = INCBIN_U32("graphics/field_effect_objects/pics/lavaridge_gym_warp/4.4bpp"); +const u32 gFieldEffectPic_Bubbles_0[] = INCBIN_U32("graphics/field_effect_objects/pics/bubbles/0.4bpp"); +const u32 gFieldEffectPic_Bubbles_1[] = INCBIN_U32("graphics/field_effect_objects/pics/bubbles/1.4bpp"); +const u32 gFieldEffectPic_Bubbles_2[] = INCBIN_U32("graphics/field_effect_objects/pics/bubbles/2.4bpp"); +const u32 gFieldEffectPic_Bubbles_3[] = INCBIN_U32("graphics/field_effect_objects/pics/bubbles/3.4bpp"); +const u32 gFieldEffectPic_Bubbles_4[] = INCBIN_U32("graphics/field_effect_objects/pics/bubbles/4.4bpp"); +const u32 gFieldEffectPic_Bubbles_5[] = INCBIN_U32("graphics/field_effect_objects/pics/bubbles/5.4bpp"); +const u32 gFieldEffectPic_Bubbles_6[] = INCBIN_U32("graphics/field_effect_objects/pics/bubbles/6.4bpp"); +const u32 gFieldEffectPic_Bubbles_7[] = INCBIN_U32("graphics/field_effect_objects/pics/bubbles/7.4bpp"); +const u32 gFieldEffectPic_Sparkle_0[] = INCBIN_U32("graphics/field_effect_objects/pics/sparkle/0.4bpp"); +const u32 gFieldEffectPic_Sparkle_1[] = INCBIN_U32("graphics/field_effect_objects/pics/sparkle/1.4bpp"); +const u16 gFieldEffectObjectPalette3[] = INCBIN_U16("graphics/field_effect_objects/palettes/03.gbapal"); +const u32 gFieldEffectPic_Bird[] = INCBIN_U32("graphics/field_effect_objects/pics/bird.4bpp"); + +void (*const gUnknown_0836DA88[])(struct Sprite *) = +{ + sub_805C884, + sub_805CDE8, + sub_805C8AC, + sub_805CF28, + sub_805CF28, + sub_805D0AC, + sub_805D0AC, + sub_805D230, + sub_805D230, + sub_805D230, + sub_805D230, + sub_80587B4, + FieldObjectCB_BerryTree, + sub_805D4F4, + sub_805D634, + sub_805D774, + sub_805D8B4, + sub_805D9F4, + sub_805DB34, + sub_805DC74, + sub_805DDB4, + sub_805DEF4, + sub_805E034, + sub_805E174, + sub_805E278, + sub_805E37C, + sub_805E37C, + sub_805E37C, + sub_805E37C, + sub_805E5DC, + sub_805E668, + sub_805E6F4, + sub_805E780, + sub_805E80C, + sub_805E898, + sub_805E924, + sub_805E9B0, + sub_805EA3C, + sub_805EAC8, + sub_805EB54, + sub_805EBE0, + sub_805EC6C, + sub_805ECF8, + sub_805ED84, + sub_805EE10, + sub_805EE9C, + sub_805EF28, + sub_805EFB4, + sub_805F040, + sub_805F0CC, + sub_805F158, + sub_805F1E4, + sub_805F270, + sub_805F2FC, + sub_805F2FC, + sub_805F2FC, + sub_805F2FC, + FieldObjectCB_TreeDisguise, + FieldObjectCB_MountainDisguise, + sub_805F8E0, + sub_805F8E0, + sub_805F8E0, + sub_805F8E0, + FieldObjectCB_Hidden1, + sub_805FB20, + sub_805FB20, + sub_805FB20, + sub_805FB20, + sub_805FB90, + sub_805FB90, + sub_805FB90, + sub_805FB90, + sub_805FC00, + sub_805FC00, + sub_805FC00, + sub_805FC00, + sub_805FC70 +}; + +const u8 gUnknown_0836DBBC[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +const u8 gUnknown_0836DC09[] = {DIR_SOUTH, DIR_SOUTH, DIR_SOUTH, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_SOUTH, DIR_SOUTH, DIR_SOUTH, DIR_WEST, DIR_NORTH, DIR_NORTH, DIR_SOUTH, DIR_SOUTH, DIR_SOUTH, DIR_SOUTH, DIR_NORTH, DIR_SOUTH, DIR_SOUTH, DIR_SOUTH, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_WEST, DIR_NORTH, DIR_WEST, DIR_SOUTH, DIR_EAST, DIR_WEST, DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_EAST, DIR_NORTH, DIR_WEST, DIR_SOUTH, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_SOUTH, DIR_SOUTH, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_SOUTH, DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST, DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST, DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST, DIR_SOUTH}; + +#include "data/field_map_obj/map_object_graphics_info_pointers.h" +#include "data/field_map_obj/field_effect_object_template_pointers.h" +#include "data/field_map_obj/map_object_pic_tables.h" +#include "data/field_map_obj/map_object_anims.h" +#include "data/field_map_obj/base_oam.h" +#include "data/field_map_obj/map_object_subsprites.h" +#include "data/field_map_obj/map_object_graphics_info.h" + +const struct SpritePalette gUnknown_0837377C[] = { + {gMapObjectPalette0, 0x1103}, + {gMapObjectPalette1, 0x1104}, + {gMapObjectPalette2, 0x1105}, + {gMapObjectPalette3, 0x1106}, + {gMapObjectPalette4, 0x1107}, + {gMapObjectPalette5, 0x1108}, + {gMapObjectPalette6, 0x1109}, + {gMapObjectPalette7, 0x110A}, + {gMapObjectPalette8, 0x1100}, + {gMapObjectPalette9, 0x1101}, + {gMapObjectPalette10, 0x1102}, + {gMapObjectPalette11, 0x1115}, + {gMapObjectPalette12, 0x110B}, + {gMapObjectPalette13, 0x110C}, + {gMapObjectPalette14, 0x110D}, + {gMapObjectPalette15, 0x110E}, + {gMapObjectPalette16, 0x110F}, + {gMapObjectPalette17, 0x1110}, + {gMapObjectPalette18, 0x1111}, + {gMapObjectPalette19, 0x1112}, + {gMapObjectPalette20, 0x1113}, + {gMapObjectPalette21, 0x1114}, + {gMapObjectPalette22, 0x1116}, + {gMapObjectPalette23, 0x1117}, + {gMapObjectPalette24, 0x1118}, + {gMapObjectPalette25, 0x1119}, + {gMapObjectPalette26, 0x111A}, + {NULL, 0x0000} +}; + +const u16 Palettes_837385C[] = { + 0x1101, + 0x1101, + 0x1101, + 0x1101 +}; + +const u16 Palettes_8373864[] = { + 0x1111, + 0x1111, + 0x1111, + 0x1111 +}; + +const u16 Palettes_837386C[] = { + 0x1115, + 0x1115, + 0x1115, + 0x1115 +}; + +const struct PairedPalettes gUnknown_08373874[] = { + {0x1100, Palettes_837385C}, + {0x1110, Palettes_837385C}, + {0x1115, Palettes_837386C}, + {0x11FF, NULL} +}; + +const u16 Palettes_8373894[] = { + 0x110C, + 0x110C, + 0x110C, + 0x110C +}; + +const u16 Palettes_837389C[] = { + 0x110D, + 0x110D, + 0x110D, + 0x110D +}; + +const u16 Palettes_83738A4[] = { + 0x110E, + 0x110E, + 0x110E, + 0x110E +}; + +const u16 Palettes_83738AC[] = { + 0x1112, + 0x1112, + 0x1112, + 0x1112 +}; + +const u16 Palettes_83738B4[] = { + 0x1113, + 0x1113, + 0x1113, + 0x1113 +}; + +const u16 Palettes_83738BC[] = { + 0x1114, + 0x1114, + 0x1114, + 0x1114 +}; + +const u16 Palettes_83738C4[] = { + 0x111A, + 0x111A, + 0x111A, + 0x111A +}; + +const u16 Palettes_83738CC[] = { + 0x1117, + 0x1117, + 0x1117, + 0x1117 +}; + +const u16 Palettes_83738D4[] = { + 0x1119, + 0x1119, + 0x1119, + 0x1119 +}; + +const u16 Palettes_83738DC[] = { + 0x1109, + 0x1109, + 0x1109, + 0x1109 +}; + +const struct PairedPalettes gUnknown_083738E4[] = { + {0x1100, Palettes_837385C}, + {0x1110, Palettes_837385C}, + {0x110B, Palettes_8373894}, + {0x110D, Palettes_837389C}, + {0x110E, Palettes_83738A4}, + {0x1112, Palettes_83738AC}, + {0x1113, Palettes_83738B4}, + {0x1114, Palettes_83738BC}, + {0x1116, Palettes_83738CC}, + {0x1118, Palettes_83738D4}, + {0x1105, Palettes_83738DC}, + {0x111A, Palettes_83738C4}, + {0x11FF, NULL} +}; + +const u16 Unknown_837394C[] = { + 0x1100, + 0x1101, + 0x1103, + 0x1104, + 0x1105, + 0x1106, + 0x1107, + 0x1108, + 0x1109, + 0x110A +}; + +const u16 Unknown_8373960[] = { + 0x1100, + 0x1101, + 0x1103, + 0x1104, + 0x1105, + 0x1106, + 0x1107, + 0x1108, + 0x1109, + 0x110A +}; + +const u16 Unknown_8373974[] = { + 0x1100, + 0x1101, + 0x1103, + 0x1104, + 0x1105, + 0x1106, + 0x1107, + 0x1108, + 0x1109, + 0x110A +}; + +const u16 Unknown_8373988[] = { + 0x1100, + 0x1101, + 0x1103, + 0x1104, + 0x1105, + 0x1106, + 0x1107, + 0x1108, + 0x1109, + 0x110A +}; + +const u16 *const gUnknown_0837399C[] = { + Unknown_837394C, + Unknown_8373960, + Unknown_8373974, + Unknown_8373988 +}; + +#include "data/field_map_obj/berry_tree_graphics_tables.h" +#include "data/field_map_obj/field_effect_objects.h" + +const s16 gUnknown_0837520C[] = {0x20, 0x40, 0x60, 0x80}; +const s16 gUnknown_08375204[] = {0x20, 0x40, 0x80, 0xc0}; +const s16 gUnknown_0837521C[] = {0x20, 0x30, 0x40, 0x50}; + +#include "data/field_map_obj/callback_subroutine_pointers.h" + +const u8 gUnknown_083755F4[] = {0x00, 0x00, 0x01, 0x02, 0x03, 0x00, 0x00, 0x01, 0x01}; +const u8 gUnknown_083755FD[] = {0x04, 0x04, 0x05, 0x06, 0x07, 0x04, 0x04, 0x05, 0x05}; +const u8 gUnknown_08375606[] = {0x08, 0x08, 0x09, 0x0A, 0x0B, 0x08, 0x08, 0x09, 0x09}; +const u8 gUnknown_0837560F[] = {0x0C, 0x0C, 0x0D, 0x0E, 0x0F, 0x0C, 0x0C, 0x0D, 0x0D}; +const u8 gUnknown_08375618[] = {0x10, 0x10, 0x11, 0x12, 0x13, 0x10, 0x10, 0x11, 0x11}; +const u8 gUnknown_08375621[] = {0x14, 0x14, 0x15, 0x16, 0x17, 0x14, 0x14, 0x15, 0x15}; +const u8 gUnknown_0837562A[] = {0x14, 0x14, 0x15, 0x16, 0x17, 0x14, 0x14, 0x15, 0x15}; +const u8 gUnknown_08375633[] = {0x18, 0x18, 0x19, 0x1A, 0x1B, 0x18, 0x18, 0x19, 0x19}; +const u8 gUnknown_0837563C[] = {0x1C, 0x1C, 0x1D, 0x1E, 0x1F, 0x1C, 0x1C, 0x1D, 0x1D}; +const u8 gUnknown_08375645[] = {0x20, 0x20, 0x21, 0x22, 0x23, 0x20, 0x20, 0x21, 0x21}; +const u8 gUnknown_0837564E[] = {0x24, 0x24, 0x25, 0x26, 0x27, 0x24, 0x24, 0x25, 0x25}; +const u8 gUnknown_08375657[] = {0x00, 0x00, 0x01, 0x02, 0x03, 0x00, 0x00, 0x01, 0x01}; +const u8 gUnknown_08375660[] = {0x04, 0x04, 0x05, 0x06, 0x07, 0x04, 0x04, 0x05, 0x05}; +const u8 gUnknown_08375669[] = {0x08, 0x08, 0x09, 0x0A, 0x0B, 0x08, 0x08, 0x09, 0x09}; +const u8 gUnknown_08375672[] = {0x14, 0x14, 0x15, 0x16, 0x17, 0x14, 0x14, 0x15, 0x15}; +const u8 gUnknown_0837567B[] = {0x08, 0x08, 0x07, 0x09, 0x0A, 0x08, 0x08, 0x07, 0x07}; + +bool8 (*const gUnknown_08375684[])(u8) = { + MetatileBehavior_IsSouthBlocked, + MetatileBehavior_IsNorthBlocked, + MetatileBehavior_IsWestBlocked, + MetatileBehavior_IsEastBlocked +}; + +bool8 (*const gUnknown_08375694[])(u8) = { + MetatileBehavior_IsNorthBlocked, + MetatileBehavior_IsSouthBlocked, + MetatileBehavior_IsEastBlocked, + MetatileBehavior_IsWestBlocked +}; + +const struct Coords16 gDirectionToVector[] = { + { 0, 0}, + { 0, 1}, + { 0, -1}, + {-1, 0}, + { 1, 0}, + {-1, 1}, + { 1, 1}, + {-1, -1}, + { 1, -1} +}; + +const u8 gUnknown_083756C8[] = {0x00, 0x00, 0x01, 0x02, 0x03}; +const u8 gUnknown_083756CD[] = {0x04, 0x04, 0x05, 0x06, 0x07}; +const u8 gUnknown_083756D2[] = {0x08, 0x08, 0x09, 0x0A, 0x0B}; +const u8 gUnknown_083756D7[] = {0x15, 0x15, 0x16, 0x17, 0x18}; +const u8 gUnknown_083756DC[] = {0x29, 0x29, 0x2A, 0x2B, 0x2C}; +const u8 gUnknown_083756E1[] = {0x2D, 0x2D, 0x2E, 0x2F, 0x30}; +const u8 gUnknown_083756E6[] = {0x31, 0x31, 0x32, 0x33, 0x34}; +const u8 gUnknown_083756EB[] = {0x35, 0x35, 0x36, 0x37, 0x38}; +const u8 gUnknown_083756F0[] = {0x0C, 0x0C, 0x0D, 0x0E, 0x0F}; +const u8 gUnknown_083756F5[] = {0x46, 0x46, 0x47, 0x48, 0x49}; +const u8 gUnknown_083756FA[] = {0x4B, 0x4B, 0x4A, 0x4D, 0x4C}; +const u8 gUnknown_083756FF[] = {0x42, 0x42, 0x43, 0x44, 0x45}; +const u8 gUnknown_08375704[] = {0x3A, 0x3A, 0x3B, 0x3C, 0x3D}; +const u8 gUnknown_08375709[] = {0x19, 0x19, 0x1A, 0x1B, 0x1C}; +const u8 gUnknown_0837570E[] = {0x1D, 0x1D, 0x1E, 0x1F, 0x20}; +const u8 gUnknown_08375713[] = {0x21, 0x21, 0x22, 0x23, 0x24}; +const u8 gUnknown_08375718[] = {0x25, 0x25, 0x26, 0x27, 0x28}; +const u8 gUnknown_0837571D[] = {0x62, 0x62, 0x63, 0x64, 0x65}; +const u8 gUnknown_08375722[] = {0x66, 0x66, 0x67, 0x68, 0x69}; +const u8 gUnknown_08375727[] = {0x6A, 0x6A, 0x6B, 0x6C, 0x6D}; +const u8 gUnknown_0837572C[] = {0x6E, 0x6E, 0x6F, 0x70, 0x71}; +const u8 gUnknown_08375731[] = {0x72, 0x72, 0x73, 0x74, 0x75}; +const u8 gUnknown_08375736[] = {0x76, 0x76, 0x77, 0x78, 0x79}; +const u8 gUnknown_0837573B[] = {0x7A, 0x7A, 0x7B, 0x7C, 0x7D}; +const u8 gUnknown_08375740[] = {0x7E, 0x7E, 0x7F, 0x80, 0x81}; +const u8 gUnknown_08375745[] = {0x82, 0x82, 0x83, 0x84, 0x85}; +const u8 gUnknown_0837574A[] = {0x86, 0x86, 0x87, 0x88, 0x89}; + +const u8 gUnknown_0837574F[] = {2, 1, 4, 3, 8, 7, 6, 5}; + +const u8 gUnknown_08375757[][4] = { + {2, 1, 4, 3}, + {1, 2, 3, 4}, + {3, 4, 2, 1}, + {4, 3, 1, 2} +}; + +const u8 gUnknown_08375767[][4] = { + {2, 1, 4, 3}, + {1, 2, 3, 4}, + {4, 3, 1, 2}, + {3, 4, 2, 1} +}; + +#include "data/field_map_obj/anim_func_ptrs.h" + +// text + +extern void strange_npc_table_clear(void); +extern void ClearPlayerAvatarInfo(void); +extern void npc_load_two_palettes__no_record(u16, u8); +extern void npc_load_two_palettes__and_record(u16, u8); +extern void sub_8060388(s16, s16, s16 *, s16 *); +void sub_80634D0(struct MapObject *, struct Sprite *); +extern void pal_patch_for_npc(u16, u16); +extern void CameraObjectReset1(void); + +extern struct LinkPlayerMapObject gLinkPlayerMapObjects[]; +extern u8 gReservedSpritePaletteCount; +extern struct Camera gUnknown_0202E844; +extern u8 gUnknown_030005A4; +extern u16 gUnknown_030005A6; + +void npc_clear_ids_and_state(struct MapObject *mapObj) +{ + memset(mapObj, 0, sizeof(struct MapObject)); + mapObj->localId = 0xFF; + mapObj->mapNum = 0xFF; + mapObj->mapGroup = 0xFF; + mapObj->mapobj_unk_1C = 0xFF; +} + +void npcs_clear_ids_and_state(void) +{ + u8 i; + + for (i = 0; i < 16; i++) + npc_clear_ids_and_state(&gMapObjects[i]); +} + +void sub_805AA98(void) +{ + strange_npc_table_clear(); + npcs_clear_ids_and_state(); + ClearPlayerAvatarInfo(); + sub_805AAB0(); +} + +void sub_805AAB0(void) +{ + u8 spriteId; + + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[21], 0, 0, 0x1F); + + gSprites[spriteId].oam.affineMode = 1; + InitSpriteAffineAnim(&gSprites[spriteId]); + StartSpriteAffineAnim(&gSprites[spriteId], 0); + gSprites[spriteId].invisible = 1; + + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[21], 0, 0, 0x1F); + + gSprites[spriteId].oam.affineMode = 1; + InitSpriteAffineAnim(&gSprites[spriteId]); + StartSpriteAffineAnim(&gSprites[spriteId], 1); + gSprites[spriteId].invisible = 1; +} + +u8 sub_805AB54(void) +{ + u8 i; + + for (i = 0; i < 16; i++) + { + if (!gMapObjects[i].active) + break; + } + return i; +} + +u8 GetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + if (localId <= 0xFE) + return GetFieldObjectIdByLocalIdAndMapInternal(localId, mapNum, mapGroup); + else + return GetFieldObjectIdByLocalId(localId); +} + +bool8 TryGetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 *mapObjectId) +{ + *mapObjectId = GetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup); + if (*mapObjectId == 16) + return TRUE; + else + return FALSE; +} + +u8 GetFieldObjectIdByXY(s16 x, s16 y) +{ + u8 i; + + for (i = 0; i < 16; i++) + { + if (gMapObjects[i].active && gMapObjects[i].coords2.x == x && gMapObjects[i].coords2.y == y) + break; + } + return i; +} + +u8 GetFieldObjectIdByLocalIdAndMapInternal(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 i; + + for (i = 0; i < 16; i++) + { + if (gMapObjects[i].active && gMapObjects[i].localId == localId && gMapObjects[i].mapNum == mapNum && gMapObjects[i].mapGroup == mapGroup) + return i; + } + return 16; +} + +u8 GetFieldObjectIdByLocalId(u8 localId) +{ + u8 i; + + for (i = 0; i < 16; i++) + { + if (gMapObjects[i].active && gMapObjects[i].localId == localId) + return i; + } + return 16; +} + +#ifdef NONMATCHING +u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 b, u8 c) +{ + struct MapObject2 *mapObj; //TODO: resolve the mapobj_unk_19b weirdness + u8 var; + u16 r3; + u16 r2; + + //asm("nop"::"r"(b)); + if (GetAvailableFieldObjectSlot(template->localId, b, c, &var) != 0) + return 16; + //_0805ACCE + mapObj = (struct MapObject2 *)&gMapObjects[var]; + npc_clear_ids_and_state((struct MapObject *)mapObj); + r3 = template->x + 7; + r2 = template->y + 7; + mapObj->active = TRUE; + mapObj->mapobj_bit_2 = TRUE; + mapObj->graphicsId = template->graphicsId; + mapObj->animPattern = template->movementType; + mapObj->localId = template->localId; + mapObj->mapNum = b; + mapObj->mapGroup = c; + mapObj->coords1.x = r3; + mapObj->coords1.y = r2; + mapObj->coords2.x = r3; + mapObj->coords2.y = r2; + mapObj->coords3.x = r3; + mapObj->coords3.y = r2; + mapObj->mapobj_unk_0B_0 = template->elevation; + mapObj->elevation = template->elevation; + mapObj->mapobj_unk_19 = template->unkA_0; + mapObj->mapobj_unk_19b = template->unkA_4; + mapObj->trainerType = template->unkC; + mapObj->trainerRange_berryTreeId = template->unkE; + mapObj->mapobj_unk_20 = gUnknown_0836DC09[template->movementType]; + FieldObjectSetDirection((struct MapObject *)mapObj, mapObj->mapobj_unk_20); + FieldObjectHandleDynamicGraphicsId(mapObj); + //asm("":::"r5","r6"); + if (gUnknown_0836DBBC[mapObj->animPattern] != 0) + { + if (mapObj->mapobj_unk_19 == 0) + mapObj->mapobj_unk_19++; + if (mapObj->mapobj_unk_19b == 0) + mapObj->mapobj_unk_19b++; + } + return var; +} +#else +__attribute__((naked)) +u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 b, u8 c) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r9\n\ + mov r6, r8\n\ + push {r6,r7}\n\ + sub sp, 0x4\n\ + adds r5, r0, 0\n\ + lsls r1, 24\n\ + lsrs r6, r1, 24\n\ + lsls r2, 24\n\ + lsrs r7, r2, 24\n\ + ldrb r0, [r5]\n\ + adds r1, r6, 0\n\ + adds r2, r7, 0\n\ + mov r3, sp\n\ + bl GetAvailableFieldObjectSlot\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0805ACCE\n\ + movs r0, 0x10\n\ + b _0805ADC2\n\ +_0805ACCE:\n\ + mov r0, sp\n\ + ldrb r1, [r0]\n\ + lsls r0, r1, 3\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + ldr r1, _0805ADD0 @ =gMapObjects\n\ + adds r4, r0, r1\n\ + adds r0, r4, 0\n\ + bl npc_clear_ids_and_state\n\ + ldrh r3, [r5, 0x4]\n\ + adds r3, 0x7\n\ + lsls r3, 16\n\ + lsrs r3, 16\n\ + ldrh r2, [r5, 0x6]\n\ + adds r2, 0x7\n\ + lsls r2, 16\n\ + lsrs r2, 16\n\ + ldrb r0, [r4]\n\ + movs r1, 0x1\n\ + orrs r0, r1\n\ + movs r1, 0x4\n\ + orrs r0, r1\n\ + strb r0, [r4]\n\ + ldrb r0, [r5, 0x1]\n\ + strb r0, [r4, 0x5]\n\ + ldrb r0, [r5, 0x9]\n\ + strb r0, [r4, 0x6]\n\ + ldrb r0, [r5]\n\ + strb r0, [r4, 0x8]\n\ + strb r6, [r4, 0x9]\n\ + strb r7, [r4, 0xA]\n\ + strh r3, [r4, 0xC]\n\ + strh r2, [r4, 0xE]\n\ + strh r3, [r4, 0x10]\n\ + strh r2, [r4, 0x12]\n\ + strh r3, [r4, 0x14]\n\ + strh r2, [r4, 0x16]\n\ + ldrb r0, [r5, 0x8]\n\ + movs r7, 0xF\n\ + adds r1, r7, 0\n\ + ands r1, r0\n\ + ldrb r2, [r4, 0xB]\n\ + movs r0, 0x10\n\ + negs r0, r0\n\ + mov r8, r0\n\ + ands r0, r2\n\ + orrs r0, r1\n\ + strb r0, [r4, 0xB]\n\ + ldrb r1, [r5, 0x8]\n\ + lsls r1, 4\n\ + ands r0, r7\n\ + orrs r0, r1\n\ + strb r0, [r4, 0xB]\n\ + ldrb r1, [r5, 0xA]\n\ + lsls r1, 28\n\ + movs r0, 0xF\n\ + mov r9, r0\n\ + lsrs r1, 28\n\ + ldrb r2, [r4, 0x19]\n\ + mov r0, r8\n\ + ands r0, r2\n\ + orrs r0, r1\n\ + strb r0, [r4, 0x19]\n\ + ldrb r1, [r5, 0xA]\n\ + lsrs r1, 4\n\ + lsls r1, 4\n\ + ands r0, r7\n\ + orrs r0, r1\n\ + strb r0, [r4, 0x19]\n\ + ldrh r0, [r5, 0xC]\n\ + strb r0, [r4, 0x7]\n\ + ldrh r0, [r5, 0xE]\n\ + strb r0, [r4, 0x1D]\n\ + ldr r1, _0805ADD4 @ =gUnknown_0836DC09\n\ + ldrb r0, [r5, 0x9]\n\ + adds r0, r1\n\ + ldrb r1, [r0]\n\ + adds r0, r4, 0\n\ + adds r0, 0x20\n\ + strb r1, [r0]\n\ + ldrb r1, [r0]\n\ + adds r0, r4, 0\n\ + bl FieldObjectSetDirection\n\ + adds r0, r4, 0\n\ + bl FieldObjectHandleDynamicGraphicsId\n\ + ldr r1, _0805ADD8 @ =gUnknown_0836DBBC\n\ + ldrb r0, [r4, 0x6]\n\ + adds r0, r1\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + beq _0805ADBE\n\ + ldrb r2, [r4, 0x19]\n\ + adds r0, r7, 0\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _0805ADA6\n\ + lsls r0, r2, 28\n\ + lsrs r0, 28\n\ + adds r0, 0x1\n\ + mov r1, r9\n\ + ands r0, r1\n\ + mov r1, r8\n\ + ands r1, r2\n\ + orrs r1, r0\n\ + strb r1, [r4, 0x19]\n\ +_0805ADA6:\n\ + ldrb r2, [r4, 0x19]\n\ + movs r0, 0xF0\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _0805ADBE\n\ + lsrs r1, r2, 4\n\ + adds r1, 0x1\n\ + lsls r1, 4\n\ + adds r0, r7, 0\n\ + ands r0, r2\n\ + orrs r0, r1\n\ + strb r0, [r4, 0x19]\n\ +_0805ADBE:\n\ + mov r0, sp\n\ + ldrb r0, [r0]\n\ +_0805ADC2:\n\ + add sp, 0x4\n\ + pop {r3,r4}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ +_0805ADD0: .4byte gMapObjects\n\ +_0805ADD4: .4byte gUnknown_0836DC09\n\ +_0805ADD8: .4byte gUnknown_0836DBBC\n\ + .syntax divided\n"); +} +#endif + +u8 sub_805ADDC(u8 localId) +{ + u8 objectCount; + u8 i; + + if (gMapHeader.events == NULL) + return 16; + objectCount = gMapHeader.events->mapObjectCount; + for (i = 0; i < objectCount; i++) + { + struct MapObjectTemplate *template = &gSaveBlock1.mapObjectTemplates[i]; + + if (template->localId == localId && !FlagGet(template->flagId)) + return InitFieldObjectStateFromTemplate(template, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup); + } + return 16; +} + +u8 GetAvailableFieldObjectSlot(u16 a, u8 b, u8 c, u8 *d) +{ + u8 i = 0; + + for (i = 0; i < 16 && gMapObjects[i].active; i++) + { + if (gMapObjects[i].localId == a && gMapObjects[i].mapNum == b && gMapObjects[i].mapGroup == c) + return 1; + } + if (i >= 16) + return 1; + *d = i; + for (; i < 16; i++) + { + if (gMapObjects[i].active && gMapObjects[i].localId == a && gMapObjects[i].mapNum == b && gMapObjects[i].mapGroup == c) + return 1; + } + return 0; +} + +void RemoveFieldObject(struct MapObject *mapObject) +{ + mapObject->active = FALSE; + RemoveFieldObjectInternal(mapObject); +} + +void RemoveFieldObjectByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + + if (TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + return; + FlagSet(GetFieldObjectFlagIdByFieldObjectId(mapObjectId)); + RemoveFieldObject(&gMapObjects[mapObjectId]); +} + +void RemoveFieldObjectInternal(struct MapObject *mapObject) +{ + struct SpriteFrameImage image; + const struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); + + image.size = gfxInfo->size; + gSprites[mapObject->spriteId].images = ℑ + DestroySprite(&gSprites[mapObject->spriteId]); +} + +void npc_hide_all_but_player(void) +{ + u8 i; + + for (i = 0; i < 16; i++) + { + if (i != gPlayerAvatar.mapObjectId) + RemoveFieldObject(&gMapObjects[i]); + } +} + +u8 sub_805AFCC(struct MapObjectTemplate *mapObjTemplate, struct SpriteTemplate *sprTemplate, u8 c, u8 d, s16 e, s16 f) +{ + u8 mapObjectId; + u8 spriteId; + const struct MapObjectGraphicsInfo *gfxInfo; + struct MapObject *mapObject; + struct Sprite *sprite; + + mapObjectId = InitFieldObjectStateFromTemplate(mapObjTemplate, c, d); + if (mapObjectId == 16) + return 16; + + mapObject = &gMapObjects[mapObjectId]; + gfxInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); + if (gfxInfo->paletteSlot == 0) + npc_load_two_palettes__no_record(gfxInfo->paletteTag1, gfxInfo->paletteSlot); + else if (gfxInfo->paletteSlot == 10) + npc_load_two_palettes__and_record(gfxInfo->paletteTag1, gfxInfo->paletteSlot); + if (mapObject->animPattern == 0x4C) + mapObject->mapobj_bit_13 = TRUE; + +#ifdef NONMATCHING + sprTemplate->paletteTag = 0xFFFF; +#else + *(u16 *)&sprTemplate->paletteTag = 0xFFFF; +#endif + spriteId = CreateSprite(sprTemplate, 0, 0, 0); + if (spriteId == 64) + { + gMapObjects[mapObjectId].active = FALSE; + return 16; + } + sprite = &gSprites[spriteId]; + sub_8060388(e + mapObject->coords2.x, f + mapObject->coords2.y, &sprite->pos1.x, &sprite->pos1.y); + sprite->centerToCornerVecX = -(gfxInfo->width >> 1); + sprite->centerToCornerVecY = -(gfxInfo->height >> 1); + sprite->pos1.x += 8; + sprite->pos1.y += 16 + sprite->centerToCornerVecY; + sprite->oam.paletteNum = gfxInfo->paletteSlot; + sprite->coordOffsetEnabled = TRUE; + sprite->data0 = mapObjectId; + mapObject->spriteId = spriteId; + mapObject->mapobj_bit_12 = gfxInfo->inanimate; + if (!mapObject->mapobj_bit_12) + StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(mapObject->mapobj_unk_18)); + SetObjectSubpriorityByZCoord(mapObject->elevation, sprite, 1); + sub_80634D0(mapObject, sprite); + return mapObjectId; +} + +u8 SpawnFieldObject(struct MapObjectTemplate *mapObjTemplate, u8 b, u8 c, s16 d, s16 e) +{ + struct SpriteTemplate spriteTemplate; + const struct SubspriteTable *subspriteTables = NULL; + struct SpriteFrameImage spriteFrameImage; + const struct MapObjectGraphicsInfo *gfxInfo; + u8 mapObjectId; + + gfxInfo = GetFieldObjectGraphicsInfo(mapObjTemplate->graphicsId); + MakeObjectTemplateFromFieldObjectTemplate(mapObjTemplate, &spriteTemplate, &subspriteTables); + spriteFrameImage.size = gfxInfo->size; + spriteTemplate.images = &spriteFrameImage; + mapObjectId = sub_805AFCC(mapObjTemplate, &spriteTemplate, b, c, d, e); + if (mapObjectId == 16) + return 16; + gSprites[gMapObjects[mapObjectId].spriteId].images = gfxInfo->images; + if (subspriteTables != NULL) + SetSubspriteTables(&gSprites[gMapObjects[mapObjectId].spriteId], subspriteTables); + return mapObjectId; +} + +u8 SpawnSpecialFieldObject(struct MapObjectTemplate *mapObjTemplate) +{ + s16 x; + s16 y; + + GetFieldObjectMovingCameraOffset(&x, &y); + return SpawnFieldObject(mapObjTemplate, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, x, y); +} + +u8 SpawnSpecialFieldObjectParametrized(u8 a, u8 b, u8 c, s16 d, s16 e, u8 f) +{ + struct MapObjectTemplate mapObjTemplate; + + d -= 7; + e -= 7; + mapObjTemplate.localId = c; + mapObjTemplate.graphicsId = a; + mapObjTemplate.unk2 = 0; + mapObjTemplate.x = d; + mapObjTemplate.y = e; + mapObjTemplate.elevation = f; + mapObjTemplate.movementType = b; + mapObjTemplate.unkA_0 = 0; + mapObjTemplate.unkA_4 = 0; + mapObjTemplate.unkC = 0; + mapObjTemplate.unkE = 0; + return SpawnSpecialFieldObject(&mapObjTemplate); +} + +u8 show_sprite(u8 a, u8 b, u8 c) +{ + struct MapObjectTemplate *r5; + s16 x; + s16 y; + + r5 = GetFieldObjectTemplateByLocalIdAndMap(a, b, c); + if (r5 == NULL) + return 16; + GetFieldObjectMovingCameraOffset(&x, &y); + return SpawnFieldObject(r5, b, c, x, y); +} + +void MakeObjectTemplateFromFieldObjectGraphicsInfo(u16 graphicsId, void (*callback)(struct Sprite *), struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables) +{ + const struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(graphicsId); + + sprTemplate->tileTag = gfxInfo->tileTag; + sprTemplate->paletteTag = gfxInfo->paletteTag1; + sprTemplate->oam = gfxInfo->oam; + sprTemplate->anims = gfxInfo->anims; + sprTemplate->images = gfxInfo->images; + sprTemplate->affineAnims = gfxInfo->affineAnims; + sprTemplate->callback = callback; + *subspriteTables = gfxInfo->subspriteTables; +} + +void MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(u16 graphicsId, u16 callbackIndex, struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables) +{ + MakeObjectTemplateFromFieldObjectGraphicsInfo(graphicsId, gUnknown_0836DA88[callbackIndex], sprTemplate, subspriteTables); +} + +void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *mapObjTemplate, struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables) +{ + MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(mapObjTemplate->graphicsId, mapObjTemplate->movementType, sprTemplate, subspriteTables); +} + +u8 AddPseudoFieldObject(u16 graphicsId, void (*callback)(struct Sprite *), s16 c, s16 d, u8 subpriority) +{ + struct SpriteTemplate spriteTemplate; + const struct SubspriteTable *subspriteTables; + u8 spriteId; + + MakeObjectTemplateFromFieldObjectGraphicsInfo(graphicsId, callback, &spriteTemplate, &subspriteTables); + if (spriteTemplate.paletteTag != 0xFFFF) + sub_805BDF8(spriteTemplate.paletteTag); + spriteId = CreateSprite(&spriteTemplate, c, d, subpriority); + if (spriteId != 64 && subspriteTables != NULL) + { + SetSubspriteTables(&gSprites[spriteId], subspriteTables); + gSprites[spriteId].subspriteMode = 2; + } + return spriteId; +} + +extern void sub_8064970(struct Sprite *); +extern void sub_8060470(s16 *, s16 *, s16, s16); +extern void InitObjectPriorityByZCoord(); + +u8 sub_805B410(u8 a, u8 b, s16 c, s16 d, u8 e, u8 f) +{ + const struct MapObjectGraphicsInfo *gfxInfo; + struct SpriteTemplate spriteTemplate; + const struct SubspriteTable *subspriteTables; + u8 spriteId; + + gfxInfo = GetFieldObjectGraphicsInfo(a); + MakeObjectTemplateFromFieldObjectGraphicsInfo(a, sub_8064970, &spriteTemplate, &subspriteTables); +#ifdef NONMATCHING + spriteTemplate.paletteTag = 0xFFFF; +#else + *(u16 *)&spriteTemplate.paletteTag = 0xFFFF; +#endif + c += 7; + d += 7; + sub_8060470(&c, &d, 8, 16); + spriteId = CreateSpriteAtEnd(&spriteTemplate, c, d, 0); + if (spriteId != 64) + { + struct Sprite *sprite = &gSprites[spriteId]; + + sprite->centerToCornerVecX = -(gfxInfo->width >> 1); + sprite->centerToCornerVecY = -(gfxInfo->height >> 1); + sprite->pos1.y += sprite->centerToCornerVecY; + sprite->oam.paletteNum = gfxInfo->paletteSlot; + sprite->coordOffsetEnabled = TRUE; + sprite->data0 = b; + sprite->data1 = e; + if (gfxInfo->paletteSlot == 10) + npc_load_two_palettes__and_record(gfxInfo->paletteTag1, gfxInfo->paletteSlot); + if (subspriteTables != NULL) + { + SetSubspriteTables(sprite, subspriteTables); + sprite->subspriteMode = 2; + } + InitObjectPriorityByZCoord(sprite, e); + SetObjectSubpriorityByZCoord(e, sprite, 1); + StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(f)); + } + return spriteId; +} + +void sub_805B55C(s16 a, s16 b) +{ + u8 i; + + if (gMapHeader.events != NULL) + { + s16 r9 = gSaveBlock1.pos.x - 2; + s16 sp8 = gSaveBlock1.pos.x + 17; + s16 r10 = gSaveBlock1.pos.y; + s16 spC = gSaveBlock1.pos.y + 16; + u8 objectCount = gMapHeader.events->mapObjectCount; + + for (i = 0; i < objectCount; i++) + { + struct MapObjectTemplate *template = &gSaveBlock1.mapObjectTemplates[i]; + s16 foo = template->x + 7; + s16 bar = template->y + 7; + + if (r10 <= bar && spC >= bar && r9 <= foo && sp8 >= foo + && !FlagGet(template->flagId)) + SpawnFieldObject(template, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, a, b); + } + } +} + +void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject); + +void RemoveFieldObjectsOutsideView(void) +{ + u8 i; + u8 j; + + for (i = 0; i < 16; i++) + { + bool8 isActiveLinkPlayer; + + for (j = 0, isActiveLinkPlayer = 0; j < 4; j++) + { + if (gLinkPlayerMapObjects[j].active && i == gLinkPlayerMapObjects[j].mapObjId) + isActiveLinkPlayer = TRUE; + } + if (!isActiveLinkPlayer) + { + struct MapObject *mapObject = &gMapObjects[i]; + + if (mapObject->active && !mapObject->mapobj_bit_16) + RemoveFieldObjectIfOutsideView(mapObject); + } + } +} + +void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject) +{ + s16 r7 = gSaveBlock1.pos.x - 2; + s16 r5 = gSaveBlock1.pos.x + 17; + s16 r4 = gSaveBlock1.pos.y; + s16 r6 = gSaveBlock1.pos.y + 16; + + if (mapObject->coords2.x >= r7 && mapObject->coords2.x <= r5 + && mapObject->coords2.y >= r4 && mapObject->coords2.y <= r6) + return; + if (mapObject->coords1.x >= r7 && mapObject->coords1.x <= r5 + && mapObject->coords1.y >= r4 && mapObject->coords1.y <= r6) + return; + RemoveFieldObject(mapObject); +} + +void sub_805B75C(u8, s16, s16); + +void sub_805B710(u16 a, u16 b) +{ + u8 i; + + ClearPlayerAvatarInfo(); + for (i = 0; i < 16; i++) + { + if (gMapObjects[i].active) + sub_805B75C(i, a, b); + } + sub_805AAB0(); +} + +extern void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); +extern void sub_805B914(struct MapObject *); + +void sub_805B75C(u8 a, s16 b, s16 c) +{ + struct SpriteTemplate sp0; + struct SpriteFrameImage sp18; + const struct SubspriteTable *subspriteTables; + const struct MapObjectGraphicsInfo *gfxInfo; + struct MapObject *mapObject; + u8 spriteId; + + #define i spriteId + for (i = 0; i < 4; i++) + { + if (gLinkPlayerMapObjects[i].active && a == gLinkPlayerMapObjects[i].mapObjId) + return; + } + #undef i + + mapObject = &gMapObjects[a]; + asm("":::"r5"); + subspriteTables = NULL; + gfxInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); + sp18.size = gfxInfo->size; + MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(mapObject->graphicsId, mapObject->animPattern, &sp0, &subspriteTables); + sp0.images = &sp18; + *(u16 *)&sp0.paletteTag = 0xFFFF; + if (gfxInfo->paletteSlot == 0) + npc_load_two_palettes__no_record(gfxInfo->paletteTag1, gfxInfo->paletteSlot); + if (gfxInfo->paletteSlot > 9) + npc_load_two_palettes__and_record(gfxInfo->paletteTag1, gfxInfo->paletteSlot); + *(u16 *)&sp0.paletteTag = 0xFFFF; + spriteId = CreateSprite(&sp0, 0, 0, 0); + if (spriteId != 64) + { + struct Sprite *sprite = &gSprites[spriteId]; + + sub_8060388(b + mapObject->coords2.x, c + mapObject->coords2.y, &sprite->pos1.x, &sprite->pos1.y); + sprite->centerToCornerVecX = -(gfxInfo->width >> 1); + sprite->centerToCornerVecY = -(gfxInfo->height >> 1); + sprite->pos1.x += 8; + sprite->pos1.y += 16 + sprite->centerToCornerVecY; + sprite->images = gfxInfo->images; + if (mapObject->animPattern == 11) + { + SetPlayerAvatarFieldObjectIdAndObjectId(a, spriteId); + mapObject->mapobj_unk_1B = sub_8126B54(); + } + if (subspriteTables != NULL) + SetSubspriteTables(sprite, subspriteTables); + sprite->oam.paletteNum = gfxInfo->paletteSlot; + sprite->coordOffsetEnabled = TRUE; + sprite->data0 = a; + mapObject->spriteId = spriteId; + if (!mapObject->mapobj_bit_12 && mapObject->animPattern != 11) + StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(mapObject->mapobj_unk_18)); + sub_805B914(mapObject); + SetObjectSubpriorityByZCoord(mapObject->elevation, sprite, 1); + } +} + +void sub_805B914(struct MapObject *mapObject) +{ + mapObject->mapobj_bit_1 = FALSE; + mapObject->mapobj_bit_2 = TRUE; + mapObject->mapobj_bit_22 = FALSE; + mapObject->mapobj_bit_17 = FALSE; + mapObject->mapobj_bit_18 = FALSE; + mapObject->mapobj_bit_19 = FALSE; + mapObject->mapobj_bit_20 = FALSE; + mapObject->mapobj_bit_21 = FALSE; + FieldObjectClearAnim(mapObject); +} + +void SetPlayerAvatarFieldObjectIdAndObjectId(u8 mapObjectId, u8 spriteId) +{ + gPlayerAvatar.mapObjectId = mapObjectId; + gPlayerAvatar.spriteId = spriteId; + gPlayerAvatar.gender = GetPlayerAvatarGenderByGraphicsId(gMapObjects[mapObjectId].graphicsId); + SetPlayerAvatarExtraStateTransition(gMapObjects[mapObjectId].graphicsId, 0x20); +} + +void sub_805B980(struct MapObject *mapObject, u8 graphicsId) +{ + const struct MapObjectGraphicsInfo *gfxInfo; + struct Sprite *sprite; + + gfxInfo = GetFieldObjectGraphicsInfo(graphicsId); + sprite = &gSprites[mapObject->spriteId]; + if (gfxInfo->paletteSlot == 0) + pal_patch_for_npc(gfxInfo->paletteTag1, gfxInfo->paletteSlot); + if (gfxInfo->paletteSlot == 10) + npc_load_two_palettes__and_record(gfxInfo->paletteTag1, gfxInfo->paletteSlot); + sprite->oam.shape = gfxInfo->oam->shape; + sprite->oam.size = gfxInfo->oam->size; + sprite->images = gfxInfo->images; + sprite->anims = gfxInfo->anims; + sprite->subspriteTables = gfxInfo->subspriteTables; + sprite->oam.paletteNum = gfxInfo->paletteSlot; + mapObject->mapobj_bit_12 = gfxInfo->inanimate; + mapObject->graphicsId = graphicsId; + sub_80603CC(mapObject->coords2.x, mapObject->coords2.y, &sprite->pos1.x, &sprite->pos1.y); + sprite->centerToCornerVecX = -(gfxInfo->width >> 1); + sprite->centerToCornerVecY = -(gfxInfo->height >> 1); + sprite->pos1.x += 8; + sprite->pos1.y += 16 + sprite->centerToCornerVecY; + if (mapObject->mapobj_bit_15) + CameraObjectReset1(); +} + +void unref_sub_805BA80(u8 localId, u8 mapNum, u8 mapGroup, u8 graphicsId) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + sub_805B980(&gMapObjects[mapObjectId], graphicsId); +} + +void FieldObjectTurn(struct MapObject *mapObject, u8 direction) +{ + FieldObjectSetDirection(mapObject, direction); + if (!mapObject->mapobj_bit_12) + { + StartSpriteAnim(&gSprites[mapObject->spriteId], FieldObjectDirectionToImageAnimId(mapObject->mapobj_unk_18)); + SeekSpriteAnim(&gSprites[mapObject->spriteId], 0); + } +} + +void FieldObjectTurnByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 direction) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + FieldObjectTurn(&gMapObjects[mapObjectId], direction); +} + +void unref_TurnPlayer(struct PlayerAvatar *player, u8 direction) +{ + FieldObjectTurn(&gMapObjects[player->mapObjectId], direction); +} + +void get_berry_tree_graphics(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 treeStage; + u8 treeId; + + mapObject->mapobj_bit_13 = TRUE; + sprite->invisible = TRUE; + treeStage = GetStageByBerryTreeId(mapObject->trainerRange_berryTreeId); + if (treeStage != 0) + { + mapObject->mapobj_bit_13 = FALSE; + sprite->invisible = FALSE; + treeId = GetBerryTypeByBerryTreeId(mapObject->trainerRange_berryTreeId) - 1; + treeStage--; + if (treeId > 0x2B) + treeId = 0; + sub_805B980(mapObject, gBerryTreeGraphicsIdTablePointers[treeId][treeStage]); + sprite->images = gBerryTreePicTablePointers[treeId]; + sprite->oam.paletteNum = gBerryTreePaletteSlotTablePointers[treeId][treeStage]; + StartSpriteAnim(sprite, treeStage); + } +} + +const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8 graphicsId) +{ + if (graphicsId > 0xEF) + graphicsId = VarGetFieldObjectGraphicsId(graphicsId + 16); + if (graphicsId > 0xD9) + graphicsId = 5; + return gMapObjectGraphicsInfoPointers[graphicsId]; +} + +void FieldObjectHandleDynamicGraphicsId(struct MapObject *mapObject) +{ + if (mapObject->graphicsId > 0xEF) + mapObject->graphicsId = VarGetFieldObjectGraphicsId(mapObject->graphicsId + 16); +} + +void npc_by_local_id_and_map_set_field_1_bit_x20(u8 localId, u8 mapNum, u8 mapGroup, u8 d) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + gMapObjects[mapObjectId].mapobj_bit_13 = d; +} + +void FieldObjectGetLocalIdAndMap(struct MapObject *mapObject, u8 *localId, u8 *mapNum, u8 *mapGroup) +{ + *localId = mapObject->localId; + *mapNum = mapObject->mapNum; + *mapGroup = mapObject->mapGroup; +} + +void sub_805BCC0(s16 x, s16 y) +{ + u8 mapObjectId; + struct MapObject *mapObject; + + mapObjectId = GetFieldObjectIdByXY(x, y); + if (mapObjectId != 16) + { + mapObject = &gMapObjects[mapObjectId]; + mapObject->mapobj_bit_2 = TRUE; + } +} + +void sub_805BCF0(u8 localId, u8 mapNum, u8 mapGroup, u8 subpriority) +{ + u8 mapObjectId; + struct MapObject *mapObject; + struct Sprite *sprite; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + mapObject = &gMapObjects[mapObjectId]; + sprite = &gSprites[mapObject->spriteId]; + mapObject->mapobj_bit_26 = TRUE; + sprite->subpriority = subpriority; + } +} + +void sub_805BD48(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + struct MapObject *mapObject; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + mapObject = &gMapObjects[mapObjectId]; + mapObject->mapobj_bit_26 = FALSE; + mapObject->mapobj_bit_2 = TRUE; + } +} + +void sub_805BD90(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y) +{ + u8 mapObjectId; + struct Sprite *sprite; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + sprite = &gSprites[gMapObjects[mapObjectId].spriteId]; + sprite->pos2.x = x; + sprite->pos2.y = y; + } +} + +void gpu_pal_allocator_reset__manage_upper_four(void) +{ + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 12; +} + +void sub_805BDF8(u16 tag) +{ + u16 paletteIndex = FindFieldObjectPaletteIndexByTag(tag); + + if (paletteIndex != 0x11FF) //always happens. FindFieldObjectPaletteIndexByTag returns u8 + sub_805BE58(&gUnknown_0837377C[paletteIndex]); +} + +void unref_sub_805BE24(u16 *arr) +{ + u8 i; + + for (i = 0; arr[i] != 0x11FF; i++) + sub_805BDF8(arr[i]); +} + +u8 sub_805BE58(const struct SpritePalette *palette) +{ + if (IndexOfSpritePaletteTag(palette->tag) != 0xFF) + return 0xFF; + else + return LoadSpritePalette(palette); +} + +void pal_patch_for_npc(u16 a, u16 b) +{ + u8 var = b; + u8 paletteIndex = FindFieldObjectPaletteIndexByTag(a); + + LoadPalette(gUnknown_0837377C[paletteIndex].data, var * 16 + 0x100, 0x20); +} + +void pal_patch_for_npc_range(const u16 *arr, u8 b, u8 c) +{ + for (; b < c; arr++, b++) + pal_patch_for_npc(*arr, b); +} + +u8 FindFieldObjectPaletteIndexByTag(u16 tag) +{ + u8 i; + + for (i = 0; gUnknown_0837377C[i].tag != 0x11FF; i++) + { + if (gUnknown_0837377C[i].tag == tag) + return i; + } + return 0xFF; +} + +void npc_load_two_palettes__no_record(u16 a, u8 b) +{ + u8 i; + + pal_patch_for_npc(a, b); + for (i = 0; gUnknown_08373874[i].tag != 0x11FF; i++) + { + if (gUnknown_08373874[i].tag == a) + { + pal_patch_for_npc(gUnknown_08373874[i].data[gUnknown_030005A4], gUnknown_0830FD14[b]); + break; + } + } +} + +void npc_load_two_palettes__and_record(u16 a, u8 b) +{ + u8 i; + + gUnknown_030005A6 = a; + pal_patch_for_npc(a, b); + for (i = 0; gUnknown_083738E4[i].tag != 0x11FF; i++) + { + if (gUnknown_083738E4[i].tag == a) + { + pal_patch_for_npc(gUnknown_083738E4[i].data[gUnknown_030005A4], gUnknown_0830FD14[b]); + break; + } + } +} + +void unref_sub_805C014(struct MapObject *mapObject, s16 x, s16 y) +{ + mapObject->coords3.x = mapObject->coords2.x; + mapObject->coords3.y = mapObject->coords2.y; + mapObject->coords2.x += x; + mapObject->coords2.y += y; +} + +void npc_coords_shift(struct MapObject *mapObject, s16 x, s16 y) +{ + mapObject->coords3.x = mapObject->coords2.x; + mapObject->coords3.y = mapObject->coords2.y; + mapObject->coords2.x = x; + mapObject->coords2.y = y; +} + +void npc_coords_set(struct MapObject *mapObject, s16 x, s16 y) +{ + mapObject->coords3.x = x; + mapObject->coords3.y = y; + mapObject->coords2.x = x; + mapObject->coords2.y = y; +} + +void sub_805C058(struct MapObject *mapObject, s16 x, s16 y) +{ + struct Sprite *sprite = &gSprites[mapObject->spriteId]; + const struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); + + npc_coords_set(mapObject, x, y); + sub_80603CC(mapObject->coords2.x, mapObject->coords2.y, &sprite->pos1.x, &sprite->pos1.y); + sprite->centerToCornerVecX = -(gfxInfo->width >> 1); + sprite->centerToCornerVecY = -(gfxInfo->height >> 1); + sprite->pos1.x += 8; + sprite->pos1.y += 16 + sprite->centerToCornerVecY; + sub_805B914(mapObject); + if (mapObject->mapobj_bit_15) + CameraObjectReset1(); +} + +void sub_805C0F8(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + x += 7; + y += 7; + sub_805C058(&gMapObjects[mapObjectId], x, y); + } +} + +void npc_coords_shift_still(struct MapObject *mapObject) +{ + npc_coords_shift(mapObject, mapObject->coords2.x, mapObject->coords2.y); +} + +void UpdateFieldObjectCoordsForCameraUpdate(void) +{ + u8 i; + s16 deltaX; + s16 deltaY; + +#ifndef NONMATCHING + asm(""::"r"(i)); //makes the compiler store i in r3 +#endif + + if (gUnknown_0202E844.field_0) + { + for (i = 0, deltaX = gUnknown_0202E844.x, deltaY = gUnknown_0202E844.y; i < 16; i++) + { + struct MapObject *mapObject = &gMapObjects[i]; + + if (mapObject->active) + { + mapObject->coords1.x -= deltaX; + mapObject->coords1.y -= deltaY; + mapObject->coords2.x -= deltaX; + mapObject->coords2.y -= deltaY; + mapObject->coords3.x -= deltaX; + mapObject->coords3.y -= deltaY; + } + } + } +} + +bool8 FieldObjectDoesZCoordMatch(struct MapObject *, u8); + +u8 GetFieldObjectIdByXYZ(u16 x, u16 y, u8 z) +{ + u8 i; + + for (i = 0; i < 16; i++) + { + if (gMapObjects[i].active && gMapObjects[i].coords2.x == x && gMapObjects[i].coords2.y == y + && FieldObjectDoesZCoordMatch(&gMapObjects[i], z)) + return i; + } + return 16; +} + +bool8 FieldObjectDoesZCoordMatch(struct MapObject *mapObject, u8 z) +{ + if (mapObject->mapobj_unk_0B_0 != 0 && z != 0 + && mapObject->mapobj_unk_0B_0 != z) + return FALSE; + else + return TRUE; +} + +void UpdateFieldObjectsForCameraUpdate(s16 x, s16 y) +{ + UpdateFieldObjectCoordsForCameraUpdate(); + sub_805B55C(x, y); + RemoveFieldObjectsOutsideView(); +} + +u8 AddCameraObject(u8 a) +{ + u8 spriteId = CreateSprite(&gSpriteTemplate_830FD24, 0, 0, 4); + + gSprites[spriteId].invisible = TRUE; + gSprites[spriteId].data0 = a; + return spriteId; +} + +void ObjectCB_CameraObject(struct Sprite *sprite) +{ + void (*cameraObjectFuncs[3])(struct Sprite *); + memcpy(cameraObjectFuncs, gCameraObjectFuncs, sizeof gCameraObjectFuncs); + cameraObjectFuncs[sprite->data1](sprite); +} + +void CameraObject_0(struct Sprite *sprite) +{ + sprite->pos1.x = gSprites[sprite->data0].pos1.x; + sprite->pos1.y = gSprites[sprite->data0].pos1.y; + sprite->invisible = TRUE; + sprite->data1 = 1; + CameraObject_1(sprite); +} + +void CameraObject_1(struct Sprite *sprite) +{ + s16 x = gSprites[sprite->data0].pos1.x; + s16 y = gSprites[sprite->data0].pos1.y; + + sprite->data2 = x - sprite->pos1.x; + sprite->data3 = y - sprite->pos1.y; + sprite->pos1.x = x; + sprite->pos1.y = y; +} + +void CameraObject_2(struct Sprite *sprite) +{ + sprite->pos1.x = gSprites[sprite->data0].pos1.x; + sprite->pos1.y = gSprites[sprite->data0].pos1.y; + sprite->data2 = 0; + sprite->data3 = 0; +} + +struct Sprite *FindCameraObject(void) +{ + u8 i; + + for (i = 0; i < 64; i++) + { + if (gSprites[i].inUse && gSprites[i].callback == ObjectCB_CameraObject) + return &gSprites[i]; + } + return NULL; +} + +void CameraObjectReset1(void) +{ + struct Sprite *cameraSprite = FindCameraObject(); + + if (cameraSprite != NULL) + { + cameraSprite->data1 = 0; + cameraSprite->callback(cameraSprite); + } +} + +void CameraObjectSetFollowedObjectId(u8 spriteId) +{ + struct Sprite *cameraSprite = FindCameraObject(); + + if (cameraSprite != NULL) + { + cameraSprite->data0 = spriteId; + CameraObjectReset1(); + } +} + +u8 CameraObjectGetFollowedObjectId(void) +{ + struct Sprite *cameraSprite = FindCameraObject(); + + if (cameraSprite == NULL) + return 64; + else + return cameraSprite->data0; +} + +void CameraObjectReset2(void) +{ + struct Sprite *cameraSprite = FindCameraObject(); + + cameraSprite->data1 = 2; +} + +u8 unref_sub_805C43C(struct Sprite *src, s16 x, s16 y, u8 subpriority) +{ + u8 i; + + for (i = 0; i < 64; i++) + { + if (!gSprites[i].inUse) + { + gSprites[i] = *src; + gSprites[i].pos1.x = x; + gSprites[i].pos1.y = y; + gSprites[i].subpriority = subpriority; + break; + } + } + return i; +} + +u8 obj_unfreeze(struct Sprite *src, s16 x, s16 y, u8 subpriority) +{ + s16 i; + + for (i = 63; i > -1; i--) + { + if (!gSprites[i].inUse) + { + gSprites[i] = *src; + gSprites[i].pos1.x = x; + gSprites[i].pos1.y = y; + gSprites[i].subpriority = subpriority; + return i; + } + } + return 64; +} + +void FieldObjectSetDirection(struct MapObject *mapObject, u8 direction) +{ + mapObject->mapobj_unk_20 = mapObject->mapobj_unk_18; + if (!mapObject->mapobj_bit_9) + { + s8 _direction = direction; //needed for the asm to match + mapObject->mapobj_unk_18 = _direction; + } + mapObject->placeholder18 = direction; +} + +u8 *GetFieldObjectScriptPointerByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + struct MapObjectTemplate *template = GetFieldObjectTemplateByLocalIdAndMap(localId, mapNum, mapGroup); + + return template->script; +} + +u8 *GetFieldObjectScriptPointerByFieldObjectId(u8 mapObjectId) +{ + return GetFieldObjectScriptPointerByLocalIdAndMap(gMapObjects[mapObjectId].localId, gMapObjects[mapObjectId].mapNum, gMapObjects[mapObjectId].mapGroup); +} + +u16 GetFieldObjectFlagIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + struct MapObjectTemplate *template = GetFieldObjectTemplateByLocalIdAndMap(localId, mapNum, mapGroup); + + return template->flagId; +} + +u16 GetFieldObjectFlagIdByFieldObjectId(u8 mapObjectId) +{ + return GetFieldObjectFlagIdByLocalIdAndMap(gMapObjects[mapObjectId].localId, gMapObjects[mapObjectId].mapNum, gMapObjects[mapObjectId].mapGroup); +} + +u8 unref_sub_805C5D0(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + + if (TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + return 0xFF; + else + return gMapObjects[mapObjectId].trainerType; +} + +u8 unref_sub_805C60C(u8 mapObjectId) +{ + return gMapObjects[mapObjectId].trainerType; +} + +u8 unref_sub_805C624(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + + if (TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + return 0xFF; + else + return gMapObjects[mapObjectId].trainerRange_berryTreeId; +} + +u8 FieldObjectGetBerryTreeId(u8 mapObjectId) +{ + return gMapObjects[mapObjectId].trainerRange_berryTreeId; +} + +struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8, struct MapObjectTemplate *, u8); + +struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + if (gSaveBlock1.location.mapNum == mapNum && gSaveBlock1.location.mapGroup == mapGroup) + return FindFieldObjectTemplateInArrayByLocalId(localId, gSaveBlock1.mapObjectTemplates, gMapHeader.events->mapObjectCount); + else + { + struct MapHeader *mapHeader = get_mapheader_by_bank_and_number(mapGroup, mapNum); + + return FindFieldObjectTemplateInArrayByLocalId(localId, mapHeader->events->mapObjects, mapHeader->events->mapObjectCount); + } +} + +struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, struct MapObjectTemplate *templates, u8 count) +{ + u8 i; + + for (i = 0; i < count; i++) + { + if (templates[i].localId == localId) + return &templates[i]; + } + return NULL; +} + +struct MapObjectTemplate *sub_805C700(struct MapObject *mapObject) +{ + s32 i; + + if (mapObject->mapNum != gSaveBlock1.location.mapNum + || mapObject->mapGroup != gSaveBlock1.location.mapGroup) + return NULL; + + for (i = 0; i < 64; i++) + { + if (mapObject->localId == gSaveBlock1.mapObjectTemplates[i].localId) + return &gSaveBlock1.mapObjectTemplates[i]; + } + return NULL; +} + +void sub_805C754(struct MapObject *mapObject) +{ + struct MapObjectTemplate *template = sub_805C700(mapObject); + + if (template != NULL) + { + template->x = mapObject->coords2.x - 7; + template->y = mapObject->coords2.y - 7; + } +} + +void sub_805C774(struct MapObject *mapObject, u8 movementType) +{ + struct MapObjectTemplate *template = sub_805C700(mapObject); + + if (template != NULL) + template->movementType = movementType; +} + +void sub_805C78C(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + sub_805C754(&gMapObjects[mapObjectId]); +} + +void sub_805C7C4(u8 a) +{ + gpu_pal_allocator_reset__manage_upper_four(); + gUnknown_030005A6 = 0x11FF; + gUnknown_030005A4 = a; + pal_patch_for_npc_range(gUnknown_0837399C[gUnknown_030005A4], 0, 10); +} + +u16 npc_paltag_by_palslot(u8 a) +{ + u8 i; + + if (a < 10) + return gUnknown_0837399C[gUnknown_030005A4][a]; + + for (i = 0; gUnknown_083738E4[i].tag != 0x11FF; i++) + { + if (gUnknown_083738E4[i].tag == gUnknown_030005A6) + { + return gUnknown_083738E4[i].data[gUnknown_030005A4]; + } + } + return 0x11FF; +} + +fieldmap_object_null_cb(sub_805C884, sub_805C8A8); +fieldmap_object_cb(sub_805C8AC, sub_805C8D0, gUnknown_08375224); + +u8 sub_805C8F0(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +extern void FieldObjectSetRegularAnim(struct MapObject *, struct Sprite *, u8); + +u8 sub_805C904(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +extern u8 FieldObjectExecRegularAnim(struct MapObject *, struct Sprite *); +extern void sub_8064820(struct Sprite *, s16); + +u8 sub_805C930(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite) == 0) + { + return 0; + } + sub_8064820(sprite, gUnknown_0837520C[Random() & 3]); + sprite->data1 = 3; + return 1; +} + +extern u8 sub_8064824(struct Sprite *); + +u8 sub_805C96C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) != 0) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +extern u8 sub_805FF20(struct MapObject *, u8); + +u8 sub_805C98C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[4]; + memcpy(directions, gUnknown_08375240, 4); + direction = directions[Random() & 3]; + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 5; + if (sub_805FF20(mapObject, direction) != 0) + { + sprite->data1 = 1; + } + return 1; +} + +u8 sub_805C9D8(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetGoSpeed0AnimId(mapObject->placeholder18)); + mapObject->mapobj_bit_1 = 1; + sprite->data1 = 6; + return 1; +} + +u8 sub_805CA08(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite) != 0) + { + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 1; + } + return 0; +} + +u8 FieldObjectIsTrainerAndCloseToPlayer(struct MapObject *mapObject) +{ + s16 x; + s16 y; + s16 objx; + s16 objy; + s16 minx; + s16 maxx; + s16 miny; + s16 maxy; + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH) == 0) + { + return 0; + } + if (mapObject->trainerType != 1 && mapObject->trainerType != 3) + { + return 0; + } + PlayerGetDestCoords(&x, &y); + objx = mapObject->coords2.x; + objy = mapObject->coords2.y; + minx = objx - mapObject->trainerRange_berryTreeId; + miny = objy - mapObject->trainerRange_berryTreeId; + maxx = objx + mapObject->trainerRange_berryTreeId; + maxy = objy + mapObject->trainerRange_berryTreeId; + if (minx > x || maxx < x || miny > y || maxy < y) + { + return 0; + } + return 1; +} + +u8 sub_805CAAC(s16 a0, s16 a1, s16 a2, s16 a3) +{ + u8 dirn; + if (a2 > a3) + { + dirn = DIR_EAST; + if (a0 < 0) + { + dirn = DIR_WEST; + } + } + else + { + dirn = DIR_SOUTH; + if (a1 < 0) + { + dirn = DIR_NORTH; + } + } + return dirn; +} + +u8 sub_805CADC(s16 a0, s16 a1, s16 a2, s16 a3) +{ + u8 dirn; + dirn = DIR_SOUTH; + if (a1 < 0) + { + dirn = DIR_NORTH; + } + return dirn; +} + +u8 sub_805CAEC(s16 a0, s16 a1, s16 a2, s16 a3) +{ + u8 dirn; + dirn = DIR_EAST; + if (a0 < 0) + { + dirn = DIR_WEST; + } + return dirn; +} + +u8 sub_805CB00(s16 a0, s16 a1, s16 a2, s16 a3) +{ + u8 dirn; + dirn = sub_805CAAC(a0, a1, a2, a3); + if (dirn == DIR_SOUTH) + { + dirn = sub_805CAEC(a0, a1, a2, a3); + if (dirn == DIR_EAST) + { + dirn = DIR_NORTH; + } + } + else if (dirn == DIR_EAST) + { + dirn = sub_805CADC(a0, a1, a2, a3); + if (dirn == DIR_SOUTH) + { + dirn = DIR_NORTH; + } + } + return dirn; +} + +u8 sub_805CB5C(s16 a0, s16 a1, s16 a2, s16 a3) +{ + u8 dirn; + dirn = sub_805CAAC(a0, a1, a2, a3); + if (dirn == DIR_SOUTH) + { + dirn = sub_805CAEC(a0, a1, a2, a3); + if (dirn == DIR_WEST) + { + dirn = DIR_NORTH; + } + } + else if (dirn == DIR_WEST) + { + dirn = sub_805CADC(a0, a1, a2, a3); + if (dirn == DIR_SOUTH) + { + dirn = DIR_NORTH; + } + } + return dirn; +} + +u8 sub_805CBB8(s16 a0, s16 a1, s16 a2, s16 a3) +{ + u8 dirn; + dirn = sub_805CAAC(a0, a1, a2, a3); + if (dirn == DIR_NORTH) + { + dirn = sub_805CAEC(a0, a1, a2, a3); + if (dirn == DIR_EAST) + { + dirn = DIR_SOUTH; + } + } + else if (dirn == DIR_EAST) + { + dirn = sub_805CADC(a0, a1, a2, a3); + if (dirn == DIR_NORTH) + { + dirn = DIR_SOUTH; + } + } + return dirn; +} + +u8 sub_805CC14(s16 a0, s16 a1, s16 a2, s16 a3) { + u8 dirn; + dirn = sub_805CAAC(a0, a1, a2, a3); + if (dirn == DIR_NORTH) + { + dirn = sub_805CAEC(a0, a1, a2, a3); + if (dirn == DIR_WEST) + { + dirn = DIR_SOUTH; + } + } + else if (dirn == DIR_WEST) + { + dirn = sub_805CADC(a0, a1, a2, a3); + if (dirn == DIR_NORTH) + { + dirn = DIR_SOUTH; + } + } + return dirn; +} + +u8 sub_805CC70(s16 a0, s16 a1, s16 a2, s16 a3) +{ + u8 dirn; + dirn = sub_805CAAC(a0, a1, a2, a3); + if (dirn == DIR_EAST) + { + dirn = sub_805CADC(a0, a1, a2, a3); + } + return dirn; +} + +u8 sub_805CCAC(s16 a0, s16 a1, s16 a2, s16 a3) +{ + u8 dirn; + dirn = sub_805CAAC(a0, a1, a2, a3); + if (dirn == DIR_WEST) + { + dirn = sub_805CADC(a0, a1, a2, a3); + } + return dirn; +} + +u8 sub_805CCE8(s16 a0, s16 a1, s16 a2, s16 a3) +{ + u8 dirn; + dirn = sub_805CAAC(a0, a1, a2, a3); + if (dirn == DIR_SOUTH) + { + dirn = sub_805CAEC(a0, a1, a2, a3); + } + return dirn; +} + +u8 sub_805CD24(s16 a0, s16 a1, s16 a2, s16 a3) +{ + u8 dirn; + dirn = sub_805CAAC(a0, a1, a2, a3); + if (dirn == DIR_NORTH) + { + dirn = sub_805CAEC(a0, a1, a2, a3); + } + return dirn; +} + +u8 sub_805CD60(struct MapObject *mapObject, u8 a1) +{ + s16 x; + s16 y; + s16 x2; + s16 y2; + if (!FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + return 0; + } + PlayerGetDestCoords(&x, &y); + x -= mapObject->coords2.x; + y -= mapObject->coords2.y; + x2 = x; + y2 = y; + if (x2 < 0) + { + x2 = -x2; + } + if (y2 < 0) + { + y2 = -y2; + } + return gUnknown_08375244[a1](x, y, x2, y2); +} + +fieldmap_object_cb(sub_805CDE8, sub_805CE0c, gUnknown_08375270); + +u8 sub_805CE2C(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805CE40(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805CE6C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite) != 0) + { + sub_8064820(sprite, gUnknown_0837520C[Random() & 3]); + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805CEB0(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805CEE0(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[4]; + memcpy(directions, gUnknown_08375240, 4); + direction = sub_805CD60(mapObject, 0); + if (direction == 0) + { + direction = directions[Random() & 3]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805CF28, sub_805CF4C, gUnknown_08375284); + +u8 sub_805CF6C(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805CF80(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805CFAC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite) == 0) + { + return 0; + } + sub_8064820(sprite, gUnknown_0837520C[Random() & 3]); + sprite->data1 = 3; + return 1; +} + +u8 sub_805CFE8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) != 0) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805D008(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[2]; + memcpy(directions, gUnknown_083752A0, 2); + direction = directions[Random() & 1]; + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 5; + if (sub_805FF20(mapObject, direction) != 0) + { + sprite->data1 = 1; + } + return 1; +} + +u8 sub_805D054(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetGoSpeed0AnimId(mapObject->placeholder18)); + mapObject->mapobj_bit_1 = 1; + sprite->data1 = 6; + return 1; +} + +u8 sub_805D084(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite) != 0) + { + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 1; + } + return 0; +} + +fieldmap_object_cb(sub_805D0AC, sub_805D0D0, gUnknown_083752A4); + +u8 sub_805D0F0(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805D104(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805D130(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite) == 0) + { + return 0; + } + sub_8064820(sprite, gUnknown_0837520C[Random() & 3]); + sprite->data1 = 3; + return 1; +} + +u8 sub_805D16C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) != 0) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805D18C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[2]; + memcpy(directions, gUnknown_083752C0, 2); + direction = directions[Random() & 1]; + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 5; + if (sub_805FF20(mapObject, direction) != 0) + { + sprite->data1 = 1; + } + return 1; +} + +u8 sub_805D1D8(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetGoSpeed0AnimId(mapObject->placeholder18)); + mapObject->mapobj_bit_1 = 1; + sprite->data1 = 6; + return 1; +} + +u8 sub_805D208(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite) != 0) + { + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 1; + } + return 0; +} + +fieldmap_object_cb(sub_805D230, sub_805D254, gUnknown_083752C4); + +u8 sub_805D274(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return 1; +} + +u8 sub_805D2A0(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite) != 0) + { + sprite->data1 = 2; + return 1; + } + return 0; +} + +u8 sub_805D2C0(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_1 = 0; + return 0; +} + +u8 sub_805D314(struct MapObject *mapObject, struct Sprite *sprite); + +void FieldObjectCB_BerryTree(struct Sprite *sprite) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[sprite->data0]; + if (!(sprite->data7 & 1)) + { + get_berry_tree_graphics(mapObject, sprite); + sprite->data7 |= 1; + } + meta_step(mapObject, sprite, sub_805D314); +} + +u8 sub_805D314(struct MapObject *mapObject, struct Sprite *sprite) +{ + return gUnknown_083752D0[sprite->data1](mapObject, sprite); +} + +extern u32 gUnknown_0202FF84[]; + +u8 do_berry_tree_growth_sparkle_1(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 berryTreeStage; + npc_reset(mapObject, sprite); + mapObject->mapobj_bit_13 = 1; + sprite->invisible = 1; + berryTreeStage = GetStageByBerryTreeId(mapObject->trainerRange_berryTreeId); + if (!berryTreeStage) + { + if (!(sprite->data7 & 4) && sprite->animNum == 4) + { + gUnknown_0202FF84[0] = mapObject->coords2.x; + gUnknown_0202FF84[1] = mapObject->coords2.y; + gUnknown_0202FF84[2] = sprite->subpriority - 1; + gUnknown_0202FF84[3] = sprite->oam.priority; + FieldEffectStart(0x17); + sprite->animNum = 0; + } + return 0; + } + mapObject->mapobj_bit_13 = 0; + sprite->invisible = 0; + berryTreeStage--; + if (sprite->animNum != berryTreeStage) + { + sprite->data1 = 2; + return 1; + } + get_berry_tree_graphics(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, 0x39); + sprite->data1 = 1; + return 1; +} + +u8 sub_805D3EC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sprite->data1 = 0; + return 1; + } + return 0; +} + +u8 do_berry_tree_growth_sparkle_2(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_1 = 1; + sprite->data1 = 3; + sprite->data2 = 0; + sprite->data7 |= 2; + gUnknown_0202FF84[0] = mapObject->coords2.x; + gUnknown_0202FF84[1] = mapObject->coords2.y; + gUnknown_0202FF84[2] = sprite->subpriority - 1; + gUnknown_0202FF84[3] = sprite->oam.priority; + FieldEffectStart(0x17); + return 1; +} + +u8 sub_805D458(struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->data2++; + mapObject->mapobj_bit_13 = ((sprite->data2 & 0x2) >> 1); + sprite->animPaused = 1; + if (sprite->data2 > 64) + { + get_berry_tree_graphics(mapObject, sprite); + sprite->data1 = 4; + sprite->data2 = 0; + return 1; + } + return 0; +} + +u8 sub_805D4A8(struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->data2++; + mapObject->mapobj_bit_13 = ((sprite->data2 & 0x2) >> 1); + sprite->animPaused = 1; + if (sprite->data2 > 64) + { + sprite->data1 = 0; + sprite->data7 &= (-3); + return 1; + } + return 0; +} + +fieldmap_object_cb(sub_805D4F4, sub_805D518, gUnknown_083752E4); + +u8 sub_805D538(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805D54C(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805D578(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, gUnknown_0837520C[Random() & 3]); + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805D5BC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805D5EC(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[2]; + memcpy(directions, gUnknown_083752A0, 2); + direction = sub_805CD60(mapObject, 1); + if (direction == 0) + { + direction = directions[Random() & 1]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805D634, sub_805D658, gUnknown_083752F8); + +u8 sub_805D678(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805D68C(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805D6B8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, gUnknown_0837520C[Random() & 3]); + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805D6FC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805D72C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[2]; + memcpy(directions, gUnknown_083752C0, 2); + direction = sub_805CD60(mapObject, 2); + if (direction == 0) + { + direction = directions[Random() & 1]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805D774, sub_805D798, gUnknown_0837530C); + +u8 sub_805D7B8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805D7CC(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805D7F8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, gUnknown_0837521C[Random() & 3]); + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805D83C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805D86C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[2]; + memcpy(directions, gUnknown_08375320, 2); + direction = sub_805CD60(mapObject, 3); + if (direction == 0) + { + direction = directions[Random() & 1]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805D8B4, sub_805D8D8, gUnknown_08375324); + +u8 sub_805D8F8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805D90C(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805D938(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, gUnknown_0837521C[Random() & 3]); + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805D97C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805D9AC(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[2]; + memcpy(directions, gUnknown_08375338, 2); + direction = sub_805CD60(mapObject, 4); + if (direction == 0) + { + direction = directions[Random() & 1]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805D9F4, sub_805DA18, gUnknown_0837533C); + +u8 sub_805DA38(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805DA4C(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805DA78(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, gUnknown_0837521C[Random() & 3]); + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805DABC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805DAEC(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[2]; + memcpy(directions, gUnknown_08375350, 2); + direction = sub_805CD60(mapObject, 5); + if (direction == 0) + { + direction = directions[Random() & 1]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805DB34, sub_805DB58, gUnknown_08375354); + +u8 sub_805DB78(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805DB8C(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805DBB8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, gUnknown_0837521C[Random() & 3]); + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805DBFC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805DC2C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[2]; + memcpy(directions, gUnknown_08375368, 2); + direction = sub_805CD60(mapObject, 6); + if (direction == 0) + { + direction = directions[Random() & 1]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805DC74, sub_805DC98, gUnknown_0837536C); + +u8 sub_805DCB8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805DCCC(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805DCF8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, gUnknown_0837521C[Random() & 3]); + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805DD3C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805DD6C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[4]; + memcpy(directions, gUnknown_08375380, 4); + direction = sub_805CD60(mapObject, 7); + if (direction == 0) + { + direction = directions[Random() & 3]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805DDB4, sub_805DDD8, gUnknown_08375384); + +u8 sub_805DDF8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805DE0C(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805DE38(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, gUnknown_0837521C[Random() & 3]); + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805DE7C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805DEAC(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[4]; + memcpy(directions, gUnknown_08375398, 4); + direction = sub_805CD60(mapObject, 8); + if (direction == 0) + { + direction = directions[Random() & 3]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805DEF4, sub_805DF18, gUnknown_0837539C); + +u8 sub_805DF38(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805DF4C(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805DF78(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, gUnknown_0837521C[Random() & 3]); + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805DFBC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805DFEC(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[4]; + memcpy(directions, gUnknown_083753B0, 4); + direction = sub_805CD60(mapObject, 9); + if (direction == 0) + { + direction = directions[Random() & 3]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805E034, sub_805E058, gUnknown_083753B4); + +u8 sub_805E078(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805E08C(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return 1; +} + +u8 sub_805E0B8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, gUnknown_0837521C[Random() & 3]); + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805E0FC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return 1; + } + return 0; +} + +u8 sub_805E12C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[4]; + memcpy(directions, gUnknown_083753C8, 4); + direction = sub_805CD60(mapObject, 10); + if (direction == 0) + { + direction = directions[Random() & 3]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805E174, sub_805E198, gUnknown_083753CC); + +u8 sub_805E1B8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return 1; +} + +u8 sub_805E1E4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, 0x30); + sprite->data1 = 2; + } + return 0; +} + +u8 sub_805E208(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805E234(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[5]; + memcpy(directions, gUnknown_083753DC, 5); + direction = sub_805CD60(mapObject, 0); + if (direction == 0) + { + direction = directions[mapObject->mapobj_unk_18]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 0; + return 1; +} + +fieldmap_object_cb(sub_805E278, sub_803E29C, gUnknown_083753E4); + +u8 sub_805E2BC(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return 1; +} + +u8 sub_805E2E8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8064820(sprite, 0x30); + sprite->data1 = 2; + } + return 0; +} + +u8 sub_805E30C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064824(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 3; + } + return 0; +} + +u8 sub_805E338(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + u8 directions[5]; + memcpy(directions, gUnknown_083753F4, 5); + direction = sub_805CD60(mapObject, 0); + if (direction == 0) + { + direction = directions[mapObject->mapobj_unk_18]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 0; + return 1; +} + +fieldmap_object_cb(sub_805E37C, sub_805E3A0, gUnknown_083753FC); + +u8 sub_805E3C0(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 sub_805E3D4(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + direction = gUnknown_0836DC09[mapObject->animPattern]; + if (mapObject->mapobj_unk_21 != 0) + { + direction = GetOppositeDirection(direction); + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 2; + return 1; +} + +u8 sub_805E40C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 v0; + u8 goSpeed0AnimId; + if (mapObject->mapobj_unk_21 && mapObject->coords1.x == mapObject->coords2.x && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 0; + FieldObjectSetDirection(mapObject, GetOppositeDirection(mapObject->placeholder18)); + } + v0 = sub_805FF20(mapObject, mapObject->placeholder18); + goSpeed0AnimId = GetGoSpeed0AnimId(mapObject->placeholder18); + if (v0 == 1) + { + mapObject->mapobj_unk_21 ++; + FieldObjectSetDirection(mapObject, GetOppositeDirection(mapObject->placeholder18)); + goSpeed0AnimId = GetGoSpeed0AnimId(mapObject->placeholder18); + v0 = sub_805FF20(mapObject, mapObject->placeholder18); + } + if (v0 != 0) + { + goSpeed0AnimId = GetStepInPlaceDelay16AnimId(mapObject->mapobj_unk_18); + } + FieldObjectSetRegularAnim(mapObject, sprite, goSpeed0AnimId); + mapObject->mapobj_bit_1 = 1; + sprite->data1 = 3; + return 1; +} + +u8 sub_805E4C4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 1; + } + return 0; +} + +u8 sub_805E4EC(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return 1; +} + +u8 MoveFieldObjectInNextDirectionInSequence(struct MapObject *mapObject, struct Sprite *sprite, u8 *directionSequence) +{ + u8 v0; + u8 goSpeed0AnimId; + if (mapObject->mapobj_unk_21 == 3 && mapObject->coords1.x == mapObject->coords2.x && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 0; + } + FieldObjectSetDirection(mapObject, directionSequence[mapObject->mapobj_unk_21]); + goSpeed0AnimId = GetGoSpeed0AnimId(mapObject->placeholder18); + v0 = sub_805FF20(mapObject, mapObject->placeholder18); + if (v0 == 1) + { + mapObject->mapobj_unk_21 ++; + FieldObjectSetDirection(mapObject, directionSequence[mapObject->mapobj_unk_21]); + goSpeed0AnimId = GetGoSpeed0AnimId(mapObject->placeholder18); + v0 = sub_805FF20(mapObject, mapObject->placeholder18); + } + if (v0 != 0) + { + goSpeed0AnimId = GetStepInPlaceDelay16AnimId(mapObject->mapobj_unk_18); + } + FieldObjectSetRegularAnim(mapObject, sprite, goSpeed0AnimId); + mapObject->mapobj_bit_1 = 1; + sprite->data1 = 2; + return 1; +} + +u8 sub_805E5B4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 1; + } + return 0; +} + +fieldmap_object_cb(sub_805E5DC, sub_805E600, gUnknown_0837540C); + +u8 sub_805E620(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375418, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805E668, sub_805E68C, gUnknown_0837541C); + +u8 sub_805E6AC(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375428, 4); + if (mapObject->mapobj_unk_21 == 1 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 2; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805E6F4, sub_805E718, gUnknown_0837542C); + +u8 sub_805E738(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375438, 4); + if (mapObject->mapobj_unk_21 == 1 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 2; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805E780, sub_805E7A4, gUnknown_0837543C); + +u8 sub_805E7C4(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375448, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + + + +fieldmap_object_cb(sub_805E80C, sub_805E830, gUnknown_0837544C); + +u8 sub_805E850(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375458, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805E898, sub_805E8BC, gUnknown_0837545C); + +u8 sub_805E8DC(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375468, 4); + if (mapObject->mapobj_unk_21 == 1 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 2; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805E924, sub_805E948, gUnknown_0837546C); + +u8 sub_805E968(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375240, 4); + if (mapObject->mapobj_unk_21 == 1 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 2; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805E9B0, sub_805E9D4, gUnknown_08375478); + +u8 sub_805E9F4(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375484, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805EA3C, sub_805EA60, gUnknown_08375488); + +u8 sub_805EA80(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375494, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805EAC8, sub_805EAEC, gUnknown_08375498); + +u8 sub_805EB0C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_083754A4, 4); + if (mapObject->mapobj_unk_21 == 1 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 2; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805EB54, sub_805EB78, gUnknown_083754A8); + +u8 sub_805EB98(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_083754B4, 4); + if (mapObject->mapobj_unk_21 == 1 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 2; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805EBE0, sub_805EC04, gUnknown_083754B8); + +u8 sub_805EC24(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_083754C4, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805EC6C, sub_805EC90, gUnknown_083754C8); + +u8 sub_805ECB0(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_083754D4, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805ECF8, sub_805ED1C, gUnknown_083754D8); + +u8 sub_805ED3C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_083754E4, 4); + if (mapObject->mapobj_unk_21 == 1 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 2; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805ED84, sub_805EDA8, gUnknown_083754E8); + +u8 sub_805EDC8(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_083754F4, 4); + if (mapObject->mapobj_unk_21 == 1 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 2; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805EE10, sub_805EE34, gUnknown_083754F8); + +u8 sub_805EE54(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375504, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805EE9C, sub_805EEC0, gUnknown_08375508); + +u8 sub_805EEE0(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375514, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805EF28, sub_805EF4C, gUnknown_08375518); + +u8 sub_805EF6C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375524, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805EFB4, sub_805EFD8, gUnknown_08375528); + +u8 sub_805EFF8(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375534, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805F040, sub_805F064, gUnknown_08375538); + +u8 sub_805F084(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375544, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805F0CC, sub_805F0F0, gUnknown_08375548); + +u8 sub_805F110(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375554, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805F158, sub_805F17C, gUnknown_08375558); + +u8 sub_805F19C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375564, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805F1E4, sub_805F208, gUnknown_08375568); + +u8 sub_805F228(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375574, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +} + +fieldmap_object_cb(sub_805F270, sub_805F294, gUnknown_08375578); + +u8 sub_805F2B4(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + memcpy(directions, gUnknown_08375584, 4); + if (mapObject->mapobj_unk_21 == 2 && mapObject->coords1.x == mapObject->coords2.x) + { + mapObject->mapobj_unk_21 = 3; + } + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, directions); +}; + +fieldmap_object_cb(sub_805F2FC, sub_805F320, gUnknown_08375588); + +u8 mss_npc_reset_oampriv3_1_unk2_unk3(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + if (mapObject->mapobj_unk_21 == 0) + { + mapObject->mapobj_unk_21 = player_get_direction_lower_nybble(); + } + sprite->data1 = 1; + return 1; +} + +u8 sub_805F364(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.running1 == 2) + { + return 0; + } + return gUnknown_08375594[player_get_x22()](mapObject, sprite, player_get_direction_upper_nybble(), NULL); +} + +u8 sub_805F3C4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + mapObject->mapobj_bit_1 = 0; + sprite->data1 = 1; + } + return 0; +} + +#ifdef NONMATCHING + +u8 sub_805F3EC(struct MapObject *mapObject, struct Sprite *sprite, u8 a2, u8 *a3(u8)) +{ + return 0; +} + +u8 sub_805F3F0(struct MapObject *mapObject, struct Sprite *sprite, u8 a2, u8 *a3(u8)) +{ + int direction; + direction = state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, a2); + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + mapObject->mapobj_bit_1 = 1; + sprite->data1 = 2; + return 1; +} + +u8 sub_805F438(struct MapObject *mapObject, struct Sprite *sprite, u8 a2, u8 *a3(u8)) +{ + s16 x; + s16 y; + int direction; + direction = state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, a2); + FieldObjectMoveDestCoords(mapObject, direction, &x, &y); + FieldObjectSetRegularAnim(mapObject, sprite, GetGoSpeed0AnimId(direction)); + if (!npc_block_way(mapObject, x, y, direction) || (a3 != NULL && !a3(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = 1; + sprite->data1 = 2; + return 1; +} +#endif + +asm(".section .text_fmocb2_c\n"); + +fieldmap_object_cb(sub_805F8E0, sub_805F904, gUnknown_083755C0); + +u8 mss_08062EA4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.running1 == 2) + { + return 0; + } + return gUnknown_08375594[player_get_x22()](mapObject, sprite, player_get_direction_upper_nybble(), MetatileBehavior_IsPokeGrass); +} + +u8 sub_805F9F8(struct MapObject *, struct Sprite *); + +void FieldObjectCB_TreeDisguise(struct Sprite *sprite) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[sprite->data0]; + if (mapObject->mapobj_unk_21 == 0 || (mapObject->mapobj_unk_21 == 1 && sprite->data7 == 0)) + { + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); + mapObject->mapobj_unk_1A = FieldEffectStart(0x1c); + mapObject->mapobj_unk_21 = 1; + sprite->data7 ++; + } + meta_step(&gMapObjects[sprite->data0], sprite, sub_805F9F8); +} + +u8 sub_805F9F8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + return 0; +} + +void FieldObjectCB_MountainDisguise(struct Sprite *sprite) +{ + struct MapObject *mapObject; + mapObject = &gMapObjects[sprite->data0]; + if (mapObject->mapobj_unk_21 == 0 || (mapObject->mapobj_unk_21 == 1 && sprite->data7 == 0)) + { + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); + mapObject->mapobj_unk_1A = FieldEffectStart(0x1d); + mapObject->mapobj_unk_21 = 1; + sprite->data7 ++; + } + meta_step(&gMapObjects[sprite->data0], sprite, sub_805F9F8); +} + +u8 sub_805FAD8(struct MapObject *mapObject, struct Sprite *sprite); + +void FieldObjectCB_Hidden1(struct Sprite *sprite) +{ + if (sprite->data7 == 0) + { + gMapObjects[sprite->data0].mapobj_bit_26 = 1; + sprite->subspriteMode = 2; + sprite->oam.priority = 3; + sprite->data7 ++; + } + meta_step(&gMapObjects[sprite->data0], sprite, sub_805FAD8); +} + +u8 sub_805FAD8(struct MapObject *mapObject, struct Sprite *sprite) +{ + return gUnknown_083755CC[sprite->data1](mapObject, sprite); +} + +u8 sub_805FAF8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + return 0; +} + +u8 sub_805FB04(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sprite->data1 = 0; + } + return 0; +} + +fieldmap_object_cb(sub_805FB20, sub_805FB44, gUnknown_083755D0); + +u8 sub_805FB64(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetStepInPlaceDelay16AnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805FB90, sub_805FBB4, gUnknown_083755D8); + +u8 sub_805FBD4(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetStepInPlaceDelay8AnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805FC00, sub_805FC24, gUnknown_083755E0); + +u8 sub_805FC44(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetStepInPlaceDelay4AnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return 1; +} + +fieldmap_object_cb(sub_805FC70, sub_805FC94, gUnknown_083755E8); + +u8 sub_805FCB4(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + mapObject->mapobj_bit_13 = 1; + sprite->data1 = 1; + return 1; +} + +u8 sub_805FCE8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sprite->data1 = 2; + return 1; + } + return 0; +} + +u8 sub_805FD08(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_1 = 0; + return 0; +} + +void sub_805FC70(struct Sprite *sprite); + +void npc_reset(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_1 = 0; + mapObject->mapobj_bit_6 = 0; + mapObject->mapobj_bit_7 = 0; + mapObject->mapobj_unk_1C = 0xff; + sprite->data1 = 0; +} + +u8 FieldObjectDirectionToImageAnimId(u8 direction) +{ + return gUnknown_083755F4[direction]; +} + +u8 get_go_image_anim_num(u8 direction) +{ + return gUnknown_083755FD[direction]; +} + +u8 get_go_fast_image_anim_num(u8 direction) +{ + return gUnknown_08375606[direction]; +} + +u8 get_go_faster_image_anim_num(u8 direction) +{ + return gUnknown_0837560F[direction]; +} + +u8 sub_805FD78(u8 direction) +{ + return gUnknown_08375618[direction]; +} + +u8 sub_805FD88(u8 direction) +{ + return gUnknown_08375621[direction]; +} + +u8 sub_805FD98(u8 direction) +{ + return gUnknown_0837562A[direction]; +} + +u8 unref_sub_805FDA8(u8 direction) +{ + return gUnknown_08375633[direction]; +} + +u8 sub_805FDB8(u8 direction) +{ + return gUnknown_0837563C[direction]; +} + +u8 sub_805FDC8(u8 direction) +{ + return gUnknown_08375645[direction]; +} + +u8 sub_805FDD8(u8 direction) +{ + return gUnknown_0837564E[direction]; +} + +u8 sub_805FDE8(u8 direction) +{ + return gUnknown_08375657[direction]; +} + +u8 sub_805FDF8(u8 direction) +{ + return gUnknown_08375660[direction]; +} + +u8 sub_805FE08(u8 direction) +{ + return gUnknown_08375669[direction]; +} + +u8 get_run_image_anim_num(u8 direction) +{ + return gUnknown_08375672[direction]; +} + +void sub_805FE28(struct MapObject *mapObject, struct Sprite *sprite, u8 animNum) +{ + if (!mapObject->mapobj_bit_12) + { + sprite->animNum = animNum; + if (sprite->animCmdIndex == 1) + { + sprite->animCmdIndex = 2; + } else if (sprite->animCmdIndex == 3) + { + sprite->animCmdIndex = 0; + } + SeekSpriteAnim(sprite, sprite->animCmdIndex); + } +} + +void sub_805FE64(struct MapObject *mapObject, struct Sprite *sprite, u8 animNum) +{ + u8 animCmdIndex; + if (!mapObject->mapobj_bit_12) + { + sprite->animNum = animNum; + animCmdIndex = 3; + if (sprite->animCmdIndex < 2) + { + animCmdIndex = 1; + } + SeekSpriteAnim(sprite, animCmdIndex); + } +} + +u8 sub_805FE90(s16 a0, s16 a1, s16 a2, s16 a3) +{ + if (a0 > a2) + { + return DIR_WEST; + } else if (a0 < a2) + { + return DIR_EAST; + } else if (a1 > a3) + { + return DIR_NORTH; + } else + { + return DIR_SOUTH; + } +} + +void npc_set_running_behaviour_etc(struct MapObject *mapObject, u8 animPattern) +{ + mapObject->animPattern = animPattern; + mapObject->mapobj_unk_21 = 0; + mapObject->animId = 0; + gSprites[mapObject->spriteId].callback = gUnknown_0836DA88[animPattern]; + gSprites[mapObject->spriteId].data1 = 0; +} + +u8 npc_running_behaviour_by_direction(u8 direction) +{ + return gUnknown_0837567B[direction]; +} + +u8 sub_805FF20(struct MapObject *mapObject, u8 direction) +{ + s16 x; + s16 y; + x = mapObject->coords2.x; + y = mapObject->coords2.y; + MoveCoords(direction, &x, &y); + return npc_block_way(mapObject, x, y, direction); +} + +bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, s16 y); +bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *mapObject, s16 x, s16 y); +bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 y, u8 direction); + +u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u8 direction) +{ + if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) + { + return 1; + } + if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction)) + { + return 2; + } else if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)) + { + return 2; + } + if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) + { + return 3; + } + if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) + { + return 4; + } + return 0; +} + +u8 sub_8060024(struct MapObject *mapObject, s16 x, s16 y, u8 direction) +{ + u8 flags; + flags = 0; + if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) + { + flags |= 1; + } + if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction) || (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction))) + { + flags |= 2; + } + if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) + { + flags |= 4; + } + if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) + { + flags |= 8; + } + return flags; +} + +bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, s16 y) +{ + s16 minv; + s16 maxv; + if (mapObject->mapobj_unk_19 != 0) + { + minv = mapObject->coords1.x - (mapObject->mapobj_unk_19); + maxv = mapObject->coords1.x + (mapObject->mapobj_unk_19); + if (minv > x || maxv < x) + { + return 1; + } + } + if (mapObject->mapobj_unk_19b != 0) + { + minv = mapObject->coords1.y - (mapObject->mapobj_unk_19b); + maxv = mapObject->coords1.y + (mapObject->mapobj_unk_19b); + if (minv > y || maxv < y) + { + return 1; + } + } + return 0; +} + +bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 y, u8 direction) +{ + if (gUnknown_08375684[direction - 1](mapObject->mapobj_unk_1E) || gUnknown_08375694[direction - 1](MapGridGetMetatileBehaviorAt(x, y))) + { + return 1; + } + return 0; +} + +bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *mapObject, s16 x, s16 y) +{ + struct MapObject *mapObject2; + u8 i; + for (i=0; i<16; i++) + { + mapObject2 = &gMapObjects[i]; + if (mapObject2->active && mapObject2 != mapObject) + { + if ((mapObject2->coords2.x != x || mapObject2->coords2.y != y) && (mapObject2->coords3.x != x || mapObject2->coords3.y != y)) + { + continue; + } + if (AreZCoordsCompatible(mapObject->mapobj_unk_0B_0, mapObject2->mapobj_unk_0B_0)) + { + return 1; + } + } + } + return 0; +} + +bool8 sub_8060234(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + if (gSprites[gMapObjects[mapObjectId].spriteId].data7 & 2) + { + return 1; + } + } + return 0; +} + +void sub_8060288(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + gSprites[gMapObjects[mapObjectId].spriteId].data7 |= 4; + } +} + +void MoveCoords(u8 direction, s16 *x, s16 *y) +{ + *x += gDirectionToVector[direction].x; + *y += gDirectionToVector[direction].y; +} + +void unref_sub_80602F8(u8 direction, s16 *x, s16 *y) +{ + *x += gDirectionToVector[direction].x << 4; + *y += gDirectionToVector[direction].y << 4; +} + +void sub_8060320(u8 direction, s16 *x, s16 *y, s16 deltaX, s16 deltaY) +{ + if (gDirectionToVector[direction].x > 0) + { + *x += deltaX; + } + if (gDirectionToVector[direction].x < 0) + { + *x -= deltaX; + } + if (gDirectionToVector[direction].y > 0) + { + *y += deltaY; + } + if (gDirectionToVector[direction].y < 0) + { + *y -= deltaY; + } +} + +void sub_8060388(s16 x1, s16 y1, s16 *x2, s16 *y2) +{ + *x2 = (x1 - gSaveBlock1.pos.x) << 4; + *y2 = (y1 - gSaveBlock1.pos.y) << 4; + *x2 -= gUnknown_0300489C; + *y2 -= gUnknown_03004898; +} + +void sub_80603CC(s16 x1, s16 y1, s16 *x2, s16 *y2) +{ + s16 x3; + s16 y3; + x3 = -gUnknown_0300489C - gUnknown_03004880.unk10; + y3 = -gUnknown_03004898 - gUnknown_03004880.unk14; + if (gUnknown_03004880.unk10 > 0) + { + x3 += 0x10; + } + if (gUnknown_03004880.unk10 < 0) + { + x3 -= 0x10; + } + if (gUnknown_03004880.unk14 > 0) + { + y3 += 0x10; + } + if (gUnknown_03004880.unk14 < 0) + { + y3 -= 0x10; + } + *x2 = ((x1 - gSaveBlock1.pos.x) << 4) + x3; + *y2 = ((y1 - gSaveBlock1.pos.y) << 4) + y3; +} + +void sub_8060470(s16 *x, s16 *y, s16 dx, s16 dy) +{ + sub_80603CC(*x, *y, x, y); + *x += dx; + *y += dy; +} + +void GetFieldObjectMovingCameraOffset(s16 *x, s16 *y) +{ + *x = 0; + *y = 0; + if (gUnknown_03004880.unk10 > 0) + { + (*x)++; + } + if (gUnknown_03004880.unk10 < 0) + { + (*x)--; + } + if (gUnknown_03004880.unk14 > 0) + { + (*y)++; + } + if (gUnknown_03004880.unk14 < 0) + { + (*y)--; + } +} + +void FieldObjectMoveDestCoords(struct MapObject *mapObject, u8 direction, s16 *x, s16 *y) +{ + *x = mapObject->coords2.x; + *y = mapObject->coords2.y; + MoveCoords(direction, x, y); +} + +bool8 FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_1 || mapObject->mapobj_bit_6) + { + return TRUE; + } + return FALSE; +} + +bool8 FieldObjectIsSpecialAnimActive(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_6 && mapObject->mapobj_unk_1C != 0xff) + { + return TRUE; + } + return FALSE; +} + +bool8 FieldObjectSetSpecialAnim(struct MapObject *mapObject, u8 specialAnimId) +{ + if (FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(mapObject)) + { + return TRUE; + } + UnfreezeMapObject(mapObject); + mapObject->mapobj_unk_1C = specialAnimId; + mapObject->mapobj_bit_6 = 1; + mapObject->mapobj_bit_7 = 0; + gSprites[mapObject->spriteId].data2 = 0; + return FALSE; +} + +void FieldObjectForceSetSpecialAnim(struct MapObject *mapObject, u8 specialAnimId) +{ + FieldObjectClearAnimIfSpecialAnimActive(mapObject); + FieldObjectSetSpecialAnim(mapObject, specialAnimId); +} + +void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_6) + { + FieldObjectClearAnim(mapObject); + } +} + +void FieldObjectClearAnim(struct MapObject *mapObject) +{ + mapObject->mapobj_unk_1C = 0xFF; + mapObject->mapobj_bit_6 = 0; + mapObject->mapobj_bit_7 = 0; + gSprites[mapObject->spriteId].data1 = 0; + gSprites[mapObject->spriteId].data2 = 0; +} + +bool8 FieldObjectCheckIfSpecialAnimFinishedOrInactive(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_6) + return mapObject->mapobj_bit_7; + return 0x10; +} + +bool8 FieldObjectClearAnimIfSpecialAnimFinished(struct MapObject *mapObject) +{ + u8 specialAnimStatus; + specialAnimStatus = FieldObjectCheckIfSpecialAnimFinishedOrInactive(mapObject); + if (specialAnimStatus != 0 && specialAnimStatus != 0x10) + { + FieldObjectClearAnimIfSpecialAnimActive(mapObject); + } + return specialAnimStatus; +} + +u8 FieldObjectGetSpecialAnim(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_6) + { + return mapObject->mapobj_unk_1C; + } + return 0xFF; +} + +extern void DoGroundEffects_OnSpawn(struct MapObject *mapObject, struct Sprite *sprite); +extern void DoGroundEffects_OnBeginStep(struct MapObject *mapObject, struct Sprite *sprite); +extern void DoGroundEffects_OnFinishStep(struct MapObject *mapObject, struct Sprite *sprite); +void npc_obj_transfer_image_anim_pause_flag(struct MapObject *mapObject, struct Sprite *sprite); +void sub_80634A0(struct MapObject *mapObject, struct Sprite *sprite); +void FieldObjectExecSpecialAnim(struct MapObject *mapObject, struct Sprite *sprite); +void FieldObjectUpdateSubpriority(struct MapObject *mapObject, struct Sprite *sprite); + +void meta_step(struct MapObject *mapObject, struct Sprite *sprite, u8 (*callback)(struct MapObject *, struct Sprite *)) +{ + DoGroundEffects_OnSpawn(mapObject, sprite); + sub_80634A0(mapObject, sprite); + if (FieldObjectIsSpecialAnimActive(mapObject)) + { + FieldObjectExecSpecialAnim(mapObject, sprite); + } else + { + if (!mapObject->mapobj_bit_8) + { + while (callback(mapObject, sprite)); + } + } + DoGroundEffects_OnBeginStep(mapObject, sprite); + DoGroundEffects_OnFinishStep(mapObject, sprite); + npc_obj_transfer_image_anim_pause_flag(mapObject, sprite); + sub_80634D0(mapObject, sprite); + FieldObjectUpdateSubpriority(mapObject, sprite); +} + + +u8 GetFaceDirectionAnimId(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756C8, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 GetSimpleGoAnimId(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756CD, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 GetGoSpeed0AnimId(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756D2, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_8060744(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756D7, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 d2s_08064034(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756DC, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_806079C(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756E1, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_80607C8(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756E6, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_80607F4(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756EB, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 GetJumpLedgeAnimId(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756F0, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_806084C(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756F5, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_8060878(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756FA, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_80608A4(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_083756FF, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_80608D0(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_08375704, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 GetStepInPlaceDelay32AnimId(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_08375709, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 GetStepInPlaceDelay16AnimId(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_0837570E, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 GetStepInPlaceDelay8AnimId(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_08375713, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 GetStepInPlaceDelay4AnimId(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_08375718, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 FieldObjectFaceOppositeDirection(struct MapObject *mapObject, u8 direction) +{ + return FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(GetOppositeDirection(direction))); +} + +u8 sub_80609D8(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_0837571D, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_8060A04(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_08375722, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_8060A30(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_08375727, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_8060A5C(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_0837572C, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_8060A88(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_08375731, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_8060AB4(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_08375736, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_8060AE0(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_0837573B, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_8060B0C(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_08375740, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_8060B38(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_08375745, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 sub_8060B64(u8 index) +{ + u8 directions[5]; + memcpy(directions, gUnknown_0837574A, 5); + if (index >= 5) + { + index = 0; + } + return directions[index]; +} + +u8 GetOppositeDirection(u8 direction) +{ + u8 directions[8]; + memcpy(directions, gUnknown_0837574F, 8); + if (direction == 0 || direction > 8) + { + return direction; + } + return directions[direction - 1]; +} + +int zffu_offset_calc(u8 a0, u8 a1) +{ + return gUnknown_08375757[a0 - 1][a1 - 1]; +} + +#ifdef NONMATCHING +int state_to_direction(u8 a0, u8 a1, u8 a2) +{ + int zffuOffset; + asm_comment("For some reason, r2 is being backed up to r3 and restored ahead of the zffu call."); + if (a1 == 0 || a2 == 0 || a1 > 4 || a2 > 4) + { + return 0; + } + zffuOffset = zffu_offset_calc(a1, a2); + return gUnknown_08375767[a0 - 1][zffuOffset - 1]; +} +#else +__attribute__((naked)) +int state_to_direction(u8 a0, u8 a1, u8 a2) +{ + asm(".syntax unified\n\ + push {r4,lr}\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + adds r0, r1, 0\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + cmp r1, 0\n\ + beq _08060BFC\n\ + cmp r2, 0\n\ + beq _08060BFC\n\ + cmp r1, 0x4\n\ + bhi _08060BFC\n\ + cmp r2, 0x4\n\ + bls _08060C00\n\ +_08060BFC:\n\ + movs r0, 0\n\ + b _08060C12\n\ +_08060C00:\n\ + adds r1, r2, 0\n\ + bl zffu_offset_calc\n\ + ldr r2, _08060C18 @ =gUnknown_08375767\n\ + lsls r1, r4, 2\n\ + subs r1, 0x5\n\ + adds r0, r1\n\ + adds r0, r2\n\ + ldrb r0, [r0]\n\ +_08060C12:\n\ + pop {r4}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ +_08060C18: .4byte gUnknown_08375767\n\ +.syntax divided\n"); +} +#endif + +void FieldObjectExecSpecialAnim(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (gUnknown_08375778[mapObject->mapobj_unk_1C][sprite->data2](mapObject, sprite)) + { + mapObject->mapobj_bit_7 = 1; + } +} + +bool8 FieldObjectExecRegularAnim(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (gUnknown_08375778[mapObject->mapobj_unk_1C][sprite->data2](mapObject, sprite)) + { + mapObject->mapobj_unk_1C = 0xFF; + sprite->data2 = 0; + return 1; + } + return 0; +} + +void FieldObjectSetRegularAnim(struct MapObject *mapObject, struct Sprite *sprite, u8 animId) +{ + mapObject->mapobj_unk_1C = animId; + sprite->data2 = 0; +} + +void an_look_any(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + FieldObjectSetDirection(mapObject, direction); + npc_coords_shift_still(mapObject); + sub_805FE64(mapObject, sprite, get_go_image_anim_num(mapObject->mapobj_unk_18)); + sprite->animPaused = 1; + sprite->data2 = 1; +} + +u8 sub_8060CE0(struct MapObject *mapObject, struct Sprite *sprite) +{ + an_look_any(mapObject, sprite, DIR_SOUTH); + return 1; +} + +u8 sub_8060CF0(struct MapObject *mapObject, struct Sprite *sprite) +{ + an_look_any(mapObject, sprite, DIR_NORTH); + return 1; +} + +u8 sub_8060D00(struct MapObject *mapObject, struct Sprite *sprite) +{ + an_look_any(mapObject, sprite, DIR_WEST); + return 1; +} + +u8 sub_8060D10(struct MapObject *mapObject, struct Sprite *sprite) +{ + an_look_any(mapObject, sprite, DIR_EAST); + return 1; +} + +void sub_8060D20(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 a3) +{ + s16 x; + s16 y; + x = mapObject->coords2.x; + y = mapObject->coords2.y; + FieldObjectSetDirection(mapObject, direction); + MoveCoords(direction, &x, &y); + npc_coords_shift(mapObject, x, y); + oamt_npc_ministep_reset(sprite, direction, a3); + sprite->animPaused = 0; + mapObject->mapobj_bit_2 = 1; + sprite->data2 = 1; +} + +extern u8 (*const gUnknown_083759C0[5])(u8); + +void do_go_anim(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 a3) +{ + u8 (*const functions[5])(u8); + memcpy((void *)functions, gUnknown_083759C0, sizeof(gUnknown_083759C0)); + sub_8060D20(mapObject, sprite, direction, a3); + sub_805FE28(mapObject, sprite, functions[a3](mapObject->mapobj_unk_18)); +} + +void do_run_anim(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + sub_8060D20(mapObject, sprite, direction, 1); + sub_805FE28(mapObject, sprite, get_run_image_anim_num(mapObject->mapobj_unk_18)); +} + +bool8 obj_npc_ministep(struct Sprite *); + +bool8 npc_obj_ministep_stop_on_arrival(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (obj_npc_ministep(sprite)) + { + npc_coords_shift_still(mapObject); + mapObject->mapobj_bit_3 = 1; + sprite->animPaused = 1; + return 1; + } + return 0; +} + +void sub_8060E68(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + s16 x; + s16 y; + x = mapObject->coords2.x; + y = mapObject->coords2.y; + FieldObjectSetDirection(mapObject, direction); + MoveCoords(direction, &x, &y); + npc_coords_shift(mapObject, x, y); + sub_806467C(sprite, direction); + sprite->animPaused = 0; + mapObject->mapobj_bit_2 = 1; + sprite->data2 = 1; +} + +void sub_8060ED8(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + sub_8060E68(mapObject, sprite, direction); + sub_805FE28(mapObject, sprite, get_go_image_anim_num(mapObject->mapobj_unk_18)); +} + +bool8 an_walk_any_2(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_806468C(sprite)) + { + npc_coords_shift_still(mapObject); + mapObject->mapobj_bit_3 = 1; + sprite->animPaused = 1; + return TRUE; + } + return FALSE; +} + +bool8 sub_8060F5C(struct MapObject *, struct Sprite *); + +bool8 sub_8060F3C(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8060ED8(mapObject, sprite, DIR_SOUTH); + return sub_8060F5C(mapObject, sprite); +} + +bool8 sub_8060F5C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (an_walk_any_2(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8060F9C(struct MapObject *, struct Sprite *); + +bool8 sub_8060F7C(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8060ED8(mapObject, sprite, DIR_NORTH); + return sub_8060F9C(mapObject, sprite); +} + +bool8 sub_8060F9C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (an_walk_any_2(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8060FDC(struct MapObject *, struct Sprite *); + +bool8 sub_8060FBC(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8060ED8(mapObject, sprite, DIR_WEST); + return sub_8060FDC(mapObject, sprite); +} + +bool8 sub_8060FDC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (an_walk_any_2(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_806101C(struct MapObject *, struct Sprite *); + +bool8 sub_8060FFC(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8060ED8(mapObject, sprite, DIR_EAST); + return sub_806101C(mapObject, sprite); +} + +bool8 sub_806101C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (an_walk_any_2(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_806105C(struct MapObject *, struct Sprite *); + +bool8 sub_806103C(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_SOUTH, 0); + return sub_806105C(mapObject, sprite); +} + +bool8 sub_806105C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_806109C(struct MapObject *, struct Sprite *); + +bool8 sub_806107C(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_NORTH, 0); + return sub_806109C(mapObject, sprite); +} + +bool8 sub_806109C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_80610DC(struct MapObject *, struct Sprite *); + +bool8 sub_80610BC(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_WEST, 0); + return sub_80610DC(mapObject, sprite); +} + +bool8 sub_80610DC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_806111C(struct MapObject *, struct Sprite *); + +bool8 sub_80610FC(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_EAST, 0); + return sub_806111C(mapObject, sprite); +} + +bool8 sub_806111C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +void sub_806113C(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 a4, u8 a5) +{ + s16 vSPp4[3]; + s16 x; + s16 y; + memcpy(vSPp4, gUnknown_08375A34, sizeof gUnknown_08375A34); + x = 0; + y = 0; + FieldObjectSetDirection(mapObject, direction); + sub_8060320(direction, &x, &y, vSPp4[a4], vSPp4[a4]); + npc_coords_shift(mapObject, mapObject->coords2.x + x, mapObject->coords2.y + y); + sub_80646E4(sprite, direction, a4, a5); + sprite->data2 = 1; + sprite->animPaused = 0; + mapObject->mapobj_bit_2 = 1; + mapObject->mapobj_bit_4 = 1; +} + +void maybe_shadow_1(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 a4, u8 a5) +{ + sub_806113C(mapObject, sprite, direction, a4, a5); + sub_805FE28(mapObject, sprite, get_go_image_anim_num(mapObject->mapobj_unk_18)); + DoShadowFieldEffect(mapObject); +} + +u8 sub_806123C(struct MapObject *mapObject, struct Sprite *sprite, u8 (*const callback)(struct Sprite *)) +{ + s16 vSPp4[3]; + s16 x; + s16 y; + u8 retval; + memcpy(vSPp4, gUnknown_08375A3A, sizeof gUnknown_08375A3A); + retval = callback(sprite); + if (retval == 1 && vSPp4[sprite->data4] != 0) + { + x = 0; + y = 0; + sub_8060320(mapObject->placeholder18, &x, &y, vSPp4[sprite->data4], vSPp4[sprite->data4]); + npc_coords_shift(mapObject, mapObject->coords2.x + x, mapObject->coords2.y + y); + mapObject->mapobj_bit_2 = 1; + mapObject->mapobj_bit_4 = 1; + } else if (retval == 0xff) + { + npc_coords_shift_still(mapObject); + mapObject->mapobj_bit_3 = 1; + mapObject->mapobj_bit_5 = 1; + sprite->animPaused = 1; + } + return retval; +} + +u8 sub_8061300(struct MapObject *mapObject, struct Sprite *sprite) +{ + return sub_806123C(mapObject, sprite, sub_8064704); +} + +u8 sub_8061314(struct MapObject *mapObject, struct Sprite *sprite) +{ + return sub_806123C(mapObject, sprite, sub_806478C); +} + +bool8 sub_8061328(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061300(mapObject, sprite) == 0xFF) + { + return TRUE; + } + return FALSE; +} + +bool8 sub_8061340(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061314(mapObject, sprite) == 0xFF) + { + return TRUE; + } + return FALSE; +} + +bool8 sub_8061358(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 retval; + + retval = sub_8061300(mapObject, sprite); + if (retval != 1) + { + if (retval == 0xFF) + { + return TRUE; + } + return FALSE; + } + FieldObjectSetDirection(mapObject, GetOppositeDirection(mapObject->placeholder18)); + sub_805FE64(mapObject, sprite, get_go_image_anim_num(mapObject->mapobj_unk_18)); + return FALSE; +} + +bool8 sub_80613D4(struct MapObject *, struct Sprite *); +bool8 sub_806142C(struct MapObject *, struct Sprite *); +bool8 sub_8061484(struct MapObject *, struct Sprite *); +bool8 sub_80614DC(struct MapObject *, struct Sprite *); + +bool8 sub_80613A8(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_SOUTH, 2, 0); + return sub_80613D4(mapObject, sprite); +} + +bool8 sub_80613D4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8061400(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_NORTH, 2, 0); + return sub_806142C(mapObject, sprite); +} + +bool8 sub_806142C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8061458(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_WEST, 2, 0); + return sub_8061484(mapObject, sprite); +} + +bool8 sub_8061484(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_80614B0(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_EAST, 2, 0); + return sub_80614DC(mapObject, sprite); +} + +bool8 sub_80614DC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +void sub_8061508(struct Sprite *sprite, u16 duration) +{ + sprite->data2 = 1; + sprite->data3 = duration; +} + +bool8 sub_8061510(struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->data3--; + if (!sprite->data3) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_806152C(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8061508(sprite, 1); + return sub_8061510(mapObject, sprite); +} + +bool8 sub_806154C(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8061508(sprite, 2); + return sub_8061510(mapObject, sprite); +} + +bool8 sub_806156C(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8061508(sprite, 4); + return sub_8061510(mapObject, sprite); +} + +bool8 sub_806158C(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8061508(sprite, 8); + return sub_8061510(mapObject, sprite); +} + +bool8 sub_80615AC(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8061508(sprite, 16); + return sub_8061510(mapObject, sprite); +} + +bool8 sub_80615EC(struct MapObject *mapObject, struct Sprite *sprite); +bool8 sub_806162C(struct MapObject *mapObject, struct Sprite *sprite); +bool8 sub_806166C(struct MapObject *mapObject, struct Sprite *sprite); +bool8 sub_80616AC(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_80615CC(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_SOUTH, 1); + return sub_80615EC(mapObject, sprite); +} + +bool8 sub_80615EC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} +bool8 sub_806160C(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_NORTH, 1); + return sub_806162C(mapObject, sprite); +} + +bool8 sub_806162C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} +bool8 sub_806164C(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_WEST, 1); + return sub_806166C(mapObject, sprite); +} + +bool8 sub_806166C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} +bool8 sub_806168C(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_EAST, 1); + return sub_80616AC(mapObject, sprite); +} + +bool8 sub_80616AC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +void sub_80616CC(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 animId, u16 duration) +{ + FieldObjectSetDirection(mapObject, direction); + sub_805FE28(mapObject, sprite, animId); + sprite->animPaused = 0; + sprite->data2 = 1; + sprite->data3 = duration; +} + +bool8 sub_8061714(struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->data3--; + if (sprite->data3 == 0) + { + sprite->data2 = 2; + sprite->animPaused = 1; + return TRUE; + } + return FALSE; +} + +bool8 sub_806173C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sprite->data3 & 1) + { + sprite->animDelayCounter++; + } + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8061778(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_SOUTH, get_go_image_anim_num(DIR_SOUTH), 32); + return sub_806173C(mapObject, sprite); +} + +bool8 sub_80617B0(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_NORTH, get_go_image_anim_num(DIR_NORTH), 32); + return sub_806173C(mapObject, sprite); +} + +bool8 sub_80617E8(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_WEST, get_go_image_anim_num(DIR_WEST), 32); + return sub_806173C(mapObject, sprite); +} + +bool8 sub_8061820(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_EAST, get_go_image_anim_num(DIR_EAST), 32); + return sub_806173C(mapObject, sprite); +} + +bool8 sub_8061858(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_SOUTH, get_go_image_anim_num(DIR_SOUTH), 16); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8061890(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_NORTH, get_go_image_anim_num(DIR_NORTH), 16); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_80618C8(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_WEST, get_go_image_anim_num(DIR_WEST), 16); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8061900(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_EAST, get_go_image_anim_num(DIR_EAST), 16); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8061938(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_SOUTH, get_go_fast_image_anim_num(DIR_SOUTH), 8); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8061970(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_NORTH, get_go_fast_image_anim_num(DIR_NORTH), 8); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_80619A8(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_WEST, get_go_fast_image_anim_num(DIR_WEST), 8); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_80619E0(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_EAST, get_go_fast_image_anim_num(DIR_EAST), 8); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8061A18(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_SOUTH, get_go_faster_image_anim_num(DIR_SOUTH), 4); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8061A50(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_NORTH, get_go_faster_image_anim_num(DIR_NORTH), 4); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8061A88(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_WEST, get_go_faster_image_anim_num(DIR_WEST), 4); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8061AC0(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_EAST, get_go_faster_image_anim_num(DIR_EAST), 4); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8061B18(struct MapObject *, struct Sprite *); + +bool8 sub_8061AF8(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_SOUTH, 2); + return sub_8061B18(mapObject, sprite); +} + +bool8 sub_8061B18(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + + +bool8 sub_8061B58(struct MapObject *, struct Sprite *); + +bool8 sub_8061B38(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_NORTH, 2); + return sub_8061B58(mapObject, sprite); +} + +bool8 sub_8061B58(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + + +bool8 sub_8061B98(struct MapObject *, struct Sprite *); + +bool8 sub_8061B78(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_WEST, 2); + return sub_8061B98(mapObject, sprite); +} + +bool8 sub_8061B98(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + + +bool8 sub_8061BD8(struct MapObject *, struct Sprite *); + +bool8 sub_8061BB8(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_EAST, 2); + return sub_8061BD8(mapObject, sprite); +} + +bool8 sub_8061BD8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8061C18(struct MapObject *, struct Sprite *); + +bool8 sub_8061BF8(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_SOUTH, 3); + return sub_8061C18(mapObject, sprite); +} + +bool8 sub_8061C18(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8061C58(struct MapObject *, struct Sprite *); + +bool8 sub_8061C38(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_NORTH, 3); + return sub_8061C58(mapObject, sprite); +} + +bool8 sub_8061C58(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + + +bool8 sub_8061C98(struct MapObject *, struct Sprite *); + +bool8 sub_8061C78(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_WEST, 3); + return sub_8061C98(mapObject, sprite); +} + +bool8 sub_8061C98(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + + +bool8 sub_8061CD8(struct MapObject *, struct Sprite *); + +bool8 sub_8061CB8(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_EAST, 3); + return sub_8061CD8(mapObject, sprite); +} + +bool8 sub_8061CD8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8061D18(struct MapObject *, struct Sprite *); + +bool8 sub_8061CF8(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_SOUTH, 4); + return sub_8061D18(mapObject, sprite); +} + +bool8 sub_8061D18(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8061D58(struct MapObject *, struct Sprite *); + +bool8 sub_8061D38(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_NORTH, 4); + return sub_8061D58(mapObject, sprite); +} + +bool8 sub_8061D58(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + + +bool8 sub_8061D98(struct MapObject *, struct Sprite *); + +bool8 sub_8061D78(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_WEST, 4); + return sub_8061D98(mapObject, sprite); +} + +bool8 sub_8061D98(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + + +bool8 sub_8061DD8(struct MapObject *, struct Sprite *); + +bool8 sub_8061DB8(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_go_anim(mapObject, sprite, DIR_EAST, 4); + return sub_8061DD8(mapObject, sprite); +} + +bool8 sub_8061DD8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8061E18(struct MapObject *, struct Sprite *); + +bool8 do_run_south_anim(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_run_anim(mapObject, sprite, DIR_SOUTH); + return sub_8061E18(mapObject, sprite); +} + +bool8 sub_8061E18(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8061E58(struct MapObject *, struct Sprite *); + +bool8 do_run_north_anim(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_run_anim(mapObject, sprite, DIR_NORTH); + return sub_8061E58(mapObject, sprite); +} + +bool8 sub_8061E58(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8061E98(struct MapObject *, struct Sprite *); + +bool8 do_run_west_anim(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_run_anim(mapObject, sprite, DIR_WEST); + return sub_8061E98(mapObject, sprite); +} + +bool8 sub_8061E98(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8061ED8(struct MapObject *, struct Sprite *); + +bool8 do_run_east_anim(struct MapObject *mapObject, struct Sprite *sprite) +{ + do_run_anim(mapObject, sprite, DIR_EAST); + return sub_8061ED8(mapObject, sprite); +} + +bool8 sub_8061ED8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +void npc_set_direction_and_anim__an_proceed(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 animNum) +{ + obj_anim_image_set_and_seek(sprite, animNum, 0); + FieldObjectSetDirection(mapObject, direction); + sprite->data2 = 1; +} + +bool8 sub_8061F24(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, mapObject->placeholder18, sprite->animNum); + return FALSE; +} + +bool8 sub_8064864(struct Sprite *); + +bool8 sub_8061F3C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064864(sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +void sub_8061F5C(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + sub_806113C(mapObject, sprite, direction, 1, 0); + StartSpriteAnim(sprite, sub_805FD88(direction)); +} + +bool8 sub_8061FB0(struct MapObject *, struct Sprite *); + +bool8 sub_8061F90(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8061F5C(mapObject, sprite, DIR_SOUTH); + return sub_8061FB0(mapObject, sprite); +} + +bool8 sub_8061FB0(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061340(mapObject, sprite)) + { + sprite->data2 = 2; + mapObject->mapobj_bit_5 = 0; + return TRUE; + } + return FALSE; +} + +bool8 sub_8061FF8(struct MapObject *, struct Sprite *); + +bool8 sub_8061FD8(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8061F5C(mapObject, sprite, DIR_NORTH); + return sub_8061FF8(mapObject, sprite); +} + +bool8 sub_8061FF8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061340(mapObject, sprite)) + { + sprite->data2 = 2; + mapObject->mapobj_bit_5 = 0; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062040(struct MapObject *, struct Sprite *); + +bool8 sub_8062020(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8061F5C(mapObject, sprite, DIR_WEST); + return sub_8062040(mapObject, sprite); +} + +bool8 sub_8062040(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061340(mapObject, sprite)) + { + sprite->data2 = 2; + mapObject->mapobj_bit_5 = 0; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062088(struct MapObject *, struct Sprite *); + +bool8 sub_8062068(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8061F5C(mapObject, sprite, DIR_EAST); + return sub_8062088(mapObject, sprite); +} + +bool8 sub_8062088(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061340(mapObject, sprite)) + { + sprite->data2 = 2; + mapObject->mapobj_bit_5 = 0; + return TRUE; + } + return FALSE; +} + +bool8 sub_80620B0(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 objectId; + if (!TryGetFieldObjectIdByLocalIdAndMap(0xFF, MAP_GROUP_PETALBURG_CITY, MAP_ID_PETALBURG_CITY, &objectId)) + { + an_look_any(mapObject, sprite, sub_805FE90(mapObject->coords2.x, mapObject->coords2.y, gMapObjects[objectId].coords2.x, gMapObjects[objectId].coords2.y)); + } + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_806210C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 objectId; + if (!TryGetFieldObjectIdByLocalIdAndMap(0xFF, MAP_GROUP_PETALBURG_CITY, MAP_ID_PETALBURG_CITY, &objectId)) + { + an_look_any(mapObject, sprite, GetOppositeDirection(sub_805FE90(mapObject->coords2.x, mapObject->coords2.y, gMapObjects[objectId].coords2.x, gMapObjects[objectId].coords2.y))); + } + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_8062170(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_9 = 1; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_8062180(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_9 = 0; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_80621BC(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_8062190(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_SOUTH, 1, 2); + return sub_80621BC(mapObject, sprite); +} + +bool8 sub_80621BC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062214(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_80621E8(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_NORTH, 1, 2); + return sub_8062214(mapObject, sprite); +} + +bool8 sub_8062214(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_806226C(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_8062240(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_WEST, 1, 2); + return sub_806226C(mapObject, sprite); +} + +bool8 sub_806226C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_80622C4(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_8062298(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_EAST, 1, 2); + return sub_80622C4(mapObject, sprite); +} + +bool8 sub_80622C4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_806231C(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_80622F0(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_SOUTH, 0, 0); + return sub_806231C(mapObject, sprite); +} + +bool8 sub_806231C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062374(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_8062348(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_NORTH, 0, 0); + return sub_8062374(mapObject, sprite); +} + +bool8 sub_8062374(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_80623CC(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_80623A0(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_WEST, 0, 0); + return sub_80623CC(mapObject, sprite); +} + +bool8 sub_80623CC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062424(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_80623F8(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_EAST, 0, 0); + return sub_8062424(mapObject, sprite); +} + +bool8 sub_8062424(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_806247C(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_8062450(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_SOUTH, 0, 2); + return sub_806247C(mapObject, sprite); +} + +bool8 sub_806247C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061358(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_80624D4(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_80624A8(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_NORTH, 0, 2); + return sub_80624D4(mapObject, sprite); +} + +bool8 sub_80624D4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061358(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_806252C(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_8062500(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_WEST, 0, 2); + return sub_806252C(mapObject, sprite); +} + +bool8 sub_806252C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061358(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062584(struct MapObject *mapObject, struct Sprite *sprite); + +bool8 sub_8062558(struct MapObject *mapObject, struct Sprite *sprite) +{ + maybe_shadow_1(mapObject, sprite, DIR_EAST, 0, 2); + return sub_8062584(mapObject, sprite); +} + +bool8 sub_8062584(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061358(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_80625B0(struct MapObject *mapObject, struct Sprite *sprite) +{ + an_look_any(mapObject, sprite, gUnknown_0836DC09[mapObject->animPattern]); + return TRUE; +} + +bool8 sub_80625C8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_SOUTH, 0x14); + return FALSE; +} + +bool8 sub_80625D8(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_25 = 0; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_80625E8(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_25 = 1; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_80625F8(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_12 = 1; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_8062608(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_12 = GetFieldObjectGraphicsInfo(mapObject->graphicsId)->inanimate; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_8062634(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_13 = 1; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_8062644(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_13 = 0; + sprite->data2 = 1; + return TRUE; +} + +bool8 do_exclamation_mark_bubble_1(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); + FieldEffectStart(0x0); + sprite->data2 = 1; + return TRUE; +} + +bool8 do_exclamation_mark_bubble_2(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); + FieldEffectStart(0x21); + sprite->data2 = 1; + return TRUE; +} + +bool8 do_heart_bubble(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); + FieldEffectStart(0x2e); + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_8062704(struct MapObject *, struct Sprite *); + +bool8 sub_80626C0(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (mapObject->animPattern == 0x3F) + { + sub_8084794(mapObject); + return FALSE; + } + else if (mapObject->animPattern != 0x39 && mapObject->animPattern != 0x3A) + { + sprite->data2 = 2; + return TRUE; + } + else + { + sub_812869C(mapObject); + sprite->data2 = 1; + return sub_8062704(mapObject, sprite); + } +} + +bool8 sub_8062704(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_81286C4(mapObject)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062724(struct MapObject *mapObject, struct Sprite *sprite) +{ + obj_anim_image_set_and_seek(sprite, 1, 0); + sprite->data2 = 1; + return FALSE; +} + +bool8 sub_8062740(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064864(sprite)) + { + sub_8064820(sprite, 0x20); + sprite->data2 = 2; + } + return FALSE; +} + +bool8 sub_8062764(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_13 ^= 1; + if (sub_8064824(sprite)) + { + mapObject->mapobj_bit_13 = 1; + sprite->data2 = 3; + } + return FALSE; +} + +bool8 sub_80627A0(struct MapObject *mapObject, struct Sprite *sprite) +{ + obj_anim_image_set_and_seek(sprite, 1, 0); + sprite->data2 = 1; + return FALSE; +} + +bool8 sub_80627BC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8064864(sprite)) + { + sub_8064820(sprite, 0x20); + sprite->data2 = 2; + } + return FALSE; +} + +bool8 sub_80627E0(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_13 ^= 1; + if (sub_8064824(sprite)) + { + mapObject->mapobj_bit_13 = 1; + sprite->data2 = 3; + } + return FALSE; +} + +bool8 sub_806281C(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_26 = 1; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_806282C(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_26 = 0; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_806283C(struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->oam.affineMode = 3; + InitSpriteAffineAnim(sprite); + sprite->affineAnimPaused = 1; + sprite->subspriteMode = 0; + return TRUE; +} + +bool8 sub_806286C(struct MapObject *mapObject, struct Sprite *sprite) +{ + FreeOamMatrix(sprite->oam.matrixNum); + sprite->oam.affineMode = 0; + CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode); + return TRUE; +} + +bool8 sub_80628D0(struct MapObject *, struct Sprite *); + +bool8 sub_806289C(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8060ED8(mapObject, sprite, DIR_SOUTH); + sprite->affineAnimPaused = 0; + StartSpriteAffineAnimIfDifferent(sprite, 0); + return sub_80628D0(mapObject, sprite); +} + +bool8 sub_80628D0(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (an_walk_any_2(mapObject, sprite)) + { + sprite->affineAnimPaused = 1; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062930(struct MapObject *, struct Sprite *); + +bool8 sub_80628FC(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8060ED8(mapObject, sprite, DIR_SOUTH); + sprite->affineAnimPaused = 0; + ChangeSpriteAffineAnimIfDifferent(sprite, 1); + return sub_8062930(mapObject, sprite); +} + +bool8 sub_8062930(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (an_walk_any_2(mapObject, sprite)) + { + sprite->affineAnimPaused = 1; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +void sub_806295C(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + FieldObjectSetDirection(mapObject, direction); + npc_coords_shift_still(mapObject); + sub_805FE64(mapObject, sprite, sub_805FDD8(direction)); + sprite->animPaused = 1; + sprite->data2 = 1; +} + +bool8 sub_806299C(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_806295C(mapObject, sprite, DIR_SOUTH); + return TRUE; +} + +bool8 sub_80629AC(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_806295C(mapObject, sprite, DIR_NORTH); + return TRUE; +} + +bool8 sub_80629BC(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_806295C(mapObject, sprite, DIR_WEST); + return TRUE; +} + +bool8 sub_80629CC(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_806295C(mapObject, sprite, DIR_EAST); + return TRUE; +} + +bool8 sub_80629DC(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_SOUTH, sub_805FD98(DIR_SOUTH)); + return FALSE; +} + +bool8 sub_8062A00(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_NORTH, sub_805FD98(DIR_NORTH)); + return FALSE; +} + +bool8 sub_8062A24(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_WEST, sub_805FD98(DIR_WEST)); + return FALSE; +} + +bool8 sub_8062A48(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_EAST, sub_805FD98(DIR_EAST)); + return FALSE; +} + +bool8 sub_8062A6C(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_SOUTH, sub_805FDB8(DIR_SOUTH)); + return FALSE; +} + +bool8 sub_8062A90(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_NORTH, sub_805FDB8(DIR_NORTH)); + return FALSE; +} + +bool8 sub_8062AB4(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_WEST, sub_805FDB8(DIR_WEST)); + return FALSE; +} + +bool8 sub_8062AD8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_EAST, sub_805FDB8(DIR_EAST)); + return FALSE; +} + +bool8 sub_8062AFC(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_SOUTH, sub_805FDC8(DIR_SOUTH)); + return FALSE; +} + +bool8 sub_8062B20(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_NORTH, sub_805FDC8(DIR_NORTH)); + return FALSE; +} + +bool8 sub_8062B44(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_WEST, sub_805FDC8(DIR_WEST)); + return FALSE; +} + +bool8 sub_8062B68(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_EAST, sub_805FDC8(DIR_EAST)); + return FALSE; +} + +void sub_8062B8C(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 a3, u8 a4) +{ + sub_806113C(mapObject, sprite, direction, a3, a4); + StartSpriteAnimIfDifferent(sprite, sub_805FD98(direction)); + DoShadowFieldEffect(mapObject); +} + +bool8 sub_8062BFC(struct MapObject *, struct Sprite *); + +bool8 sub_8062BD0(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_SOUTH, 0, 1); + return sub_8062BFC(mapObject, sprite); +} + +bool8 sub_8062BFC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062C54(struct MapObject *, struct Sprite *); + +bool8 sub_8062C28(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_NORTH, 0, 1); + return sub_8062C54(mapObject, sprite); +} + +bool8 sub_8062C54(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062CAC(struct MapObject *, struct Sprite *); + +bool8 sub_8062C80(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_WEST, 0, 1); + return sub_8062CAC(mapObject, sprite); +} + +bool8 sub_8062CAC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062D04(struct MapObject *, struct Sprite *); + +bool8 sub_8062CD8(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_EAST, 0, 1); + return sub_8062D04(mapObject, sprite); +} + +bool8 sub_8062D04(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062D5C(struct MapObject *, struct Sprite *); + +bool8 sub_8062D30(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_SOUTH, 1, 1); + return sub_8062D5C(mapObject, sprite); +} + +bool8 sub_8062D5C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062DB4(struct MapObject *, struct Sprite *); + +bool8 sub_8062D88(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_NORTH, 1, 1); + return sub_8062DB4(mapObject, sprite); +} + +bool8 sub_8062DB4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062E0C(struct MapObject *, struct Sprite *); + +bool8 sub_8062DE0(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_WEST, 1, 1); + return sub_8062E0C(mapObject, sprite); +} + +bool8 sub_8062E0C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062E64(struct MapObject *, struct Sprite *); + +bool8 sub_8062E38(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_EAST, 1, 1); + return sub_8062E64(mapObject, sprite); +} + +bool8 sub_8062E64(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062EBC(struct MapObject *, struct Sprite *); + +bool8 sub_8062E90(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_SOUTH, 2, 0); + return sub_8062EBC(mapObject, sprite); +} + +bool8 sub_8062EBC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062F14(struct MapObject *, struct Sprite *); + +bool8 sub_8062EE8(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_NORTH, 2, 0); + return sub_8062F14(mapObject, sprite); +} + +bool8 sub_8062F14(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062F6C(struct MapObject *, struct Sprite *); + +bool8 sub_8062F40(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_WEST, 2, 0); + return sub_8062F6C(mapObject, sprite); +} + +bool8 sub_8062F6C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062FC4(struct MapObject *, struct Sprite *); + +bool8 sub_8062F98(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8062B8C(mapObject, sprite, DIR_EAST, 2, 0); + return sub_8062FC4(mapObject, sprite); +} + +bool8 sub_8062FC4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8061328(mapObject, sprite)) + { + mapObject->mapobj_bit_22 = 0; + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8062FF0(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_SOUTH, sub_805FDD8(DIR_SOUTH), 8); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8063028(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_NORTH, sub_805FDD8(DIR_NORTH), 8); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8063060(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_WEST, sub_805FDD8(DIR_WEST), 8); + return sub_8061714(mapObject, sprite); +} + +bool8 sub_8063098(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80616CC(mapObject, sprite, DIR_EAST, sub_805FDD8(DIR_EAST), 8); + return sub_8061714(mapObject, sprite); +} + +void sub_80630D0(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 a3) +{ + sub_8060D20(mapObject, sprite, direction, a3); + StartSpriteAnim(sprite, sub_805FD98(mapObject->mapobj_unk_18)); + SeekSpriteAnim(sprite, 0); +} + +bool8 sub_8063128(struct MapObject *, struct Sprite *); + +bool8 sub_8063108(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80630D0(mapObject, sprite, DIR_SOUTH, 1); + return sub_8063128(mapObject, sprite); +} + +bool8 sub_8063128(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8063168(struct MapObject *, struct Sprite *); + +bool8 sub_8063148(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80630D0(mapObject, sprite, DIR_NORTH, 1); + return sub_8063168(mapObject, sprite); +} + +bool8 sub_8063168(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_80631A8(struct MapObject *, struct Sprite *); + +bool8 sub_8063188(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80630D0(mapObject, sprite, DIR_WEST, 1); + return sub_80631A8(mapObject, sprite); +} + +bool8 sub_80631A8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_80631E8(struct MapObject *, struct Sprite *); + +bool8 sub_80631C8(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80630D0(mapObject, sprite, DIR_EAST, 1); + return sub_80631E8(mapObject, sprite); +} + +bool8 sub_80631E8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +void sub_8063208(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 a3) +{ + sub_8060D20(mapObject, sprite, direction, a3); + sub_805FE28(mapObject, sprite, sub_805FDD8(mapObject->mapobj_unk_18)); +} + +bool8 sub_8063258(struct MapObject *, struct Sprite *); + +bool8 sub_8063238(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8063208(mapObject, sprite, DIR_SOUTH, 1); + return sub_8063258(mapObject, sprite); +} + +bool8 sub_8063258(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8063298(struct MapObject *, struct Sprite *); + +bool8 sub_8063278(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8063208(mapObject, sprite, DIR_NORTH, 1); + return sub_8063298(mapObject, sprite); +} + +bool8 sub_8063298(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_80632D8(struct MapObject *, struct Sprite *); + +bool8 sub_80632B8(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8063208(mapObject, sprite, DIR_WEST, 1); + return sub_80632D8(mapObject, sprite); +} + +bool8 sub_80632D8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8063318(struct MapObject *, struct Sprite *); + +bool8 sub_80632F8(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8063208(mapObject, sprite, DIR_EAST, 1); + return sub_8063318(mapObject, sprite); +} + +bool8 sub_8063318(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +void sub_8063338(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 a3) +{ + sub_8060D20(mapObject, sprite, direction, a3); + StartSpriteAnim(sprite, sub_805FDB8(mapObject->mapobj_unk_18)); + SeekSpriteAnim(sprite, 0); +} + +bool8 sub_8063390(struct MapObject *, struct Sprite *); + +bool8 sub_8063370(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8063338(mapObject, sprite, DIR_SOUTH, 1); + return sub_8063390(mapObject, sprite); +} + +bool8 sub_8063390(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_80633D0(struct MapObject *, struct Sprite *); + +bool8 sub_80633B0(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8063338(mapObject, sprite, DIR_NORTH, 1); + return sub_80633D0(mapObject, sprite); +} + +bool8 sub_80633D0(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8063410(struct MapObject *, struct Sprite *); + +bool8 sub_80633F0(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8063338(mapObject, sprite, DIR_WEST, 1); + return sub_8063410(mapObject, sprite); +} + +bool8 sub_8063410(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8063450(struct MapObject *, struct Sprite *); + +bool8 sub_8063430(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8063338(mapObject, sprite, DIR_EAST, 1); + return sub_8063450(mapObject, sprite); +} + +bool8 sub_8063450(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_8063470(struct MapObject *mapObject, struct Sprite *sprite) +{ + return TRUE; +} + +bool8 sub_8063474(struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->animPaused = 1; + return TRUE; +} + +void npc_obj_transfer_image_anim_pause_flag(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (mapObject->mapobj_bit_10) + { + sprite->animPaused = 1; + } +} + +void sub_80634A0(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (mapObject->mapobj_bit_11) + { + sprite->animPaused = 0; + mapObject->mapobj_bit_10 = 0; + mapObject->mapobj_bit_11 = 0; + } +} + +void sub_80634E8(struct MapObject *, struct Sprite *); +void npc_update_obj_anim_flag(struct MapObject *, struct Sprite *); + +void sub_80634D0(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80634E8(mapObject, sprite); + npc_update_obj_anim_flag(mapObject, sprite); +} + +#ifdef NONMATCHING +void sub_80634E8(struct MapObject *mapObject, struct Sprite *sprite) +{ + u16 x; + u16 y; + s16 x2; + s16 y2; + const struct MapObjectGraphicsInfo *graphicsInfo; + mapObject->mapobj_bit_14 = 0; + graphicsInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); + if (sprite->coordOffsetEnabled) + { + x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX; + y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY; + } else + { + x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX; + y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY; + } + x2 = graphicsInfo->width + x; // offending line + y2 = graphicsInfo->height + y; // similarly offending line + if ((s16)x >= 0x100 || x2 < -0x10) + { + mapObject->mapobj_bit_14 = 1; + } + if ((s16)y >= 0xB0 || y2 < -0x10) + { + mapObject->mapobj_bit_14 = 1; + } +} +#else +__attribute__((naked)) +void sub_80634E8(struct MapObject *mapObject, struct Sprite *sprite) { + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + adds r5, r0, 0\n\ + adds r4, r1, 0\n\ + ldrb r1, [r5, 0x1]\n\ + movs r0, 0x41\n\ + negs r0, r0\n\ + ands r0, r1\n\ + strb r0, [r5, 0x1]\n\ + ldrb r0, [r5, 0x5]\n\ + bl GetFieldObjectGraphicsInfo\n\ + adds r6, r0, 0\n\ + adds r0, r4, 0\n\ + adds r0, 0x3E\n\ + ldrb r1, [r0]\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0806354C\n\ + ldrh r1, [r4, 0x24]\n\ + ldrh r0, [r4, 0x20]\n\ + adds r1, r0\n\ + adds r0, r4, 0\n\ + adds r0, 0x28\n\ + ldrb r0, [r0]\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + ldr r2, _08063544 @ =gSpriteCoordOffsetX\n\ + adds r0, r1\n\ + ldrh r2, [r2]\n\ + adds r0, r2\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + ldrh r1, [r4, 0x26]\n\ + ldrh r0, [r4, 0x22]\n\ + adds r1, r0\n\ + adds r0, r4, 0\n\ + adds r0, 0x29\n\ + ldrb r0, [r0]\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + ldr r2, _08063548 @ =gSpriteCoordOffsetY\n\ + adds r0, r1\n\ + ldrh r2, [r2]\n\ + adds r0, r2\n\ + b _08063574\n\ + .align 2, 0\n\ +_08063544: .4byte gSpriteCoordOffsetX\n\ +_08063548: .4byte gSpriteCoordOffsetY\n\ +_0806354C:\n\ + ldrh r1, [r4, 0x24]\n\ + ldrh r0, [r4, 0x20]\n\ + adds r1, r0\n\ + adds r0, r4, 0\n\ + adds r0, 0x28\n\ + ldrb r0, [r0]\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + adds r0, r1\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + ldrh r1, [r4, 0x26]\n\ + ldrh r0, [r4, 0x22]\n\ + adds r1, r0\n\ + adds r0, r4, 0\n\ + adds r0, 0x29\n\ + ldrb r0, [r0]\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + adds r0, r1\n\ +_08063574:\n\ + lsls r0, 16\n\ + lsrs r2, r0, 16\n\ + ldrh r0, [r6, 0x8]\n\ + adds r0, r3\n\ + lsls r0, 16\n\ + lsrs r1, r0, 16\n\ + ldrh r0, [r6, 0xA]\n\ + adds r0, r2\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + lsls r0, r3, 16\n\ + asrs r0, 16\n\ + cmp r0, 0xFF\n\ + bgt _0806359C\n\ + lsls r0, r1, 16\n\ + asrs r0, 16\n\ + movs r1, 0x10\n\ + negs r1, r1\n\ + cmp r0, r1\n\ + bge _080635A4\n\ +_0806359C:\n\ + ldrb r0, [r5, 0x1]\n\ + movs r1, 0x40\n\ + orrs r0, r1\n\ + strb r0, [r5, 0x1]\n\ +_080635A4:\n\ + lsls r0, r2, 16\n\ + asrs r0, 16\n\ + cmp r0, 0xAF\n\ + bgt _080635B8\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + movs r1, 0x10\n\ + negs r1, r1\n\ + cmp r0, r1\n\ + bge _080635C0\n\ +_080635B8:\n\ + ldrb r0, [r5, 0x1]\n\ + movs r1, 0x40\n\ + orrs r0, r1\n\ + strb r0, [r5, 0x1]\n\ +_080635C0:\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ +.syntax divided\n"); +} +#endif + +void npc_update_obj_anim_flag(struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->invisible = 0; + if (mapObject->mapobj_bit_13 || mapObject->mapobj_bit_14) + { + sprite->invisible = 1; + } +} diff --git a/src/map_obj_80643A4.c b/src/field_map_obj_helpers.c index 20c5303c4..17584c96a 100644..100755 --- a/src/map_obj_80643A4.c +++ b/src/field_map_obj_helpers.c @@ -1,14 +1,14 @@ #include "global.h" -#include "asm.h" -#include "sprite.h" -#include "asm_fieldmap.h" +#include "field_map_obj_helpers.h" #include "field_effect.h" +#include "field_ground_effect.h" +#include "field_map_obj.h" +#include "sprite.h" typedef void (*SpriteStepFunc)(struct Sprite *sprite, u8 dir); extern u32 gUnknown_0202FF84[]; -extern struct UCoords16 gDirectionToVector[]; extern s16 gUnknown_08376194[]; extern SpriteStepFunc *gUnknown_08376180[]; extern s8 *gUnknown_083761D0[]; @@ -17,7 +17,7 @@ extern u8 gUnknown_083761E2[]; extern s16 gUnknown_083761E6[]; extern u8 gUnknown_083761EC[]; -bool8 sub_80643A4(struct MapObject *mapObject) +bool8 FreezeMapObject(struct MapObject *mapObject) { if (mapObject->mapobj_bit_6 || mapObject->mapobj_bit_8) { @@ -34,23 +34,23 @@ bool8 sub_80643A4(struct MapObject *mapObject) } } -void player_bitmagic() +void FreezeMapObjects() { u8 i; for (i = 0; i < 16; i++) if (gMapObjects[i].active && i != gPlayerAvatar.mapObjectId) - sub_80643A4(&gMapObjects[i]); + FreezeMapObject(&gMapObjects[i]); } -void sub_8064470(u8 a1) +void FreezeMapObjectsExceptOne(u8 a1) { u8 i; for (i = 0; i < 16; i++) if (i != a1 && gMapObjects[i].active && i != gPlayerAvatar.mapObjectId) - sub_80643A4(&gMapObjects[i]); + FreezeMapObject(&gMapObjects[i]); } -void npc_sync_anim_pause_bits(struct MapObject *mapObject) +void UnfreezeMapObject(struct MapObject *mapObject) { if (mapObject->active && mapObject->mapobj_bit_8) { @@ -60,42 +60,42 @@ void npc_sync_anim_pause_bits(struct MapObject *mapObject) } } -void sub_806451C(void) +void UnfreezeMapObjects(void) { u8 i; for (i = 0; i < 16; i++) if (gMapObjects[i].active) - npc_sync_anim_pause_bits(&gMapObjects[i]); + UnfreezeMapObject(&gMapObjects[i]); } -void little_step(struct Sprite *sprite, u8 dir) +void Step1(struct Sprite *sprite, u8 dir) { sprite->pos1.x += gDirectionToVector[dir].x; sprite->pos1.y += gDirectionToVector[dir].y; } -void sub_806456C(struct Sprite *sprite, u8 dir) +void Step2(struct Sprite *sprite, u8 dir) { - sprite->pos1.x += 2 * gDirectionToVector[dir].x; - sprite->pos1.y += 2 * gDirectionToVector[dir].y; + sprite->pos1.x += 2 * (u16) gDirectionToVector[dir].x; + sprite->pos1.y += 2 * (u16) gDirectionToVector[dir].y; } -void sub_8064590(struct Sprite *sprite, u8 dir) +void Step3(struct Sprite *sprite, u8 dir) { - sprite->pos1.x += 2 * gDirectionToVector[dir].x + gDirectionToVector[dir].x; - sprite->pos1.y += 2 * gDirectionToVector[dir].y + gDirectionToVector[dir].y; + sprite->pos1.x += 2 * (u16) gDirectionToVector[dir].x + (u16) gDirectionToVector[dir].x; + sprite->pos1.y += 2 * (u16) gDirectionToVector[dir].y + (u16) gDirectionToVector[dir].y; } -void sub_80645B8(struct Sprite *sprite, u8 dir) +void Step4(struct Sprite *sprite, u8 dir) { - sprite->pos1.x += 4 * gDirectionToVector[dir].x; - sprite->pos1.y += 4 * gDirectionToVector[dir].y; + sprite->pos1.x += 4 * (u16) gDirectionToVector[dir].x; + sprite->pos1.y += 4 * (u16) gDirectionToVector[dir].y; } -void sub_80645DC(struct Sprite *sprite, u8 dir) +void Step8(struct Sprite *sprite, u8 dir) { - sprite->pos1.x += 8 * gDirectionToVector[dir].x; - sprite->pos1.y += 8 * gDirectionToVector[dir].y; + sprite->pos1.x += 8 * (u16) gDirectionToVector[dir].x; + sprite->pos1.y += 8 * (u16) gDirectionToVector[dir].y; } void oamt_npc_ministep_reset(struct Sprite *sprite, u8 a2, u8 a3) @@ -131,7 +131,7 @@ bool8 sub_806468C(struct Sprite *sprite) { if (!(sprite->data4 & 1)) { - little_step(sprite, sprite->data3); + Step1(sprite, sprite->data3); sprite->data5++; } @@ -168,7 +168,7 @@ u8 sub_8064704(struct Sprite *sprite) v2 = 0; if (sprite->data4) - little_step(sprite, sprite->data3); + Step1(sprite, sprite->data3); sprite->pos2.y = sub_80646C8(sprite->data6 >> v6[sprite->data4], sprite->data5); @@ -198,7 +198,7 @@ u8 sub_806478C(struct Sprite *sprite) v2 = 0; if (sprite->data4 && !(sprite->data6 & 1)) - little_step(sprite, sprite->data3); + Step1(sprite, sprite->data3); sprite->pos2.y = sub_80646C8(sprite->data6 >> v6[sprite->data4], sprite->data5); @@ -311,7 +311,7 @@ void DoShadowFieldEffect(struct MapObject *mapObject) void DoRippleFieldEffect(struct MapObject *mapObject, struct Sprite *sprite) { - struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); + const struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); gUnknown_0202FF84[0] = sprite->pos1.x; gUnknown_0202FF84[1] = sprite->pos1.y + (gfxInfo->height >> 1) - 2; gUnknown_0202FF84[2] = 151; diff --git a/src/field_message_box.c b/src/field_message_box.c index a7d1a2fd8..2cd2e66ab 100644 --- a/src/field_message_box.c +++ b/src/field_message_box.c @@ -1,21 +1,19 @@ #include "global.h" +#include "field_message_box.h" +#include "menu.h" +#include "string_util.h" +#include "task.h" #include "text.h" #include "text_window.h" -#include "task.h" -#include "string_util.h" -#include "field_message_box.h" extern struct Window gFieldMessageBoxWindow; -extern u16 gMenuTextWindowContentTileOffset; - -extern u16 gMenuTextTileOffset; static u8 sMessageBoxMode; static void Task_FieldMessageBox(u8 taskId); static void CreateFieldMessageBoxTask(void); static void DestroyFieldMessageBoxTask(void); -static void PrintFieldMessage(u8 *message); +static void PrintFieldMessage(const u8 *message); static void PrintFieldMessageFromStringVar4(void); void InitFieldMessageBox(void) @@ -67,7 +65,7 @@ static void DestroyFieldMessageBoxTask(void) DestroyTask(taskId); } -bool8 ShowFieldMessage(u8 *message) +bool8 ShowFieldMessage(const u8 *message) { if (sMessageBoxMode != FIELD_MESSAGE_BOX_HIDDEN) { @@ -81,7 +79,7 @@ bool8 ShowFieldMessage(u8 *message) } } -bool8 ShowFieldAutoScrollMessage(u8 *message) +bool8 ShowFieldAutoScrollMessage(const u8 *message) { if (sMessageBoxMode != FIELD_MESSAGE_BOX_HIDDEN) { @@ -95,14 +93,14 @@ bool8 ShowFieldAutoScrollMessage(u8 *message) } } -bool8 unref_sub_8064BB8(u8 *message) +bool8 unref_sub_8064BB8(const u8 *message) { sMessageBoxMode = FIELD_MESSAGE_BOX_AUTO_SCROLL; PrintFieldMessage(message); return TRUE; } -bool8 unref_sub_8064BD0(u8 *message) +bool8 unref_sub_8064BD0(const u8 *message) { if (sMessageBoxMode != FIELD_MESSAGE_BOX_HIDDEN) { @@ -116,7 +114,7 @@ bool8 unref_sub_8064BD0(u8 *message) } } -static void PrintFieldMessage(u8 *message) +static void PrintFieldMessage(const u8 *message) { StringExpandPlaceholders(gStringVar4, message); sub_8002EB0(&gFieldMessageBoxWindow, gStringVar4, gMenuTextTileOffset, 2, 15); diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 32835a431..3cdb45584 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -1,58 +1,32 @@ #include "global.h" #include "field_player_avatar.h" -#include "asm.h" +#include "bike.h" +#include "event_data.h" +#include "field_effect.h" +#include "field_effect_helpers.h" +#include "field_ground_effect.h" #include "field_map_obj.h" -#include "rom4.h" -#include "flag.h" +#include "field_map_obj_helpers.h" +#include "fieldmap.h" #include "main.h" +#include "map_object_constants.h" #include "menu.h" +#include "metatile_behavior.h" +#include "party_menu.h" #include "rng.h" +#include "rom4.h" +#include "rotating_gate.h" #include "script.h" #include "songs.h" #include "sound.h" +#include "strings2.h" #include "task.h" -#include "field_effect.h" +#include "tv.h" #include "wild_encounter.h" -#include "asm_fieldmap.h" - -extern u8 gOtherText_OhABite[]; -extern u8 gOtherText_PokeOnHook[]; -extern u8 gOtherText_NotEvenANibble[]; -extern u8 gOtherText_ItGotAway[]; - -extern struct -{ - s32 x; - s32 y; - u32 unk8; - u32 unkC; -} gUnknown_0202FF84; - -extern bool8 (*gUnknown_0830FB58[])(u8); -extern u8 (*gUnknown_0830FBA0[])(void); -extern void (*gUnknown_0830FBEC[])(u8, u16); -extern bool8 (*gUnknown_0830FBF8[])(u8); -extern u8 gUnknown_0830FC0C[]; -extern void (*gUnknown_0830FC14[])(struct MapObject *); -extern bool8 (*gUnknown_0830FC34[])(u8); -extern u8 gUnknown_0830FC44[][2]; -extern u8 gUnknown_0830FC54[][2]; -extern u8 gUnknown_0830FC64[2][5][2]; -extern bool8 (*gUnknown_0830FC78[])(u8); //Duplicate of gUnknown_0830FC34 -extern u8 (*gUnknown_0830FC88[])(struct Task *, struct MapObject *, struct MapObject *); -extern u8 (*gUnknown_0830FC94[])(struct Task *, struct MapObject *); -extern u8 (*gUnknown_0830FC98[])(struct Task *, struct MapObject *); -extern u8 gUnknown_0830FCA8[]; -extern u8 gUnknown_0830FCAC[]; -extern u8 (*gUnknown_0830FCB4[])(struct Task *); -extern s16 gUnknown_0830FCF4[]; -extern s16 gUnknown_0830FCFA[]; -extern u8 gUnknown_0830FD00[]; -extern s16 gUnknown_0830FD02[]; -extern s16 gUnknown_0830FD08[]; + +extern u32 gUnknown_0202FF84[]; //Functions -static u32 sub_80587D8(void); static bool8 sub_8058854(struct MapObject *, u8); static void npc_clear_strange_bits(struct MapObject *a); static void MovePlayerAvatarUsingKeypadInput(u8 a, u16 b, u16 c); @@ -78,47 +52,181 @@ static void StartStrengthAnim(u8 a, u8 b); static void sub_8059F94(void); static void sub_805A06C(void); -void sub_80587B4(struct Sprite *sprite) +static bool8 (*const gUnknown_0830FB58[])(u8) = +{ + MetatileBehavior_IsTrickHouseSlipperyFloor, + MetatileBehavior_IsIce_2, + MetatileBehavior_IsWalkSouth, + MetatileBehavior_IsWalkNorth, + MetatileBehavior_IsWalkWest, + MetatileBehavior_IsWalkEast, + MetatileBehavior_IsSouthwardCurrent, + MetatileBehavior_IsNorthwardCurrent, + MetatileBehavior_IsWestwardCurrent, + MetatileBehavior_IsEastwardCurrent, + MetatileBehavior_IsSlideSouth, + MetatileBehavior_IsSlideNorth, + MetatileBehavior_IsSlideWest, + MetatileBehavior_IsSlideEast, + MetatileBehavior_IsWaterfall, + MetatileBehavior_0xBB, + MetatileBehavior_0xBC, + MetatileBehavior_IsMuddySlope, +}; +static u8 (*const gUnknown_0830FBA0[])(void) = +{ + ForcedMovement_None, + ForcedMovement_Slip, + ForcedMovement_Slip, + sub_8058AAC, + sub_8058AC4, + sub_8058ADC, + sub_8058AF4, + sub_8058B0C, + sub_8058B24, + sub_8058B3C, + sub_8058B54, + ForcedMovement_SlideSouth, + ForcedMovement_SlideNorth, + ForcedMovement_SlideWest, + ForcedMovement_SlideEast, + sub_8058B0C, + sub_8058C04, + sub_8058C10, + ForcedMovement_MuddySlope, +}; +static void (*const gUnknown_0830FBEC[])(u8, u16) = +{ + PlayerNotOnBikeNotMoving, + PlayerNotOnBikeTurningInPlace, + sub_8058D0C, +}; +static bool8 (*const gUnknown_0830FBF8[])(u8) = +{ + MetatileBehavior_IsBumpySlope, + MetatileBehavior_IsIsolatedVerticalRail, + MetatileBehavior_IsIsolatedHorizontalRail, + MetatileBehavior_IsVerticalRail, + MetatileBehavior_IsHorizontalRail, +}; +static const u8 gUnknown_0830FC0C[] = {9, 10, 11, 12, 13}; +static void (*const gUnknown_0830FC14[])(struct MapObject *) = +{ + PlayerAvatarTransition_Normal, + PlayerAvatarTransition_MachBike, + PlayerAvatarTransition_AcroBike, + PlayerAvatarTransition_Surfing, + PlayerAvatarTransition_Underwater, + sub_80591F4, + nullsub_49, + nullsub_49, +}; +static bool8 (*const gUnknown_0830FC34[])(u8) = +{ + MetatileBehavior_IsSouthArrowWarp, + MetatileBehavior_IsNorthArrowWarp, + MetatileBehavior_IsWestArrowWarp, + MetatileBehavior_IsEastArrowWarp, +}; +static const u8 sRivalAvatarGfxIds[][2] = +{ + {MAP_OBJ_GFX_RIVAL_BRENDAN_NORMAL, MAP_OBJ_GFX_RIVAL_MAY_NORMAL}, + {MAP_OBJ_GFX_RIVAL_BRENDAN_MACH_BIKE, MAP_OBJ_GFX_RIVAL_MAY_MACH_BIKE}, + {MAP_OBJ_GFX_RIVAL_BRENDAN_ACRO_BIKE, MAP_OBJ_GFX_RIVAL_MAY_ACRO_BIKE}, + {MAP_OBJ_GFX_RIVAL_BRENDAN_SURFING, MAP_OBJ_GFX_RIVAL_MAY_SURFING}, + {MAP_OBJ_GFX_BRENDAN_UNDERWATER, MAP_OBJ_GFX_MAY_UNDERWATER}, + {MAP_OBJ_GFX_RIVAL_BRENDAN_FIELD_MOVE, MAP_OBJ_GFX_RIVAL_MAY_FIELD_MOVE}, + {MAP_OBJ_GFX_BRENDAN_FISHING, MAP_OBJ_GFX_MAY_FISHING}, + {MAP_OBJ_GFX_BRENDAN_WATERING, MAP_OBJ_GFX_MAY_WATERING}, +}; +static const u8 sPlayerAvatarGfxIds[][2] = +{ + {MAP_OBJ_GFX_BRENDAN_NORMAL, MAP_OBJ_GFX_MAY_NORMAL}, + {MAP_OBJ_GFX_BRENDAN_MACH_BIKE, MAP_OBJ_GFX_MAY_MACH_BIKE}, + {MAP_OBJ_GFX_BRENDAN_ACRO_BIKE, MAP_OBJ_GFX_MAY_ACRO_BIKE}, + {MAP_OBJ_GFX_BRENDAN_SURFING, MAP_OBJ_GFX_MAY_SURFING}, + {MAP_OBJ_GFX_BRENDAN_UNDERWATER, MAP_OBJ_GFX_MAY_UNDERWATER}, + {MAP_OBJ_GFX_BRENDAN_FIELD_MOVE, MAP_OBJ_GFX_MAY_FIELD_MOVE}, + {MAP_OBJ_GFX_BRENDAN_FISHING, MAP_OBJ_GFX_MAY_FISHING}, + {MAP_OBJ_GFX_BRENDAN_WATERING, MAP_OBJ_GFX_MAY_WATERING}, +}; +static const u8 gUnknown_0830FC64[2][5][2] = +{ + //male + { + {MAP_OBJ_GFX_BRENDAN_NORMAL, 1}, + {MAP_OBJ_GFX_BRENDAN_MACH_BIKE, 2}, + {MAP_OBJ_GFX_BRENDAN_ACRO_BIKE, 4}, + {MAP_OBJ_GFX_BRENDAN_SURFING, 8}, + {MAP_OBJ_GFX_BRENDAN_UNDERWATER, 16}, + }, + //female + { + {MAP_OBJ_GFX_MAY_NORMAL, 1}, + {MAP_OBJ_GFX_MAY_MACH_BIKE, 2}, + {MAP_OBJ_GFX_MAY_ACRO_BIKE, 4}, + {MAP_OBJ_GFX_MAY_SURFING, 8}, + {MAP_OBJ_GFX_MAY_UNDERWATER, 16}, + } +}; +static bool8 (*const gUnknown_0830FC78[])(u8) = //Duplicate of gUnknown_0830FC34 { - meta_step(&gMapObjects[sprite->data0], sprite, sub_80587D8); -} - -static u32 sub_80587D8(void) + MetatileBehavior_IsSouthArrowWarp, + MetatileBehavior_IsNorthArrowWarp, + MetatileBehavior_IsWestArrowWarp, + MetatileBehavior_IsEastArrowWarp, +}; +static u8 (*const gUnknown_0830FC88[])(struct Task *, struct MapObject *, struct MapObject *) = { - return 0; -} + sub_8059E84, + sub_8059EA4, + sub_8059F40, +}; +static u8 (*const gUnknown_0830FC94[])(struct Task *, struct MapObject *) = +{ + sub_805A000, +}; +static u8 (*const gUnknown_0830FC98[])(struct Task *, struct MapObject *) = +{ + sub_805A0D8, + sub_805A100, + sub_805A178, + sub_805A1B8, +}; -void player_step(u8 a, u16 b, u16 c) +fieldmap_object_null_cb(sub_80587B4, sub_80587D8); + +void player_step(u8 direction, u16 newKeys, u16 heldKeys) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + sub_8059D60(playerMapObj); if (gPlayerAvatar.unk6 == 0) { - sub_80E5B38(b, c); - if (sub_8058854(playerMapObj, a) == 0) + sub_80E5B38(newKeys, heldKeys); + if (!sub_8058854(playerMapObj, direction)) { npc_clear_strange_bits(playerMapObj); DoPlayerAvatarTransition(); if (TryDoMetatileBehaviorForcedMovement() == 0) { - MovePlayerAvatarUsingKeypadInput(a, b, c); + MovePlayerAvatarUsingKeypadInput(direction, newKeys, heldKeys); PlayerAllowForcedMovementIfMovingSameDirection(); } } } } -static bool8 sub_8058854(struct MapObject *a, u8 b) +static bool8 sub_8058854(struct MapObject *playerMapObj, u8 direction) { - if (FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(a) - && !FieldObjectClearAnimIfSpecialAnimFinished(a)) + if (FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(playerMapObj) + && !FieldObjectClearAnimIfSpecialAnimFinished(playerMapObj)) { - u8 specialAnim = FieldObjectGetSpecialAnim(a); - - if (specialAnim > 24 && specialAnim < 29 && b != 0 && a->placeholder18 != b) + u8 specialAnim = FieldObjectGetSpecialAnim(playerMapObj); + + if (specialAnim > 24 && specialAnim < 29 && direction != DIR_NONE && playerMapObj->placeholder18 != direction) { - FieldObjectClearAnim(a); + FieldObjectClearAnim(playerMapObj); return FALSE; } else @@ -137,13 +245,13 @@ static void npc_clear_strange_bits(struct MapObject *a) gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_DASH; } -static void MovePlayerAvatarUsingKeypadInput(u8 a, u16 b, u16 c) +static void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys) { if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE) || (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE)) - MovePlayerOnBike(a, b, c); + MovePlayerOnBike(direction, newKeys, heldKeys); else - MovePlayerNotOnBike(a, c); + MovePlayerNotOnBike(direction, heldKeys); } static void PlayerAllowForcedMovementIfMovingSameDirection(void) @@ -160,11 +268,11 @@ static u8 TryDoMetatileBehaviorForcedMovement(void) static u8 GetForcedMovementByMetatileBehavior(void) { u8 i; - + if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_5)) { u8 r5 = gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E; - + for (i = 0; i < 18; i++) { if (gUnknown_0830FB58[i](r5)) @@ -179,7 +287,7 @@ u8 ForcedMovement_None(void) if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_6) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + playerMapObj->mapobj_bit_9 = 0; playerMapObj->mapobj_bit_11 = 1; FieldObjectSetDirection(playerMapObj, playerMapObj->mapobj_unk_18); @@ -188,23 +296,23 @@ u8 ForcedMovement_None(void) return 0; } -static u8 DoForcedMovement(u8 a, void (*b)(u8)) +static u8 DoForcedMovement(u8 direction, void (*b)(u8)) { struct PlayerAvatar *playerAvatar = &gPlayerAvatar; - u8 r7 = CheckForPlayerAvatarCollision(a); - + u8 collisionType = CheckForPlayerAvatarCollision(direction); + playerAvatar->flags |= PLAYER_AVATAR_FLAG_6; - if (r7 != 0) + if (collisionType != 0) { ForcedMovement_None(); - if (r7 <= 4) + if (collisionType <= 4) { return 0; } else { - if (r7 == 6) - PlayerJumpLedge(a); + if (collisionType == COLLISION_LEDGE_JUMP) + PlayerJumpLedge(direction); playerAvatar->flags |= PLAYER_AVATAR_FLAG_6; playerAvatar->running2 = 2; return 1; @@ -213,7 +321,7 @@ static u8 DoForcedMovement(u8 a, void (*b)(u8)) else { playerAvatar->running2 = 2; - b(a); + b(direction); return 1; } } @@ -221,7 +329,7 @@ static u8 DoForcedMovement(u8 a, void (*b)(u8)) static u8 DoForcedMovementInCurrentDirection(void (*a)(u8)) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + playerMapObj->mapobj_bit_10 = 1; return DoForcedMovement(playerMapObj->placeholder18, a); } @@ -271,13 +379,13 @@ u8 sub_8058B54(void) return DoForcedMovement(4, npc_use_some_d2s); } -static u8 ForcedMovement_Slide(u8 a, void (*b)(u8)) +static u8 ForcedMovement_Slide(u8 direction, void (*b)(u8)) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + playerMapObj->mapobj_bit_10 = 1; playerMapObj->mapobj_bit_9 = 1; - return DoForcedMovement(a, b); + return DoForcedMovement(direction, b); } u8 ForcedMovement_SlideSouth(void) @@ -315,8 +423,8 @@ u8 sub_8058C10(void) u8 ForcedMovement_MuddySlope(void) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - - if (playerMapObj->placeholder18 != 2 || sub_80E6034() <= 3) + + if (playerMapObj->placeholder18 != 2 || GetPlayerSpeed() <= 3) { sub_80E6010(0); playerMapObj->mapobj_bit_9 = 1; @@ -328,19 +436,19 @@ u8 ForcedMovement_MuddySlope(void) } } -static void MovePlayerNotOnBike(u8 a, u16 b) +static void MovePlayerNotOnBike(u8 direction, u16 heldKeys) { - gUnknown_0830FBEC[CheckMovementInputNotOnBike(a)](a, b); + gUnknown_0830FBEC[CheckMovementInputNotOnBike(direction)](direction, heldKeys); } -static u8 CheckMovementInputNotOnBike(u8 a) +static u8 CheckMovementInputNotOnBike(u8 direction) { - if (a == 0) + if (direction == DIR_NONE) { gPlayerAvatar.running2 = 0; return 0; } - else if (a != player_get_direction_upper_nybble() && gPlayerAvatar.running2 != 2) + else if (direction != player_get_direction_upper_nybble() && gPlayerAvatar.running2 != 2) { gPlayerAvatar.running2 = 1; return 1; @@ -352,81 +460,81 @@ static u8 CheckMovementInputNotOnBike(u8 a) } } -void PlayerNotOnBikeNotMoving(u8 a, u16 b) +void PlayerNotOnBikeNotMoving(u8 direction, u16 heldKeys) { PlayerFaceDirection(player_get_direction_lower_nybble()); } -void PlayerNotOnBikeTurningInPlace(u8 a, u16 b) +void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys) { - PlayerTurnInPlace(a); + PlayerTurnInPlace(direction); } -void sub_8058D0C(u8 a, u16 b) +void sub_8058D0C(u8 direction, u16 heldKeys) { - u8 r1 = CheckForPlayerAvatarCollision(a); - + u8 r1 = CheckForPlayerAvatarCollision(direction); + switch (r1) { case 6: - PlayerJumpLedge(a); + PlayerJumpLedge(direction); return; default: if (r1 > 8 || r1 < 5) - PlayerNotOnBikeCollide(a); + PlayerNotOnBikeCollide(direction); return; case 0: if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) { - sub_80593C4(a); + sub_80593C4(direction); return; } - if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_4) && (b & 2) && FlagGet(SYS_B_DASH) - && sub_80E5DEC(gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E) == 0) + if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_4) && (heldKeys & B_BUTTON) && FlagGet(SYS_B_DASH) + && IsRunningDisallowed(gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E) == 0) { - sub_805940C(a); + sub_805940C(direction); gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH; } else { - PlayerGoSpeed0(a); + PlayerGoSpeed0(direction); } } } -static u8 CheckForPlayerAvatarCollision(u8 a) +static u8 CheckForPlayerAvatarCollision(u8 direction) { s16 x, y; struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + x = playerMapObj->coords2.x; y = playerMapObj->coords2.y; - MoveCoords(a, &x, &y); - return CheckForFieldObjectCollision(playerMapObj, x, y, a, MapGridGetMetatileBehaviorAt(x, y)); + MoveCoords(direction, &x, &y); + return CheckForFieldObjectCollision(playerMapObj, x, y, direction, MapGridGetMetatileBehaviorAt(x, y)); } -u8 CheckForFieldObjectCollision(struct MapObject *a, s16 b, s16 c, u8 d, u8 e) +u8 CheckForFieldObjectCollision(struct MapObject *a, s16 x, s16 y, u8 direction, u8 e) { - u8 sp0; - - sp0 = npc_block_way(a, b, c, d); - if (sp0 == 3 && sub_8058EF0(b, c, d)) + u8 collision; + + collision = npc_block_way(a, x, y, direction); + if (collision == 3 && sub_8058EF0(x, y, direction)) return 5; - if (ShouldJumpLedge(b, c, d)) + if (ShouldJumpLedge(x, y, direction)) { - sav12_xor_increment(0x2B); - return 6; + IncrementGameStat(0x2B); + return COLLISION_LEDGE_JUMP; } - if (sp0 == 4 && sub_8058F6C(b, c, d)) + if (collision == 4 && sub_8058F6C(x, y, direction)) return 7; - - if (sp0 == 0) + + if (collision == 0) { - if (CheckForRotatingGatePuzzleCollision(d, b, c)) + if (CheckForRotatingGatePuzzleCollision(direction, x, y)) return 8; - check_acro_bike_metatile(b, c, e, &sp0); + check_acro_bike_metatile(x, y, e, &collision); } - return sp0; + return collision; } static u8 sub_8058EF0(s16 a, s16 b, u8 c) @@ -457,7 +565,7 @@ static u8 sub_8058F6C(s16 a, s16 b, u8 c) if (FlagGet(SYS_USE_STRENGTH)) { u8 mapObjectId = GetFieldObjectIdByXY(a, b); - + if (mapObjectId != 16) { if (gMapObjects[mapObjectId].graphicsId == 0x57) @@ -466,7 +574,7 @@ static u8 sub_8058F6C(s16 a, s16 b, u8 c) b = gMapObjects[mapObjectId].coords2.y; MoveCoords(c, &a, &b); if (npc_block_way(&gMapObjects[mapObjectId], a, b, c) == 0 - && sub_8056F08(MapGridGetMetatileBehaviorAt(a, b)) == 0) + && MetatileBehavior_IsNonAnimDoor(MapGridGetMetatileBehaviorAt(a, b)) == 0) { StartStrengthAnim(mapObjectId, c); return 1; @@ -480,7 +588,7 @@ static u8 sub_8058F6C(s16 a, s16 b, u8 c) static void check_acro_bike_metatile(int unused1, int unused2, u8 c, u8 *d) { u8 i; - + for (i = 0; i < 5; i++) { if (gUnknown_0830FBF8[i](c)) @@ -501,7 +609,7 @@ static void DoPlayerAvatarTransition(void) { u8 i; u32 flags = gPlayerAvatar.bike; - + if (flags != 0) { for (i = 0; i < 8; i++, flags >>= 1) @@ -514,7 +622,7 @@ static void DoPlayerAvatarTransition(void) #else if (flags & 1) { - register void (**funcs)(struct MapObject *) asm("r0") = gUnknown_0830FC14; + register void (*const *funcs)(struct MapObject *) asm("r0") = gUnknown_0830FC14; funcs[i](&gMapObjects[gPlayerAvatar.mapObjectId]); } #endif @@ -539,7 +647,7 @@ void PlayerAvatarTransition_MachBike(struct MapObject *a) sub_805B980(a, GetPlayerAvatarGraphicsIdByStateId(1)); FieldObjectTurn(a, a->placeholder18); SetPlayerAvatarStateMask(2); - sub_80E5FCC(0, 0); + BikeClearState(0, 0); } void PlayerAvatarTransition_AcroBike(struct MapObject *a) @@ -547,20 +655,20 @@ void PlayerAvatarTransition_AcroBike(struct MapObject *a) sub_805B980(a, GetPlayerAvatarGraphicsIdByStateId(2)); FieldObjectTurn(a, a->placeholder18); SetPlayerAvatarStateMask(4); - sub_80E5FCC(0, 0); + BikeClearState(0, 0); sub_80E6084(); } void PlayerAvatarTransition_Surfing(struct MapObject *a) { u8 unk; - + sub_805B980(a, GetPlayerAvatarGraphicsIdByStateId(3)); FieldObjectTurn(a, a->placeholder18); SetPlayerAvatarStateMask(8); - gUnknown_0202FF84.x = a->coords2.x; - gUnknown_0202FF84.y = a->coords2.y; - gUnknown_0202FF84.unk8 = gPlayerAvatar.mapObjectId; + gUnknown_0202FF84[0] = a->coords2.x; + gUnknown_0202FF84[1] = a->coords2.y; + gUnknown_0202FF84[2] = gPlayerAvatar.mapObjectId; unk = FieldEffectStart(8); a->mapobj_unk_1A = unk; sub_8127ED0(unk, 1); @@ -600,7 +708,7 @@ void sub_8059204(void) static bool8 player_is_anim_in_certain_ranges(void) { u8 unk = gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C; - + if (unk < 4 || (unk >= 16 && unk < 0x15) || (unk >= 25 && unk < 41) @@ -631,12 +739,12 @@ static bool8 PlayerCheckIfAnimFinishedOrInactive(void) static void player_set_x22(u8 a) { - gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_22 = a; + gMapObjects[gPlayerAvatar.mapObjectId].animId = a; } u8 player_get_x22(void) { - return gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_22; + return gMapObjects[gPlayerAvatar.mapObjectId].animId; } static void sub_8059348(u8 a) @@ -644,66 +752,66 @@ static void sub_8059348(u8 a) FieldObjectForceSetSpecialAnim(&gMapObjects[gPlayerAvatar.mapObjectId], a); } -void player_npc_set_state_and_x22_etc(u8 a, u8 b) +void PlayerSetAnimId(u8 animId, u8 b) { if (!PlayerIsAnimActive()) { player_set_x22(b); - FieldObjectSetSpecialAnim(&gMapObjects[gPlayerAvatar.mapObjectId], a); + FieldObjectSetSpecialAnim(&gMapObjects[gPlayerAvatar.mapObjectId], animId); } } void PlayerGoSpeed0(u8 a) { - player_npc_set_state_and_x22_etc(GetGoSpeed0AnimId(a), 2); + PlayerSetAnimId(GetGoSpeed0AnimId(a), 2); } void sub_80593C4(u8 a) { - player_npc_set_state_and_x22_etc(sub_8060744(a), 2); + PlayerSetAnimId(sub_8060744(a), 2); } void npc_use_some_d2s(u8 a) { - player_npc_set_state_and_x22_etc(d2s_08064034(a), 2); + PlayerSetAnimId(d2s_08064034(a), 2); } void sub_80593F4(u8 a) { - player_npc_set_state_and_x22_etc(sub_806079C(a), 2); + PlayerSetAnimId(sub_806079C(a), 2); } void sub_805940C(u8 a) { - player_npc_set_state_and_x22_etc(sub_80607F4(a), 2); + PlayerSetAnimId(sub_80607F4(a), 2); } void PlayerOnBikeCollide(u8 a) { PlayCollisionSoundIfNotFacingWarp(a); - player_npc_set_state_and_x22_etc(GetStepInPlaceDelay16AnimId(a), 2); + PlayerSetAnimId(GetStepInPlaceDelay16AnimId(a), 2); } static void PlayerNotOnBikeCollide(u8 a) { PlayCollisionSoundIfNotFacingWarp(a); - player_npc_set_state_and_x22_etc(GetStepInPlaceDelay32AnimId(a), 2); + PlayerSetAnimId(GetStepInPlaceDelay32AnimId(a), 2); } -void PlayerFaceDirection(u8 a) +void PlayerFaceDirection(u8 direction) { - player_npc_set_state_and_x22_etc(GetFaceDirectionAnimId(a), 1); + PlayerSetAnimId(GetFaceDirectionAnimId(direction), 1); } -void PlayerTurnInPlace(u8 a) +void PlayerTurnInPlace(u8 direction) { - player_npc_set_state_and_x22_etc(GetStepInPlaceDelay8AnimId(a), 1); + PlayerSetAnimId(GetStepInPlaceDelay8AnimId(direction), 1); } -void PlayerJumpLedge(u8 a) +void PlayerJumpLedge(u8 direction) { PlaySE(SE_DANSA); - player_npc_set_state_and_x22_etc(GetJumpLedgeAnimId(a), 8); + PlayerSetAnimId(GetJumpLedgeAnimId(direction), 8); } void sub_80594C0(void) @@ -717,76 +825,77 @@ void sub_80594C0(void) void sub_8059504(u8 a) { - player_npc_set_state_and_x22_etc(sub_80609D8(a), 1); + PlayerSetAnimId(sub_80609D8(a), 1); } -void sub_805951C(u8 a) +//normal to wheelie +void PlayerStartWheelie(u8 a) { - player_npc_set_state_and_x22_etc(sub_8060A04(a), 1); + PlayerSetAnimId(sub_8060A04(a), 1); } void sub_8059534(u8 a) { - player_npc_set_state_and_x22_etc(sub_8060A30(a), 1); + PlayerSetAnimId(sub_8060A30(a), 1); } void sub_805954C(u8 a) { PlaySE(SE_JITE_PYOKO); - player_npc_set_state_and_x22_etc(sub_8060A5C(a), 1); + PlayerSetAnimId(sub_8060A5C(a), 1); } void sub_8059570(u8 a) { PlaySE(SE_JITE_PYOKO); - player_npc_set_state_and_x22_etc(sub_8060A88(a), 2); + PlayerSetAnimId(sub_8060A88(a), 2); } void sub_8059594(u8 a) { PlaySE(SE_JITE_PYOKO); - player_npc_set_state_and_x22_etc(sub_8060AB4(a), 8); + PlayerSetAnimId(sub_8060AB4(a), 8); } -void sub_80595B8(u8 a) +void sub_80595B8(u8 direction) { PlaySE(SE_JITE_PYOKO); - player_npc_set_state_and_x22_etc(sub_8060878(a), 1); + PlayerSetAnimId(sub_8060878(direction), 1); } -void sub_80595DC(u8 a) +void sub_80595DC(u8 direction) { PlaySE(SE_WALL_HIT); - player_npc_set_state_and_x22_etc(sub_8060AE0(a), 2); + PlayerSetAnimId(sub_8060AE0(direction), 2); } void sub_8059600(u8 a) { - player_npc_set_state_and_x22_etc(sub_8060B0C(a), 2); + PlayerSetAnimId(sub_8060B0C(a), 2); } void sub_8059618(u8 a) { - player_npc_set_state_and_x22_etc(sub_8060B38(a), 2); + PlayerSetAnimId(sub_8060B38(a), 2); } void sub_8059630(u8 a) { - player_npc_set_state_and_x22_etc(sub_8060B64(a), 2); + PlayerSetAnimId(sub_8060B64(a), 2); } static void PlayCollisionSoundIfNotFacingWarp(u8 a) { s16 x, y; u8 unk = gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E; - + if (!gUnknown_0830FC34[a - 1](unk)) { if (a == 2) { PlayerGetDestCoords(&x, &y); MoveCoords(2, &x, &y); - if (is_tile_x69_2_warp_door(MapGridGetMetatileBehaviorAt(x, y))) + if (MetatileBehavior_IsWarpDoor(MapGridGetMetatileBehaviorAt(x, y))) return; } PlaySE(SE_WALL_HIT); @@ -849,7 +958,7 @@ void sub_80597E8(void) void sub_80597F4(void) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + npc_clear_strange_bits(playerMapObj); FieldObjectSetDirection(playerMapObj, playerMapObj->mapobj_unk_18); if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) @@ -859,51 +968,51 @@ void sub_80597F4(void) } } -u8 sub_805983C(u8 a, u8 b) +u8 GetRivalAvatarGraphicsIdByStateIdAndGender(u8 state, u8 gender) { - return gUnknown_0830FC44[a][b]; + return sRivalAvatarGfxIds[state][gender]; } -static u8 GetPlayerAvatarGraphicsIdByStateIdAndGender(u8 a, u8 b) +static u8 GetPlayerAvatarGraphicsIdByStateIdAndGender(u8 state, u8 gender) { - return gUnknown_0830FC54[a][b]; + return sPlayerAvatarGfxIds[state][gender]; } -u8 GetPlayerAvatarGraphicsIdByStateId(u8 a) +u8 GetPlayerAvatarGraphicsIdByStateId(u8 state) { - return GetPlayerAvatarGraphicsIdByStateIdAndGender(a, gPlayerAvatar.gender); + return GetPlayerAvatarGraphicsIdByStateIdAndGender(state, gPlayerAvatar.gender); } -u8 unref_sub_8059888(u8 a) +u8 unref_GetRivalAvatarGenderByGraphcsId(u8 gfxId) { - switch (a) + switch (gfxId) { - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x70: - case 0x8A: - case 0xC0: + case MAP_OBJ_GFX_RIVAL_MAY_NORMAL: + case MAP_OBJ_GFX_RIVAL_MAY_MACH_BIKE: + case MAP_OBJ_GFX_RIVAL_MAY_ACRO_BIKE: + case MAP_OBJ_GFX_RIVAL_MAY_SURFING: + case MAP_OBJ_GFX_RIVAL_MAY_FIELD_MOVE: + case MAP_OBJ_GFX_MAY_UNDERWATER: + case MAP_OBJ_GFX_MAY_FISHING: + case MAP_OBJ_GFX_MAY_WATERING: return FEMALE; default: return MALE; } } -u8 GetPlayerAvatarGenderByGraphicsId(u8 a) +u8 GetPlayerAvatarGenderByGraphicsId(u8 gfxId) { - switch (a) + switch (gfxId) { - case 0x59: - case 0x5A: - case 0x5B: - case 0x5C: - case 0x5D: - case 0x70: - case 0x8A: - case 0xC0: + case MAP_OBJ_GFX_MAY_NORMAL: + case MAP_OBJ_GFX_MAY_MACH_BIKE: + case MAP_OBJ_GFX_MAY_ACRO_BIKE: + case MAP_OBJ_GFX_MAY_SURFING: + case MAP_OBJ_GFX_MAY_FIELD_MOVE: + case MAP_OBJ_GFX_MAY_UNDERWATER: + case MAP_OBJ_GFX_MAY_FISHING: + case MAP_OBJ_GFX_MAY_WATERING: return FEMALE; default: return MALE; @@ -913,7 +1022,7 @@ u8 GetPlayerAvatarGenderByGraphicsId(u8 a) bool8 PartyHasMonWithSurf(void) { u8 i; - + if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) { for (i = 0; i < 6; i++) @@ -929,7 +1038,7 @@ bool8 PartyHasMonWithSurf(void) bool8 IsPlayerSurfingNorth(void) { - if (player_get_direction_upper_nybble() == 2 && TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) + if (player_get_direction_upper_nybble() == DIR_NORTH && TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) return TRUE; else return FALSE; @@ -940,7 +1049,7 @@ bool8 IsPlayerFacingSurfableFishableWater(void) struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; s16 x = playerMapObj->coords2.x; s16 y = playerMapObj->coords2.y; - + MoveCoords(playerMapObj->mapobj_unk_18, &x, &y); if (npc_block_way(playerMapObj, x, y, playerMapObj->mapobj_unk_18) == 3 && PlayerGetZCoord() == 3 && MetatileBehavior_IsSurfableFishableWater(MapGridGetMetatileBehaviorAt(x, y))) @@ -952,7 +1061,7 @@ bool8 IsPlayerFacingSurfableFishableWater(void) void ClearPlayerAvatarInfo(void) { //TODO: 0x24 should be the size of gPlayerAvatar - memset(&gPlayerAvatar, 0, 0x24); + memset(&gPlayerAvatar, 0, sizeof(struct PlayerAvatar)); } void SetPlayerAvatarStateMask(u8 a) @@ -964,7 +1073,7 @@ void SetPlayerAvatarStateMask(u8 a) static u8 GetPlayerAvatarStateTransitionByGraphicsId(u8 a, u8 gender) { u8 i; - + for (i = 0; i < 5; i++) { if (gUnknown_0830FC64[gender][i][0] == a) @@ -977,7 +1086,7 @@ u8 GetPlayerAvatarGraphicsIdByCurrentState(void) { u8 i; u8 r5 = gPlayerAvatar.flags; - + for (i = 0; i < 5; i++) { if (gUnknown_0830FC64[gPlayerAvatar.gender][i][1] & r5) @@ -989,40 +1098,40 @@ u8 GetPlayerAvatarGraphicsIdByCurrentState(void) void SetPlayerAvatarExtraStateTransition(u8 a, u8 b) { u8 unk = GetPlayerAvatarStateTransitionByGraphicsId(a, gPlayerAvatar.gender); - + gPlayerAvatar.bike |= unk | b; DoPlayerAvatarTransition(); } -void InitPlayerAvatar(s16 a, s16 b, u8 c, u8 d) +void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender) { - struct UnknownStruct_FPA s; + struct MapObjectTemplate playerMapObjTemplate; u8 mapObjectId; struct MapObject *mapObject; - - s.unk0 = 0xFF; - s.unk1 = GetPlayerAvatarGraphicsIdByStateIdAndGender(0, d); - s.unk4 = a - 7; - s.unk6 = b - 7; - s.unk8 = 0; - s.unk9 = 11; - s.unkA_0 = 0; - s.unkA_4 = 0; - s.unkC = 0; - s.unkE = 0; - s.unk10 = 0; - s.unk14 = 0; - mapObjectId = SpawnSpecialFieldObject(&s); + + playerMapObjTemplate.localId = 0xFF; + playerMapObjTemplate.graphicsId = GetPlayerAvatarGraphicsIdByStateIdAndGender(0, gender); + playerMapObjTemplate.x = x - 7; + playerMapObjTemplate.y = y - 7; + playerMapObjTemplate.elevation = 0; + playerMapObjTemplate.movementType = 11; + playerMapObjTemplate.unkA_0 = 0; + playerMapObjTemplate.unkA_4 = 0; + playerMapObjTemplate.unkC = 0; + playerMapObjTemplate.unkE = 0; + playerMapObjTemplate.script = NULL; + playerMapObjTemplate.flagId = 0; + mapObjectId = SpawnSpecialFieldObject(&playerMapObjTemplate); mapObject = &gMapObjects[mapObjectId]; mapObject->mapobj_bit_16 = 1; mapObject->mapobj_unk_1B = sub_8126B54(); - FieldObjectTurn(mapObject, c); + FieldObjectTurn(mapObject, direction); ClearPlayerAvatarInfo(); gPlayerAvatar.running2 = 0; gPlayerAvatar.running1 = 0; gPlayerAvatar.mapObjectId = mapObjectId; gPlayerAvatar.spriteId = mapObject->spriteId; - gPlayerAvatar.gender = d; + gPlayerAvatar.gender = gender; SetPlayerAvatarStateMask(0x21); } @@ -1064,7 +1173,7 @@ static void sub_8059D60(struct MapObject *a) s16 y; u8 r6; u8 r8 = a->mapobj_unk_1E; - + for (x = 0, r6 = 1; x < 4; x++, r6++) { if (gUnknown_0830FC78[x](r8) && r6 == a->placeholder18) @@ -1086,7 +1195,7 @@ static void sub_8059E2C(u8 taskId); static void StartStrengthAnim(u8 a, u8 b) { u8 taskId = CreateTask(sub_8059E2C, 0xFF); - + gTasks[taskId].data[1] = a; gTasks[taskId].data[2] = b; sub_8059E2C(taskId); @@ -1117,10 +1226,10 @@ u8 sub_8059EA4(struct Task *task, struct MapObject *b, struct MapObject *c) FieldObjectClearAnimIfSpecialAnimFinished(c); FieldObjectSetSpecialAnim(b, GetStepInPlaceDelay16AnimId(task->data[2])); FieldObjectSetSpecialAnim(c, GetSimpleGoAnimId(task->data[2])); - gUnknown_0202FF84.x = c->coords2.x; - gUnknown_0202FF84.y = c->coords2.y; - gUnknown_0202FF84.unk8 = c->elevation; - gUnknown_0202FF84.unkC = gSprites[c->spriteId].oam.priority; + gUnknown_0202FF84[0] = c->coords2.x; + gUnknown_0202FF84[1] = c->coords2.y; + gUnknown_0202FF84[2] = c->elevation; + gUnknown_0202FF84[3] = gSprites[c->spriteId].oam.priority; FieldEffectStart(10); PlaySE(SE_W070); task->data[0]++; @@ -1149,7 +1258,7 @@ static void sub_8059FB4(u8 taskId); static void sub_8059F94(void) { u8 taskId = CreateTask(sub_8059FB4, 0xFF); - + sub_8059FB4(taskId); } @@ -1184,7 +1293,7 @@ static void sub_805A08C(u8 taskId); static void sub_805A06C(void) { u8 taskId = CreateTask(sub_805A08C, 0xFF); - + sub_805A08C(taskId); } @@ -1206,13 +1315,12 @@ u8 sub_805A0D8(struct Task *task, struct MapObject *mapObject) u8 sub_805A100(struct Task *task, struct MapObject *mapObject) { - u8 directions[4]; - - memcpy(directions, gUnknown_0830FCA8, sizeof(directions)); + u8 directions[] = {DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; + if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) { u8 direction; - + FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(direction = directions[mapObject->placeholder18 - 1])); if (direction == (u8)task->data[1]) task->data[2]++; @@ -1225,9 +1333,8 @@ u8 sub_805A100(struct Task *task, struct MapObject *mapObject) u8 sub_805A178(struct Task *task, struct MapObject *mapObject) { - u8 arr[5]; - - memcpy(arr, gUnknown_0830FCAC, sizeof(arr)); + const u8 arr[] = {16, 16, 17, 18, 19}; + if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) { FieldObjectSetSpecialAnim(mapObject, arr[task->data[2]]); @@ -1256,7 +1363,7 @@ static void sub_805A2D0(u8 taskId); void sub_805A20C(u8 a) { u8 taskId; - + ScriptContext2_Enable(); sav1_reset_battle_music_maybe(); sub_8053F84(); @@ -1271,7 +1378,7 @@ void sub_805A20C(u8 a) static void taskFF_0805D1D4(u8 taskId) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + if (FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(playerMapObj)) { if (!FieldObjectClearAnimIfSpecialAnimFinished(playerMapObj)) @@ -1285,7 +1392,7 @@ static void taskFF_0805D1D4(u8 taskId) static void sub_805A2D0(u8 taskId) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + if (FieldObjectClearAnimIfSpecialAnimFinished(playerMapObj)) { sub_805B980(playerMapObj, GetPlayerAvatarGraphicsIdByStateId(0)); @@ -1299,13 +1406,33 @@ static void sub_805A2D0(u8 taskId) /* Fishing */ +static u8 (*const gUnknown_0830FCB4[])(struct Task *) = +{ + Fishing1, + Fishing2, + Fishing3, + Fishing4, + Fishing5, + Fishing6, + Fishing7, + Fishing8, + Fishing9, + Fishing10, + Fishing11, + Fishing12, + Fishing13, + Fishing14, + Fishing15, + Fishing16, +}; + static void Task_Fishing(u8 taskId); static void sub_805A954(void); void StartFishing(u8 a) { u8 taskId = CreateTask(Task_Fishing, 0xFF); - + gTasks[taskId].data[15] = a; Task_Fishing(taskId); } @@ -1326,12 +1453,10 @@ u8 Fishing1(struct Task *task) u8 Fishing2(struct Task *task) { - s16 arr1[3]; - s16 arr2[3]; struct MapObject *playerMapObj; - - memcpy(arr1, gUnknown_0830FCF4, sizeof(arr1)); - memcpy(arr2, gUnknown_0830FCFA, sizeof(arr2)); + const s16 arr1[] = {1, 1, 1}; + const s16 arr2[] = {1, 3, 6}; + task->data[12] = 0; task->data[13] = arr1[task->data[15]] + (Random() % arr2[task->data[15]]); task->data[14] = gMapObjects[gPlayerAvatar.mapObjectId].graphicsId; @@ -1355,7 +1480,7 @@ u8 Fishing3(struct Task *task) u8 Fishing4(struct Task *task) { u32 randVal; - + MenuDisplayMessageBox(); task->data[0]++; task->data[1] = 0; @@ -1372,9 +1497,8 @@ u8 Fishing4(struct Task *task) u8 Fishing5(struct Task *task) { - u8 dot[2]; - - memcpy(dot, gUnknown_0830FD00, sizeof(dot)); + const u8 dot[] = _("·"); + sub_805A954(); task->data[1]++; if (gMain.newKeys & A_BUTTON) @@ -1428,9 +1552,8 @@ u8 Fishing7(struct Task *task) u8 Fishing8(struct Task *task) { - s16 arr[3]; - - memcpy(arr, gUnknown_0830FD02, sizeof(arr)); + const s16 arr[3] = {36, 33, 30}; + sub_805A954(); task->data[1]++; if (task->data[1] >= arr[task->data[15]]) @@ -1442,9 +1565,13 @@ u8 Fishing8(struct Task *task) u8 Fishing9(struct Task *task) { - s16 arr[3][2]; - - memcpy(arr, gUnknown_0830FD08, sizeof(arr)); + const s16 arr[][2] = + { + {0, 0}, + {40, 10}, + {70, 30} + }; + sub_805A954(); task->data[0]++; if (task->data[12] < task->data[13]) @@ -1454,7 +1581,7 @@ u8 Fishing9(struct Task *task) else if (task->data[12] < 2) { s16 randVal = Random() % 100; - + if (arr[task->data[15]][task->data[12]] > randVal) task->data[0] = 3; } @@ -1481,7 +1608,7 @@ u8 Fishing11(struct Task *task) if (MenuUpdateWindowText()) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + sub_805B980(playerMapObj, task->data[14]); FieldObjectTurn(playerMapObj, playerMapObj->placeholder18); if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) @@ -1539,7 +1666,7 @@ u8 Fishing15(struct Task *task) if (gSprites[gPlayerAvatar.spriteId].animEnded) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + sub_805B980(playerMapObj, task->data[14]); FieldObjectTurn(playerMapObj, playerMapObj->placeholder18); if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) @@ -1557,7 +1684,7 @@ u8 Fishing16(struct Task *task) { gPlayerAvatar.unk6 = 0; ScriptContext2_Disable(); - sub_806451C(); + UnfreezeMapObjects(); MenuZeroFillScreen(); sub_80BE97C(0); DestroyTask(FindTaskIdByFunc(Task_Fishing)); @@ -1570,7 +1697,7 @@ static void sub_805A954(void) struct Sprite *playerSprite = &gSprites[gPlayerAvatar.spriteId]; u8 animCmdIndex; u8 animType; - + AnimateSprite(playerSprite); playerSprite->pos2.x = 0; playerSprite->pos2.y = 0; diff --git a/src/field_poison.c b/src/field_poison.c index 309ec1d71..8c9e029e1 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -1,12 +1,14 @@ #include "global.h" -#include "asm.h" +#include "field_poison.h" #include "field_message_box.h" +#include "fldeff_80C5CD4.h" #include "pokemon.h" +#include "pokemon_summary_screen.h" #include "script.h" #include "string_util.h" #include "task.h" +#include "text.h" -extern struct Pokemon gPlayerParty[6]; extern u16 gScriptResult; extern u8 fieldPoisonText_PokemonFainted[]; @@ -14,7 +16,7 @@ bool32 CheckMonIsValid(struct Pokemon *pkmn) { // UB: Too few arguments for function 'GetMonData' u16 species2 = GetMonData(pkmn, MON_DATA_SPECIES2); - + if (species2 == 0 || species2 == 0x19C) return FALSE; else @@ -25,7 +27,7 @@ bool32 AllMonsFainted(void) { struct Pokemon *pkmn = &gPlayerParty[0]; int i; - + for (i = 0; i < 6; i++, pkmn++) { // UB: Too few arguments for function 'GetMonData' @@ -39,7 +41,7 @@ void MonFaintFromPoisonOnField(u8 partyMember) { struct Pokemon *pkmn = &gPlayerParty[partyMember]; u32 val = 0; - + AdjustFriendship(pkmn, 7); SetMonData(pkmn, MON_DATA_STATUS, (u8*)&val); GetMonData(pkmn, MON_DATA_NICKNAME, gStringVar1); @@ -49,7 +51,7 @@ void MonFaintFromPoisonOnField(u8 partyMember) bool32 CheckMonFaintedFromPoison(u8 partyMember) { struct Pokemon *pkmn = &gPlayerParty[partyMember]; - + // UB: Too few arguments for function 'GetMonData' if (CheckMonIsValid(pkmn) && GetMonData(pkmn, MON_DATA_HP) == 0 && pokemon_ailments_get_primary(GetMonData(pkmn, MON_DATA_STATUS)) == 1) @@ -68,74 +70,74 @@ enum void Task_WhiteOut(u8 taskId) { s16 *taskData = gTasks[taskId].data; - + switch (taskData[TD_STATE]) { - case 0: //Check if Pokemon have fainted due to poison - while (taskData[TD_PARTY_MEMBER] < 6) + case 0: //Check if Pokemon have fainted due to poison + while (taskData[TD_PARTY_MEMBER] < 6) + { + if (CheckMonFaintedFromPoison(taskData[TD_PARTY_MEMBER])) { - if (CheckMonFaintedFromPoison(taskData[TD_PARTY_MEMBER])) - { - MonFaintFromPoisonOnField(taskData[TD_PARTY_MEMBER]); - ShowFieldMessage(fieldPoisonText_PokemonFainted); - taskData[TD_STATE]++; - return; - } - taskData[TD_PARTY_MEMBER]++; + MonFaintFromPoisonOnField(taskData[TD_PARTY_MEMBER]); + ShowFieldMessage(fieldPoisonText_PokemonFainted); + taskData[TD_STATE]++; + return; } - taskData[TD_STATE] = 2; - break; - case 1: //Wait for message box to disappear - if (IsFieldMessageBoxHidden()) - taskData[TD_STATE]--; //Check next party member - break; - case 2: //Done checking Pokemon - if (AllMonsFainted()) - gScriptResult = 1; - else - gScriptResult = 0; - EnableBothScriptContexts(); - DestroyTask(taskId); - break; + taskData[TD_PARTY_MEMBER]++; + } + taskData[TD_STATE] = 2; + break; + case 1: //Wait for message box to disappear + if (IsFieldMessageBoxHidden()) + taskData[TD_STATE]--; //Check next party member + break; + case 2: //Done checking Pokemon + if (AllMonsFainted()) + gScriptResult = 1; + else + gScriptResult = 0; + EnableBothScriptContexts(); + DestroyTask(taskId); + break; } } -void DoWhiteOut(void) +void ExecuteWhiteOut(void) { CreateTask(Task_WhiteOut, 0x50); ScriptContext1_Stop(); } -u8 overworld_poison(void) +s32 overworld_poison(void) { struct Pokemon *pkmn = &gPlayerParty[0]; u32 numPoisoned = 0; u32 numFainting = 0; int i; - - for(i = 0; i < 6; i++) + + for (i = 0; i < 6; i++) { u32 hp; - + // UB: Too few arguments for function 'GetMonData' if (GetMonData(pkmn, MON_DATA_SANITY_BIT2) != 0 && pokemon_ailments_get_primary(GetMonData(pkmn, MON_DATA_STATUS)) == 1) { hp = GetMonData(pkmn, MON_DATA_HP); - if(hp != 0) + if (hp != 0) hp--; - if(hp == 0) + if (hp == 0) numFainting++; //Pokemon will now faint due to poison SetMonData(pkmn, MON_DATA_HP, (u8 *)&hp); numPoisoned++; } pkmn++; } - if(numFainting != 0 || numPoisoned != 0) + if (numFainting != 0 || numPoisoned != 0) DoFieldPoisonEffect(); - if(numFainting != 0) + if (numFainting != 0) return 2; - if(numPoisoned != 0) + if (numPoisoned != 0) return 1; return 0; } diff --git a/src/field_region_map.c b/src/field_region_map.c new file mode 100644 index 000000000..58b0e37bc --- /dev/null +++ b/src/field_region_map.c @@ -0,0 +1,122 @@ +#include "global.h" +#include "field_region_map.h" +#include "main.h" +#include "menu.h" +#include "palette.h" +#include "region_map.h" +#include "sprite.h" +#include "strings2.h" +#include "text.h" + +struct RegionMapStruct +{ + u8 str[0x16]; + u8 unk16; + u8 filler[0x869]; +}; + +struct UnkStruct +{ + MainCallback callback; + u8 filler[4]; + struct RegionMapStruct unk8; + u16 unk888; +}; + +extern struct UnkStruct unk_2000000; + +void FieldInitRegionMap(MainCallback callback) +{ + SetVBlankCallback(NULL); + unk_2000000.unk888 = 0; + unk_2000000.callback = callback; + SetMainCallback2(CB2_FieldInitRegionMap); +} + +void CB2_FieldInitRegionMap(void) +{ + REG_DISPCNT = 0; + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG2HOFS = 0; + REG_BG2VOFS = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; + ResetSpriteData(); + FreeAllSpritePalettes(); + sub_80FA8EC((u32)&unk_2000000.unk8, 0); + sub_80FBCF0(0, 0); + sub_80FBB3C(1, 1); + SetUpWindowConfig(&gWindowConfig_81E709C); + InitMenuWindow(&gWindowConfig_81E709C); + MenuZeroFillScreen(); + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; + MenuDrawTextWindow(21, 0, 29, 3); + sub_8072BD8(gOtherText_Hoenn, 0x16, 1, 0x38); + MenuDrawTextWindow(16, 16, 29, 19); + sub_813F0C8(); + SetMainCallback2(CB2_FieldRegionMap); + SetVBlankCallback(VBlankCB_FieldRegionMap); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); +} + +void VBlankCB_FieldRegionMap(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void CB2_FieldRegionMap(void) +{ + sub_813EFDC(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +void sub_813EFDC(void) +{ + switch (unk_2000000.unk888) + { + case 0: + REG_DISPCNT = DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; + unk_2000000.unk888++; + break; + case 1: + if (!gPaletteFade.active) + unk_2000000.unk888++; + break; + case 2: + switch (sub_80FAB60()) + { + case 3: + sub_813F0C8(); + break; + case 4: + case 5: + unk_2000000.unk888++; + } + break; + case 3: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + unk_2000000.unk888++; + break; + case 4: + if (!gPaletteFade.active) + { + sub_80FAB10(); + SetMainCallback2(unk_2000000.callback); + } + break; + } +} + +void sub_813F0C8(void) +{ + MenuFillWindowRectWithBlankTile(17, 17, 28, 18); + if (unk_2000000.unk8.unk16) + MenuPrint(unk_2000000.unk8.str, 17, 17); +} diff --git a/src/field_special_scene.c b/src/field_special_scene.c new file mode 100644 index 000000000..c88ac8f65 --- /dev/null +++ b/src/field_special_scene.c @@ -0,0 +1,349 @@ +#include "global.h" +#include "field_special_scene.h" +#include "event_data.h" +#include "field_camera.h" +#include "field_fadetransition.h" +#include "field_map_obj.h" +#include "field_specials.h" +#include "fieldmap.h" +#include "main.h" +#include "palette.h" +#include "rom4.h" +#include "script.h" +#include "script_movement.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" + +#define SECONDS(value) ((signed) (60.0 * value + 0.5)) + +// porthole states +enum +{ + INIT_PORTHOLE, + IDLE_CHECK, + EXECUTE_MOVEMENT, + EXIT_PORTHOLE, +}; + +extern s8 gTruckCamera_HorizontalTable[]; + +extern u8 gUnknown_083D295F[]; +extern u8 gUnknown_083D2961[]; + +s32 GetTruckCameraBobbingY(int a1) +{ + if (!(a1 % 120)) + return -1; + else if ((a1 % 10) <= 4) + return 1; + + return 0; +} + +s32 GetTruckBoxMovement(int a1) // for the box movement? +{ + if (!((a1 + 120) % 180)) + return -1; + + return 0; +} + +void Task_Truck1(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + s16 cameraYpan; + s16 box1 = 0; + s16 box2 = 0; + s16 box3 = 0; + u8 mapNum, mapGroup; + register s16 zero asm("r4"); + + box1 = GetTruckBoxMovement(data[0] + 30) * 4; // top box. + sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3, box1 + 3); + box2 = GetTruckBoxMovement(data[0]) * 2; // bottom left box. + sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 0, box2 - 3); + box3 = GetTruckBoxMovement(data[0]) * 4; // bottom right box. + mapNum = gSaveBlock1.location.mapNum; + mapGroup = gSaveBlock1.location.mapGroup; + zero = 0; + sub_805BD90(3, mapNum, mapGroup, -3, box3); + + if (++data[0] == SECONDS(500)) // this will never run + data[0] = zero; // reset the timer if it gets stuck. + + cameraYpan = GetTruckCameraBobbingY(data[0]); + SetCameraPanning(0, cameraYpan); +} + +void Task_Truck2(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + s16 cameraYpan; + s16 cameraXpan; + s16 box1; + s16 box2; + s16 box3; + + data[0]++; + data[2]++; + + if (data[0] > 5) + { + data[0] = 0; + data[1]++; + } + if ((u16)data[1] == 19) + { + DestroyTask(taskId); + } + else + { + if (gTruckCamera_HorizontalTable[data[1]] == 2) + gTasks[taskId].func = Task_Truck3; + + cameraXpan = gTruckCamera_HorizontalTable[data[1]]; + cameraYpan = GetTruckCameraBobbingY(data[2]); + SetCameraPanning(cameraXpan, cameraYpan); + box1 = GetTruckBoxMovement(data[2] + 30) * 4; + sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3 - cameraXpan, box1 + 3); + box2 = GetTruckBoxMovement(data[2]) * 2; + sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -cameraXpan, box2 - 3); + box3 = GetTruckBoxMovement(data[2]) * 4; + sub_805BD90(3, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -3 - cameraXpan, box3); + } +} + +void Task_Truck3(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + s16 cameraXpan; + s16 cameraYpan; + + data[0]++; + + if (data[0] > 5) + { + data[0] = 0; + data[1]++; + } + + if ((u16)data[1] == 19) + { + DestroyTask(taskId); + } + else + { + cameraXpan = gTruckCamera_HorizontalTable[data[1]]; + cameraYpan = 0; + SetCameraPanning(cameraXpan, 0); + sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3 - cameraXpan, cameraYpan + 3); + sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -cameraXpan, cameraYpan - 3); + sub_805BD90(3, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -3 - cameraXpan, cameraYpan); + } +} + +void Task_HandleTruckSequence(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + switch (data[0]) + { + /* + Each case has a timer which is handled with data[1], incrementing + until it reaches the if function's condition, which sets the next task up. + */ + case 0: + data[1]++; + if (data[1] == SECONDS(1.5)) + { + SetCameraPanningCallback(0); + data[1] = 0; // reset the timer. + data[2] = CreateTask(Task_Truck1, 0xA); + data[0] = 1; // run the next case. + PlaySE(SE_TRACK_MOVE); + } + break; + case 1: + data[1]++; + if (data[1] == SECONDS(2.5)) + { + pal_fill_black(); + data[1] = 0; + data[0] = 2; + } + break; + case 2: + data[1]++; + if (!gPaletteFade.active && data[1] > SECONDS(5)) + { + data[1] = 0; + DestroyTask(data[2]); + data[3] = CreateTask(Task_Truck2, 0xA); + data[0] = 3; + PlaySE(SE_TRACK_STOP); + } + break; + case 3: + if (!gTasks[data[3]].isActive) // is Truck2 no longer active (is Truck3 active?) + { + InstallCameraPanAheadCallback(); + data[1] = 0; + data[0] = 4; + } + break; + case 4: + data[1]++; + if (data[1] == 90) + { + PlaySE(SE_TRACK_HAIK); + data[1] = 0; + data[0] = 5; + } + break; + case 5: + data[1]++; + if (data[1] == 120) + { + MapGridSetMetatileIdAt(11, 8, 520); + MapGridSetMetatileIdAt(11, 9, 528); + MapGridSetMetatileIdAt(11, 10, 536); + DrawWholeMapView(); + PlaySE(SE_TRACK_DOOR); + DestroyTask(taskId); + ScriptContext2_Disable(); + } + break; + } +} + +void ExecuteTruckSequence(void) +{ + MapGridSetMetatileIdAt(11, 8, 525); + MapGridSetMetatileIdAt(11, 9, 533); + MapGridSetMetatileIdAt(11, 10, 541); + DrawWholeMapView(); + ScriptContext2_Enable(); + CpuFastFill(0, gPlttBufferFaded, 0x400); + CreateTask(Task_HandleTruckSequence, 0xA); +} + +void EndTruckSequence(void) +{ + if (!FuncIsActiveTask(Task_HandleTruckSequence)) + { + sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3, 3); + sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 0, -3); + sub_805BD90(3, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -3, 0); + } +} + +bool8 sub_80C7754(void) +{ + s8 mapGroup, mapNum; + s16 x, y; + + if (GetSSTidalLocation(&mapGroup, &mapNum, &x, &y)) + { + return FALSE; + } + else + { + warp1_set(mapGroup, mapNum, -1, x, y); + return TRUE; + } +} + +void Task_HandlePorthole(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + u16 *var = GetVarPointer(VAR_PORTHOLE); + struct WarpData *location = &gSaveBlock1.location; + + switch (data[0]) + { + case INIT_PORTHOLE: // finish fading before making porthole finish. + if (!gPaletteFade.active) + { + data[1] = 0; + data[0] = EXECUTE_MOVEMENT; // execute movement before checking if should be exited. strange? + } + break; + case IDLE_CHECK: // idle and move. + if (gMain.newKeys & A_BUTTON) + data[1] = 1; + if (!sub_80A212C(0xFF, location->mapNum, location->mapGroup)) + return; + if (CountSSTidalStep(1) == TRUE) + { + if (*var == 2) + *var = 9; + else + *var = 10; + data[0] = 3; + return; + } + data[0] = 2; + case EXECUTE_MOVEMENT: // execute movement. + if (data[1]) + { + data[0] = EXIT_PORTHOLE; // exit porthole. + return; + } + // run this once. + if (*var == 2) // which direction? + { + exec_movement(0xFF, location->mapNum, location->mapGroup, gUnknown_083D295F); + data[0] = IDLE_CHECK; // run case 1. + } + else + { + exec_movement(0xFF, location->mapNum, location->mapGroup, gUnknown_083D2961); + data[0] = IDLE_CHECK; // run case 1. + } + break; + case EXIT_PORTHOLE: // exit porthole. + FlagReset(0x4001); + FlagReset(0x4000); + copy_saved_warp2_bank_and_enter_x_to_warp1(0); + sp13E_warp_to_last_warp(); + DestroyTask(taskId); + break; + } +} + +void sub_80C78A0(void) +{ + u8 spriteId = AddPseudoFieldObject(0x8C, SpriteCallbackDummy, 112, 80, 0); + + gSprites[spriteId].coordOffsetEnabled = FALSE; + + if (VarGet(0x40B4) == 2) + { + StartSpriteAnim(&gSprites[spriteId], FieldObjectDirectionToImageAnimId(4)); + } + else + { + StartSpriteAnim(&gSprites[spriteId], FieldObjectDirectionToImageAnimId(3)); + } +} + +void sub_80C791C(void) +{ + sub_80C78A0(); + gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = TRUE; + pal_fill_black(); + CreateTask(Task_HandlePorthole, 80); + ScriptContext2_Enable(); +} + +void sub_80C7958(void) +{ + FlagSet(SYS_CRUISE_MODE); + FlagSet(0x4001); + FlagSet(0x4000); + saved_warp2_set(0, gSaveBlock1.location.mapGroup, gSaveBlock1.location.mapNum, -1); + sub_80C7754(); + sub_8080F9C(); +} diff --git a/src/field_specials.c b/src/field_specials.c new file mode 100755 index 000000000..2b505bbfe --- /dev/null +++ b/src/field_specials.c @@ -0,0 +1,2365 @@ +#include "global.h" +#include "field_specials.h" +#include "diploma.h" +#include "fieldmap.h" +#include "event_data.h" +#include "battle_tower.h" +#include "field_map_obj.h" +#include "region_map.h" +#include "field_region_map.h" +#include "field_message_box.h" +#include "field_camera.h" +#include "field_player_avatar.h" +#include "main.h" +#include "map_constants.h" +#include "rom4.h" +#include "script.h" +#include "songs.h" +#include "string_util.h" +#include "strings.h" +#include "pokeblock.h" +#include "species.h" +#include "abilities.h" +#include "moves.h" +#include "text.h" +#include "wallclock.h" +#include "tv.h" +#include "rtc.h" +#include "link.h" +#include "songs.h" +#include "sound.h" +#include "menu.h" +#include "starter_choose.h" +#include "menu_helpers.h" +#include "battle_tower.h" +#include "field_weather.h" +#include "pokemon_summary_screen.h" +#include "rng.h" + +#if ENGLISH +#define CHAR_DECIMAL_SEPARATOR CHAR_PERIOD +#elif GERMAN +#define CHAR_DECIMAL_SEPARATOR CHAR_COMMA +#endif +static void RecordCyclingRoadResults(u32, u8); + +void sub_810D6A4(void) { + SetMainCallback2(sub_8145D88); + ScriptContext2_Enable(); +} + +void sub_810D6B8(void) { + gMain.savedCallback = c2_exit_to_overworld_2_switch; + SetMainCallback2(CB2_ViewWallClock); + ScriptContext2_Enable(); +} + +void ResetCyclingRoadChallengeData(void) { + gUnknown_02039250 = 0; + gUnknown_02039251 = 0; + gUnknown_02039254 = 0; +} + +void BeginCyclingRoadChallenge(void) { + gUnknown_02039250 = 1; + gUnknown_02039251 = 0; + gUnknown_02039254 = gMain.vblankCounter1; +} + +u16 GetPlayerAvatarBike(void) { + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE)) + { + return 1; + } + + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE)) + { + return 2; + } + + return 0; +} + +void DetermineCyclingRoadResults(u32 arg0, u8 arg1) { + u8 result; + + if (arg1 <= 99) + { + ConvertIntToDecimalStringN(gStringVar1, arg1, STR_CONV_MODE_LEFT_ALIGN, 2); + StringAppend(gStringVar1, gOtherText_Times); + } + else + { + StringCopy(gStringVar1, gOtherText_99Times); + } + + if (arg0 < 3600) + { + ConvertIntToDecimalStringN(gStringVar2, arg0 / 60, STR_CONV_MODE_RIGHT_ALIGN, 2); + gStringVar2[2] = CHAR_DECIMAL_SEPARATOR; + ConvertIntToDecimalStringN(&gStringVar2[3], ((arg0 % 60) * 100) / 60, STR_CONV_MODE_LEADING_ZEROS, 2); + StringAppend(gStringVar2, gOtherText_Seconds); + } + else + { + StringCopy(gStringVar2, gOtherText_1Minute); + } + + result = 0; + if (arg1 == 0) + { + result = 5; + } + else if (arg1 < 4) + { + result = 4; + } + else if (arg1 < 10) + { + result = 3; + } + else if (arg1 < 20) + { + result = 2; + } + else if (arg1 < 100) + { + result = 1; + } + + if (arg0 / 60 <= 10) + { + result += 5; + } + else if (arg0 / 60 <= 15) + { + result += 4; + } + else if (arg0 / 60 <= 20) + { + result += 3; + } + else if (arg0 / 60 <= 40) + { + result += 2; + } + else if (arg0 / 60 < 60) + { + result += 1; + } + + + gScriptResult = result; +} + +void FinishCyclingRoadChallenge(void) { + const u32 time = gMain.vblankCounter1 - gUnknown_02039254; + + DetermineCyclingRoadResults(time, gUnknown_02039251); + RecordCyclingRoadResults(time, gUnknown_02039251); +} + +static void RecordCyclingRoadResults(u32 arg0, u8 arg1) { + u16 high = VarGet(0x4028); + u16 low = VarGet(0x4029); + u32 record = high + (low << 16); + + if (record > arg0 || record == 0) + { + VarSet(0x4028, arg0); + VarSet(0x4029, arg0 >> 16); + VarSet(0x4027, arg1); + } +} + +u16 GetRecordedCyclingRoadResults(void) { + u16 high = VarGet(0x4028); + u16 low = VarGet(0x4029); + u32 record = high + (low << 16); + + if (record == 0) + { + return FALSE; + } + + DetermineCyclingRoadResults(record, VarGet(0x4027)); + return TRUE; +} + +void UpdateCyclingRoadState(void) { + if (gUnknown_020297F0.mapNum == MAP_ID_ROUTE110_SEASIDE_CYCLING_ROAD_NORTH_ENTRANCE && gUnknown_020297F0.mapGroup == MAP_GROUP_ROUTE110_SEASIDE_CYCLING_ROAD_NORTH_ENTRANCE) + { + return; + } + + if (VarGet(0x40a9) == 2 || VarGet(0x40a9) == 3) + { + VarSet(0x40a9, 0); + sav1_set_battle_music_maybe(SE_STOP); + } +} + +void SetSSTidalFlag(void) +{ + FlagSet(SYS_CRUISE_MODE); + *GetVarPointer(VAR_CRUISE_STEP_COUNT) = 0; +} + +void ResetSSTidalFlag(void) +{ + FlagReset(SYS_CRUISE_MODE); +} + +bool32 CountSSTidalStep(u16 delta) +{ + if (!FlagGet(SYS_CRUISE_MODE) || (*GetVarPointer(VAR_CRUISE_STEP_COUNT) += delta) <= 0xcc) + { + return FALSE; + } + return TRUE; +} + +u8 GetSSTidalLocation(s8 *mapGroup, s8 *mapNum, s16 *x, s16 *y) +{ + u16 *varCruiseStepCount = GetVarPointer(VAR_CRUISE_STEP_COUNT); + switch (*GetVarPointer(VAR_PORTHOLE)) + { + case 1: + case 8: + return 1; + case 3: + case 9: + return 4; + case 4: + case 5: + return 2; + case 6: + case 10: + return 3; + case 2: + if (*varCruiseStepCount < 60) + { + *mapNum = MAP_ID_ROUTE134; + *x = *varCruiseStepCount + 19; + } + else if (*varCruiseStepCount < 140) + { + *mapNum = MAP_ID_ROUTE133; + *x = *varCruiseStepCount - 60; + } + else + { + *mapNum = MAP_ID_ROUTE132; + *x = *varCruiseStepCount - 140; + } + break; + case 7: + if (*varCruiseStepCount < 66) + { + *mapNum = MAP_ID_ROUTE132; + *x = 65 - *varCruiseStepCount; + } + else if (*varCruiseStepCount < 146) { + *mapNum = MAP_ID_ROUTE133; + *x = 145 - *varCruiseStepCount; + } + else + { + *mapNum = MAP_ID_ROUTE134; + *x = 224 - *varCruiseStepCount; + } + break; + } + *mapGroup = MAP_GROUP_ROUTE132; + *y = 20; + return 0; +} + +u8 GetLinkPartnerNames(void) +{ + u8 i; + u8 j = 0; + u8 myLinkPlayerNumber = sub_8008218(); + u8 nLinkPlayers = sub_800820C(); + for (i=0; i<nLinkPlayers; i++) + { + if (myLinkPlayerNumber != i) + { + StringCopy(gUnknown_083D1464[j], gLinkPlayers[i].name); + j++; + } + } + return nLinkPlayers; +} + +const u8 gUnknown_083F8358[4] = {7, 9, 8, 10}; +const s8 gUnknown_083F835C[4][2] = { + { 0, 1}, + { 1, 0}, + { 0, -1}, + {-1, 0} +}; + +void SpawnBerryBlenderLinkPlayerSprites(void) +{ + u8 unknown_083F8358[4]; + u8 unknown_083F835C[4][2]; + u8 myLinkPlayerNumber; + u8 playerDirectionLowerNybble; + u8 rivalAvatarGraphicsId; + u8 i; + u8 j = 0; + s16 x = 0; + s16 y = 0; + + memcpy(unknown_083F8358, gUnknown_083F8358, sizeof gUnknown_083F8358); + memcpy(unknown_083F835C, gUnknown_083F835C, sizeof gUnknown_083F835C); + myLinkPlayerNumber = sub_8008218(); + playerDirectionLowerNybble = player_get_direction_lower_nybble(); + switch (playerDirectionLowerNybble) + { + case DIR_WEST: + j = 2; + x = gSaveBlock1.pos.x - 1; + y = gSaveBlock1.pos.y; + break; + case DIR_NORTH: + j = 1; + x = gSaveBlock1.pos.x; + y = gSaveBlock1.pos.y - 1; + break; + case DIR_EAST: + x = gSaveBlock1.pos.x + 1; + y = gSaveBlock1.pos.y; + break; + case DIR_SOUTH: + j = 3; + x = gSaveBlock1.pos.x; + y = gSaveBlock1.pos.y + 1; + } + for (i=0; i<gSpecialVar_0x8004; i++) + { + if (myLinkPlayerNumber != i) + { + rivalAvatarGraphicsId = GetRivalAvatarGraphicsIdByStateIdAndGender(0, gLinkPlayers[i].gender); + SpawnSpecialFieldObjectParametrized(rivalAvatarGraphicsId, unknown_083F8358[j], 0xf0 - i, (s8)unknown_083F835C[j][0] + x + 7, (s8)unknown_083F835C[j][1] + y + 7, 0); + j++; + if (j == 4) + { + j = 0; + } + } + } +} + +struct Coords8 { + u8 x; + u8 y; +}; + +const struct Coords8 gUnknown_083F8364[3] = { + { 7, 16}, + {15, 18}, + {11, 22} +}; + +void MauvilleGymSpecial1(void) +{ + u8 i; + for (i=0; i<3; i++) + { + if (i == gSpecialVar_0x8004) + { + MapGridSetMetatileIdAt(gUnknown_083F8364[i].x, gUnknown_083F8364[i].y, 0x206); + } + else + { + MapGridSetMetatileIdAt(gUnknown_083F8364[i].x, gUnknown_083F8364[i].y, 0x205); + } + } +} + +void MauvilleGymSpecial2(void) +{ + int x, y; + for (y=12; y<24; y++) + { + for (x=7; x<16; x++) + { + switch (MapGridGetMetatileIdAt(x, y)) + { + case 0x220: + MapGridSetMetatileIdAt(x, y, 0x230); + break; + case 0x221: + MapGridSetMetatileIdAt(x, y, 0x231); + break; + case 0x228: + MapGridSetMetatileIdAt(x, y, 0x238); + break; + case 0x229: + MapGridSetMetatileIdAt(x, y, 0x239); + break; + case 0x230: + MapGridSetMetatileIdAt(x, y, 0x220); + break; + case 0x231: + MapGridSetMetatileIdAt(x, y, 0x221); + break; + case 0x238: + MapGridSetMetatileIdAt(x, y, 0xe28); + break; + case 0x239: + MapGridSetMetatileIdAt(x, y, 0xe29); + break; + case 0x222: + MapGridSetMetatileIdAt(x, y, 0x232); + break; + case 0x223: + MapGridSetMetatileIdAt(x, y, 0x233); + break; + case 0x22a: + MapGridSetMetatileIdAt(x, y, 0x23a); + break; + case 0x22b: + MapGridSetMetatileIdAt(x, y, 0x23b); + break; + case 0x232: + MapGridSetMetatileIdAt(x, y, 0x222); + break; + case 0x233: + MapGridSetMetatileIdAt(x, y, 0x223); + break; + case 0x23a: + MapGridSetMetatileIdAt(x, y, 0xe2a); + break; + case 0x23b: + MapGridSetMetatileIdAt(x, y, 0xe2b); + break; + case 0x240: + MapGridSetMetatileIdAt(x, y, 0xe42); + break; + case 0x248: + MapGridSetMetatileIdAt(x, y, 0x21a); + break; + case 0x241: + MapGridSetMetatileIdAt(x, y, 0xe43); + break; + case 0x249: + MapGridSetMetatileIdAt(x, y, 0x21a); + break; + case 0x242: + MapGridSetMetatileIdAt(x, y, 0xe40); + break; + case 0x21a: + if (MapGridGetMetatileIdAt(x, y - 1) == 0x240) + { + MapGridSetMetatileIdAt(x, y, 0xe48); + } + else + { + MapGridSetMetatileIdAt(x, y, 0xe49); + } + break; + case 0x243: + MapGridSetMetatileIdAt(x, y, 0xe41); + break; + case 0x251: + MapGridSetMetatileIdAt(x, y, 0xe50); + break; + case 0x250: + MapGridSetMetatileIdAt(x, y, 0x251); + break; + } + } + } +} + +void MauvilleGymSpecial3(void) +{ + int i, x, y; + const struct Coords8 *switchCoords = gUnknown_083F8364; + for (i=ARRAY_COUNT(gUnknown_083F8364)-1; i>=0; i--) + { + MapGridSetMetatileIdAt(switchCoords->x, switchCoords->y, 0x206); + switchCoords++; + } + for (y=12; y<24; y++) + { + for (x=7; x<16; x++) + { + switch (MapGridGetMetatileIdAt(x, y)) + { + case 0x220: + MapGridSetMetatileIdAt(x, y, 0x230); + break; + case 0x221: + MapGridSetMetatileIdAt(x, y, 0x231); + break; + case 0x228: + MapGridSetMetatileIdAt(x, y, 0x238); + break; + case 0x229: + MapGridSetMetatileIdAt(x, y, 0x239); + break; + case 0x222: + MapGridSetMetatileIdAt(x, y, 0x232); + break; + case 0x223: + MapGridSetMetatileIdAt(x, y, 0x233); + break; + case 0x22a: + MapGridSetMetatileIdAt(x, y, 0x23a); + break; + case 0x22b: + MapGridSetMetatileIdAt(x, y, 0x23b); + break; + case 0x240: + MapGridSetMetatileIdAt(x, y, 0xe42); + break; + case 0x241: + MapGridSetMetatileIdAt(x, y, 0xe43); + break; + case 0x248: + case 0x249: + MapGridSetMetatileIdAt(x, y, 0x21a); + break; + case 0x250: + MapGridSetMetatileIdAt(x, y, 0x251); + break; + } + } + } +} + +static void Task_PetalburgGym(u8); +static void PetalburgGymFunc(u8, u16); +const u8 gUnknown_083F8370[] = {0, 1, 1, 1, 1}; +const u16 gUnknown_083F8376[] = {0x218, 0x219, 0x21a, 0x21b, 0x21c}; + +void PetalburgGymSpecial1(void) +{ + gUnknown_02039258 = 0; + gUnknown_02039259 = 0; + PlaySE(SE_KI_GASYAN); + CreateTask(Task_PetalburgGym, 8); +} + +static void Task_PetalburgGym(u8 taskId) +{ + if (gUnknown_083F8370[gUnknown_02039259] == gUnknown_02039258) + { + PetalburgGymFunc(gSpecialVar_0x8004, gUnknown_083F8376[gUnknown_02039259]); + gUnknown_02039258 = 0; + if ((++gUnknown_02039259) == 5) + { + DestroyTask(taskId); + EnableBothScriptContexts(); + } + } + else + { + gUnknown_02039258++; + } +} + +static void PetalburgGymFunc(u8 a0, u16 a1) +{ + u16 x[4]; + u16 y[4]; + u8 i; + u8 nDoors = 0; + switch (a0) + { + case 1: + nDoors = 2; + x[0] = 1; + x[1] = 7; + y[0] = 0x68; + y[1] = 0x68; + break; + case 2: + nDoors = 2; + x[0] = 1; + x[1] = 7; + y[0] = 0x4e; + y[1] = 0x4e; + break; + case 3: + nDoors = 2; + x[0] = 1; + x[1] = 7; + y[0] = 0x5b; + y[1] = 0x5b; + break; + case 4: + nDoors = 1; + x[0] = 7; + y[0] = 0x27; + break; + case 5: + nDoors = 2; + x[0] = 1; + x[1] = 7; + y[0] = 0x34; + y[1] = 0x34; + break; + case 6: + nDoors = 1; + x[0] = 1; + y[0] = 0x41; + break; + case 7: + nDoors = 1; + x[0] = 7; + y[0] = 0xd; + break; + case 8: + nDoors = 1; + x[0] = 1; + y[0] = 0x1a; + break; + } + for (i=0; i<nDoors; i++) + { + MapGridSetMetatileIdAt(x[i] + 7, y[i] + 7, a1 | 0xc00); + MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | 0xc00); + } + DrawWholeMapView(); +} + +void PetalburgGymSpecial2(void) +{ + PetalburgGymFunc(gSpecialVar_0x8004, gUnknown_083F8376[4]); +} + +void ShowFieldMessageStringVar4(void) +{ + ShowFieldMessage(gStringVar4); +} + +void StorePlayerCoordsInVars(void) +{ + gSpecialVar_0x8004 = gSaveBlock1.pos.x; + gSpecialVar_0x8005 = gSaveBlock1.pos.y; +} + +u8 GetPlayerTrainerIdOnesDigit(void) +{ + return (u16)((gSaveBlock2.playerTrainerId[1] << 8) | gSaveBlock2.playerTrainerId[0]) % 10; +} + +void GetPlayerBigGuyGirlString(void) +{ + if (gSaveBlock2.playerGender == MALE) + { + StringCopy(gStringVar1, gOtherText_BigGuy); + } + else + { + StringCopy(gStringVar1, gOtherText_BigGirl); + } +} + +void GetRivalSonDaughterString(void) +{ + if (gSaveBlock2.playerGender == MALE) + { + StringCopy(gStringVar1, gOtherText_Daughter); + } + else + { + StringCopy(gStringVar1, gOtherText_Son); + } +} + +u8 sub_810E300(void) +{ + return gBattleOutcome; +} + +void CableCarWarp(void) +{ + if (gSpecialVar_0x8004 != 0) + { + warp1_set(MAP_GROUP_ROUTE112_CABLE_CAR_STATION, MAP_ID_ROUTE112_CABLE_CAR_STATION, -1, 6, 4); + } + else + { + warp1_set(MAP_GROUP_MT_CHIMNEY_CABLE_CAR_STATION, MAP_ID_MT_CHIMNEY_CABLE_CAR_STATION, -1, 6, 4); + } +} + +void SetFlagInVar(void) +{ + FlagSet(gSpecialVar_0x8004); +} + +u16 GetWeekCount(void) +{ + u16 weekCount = gLocalTime.days / 7; + if (weekCount > 9999) + { + weekCount = 9999; + } + return weekCount; +} + +u8 GetLeadMonFriendshipScore(void) +{ + struct Pokemon *pokemon = &gPlayerParty[GetLeadMonIndex()]; + if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) == 255) + { + return 6; + } + if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 200) + { + return 5; + } + if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 150) + { + return 4; + } + if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 100) + { + return 3; + } + if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 50) + { + return 2; + } + if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 1) + { + return 1; + } + return 0; +} + +void CB2_FieldShowRegionMap(void) +{ + FieldInitRegionMap(c2_exit_to_overworld_1_continue_scripts_restart_music); +} + +void FieldShowRegionMap(void) +{ + SetMainCallback2(CB2_FieldShowRegionMap); +} + +static void Task_PCTurnOnEffect(u8); +static void PCTurnOffEffect_0(struct Task *); +static void PCTurnOffEffect_1(s16, s8, s8); +static void PCTurnOffEffect(void); + +void DoPCTurnOnEffect(void) +{ + if (FuncIsActiveTask(Task_PCTurnOnEffect) != TRUE) + { + u8 taskId = CreateTask(Task_PCTurnOnEffect, 8); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = taskId; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3] = 0; + gTasks[taskId].data[4] = 0; + } +} + +static void Task_PCTurnOnEffect(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + if (task->data[0] == 0) + { + PCTurnOffEffect_0(task); + } +} + +static void PCTurnOffEffect_0(struct Task *task) +{ + u8 playerDirectionLowerNybble; + s8 dx = 0; + s8 dy = 0; + if (task->data[3] == 6) + { + task->data[3] = 0; + playerDirectionLowerNybble = player_get_direction_lower_nybble(); + switch (playerDirectionLowerNybble) + { + case DIR_NORTH: + dx = 0; + dy = -1; + break; + case DIR_WEST: + dx = -1; + dy = -1; + break; + case DIR_EAST: + dx = 1; + dy = -1; + break; + } + PCTurnOffEffect_1(task->data[4], dx, dy); + DrawWholeMapView(); + task->data[4] ^= 1; + if ((++task->data[2]) == 5) + { + DestroyTask(task->data[1]); + } + } + task->data[3]++; +} + +static void PCTurnOffEffect_1(s16 flag, s8 dx, s8 dy) +{ + u16 tileId = 0; + if (flag != 0) + { + if (gSpecialVar_0x8004 == 0) + { + tileId = 0x4; + } + else if (gSpecialVar_0x8004 == 1) + { + tileId = 0x25a; + } + else if (gSpecialVar_0x8004 == 2) + { + tileId = 0x259; + } + } + else + { + if (gSpecialVar_0x8004 == 0) + { + tileId = 0x5; + } + else if (gSpecialVar_0x8004 == 1) + { + tileId = 0x27f; + } + else if (gSpecialVar_0x8004 == 2) + { + tileId = 0x27e; + } + } + MapGridSetMetatileIdAt(gSaveBlock1.pos.x + dx + 7, gSaveBlock1.pos.y + dy + 7, tileId | 0xc00); +} + +void DoPCTurnOffEffect(void) +{ + PCTurnOffEffect(); +} + +static void PCTurnOffEffect(void) +{ + s8 dx = 0; + s8 dy = 0; + u16 tileId = 0; + u8 playerDirectionLowerNybble = player_get_direction_lower_nybble(); + switch (playerDirectionLowerNybble) + { + case DIR_NORTH: + dx = 0; + dy = -1; + break; + case DIR_WEST: + dx = -1; + dy = -1; + break; + case DIR_EAST: + dx = 1; + dy = -1; + break; + } + if (gSpecialVar_0x8004 == 0) + { + tileId = 0x4; + } + else if (gSpecialVar_0x8004 == 1) + { + tileId = 0x25a; + } + else if (gSpecialVar_0x8004 == 2) + { + tileId = 0x259; + } + MapGridSetMetatileIdAt(gSaveBlock1.pos.x + dx + 7, gSaveBlock1.pos.y + dy + 7, tileId | 0xc00); + DrawWholeMapView(); +} + +static void Task_LotteryCornerComputerEffect(u8); +static void LotteryCornerComputerEffect(struct Task *); + +void DoLotteryCornerComputerEffect(void) +{ + if (FuncIsActiveTask(Task_LotteryCornerComputerEffect) != TRUE) + { + u8 taskId = CreateTask(Task_LotteryCornerComputerEffect, 8); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = taskId; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3] = 0; + gTasks[taskId].data[4] = 0; + } +} + +static void Task_LotteryCornerComputerEffect(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + if (task->data[0] == 0) + { + LotteryCornerComputerEffect(task); + } +} + +static void LotteryCornerComputerEffect(struct Task *task) +{ + if (task->data[3] == 6) + { + task->data[3] = 0; + if (task->data[4] != 0) + { + MapGridSetMetatileIdAt(18, 8, 0xe9d); + MapGridSetMetatileIdAt(18, 9, 0xea5); + } + else + { + MapGridSetMetatileIdAt(18, 8, 0xe58); + MapGridSetMetatileIdAt(18, 9, 0xe60); + } + DrawWholeMapView(); + task->data[4] ^= 1; + if ((++task->data[2]) == 5) + { + DestroyTask(task->data[1]); + } + } + task->data[3]++; +} + +void EndLotteryCornerComputerEffect(void) +{ + MapGridSetMetatileIdAt(18, 8, 0xe9d); + MapGridSetMetatileIdAt(18, 9, 0xea5); + DrawWholeMapView(); +} + +static void sub_810E874(void); +void sub_810E944(void); +void sub_810E984(u8); +bool8 sub_810EAC8(u8, u8); +void sub_810EB90(u8, u8); +void sub_810EBEC(void); +void sub_810EC34(u8); +void sub_810EC9C(u8); +void sub_810ECB0(void); +void sub_810ECD4(void); +void sub_810ECFC(void); +void sub_810ED40(u8); +void sub_810ED60(struct Task *); +void sub_810EEDC(void); + +const u8 *const gUnknown_083F8380[] = { + OtherText_1F, + OtherText_2F, + OtherText_3F, + OtherText_4F, + OtherText_5F, + OtherText_6F, + OtherText_7F, + OtherText_8F, + OtherText_9F, + OtherText_10F, + OtherText_11F, + OtherText_B1F, + OtherText_B2F, + OtherText_B3F, + OtherText_B4F, + OtherText_Rooftop +}; + +void SetDepartmentStoreFloorVar(void) +{ + u8 deptStoreFloor; + switch (gSaveBlock1.warp2.mapNum) + { + case MAP_ID_LILYCOVE_CITY_DEPARTMENT_STORE_1F: + deptStoreFloor = 0; + break; + case MAP_ID_LILYCOVE_CITY_DEPARTMENT_STORE_2F: + deptStoreFloor = 1; + break; + case MAP_ID_LILYCOVE_CITY_DEPARTMENT_STORE_3F: + deptStoreFloor = 2; + break; + case MAP_ID_LILYCOVE_CITY_DEPARTMENT_STORE_4F: + deptStoreFloor = 3; + break; + case MAP_ID_LILYCOVE_CITY_DEPARTMENT_STORE_5F: + deptStoreFloor = 4; + break; + case MAP_ID_LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP: + deptStoreFloor = 15; + break; + default: + deptStoreFloor = 0; + break; + } + VarSet(VAR_DEPT_STORE_FLOOR, deptStoreFloor); +} + +void ScriptAddElevatorMenuItem(u8 a0, u8 a1, u8 a2, u8 a3) +{ + u8 i; + if (gSpecialVar_0x8004 == 0) + { + for (i=0; i<20; i++) + { + gUnknown_03000760[i].var0 = 16; + } + } + gUnknown_03000760[gSpecialVar_0x8004].var0 = a0; + gUnknown_03000760[gSpecialVar_0x8004].var1 = a1; + gUnknown_03000760[gSpecialVar_0x8004].var2 = a2; + gUnknown_03000760[gSpecialVar_0x8004].var3 = a3; + gSpecialVar_0x8004++; +} + +void ScriptShowElevatorMenu(void) +{ + u8 i = 0; + gUnknown_0203925A = 0; + gUnknown_0203925B = 0; + ScriptAddElevatorMenuItem(16, 0, 0, 0); + while (gUnknown_03000760[i].var0 != 16) + { + gUnknown_0203925A++; + i++; + } + sub_810E874(); +} + +static void sub_810E874(void) +{ + u8 i; + ScriptContext2_Enable(); + if (gUnknown_0203925A > 5) + { + MenuDrawTextWindow(0, 0, 8, 11); + InitMenu(0, 1, 1, 5, 0, 7); + gUnknown_0203925C = 0; + sub_80F944C(); + LoadScrollIndicatorPalette(); + sub_810ECD4(); + } + else + { + MenuDrawTextWindow(0, 0, 8, 2 * gUnknown_0203925A + 1); + InitMenu(0, 1, 1, gUnknown_0203925A, 0, 7); + } + for (i = 0; i < 5 && gUnknown_03000760[i].var0 != 16; i ++) + { + MenuPrint(gUnknown_083F8380[gUnknown_03000760[i].var0], 1, 2 * i + 1); + } + sub_810E944(); + CreateTask(sub_810E984, 8); +} + +void sub_810E944(void) +{ + MenuDrawTextWindow(20, 0, 29, 5); + sub_8072BD8(gOtherText_NowOn, 21, 1, 64); + sub_8072BD8(gUnknown_083F8380[gSpecialVar_0x8005], 21, 3, 64); +} + +void sub_810E984(u8 taskId) +{ + u8 curMenuPos; + if (gMain.newKeys == DPAD_UP && gUnknown_0203925B != 0) + { + gUnknown_0203925B--; + curMenuPos = GetMenuCursorPos(); + MoveMenuCursorNoWrap(-1); + sub_810EAC8(curMenuPos, DPAD_UP); + } + if (gMain.newKeys == DPAD_DOWN && gUnknown_0203925B != gUnknown_0203925A - 1) + { + gUnknown_0203925B++; + curMenuPos = GetMenuCursorPos(); + MoveMenuCursorNoWrap(+1); + sub_810EAC8(curMenuPos, DPAD_DOWN); + } + if (gMain.newKeys & A_BUTTON) + { + saved_warp2_set_2(0, gUnknown_03000760[gUnknown_0203925B].var1, gUnknown_03000760[gUnknown_0203925B].var2, -1, 2, 1); + if (gSpecialVar_0x8005 == gUnknown_0203925B) + { + gScriptResult = 0; + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(0, 0, 29, 12); + sub_810EC9C(taskId); + } + else + { + gScriptResult = 1; + gSpecialVar_0x8005 = gUnknown_0203925B; + sub_810EBEC(); + FieldObjectTurnByLocalIdAndMap(gScriptLastTalked, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, DIR_SOUTH); + sub_810EEDC(); + MenuZeroFillScreen(); + DestroyTask(taskId); + } + } + else if (gMain.newKeys & B_BUTTON) + { + gScriptResult = 0; + PlaySE(SE_SELECT); + sub_810EEDC(); + MenuZeroFillWindowRect(0, 0, 29, 12); + sub_810EC9C(taskId); + } +} + +// This function, as written, swaps the roles of r4 and r5 throughout. +#ifdef NONMATCHING +bool8 sub_810EAC8(u8 prevMenuPos, u8 dpadInput) +{ + u8 i; + bool8 flag = 0; + u8 newPos = 0; + if (gUnknown_0203925A < 5) + { + return FALSE; + } + if (dpadInput == DPAD_UP) + { + if (prevMenuPos == 0) + { + newPos = gUnknown_0203925B; + flag = 1; + } + } + else if (dpadInput == DPAD_DOWN) + { + if (prevMenuPos == 4) + { + newPos = gUnknown_0203925B - 4; + flag = 1; + } + } + if (flag) + { + sub_810EB90(newPos, 5); + MenuFillWindowRectWithBlankTile(2, 1, 7, 10); + for (i=0; i<5 && gUnknown_03000760[newPos].var0 != 16; newPos++, i++) + { + MenuPrint(gUnknown_083F8380[gUnknown_03000760[newPos].var0], 1, i * 2 + 1); + } + } + return flag; +} +#else +__attribute__((naked)) +bool8 sub_810EAC8(u8 prevMenuPos, u8 dpadInput) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmov r7, r8\n" + "\tpush {r7}\n" + "\tlsls r0, 24\n" + "\tlsrs r2, r0, 24\n" + "\tadds r5, r2, 0\n" + "\tlsls r1, 24\n" + "\tlsrs r1, 24\n" + "\tadds r3, r1, 0\n" + "\tmovs r7, 0\n" + "\tmovs r4, 0\n" + "\tldr r0, _0810EAEC @ =gUnknown_0203925A\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x4\n" + "\tbhi _0810EAF0\n" + "\tmovs r0, 0\n" + "\tb _0810EB78\n" + "\t.align 2, 0\n" + "_0810EAEC: .4byte gUnknown_0203925A\n" + "_0810EAF0:\n" + "\tcmp r1, 0x40\n" + "\tbne _0810EB04\n" + "\tcmp r2, 0\n" + "\tbne _0810EB18\n" + "\tldr r0, _0810EB00 @ =gUnknown_0203925B\n" + "\tldrb r4, [r0]\n" + "\tmovs r7, 0x1\n" + "\tb _0810EB1C\n" + "\t.align 2, 0\n" + "_0810EB00: .4byte gUnknown_0203925B\n" + "_0810EB04:\n" + "\tcmp r3, 0x80\n" + "\tbne _0810EB18\n" + "\tcmp r5, 0x4\n" + "\tbne _0810EB18\n" + "\tldr r0, _0810EB84 @ =gUnknown_0203925B\n" + "\tldrb r0, [r0]\n" + "\tsubs r0, 0x4\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tmovs r7, 0x1\n" + "_0810EB18:\n" + "\tcmp r7, 0\n" + "\tbeq _0810EB76\n" + "_0810EB1C:\n" + "\tadds r0, r4, 0\n" + "\tmovs r1, 0x5\n" + "\tbl sub_810EB90\n" + "\tmovs r0, 0x2\n" + "\tmovs r1, 0x1\n" + "\tmovs r2, 0x7\n" + "\tmovs r3, 0xA\n" + "\tbl MenuFillWindowRectWithBlankTile\n" + "\tmovs r5, 0\n" + "\tldr r2, _0810EB88 @ =gUnknown_03000760\n" + "\tlsls r1, r4, 2\n" + "\tadds r0, r1, r2\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x10\n" + "\tbeq _0810EB76\n" + "\tldr r0, _0810EB8C @ =gUnknown_083F8380\n" + "\tmov r8, r0\n" + "\tadds r6, r2, 0\n" + "_0810EB44:\n" + "\tadds r0, r1, r6\n" + "\tldrb r0, [r0]\n" + "\tlsls r0, 2\n" + "\tadd r0, r8\n" + "\tldr r0, [r0]\n" + "\tlsls r2, r5, 1\n" + "\tadds r2, 0x1\n" + "\tlsls r2, 24\n" + "\tlsrs r2, 24\n" + "\tmovs r1, 0x1\n" + "\tbl MenuPrint\n" + "\tadds r0, r4, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tadds r0, r5, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r5, r0, 24\n" + "\tcmp r5, 0x4\n" + "\tbhi _0810EB76\n" + "\tlsls r1, r4, 2\n" + "\tadds r0, r1, r6\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x10\n" + "\tbne _0810EB44\n" + "_0810EB76:\n" + "\tadds r0, r7, 0\n" + "_0810EB78:\n" + "\tpop {r3}\n" + "\tmov r8, r3\n" + "\tpop {r4-r7}\n" + "\tpop {r1}\n" + "\tbx r1\n" + "\t.align 2, 0\n" + "_0810EB84: .4byte gUnknown_0203925B\n" + "_0810EB88: .4byte gUnknown_03000760\n" + "_0810EB8C: .4byte gUnknown_083F8380"); +} +#endif + +void sub_810EB90(u8 newPos, u8 maxItems) +{ + if (newPos == 0) + { + gUnknown_0203925C ^= 0x02; + DestroyVerticalScrollIndicator(0); + } + else + { + sub_810ECB0(); + } + if (newPos + maxItems < gUnknown_0203925A) + { + sub_810ECD4(); + } + else if (newPos + maxItems == gUnknown_0203925A) + { + gUnknown_0203925C ^= 0x01; + DestroyVerticalScrollIndicator(1); + } +} + +void sub_810EBEC(void) +{ + u8 taskId = CreateTask(sub_810EC34, 9); + gTasks[taskId].data[0] = 1; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3] = 0; + gTasks[taskId].data[4] = 1; + gTasks[taskId].data[5] = 3; + SetCameraPanningCallback(NULL); + sub_810ECFC(); + PlaySE(SE_ELEBETA); +} + +void sub_810EC34(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + task->data[1] ++; + if (task->data[1] % task->data[5] == 0) + { + task->data[1] = 0; + task->data[2] ++; + if (task->data[3] == 0) + { + task->data[4] = -task->data[4]; + SetCameraPanning(0, task->data[4]); + if (task->data[2] == 23) + { + PlaySE(SE_PINPON); + sub_810EC9C(taskId); + InstallCameraPanAheadCallback(); + } + } + } +} + +void sub_810EC9C(u8 taskId) +{ + DestroyTask(taskId); + EnableBothScriptContexts(); +} + +void sub_810ECB0(void) +{ + if (gUnknown_0203925C >> 1 != 1) + { + gUnknown_0203925C |= 0x2; + CreateVerticalScrollIndicators(0, 0x24, 0x08); + } +} + +void sub_810ECD4(void) +{ + if ((gUnknown_0203925C & 1) == 0) + { + gUnknown_0203925C |= 0x1; + CreateVerticalScrollIndicators(1, 0x24, 0x48); + } +} + +void sub_810ECFC(void) +{ + if (FuncIsActiveTask(sub_810ED40) != TRUE) + { + u8 taskId = CreateTask(sub_810ED40, 8); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = taskId; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3] = 0; + gTasks[taskId].data[4] = 0; + } +} + +void sub_810ED40(u8 taskId) +{ + sub_810ED60(&gTasks[taskId]); +} + +void sub_810ED60(struct Task *task) +{ + if (task->data[3] == 8) + { + task->data[3] = 0; + if (task->data[4] != 0) + { + MapGridSetMetatileIdAt( 7, 7, 0xe68); + MapGridSetMetatileIdAt( 8, 7, 0xe69); + MapGridSetMetatileIdAt( 9, 7, 0xe69); + MapGridSetMetatileIdAt(10, 7, 0xe6a); + MapGridSetMetatileIdAt( 7, 8, 0xe70); + MapGridSetMetatileIdAt( 8, 8, 0xe71); + MapGridSetMetatileIdAt( 9, 8, 0xe71); + MapGridSetMetatileIdAt(10, 8, 0xe72); + MapGridSetMetatileIdAt( 7, 9, 0xe78); + MapGridSetMetatileIdAt( 8, 9, 0xe79); + MapGridSetMetatileIdAt( 9, 9, 0xe79); + MapGridSetMetatileIdAt(10, 9, 0xe7a); + } + else + { + MapGridSetMetatileIdAt( 7, 7, 0xe6b); + MapGridSetMetatileIdAt( 8, 7, 0xe6c); + MapGridSetMetatileIdAt( 9, 7, 0xe6c); + MapGridSetMetatileIdAt(10, 7, 0xe6d); + MapGridSetMetatileIdAt( 7, 8, 0xe73); + MapGridSetMetatileIdAt( 8, 8, 0xe74); + MapGridSetMetatileIdAt( 9, 8, 0xe74); + MapGridSetMetatileIdAt(10, 8, 0xe75); + MapGridSetMetatileIdAt( 7, 9, 0xe7b); + MapGridSetMetatileIdAt( 8, 9, 0xe7c); + MapGridSetMetatileIdAt( 9, 9, 0xe7c); + MapGridSetMetatileIdAt(10, 9, 0xe7d); + } + DrawWholeMapView(); + task->data[4] ^= 1; + task->data[2]++; + if (task->data[2] == 8) + { + DestroyTask(task->data[1]); + } + } + task->data[3]++; +} + +void sub_810EEDC(void) +{ + if ((gUnknown_0203925C & 1) != 0) + { + DestroyVerticalScrollIndicator(1); + } + if ((gUnknown_0203925C >> 1) == 1) + { + DestroyVerticalScrollIndicator(0); + } + BuyMenuFreeMemory(); +} + +void SetTrickHouseEndRoomFlag(void) +{ + u16 *specVar = &gSpecialVar_0x8004; + u16 flag = 0x259; + *specVar = flag; + FlagSet(flag); +} + +void ResetTrickHouseEndRoomFlag(void) +{ + u16 *specVar = &gSpecialVar_0x8004; + u16 flag = 0x259; + *specVar = flag; + FlagReset(flag); +} + +bool8 CheckLeadMonCool(void) +{ + if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_COOL) < 200) + { + return FALSE; + } + return TRUE; +} + +bool8 CheckLeadMonBeauty(void) +{ + if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_BEAUTY) < 200) + { + return FALSE; + } + return TRUE; +} + +bool8 CheckLeadMonCute(void) +{ + if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_CUTE) < 200) + { + return FALSE; + } + return TRUE; +} + +bool8 CheckLeadMonSmart(void) +{ + if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SMART) < 200) + { + return FALSE; + } + return TRUE; +} + +bool8 CheckLeadMonTough(void) +{ + if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_TOUGH) < 200) + { + return FALSE; + } + return TRUE; +} + +void IsGrassTypeInParty(void) +{ + u8 i; + u16 species; + struct Pokemon *pokemon; + for (i=0; i<PARTY_SIZE; i++) + { + pokemon = &gPlayerParty[i]; + if (GetMonData(pokemon, MON_DATA_SANITY_BIT2) && !GetMonData(pokemon, MON_DATA_IS_EGG)) + { + species = GetMonData(pokemon, MON_DATA_SPECIES); + if (gBaseStats[species].type1 == TYPE_GRASS || gBaseStats[species].type2 == TYPE_GRASS) + { + gScriptResult = TRUE; + return; + } + } + } + gScriptResult = FALSE; +} + +const u8 *const gUnknown_083F83C0[] = { + OtherText_BlueFlute, + OtherText_YellowFlute, + OtherText_RedFlute, + OtherText_WhiteFlute, + OtherText_BlackFlute, + OtherText_PrettyChair, + OtherText_PrettyDesk, + gOtherText_CancelNoTerminator +}; + +void sub_810F118(u8); +bool8 sub_810F1F4(u8, u8); +void sub_810F2B4(void); +void GlassWorkshopUpdateScrollIndicators(u8, u8); + +void ShowGlassWorkshopMenu(void) +{ + u8 i; + ScriptContext2_Enable(); + MenuDrawTextWindow(0, 0, 10, 11); + InitMenu(0, 1, 1, 5, 0, 9); + gUnknown_0203925C = 0; + sub_80F944C(); + LoadScrollIndicatorPalette(); + sub_810F2B4(); + for (i=0; i<5; i++) + { + MenuPrint(gUnknown_083F83C0[i], 1, 2 * i + 1); + } + gUnknown_0203925B = 0; + gUnknown_0203925A = ARRAY_COUNT(gUnknown_083F83C0); + CreateTask(sub_810F118, 8); +} + +void sub_810F118(u8 taskId) +{ + u8 prevCursorPos; + if (gMain.newKeys == DPAD_UP && gUnknown_0203925B != 0) + { + gUnknown_0203925B--; + prevCursorPos = GetMenuCursorPos(); + MoveMenuCursorNoWrap(-1); + sub_810F1F4(prevCursorPos, DPAD_UP); + } + if (gMain.newKeys == DPAD_DOWN && gUnknown_0203925B != gUnknown_0203925A - 1) + { + gUnknown_0203925B++; + prevCursorPos = GetMenuCursorPos(); + MoveMenuCursorNoWrap(1); + sub_810F1F4(prevCursorPos, DPAD_DOWN); + } + if (gMain.newKeys & A_BUTTON) + { + HandleDestroyMenuCursors(); + gScriptResult = gUnknown_0203925B; + PlaySE(SE_SELECT); + sub_810EEDC(); + MenuZeroFillWindowRect(0, 0, 29, 12); + sub_810EC9C(taskId); + } + if (gMain.newKeys & B_BUTTON) + { + HandleDestroyMenuCursors(); + gScriptResult = 0x7f; + PlaySE(SE_SELECT); + sub_810EEDC(); + MenuZeroFillWindowRect(0, 0, 29, 12); + sub_810EC9C(taskId); + } +} + +// Second verse, same as the first +#ifdef NONMATCHING +bool8 sub_810F1F4(u8 prevCursorPos, u8 dpadInput) +{ + u8 i; + u8 flag = 0; + u8 newPos = 0; + if (gUnknown_0203925A < 5) + { + return FALSE; + } + if (dpadInput == DPAD_UP) + { + if (prevCursorPos == 0) + { + newPos = gUnknown_0203925B; + flag = TRUE; + } + } + else if (dpadInput == DPAD_DOWN) + { + if (prevCursorPos == 4) + { + newPos = gUnknown_0203925B - 4; + flag = TRUE; + } + } + if (flag) + { + GlassWorkshopUpdateScrollIndicators(newPos, 5); + MenuFillWindowRectWithBlankTile(2, 1, 9, 10); + for (i=0; i<5; newPos++, i++) + { + MenuPrint(gUnknown_083F83C0[newPos], 1, 2 * i + 1); + } + } + return flag; +} +#else +__attribute__((naked)) +bool8 sub_810F1F4(u8 prevCursorPos, u8 dpadInput) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tlsls r0, 24\n" + "\tlsrs r2, r0, 24\n" + "\tadds r5, r2, 0\n" + "\tlsls r1, 24\n" + "\tlsrs r1, 24\n" + "\tadds r3, r1, 0\n" + "\tmovs r6, 0\n" + "\tmovs r4, 0\n" + "\tldr r0, _0810F214 @ =gUnknown_0203925A\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x4\n" + "\tbhi _0810F218\n" + "\tmovs r0, 0\n" + "\tb _0810F282\n" + "\t.align 2, 0\n" + "_0810F214: .4byte gUnknown_0203925A\n" + "_0810F218:\n" + "\tcmp r1, 0x40\n" + "\tbne _0810F22C\n" + "\tcmp r2, 0\n" + "\tbne _0810F240\n" + "\tldr r0, _0810F228 @ =gUnknown_0203925B\n" + "\tldrb r4, [r0]\n" + "\tmovs r6, 0x1\n" + "\tb _0810F244\n" + "\t.align 2, 0\n" + "_0810F228: .4byte gUnknown_0203925B\n" + "_0810F22C:\n" + "\tcmp r3, 0x80\n" + "\tbne _0810F240\n" + "\tcmp r5, 0x4\n" + "\tbne _0810F240\n" + "\tldr r0, _0810F288 @ =gUnknown_0203925B\n" + "\tldrb r0, [r0]\n" + "\tsubs r0, 0x4\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tmovs r6, 0x1\n" + "_0810F240:\n" + "\tcmp r6, 0\n" + "\tbeq _0810F280\n" + "_0810F244:\n" + "\tadds r0, r4, 0\n" + "\tmovs r1, 0x5\n" + "\tbl GlassWorkshopUpdateScrollIndicators\n" + "\tmovs r0, 0x2\n" + "\tmovs r1, 0x1\n" + "\tmovs r2, 0x9\n" + "\tmovs r3, 0xA\n" + "\tbl MenuFillWindowRectWithBlankTile\n" + "\tmovs r5, 0\n" + "\tldr r7, _0810F28C @ =gUnknown_083F83C0\n" + "_0810F25C:\n" + "\tlsls r0, r4, 2\n" + "\tadds r0, r7\n" + "\tldr r0, [r0]\n" + "\tlsls r2, r5, 1\n" + "\tadds r2, 0x1\n" + "\tlsls r2, 24\n" + "\tlsrs r2, 24\n" + "\tmovs r1, 0x1\n" + "\tbl MenuPrint\n" + "\tadds r0, r4, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tadds r0, r5, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r5, r0, 24\n" + "\tcmp r5, 0x4\n" + "\tbls _0810F25C\n" + "_0810F280:\n" + "\tadds r0, r6, 0\n" + "_0810F282:\n" + "\tpop {r4-r7}\n" + "\tpop {r1}\n" + "\tbx r1\n" + "\t.align 2, 0\n" + "_0810F288: .4byte gUnknown_0203925B\n" + "_0810F28C: .4byte gUnknown_083F83C0"); +} +#endif + +void sub_810F290(void) +{ + if (gUnknown_0203925C >> 1 != 1) + { + gUnknown_0203925C |= 0x02; + CreateVerticalScrollIndicators(0, 0x2c, 0x08); + } +} + +void sub_810F2B4(void) +{ + if (!(gUnknown_0203925C & 0x01)) + { + gUnknown_0203925C |= 0x01; + CreateVerticalScrollIndicators(1, 0x2c, 0x58); + } +} + +void GlassWorkshopUpdateScrollIndicators(u8 newPos, u8 maxItems) +{ + if (newPos == 0) + { + gUnknown_0203925C ^= 0x02; + DestroyVerticalScrollIndicator(0); + } + else + { + sub_810F290(); + } + if (newPos + maxItems < gUnknown_0203925A) + { + sub_810F2B4(); + } + else if (newPos + maxItems == gUnknown_0203925A) + { + gUnknown_0203925C ^= 0x01; + DestroyVerticalScrollIndicator(1); + } +} + +void SpawnCameraDummy(void) +{ + u8 mapObjectId = SpawnSpecialFieldObjectParametrized(7, 8, 0x7f, gSaveBlock1.pos.x + 7, gSaveBlock1.pos.y + 7, 3); + gMapObjects[mapObjectId].mapobj_bit_13 = 1; + CameraObjectSetFollowedObjectId(gMapObjects[mapObjectId].spriteId); +} + +void RemoveCameraDummy(void) +{ + CameraObjectSetFollowedObjectId(GetPlayerAvatarObjectId()); + RemoveFieldObjectByLocalIdAndMap(0x7f, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup); +} + +u8 GetPokeblockNameByMonNature(void) +{ + return sub_810CB68(GetNature(&gPlayerParty[GetLeadMonIndex()]), gStringVar1); +} + +void GetSecretBaseNearbyMapName(void) +{ + sub_80FBFB4(gStringVar1, VarGet(VAR_SECRET_BASE_MAP), 0); +} + +u16 sub_810F404(void) +{ + return GetGameStat(GAME_STAT_BATTLE_TOWER_BEST_STREAK); +} + +void sub_810F414(void) +{ + sub_8135FF4(gStringVar1); +} + +const u8 gUnknown_083F83E0[] = {12, 2, 4, 5, 1, 8, 7, 11, 3, 10, 9, 6}; +const u8 gUnknown_083F83EC[] = {0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5}; +const u8 gUnknown_083F83F8[] = {3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5}; + +u8 sub_810F424(void) +{ + u32 v0 = gSaveBlock1.easyChatPairs[0].unk0_0 + gSaveBlock1.easyChatPairs[0].unk2 + gUnknown_083F83E0[gSpecialVar_0x8004]; + if (GetPriceReduction(2)) + { + return gUnknown_083F83F8[v0 % 12]; + } + return gUnknown_083F83EC[v0 % 12]; +} + +bool8 sub_810F488(void) +{ + u16 *specVar = &gSpecialVar_0x8004; + u16 flag = 0x277; + *specVar = flag; + if (!FlagGet(flag)) + { + return FALSE; + } + return TRUE; +} + +bool8 sub_810F4B0(void) +{ + u16 *specVar = &gSpecialVar_0x8004; + u16 flag = 0x278; + *specVar = flag; + if (!FlagGet(flag)) + { + return FALSE; + } + return TRUE; +} + +bool8 sub_810F4D4(void) +{ + u16 *specVar = &gSpecialVar_0x8004; + u16 flag = 0x279; + *specVar = flag; + if (!FlagGet(flag)) + { + return FALSE; + } + return TRUE; +} + +bool8 sub_810F4FC(void) +{ + u16 *specVar = &gSpecialVar_0x8004; + u16 flag = 0x27a; + *specVar = flag; + if (!FlagGet(flag)) + { + return FALSE; + } + return TRUE; +} + +bool8 LeadMonHasEffortRibbon(void) +{ + return GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_EFFORT_RIBBON, NULL); +} + +void GivLeadMonEffortRibbon(void) +{ + bool8 ribbonSet; + IncrementGameStat(GAME_STAT_RECEIVED_RIBBONS); + FlagSet(SYS_RIBBON_GET); + ribbonSet = TRUE; + SetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_EFFORT_RIBBON, &ribbonSet); +} + +bool8 GetLeadMonEVCount(void) +{ + if (GetMonEVCount(&gPlayerParty[GetLeadMonIndex()]) >= 510) + { + return TRUE; + } + return FALSE; +} + +u8 sub_810F5BC(void) +{ + if (!FlagGet(0xc7) && gSaveBlock1.location.mapGroup == MAP_GROUP_RUSTURF_TUNNEL && gSaveBlock1.location.mapNum == MAP_ID_RUSTURF_TUNNEL) + { + if (FlagGet(0x3a3)) + { + VarSet(VAR_0x409a, 4); + return TRUE; + } + else if (FlagGet(0x3a4)) + { + VarSet(VAR_0x409a, 5); + return TRUE; + } + } + return FALSE; +} + +void SetShoalItemFlag(u16 v0) +{ + FlagSet(0x85f); +} + +void PutZigzagoonInPlayerParty(void) +{ + u16 monData; + CreateMon(&gPlayerParty[0], SPECIES_ZIGZAGOON, 7, 0x20, FALSE, 0, FALSE, 0); + monData = TRUE; + SetMonData(&gPlayerParty[0], MON_DATA_ALT_ABILITY, (u8 *)&monData); + monData = MOVE_TACKLE; + SetMonData(&gPlayerParty[0], MON_DATA_MOVE1, (u8 *)&monData); + monData = MOVE_NONE; + SetMonData(&gPlayerParty[0], MON_DATA_MOVE2, (u8 *)&monData); + SetMonData(&gPlayerParty[0], MON_DATA_MOVE3, (u8 *)&monData); + SetMonData(&gPlayerParty[0], MON_DATA_MOVE4, (u8 *)&monData); +} + +bool8 IsStarterInParty(void) +{ + u8 i; + u16 starter = GetStarterPokemon(VarGet(VAR_FIRST_POKE)); + u8 partyCount = CalculatePlayerPartyCount(); + for (i=0; i<partyCount; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) == starter) + { + return TRUE; + } + } + return FALSE; +} + +bool8 CheckFreePokemonStorageSpace(void) +{ + u16 i, j; + for (i=0; i<14; i++) + { + for (j=0; j<30; j++) + { + if (GetBoxMonData(&gPokemonStorage.boxes[i][j], MON_DATA_SPECIES, NULL) == SPECIES_NONE) + { + return TRUE; + } + } + } + return FALSE; +} + +bool8 IsPokerusInParty(void) +{ + if (!CheckPartyPokerus(gPlayerParty, 0x3f)) + { + return FALSE; + } + return TRUE; +} + +static void sub_810F7A8(u8); +static void sub_810F814(u8); + +void sub_810F758(void) +{ + u8 taskId = CreateTask(sub_810F7A8, 9); + gTasks[taskId].data[0] = gSpecialVar_0x8005; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3] = 0; + gTasks[taskId].data[4] = gSpecialVar_0x8004; + gTasks[taskId].data[5] = 5; + SetCameraPanningCallback(NULL); + PlaySE(SE_W070); +} + +static void sub_810F7A8(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + task->data[1]++; + if ((task->data[1] % task->data[5]) == 0) + { + task->data[1] = 0; + task->data[2]++; + if (task->data[3] == 0) + { + task->data[0] = -task->data[0]; + task->data[4] = -task->data[4]; + SetCameraPanning(task->data[0], task->data[4]); + if (task->data[2] == 8) + { + sub_810F814(taskId); + InstallCameraPanAheadCallback(); + } + } + } +} + +static void sub_810F814(u8 taskId) +{ + DestroyTask(taskId); + EnableBothScriptContexts(); +} + +bool8 sub_810F828(void) +{ + return FlagGet(0x2b8); +} + +void SetRoute119Weather(void) +{ + if (is_light_level_1_2_3_5_or_6(get_map_light_from_warp0()) != TRUE) + { + SetSav1Weather(0x14); + } +} + +void SetRoute123Weather(void) +{ + if (is_light_level_1_2_3_5_or_6(get_map_light_from_warp0()) != TRUE) + { + SetSav1Weather(0x15); + } +} + +u8 GetLeadMonIndex(void) +{ + u8 i; + u8 partyCount = CalculatePlayerPartyCount(); + for (i=0; i<partyCount; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_EGG && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != 0) + { + return i; + } + } + return 0; +} + +u16 ScriptGetPartyMonSpecies(void) +{ + return GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES2, NULL); +} + +void sub_810F8FC(void) +{ + sub_805ADDC(6); +} + +u16 sub_810F908(void) +{ + u16 var40c2 = VarGet(VAR_0x40C2); + if (gLocalTime.days - var40c2 >= 7) + { + return 0; + } + else if (gLocalTime.days < 0) + { + return 8; + } + return 7 - (gLocalTime.days - var40c2); +} + +u16 sub_810F950(void) +{ + VarSet(VAR_0x40C2, gLocalTime.days); + return gLocalTime.days; +} + +bool8 sub_810F96C(void) +{ + GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_OT_NAME, gStringVar1); + if (!StringCompareWithoutExtCtrlCodes(gSaveBlock2.playerName, gStringVar1)) + { + return FALSE; + } + return TRUE; +} + +void sub_810F9AC(void) +{ + if (gScriptResult >= 10000) + { + sub_80BF088(0, gScriptResult); + } + else if (gScriptResult >= 1000) + { + gStringVar1[0] = CHAR_0; + ConvertIntToDecimalStringN(gStringVar1 + 1, gScriptResult, 0, sub_80BF0B8(gScriptResult)); + } + else if (gScriptResult >= 100) + { + gStringVar1[0] = CHAR_0; + gStringVar1[1] = CHAR_0; + ConvertIntToDecimalStringN(gStringVar1 + 2, gScriptResult, 0, sub_80BF0B8(gScriptResult)); + } + else if (gScriptResult >= 10) + { + gStringVar1[0] = CHAR_0; + gStringVar1[1] = CHAR_0; + gStringVar1[2] = CHAR_0; + ConvertIntToDecimalStringN(gStringVar1 + 3, gScriptResult, 0, sub_80BF0B8(gScriptResult)); + } + else + { + gStringVar1[0] = CHAR_0; + gStringVar1[1] = CHAR_0; + gStringVar1[2] = CHAR_0; + gStringVar1[3] = CHAR_0; + ConvertIntToDecimalStringN(gStringVar1 + 4, gScriptResult, 0, sub_80BF0B8(gScriptResult)); + } +} + +const u8 gUnknown_083F8404[] = {2, 1, 2, 1}; +const u8 gUnknown_083F8408[] = {8, 9, 10, 11, 12, 13, 14, 15}; +const u8 gUnknown_083F8410[] = {8, 13, 14, 11, 10, 12, 15, 9}; + +bool8 sub_810FF30(void); +void sub_810FCE8(void); +void sub_810FF48(void); +void sub_810FD80(void); +u16 sub_810FCB0(void); +int sub_810FB9C(void); + +void ResetFanClub(void) +{ + gSaveBlock1.vars[0x41] = 0; + gSaveBlock1.vars[0x42] = 0; +} + +void sub_810FA74(void) +{ + if (sub_810FF30()) + { + sub_810FCE8(); + gSaveBlock1.vars[0x42] = gSaveBlock2.playTimeHours; + } +} + +void sub_810FAA0(void) +{ + if (!((gSaveBlock1.vars[0x41] >> 7) & 1)) + { + sub_810FF48(); + sub_810FD80(); + gSaveBlock1.vars[0x42] = gSaveBlock2.playTimeHours; + FlagReset(0x315); + FlagReset(0x316); + FlagReset(0x317); + FlagReset(0x318); + VarSet(VAR_0x4095, 1); + } +} + +u8 sub_810FB10(u8 a0) +{ + if (VarGet(VAR_0x4095) == 2) + { + if ((gSaveBlock1.vars[0x41] & 0x7f) + gUnknown_083F8404[a0] >= 20) + { + if (sub_810FCB0() < 3) + { + sub_810FB9C(); + gSaveBlock1.vars[0x41] &= 0xff80; + } + else + { + gSaveBlock1.vars[0x41] = (gSaveBlock1.vars[0x41] & 0xff80) | 20; + } + } + else + { + gSaveBlock1.vars[0x41] += gUnknown_083F8404[a0]; + } + } + return gSaveBlock1.vars[0x41] & 0x7f; +} + +int sub_810FB9C(void) +{ + u8 i; + int retval = 0; + for (i=0; i<8; i++) + { + if (!((gSaveBlock1.vars[0x41] >> gUnknown_083F8408[i]) & 0x01)) + { + retval = i; + if (Random() & 1) + { + gSaveBlock1.vars[0x41] |= (1 << gUnknown_083F8408[i]); + return retval; + } + } + } + gSaveBlock1.vars[0x41] |= (1 << gUnknown_083F8408[retval]); + return retval; +} + +int sub_810FC18(void) +{ + u8 i; + int retval = 0; + if (sub_810FCB0() == TRUE) + { + return 0; + } + for (i=0; i<8; i++) + { + if ((gSaveBlock1.vars[0x41] >> gUnknown_083F8410[i]) & 1) + { + retval = i; + if (Random() & 1) + { + gSaveBlock1.vars[0x41] ^= (1 << gUnknown_083F8410[i]); + return retval; + } + } + } + if ((gSaveBlock1.vars[0x41] >> gUnknown_083F8410[retval]) & 1) + { + gSaveBlock1.vars[0x41] ^= (1 << gUnknown_083F8410[retval]); + } + return retval; +} + +u16 sub_810FCB0(void) +{ + u8 i; + u8 retval = 0; + for (i=0; i<8; i++) + { + if ((gSaveBlock1.vars[0x41] >> (i + 8)) & 1) + { + retval ++; + } + } + return retval; +} + +void sub_810FCE8(void) +{ + u8 i = 0; + if (gSaveBlock2.playTimeHours < 999) + { + while (1) + { + if (sub_810FCB0() < 5) + { + gSaveBlock1.vars[0x42] = gSaveBlock2.playTimeHours; + break; + } + else if (i == 8) + { + break; + } + else if (gSaveBlock2.playTimeHours - gSaveBlock1.vars[0x42] < 12) + { + return; + } + sub_810FC18(); + gSaveBlock1.vars[0x42] += 12; + i++; + } + } +} + +bool8 sub_810FD60(void) +{ + return (gSaveBlock1.vars[0x41] >> gSpecialVar_0x8004) & 0x01; +} + +void sub_810FD80(void) +{ + gSaveBlock1.vars[0x41] |= 0x2000; + gSaveBlock1.vars[0x41] |= 0x100; + gSaveBlock1.vars[0x41] |= 0x400; +} + +void sub_810FE1C(void *, u8, u8); + +void sub_810FDAC(void) +{ + u8 a = 0; + u8 b = 0; + switch (gSpecialVar_0x8004) + { + case 8: + break; + case 9: + break; + case 10: + a = 0; + b = 3; + break; + case 11: + a = 0; + b = 1; + break; + case 12: + a = 1; + b = 0; + break; + case 13: + a = 0; + b = 4; + break; + case 14: + a = 1; + b = 5; + break; + case 15: + break; + } + sub_810FE1C(gSaveBlock1.linkBattleRecords, a, b); +} + +void sub_810FE1C(void *linkRecords, u8 a, u8 b) +{ + u8 *curRecord = (linkRecords + 16 * a); + if (*curRecord == EOS) + { + switch (b) + { + case 0: + StringCopy(gStringVar1, gOtherText_Wallace); + break; + case 1: + StringCopy(gStringVar1, gOtherText_Steven); + break; + case 2: + StringCopy(gStringVar1, gOtherText_Brawly); + break; + case 3: + StringCopy(gStringVar1, gOtherText_Winona); + break; + case 4: + StringCopy(gStringVar1, gOtherText_Phoebe); + break; + case 5: + StringCopy(gStringVar1, gOtherText_Glacia); + break; + default: + StringCopy(gStringVar1, gOtherText_Wallace); + break; + } + } + else + { + StringCopyN(gStringVar1, curRecord, 7); + gStringVar1[7] = EOS; + if (gStringVar1[0] == 0xfc && gStringVar1[1] == 0x15) + { + ConvertInternationalString(gStringVar1, 1); + } + } +} + +void sub_810FEFC(void) +{ + if (VarGet(VAR_0x4095) == 2) + { + sub_810FA74(); + if (gBattleOutcome == 1) + { + sub_810FB9C(); + } + else + { + sub_810FC18(); + } + } +} + +bool8 sub_810FF30(void) +{ + return (gSaveBlock1.vars[0x41] >> 7) & 0x01; +} + +void sub_810FF48(void) +{ + gSaveBlock1.vars[0x41] |= 0x80; +} + +u8 sub_810FF60(void) +{ + return sub_810FB10(gSpecialVar_0x8004); +} diff --git a/src/field_weather.c b/src/field_weather.c new file mode 100644 index 000000000..5ff2eddf9 --- /dev/null +++ b/src/field_weather.c @@ -0,0 +1,367 @@ +#include "global.h" +#include "field_weather.h" +#include "palette.h" +#include "sprite.h" +#include "task.h" + +struct Weather +{ + u8 filler_000[0x200]; + u8 unknown_200[2][32]; + u8 filler_240[0x480]; + s8 unknown_6C0; + s8 unknown_6C1; + u8 unknown_6C2; + u8 unknown_6C3; + u16 unknown_6C4; + u8 unknown_6C6; + u8 unknown_6C7; + u8 unknown_6C8; + u8 unknown_6C9; + u8 unknown_6CA; + u8 unknown_6CB; + u8 filler_6CC[2]; + u16 unknown_6CE; + u8 unknown_6D0; + u8 unknown_6D1; + u8 filler_6D2[1]; + u8 unknown_6D3; + u8 unknown_6D4; + u8 unknown_6D5; + u8 filler_6D6[2]; + u8 unknown_6D8; + u8 filler_6D9[1]; + u8 unknown_6DA; + u8 filler_6DB[3]; + u8 unknown_6DE; + u8 filler_6DF[5]; + u8 unknown_6E4; + u8 filler_6E5[0x15]; + u8 unknown_6FA; + u8 unknown_6FB; + u8 filler_6FC[4]; + u8 unknown_700; + u8 filler_701[0x15]; + u8 unknown_716; + u8 unknown_717; + u8 filler_718[0xc]; + u8 unknown_724; + u8 filler_725[9]; + u8 unknown_72E; +}; + +#define gWeather gUnknown_0202F7E8 +extern struct Weather gWeather; +extern u8 *gUnknown_083970E8; +extern u8 (*gUnknown_08396FC8[][4])(void); +extern u8 (*gUnknown_083970B8[])(void); +extern u8 *gUnknown_030006DC; +extern u8 gUnknown_083970C8; +extern u8 (*gUnknown_0202FC48)[32]; +extern u8 gUnknown_0202F9E8[32]; + + +void sub_807C828(void) +{ + u8 index; + if (!FuncIsActiveTask(&sub_807CA34)) + { + index = AllocSpritePalette(0x1200); + CpuCopy32(&gUnknown_083970E8, &gPlttBufferUnfaded[0x100 + index * 16], 32); + sub_807CB10(); + gWeather.unknown_6D5 = index; + gWeather.unknown_6D4 = AllocSpritePalette(0x1201); + gWeather.unknown_6DA = 0; + gWeather.unknown_6D8 = 0; + gWeather.unknown_6DE = 0; + gWeather.unknown_6E4 = 0; + gWeather.unknown_700 = 0; + gWeather.unknown_6FB = 0; + gWeather.unknown_724 = 0; + gWeather.unknown_716 = 0; + gWeather.unknown_717 = 0; + gWeather.unknown_72E = 0; + gWeather.unknown_6FA = 0; + sub_807DB64(16, 0); + gWeather.unknown_6D0 = 0; + gWeather.unknown_6C6 = 3; + gWeather.unknown_6C8 = 0; + gWeather.unknown_6D3 = 1; + gWeather.unknown_6C9 = CreateTask(&sub_807C9E4, 80); + } +} + +void DoWeatherEffect(u8 effect) +{ + if (effect != 3 && effect != 5 && effect != 13) + { + PlayRainSoundEffect(); + } + if (gWeather.unknown_6D1 != effect && gWeather.unknown_6D0 == effect) + { + gUnknown_08396FC8[effect][0](); + } + gWeather.unknown_6D3 = 0; + gWeather.unknown_6D1 = effect; + gWeather.unknown_6CE = 0; +} + +void sub_807C988(u8 effect) +{ + PlayRainSoundEffect(); + gWeather.unknown_6D0 = effect; + gWeather.unknown_6D1 = effect; +} + +void sub_807C9B4(u8 effect) +{ + PlayRainSoundEffect(); + gWeather.unknown_6D0 = effect; + gWeather.unknown_6D1 = effect; + gWeather.unknown_6C8 = 1; +} + +void sub_807C9E4(u8 task) +{ + if (gWeather.unknown_6C8) + { + gUnknown_08396FC8[gWeather.unknown_6D0][2](); + gTasks[task].func = &sub_807CA34; + } +} + +void sub_807CA34(u8 task) +{ + u8 v1; + if (gWeather.unknown_6D0 != gWeather.unknown_6D1) + { + v1 = gUnknown_08396FC8[gWeather.unknown_6D0][3](); + if (!v1) + { + gUnknown_08396FC8[gWeather.unknown_6D1][0](); + gWeather.unknown_6C3 = 0; // compiler reuses v1 + gWeather.unknown_6C6 = 0; // compiler reuses v1 + gWeather.unknown_6D0 = gWeather.unknown_6D1; + gWeather.unknown_6D3 = 1; + } + } + else + { + gUnknown_08396FC8[gWeather.unknown_6D0][1](); + } + gUnknown_083970B8[gWeather.unknown_6C6](); +} + +void sub_807CAE8(void) +{ + gWeather.unknown_6C1 = 0; + gWeather.unknown_6C2 = 0; +} + +void nullsub_38(void) +{ +} + +u32 sub_807CB0C(void) +{ + return 0; +} + +void sub_807CB10(void) +{ + u16 v0; + u8(*v1)[32]; + u16 v2; + u16 v4; + u16 v5; + u16 v6; + u16 v9; + u32 v10; + u16 v11; + s16 dunno; + + gUnknown_030006DC = &gUnknown_083970C8; + for (v0 = 0; v0 <= 1; v0++) + { + if (v0 == 0) + { + v1 = &gUnknown_0202F9E8; + } + else + { + v1 = &gUnknown_0202F9E8 + 19; + } + for (v2 = 0; (u16)v2 <= 0x1f; v2++) + { + v4 = v2 << 8; + if (v0 == 0) + { + v5 = (v2 << 8) / 16; + } + else + { + v5 = 0; + } + v6 = 0; + for (; v6 <= 2; v6++) + { + v4 = (v4 - v5); + v1[v6][v2] = v4 >> 8; + } + v9 = v4; + v10 = 0x1f00 - v4; + if ((0x1f00 - v4) < 0) + { + v10 += 0xf; + } + v11 = v10 >> 4; + if (v2 <= 0xb) + { + for (; v6 <= 0x12; v6++) + { + v4 += v11; + dunno = v4 - v9; + if (dunno > 0) + { + v4 -= (dunno + ((u16)dunno >> 15)) >> 1; + } + v1[v6][v2] = v4 >> 8; + if (v1[v6][v2] > 0x1f) + { + v1[v6][v2] = 0x1f; + } + } + } + else + { + for (; v6 <= 0x12; v6++) + { + v4 += v11; + v1[v6][v2] = v4 >> 8; + if (v1[v6][v2] > 0x1f) + { + v1[v6][v2] = 0x1f; + } + } + } + } + } +} + +void sub_807CC24(void) +{ + if (gWeather.unknown_6C0 == gWeather.unknown_6C1) + { + gWeather.unknown_6C6 = 3; + } + else + { + if (++gWeather.unknown_6C3 >= gWeather.unknown_6C2) + { + gWeather.unknown_6C3 = 0; + if (gWeather.unknown_6C0 < gWeather.unknown_6C1) + { + gWeather.unknown_6C0++; + } + else + { + gWeather.unknown_6C0--; + } + sub_807CEBC(0, 0x20, gWeather.unknown_6C0); + } + } +} + +void sub_807CCAC(void) +{ + if (++gWeather.unknown_6CB > 1) + { + gWeather.unknown_6CA = 0; + } + switch (gWeather.unknown_6D0) + { + case 3: + case 4: + case 5: + case 11: + case 13: + if (sub_807CDC4() == 0) + { + gWeather.unknown_6C0 = 3; + gWeather.unknown_6C6 = 3; + } + break; + case 12: + if (sub_807CE24() == 0) + { + gWeather.unknown_6C0 = -6; + gWeather.unknown_6C6 = 3; + } + break; + case 6: + if (sub_807CE7C() == 0) + { + gWeather.unknown_6C0 = 0; + gWeather.unknown_6C6 = 3; + } + break; + case 7: + case 8: + case 9: + case 10: + default: + if (!gPaletteFade.active) + { + gWeather.unknown_6C0 = gWeather.unknown_6C1; + gWeather.unknown_6C6 = 3; + } + break; + } +} + +u8 sub_807CDC4(void) +{ + if (gWeather.unknown_6C7 == 0x10) + { + return 0; + } + if (++gWeather.unknown_6C7 >= 0x10) + { + sub_807CEBC(0, 0x20, 3); + gWeather.unknown_6C7 = 0x10; + return 0; + } + sub_807D1BC(0, 0x20, 3, 0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); + return 1; +} + +u8 sub_807CE24(void) +{ + if (gWeather.unknown_6C7 == 0x10) + { + return 0; + } + if (++gWeather.unknown_6C7 >= 0x10) + { + sub_807CEBC(0, 0x20, -6); + gWeather.unknown_6C7 = 0x10; + return 0; + } + sub_807D304(-6, 0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); + return 1; +} + +u8 sub_807CE7C(void) +{ + if (gWeather.unknown_6C7 == 0x10) + { + return 0; + } + ++gWeather.unknown_6C7; + sub_807D424(0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); + return 1; +} + +void nullsub_39(void) +{ +} diff --git a/src/fieldmap.c b/src/fieldmap.c index 0470d33ff..e573ec13a 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -1,809 +1,953 @@ #include "global.h" +#include "fieldmap.h" #include "palette.h" +#include "rom4.h" +#include "script.h" +#include "secret_base.h" +#include "tv.h" -struct BackupMapData +struct ConnectionFlags { - s32 width; - s32 height; - u16 *map; + u8 south:1; + u8 north:1; + u8 west:1; + u8 east:1; }; -extern struct MapHeader * const get_mapheader_by_bank_and_number(u8, u8); -extern void mapheader_run_script_with_tag_x1(void); -extern void sub_80BB970(struct MapEvents *); -extern void sub_80BBCCC(); -extern void sub_8056670(); -extern void UpdateTVScreensOnMap(); -extern void sub_80538F0(u8 mapGroup, u8 mapNum); - -struct Camera { - bool8 field_0:1; - s32 x; - s32 y; -}; - -struct ConnectionFlags { - u8 south:1; - u8 north:1; - u8 west:1; - u8 east:1; -}; - -struct Coords32 { - s32 x; - s32 y; +struct Coords32 +{ + s32 x; + s32 y; }; -extern const struct Coords32 gUnknown_0821664C[]; -extern struct BackupMapData gUnknown_03004870; - EWRAM_DATA static u16 gUnknown_02029828[0x2800] = {0}; EWRAM_DATA struct MapHeader gMapHeader = {0}; EWRAM_DATA struct Camera gUnknown_0202E844 = {0}; EWRAM_DATA static struct ConnectionFlags gUnknown_0202E850 = {0}; -extern const struct ConnectionFlags gUnknown_08308E28; - -void mapheader_copy_mapdata_with_padding(struct MapHeader *mapHeader); -void sub_80560AC(struct MapHeader *); -void map_copy_with_padding(u16 *map, u16 width, u16 height); -void fillSouthConnection(struct MapHeader *, struct MapHeader *, s32); -void fillNorthConnection(struct MapHeader *, struct MapHeader *, s32); -void fillWestConnection(struct MapHeader *, struct MapHeader *, s32); -void fillEastConnection(struct MapHeader *, struct MapHeader *, s32); -u32 GetBehaviorByMetatileId(u16 metatile); -struct MapConnection *sub_8056A64(u8 direction, int x, int y); -bool8 sub_8056ABC(u8 direction, int x, int y, struct MapConnection *connection); -bool8 sub_8056B20(int x, int src_width, int dest_width, int offset); - -struct MapHeader *mapconnection_get_mapheader(struct MapConnection *connection) { - return get_mapheader_by_bank_and_number(connection->mapGroup, connection->mapNum); -} - -void not_trainer_hill_battle_pyramid(void) { - mapheader_copy_mapdata_with_padding(&gMapHeader); - sub_80BB970(gMapHeader.events); - mapheader_run_script_with_tag_x1(); -} - -void sub_8055FC0(void) { - mapheader_copy_mapdata_with_padding(&gMapHeader); - sub_80BBCCC(0); - sub_80BB970(gMapHeader.events); - sub_8056670(); - mapheader_run_script_with_tag_x1(); - UpdateTVScreensOnMap(gUnknown_03004870.width, gUnknown_03004870.height); -} - -void mapheader_copy_mapdata_with_padding(struct MapHeader *mapHeader) { - struct MapData *mapData; - int width; - int height; - mapData = mapHeader->mapData; - CpuFastFill16(0x03ff, gUnknown_02029828, sizeof(gUnknown_02029828)); - gUnknown_03004870.map = gUnknown_02029828; - width = mapData->width + 15; - gUnknown_03004870.width = width; - height = mapData->height + 14; - gUnknown_03004870.height = height; - if (width * height <= 0x2800) { - map_copy_with_padding(mapData->map, mapData->width, mapData->height); - sub_80560AC(mapHeader); - } -} - -void map_copy_with_padding(u16 *map, u16 width, u16 height) { - u16 *dest; - int y; - dest = gUnknown_03004870.map; - dest += gUnknown_03004870.width * 7 + 7; - for (y = 0; y < height; y++) { - CpuCopy16(map, dest, width * 2); - dest += width + 0xf; - map += width; - } -} - -void sub_80560AC(struct MapHeader *mapHeader) { - int i; - struct MapConnection *connection; - struct MapHeader *cMap; - u32 offset; - int count; - count = mapHeader->connections->count; - connection = mapHeader->connections->connections; - gUnknown_0202E850 = gUnknown_08308E28; - for (i = 0; i < count; i++, connection++) { - cMap = mapconnection_get_mapheader(connection); - offset = connection->offset; - switch (connection->direction) { - case CONNECTION_SOUTH: - fillSouthConnection(mapHeader, cMap, offset); - gUnknown_0202E850.south = 1; - break; - case CONNECTION_NORTH: - fillNorthConnection(mapHeader, cMap, offset); - gUnknown_0202E850.north = 1; - break; - case CONNECTION_WEST: - fillWestConnection(mapHeader, cMap, offset); - gUnknown_0202E850.west = 1; - break; - case CONNECTION_EAST: - fillEastConnection(mapHeader, cMap, offset); - gUnknown_0202E850.east = 1; - break; - } - } -} - -void sub_8056134(int x, int y, struct MapHeader *mapHeader, int x2, int y2, int width, int height) { - int i; - u16 *src; - u16 *dest; - int mapWidth; - - mapWidth = mapHeader->mapData->width; - src = &mapHeader->mapData->map[mapWidth * y2 + x2]; - dest = &gUnknown_03004870.map[gUnknown_03004870.width * y + x]; - - for (i = 0; i < height; i++) { - CpuCopy16(src, dest, width * 2); - dest += gUnknown_03004870.width; - src += mapWidth; - } -} - -void fillSouthConnection(struct MapHeader *mapHeader, struct MapHeader *connectedMapHeader, s32 offset) { - int x, y; - int x2; - int width; - int cWidth; - - if (connectedMapHeader) { - cWidth = connectedMapHeader->mapData->width; - x = offset + 7; - y = mapHeader->mapData->height + 7; - if (x < 0) { - x2 = -x; - x += cWidth; - if (x < gUnknown_03004870.width) { - width = x; - } else { - width = gUnknown_03004870.width; - } - x = 0; - } else { - x2 = 0; - if (x + cWidth < gUnknown_03004870.width) { - width = cWidth; - } else { - width = gUnknown_03004870.width - x; - } - } - sub_8056134( - x, y, - connectedMapHeader, - x2, /*y2*/ 0, - width, /*height*/ 7); - } -} - -void fillNorthConnection(struct MapHeader *mapHeader, struct MapHeader *connectedMapHeader, s32 offset) { - int x; - int x2, y2; - int width; - int cWidth, cHeight; - - if (connectedMapHeader) { - cWidth = connectedMapHeader->mapData->width; - cHeight = connectedMapHeader->mapData->height; - x = offset + 7; - y2 = cHeight - 7; - if (x < 0) { - x2 = -x; - x += cWidth; - if (x < gUnknown_03004870.width) { - width = x; - } else { - width = gUnknown_03004870.width; - } - x = 0; - } else { - x2 = 0; - if (x + cWidth < gUnknown_03004870.width) { - width = cWidth; - } else { - width = gUnknown_03004870.width - x; - } - } - - sub_8056134( - x, /*y*/ 0, - connectedMapHeader, - x2, y2, - width, /*height*/ 7); - - } -} - - -void fillWestConnection(struct MapHeader *mapHeader, struct MapHeader *connectedMapHeader, s32 offset) { - int y; - int x2, y2; - int height; - int cWidth, cHeight; - if (connectedMapHeader) { - cWidth = connectedMapHeader->mapData->width; - cHeight = connectedMapHeader->mapData->height; - y = offset + 7; - x2 = cWidth - 7; - if (y < 0) { - y2 = -y; - if (y + cHeight < gUnknown_03004870.height) { - height = y + cHeight; - } else { - height = gUnknown_03004870.height; - } - y = 0; - } else { - y2 = 0; - if (y + cHeight < gUnknown_03004870.height) { - height = cHeight; - } else { - height = gUnknown_03004870.height - y; - } - } - - sub_8056134( - /*x*/ 0, y, - connectedMapHeader, - x2, y2, - /*width*/ 7, height); - } -} - -void fillEastConnection(struct MapHeader *mapHeader, struct MapHeader *connectedMapHeader, s32 offset) { - int x, y; - int y2; - int height; - int cHeight; - if (connectedMapHeader) { - cHeight = connectedMapHeader->mapData->height; - x = mapHeader->mapData->width + 7; - y = offset + 7; - if (y < 0) { - y2 = -y; - if (y + cHeight < gUnknown_03004870.height) { - height = y + cHeight; - } else { - height = gUnknown_03004870.height; - } - y = 0; - } else { - y2 = 0; - if (y + cHeight < gUnknown_03004870.height) { - height = cHeight; - } else { - height = gUnknown_03004870.height - y; - } - } - - sub_8056134( - x, y, - connectedMapHeader, - /*x2*/ 0, y2, - /*width*/ 8, height); - } -} - -union Block { - struct { - u16 block:10; - u16 collision:2; - u16 elevation:4; - } block; - u16 value; +static const struct ConnectionFlags sDummyConnectionFlags = {0}; + +struct MapHeader *mapconnection_get_mapheader(struct MapConnection *connection) +{ + return get_mapheader_by_bank_and_number(connection->mapGroup, connection->mapNum); +} + +void not_trainer_hill_battle_pyramid(void) +{ + mapheader_copy_mapdata_with_padding(&gMapHeader); + sub_80BB970(gMapHeader.events); + mapheader_run_script_with_tag_x1(); +} + +void sub_8055FC0(void) +{ + mapheader_copy_mapdata_with_padding(&gMapHeader); + sub_80BBCCC(0); + sub_80BB970(gMapHeader.events); + sub_8056670(); + mapheader_run_script_with_tag_x1(); + UpdateTVScreensOnMap(gUnknown_03004870.width, gUnknown_03004870.height); +} + +void mapheader_copy_mapdata_with_padding(struct MapHeader *mapHeader) +{ + struct MapData *mapData; + int width; + int height; + mapData = mapHeader->mapData; + CpuFastFill16(0x03ff, gUnknown_02029828, sizeof(gUnknown_02029828)); + gUnknown_03004870.map = gUnknown_02029828; + width = mapData->width + 15; + gUnknown_03004870.width = width; + height = mapData->height + 14; + gUnknown_03004870.height = height; + if (width * height <= 0x2800) + { + map_copy_with_padding(mapData->map, mapData->width, mapData->height); + sub_80560AC(mapHeader); + } +} + +void map_copy_with_padding(u16 *map, u16 width, u16 height) +{ + u16 *dest; + int y; + dest = gUnknown_03004870.map; + dest += gUnknown_03004870.width * 7 + 7; + for (y = 0; y < height; y++) + { + CpuCopy16(map, dest, width * 2); + dest += width + 0xf; + map += width; + } +} + +void sub_80560AC(struct MapHeader *mapHeader) +{ + int i; + struct MapConnection *connection; + struct MapHeader *cMap; + u32 offset; + int count; + count = mapHeader->connections->count; + connection = mapHeader->connections->connections; + gUnknown_0202E850 = sDummyConnectionFlags; + for (i = 0; i < count; i++, connection++) + { + cMap = mapconnection_get_mapheader(connection); + offset = connection->offset; + switch (connection->direction) + { + case CONNECTION_SOUTH: + fillSouthConnection(mapHeader, cMap, offset); + gUnknown_0202E850.south = 1; + break; + case CONNECTION_NORTH: + fillNorthConnection(mapHeader, cMap, offset); + gUnknown_0202E850.north = 1; + break; + case CONNECTION_WEST: + fillWestConnection(mapHeader, cMap, offset); + gUnknown_0202E850.west = 1; + break; + case CONNECTION_EAST: + fillEastConnection(mapHeader, cMap, offset); + gUnknown_0202E850.east = 1; + break; + } + } +} + +void sub_8056134(int x, int y, struct MapHeader *mapHeader, int x2, int y2, int width, int height) +{ + int i; + u16 *src; + u16 *dest; + int mapWidth; + + mapWidth = mapHeader->mapData->width; + src = &mapHeader->mapData->map[mapWidth * y2 + x2]; + dest = &gUnknown_03004870.map[gUnknown_03004870.width * y + x]; + + for (i = 0; i < height; i++) + { + CpuCopy16(src, dest, width * 2); + dest += gUnknown_03004870.width; + src += mapWidth; + } +} + +void fillSouthConnection(struct MapHeader *mapHeader, struct MapHeader *connectedMapHeader, s32 offset) +{ + int x, y; + int x2; + int width; + int cWidth; + + if (connectedMapHeader) + { + cWidth = connectedMapHeader->mapData->width; + x = offset + 7; + y = mapHeader->mapData->height + 7; + if (x < 0) + { + x2 = -x; + x += cWidth; + if (x < gUnknown_03004870.width) + { + width = x; + } + else + { + width = gUnknown_03004870.width; + } + x = 0; + } + else + { + x2 = 0; + if (x + cWidth < gUnknown_03004870.width) + { + width = cWidth; + } + else + { + width = gUnknown_03004870.width - x; + } + } + sub_8056134( + x, y, + connectedMapHeader, + x2, /*y2*/ 0, + width, /*height*/ 7); + } +} + +void fillNorthConnection(struct MapHeader *mapHeader, struct MapHeader *connectedMapHeader, s32 offset) +{ + int x; + int x2, y2; + int width; + int cWidth, cHeight; + + if (connectedMapHeader) + { + cWidth = connectedMapHeader->mapData->width; + cHeight = connectedMapHeader->mapData->height; + x = offset + 7; + y2 = cHeight - 7; + if (x < 0) + { + x2 = -x; + x += cWidth; + if (x < gUnknown_03004870.width) + { + width = x; + } + else + { + width = gUnknown_03004870.width; + } + x = 0; + } + else + { + x2 = 0; + if (x + cWidth < gUnknown_03004870.width) + { + width = cWidth; + } + else + { + width = gUnknown_03004870.width - x; + } + } + + sub_8056134( + x, /*y*/ 0, + connectedMapHeader, + x2, y2, + width, /*height*/ 7); + + } +} + + +void fillWestConnection(struct MapHeader *mapHeader, struct MapHeader *connectedMapHeader, s32 offset) +{ + int y; + int x2, y2; + int height; + int cWidth, cHeight; + if (connectedMapHeader) + { + cWidth = connectedMapHeader->mapData->width; + cHeight = connectedMapHeader->mapData->height; + y = offset + 7; + x2 = cWidth - 7; + if (y < 0) + { + y2 = -y; + if (y + cHeight < gUnknown_03004870.height) + { + height = y + cHeight; + } + else + { + height = gUnknown_03004870.height; + } + y = 0; + } + else + { + y2 = 0; + if (y + cHeight < gUnknown_03004870.height) + { + height = cHeight; + } + else + { + height = gUnknown_03004870.height - y; + } + } + + sub_8056134( + /*x*/ 0, y, + connectedMapHeader, + x2, y2, + /*width*/ 7, height); + } +} + +void fillEastConnection(struct MapHeader *mapHeader, struct MapHeader *connectedMapHeader, s32 offset) +{ + int x, y; + int y2; + int height; + int cHeight; + if (connectedMapHeader) + { + cHeight = connectedMapHeader->mapData->height; + x = mapHeader->mapData->width + 7; + y = offset + 7; + if (y < 0) + { + y2 = -y; + if (y + cHeight < gUnknown_03004870.height) + { + height = y + cHeight; + } + else + { + height = gUnknown_03004870.height; + } + y = 0; + } + else + { + y2 = 0; + if (y + cHeight < gUnknown_03004870.height) + { + height = cHeight; + } + else + { + height = gUnknown_03004870.height - y; + } + } + + sub_8056134( + x, y, + connectedMapHeader, + /*x2*/ 0, y2, + /*width*/ 8, height); + } +} + +union Block +{ + struct + { + u16 block:10; + u16 collision:2; + u16 elevation:4; + } block; + u16 value; }; -u16 MapGridGetZCoordAt(int x, int y) { - u16 block; - int i; - u16 *border; - - if (x >= 0 && x < gUnknown_03004870.width - && y >= 0 && y < gUnknown_03004870.height) { - block = gUnknown_03004870.map[x + gUnknown_03004870.width * y]; - } else { - border = gMapHeader.mapData->border; - i = (x + 1) & 1; - i += ((y + 1) & 1) * 2; - block = gMapHeader.mapData->border[i]; - block |= 0xc00; - } - if (block == 0x3ff) { - return 0; - } - return block >> 12; -} - -u16 MapGridIsImpassableAt(int x, int y) { - u16 block; - int i; - u16 *border; - - if (x >= 0 && x < gUnknown_03004870.width - && y >= 0 && y < gUnknown_03004870.height) { - block = gUnknown_03004870.map[x + gUnknown_03004870.width * y]; - } else { - border = gMapHeader.mapData->border; - i = (x + 1) & 1; - i += ((y + 1) & 1) * 2; - block = gMapHeader.mapData->border[i]; - block |= 0xc00; - } - if (block == 0x3ff) { - return 1; - } - return (block & 0xc00) >> 10; -} - -u16 MapGridGetMetatileIdAt(int x, int y) { - u16 block; - int i; - int j; - struct MapData *mapData; - u16 *border; - u16 block2; - - if (x >= 0 && x < gUnknown_03004870.width - && y >= 0 && y < gUnknown_03004870.height) { - block = gUnknown_03004870.map[x + gUnknown_03004870.width * y]; - } else { - mapData = gMapHeader.mapData; - i = (x + 1) & 1; - i += ((y + 1) & 1) * 2; - block = mapData->border[i] | 0xc00; - } - if (block == 0x3ff) { - border = gMapHeader.mapData->border; - j = (x + 1) & 1; - j += ((y + 1) & 1) * 2; - block2 = gMapHeader.mapData->border[j]; - block2 |= 0xc00; - return block2 & block; - } - return block & 0x3ff; -} - -u32 MapGridGetMetatileBehaviorAt(int x, int y) { - u16 metatile; - metatile = MapGridGetMetatileIdAt(x, y); - return GetBehaviorByMetatileId(metatile) & 0xff; -} - -u16 MapGridGetMetatileLayerTypeAt(int x, int y) { - u16 metatile; - metatile = MapGridGetMetatileIdAt(x, y); - return (GetBehaviorByMetatileId(metatile) & 0xf000) >> 12; -} - -void MapGridSetMetatileIdAt(int x, int y, u16 metatile) { - int i; - if (x >= 0 && x < gUnknown_03004870.width - && y >= 0 && y < gUnknown_03004870.height) { - i = x + y * gUnknown_03004870.width; - gUnknown_03004870.map[i] = (gUnknown_03004870.map[i] & 0xf000) | (metatile & 0xfff); - } -} - -void MapGridSetMetatileEntryAt(int x, int y, u16 metatile) { - int i; - if (x >= 0 && x < gUnknown_03004870.width - && y >= 0 && y < gUnknown_03004870.height) { - i = x + gUnknown_03004870.width * y; - gUnknown_03004870.map[i] = metatile; - } -} - -u32 GetBehaviorByMetatileId(u16 metatile) { - u16 *attributes; - if (metatile <= 0x1ff) { - attributes = gMapHeader.mapData->primaryTileset->metatileAttributes; - return attributes[metatile]; - } else if (metatile <= 0x3ff) { - attributes = gMapHeader.mapData->secondaryTileset->metatileAttributes; - return attributes[metatile - 0x200]; - } else { - return 0xff; - } -} - -void save_serialize_map(void) { - int i, j; - int x, y; - u16 *mapView; - int width; - mapView = gSaveBlock1.mapView; - width = gUnknown_03004870.width; - x = gSaveBlock1.pos.x; - y = gSaveBlock1.pos.y; - for (i = y; i < y + 14; i++) - for (j = x; j < x + 15; j++) { - *mapView++ = gUnknown_02029828[width * i + j]; - } -} - -int sub_8056618(void) { - u16 i; - u32 r2; - r2 = 0; - for (i = 0; i < 0x200; i++) { - r2 |= gSaveBlock1.mapView[i]; - } - if (r2 == 0) { - return 1; - } - return 0; -} - -void sav2_mapdata_clear(void) { - CpuFill16(0, gSaveBlock1.mapView, sizeof(gSaveBlock1.mapView)); -} - -void sub_8056670(void) { - int i, j; - int x, y; - u16 *mapView; - int width; - mapView = gSaveBlock1.mapView; - if (!sub_8056618()) { - width = gUnknown_03004870.width; - x = gSaveBlock1.pos.x; - y = gSaveBlock1.pos.y; - for (i = y; i < y + 14; i++) - for (j = x; j < x + 15; j++) { - gUnknown_02029828[width * i + j] = *mapView++; - } - sav2_mapdata_clear(); - } -} - -void sub_80566F0(u8 a1) { - u16 *mapView; - int width; - int x0, y0; - int x2, y2; - u16 *src, *dest; - int srci, desti; - int r9, r8; - int x, y; - int i, j; - mapView = gSaveBlock1.mapView; - width = gUnknown_03004870.width; - r9 = 0; - r8 = 0; - x0 = gSaveBlock1.pos.x; - y0 = gSaveBlock1.pos.y; - x2 = 15; - y2 = 14; - switch (a1) { - case CONNECTION_NORTH: - y0 += 1; - y2 = 13; - break; - case CONNECTION_SOUTH: - r8 = 1; - y2 = 13; - break; - case CONNECTION_WEST: - x0 += 1; - x2 = 14; - break; - case CONNECTION_EAST: - r9 = 1; - x2 = 14; - break; - } - for (y = 0; y < y2; y++) { - i = 0; - j = 0; - for (x = 0; x < x2; x++) { - desti = width * (y + y0); - srci = (y + r8) * 15 + r9; - src = &mapView[srci + i]; - dest = &gUnknown_02029828[x0 + desti + j]; - *dest = *src; - i++; - j++; - } - } - sav2_mapdata_clear(); -} - -int GetMapBorderIdAt(int x, int y) { - struct MapData *mapData; - u16 block, block2; - int i, j; - if (x >= 0 && x < gUnknown_03004870.width - && y >= 0 && y < gUnknown_03004870.height) { - i = gUnknown_03004870.width; - i *= y; - block = gUnknown_03004870.map[x + i]; - if (block == 0x3ff) { - goto fail; - } - } else { - mapData = gMapHeader.mapData; - j = (x + 1) & 1; - j += ((y + 1) & 1) * 2; - block2 = 0xc00 | mapData->border[j]; - if (block2 == 0x3ff) { - goto fail; - } - } - goto success; +u8 MapGridGetZCoordAt(int x, int y) +{ + u16 block; + int i; + u16 *border; + + if (x >= 0 && x < gUnknown_03004870.width + && y >= 0 && y < gUnknown_03004870.height) + { + block = gUnknown_03004870.map[x + gUnknown_03004870.width * y]; + } + else + { + border = gMapHeader.mapData->border; + i = (x + 1) & 1; + i += ((y + 1) & 1) * 2; + block = gMapHeader.mapData->border[i]; + block |= 0xc00; + } + if (block == 0x3ff) + { + return 0; + } + return block >> 12; +} + +u8 MapGridIsImpassableAt(int x, int y) +{ + u16 block; + int i; + u16 *border; + + if (x >= 0 && x < gUnknown_03004870.width + && y >= 0 && y < gUnknown_03004870.height) + { + block = gUnknown_03004870.map[x + gUnknown_03004870.width * y]; + } + else + { + border = gMapHeader.mapData->border; + i = (x + 1) & 1; + i += ((y + 1) & 1) * 2; + block = gMapHeader.mapData->border[i]; + block |= 0xc00; + } + if (block == 0x3ff) + { + return 1; + } + return (block & 0xc00) >> 10; +} + +u32 MapGridGetMetatileIdAt(int x, int y) +{ + u16 block; + int i; + int j; + struct MapData *mapData; + u16 *border; + u16 block2; + + if (x >= 0 && x < gUnknown_03004870.width + && y >= 0 && y < gUnknown_03004870.height) + { + block = gUnknown_03004870.map[x + gUnknown_03004870.width * y]; + } + else + { + mapData = gMapHeader.mapData; + i = (x + 1) & 1; + i += ((y + 1) & 1) * 2; + block = mapData->border[i] | 0xc00; + } + if (block == 0x3ff) + { + border = gMapHeader.mapData->border; + j = (x + 1) & 1; + j += ((y + 1) & 1) * 2; + block2 = gMapHeader.mapData->border[j]; + block2 |= 0xc00; + return block2 & block; + } + return block & 0x3ff; +} + +u32 MapGridGetMetatileBehaviorAt(int x, int y) +{ + u16 metatile; + metatile = MapGridGetMetatileIdAt(x, y); + return GetBehaviorByMetatileId(metatile) & 0xff; +} + +u8 MapGridGetMetatileLayerTypeAt(int x, int y) +{ + u16 metatile; + metatile = MapGridGetMetatileIdAt(x, y); + return (GetBehaviorByMetatileId(metatile) & 0xf000) >> 12; +} + +void MapGridSetMetatileIdAt(int x, int y, u16 metatile) +{ + int i; + if (x >= 0 && x < gUnknown_03004870.width + && y >= 0 && y < gUnknown_03004870.height) + { + i = x + y * gUnknown_03004870.width; + gUnknown_03004870.map[i] = (gUnknown_03004870.map[i] & 0xf000) | (metatile & 0xfff); + } +} + +void MapGridSetMetatileEntryAt(int x, int y, u16 metatile) +{ + int i; + if (x >= 0 && x < gUnknown_03004870.width + && y >= 0 && y < gUnknown_03004870.height) + { + i = x + gUnknown_03004870.width * y; + gUnknown_03004870.map[i] = metatile; + } +} + +u32 GetBehaviorByMetatileId(u16 metatile) +{ + u16 *attributes; + if (metatile <= 0x1ff) + { + attributes = gMapHeader.mapData->primaryTileset->metatileAttributes; + return attributes[metatile]; + } + else if (metatile <= 0x3ff) + { + attributes = gMapHeader.mapData->secondaryTileset->metatileAttributes; + return attributes[metatile - 0x200]; + } + else + { + return 0xff; + } +} + +void save_serialize_map(void) +{ + int i, j; + int x, y; + u16 *mapView; + int width; + mapView = gSaveBlock1.mapView; + width = gUnknown_03004870.width; + x = gSaveBlock1.pos.x; + y = gSaveBlock1.pos.y; + for (i = y; i < y + 14; i++) + { + for (j = x; j < x + 15; j++) + { + *mapView++ = gUnknown_02029828[width * i + j]; + } + } +} + +int sub_8056618(void) +{ + u16 i; + u32 r2; + r2 = 0; + for (i = 0; i < 0x200; i++) + { + r2 |= gSaveBlock1.mapView[i]; + } + if (r2 == 0) + { + return 1; + } + return 0; +} + +void sav2_mapdata_clear(void) +{ + CpuFill16(0, gSaveBlock1.mapView, sizeof(gSaveBlock1.mapView)); +} + +void sub_8056670(void) +{ + int i, j; + int x, y; + u16 *mapView; + int width; + mapView = gSaveBlock1.mapView; + if (!sub_8056618()) + { + width = gUnknown_03004870.width; + x = gSaveBlock1.pos.x; + y = gSaveBlock1.pos.y; + for (i = y; i < y + 14; i++) + { + for (j = x; j < x + 15; j++) + { + gUnknown_02029828[width * i + j] = *mapView++; + } + } + sav2_mapdata_clear(); + } +} + +void sub_80566F0(u8 a1) +{ + u16 *mapView; + int width; + int x0, y0; + int x2, y2; + u16 *src, *dest; + int srci, desti; + int r9, r8; + int x, y; + int i, j; + mapView = gSaveBlock1.mapView; + width = gUnknown_03004870.width; + r9 = 0; + r8 = 0; + x0 = gSaveBlock1.pos.x; + y0 = gSaveBlock1.pos.y; + x2 = 15; + y2 = 14; + switch (a1) + { + case CONNECTION_NORTH: + y0 += 1; + y2 = 13; + break; + case CONNECTION_SOUTH: + r8 = 1; + y2 = 13; + break; + case CONNECTION_WEST: + x0 += 1; + x2 = 14; + break; + case CONNECTION_EAST: + r9 = 1; + x2 = 14; + break; + } + for (y = 0; y < y2; y++) + { + i = 0; + j = 0; + for (x = 0; x < x2; x++) + { + desti = width * (y + y0); + srci = (y + r8) * 15 + r9; + src = &mapView[srci + i]; + dest = &gUnknown_02029828[x0 + desti + j]; + *dest = *src; + i++; + j++; + } + } + sav2_mapdata_clear(); +} + +int GetMapBorderIdAt(int x, int y) +{ + struct MapData *mapData; + u16 block, block2; + int i, j; + if (x >= 0 && x < gUnknown_03004870.width + && y >= 0 && y < gUnknown_03004870.height) + { + i = gUnknown_03004870.width; + i *= y; + block = gUnknown_03004870.map[x + i]; + if (block == 0x3ff) + { + goto fail; + } + } + else + { + mapData = gMapHeader.mapData; + j = (x + 1) & 1; + j += ((y + 1) & 1) * 2; + block2 = 0xc00 | mapData->border[j]; + if (block2 == 0x3ff) + { + goto fail; + } + } + goto success; fail: - return -1; + return -1; success: - if (x >= (gUnknown_03004870.width - 8)) { - if (!gUnknown_0202E850.east) { - return -1; - } - return CONNECTION_EAST; - } else if (x < 7) { - if (!gUnknown_0202E850.west) { - return -1; - } - return CONNECTION_WEST; - } else if (y >= (gUnknown_03004870.height - 7)) { - if (!gUnknown_0202E850.south) { - return -1; - } - return CONNECTION_SOUTH; - } else if (y < 7) { - if (!gUnknown_0202E850.north) { - return -1; - } - return CONNECTION_NORTH; - } else { - return 0; - } -} - -int GetPostCameraMoveMapBorderId(int x, int y) { - return GetMapBorderIdAt(gSaveBlock1.pos.x + 7 + x, gSaveBlock1.pos.y + 7 + y); -} - -int CanCameraMoveInDirection(int direction) { - int x, y; - x = gSaveBlock1.pos.x + 7 + gUnknown_0821664C[direction].x; - y = gSaveBlock1.pos.y + 7 + gUnknown_0821664C[direction].y; - if (GetMapBorderIdAt(x, y) == -1) { - return 0; - } - return 1; -} - -void sub_8056918(struct MapConnection *connection, int direction, int x, int y) { - struct MapHeader *mapHeader; - mapHeader = mapconnection_get_mapheader(connection); - switch (direction) { - case CONNECTION_EAST: - gSaveBlock1.pos.x = -x; - gSaveBlock1.pos.y -= connection->offset; - break; - case CONNECTION_WEST: - gSaveBlock1.pos.x = mapHeader->mapData->width; - gSaveBlock1.pos.y -= connection->offset; - break; - case CONNECTION_SOUTH: - gSaveBlock1.pos.x -= connection->offset; - gSaveBlock1.pos.y = -y; - break; - case CONNECTION_NORTH: - gSaveBlock1.pos.x -= connection->offset; - gSaveBlock1.pos.y = mapHeader->mapData->height; - break; - } -} - -bool8 CameraMove(int x, int y) { - unsigned int direction; - struct MapConnection *connection; - int old_x, old_y; - gUnknown_0202E844.field_0 = FALSE; - direction = GetPostCameraMoveMapBorderId(x, y); - if (direction + 1 <= 1) { - gSaveBlock1.pos.x += x; - gSaveBlock1.pos.y += y; - } else { - save_serialize_map(); - old_x = gSaveBlock1.pos.x; - old_y = gSaveBlock1.pos.y; - connection = sub_8056A64(direction, gSaveBlock1.pos.x, gSaveBlock1.pos.y); - sub_8056918(connection, direction, x, y); - sub_80538F0(connection->mapGroup, connection->mapNum); - gUnknown_0202E844.field_0 = TRUE; - gUnknown_0202E844.x = old_x - gSaveBlock1.pos.x; - gUnknown_0202E844.y = old_y - gSaveBlock1.pos.y; - gSaveBlock1.pos.x += x; - gSaveBlock1.pos.y += y; - sub_80566F0(direction); - } - return gUnknown_0202E844.field_0; -} - -struct MapConnection *sub_8056A64(u8 direction, int x, int y) { - int count; - struct MapConnection *connection; - int i; - count = gMapHeader.connections->count; - connection = gMapHeader.connections->connections; - for (i = 0; i < count; i++, connection++) { - if (connection->direction == direction) { - if (sub_8056ABC(direction, x, y, connection) == TRUE) { - return connection; - } - } - } - return NULL; -} - -bool8 sub_8056ABC(u8 direction, int x, int y, struct MapConnection *connection) { - struct MapHeader *mapHeader; - mapHeader = mapconnection_get_mapheader(connection); - switch (direction) { - case CONNECTION_SOUTH: - case CONNECTION_NORTH: - return sub_8056B20(x, gMapHeader.mapData->width, mapHeader->mapData->width, connection->offset); - case CONNECTION_WEST: - case CONNECTION_EAST: - return sub_8056B20(y, gMapHeader.mapData->height, mapHeader->mapData->height, connection->offset); - } - return FALSE; -} - -bool8 sub_8056B20(int x, int src_width, int dest_width, int offset) { - int offset2; - offset2 = offset; - if (offset2 < 0) { - offset2 = 0; - } - if (dest_width + offset < src_width) { - src_width = dest_width + offset; - } - if (offset2 <= x && x <= src_width) { - return TRUE; - } - return FALSE; -} - -int sub_8056B4C(int x, int width) { - if (x >= 0 && x < width) { - return TRUE; - } - return FALSE; -} - -int sub_8056B60(struct MapConnection *connection, int x, int y) { - struct MapHeader *mapHeader; - mapHeader = mapconnection_get_mapheader(connection); - switch (connection->direction) { - case CONNECTION_SOUTH: - case CONNECTION_NORTH: - return sub_8056B4C(x - connection->offset, mapHeader->mapData->width); - case CONNECTION_WEST: - case CONNECTION_EAST: - return sub_8056B4C(y - connection->offset, mapHeader->mapData->height); - } - return FALSE; -} - -struct MapConnection *sub_8056BA0(s16 x, s16 y) { - int count; - struct MapConnection *connection; - int i; - u8 direction; - if (!gMapHeader.connections) { - return NULL; - } else { - count = gMapHeader.connections->count; - connection = gMapHeader.connections->connections; - for (i = 0; i < count; i++, connection++) { - direction = connection->direction; - if ( - (direction == CONNECTION_DIVE || direction == CONNECTION_EMERGE) - || (direction == CONNECTION_NORTH && y > 6) - || (direction == CONNECTION_SOUTH && y < gMapHeader.mapData->height + 7) - || (direction == CONNECTION_WEST && x > 6) - || (direction == CONNECTION_EAST && x < gMapHeader.mapData->width + 7) - ) { - continue; - } - if (sub_8056B60(connection, x - 7, y - 7) == TRUE) { - return connection; - } - } - } - return NULL; -} - -void sub_8056C50(u16 x, u16 y) { - gSaveBlock1.pos.x = x - 7; - gSaveBlock1.pos.y = y - 7; -} - -void sav1_camera_get_focus_coords(u16 *x, u16 *y) { - *x = gSaveBlock1.pos.x + 7; - *y = gSaveBlock1.pos.y + 7; -} - -void unref_sub_8056C7C(u16 x, u16 y) { - gSaveBlock1.pos.x = x; - gSaveBlock1.pos.y = y; -} - -void GetCameraCoords(u16 *x, u16 *y) { - *x = gSaveBlock1.pos.x; - *y = gSaveBlock1.pos.y; -} - -void sub_8056C98(struct Tileset *tileset, void *src) { - if (tileset) { - if (!tileset->isCompressed) { - CpuFastSet(tileset->tiles, src, 0x1000); - } else { - LZ77UnCompVram(tileset->tiles, src); - } - } -} - -void sub_8056CBC(struct Tileset *tileset, int offset, int size) { - u16 black; - if (tileset) { - if (tileset->isSecondary == FALSE) { - black = 0; - LoadPalette(&black, offset, 2); - LoadPalette(tileset->palettes + 2, offset + 1, size - 2); - } else if (tileset->isSecondary == TRUE) { - LoadPalette(tileset->palettes + 0xc0, offset, size); - } else { - LZ77UnCompVram(tileset->palettes, (void*)0x2000000); - LoadPalette((void*)0x2000000, offset, size); - } - } -} - -void sub_8056D28(struct MapData *mapData) { - void *src = (void*)(BG_VRAM); - sub_8056C98(mapData->primaryTileset, src); -} - -void sub_8056D38(struct MapData *mapData) { - void *src = (void*)(BG_VRAM + 0x4000); - sub_8056C98(mapData->secondaryTileset, src); -} - -void apply_map_tileset1_palette(struct MapData *mapData) { - sub_8056CBC(mapData->primaryTileset, 0, 0xc0); -} - -void apply_map_tileset2_palette(struct MapData *mapData) { - sub_8056CBC(mapData->secondaryTileset, 0x60, 0xc0); -} - -void copy_map_tileset1_tileset2_to_vram(struct MapData *mapData) { - if (mapData) { - sub_8056D28(mapData); - sub_8056D38(mapData); - } + if (x >= (gUnknown_03004870.width - 8)) + { + if (!gUnknown_0202E850.east) + { + return -1; + } + return CONNECTION_EAST; + } + else if (x < 7) + { + if (!gUnknown_0202E850.west) + { + return -1; + } + return CONNECTION_WEST; + } + else if (y >= (gUnknown_03004870.height - 7)) + { + if (!gUnknown_0202E850.south) + { + return -1; + } + return CONNECTION_SOUTH; + } + else if (y < 7) + { + if (!gUnknown_0202E850.north) + { + return -1; + } + return CONNECTION_NORTH; + } + else + { + return 0; + } +} + +int GetPostCameraMoveMapBorderId(int x, int y) +{ + return GetMapBorderIdAt(gSaveBlock1.pos.x + 7 + x, gSaveBlock1.pos.y + 7 + y); } - -void apply_map_tileset1_tileset2_palette(struct MapData *mapData) { - if (mapData) { - apply_map_tileset1_palette(mapData); - apply_map_tileset2_palette(mapData); - } + +int CanCameraMoveInDirection(int direction) +{ + int x, y; + x = gSaveBlock1.pos.x + 7 + gUnknown_0821664C[direction].x; + y = gSaveBlock1.pos.y + 7 + gUnknown_0821664C[direction].y; + if (GetMapBorderIdAt(x, y) == -1) + { + return 0; + } + return 1; +} + +void sub_8056918(struct MapConnection *connection, int direction, int x, int y) +{ + struct MapHeader *mapHeader; + mapHeader = mapconnection_get_mapheader(connection); + switch (direction) + { + case CONNECTION_EAST: + gSaveBlock1.pos.x = -x; + gSaveBlock1.pos.y -= connection->offset; + break; + case CONNECTION_WEST: + gSaveBlock1.pos.x = mapHeader->mapData->width; + gSaveBlock1.pos.y -= connection->offset; + break; + case CONNECTION_SOUTH: + gSaveBlock1.pos.x -= connection->offset; + gSaveBlock1.pos.y = -y; + break; + case CONNECTION_NORTH: + gSaveBlock1.pos.x -= connection->offset; + gSaveBlock1.pos.y = mapHeader->mapData->height; + break; + } +} + +bool8 CameraMove(int x, int y) +{ + unsigned int direction; + struct MapConnection *connection; + int old_x, old_y; + gUnknown_0202E844.field_0 = FALSE; + direction = GetPostCameraMoveMapBorderId(x, y); + if (direction + 1 <= 1) + { + gSaveBlock1.pos.x += x; + gSaveBlock1.pos.y += y; + } + else + { + save_serialize_map(); + old_x = gSaveBlock1.pos.x; + old_y = gSaveBlock1.pos.y; + connection = sub_8056A64(direction, gSaveBlock1.pos.x, gSaveBlock1.pos.y); + sub_8056918(connection, direction, x, y); + sub_80538F0(connection->mapGroup, connection->mapNum); + gUnknown_0202E844.field_0 = TRUE; + gUnknown_0202E844.x = old_x - gSaveBlock1.pos.x; + gUnknown_0202E844.y = old_y - gSaveBlock1.pos.y; + gSaveBlock1.pos.x += x; + gSaveBlock1.pos.y += y; + sub_80566F0(direction); + } + return gUnknown_0202E844.field_0; +} + +struct MapConnection *sub_8056A64(u8 direction, int x, int y) +{ + int count; + struct MapConnection *connection; + int i; + count = gMapHeader.connections->count; + connection = gMapHeader.connections->connections; + for (i = 0; i < count; i++, connection++) + { + if (connection->direction == direction) + { + if (sub_8056ABC(direction, x, y, connection) == TRUE) + { + return connection; + } + } + } + return NULL; +} + +bool8 sub_8056ABC(u8 direction, int x, int y, struct MapConnection *connection) +{ + struct MapHeader *mapHeader; + mapHeader = mapconnection_get_mapheader(connection); + switch (direction) + { + case CONNECTION_SOUTH: + case CONNECTION_NORTH: + return sub_8056B20(x, gMapHeader.mapData->width, mapHeader->mapData->width, connection->offset); + case CONNECTION_WEST: + case CONNECTION_EAST: + return sub_8056B20(y, gMapHeader.mapData->height, mapHeader->mapData->height, connection->offset); + } + return FALSE; +} + +bool8 sub_8056B20(int x, int src_width, int dest_width, int offset) +{ + int offset2; + offset2 = offset; + if (offset2 < 0) + { + offset2 = 0; + } + if (dest_width + offset < src_width) + { + src_width = dest_width + offset; + } + if (offset2 <= x && x <= src_width) + { + return TRUE; + } + return FALSE; +} + +int sub_8056B4C(int x, int width) +{ + if (x >= 0 && x < width) + { + return TRUE; + } + return FALSE; +} + +int sub_8056B60(struct MapConnection *connection, int x, int y) +{ + struct MapHeader *mapHeader; + mapHeader = mapconnection_get_mapheader(connection); + switch (connection->direction) + { + case CONNECTION_SOUTH: + case CONNECTION_NORTH: + return sub_8056B4C(x - connection->offset, mapHeader->mapData->width); + case CONNECTION_WEST: + case CONNECTION_EAST: + return sub_8056B4C(y - connection->offset, mapHeader->mapData->height); + } + return FALSE; +} + +struct MapConnection *sub_8056BA0(s16 x, s16 y) +{ + int count; + struct MapConnection *connection; + int i; + u8 direction; + if (!gMapHeader.connections) + { + return NULL; + } + else + { + count = gMapHeader.connections->count; + connection = gMapHeader.connections->connections; + for (i = 0; i < count; i++, connection++) + { + direction = connection->direction; + if ((direction == CONNECTION_DIVE || direction == CONNECTION_EMERGE) + || (direction == CONNECTION_NORTH && y > 6) + || (direction == CONNECTION_SOUTH && y < gMapHeader.mapData->height + 7) + || (direction == CONNECTION_WEST && x > 6) + || (direction == CONNECTION_EAST && x < gMapHeader.mapData->width + 7)) + { + continue; + } + if (sub_8056B60(connection, x - 7, y - 7) == TRUE) + { + return connection; + } + } + } + return NULL; +} + +void sub_8056C50(u16 x, u16 y) +{ + gSaveBlock1.pos.x = x - 7; + gSaveBlock1.pos.y = y - 7; +} + +void sav1_camera_get_focus_coords(u16 *x, u16 *y) +{ + *x = gSaveBlock1.pos.x + 7; + *y = gSaveBlock1.pos.y + 7; +} + +void unref_sub_8056C7C(u16 x, u16 y) +{ + gSaveBlock1.pos.x = x; + gSaveBlock1.pos.y = y; +} + +void GetCameraCoords(u16 *x, u16 *y) +{ + *x = gSaveBlock1.pos.x; + *y = gSaveBlock1.pos.y; +} + +void sub_8056C98(struct Tileset *tileset, void *src) +{ + if (tileset) + { + if (!tileset->isCompressed) + { + CpuFastSet(tileset->tiles, src, 0x1000); + } + else + { + LZ77UnCompVram(tileset->tiles, src); + } + } +} + +void sub_8056CBC(struct Tileset *tileset, int offset, int size) +{ + u16 black; + if (tileset) + { + if (tileset->isSecondary == FALSE) + { + black = 0; + LoadPalette(&black, offset, 2); + LoadPalette(tileset->palettes + 2, offset + 1, size - 2); + } + else if (tileset->isSecondary == TRUE) + { + LoadPalette(tileset->palettes + 0xc0, offset, size); + } + else + { + LZ77UnCompVram(tileset->palettes, (void*)0x2000000); + LoadPalette((void*)0x2000000, offset, size); + } + } +} + +void sub_8056D28(struct MapData *mapData) +{ + void *src = (void*)(BG_VRAM); + sub_8056C98(mapData->primaryTileset, src); +} + +void sub_8056D38(struct MapData *mapData) +{ + void *src = (void*)(BG_VRAM + 0x4000); + sub_8056C98(mapData->secondaryTileset, src); +} + +void apply_map_tileset1_palette(struct MapData *mapData) +{ + sub_8056CBC(mapData->primaryTileset, 0, 0xc0); +} + +void apply_map_tileset2_palette(struct MapData *mapData) +{ + sub_8056CBC(mapData->secondaryTileset, 0x60, 0xc0); +} + +void copy_map_tileset1_tileset2_to_vram(struct MapData *mapData) +{ + if (mapData) + { + sub_8056D28(mapData); + sub_8056D38(mapData); + } +} + +void apply_map_tileset1_tileset2_palette(struct MapData *mapData) +{ + if (mapData) + { + apply_map_tileset1_palette(mapData); + apply_map_tileset2_palette(mapData); + } } diff --git a/src/flag.c b/src/flag.c deleted file mode 100644 index e7347ad0d..000000000 --- a/src/flag.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "global.h" -#include "flag.h" - -extern u8 gUnknown_0202E8E2[]; - -u8 *GetFlagPointer(u16 id) -{ - if (id == 0) - return 0; - - if (id < 0x4000) - return &gSaveBlock1.flags[id / 8]; - - return &gUnknown_0202E8E2[(id - 0x4000) / 8]; -} - -u8 FlagSet(u16 id) -{ - u8 *ptr = GetFlagPointer(id); - if (ptr) - *ptr |= 1 << (id & 7); - return 0; -} - -u8 FlagReset(u16 id) -{ - u8 *ptr = GetFlagPointer(id); - if (ptr) - *ptr &= ~(1 << (id & 7)); - return 0; -} - -bool8 FlagGet(u16 id) -{ - u8 *ptr = GetFlagPointer(id); - - if (!ptr) - return FALSE; - - if (!(((*ptr) >> (id & 7)) & 1)) - return FALSE; - - return TRUE; -} diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c new file mode 100644 index 000000000..e837dbd45 --- /dev/null +++ b/src/fldeff_cut.c @@ -0,0 +1,291 @@ +#include "global.h" +#include "fldeff_cut.h" +#include "field_camera.h" +#include "field_effect.h" +#include "field_player_avatar.h" +#include "fieldmap.h" +#include "map_obj_lock.h" +#include "metatile_behavior.h" +#include "metatile_behaviors.h" +#include "pokemon_menu.h" +#include "rom4.h" +#include "rom6.h" +#include "script.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "trig.h" + +extern u8 gCutGrassSpriteArray[8]; // seems to be an array of 8 sprite IDs + +extern void (*gFieldCallback)(void); +extern void (*gUnknown_03005CE4)(void); + +extern struct SpriteTemplate gSpriteTemplate_CutGrass; + +extern struct MapPosition gUnknown_0203923C; + +extern u8 gLastFieldPokeMenuOpened; +extern u32 gUnknown_0202FF84[]; + +extern u8 UseCutScript; + +bool8 SetUpFieldMove_Cut(void) +{ + s16 x, y; + u8 i, j; + u8 tileBehavior; + + if(npc_before_player_of_type(0x52) == TRUE) // is in front of tree? + { + gFieldCallback = sub_808AB90; + gUnknown_03005CE4 = sub_80A2634; + return TRUE; + } + else // is in ash or grass to cut? + { + PlayerGetDestCoords(&gUnknown_0203923C.x, &gUnknown_0203923C.y); + for(i = 0; i < 3; i++) + { + y = i - 1 + gUnknown_0203923C.y; + for(j = 0; j < 3; j++) + { + x = j - 1 + gUnknown_0203923C.x; + if(MapGridGetZCoordAt(x, y) == (s8)gUnknown_0203923C.height) + { + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if(MetatileBehavior_IsPokeGrass(tileBehavior) == TRUE + || MetatileBehavior_IsAshGrass(tileBehavior) == TRUE) + { + gFieldCallback = sub_808AB90; + gUnknown_03005CE4 = sub_80A25E8; + return TRUE; + } + } + } + } + return FALSE; // do not use cut + } +} + +void sub_80A25E8(void) +{ + FieldEffectStart(1); + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; +} + +bool8 FldEff_UseCutOnGrass(void) +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)sub_80A2684 >> 16; + gTasks[taskId].data[9] = (u32)sub_80A2684; + IncrementGameStat(0x12); + return FALSE; +} + +void sub_80A2634(void) +{ + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; + ScriptContext1_SetupScript(&UseCutScript); +} + +bool8 FldEff_UseCutOnTree(void) +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)sub_80A2B00 >> 16; + gTasks[taskId].data[9] = (u32)sub_80A2B00; + IncrementGameStat(0x12); + return FALSE; +} + +void sub_80A2684(void) +{ + FieldEffectActiveListRemove(1); + FieldEffectStart(0x3A); +} + +bool8 FldEff_CutGrass(void) +{ + s16 x, y; + u8 tileBehavior; + u8 i, j; // not in for loop? + + for(i = 0, PlaySE(SE_W015), PlayerGetDestCoords(&gUnknown_0203923C.x, &gUnknown_0203923C.y); i < 3; i++) + { + y = i - 1 + gUnknown_0203923C.y; + for(j = 0; j < 3; j++) + { + x = j - 1 + gUnknown_0203923C.x; + if(MapGridGetZCoordAt(x, y) == (s8)gUnknown_0203923C.height) + { + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if(MetatileBehavior_IsCuttableGrass(tileBehavior) == TRUE) + { + sub_80A27A8(x, y); + sub_805BCC0(x, y); + } + } + } + } + sub_80A28F4(gUnknown_0203923C.x - 1, gUnknown_0203923C.y - 2); + DrawWholeMapView(); + + // populate sprite ID array + for(i = 0; i < 8; i++) + { + gCutGrassSpriteArray[i] = CreateSprite((struct SpriteTemplate *)&gSpriteTemplate_CutGrass, + gSprites[gPlayerAvatar.spriteId].oam.x + 8, gSprites[gPlayerAvatar.spriteId].oam.y + 20, 0); + gSprites[gCutGrassSpriteArray[i]].data2 = 32 * i; + } + return 0; +} + +// set map grid metatile depending on x, y +// TODO: enum for metatile IDs +void sub_80A27A8(s16 x, s16 y) +{ + int metatileId = MapGridGetMetatileIdAt(x, y); + + switch(metatileId) + { + case 0x208: + case 0x15: + case 0xD: + MapGridSetMetatileIdAt(x, y, 0x1); + break; + case 0x1C6: + MapGridSetMetatileIdAt(x, y, 0x1CE); + break; + case 0x1C7: + MapGridSetMetatileIdAt(x, y, 0x1CF); + break; + case 0x281: + MapGridSetMetatileIdAt(x, y, 0x279); + break; + case 0x282: + MapGridSetMetatileIdAt(x, y, 0x27A); + break; + case 0x283: + MapGridSetMetatileIdAt(x, y, 0x27B); + break; + case 0x206: + case 0x207: + MapGridSetMetatileIdAt(x, y, 0x271); + break; + case 0x212: + case 0x20A: + MapGridSetMetatileIdAt(x, y, 0x218); + break; + case 0x25: + MapGridSetMetatileIdAt(x, y, 0xE); + break; + } +} + +s32 sub_80A28A0(s16 x, s16 y) +{ + u16 metatileId = MapGridGetMetatileIdAt(x, y); + + if(metatileId == 1) + return 1; + else if(metatileId == 633) + return 2; + else if(metatileId == 634) + return 3; + else if(metatileId == 635) + return 4; + else + return 0; +} + +void sub_80A28F4(s16 x, s16 y) +{ + s16 i; + u16 lowerY = y + 3; + + for(i = 0; i < 3; i++) + { + u16 currentX = x + i; + s16 currentXsigned = x + i; + if(MapGridGetMetatileIdAt(currentXsigned, y) == 21) + { + switch((u8)sub_80A28A0(currentXsigned, y + 1)) + { + case 1: + MapGridSetMetatileIdAt(currentXsigned, y + 1, 0x208); + break; + case 2: + MapGridSetMetatileIdAt(currentXsigned, y + 1, 0x281); + break; + case 3: + MapGridSetMetatileIdAt(currentXsigned, y + 1, 0x282); + break; + case 4: + MapGridSetMetatileIdAt(currentXsigned, y + 1, 0x283); + break; + } + } + if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY) == 1) + { + if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x208) + MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x1); + if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x281) + MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x279); + if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x282) + MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x27A); + if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x283) + MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x27B); + } + } +} + +void sub_80A2A48(struct Sprite *sprite) +{ + sprite->data0 = 8; + sprite->data1 = 0; + sprite->data3 = 0; + sprite->callback = (void *)objc_8097BBC; +} + +void objc_8097BBC(struct Sprite *sprite) +{ + u16 tempdata; + u16 tempdata2; + + sprite->pos2.x = Sin(sprite->data2, sprite->data0); + sprite->pos2.y = Cos(sprite->data2, sprite->data0); + + sprite->data2 = (sprite->data2 + 8) & 0xFF; + sprite->data0 += ((tempdata2 = sprite->data3) << 16 >> 18) + 1; // what? + sprite->data3 = tempdata2 + 1; + + tempdata = sprite->data1; + if((s16)tempdata != 28) // done rotating the grass, execute clean up function + sprite->data1++; + else + sprite->callback = (void *)sub_80A2AB8; +} + +void sub_80A2AB8(void) +{ + u8 i; + + for(i = 1; i < 8; i++) + { + DestroySprite(&gSprites[gCutGrassSpriteArray[i]]); + } + + FieldEffectStop(&gSprites[gCutGrassSpriteArray[0]], 0x3A); + sub_8064E2C(); + ScriptContext2_Disable(); +} + +void sub_80A2B00(void) +{ + PlaySE(0x80); + FieldEffectActiveListRemove(2); + EnableBothScriptContexts(); +} diff --git a/src/fldeff_emotion.c b/src/fldeff_emotion.c deleted file mode 100644 index efe4ef683..000000000 --- a/src/fldeff_emotion.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "global.h" -#include "asm.h" -#include "sprite.h" -#include "asm_fieldmap.h" -#include "field_effect.h" - -extern u32 gUnknown_0202FF84[]; - -extern struct SpriteTemplate gSpriteTemplate_839B510; -extern struct SpriteTemplate gSpriteTemplate_839B528; - -u8 FldEff_ExclamationMarkIcon1(void) -{ - u8 spriteId = CreateSpriteAtEnd(&gSpriteTemplate_839B510, 0, 0, 0x53); - - if (spriteId != 64) - sub_8084894(&gSprites[spriteId], 0, 0); - - return 0; -} - -u8 FldEff_ExclamationMarkIcon2(void) -{ - u8 spriteId = CreateSpriteAtEnd(&gSpriteTemplate_839B510, 0, 0, 0x52); - - if (spriteId != 64) - sub_8084894(&gSprites[spriteId], 33, 1); - - return 0; -} - -u8 FldEff_HeartIcon(void) -{ - u8 spriteId = CreateSpriteAtEnd(&gSpriteTemplate_839B528, 0, 0, 0x52); - - if (spriteId != 64) - sub_8084894(&gSprites[spriteId], 46, 0); - - return 0; -} - -void sub_8084894(struct Sprite *sprite, u16 a2, u8 a3) -{ - sprite->oam.priority = 1; - sprite->coordOffsetEnabled = 1; - - sprite->data0 = gUnknown_0202FF84[0]; - sprite->data1 = gUnknown_0202FF84[1]; - sprite->data2 = gUnknown_0202FF84[2]; - sprite->data3 = -5; - sprite->data7 = a2; - - StartSpriteAnim(sprite, a3); -} - -void objc_exclamation_mark_probably(struct Sprite *sprite) -{ - u8 mapObjId; - - if (TryGetFieldObjectIdByLocalIdAndMap(sprite->data0, sprite->data1, sprite->data2, &mapObjId) - || sprite->animEnded) - { - FieldEffectStop(sprite, (u8)sprite->data7); - } - else - { - struct Sprite *mapObjSprite = &gSprites[gMapObjects[mapObjId].spriteId]; - sprite->data4 += sprite->data3; - sprite->pos1.x = mapObjSprite->pos1.x; - sprite->pos1.y = mapObjSprite->pos1.y - 16; - sprite->pos2.x = mapObjSprite->pos2.x; - sprite->pos2.y = mapObjSprite->pos2.y + sprite->data4; - if (sprite->data4) - sprite->data3++; - else - sprite->data3 = 0; - } -}
\ No newline at end of file diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c new file mode 100644 index 000000000..45f319c62 --- /dev/null +++ b/src/fldeff_softboiled.c @@ -0,0 +1,168 @@ +#include "global.h" +#include "fldeff_softboiled.h" +#include "menu.h" +#include "party_menu.h" +#include "pokemon.h" +#include "pokemon_menu.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "strings.h" +#include "task.h" + +struct UnknownStruct1 { + u8 filler0[0x259]; + u8 unk259; + u8 filler25A[6]; + u8 unk260; + u8 unk261; + u8 unk262; + s16 unk264; + s16 unk266; + u8 filler268[10]; + u16 unk272; + u8 filler274[14]; + u16 unk282; +}; + +struct UnknownStruct2 { + u8 unk0; + u8 unk1; + u8 unk2; + u8 filler3[9]; + void *unkC; +}; + +struct UnknownStruct3 { + struct Pokemon *unk0; + u8 filler4[1]; + u8 unk5; + u16 unk6; + u8 filler8[4]; + s32 unkC; + void* unk10; + u8 filler14[26]; + s16 unk2E; +}; + +#if ENGLISH +#define WINDOW_LEFT 3 +#define WINDOW_RIGHT 26 +#elif GERMAN +#define WINDOW_LEFT 0 +#define WINDOW_RIGHT 29 +#endif + +#define EWRAM_1000 (*(struct UnknownStruct2 *)(unk_2000000 + 0x1000)) +#define EWRAM_1B000 (*(struct UnknownStruct1 *)(unk_2000000 + 0x1B000)) +#define EWRAM_1C000 (*(struct UnknownStruct3 *)(unk_2000000 + 0x1C000)) + +// extern +extern u8 gUnknown_0202E8F6; +extern u8 gLastFieldPokeMenuOpened; + +extern u8 unk_2000000[]; +extern u8 gUnknown_0202E8F4; + +// Static +static void sub_8133D50(u8 taskId); +static void sub_8133E74(u8 taskId); +static void sub_8133EB8(u8 taskId); +static void sub_8133EF8(void); + +bool8 SetUpFieldMove_SoftBoiled(void) { + u16 maxHp; + u16 hp; + u16 minHp; + + maxHp = GetMonData(&gPlayerParty[gLastFieldPokeMenuOpened], MON_DATA_MAX_HP); + hp = GetMonData(&gPlayerParty[gLastFieldPokeMenuOpened], MON_DATA_HP); + + minHp = (maxHp / 5); + if (hp >= minHp) + { + return TRUE; + } + + return FALSE; +} + +void sub_8133D28(u8 taskid) { + EWRAM_1000.unkC = sub_8133D50; + EWRAM_1B000.unk272 = 3; + sub_808A004(taskid); +} + +static void sub_8133D50(u8 taskId) { + u8 unk1, unk2; + u16 hp; + struct Pokemon *pokemon; + //struct Task *task; + + struct Sprite *sprites = gSprites; + + + unk1 = sprites[EWRAM_1000.unk1].data0; + unk2 = sprites[EWRAM_1000.unk2].data0; + + if (unk1 > 5 || unk2 > 5) + { + sub_806CD44(taskId); + return; + } + + EWRAM_1C000.unk0 = &gPlayerParty[sprites[EWRAM_1000.unk2].data0]; + hp = GetMonData(EWRAM_1C000.unk0, MON_DATA_HP); + + if (hp == 0 || unk1 == unk2 || GetMonData(EWRAM_1C000.unk0, MON_DATA_MAX_HP) == hp) + { + sub_8133EB8(taskId); + return; + } + + PlaySE(SE_KAIFUKU); + + EWRAM_1C000.unk5 = gSprites[EWRAM_1000.unk1].data0; + + pokemon = &gPlayerParty[EWRAM_1C000.unk5]; + EWRAM_1C000.unk0 = pokemon; + EWRAM_1C000.unk6 = 0; + EWRAM_1C000.unkC = -0x8000; + EWRAM_1C000.unk10 = sub_8133EF8; + + + gTasks[taskId].data[10] = GetMonData(EWRAM_1C000.unk0, MON_DATA_MAX_HP); + gTasks[taskId].data[11] = GetMonData(EWRAM_1C000.unk0, MON_DATA_HP); + gTasks[taskId].data[12] = gTasks[taskId].data[10] / 5; + + sub_806D5A4(); + gTasks[taskId].func = sub_806FA18; + EWRAM_1B000.unk282 = gTasks[taskId].data[11]; +} + +static void sub_8133E74(u8 taskId) { + if (gUnknown_0202E8F6) + { + return; + } + + MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + sub_806D538(3, 0); + gTasks[taskId].func = sub_806CB74; +} + +static void sub_8133EB8(u8 taskId) { + gUnknown_0202E8F4 = 0; + sub_806D5A4(); + sub_806E834(gOtherText_CantUseOnPoke, 1); + gTasks[taskId].func = sub_8133E74; +} + +static void sub_8133EF8(void) { + sub_806CCE4(); + EWRAM_1B000.unk261 = 2; + DestroySprite(&gSprites[EWRAM_1000.unk1]); + MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + sub_806D538(0, 0); + SwitchTaskToFollowupFunc(EWRAM_1000.unk0); +} diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c index 3cc33e3c1..1edae09d4 100644 --- a/src/fldeff_strength.c +++ b/src/fldeff_strength.c @@ -1,37 +1,41 @@ #include "global.h" +#include "braille_puzzles.h" #include "field_effect.h" -#include "asm.h" +#include "party_menu.h" #include "pokemon.h" +#include "pokemon_menu.h" +#include "rom6.h" #include "script.h" #include "task.h" +#include "text.h" static void sub_811AA18(void); static void sub_811AA38(void); static void sub_811AA9C(void); -extern u32 gUnknown_0202FF84; +extern u32 gUnknown_0202FF84[]; -extern u8 gUnknown_03005CE0; +extern u8 gLastFieldPokeMenuOpened; extern u16 gScriptResult; -extern void (*gUnknown_0300485C)(void); +extern void (*gFieldCallback)(void); extern void (*gUnknown_03005CE4)(void); extern u8 UseStrengthScript[]; bool8 SetUpFieldMove_Strength(void) { - if (sub_81474C8()) + if (ShouldDoBrailleStrengthEffect()) { - gScriptResult = gUnknown_03005CE0; - gUnknown_0300485C = sub_808AB90; + gScriptResult = gLastFieldPokeMenuOpened; + gFieldCallback = sub_808AB90; gUnknown_03005CE4 = sub_811AA38; } else { if (npc_before_player_of_type(87) != TRUE) return 0; - gScriptResult = gUnknown_03005CE0; - gUnknown_0300485C = sub_808AB90; + gScriptResult = gLastFieldPokeMenuOpened; + gFieldCallback = sub_808AB90; gUnknown_03005CE4 = sub_811AA18; } @@ -40,13 +44,13 @@ bool8 SetUpFieldMove_Strength(void) static void sub_811AA18(void) { - gUnknown_0202FF84 = gUnknown_03005CE0; + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; ScriptContext1_SetupScript(UseStrengthScript); } static void sub_811AA38(void) { - gUnknown_0202FF84 = gUnknown_03005CE0; + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; FieldEffectStart(40); } @@ -56,15 +60,15 @@ bool8 FldEff_UseStrength(void) gTasks[taskId].data[8] = (u32)sub_811AA9C >> 16; gTasks[taskId].data[9] = (u32)sub_811AA9C; - GetMonNickname(&gPlayerParty[gUnknown_0202FF84], gStringVar1); + GetMonNickname(&gPlayerParty[gUnknown_0202FF84[0]], gStringVar1); return FALSE; } static void sub_811AA9C(void) { - if (sub_81474C8()) + if (ShouldDoBrailleStrengthEffect()) { - sub_8147514(); + DoBrailleStrengthEffect(); } else { diff --git a/src/fldeff_sweetscent.c b/src/fldeff_sweetscent.c new file mode 100644 index 000000000..6e782f4ac --- /dev/null +++ b/src/fldeff_sweetscent.c @@ -0,0 +1,90 @@ +#include "global.h" +#include "field_effect.h" +#include "field_player_avatar.h" +#include "palette.h" +#include "pokemon_menu.h" +#include "rom6.h" +#include "script.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "wild_encounter.h" + +static void sub_812BFD4(void); +static void sub_812C01C(void); +static void sub_812C084(u8); +static void sub_812C118(u8); + +extern u32 gUnknown_0202FF84[]; + +extern u8 gLastFieldPokeMenuOpened; +extern void (*gFieldCallback)(void); +extern void (*gUnknown_03005CE4)(void); + +extern u8 SweetScentNothingHereScript[]; + +bool8 SetUpFieldMove_SweetScent(void) +{ + gFieldCallback = sub_808AB90; + gUnknown_03005CE4 = sub_812BFD4; + return TRUE; +} + +static void sub_812BFD4(void) +{ + FieldEffectStart(51); + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; +} + +bool8 FldEff_SweetScent() +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)sub_812C01C >> 16; + gTasks[taskId].data[9] = (u32)sub_812C01C; + return FALSE; +} + +static void sub_812C01C(void) +{ + u8 taskId; + + PlaySE(0xEC); + BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 0, 8, 0x1F); + taskId = CreateTask(sub_812C084, 0); + gTasks[taskId].data[0] = 0; + FieldEffectActiveListRemove(51); +} + +static void sub_812C084(u8 taskId) +{ + if (!gPaletteFade.active) + { + if (gTasks[taskId].data[0] == 64) + { + gTasks[taskId].data[0] = 0; + if (SweetScentWildEncounter() == TRUE) + { + DestroyTask(taskId); + } + else + { + gTasks[taskId].func = sub_812C118; + BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 8, 0, 0x1F); + } + } + else + { + gTasks[taskId].data[0]++; + } + } +} + +static void sub_812C118(u8 taskId) +{ + if (!gPaletteFade.active) + { + ScriptContext1_SetupScript(SweetScentNothingHereScript); + DestroyTask(taskId); + } +} diff --git a/src/fldeff_teleport.c b/src/fldeff_teleport.c new file mode 100644 index 000000000..df12d3072 --- /dev/null +++ b/src/fldeff_teleport.c @@ -0,0 +1,48 @@ +#include "global.h" +#include "fldeff_teleport.h" +#include "field_effect.h" +#include "field_player_avatar.h" +#include "pokemon_menu.h" +#include "rom4.h" +#include "rom6.h" +#include "task.h" + +extern u32 gUnknown_0202FF84[]; + +extern void (*gFieldCallback)(void); +extern u8 gLastFieldPokeMenuOpened; +extern void (*gUnknown_03005CE4)(void); + +bool8 SetUpFieldMove_Teleport(void) +{ + if (is_light_level_1_2_3_or_6(gMapHeader.mapType) == TRUE) + { + gFieldCallback = sub_808AB90; + gUnknown_03005CE4 = hm_teleport_run_dp02scr; + return TRUE; + } + + return FALSE; +} + +void hm_teleport_run_dp02scr(void) +{ + new_game(); + FieldEffectStart(63); + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; +} + +bool8 FldEff_UseTeleport(void) +{ + u8 taskId = oei_task_add(); + gTasks[taskId].data[8] = (u32)sub_814A404 >> 16; + gTasks[taskId].data[9] = (u32)sub_814A404; + SetPlayerAvatarTransitionFlags(1); + return 0; +} + +void sub_814A404(void) +{ + FieldEffectActiveListRemove(63); + sub_8087BA8(); +} diff --git a/src/heal_location.c b/src/heal_location.c index 13bb125b6..42bc18567 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -1,17 +1,42 @@ #include "global.h" #include "heal_location.h" +#include "map_constants.h" #define NUM_HEAL_LOCATIONS 22 -extern const struct HealLocation gHealLocations[]; +static const struct HealLocation sHealLocations[] = +{ + {MAP_GROUP_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F, MAP_ID_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F, 4, 2}, + {MAP_GROUP_LITTLEROOT_TOWN_MAYS_HOUSE_2F, MAP_ID_LITTLEROOT_TOWN_MAYS_HOUSE_2F, 4, 2}, + {MAP_GROUP_PETALBURG_CITY, MAP_ID_PETALBURG_CITY, 20, 17}, + {MAP_GROUP_SLATEPORT_CITY, MAP_ID_SLATEPORT_CITY, 19, 20}, + {MAP_GROUP_MAUVILLE_CITY, MAP_ID_MAUVILLE_CITY, 22, 6}, + {MAP_GROUP_RUSTBORO_CITY, MAP_ID_RUSTBORO_CITY, 16, 39}, + {MAP_GROUP_FORTREE_CITY, MAP_ID_FORTREE_CITY, 5, 7}, + {MAP_GROUP_LILYCOVE_CITY, MAP_ID_LILYCOVE_CITY, 24, 15}, + {MAP_GROUP_MOSSDEEP_CITY, MAP_ID_MOSSDEEP_CITY, 28, 17}, + {MAP_GROUP_SOOTOPOLIS_CITY, MAP_ID_SOOTOPOLIS_CITY, 43, 32}, + {MAP_GROUP_EVER_GRANDE_CITY, MAP_ID_EVER_GRANDE_CITY, 27, 49}, + {MAP_GROUP_LITTLEROOT_TOWN, MAP_ID_LITTLEROOT_TOWN, 5, 9}, + {MAP_GROUP_LITTLEROOT_TOWN, MAP_ID_LITTLEROOT_TOWN, 14, 9}, + {MAP_GROUP_OLDALE_TOWN, MAP_ID_OLDALE_TOWN, 6, 17}, + {MAP_GROUP_DEWFORD_TOWN, MAP_ID_DEWFORD_TOWN, 2, 11}, + {MAP_GROUP_LAVARIDGE_TOWN, MAP_ID_LAVARIDGE_TOWN, 9, 7}, + {MAP_GROUP_FALLARBOR_TOWN, MAP_ID_FALLARBOR_TOWN, 14, 8}, + {MAP_GROUP_VERDANTURF_TOWN, MAP_ID_VERDANTURF_TOWN, 16, 4}, + {MAP_GROUP_PACIFIDLOG_TOWN, MAP_ID_PACIFIDLOG_TOWN, 8, 16}, + {MAP_GROUP_EVER_GRANDE_CITY, MAP_ID_EVER_GRANDE_CITY, 18, 6}, + {MAP_GROUP_BATTLE_TOWER_OUTSIDE, MAP_ID_BATTLE_TOWER_OUTSIDE, 14, 9}, + {MAP_GROUP_SOUTHERN_ISLAND_EXTERIOR, MAP_ID_SOUTHERN_ISLAND_EXTERIOR, 15, 20}, +}; u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum) { u32 i; - + for (i = 0; i < NUM_HEAL_LOCATIONS; i++) { - if(gHealLocations[i].group == mapGroup && gHealLocations[i].map == mapNum) + if (sHealLocations[i].group == mapGroup && sHealLocations[i].map == mapNum) return i + 1; } return 0; @@ -20,11 +45,11 @@ u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum) const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum) { u32 index = GetHealLocationIndexByMap(mapGroup, mapNum); - + if (index == 0) return NULL; else - return &gHealLocations[index - 1]; + return &sHealLocations[index - 1]; } const struct HealLocation *GetHealLocation(u32 index) @@ -34,5 +59,5 @@ const struct HealLocation *GetHealLocation(u32 index) else if (index > NUM_HEAL_LOCATIONS) return NULL; else - return &gHealLocations[index - 1]; + return &sHealLocations[index - 1]; } diff --git a/src/hof_pc.c b/src/hof_pc.c new file mode 100644 index 000000000..4646d171c --- /dev/null +++ b/src/hof_pc.c @@ -0,0 +1,42 @@ +#include "global.h" +#include "hall_of_fame.h" +#include "main.h" +#include "palette.h" +#include "rom4.h" +#include "script.h" +#include "script_menu.h" +#include "task.h" + +extern void (*gFieldCallback)(void); +extern void (*gUnknown_0300485C)(void); + +static void ReshowPCMenuAfterHallOfFamePC(void); +static void Task_WaitForPaletteFade(u8); + +void AccessHallOfFamePC(void) +{ + SetMainCallback2(sub_81428CC); + ScriptContext2_Enable(); +} + +void ReturnFromHallOfFamePC(void) +{ + SetMainCallback2(c2_exit_to_overworld_2_switch); + gFieldCallback = ReshowPCMenuAfterHallOfFamePC; +} + +static void ReshowPCMenuAfterHallOfFamePC(void) +{ + ScriptContext2_Enable(); + sub_8053E90(); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + TryCreatePCMenu(); + sub_80B5838(); + CreateTask(Task_WaitForPaletteFade, 10); +} + +static void Task_WaitForPaletteFade(u8 taskId) +{ + if (!gPaletteFade.active) + DestroyTask(taskId); +} diff --git a/src/intro.c b/src/intro.c index dfc1d6a4c..462a2134d 100644 --- a/src/intro.c +++ b/src/intro.c @@ -1,86 +1,813 @@ #include "global.h" -#include "intro.h" -#include "asm.h" #include "gba/m4a_internal.h" -#include "m4a.h" -#include "libgncmultiboot.h" -#include "save.h" +#include "intro.h" +#include "data2.h" #include "decompress.h" -#include "title_screen.h" -#include "new_game.h" +#include "hall_of_fame.h" +#include "intro_credits_graphics.h" +#include "libgncmultiboot.h" #include "link.h" +#include "m4a.h" #include "main.h" +#include "new_game.h" #include "palette.h" #include "rng.h" +#include "save.h" #include "songs.h" #include "sound.h" #include "species.h" #include "task.h" +#include "title_screen.h" #include "trig.h" +#include "unknown_task.h" +extern struct SpriteTemplate gUnknown_02024E8C; extern u16 gUnknown_02039318; extern u16 gUnknown_0203931A; extern u16 gUnknown_02039358; extern u16 gUnknown_0203935A; - extern u32 gIntroFrameCounter; -extern struct GcmbStruct gUnknown_03005EE0; +extern struct GcmbStruct gMultibootProgramStruct; extern u16 gSaveFileStatus; extern u8 gReservedSpritePaletteCount; - -extern const u16 gUnknown_08406974[]; -extern const u8 gUnknown_08406B74[]; -extern const u8 gUnknown_08406F28[]; -extern const u8 gUnknown_0840725C[]; -extern const u8 gUnknown_0840754C[]; -extern const u8 gUnknown_08407764[]; -extern const u8 gUnknown_084098D4[]; -extern const u8 gUnknown_08409AD4[]; -extern const u8 gUnknown_08409C04[]; -extern const u16 gUnknown_0840A758[]; -extern const u8 gUnknown_0840A778[]; -extern const u8 gUnknown_0840A7E4[]; -extern union AnimCmd *gUnknown_0840AE80[]; -extern const struct SpriteTemplate gSpriteTemplate_840AFF0; -extern const struct SpriteSheet gUnknown_0840B008; -extern const struct SpriteSheet gUnknown_0840B018; -extern const struct SpritePalette gUnknown_0840B028[]; -extern const struct SpriteTemplate gSpriteTemplate_840B1F4; -extern const struct SpriteSheet gUnknown_0840B20C; -extern const struct SpriteSheet gUnknown_0840B21C; -extern const struct SpritePalette gUnknown_0840B22C; -extern const struct SpritePalette gUnknown_0840B23C[]; -extern const struct SpriteSheet gIntro2BrendanSpriteSheet; -extern const struct SpriteSheet gIntro2MaySpriteSheet; -extern const struct SpriteSheet gIntro2BicycleSpriteSheet; -extern const struct SpriteSheet gIntro2LatiosSpriteSheet; -extern const struct SpriteSheet gIntro2LatiasSpriteSheet; -extern const struct SpritePalette gIntro2SpritePalettes[]; - +extern const u8 gInterfaceGfx_PokeBall[]; +extern const u8 gInterfacePal_PokeBall[]; extern const u8 gIntroCopyright_Gfx[]; extern const u16 gIntroCopyright_Pal[]; extern const u16 gIntroCopyright_Tilemap[]; +extern void *const gUnknown_0840B5A0[]; + +//-------------------------------------------------- +// Graphics Data +//-------------------------------------------------- + +static const u16 Palette_406340[] = INCBIN_U16("graphics/intro/unknown1.gbapal"); +static const u16 Palette_406360[] = INCBIN_U16("graphics/intro/unknown2.gbapal"); +#if ENGLISH +static const u8 gIntroTiles[] = INCBIN_U8("graphics/intro/intro.4bpp.lz"); +#elif GERMAN +extern const u8 gIntroTiles[]; +#endif +static const u16 gIntro1BGPals[][16] = +{ + INCBIN_U16("graphics/intro/intro1_bgpal1.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal2.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal3.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal4.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal5.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal6.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal7.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal8.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal9.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal10.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal11.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal12.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal13.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal14.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal15.gbapal"), + INCBIN_U16("graphics/intro/intro1_bgpal16.gbapal"), +}; +static const u8 gIntro1BG0_Tilemap[] = INCBIN_U8("graphics/intro/intro1_bg0_map.bin.lz"); +static const u8 gIntro1BG1_Tilemap[] = INCBIN_U8("graphics/intro/intro1_bg1_map.bin.lz"); +static const u8 gIntro1BG2_Tilemap[] = INCBIN_U8("graphics/intro/intro1_bg2_map.bin.lz"); +static const u8 gIntro1BG3_Tilemap[] = INCBIN_U8("graphics/intro/intro1_bg3_map.bin.lz"); +static const u8 gIntro1BGLeavesGfx[] = INCBIN_U8("graphics/intro/introgfx.4bpp.lz"); +static const u16 gIntro3PokeballPal[] = INCBIN_U16("graphics/intro/intro3_pokeball.gbapal"); +static const u8 gIntro3Pokeball_Tilemap[] = INCBIN_U8("graphics/intro/intro3_pokeball_map.bin.lz"); +static const u8 gIntro3Pokeball_Gfx[] = INCBIN_U8("graphics/intro/intro3_pokeball.8bpp.lz"); +static const u16 gIntro3Streaks_Pal[] = INCBIN_U16("graphics/intro/intro3_streaks.gbapal"); +static const u8 gIntro3Streaks_Gfx[] = INCBIN_U8("graphics/intro/intro3_streaks.4bpp.lz"); +static const u8 gIntro3Streaks_Tilemap[] = INCBIN_U8("graphics/intro/intro3_streaks_map.bin.lz"); +static const u16 gIntro3Misc1Palette[] = INCBIN_U16("graphics/intro/intro3_misc1.gbapal"); +static const u16 gIntro3Misc2Palette[] = INCBIN_U16("graphics/intro/intro3_misc2.gbapal"); +static const u8 gIntro3MiscTiles[] = INCBIN_U8("graphics/intro/intro3_misc.4bpp.lz"); +static const u16 gIntro1EonPalette[] = INCBIN_U16("graphics/intro/intro1_eon.gbapal"); +static const u8 gIntro1EonTiles[] = INCBIN_U8("graphics/intro/intro1_eon.4bpp.lz"); +static const struct OamData gOamData_840ADE8 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 2, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_840ADF0[] = +{ + ANIMCMD_FRAME(16, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840ADF8[] = +{ + ANIMCMD_FRAME(24, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AE00[] = +{ + ANIMCMD_FRAME(0, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AE08[] = +{ + ANIMCMD_FRAME(48, 8), + ANIMCMD_END, +}; +static const union AnimCmd *const gSpriteAnimTable_840AE10[] = +{ + gSpriteAnim_840ADF0, + gSpriteAnim_840ADF8, + gSpriteAnim_840AE00, + gSpriteAnim_840AE08, +}; +static void sub_813D208(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840AE20 = +{ + .tileTag = 2000, + .paletteTag = 2000, + .oam = &gOamData_840ADE8, + .anims = gSpriteAnimTable_840AE10, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813D208, +}; +static const union AnimCmd Unknown_40AE38[] = +{ + ANIMCMD_FRAME(0, 4), + ANIMCMD_FRAME(64, 4), + ANIMCMD_FRAME(128, 4), + ANIMCMD_FRAME(192, 4), + ANIMCMD_JUMP(0), +}; +static const union AnimCmd Unknown_40AE4C[] = +{ + ANIMCMD_FRAME(0, 8), + ANIMCMD_FRAME(64, 8), + ANIMCMD_FRAME(128, 8), + ANIMCMD_FRAME(192, 8), + ANIMCMD_JUMP(0), +}; +static const union AnimCmd Unknown_40AE60[] = +{ + ANIMCMD_FRAME(256, 4), + ANIMCMD_FRAME(0x140, 4), + ANIMCMD_FRAME(0x180, 4), + ANIMCMD_END, +}; +static const union AnimCmd Unknown_40AE70[] = +{ + ANIMCMD_FRAME(0x180, 16), + ANIMCMD_FRAME(0x140, 16), + ANIMCMD_FRAME(256, 16), + ANIMCMD_END, +}; +static const union AnimCmd *const gUnknown_0840AE80[] = +{ + Unknown_40AE38, + Unknown_40AE4C, + Unknown_40AE60, + Unknown_40AE70, +}; +static const struct OamData gOamData_840AE90 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const struct OamData gOamData_840AE98 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const struct OamData gOamData_840AEA0 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 2, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_840AEA8[] = +{ + ANIMCMD_FRAME(80, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AEB0[] = +{ + ANIMCMD_FRAME(84, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AEB8[] = +{ + ANIMCMD_FRAME(88, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AEC0[] = +{ + ANIMCMD_FRAME(92, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AEC8[] = +{ + ANIMCMD_FRAME(96, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AED0[] = +{ + ANIMCMD_FRAME(100, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AED8[] = +{ + ANIMCMD_FRAME(104, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AEE0[] = +{ + ANIMCMD_FRAME(112, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AEE8[] = +{ + ANIMCMD_FRAME(113, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AEF0[] = +{ + ANIMCMD_FRAME(114, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AEF8[] = +{ + ANIMCMD_FRAME(115, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AF00[] = +{ + ANIMCMD_FRAME(116, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AF08[] = +{ + ANIMCMD_FRAME(117, 8), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_840AF10[] = +{ + ANIMCMD_FRAME(128, 8), + ANIMCMD_END, +}; +#if GERMAN +static const union AnimCmd gSpriteAnim_8416DA4[] = +{ + ANIMCMD_FRAME(118, 8), + ANIMCMD_END, +}; +#endif +static const union AnimCmd *const gSpriteAnimTable_840AF18[] = +{ + gSpriteAnim_840AEA8, + gSpriteAnim_840AEB0, + gSpriteAnim_840AEB8, + gSpriteAnim_840AEC0, + gSpriteAnim_840AEC8, + gSpriteAnim_840AED0, + gSpriteAnim_840AED8, +}; +static const union AnimCmd *const gSpriteAnimTable_840AF34[] = +{ + gSpriteAnim_840AEE0, + gSpriteAnim_840AEE8, + gSpriteAnim_840AEF0, + gSpriteAnim_840AEF8, + gSpriteAnim_840AF00, + gSpriteAnim_840AF08, +#if GERMAN + gSpriteAnim_8416DA4, +#endif +}; +static const union AnimCmd *const gSpriteAnimTable_840AF4C[] = +{ + gSpriteAnim_840AF10, +}; +static const s16 gUnknown_0840AF50[][2] = +{ + {0, -72}, + {1, -56}, + {2, -40}, + {3, -24}, + {4, 8}, + {5, 24}, + {3, 40}, + {1, 56}, + {6, 72}, +}; +static const s16 gUnknown_0840AF74[][2] = +{ + {0, -28}, + {1, -20}, + {2, -12}, + {3, -4}, + {2, 4}, + {4, 12}, + {5, 20}, + {3, 28}, +}; +static void sub_813D908(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840AF94 = +{ + .tileTag = 2000, + .paletteTag = 2001, + .oam = &gOamData_840AE90, + .anims = gSpriteAnimTable_840AF18, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813D908, +}; +static const struct SpriteTemplate gSpriteTemplate_840AFAC = +{ + .tileTag = 2000, + .paletteTag = 2001, + .oam = &gOamData_840AE98, + .anims = gSpriteAnimTable_840AF34, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813D908, +}; +static const struct SpriteTemplate gSpriteTemplate_840AFC4 = +{ + .tileTag = 2000, + .paletteTag = 2001, + .oam = &gOamData_840AEA0, + .anims = gSpriteAnimTable_840AF4C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813D908, +}; +static const struct OamData gOamData_840AFDC = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_840AFE4[] = +{ + ANIMCMD_FRAME(0, 10), + ANIMCMD_JUMP(0), +}; +static const union AnimCmd *const gSpriteAnimTable_840AFEC[] = +{ + gSpriteAnim_840AFE4, +}; +static void sub_813DA64(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840AFF0 = +{ + .tileTag = 2002, + .paletteTag = 2002, + .oam = &gOamData_840AFDC, + .anims = gSpriteAnimTable_840AFEC, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813DA64, +}; +const struct CompressedSpriteSheet gUnknown_0840B008[] = +{ + {gIntroTiles, 0x1400, 2000}, + {NULL}, +}; +const struct CompressedSpriteSheet gUnknown_0840B018[] = +{ + {gIntro1EonTiles, 0x400, 2002}, + {NULL}, +}; +const struct SpritePalette gUnknown_0840B028[] = +{ + {Palette_406340, 2000}, + {Palette_406360, 2001}, + {gIntro1EonPalette, 2002}, + {NULL}, +}; +static const union AnimCmd gUnknown_0840B048[] = +{ + ANIMCMD_FRAME(3, 0), + ANIMCMD_END, +}; +static const union AnimCmd gUnknown_0840B050[] = +{ + ANIMCMD_FRAME(0, 8), + ANIMCMD_END, +}; +static const union AnimCmd gUnknown_0840B058[] = +{ + ANIMCMD_FRAME(1, 8), + ANIMCMD_FRAME(2, 8), + ANIMCMD_END, +}; +static const union AnimCmd *const gUnknown_0840B064[] = +{ + gUnknown_0840B048, + gUnknown_0840B050, + gUnknown_0840B058, +}; +static const struct OamData gOamData_840B070 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_840B078[] = +{ + ANIMCMD_FRAME(0, 8), + ANIMCMD_END, +}; +static const union AnimCmd *const gSpriteAnimTable_840B080[] = +{ + gSpriteAnim_840B078, +}; +static void sub_813E30C(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840B084 = +{ + .tileTag = 2002, + .paletteTag = 2002, + .oam = &gOamData_840B070, + .anims = gSpriteAnimTable_840B080, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813E30C, +}; +static const struct OamData gOamData_840B09C = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_840B0A4[] = +{ + ANIMCMD_FRAME(1, 8), + ANIMCMD_END, +}; +static const union AnimCmd *const gSpriteAnimTable_840B0AC[] = +{ + gSpriteAnim_840B0A4, +}; +static void sub_813E4B8(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840B0B0 = +{ + .tileTag = 2003, + .paletteTag = 2003, + .oam = &gOamData_840B09C, + .anims = gSpriteAnimTable_840B0AC, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813E4B8, +}; +static const struct OamData gOamData_840B0C8 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_840B0D0[] = +{ + ANIMCMD_FRAME(14, 8), + ANIMCMD_END, +}; +static const union AnimCmd *const gSpriteAnimTable_840B0D8[] = +{ + gSpriteAnim_840B0D0, +}; +static void sub_813E5E0(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840B0DC = +{ + .tileTag = 2003, + .paletteTag = 2004, + .oam = &gOamData_840B0C8, + .anims = gSpriteAnimTable_840B0D8, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813E5E0, +}; +static void sub_813E6C0(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840B0F4 = +{ + .tileTag = 2003, + .paletteTag = 2004, + .oam = &gOamData_840B0C8, + .anims = gSpriteAnimTable_840B0D8, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813E6C0, +}; +static const struct OamData gOamData_840B10C = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_840B114[] = +{ + ANIMCMD_FRAME(6, 8), + ANIMCMD_FRAME(6, 8, .hFlip = TRUE), + ANIMCMD_JUMP(0), +}; +static const union AnimCmd *const gSpriteAnimTable_840B120[] = +{ + gSpriteAnim_840B114, +}; +static void sub_813E804(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840B124 = +{ + .tileTag = 2003, + .paletteTag = 2004, + .oam = &gOamData_840B10C, + .anims = gSpriteAnimTable_840B120, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813E804, +}; +static const struct OamData gOamData_840B13C = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_840B144[] = +{ + ANIMCMD_FRAME(10, 8), + ANIMCMD_END, +}; +static const union AnimCmd *const gSpriteAnimTable_840B14C[] = +{ + gSpriteAnim_840B144, +}; +static void sub_813E980(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840B150 = +{ + .tileTag = 2003, + .paletteTag = 2004, + .oam = &gOamData_840B13C, + .anims = gSpriteAnimTable_840B14C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813E980, +}; +static const u8 gUnknown_0840B168[] = {0xE6, 0xEB, 0xE4, 0xEA, 0xE5, 0xE9, 0xE7, 0xE8}; +static void sub_813EA60(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840B170 = +{ + .tileTag = 2003, + .paletteTag = 2004, + .oam = &gOamData_840B13C, + .anims = gSpriteAnimTable_840B14C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813EA60, +}; +static const u16 gUnknown_0840B188[] = {0x200, 0x1C0, 0x180, 0x140, 0x100, 0xE0, 0xC0, 0xA0, 0x80, 0x80}; +static const struct OamData gOamData_840B19C = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_840B1A4[] = +{ + ANIMCMD_FRAME(2, 8), + ANIMCMD_END, +}; +static const union AnimCmd *const gSpriteAnimTable_840B1AC[] = +{ + gSpriteAnim_840B1A4, +}; +static void sub_813EBBC(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840B1B0 = +{ + .tileTag = 2003, + .paletteTag = 2004, + .oam = &gOamData_840B19C, + .anims = gSpriteAnimTable_840B1AC, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813EBBC, +}; +static void sub_813EC90(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840B1C8 = +{ + .tileTag = 2003, + .paletteTag = 2004, + .oam = &gOamData_840B19C, + .anims = gSpriteAnimTable_840B1AC, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813EC90, +}; +static const struct OamData gOamData_840B1E0 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_840B1E8[] = +{ + ANIMCMD_FRAME(16, 8), + ANIMCMD_END, +}; +static const union AnimCmd *const gSpriteAnimTable_840B1F0[] = +{ + gSpriteAnim_840B1E8, +}; +static void sub_813EDFC(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_840B1F4 = +{ + .tileTag = 2003, + .paletteTag = 2003, + .oam = &gOamData_840B1E0, + .anims = gSpriteAnimTable_840B1F0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_813EDFC, +}; +const struct CompressedSpriteSheet gIntro3PokeballGfx_Table[] = +{ + {gInterfaceGfx_PokeBall, 0x100, 2002}, + {NULL}, +}; +const struct CompressedSpriteSheet gIntro3MiscGfx_Table[] = +{ + {gIntro3MiscTiles, 0xa00, 2003}, + {NULL}, +}; +const struct CompressedSpritePalette gInterfacePokeballPal_Table[] = +{ + {gInterfacePal_PokeBall, 2002}, + {NULL}, +}; +const struct SpritePalette gIntro3MiscPal_Table[] = +{ + {gIntro3Misc1Palette, 2003}, + {gIntro3Misc2Palette, 2004}, + {NULL}, +}; +const u32 unusedData = 0x02000000; static void MainCB2_EndIntro(void); static void Task_IntroLoadPart1Graphics(u8); static void Task_IntroFadeIn(u8); static void Task_IntroWaterDrops(u8); -static void task_intro_4(u8); -static void task_intro_5(u8); +static void Task_IntroScrollDownAndShowEon(u8); +static void Task_IntroWaitToSetupPart2(u8); static void Task_IntroLoadPart2Graphics(u8); static void Task_IntroStartBikeRide(u8); -static void task_intro_8(u8); -static void task_intro_9(u8); -static void task_intro_10(u8); -static void task_intro_11(u8); -static void task_intro_12(u8); -static void task_intro_13(u8); +static void Task_IntroHandleBikeAndEonMovement(u8); +static void Task_IntroWaitToSetupPart3(u8); +static void Task_IntroLoadPart3Graphics(u8); +static void Task_IntroSpinAndZoomPokeball(u8); +static void Task_IntroWaitToSetupPart3DoubleFight(u8); +static void Task_IntroLoadPart3Streaks(u8); static void task_intro_14(u8); static void task_intro_15(u8); static void task_intro_16(u8); static void task_intro_17(u8); static void Task_IntroPokemonBattle(u8); static void task_intro_19(u8); +static void task_intro_20(u8); +static void intro_reset_and_hide_bgs(void); +static void sub_813CCE8(u8); +static u16 sub_813CE88(u16, s16, s16, u16, u8); +static u8 sub_813CFA8(u16, u16, u16, u16); +static void sub_813D084(u8); +static void sub_813D220(struct Sprite *); +static void sub_813D368(struct Sprite *); +static void sub_813D414(struct Sprite *); +static void SpriteCB_WaterDropFall(struct Sprite *); +static u8 CreateWaterDrop(s16, s16, u16, u16, u16, u8); +static void sub_813D788(struct Sprite *); +static void sub_813D880(struct Sprite *); +static u8 CreateGameFreakLogo(s16, s16, u8); +static void sub_813DB9C(struct Sprite *); +static void sub_813DE70(struct Sprite *); +static void sub_813E10C(struct Sprite *); +static void sub_813E210(struct Sprite *); +static void sub_813E580(u16, u16); +static void sub_813E7C0(u8); +static void sub_813E930(u8); +static void InitIntroTorchicAttackAnim(u8); +static void InitIntroMudkipAttackAnim(u8); static void VBlankCB_Intro(void) { @@ -107,16 +834,16 @@ static void MainCB2_EndIntro(void) SetMainCallback2(CB2_InitTitleScreen); } -static void LoadCopyrightGraphics(u16 a1, u16 a2, u16 a3) +static void LoadCopyrightGraphics(u16 tilesetAddress, u16 tilemapAddress, u16 paletteAddress) { - LZ77UnCompVram(gIntroCopyright_Gfx, (void *)(VRAM + a1)); - LoadPalette(gIntroCopyright_Pal, a3, 0x20); - CpuCopy16(gIntroCopyright_Tilemap, (void *)(VRAM + a2), 0x500); + LZ77UnCompVram(gIntroCopyright_Gfx, (void *)(VRAM + tilesetAddress)); + LoadPalette(gIntroCopyright_Pal, paletteAddress, 0x20); + CpuCopy16(gIntroCopyright_Tilemap, (void *)(VRAM + tilemapAddress), 0x500); } -static void SerialCb_CopyrightScreen(void) +static void SerialCB_CopyrightScreen(void) { - GameCubeMultiBoot_HandleSerialInterrupt(&gUnknown_03005EE0); + GameCubeMultiBoot_HandleSerialInterrupt(&gMultibootProgramStruct); } static u8 SetUpCopyrightScreen(void) @@ -138,13 +865,17 @@ static u8 SetUpCopyrightScreen(void) DmaFill32(3, 0, (void *)OAM, OAM_SIZE); DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2); ResetPaletteFade(); - LoadCopyrightGraphics(0, 14336, 0); + LoadCopyrightGraphics(0, 0x3800, 0); remove_some_task(); ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0xFFFF); - REG_BG0CNT = 1792; + REG_BG0CNT = BGCNT_PRIORITY(0) + | BGCNT_CHARBASE(0) + | BGCNT_SCREENBASE(7) + | BGCNT_16COLOR + | BGCNT_TXT256x256; ime = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; @@ -152,18 +883,18 @@ static u8 SetUpCopyrightScreen(void) REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; SetVBlankCallback(VBlankCB_Intro); REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON; - SetSerialCallback(SerialCb_CopyrightScreen); - GameCubeMultiBoot_Init(&gUnknown_03005EE0); + SetSerialCallback(SerialCB_CopyrightScreen); + GameCubeMultiBoot_Init(&gMultibootProgramStruct); default: UpdatePaletteFade(); gMain.state++; - GameCubeMultiBoot_Main(&gUnknown_03005EE0); + GameCubeMultiBoot_Main(&gMultibootProgramStruct); break; case 140: - GameCubeMultiBoot_Main(&gUnknown_03005EE0); - if (gUnknown_03005EE0.gcmb_field_2 != 1) + GameCubeMultiBoot_Main(&gMultibootProgramStruct); + if (gMultibootProgramStruct.gcmb_field_2 != 1) { - BeginNormalPaletteFade(0xFFFFFFFFu, 0, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); gMain.state++; } break; @@ -172,9 +903,9 @@ static u8 SetUpCopyrightScreen(void) break; CreateTask(Task_IntroLoadPart1Graphics, 0); SetMainCallback2(MainCB2_Intro); - if (gUnknown_03005EE0.gcmb_field_2) + if (gMultibootProgramStruct.gcmb_field_2) { - GameCubeMultiBoot_ExecuteProgram(&gUnknown_03005EE0); + GameCubeMultiBoot_ExecuteProgram(&gMultibootProgramStruct); } else { @@ -187,12 +918,12 @@ static u8 SetUpCopyrightScreen(void) return 1; } -void c2_copyright_1(void) +void CB2_InitCopyrightScreenAfterBootup(void) { if (!SetUpCopyrightScreen()) { sub_8052E4C(); - sub_81251B8(); + ResetSaveCounters(); sub_8125EC8(0); if (gSaveFileStatus == 0 || gSaveFileStatus == 2) ClearSav2(); @@ -200,7 +931,7 @@ void c2_copyright_1(void) } } -void CB2_InitCopyrightScreen(void) +void CB2_InitCopyrightScreenAfterTitleScreen(void) { SetUpCopyrightScreen(); } @@ -214,22 +945,22 @@ static void Task_IntroLoadPart1Graphics(u8 taskId) REG_BG2VOFS = 0x50; REG_BG1VOFS = 0x18; REG_BG0VOFS = 0x28; - LZ77UnCompVram(gUnknown_08407764, (void *)VRAM); - LZ77UnCompVram(gUnknown_08406B74, (void *)(VRAM + 0x8000)); + LZ77UnCompVram(gIntro1BGLeavesGfx, (void *)VRAM); + LZ77UnCompVram(gIntro1BG0_Tilemap, (void *)(VRAM + 0x8000)); DmaClear16(3, VRAM + 0x8800, 0x800); - LZ77UnCompVram(gUnknown_08406F28, (void *)(VRAM + 0x9000)); + LZ77UnCompVram(gIntro1BG1_Tilemap, (void *)(VRAM + 0x9000)); DmaClear16(3, VRAM + 0x9800, 0x800); - LZ77UnCompVram(gUnknown_0840725C, (void *)(VRAM + 0xA000)); + LZ77UnCompVram(gIntro1BG2_Tilemap, (void *)(VRAM + 0xA000)); DmaClear16(3, VRAM + 0xA800, 0x800); - LZ77UnCompVram(gUnknown_0840754C, (void *)(VRAM + 0xB000)); + LZ77UnCompVram(gIntro1BG3_Tilemap, (void *)(VRAM + 0xB000)); DmaClear16(3, VRAM + 0xB800, 0x800); - LoadPalette(gUnknown_08406974, 0, 0x200); - REG_BG3CNT = 0x9603; - REG_BG2CNT = 0x9402; - REG_BG1CNT = 0x9201; - REG_BG0CNT = 0x9000; - LoadCompressedObjectPic(&gUnknown_0840B008); - LoadCompressedObjectPic(&gUnknown_0840B018); + LoadPalette(gIntro1BGPals, 0, sizeof(gIntro1BGPals)); + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(22) | BGCNT_16COLOR | BGCNT_TXT256x512; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(20) | BGCNT_16COLOR | BGCNT_TXT256x512; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(18) | BGCNT_16COLOR | BGCNT_TXT256x512; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(16) | BGCNT_16COLOR | BGCNT_TXT256x512; + LoadCompressedObjectPic(&gUnknown_0840B008[0]); + LoadCompressedObjectPic(&gUnknown_0840B018[0]); LoadSpritePalettes(gUnknown_0840B028); CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1F0, 0x20); CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1E1, 0x1E); @@ -238,13 +969,13 @@ static void Task_IntroLoadPart1Graphics(u8 taskId) CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1B4, 0x18); CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1A5, 0x16); CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x196, 0x14); - gTasks[taskId].data[0] = sub_813D584(0xEC, -14, 0x200, 1, 0x78, 0); + gTasks[taskId].data[0] = CreateWaterDrop(236, -14, 0x200, 1, 0x78, FALSE); gTasks[taskId].func = Task_IntroFadeIn; } static void Task_IntroFadeIn(u8 taskId) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); SetVBlankCallback(VBlankCB_Intro); REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON; gTasks[taskId].func = Task_IntroWaterDrops; @@ -258,21 +989,19 @@ static void Task_IntroWaterDrops(u8 taskId) //start moving rock if (gIntroFrameCounter == 76) gSprites[gTasks[taskId].data[0]].data0 = 1; - + //drop rock if (gIntroFrameCounter == 251) gSprites[gTasks[taskId].data[0]].data0 = 2; - - //drop two more rocks + if (gIntroFrameCounter == 368) - sub_813D584(0x30, 0, 0x400, 5, 0x70, 1); + CreateWaterDrop(48, 0, 0x400, 5, 0x70, TRUE); if (gIntroFrameCounter == 384) - sub_813D584(0xC8, 0x3C, 0x400, 9, 0x80, 1); - - //show GameFreak logo + CreateWaterDrop(200, 60, 0x400, 9, 0x80, TRUE); + if (gIntroFrameCounter == 560) - sub_813D954(0x78, 0x50, CreateTask(sub_813CCE8, 0)); - + CreateGameFreakLogo(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, CreateTask(sub_813CCE8, 0)); + if (gIntroFrameCounter > 739) { gTasks[taskId].data[1] = 0x50; @@ -281,16 +1010,16 @@ static void Task_IntroWaterDrops(u8 taskId) gTasks[taskId].data[4] = 0; gTasks[taskId].data[5] = 0x28; gTasks[taskId].data[6] = 0; - gTasks[taskId].func = task_intro_4; + gTasks[taskId].func = Task_IntroScrollDownAndShowEon; } } -static void task_intro_4(u8 taskId) +static void Task_IntroScrollDownAndShowEon(u8 taskId) { if (gIntroFrameCounter < 904) { s32 r2; - + //slide backgrounds downward r2 = (gTasks[taskId].data[1] << 16) + (u16)gTasks[taskId].data[2] - 0xC000; gTasks[taskId].data[1] = r2 >> 16; @@ -304,12 +1033,12 @@ static void task_intro_4(u8 taskId) gTasks[taskId].data[5] = r2 >> 16; gTasks[taskId].data[6] = r2; REG_BG0VOFS = gTasks[taskId].data[5]; - + //show Lati@s sprite if (gIntroFrameCounter == 880) { - u8 spriteId = CreateSprite(&gSpriteTemplate_840AFF0, 0xC8, 0xA0, 10); - + u8 spriteId = CreateSprite(&gSpriteTemplate_840AFF0, 200, 160, 10); + gSprites[spriteId].invisible = 1; } } @@ -318,13 +1047,13 @@ static void task_intro_4(u8 taskId) //fade to white if (gIntroFrameCounter > 1007) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0xFFFF); - gTasks[taskId].func = task_intro_5; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0xFFFF); + gTasks[taskId].func = Task_IntroWaitToSetupPart2; } } } -static void task_intro_5(u8 taskId) +static void Task_IntroWaitToSetupPart2(u8 taskId) { if (gIntroFrameCounter > 1026) gTasks[taskId].func = Task_IntroLoadPart2Graphics; @@ -349,7 +1078,7 @@ static void Task_IntroLoadPart2Graphics(u8 taskId) static void Task_IntroStartBikeRide(u8 taskId) { u8 spriteId; - + if (gUnknown_02039318 == 0) LoadCompressedObjectPic(&gIntro2BrendanSpriteSheet); else @@ -375,7 +1104,7 @@ static void Task_IntroStartBikeRide(u8 taskId) #endif gSprites[spriteId].callback = sub_813D880; gTasks[taskId].data[2] = spriteId; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0xFFFF); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0xFFFF); SetVBlankCallback(VBlankCB_Intro); #ifdef SAPPHIRE gTasks[taskId].data[0] = sub_8148EC0(0, 0x4000, 0x40, 0x10); @@ -384,18 +1113,18 @@ static void Task_IntroStartBikeRide(u8 taskId) gTasks[taskId].data[0] = sub_8148EC0(1, 0x4000, 0x400, 0x10); sub_8148C78(1); #endif - gTasks[taskId].func = task_intro_8; + gTasks[taskId].func = Task_IntroHandleBikeAndEonMovement; } -static void task_intro_8(u8 taskId) +static void Task_IntroHandleBikeAndEonMovement(u8 taskId) { s16 a; u16 sine; - + if (gIntroFrameCounter > 1823) { - BeginNormalPaletteFade(0xFFFFFFFF, 0x10, 0, 0x10, 0xFFFF); - gTasks[taskId].func = task_intro_9; + BeginNormalPaletteFade(0xFFFFFFFF, 16, 0, 16, 0xFFFF); + gTasks[taskId].func = Task_IntroWaitToSetupPart3; } if (gIntroFrameCounter == 1109) gSprites[gTasks[taskId].data[1]].data0 = 1; @@ -409,12 +1138,12 @@ static void task_intro_8(u8 taskId) gSprites[gTasks[taskId].data[1]].data0 = 3; if (gIntroFrameCounter == 1727) gSprites[gTasks[taskId].data[1]].data0 = 4; - + //TODO: Clean this up a = (((u16)gTasks[taskId].data[3] << 16) >> 18) & 0x7F; - sine = Sin(a, 0x30); + sine = Sin(a, 48); gUnknown_0203935A = sine; - if (gTasks[taskId].data[3] < 0x200) + if (gTasks[taskId].data[3] < 512) gTasks[taskId].data[3]++; #ifdef SAPPHIRE sub_8149020(0); @@ -423,21 +1152,21 @@ static void task_intro_8(u8 taskId) #endif } -static void task_intro_9(u8 taskId) +static void Task_IntroWaitToSetupPart3(u8 taskId) { if (gIntroFrameCounter > 2068) { DestroyTask(gTasks[taskId].data[0]); - gTasks[taskId].func = task_intro_10; + gTasks[taskId].func = Task_IntroLoadPart3Graphics; } } -static void task_intro_10(u8 taskId) +static void Task_IntroLoadPart3Graphics(u8 taskId) { intro_reset_and_hide_bgs(); - LZ77UnCompVram(gUnknown_08409C04, (void *)VRAM); - LZ77UnCompVram(gUnknown_08409AD4, (void *)(VRAM + 0x4000)); - LoadPalette(gUnknown_084098D4, 0, 0x200); + LZ77UnCompVram(gIntro3Pokeball_Gfx, (void *)VRAM); + LZ77UnCompVram(gIntro3Pokeball_Tilemap, (void *)(VRAM + 0x4000)); + LoadPalette(gIntro3PokeballPal, 0, 0x200); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0; gTasks[taskId].data[2] = 0; @@ -446,14 +1175,14 @@ static void task_intro_10(u8 taskId) ResetSpriteData(); FreeAllSpritePalettes(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0xFFFF); - REG_BG2CNT = 0x4883; + REG_BG2CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(8) | BGCNT_256COLOR | BGCNT_AFF256x256; REG_DISPCNT = DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; - gTasks[taskId].func = task_intro_11; + gTasks[taskId].func = Task_IntroSpinAndZoomPokeball; gIntroFrameCounter = 0; m4aSongNumStart(0x1BA); } -static void task_intro_11(u8 taskId) +static void Task_IntroSpinAndZoomPokeball(u8 taskId) { gTasks[taskId].data[0] += 0x400; if (gTasks[taskId].data[1] <= 0x6BF) @@ -463,26 +1192,26 @@ static void task_intro_11(u8 taskId) } else { - gTasks[taskId].func = task_intro_12; + gTasks[taskId].func = Task_IntroWaitToSetupPart3DoubleFight; } sub_813CE30(0x78, 0x50, 0x10000 / gTasks[taskId].data[1], gTasks[taskId].data[0]); if (gIntroFrameCounter == 44) BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0xFFFF); } -static void task_intro_12(u8 taskId) +static void Task_IntroWaitToSetupPart3DoubleFight(u8 taskId) { if (gIntroFrameCounter > 59) - gTasks[taskId].func = task_intro_13; + gTasks[taskId].func = Task_IntroLoadPart3Streaks; } extern u8 unk_2000000[][32]; -static void task_intro_13(u8 taskId) +static void Task_IntroLoadPart3Streaks(u8 taskId) { u16 i; void *vram; - + intro_reset_and_hide_bgs(); for (i = 0; i < 32; i++) { @@ -505,16 +1234,16 @@ static void task_intro_13(u8 taskId) sub_813D084(1); gPlttBufferUnfaded[0xF2] = RGB_BLACK; gPlttBufferFaded[0xF2] = RGB_BLACK; - LZ77UnCompVram(gUnknown_0840A778, (void *)(VRAM + 0x4000)); - LZ77UnCompVram(gUnknown_0840A7E4, (void *)(VRAM + 0x7000)); - LoadPalette(gUnknown_0840A758, 0, 0x20); + LZ77UnCompVram(gIntro3Streaks_Gfx, (void *)(VRAM + 0x4000)); + LZ77UnCompVram(gIntro3Streaks_Tilemap, (void *)(VRAM + 0x7000)); + LoadPalette(gIntro3Streaks_Pal, 0, 0x20); ResetSpriteData(); FreeAllSpritePalettes(); gReservedSpritePaletteCount = 8; - LoadCompressedObjectPic(&gUnknown_0840B20C); - LoadCompressedObjectPic(&gUnknown_0840B21C); - LoadCompressedObjectPalette(&gUnknown_0840B22C); - LoadSpritePalettes(gUnknown_0840B23C); + LoadCompressedObjectPic(&gIntro3PokeballGfx_Table[0]); + LoadCompressedObjectPic(&gIntro3MiscGfx_Table[0]); + LoadCompressedObjectPalette(&gInterfacePokeballPal_Table[0]); + LoadSpritePalettes(gIntro3MiscPal_Table); gTasks[taskId].func = task_intro_14; } @@ -524,10 +1253,18 @@ static void task_intro_14(u8 taskId) REG_WIN0V = 0xA0; REG_WININ = 0x1C; REG_WINOUT = 0x1D; - REG_BG3CNT = 0x603; - REG_BG0CNT = 0x700; + REG_BG3CNT = BGCNT_PRIORITY(3) + | BGCNT_CHARBASE(0) + | BGCNT_SCREENBASE(6) + | BGCNT_16COLOR + | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(0) + | BGCNT_CHARBASE(0) + | BGCNT_SCREENBASE(7) + | BGCNT_16COLOR + | BGCNT_TXT256x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON; - gTasks[taskId].data[15] = CreateTask(sub_813CAF4, 0); + gTasks[taskId].data[15] = CreateTask(task_intro_20, 0); gTasks[gTasks[taskId].data[15]].data[0] = 0; gTasks[taskId].data[0] = 0; gTasks[taskId].func = task_intro_15; @@ -536,11 +1273,11 @@ static void task_intro_14(u8 taskId) static void task_intro_15(u8 taskId) { u16 foo = gTasks[taskId].data[0]; - + if (gTasks[taskId].data[0] != 32) { u32 bar; //needed to match for some reason - + gTasks[taskId].data[0] += 4; REG_WIN0V = (gTasks[taskId].data[0] * 256) - (bar = foo - 0x9C); } @@ -565,7 +1302,7 @@ static void task_intro_17(u8 taskId) static void Task_IntroPokemonBattle(u8 taskId) { u8 spriteId; - + if (gIntroFrameCounter == 80) { spriteId = sub_813CE88(SPECIES_SHARPEDO, 0xF0, 0xA0, 5, 1); @@ -637,14 +1374,14 @@ static void Task_IntroPokemonBattle(u8 taskId) spriteId = sub_813CE88(SPECIES_MUDKIP, 0x20, 0x98, 0, 0); gSprites[spriteId].callback = sub_813E210; gTasks[taskId].data[4] = spriteId; - sub_813EDBC(spriteId); + InitIntroMudkipAttackAnim(spriteId); } if (gIntroFrameCounter == 700) { spriteId = sub_813CE88(SPECIES_TORCHIC, -8, 0x90, 1, 0); gSprites[spriteId].callback = sub_813E210; gTasks[taskId].data[5] = spriteId; - sub_813EB4C(spriteId); + InitIntroTorchicAttackAnim(spriteId); } if (gIntroFrameCounter == 776) { @@ -676,3 +1413,1753 @@ static void task_intro_19(u8 taskId) DestroyTask(taskId); SetMainCallback2(MainCB2_EndIntro); } + +static void task_intro_20(u8 taskId) +{ +#define BG2_FLAGS (BGCNT_PRIORITY(3) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(14) | BGCNT_16COLOR | BGCNT_TXT256x256) +#define DISPCNT_FLAGS (DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON) + + gTasks[taskId].data[15]++; + switch (gTasks[taskId].data[0]) + { + case 0: + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON; + REG_BG2CNT = 0; + gTasks[taskId].data[0] = 0xFF; + break; + case 2: + BeginNormalPaletteFade(1, 0, 0x10, 0, 0xFFFF); + REG_BG2CNT = BG2_FLAGS; + REG_DISPCNT = DISPCNT_FLAGS; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[0] = 20; + //fall through + case 20: + REG_BG2VOFS = gTasks[taskId].data[1]; + REG_BG2HOFS = gTasks[taskId].data[2]; + gTasks[taskId].data[1] += 6; + gTasks[taskId].data[2] -= 8; + break; + case 3: + BeginNormalPaletteFade(1, 0, 0x10, 0, 0xFFFF); + REG_BG2CNT = BG2_FLAGS; + REG_DISPCNT = DISPCNT_FLAGS; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[0] = 0x1E; + //fall through + case 0x1E: + REG_BG2VOFS = gTasks[taskId].data[1]; + REG_BG2HOFS = gTasks[taskId].data[2]; + gTasks[taskId].data[1] -= 6; + gTasks[taskId].data[2] += 8; + break; + case 4: + BeginNormalPaletteFade(1, 5, 0, 0x10, 0x37F7); + REG_BG2CNT = BG2_FLAGS; + REG_DISPCNT = DISPCNT_FLAGS; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3] = 8; + gTasks[taskId].data[0] = 0x28; + //fall through + case 0x28: + REG_BG2VOFS = gTasks[taskId].data[1]; + REG_BG2HOFS = gTasks[taskId].data[2]; + gTasks[taskId].data[1] -= gTasks[taskId].data[3]; + gTasks[taskId].data[2] += gTasks[taskId].data[3]; + if (!(gTasks[taskId].data[15] & 7) && gTasks[taskId].data[3] != 0) + gTasks[taskId].data[3]--; + break; + case 0xFF: //needed to prevent jump table optimization + break; + } + +#undef BG2_FLAGS +#undef DISPCNT_FLAGS +} + +static void intro_reset_and_hide_bgs(void) +{ + REG_DISPCNT = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; + REG_BG2HOFS = 0; + REG_BG2VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + REG_BLDY = 0; +} + +#ifdef NONMATCHING +static void sub_813CCE8(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + default: + case 0: + REG_BLDCNT = 0x3F50; + REG_BLDALPHA = 0x1000; + REG_BLDY = 0; + gTasks[taskId].data[1] = 0x40; + gTasks[taskId].data[0] = 1; + return; + case 1: + if (gTasks[taskId].data[1] != 0) + { + u32 foo; + u32 bar asm("r2"); + + gTasks[taskId].data[1]--; + //tail merge at _0813CDC2 + foo = gTasks[taskId].data[1] + (gTasks[taskId].data[1] < 0); + bar = 0x1FE; + REG_BLDALPHA = gUnknown_08393E64[(foo & bar) / 2]; + } + else + { + REG_BLDALPHA = gUnknown_08393E64[0]; + gTasks[taskId].data[1] = 0x80; + gTasks[taskId].data[0]++; + } + return; + case 2: + if (gTasks[taskId].data[1] != 0) + { + //tail merge at _0813CE0E + gTasks[taskId].data[1]--; + } + else + { + gTasks[taskId].data[1] = 0; //redundant? + gTasks[taskId].data[0]++; + } + return; + case 3: + if (gTasks[taskId].data[1] <= 0x3D) + { + u32 foo; + u32 bar asm("r2"); + + gTasks[taskId].data[1]++; + //_0813CDC2 + foo = gTasks[taskId].data[1] + (gTasks[taskId].data[1] < 0); + bar = 0x1FE; + REG_BLDALPHA = gUnknown_08393E64[(foo & bar) / 2]; + } + else + { + //_0813CDE0 + REG_BLDALPHA = gUnknown_08393E64[0x1F]; + gTasks[taskId].data[1] = 0x10; + gTasks[taskId].data[0]++; + } + return; + case 4: + if (gTasks[taskId].data[1] != 0) + { + gTasks[taskId].data[1]--; + } + else + { + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + REG_BLDY = 0; + DestroyTask(taskId); + } + return; + } +} +#else +__attribute__((naked)) +static void sub_813CCE8(u8 taskId) +{ + asm("\n\ + .equ REG_BLDCNT, 0x4000050\n\ + .equ REG_BLDALPHA, 0x4000052\n\ + .syntax unified\n\ + push {r4,lr}\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + ldr r1, _0813CD0C @ =gTasks\n\ + lsls r0, r3, 2\n\ + adds r0, r3\n\ + lsls r0, 3\n\ + adds r0, r1\n\ + movs r2, 0x8\n\ + ldrsh r0, [r0, r2]\n\ + adds r2, r1, 0\n\ + cmp r0, 0x4\n\ + bhi _0813CD28\n\ + lsls r0, 2\n\ + ldr r1, _0813CD10 @ =_0813CD14\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + mov pc, r0\n\ + .align 2, 0\n\ +_0813CD0C: .4byte gTasks\n\ +_0813CD10: .4byte _0813CD14\n\ + .align 2, 0\n\ +_0813CD14:\n\ + .4byte _0813CD28\n\ + .4byte _0813CD5C\n\ + .4byte _0813CD8C\n\ + .4byte _0813CDA8\n\ + .4byte _0813CDFC\n\ +_0813CD28:\n\ + ldr r1, _0813CD54 @ =REG_BLDCNT\n\ + ldr r4, _0813CD58 @ =0x00003f50\n\ + adds r0, r4, 0\n\ + strh r0, [r1]\n\ + adds r1, 0x2\n\ + movs r4, 0x80\n\ + lsls r4, 5\n\ + adds r0, r4, 0\n\ + strh r0, [r1]\n\ + adds r1, 0x2\n\ + movs r0, 0\n\ + strh r0, [r1]\n\ + lsls r0, r3, 2\n\ + adds r0, r3\n\ + lsls r0, 3\n\ + adds r0, r2\n\ + movs r1, 0x40\n\ + strh r1, [r0, 0xA]\n\ + movs r1, 0x1\n\ + strh r1, [r0, 0x8]\n\ + b _0813CE26\n\ + .align 2, 0\n\ +_0813CD54: .4byte REG_BLDCNT\n\ +_0813CD58: .4byte 0x00003f50\n\ +_0813CD5C:\n\ + lsls r0, r3, 2\n\ + adds r0, r3\n\ + lsls r0, 3\n\ + adds r2, r0, r2\n\ + ldrh r1, [r2, 0xA]\n\ + movs r3, 0xA\n\ + ldrsh r0, [r2, r3]\n\ + cmp r0, 0\n\ + beq _0813CD78\n\ + subs r0, r1, 0x1\n\ + strh r0, [r2, 0xA]\n\ + movs r4, 0xA\n\ + ldrsh r0, [r2, r4]\n\ + b _0813CDC2\n\ +_0813CD78:\n\ + ldr r1, _0813CD84 @ =REG_BLDALPHA\n\ + ldr r0, _0813CD88 @ =gUnknown_08393E64\n\ + ldrh r0, [r0]\n\ + strh r0, [r1]\n\ + movs r0, 0x80\n\ + b _0813CDEA\n\ + .align 2, 0\n\ +_0813CD84: .4byte REG_BLDALPHA\n\ +_0813CD88: .4byte gUnknown_08393E64\n\ +_0813CD8C:\n\ + lsls r0, r3, 2\n\ + adds r0, r3\n\ + lsls r0, 3\n\ + adds r1, r0, r2\n\ + ldrh r0, [r1, 0xA]\n\ + movs r3, 0xA\n\ + ldrsh r2, [r1, r3]\n\ + cmp r2, 0\n\ + bne _0813CE0E\n\ + strh r2, [r1, 0xA]\n\ + ldrh r0, [r1, 0x8]\n\ + adds r0, 0x1\n\ + strh r0, [r1, 0x8]\n\ + b _0813CE26\n\ +_0813CDA8:\n\ + lsls r0, r3, 2\n\ + adds r0, r3\n\ + lsls r0, 3\n\ + adds r2, r0, r2\n\ + ldrh r1, [r2, 0xA]\n\ + movs r4, 0xA\n\ + ldrsh r0, [r2, r4]\n\ + cmp r0, 0x3D\n\ + bgt _0813CDE0\n\ + adds r0, r1, 0x1\n\ + strh r0, [r2, 0xA]\n\ + movs r1, 0xA\n\ + ldrsh r0, [r2, r1]\n\ +_0813CDC2:\n\ + lsrs r1, r0, 31\n\ + adds r0, r1\n\ + movs r2, 0xFF\n\ + lsls r2, 1\n\ + ldr r3, _0813CDD8 @ =REG_BLDALPHA\n\ + ldr r1, _0813CDDC @ =gUnknown_08393E64\n\ + ands r0, r2\n\ + adds r0, r1\n\ + ldrh r0, [r0]\n\ + strh r0, [r3]\n\ + b _0813CE26\n\ + .align 2, 0\n\ +_0813CDD8: .4byte REG_BLDALPHA\n\ +_0813CDDC: .4byte gUnknown_08393E64\n\ +_0813CDE0:\n\ + ldr r1, _0813CDF4 @ =REG_BLDALPHA\n\ + ldr r0, _0813CDF8 @ =gUnknown_08393E64\n\ + ldrh r0, [r0, 0x3E]\n\ + strh r0, [r1]\n\ + movs r0, 0x10\n\ +_0813CDEA:\n\ + strh r0, [r2, 0xA]\n\ + ldrh r0, [r2, 0x8]\n\ + adds r0, 0x1\n\ + strh r0, [r2, 0x8]\n\ + b _0813CE26\n\ + .align 2, 0\n\ +_0813CDF4: .4byte REG_BLDALPHA\n\ +_0813CDF8: .4byte gUnknown_08393E64\n\ +_0813CDFC:\n\ + lsls r0, r3, 2\n\ + adds r0, r3\n\ + lsls r0, 3\n\ + adds r1, r0, r2\n\ + ldrh r0, [r1, 0xA]\n\ + movs r4, 0xA\n\ + ldrsh r2, [r1, r4]\n\ + cmp r2, 0\n\ + beq _0813CE14\n\ +_0813CE0E:\n\ + subs r0, 0x1\n\ + strh r0, [r1, 0xA]\n\ + b _0813CE26\n\ +_0813CE14:\n\ + ldr r0, _0813CE2C @ =REG_BLDCNT\n\ + strh r2, [r0]\n\ + adds r0, 0x2\n\ + strh r2, [r0]\n\ + adds r0, 0x2\n\ + strh r2, [r0]\n\ + adds r0, r3, 0\n\ + bl DestroyTask\n\ +_0813CE26:\n\ + pop {r4}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_0813CE2C: .4byte REG_BLDCNT\n\ + .syntax divided\n"); +} +#endif + +void sub_813CE30(u16 scrX, u16 scrY, u16 zoom, u16 alpha) +{ + struct BgAffineSrcData src; + struct BgAffineDstData dest; + + src.texX = 0x8000; + src.texY = 0x8000; + src.scrX = scrX; + src.scrY = scrY; + src.sx = zoom; + src.sy = zoom; + src.alpha = alpha; + BgAffineSet(&src, &dest, 1); + REG_BG2PA = dest.pa; + REG_BG2PB = dest.pb; + REG_BG2PC = dest.pc; + REG_BG2PD = dest.pd; + REG_BG2X = dest.dx; + REG_BG2Y = dest.dy; +} + +static u16 sub_813CE88(u16 species, s16 x, s16 y, u16 d, u8 front) +{ + const u8 *lzPaletteData; + u8 spriteId; + + if (front) + LoadSpecialPokePic(&gMonFrontPicTable[species], gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, 0x2000000, gUnknown_0840B5A0[d], species, 0, 1); + else + LoadSpecialPokePic(&gMonBackPicTable[species], gMonBackPicCoords[species].coords, gMonBackPicCoords[species].y_offset, 0x2000000, gUnknown_0840B5A0[d], species, 0, 0); + lzPaletteData = species_and_otid_get_pal(species, 0, 0xFFFF); + LoadCompressedPalette(lzPaletteData, 0x100 + d * 0x10, 0x20); + sub_8143648(d, d); + spriteId = CreateSprite(&gUnknown_02024E8C, x, y, (d + 1) * 4); + gSprites[spriteId].oam.paletteNum = d; + gSprites[spriteId].oam.priority = 1; + return spriteId; +} + +static u8 sub_813CFA8(u16 a, u16 b, u16 c, u16 d) +{ + u8 spriteId; + + DecompressPicFromTable_2(&gTrainerBackPicTable[a], gTrainerBackPicCoords[a].coords, gTrainerBackPicCoords[a].y_offset, (void *)0x2000000, gUnknown_0840B5A0[d], a); + LoadCompressedPalette(gTrainerBackPicPaletteTable[a].data, 0x100 + d * 0x10, 0x20); + sub_8143680(d, d); + gUnknown_02024E8C.anims = gUnknown_0840B064; + spriteId = CreateSprite(&gUnknown_02024E8C, b, c, 1); + gSprites[spriteId].oam.paletteNum = d; + gSprites[spriteId].oam.priority = 1; + return spriteId; +} + +static void sub_813D084(u8 a) +{ + u16 color; + + switch (a) + { + default: + case 0: + color = RGB(22, 31, 15); + break; + case 1: + color = RGB(31, 14, 12); + break; + case 2: + color = RGB(12, 12, 20); + break; + } + gPlttBufferUnfaded[241] = color; + gPlttBufferFaded[241] = color; +} + +static void sub_813D0CC(struct Sprite *sprite) +{ + u8 r0; + + if (sprite->data2 >= 192) + { + if (sprite->data3 != 0) + { + sprite->data3--; + } + else + { + sprite->invisible = FALSE; + SetOamMatrix(sprite->data1, sprite->data2, 0, 0, sprite->data2); + sprite->data2 = (sprite->data2 * 95) / 100; + r0 = (sprite->data2 - 192) / 128 + 9; + if (r0 > 15) + r0 = 15; + sprite->oam.paletteNum = r0; + } + } + else + { + DestroySprite(sprite); + } +} + +static void sub_813D158(struct Sprite *sprite) +{ + if (gSprites[sprite->data7].data7 != 0) + { + sprite->invisible = TRUE; + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + StartSpriteAnim(sprite, 3); + sprite->data2 = 1024; + sprite->data3 = 8 * (sprite->data1 & 3); + sprite->callback = sub_813D0CC; + sprite->oam.shape = 1; + sprite->oam.size = 3; + CalcCenterToCornerVec(sprite, 1, 3, 2); + } + else + { + sprite->pos2.x = gSprites[sprite->data7].pos2.x; + sprite->pos2.y = gSprites[sprite->data7].pos2.y; + sprite->pos1.x = gSprites[sprite->data7].pos1.x; + sprite->pos1.y = gSprites[sprite->data7].pos1.y; + } +} + +static void sub_813D208(struct Sprite *sprite) +{ + if (sprite->data0 != 0) + sprite->callback = sub_813D220; +} + +static void sub_813D220(struct Sprite *sprite) +{ + if (sprite->pos1.x <= 116) + { + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.y = 0; + sprite->pos1.x += 4; + sprite->pos2.x = -4; + sprite->data4 = 128; + sprite->callback = sub_813D368; + } + else + { + u16 data2; + u16 data3; + u16 data4; + s16 sin1; + s16 sin2; + s16 sin3; + s16 sin4; + s16 var1; + s16 var2; + s16 var3; + s16 var4; + s16 temp; + + data4 = sprite->data4; + sin1 = gSineTable[(u8)data4]; + sin2 = gSineTable[(u8)(data4 + 64)]; + sprite->data4 += 2; + sprite->pos2.y = sin1 / 32; + sprite->pos1.x--; + if (sprite->pos1.x & 1) + sprite->pos1.y++; + temp = -sin2 / 16; + data2 = sprite->data2; + data3 = sprite->data3; + sin3 = gSineTable[(u8)(temp - 16)]; + sin4 = gSineTable[(u8)(temp + 48)]; + var1 = sin4 * data2 / 256; + var2 = -sin3 * data3 / 256; + var3 = sin3 * data2 / 256; + var4 = sin4 * data3 / 256; + SetOamMatrix(sprite->data1, data2, 0, 0, data3); + SetOamMatrix(sprite->data1 + 1, var1, var3, var2, var4); + SetOamMatrix(sprite->data1 + 2, var1, var3, var2 * 2, var4 * 2); + } +} + +static void sub_813D368(struct Sprite *sprite) +{ + SetOamMatrix(sprite->data1, sprite->data6 + 64, 0, 0, sprite->data6 + 64); + SetOamMatrix(sprite->data1 + 1, sprite->data6 + 64, 0, 0, sprite->data6 + 64); + SetOamMatrix(sprite->data1 + 2, sprite->data6 + 64, 0, 0, sprite->data6 + 64); + if (sprite->data4 != 64) + { + u16 data4; + + sprite->data4 -= 8; + data4 = sprite->data4; + sprite->pos2.x = gSineTable[(u8)(data4 + 64)] / 64; + sprite->pos2.y = gSineTable[(u8)data4] / 64; + } + else + { + sprite->data4 = 0; + sprite->callback = sub_813D414; + } +} + +static void sub_813D414(struct Sprite *sprite) +{ + if (sprite->data0 != 2) + { + s16 r2; + + sprite->data4 += 8; + r2 = gSineTable[(u8)sprite->data4] / 16 + 64; + sprite->pos2.x = gSineTable[(u8)(r2 + 64)] / 64; + sprite->pos2.y = gSineTable[(u8)r2] / 64; + } + else + { + sprite->callback = SpriteCB_WaterDropFall; + } +} + +static void SpriteCB_WaterDropFall(struct Sprite *sprite) +{ + if (sprite->pos1.y < sprite->data5) + { + sprite->pos1.y += 4; + } + else + { + sprite->data7 = 1; + sprite->invisible = TRUE; + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + StartSpriteAnim(sprite, 3); + sprite->data2 = 1024; + sprite->data3 = 8 * (sprite->data1 & 3); + sprite->callback = sub_813D0CC; + sprite->oam.shape = 1; + sprite->oam.size = 3; + CalcCenterToCornerVec(sprite, 1, 3, 2); + } +} + +//Duplicate function +static void SpriteCB_WaterDropFall_2(struct Sprite *sprite) +{ + if (sprite->pos1.y < sprite->data5) + { + sprite->pos1.y += 4; + } + else + { + sprite->data7 = 1; + sprite->invisible = TRUE; + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + StartSpriteAnim(sprite, 3); + sprite->data2 = 1024; + sprite->data3 = 8 * (sprite->data1 & 3); + sprite->callback = sub_813D0CC; + sprite->oam.shape = 1; + sprite->oam.size = 3; + CalcCenterToCornerVec(sprite, 1, 3, 2); + } +} + +static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) +{ + u8 spriteId; + u8 oldSpriteId; + + spriteId = CreateSprite(&gSpriteTemplate_840AE20, x, y, 0); + gSprites[spriteId].data0 = 0; + gSprites[spriteId].data7 = 0; + gSprites[spriteId].data1 = d; + gSprites[spriteId].data2 = c; + gSprites[spriteId].data3 = c; + gSprites[spriteId].data5 = e; + gSprites[spriteId].data6 = c; + gSprites[spriteId].oam.affineMode = 3; + gSprites[spriteId].oam.matrixNum = d; + CalcCenterToCornerVec(&gSprites[spriteId], 0, 2, 2); + StartSpriteAnim(&gSprites[spriteId], 2); + if (!fallImmediately) + gSprites[spriteId].callback = sub_813D208; + else + gSprites[spriteId].callback = SpriteCB_WaterDropFall_2; + oldSpriteId = spriteId; + + spriteId = CreateSprite(&gSpriteTemplate_840AE20, x, y, 0); + gSprites[spriteId].data7 = oldSpriteId; + gSprites[spriteId].data1 = d + 1; + gSprites[spriteId].oam.affineMode = 3; + gSprites[spriteId].oam.matrixNum = d + 1; + CalcCenterToCornerVec(&gSprites[spriteId], 0, 2, 2); + gSprites[spriteId].callback = sub_813D158; + + spriteId = CreateSprite(&gSpriteTemplate_840AE20, x, y, 0); + gSprites[spriteId].data7 = oldSpriteId; + gSprites[spriteId].data1 = d + 2; + StartSpriteAnim(&gSprites[spriteId], 1); + gSprites[spriteId].oam.affineMode = 3; + gSprites[spriteId].oam.matrixNum = d + 2; + CalcCenterToCornerVec(&gSprites[spriteId], 0, 2, 2); + gSprites[spriteId].callback = sub_813D158; + + SetOamMatrix(d, c + 32, 0, 0, c + 32); + SetOamMatrix(d + 1, c + 32, 0, 0, c + 32); + SetOamMatrix(d + 2, c + 32, 0, 0, 2 * (c + 32)); + + return oldSpriteId; +} + +static void sub_813D788(struct Sprite *sprite) +{ + switch (sprite->data0) + { + case 0: + StartSpriteAnimIfDifferent(sprite, 0); + sprite->pos1.x--; + break; + case 1: + StartSpriteAnimIfDifferent(sprite, 0); + if (gIntroFrameCounter & 7) + return; + sprite->pos1.x++; + break; + case 2: + StartSpriteAnimIfDifferent(sprite, 2); + if (sprite->pos1.x <= 120 || (gIntroFrameCounter & 7)) + sprite->pos1.x++; + break; + case 3: + StartSpriteAnimIfDifferent(sprite, 3); + break; + case 4: + StartSpriteAnimIfDifferent(sprite, 0); + if (sprite->pos1.x > -32) + sprite->pos1.x -= 2; + break; + } + if (gIntroFrameCounter & 7) + return; + if (sprite->pos2.y != 0) + { + sprite->pos2.y = 0; + } + else + { + switch (Random() & 3) + { + case 0: + sprite->pos2.y = -1; + break; + case 1: + sprite->pos2.y = 1; + break; + case 2: + case 3: + sprite->pos2.y = 0; + break; + } + } +} + +static void sub_813D880(struct Sprite *sprite) +{ + switch (sprite->data0) + { + case 0: + break; + case 1: + if (sprite->pos2.x + sprite->pos1.x < 304) + sprite->pos2.x += 8; + else + sprite->data0 = 2; + break; + case 2: + if (sprite->pos2.x + sprite->pos1.x > 120) + sprite->pos2.x -= 1; + else + sprite->data0 = 3; + break; + case 3: + if (sprite->pos2.x > 0) + sprite->pos2.x -= 2; + break; + } + sprite->pos2.y = Sin((u8)sprite->data1, 8) - gUnknown_0203935A; + sprite->data1 += 4; +} + +static void sub_813D908(struct Sprite *sprite) +{ + if (gTasks[sprite->data0].data[0] == 0) + { + sprite->invisible = TRUE; + } + else if (gTasks[sprite->data0].data[0] != 4) + { + sprite->invisible = FALSE; + } + else + { + DestroySprite(sprite); + } +} + +static u8 CreateGameFreakLogo(s16 a, s16 b, u8 c) +{ + u8 spriteId; + u16 i; + + for (i = 0; i < 9; i++) + { + spriteId = CreateSprite(&gSpriteTemplate_840AF94, gUnknown_0840AF50[i][1] + a, b - 4, 0); + gSprites[spriteId].data0 = c; + StartSpriteAnim(&gSprites[spriteId], gUnknown_0840AF50[i][0]); + } + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gSpriteTemplate_840AFAC, gUnknown_0840AF74[i][1] + a, b + 12, 0); + gSprites[spriteId].data0 = c; + StartSpriteAnim(&gSprites[spriteId], gUnknown_0840AF74[i][0]); + } + spriteId = CreateSprite(&gSpriteTemplate_840AFC4, 120, b - 4, 0); + gSprites[spriteId].data0 = c; + + return spriteId; +} + +#ifdef NONMATCHING +static void sub_813DA64(struct Sprite *sprite) +{ + sprite->data7++; + + switch (sprite->data0) + { + case 0: + default: + sprite->oam.affineMode = 3; + sprite->oam.matrixNum = 1; + CalcCenterToCornerVec(sprite, 1, 3, 3); + sprite->invisible = FALSE; + sprite->data0 = 1; + sprite->data1 = 128; + sprite->data2 = -24; + sprite->data3 = 0; + break; + case 1: + { + s16 r3; + s16 sin1; + s16 r6; + s16 foo; + s16 r5; + s16 r2; + + //_0813DAC0 + if (sprite->data3 < 0x50) + { + sprite->pos2.y = -Sin((u8)sprite->data3, 0x78); + sprite->pos2.x = -Sin((u8)sprite->data3, 0x8C); + if (sprite->data3 > 64) + sprite->oam.priority = 3; + } + //_0813DAF8 + r3 = gSineTable[(u8)sprite->data2]; + sin1 = gSineTable[(u8)(sprite->data2 + 64)]; + r6 = sin1 * sprite->data1 / 256; + foo = sin1 * sprite->data1 / 256; + r5 = -r3 * sprite->data1 / 256; + r2 = r3 * sprite->data1 / 256; + + SetOamMatrix(1, r6, r2, r5, foo); + + if (sprite->data1 < 0x100) + sprite->data1 += 8; + else + sprite->data1 += 32; + if (sprite->data2 < 0x18) + sprite->data2 += 1; + if (sprite->data3 < 64) + sprite->data3 += 2; + else if (!(sprite->data7 & 3)) + sprite->data3 += 1; + break; + } + } + //_0813DB92 +} +#else +__attribute__((naked)) +static void sub_813DA64(struct Sprite *sprite) +{ + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + sub sp, 0x4\n\ + adds r4, r0, 0\n\ + ldrh r0, [r4, 0x3C]\n\ + adds r0, 0x1\n\ + strh r0, [r4, 0x3C]\n\ + movs r1, 0x2E\n\ + ldrsh r0, [r4, r1]\n\ + cmp r0, 0\n\ + beq _0813DA7C\n\ + cmp r0, 0x1\n\ + beq _0813DAC0\n\ +_0813DA7C:\n\ + ldrb r0, [r4, 0x1]\n\ + movs r1, 0x3\n\ + orrs r0, r1\n\ + strb r0, [r4, 0x1]\n\ + ldrb r1, [r4, 0x3]\n\ + movs r0, 0x3F\n\ + negs r0, r0\n\ + ands r0, r1\n\ + movs r1, 0x2\n\ + orrs r0, r1\n\ + strb r0, [r4, 0x3]\n\ + adds r0, r4, 0\n\ + movs r1, 0x1\n\ + movs r2, 0x3\n\ + movs r3, 0x3\n\ + bl CalcCenterToCornerVec\n\ + adds r2, r4, 0\n\ + adds r2, 0x3E\n\ + ldrb r1, [r2]\n\ + movs r0, 0x5\n\ + negs r0, r0\n\ + ands r0, r1\n\ + strb r0, [r2]\n\ + movs r0, 0x1\n\ + strh r0, [r4, 0x2E]\n\ + movs r0, 0x80\n\ + strh r0, [r4, 0x30]\n\ + ldr r0, _0813DABC @ =0x0000ffe8\n\ + strh r0, [r4, 0x32]\n\ + movs r0, 0\n\ + b _0813DB92\n\ + .align 2, 0\n\ +_0813DABC: .4byte 0x0000ffe8\n\ +_0813DAC0:\n\ + ldrh r1, [r4, 0x34]\n\ + movs r2, 0x34\n\ + ldrsh r0, [r4, r2]\n\ + cmp r0, 0x4F\n\ + bgt _0813DAF8\n\ + lsls r0, r1, 24\n\ + lsrs r0, 24\n\ + movs r1, 0x78\n\ + bl Sin\n\ + negs r0, r0\n\ + strh r0, [r4, 0x26]\n\ + ldrh r0, [r4, 0x34]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + movs r1, 0x8C\n\ + bl Sin\n\ + negs r0, r0\n\ + strh r0, [r4, 0x24]\n\ + movs r1, 0x34\n\ + ldrsh r0, [r4, r1]\n\ + cmp r0, 0x40\n\ + ble _0813DAF8\n\ + ldrb r0, [r4, 0x5]\n\ + movs r1, 0xC\n\ + orrs r0, r1\n\ + strb r0, [r4, 0x5]\n\ +_0813DAF8:\n\ + ldr r2, _0813DB60 @ =gSineTable\n\ + ldrh r1, [r4, 0x32]\n\ + lsls r0, r1, 24\n\ + lsrs r0, 23\n\ + adds r0, r2\n\ + ldrh r3, [r0]\n\ + adds r1, 0x40\n\ + lsls r1, 24\n\ + lsrs r1, 23\n\ + adds r1, r2\n\ + movs r2, 0\n\ + ldrsh r0, [r1, r2]\n\ + movs r1, 0x30\n\ + ldrsh r2, [r4, r1]\n\ + adds r1, r0, 0\n\ + muls r1, r2\n\ + adds r0, r1, 0\n\ + cmp r1, 0\n\ + bge _0813DB20\n\ + adds r0, 0xFF\n\ +_0813DB20:\n\ + lsls r0, 8\n\ + lsrs r6, r0, 16\n\ + lsls r0, r3, 16\n\ + asrs r3, r0, 16\n\ + negs r0, r3\n\ + muls r0, r2\n\ + cmp r0, 0\n\ + bge _0813DB32\n\ + adds r0, 0xFF\n\ +_0813DB32:\n\ + lsls r0, 8\n\ + lsrs r5, r0, 16\n\ + adds r0, r3, 0\n\ + muls r0, r2\n\ + cmp r0, 0\n\ + bge _0813DB40\n\ + adds r0, 0xFF\n\ +_0813DB40:\n\ + lsls r0, 8\n\ + lsrs r2, r0, 16\n\ + adds r1, r6, 0\n\ + adds r3, r5, 0\n\ + str r1, [sp]\n\ + movs r0, 0x1\n\ + bl SetOamMatrix\n\ + ldrh r1, [r4, 0x30]\n\ + movs r2, 0x30\n\ + ldrsh r0, [r4, r2]\n\ + cmp r0, 0xFF\n\ + bgt _0813DB64\n\ + adds r0, r1, 0\n\ + adds r0, 0x8\n\ + b _0813DB68\n\ + .align 2, 0\n\ +_0813DB60: .4byte gSineTable\n\ +_0813DB64:\n\ + adds r0, r1, 0\n\ + adds r0, 0x20\n\ +_0813DB68:\n\ + strh r0, [r4, 0x30]\n\ + ldrh r1, [r4, 0x32]\n\ + movs r2, 0x32\n\ + ldrsh r0, [r4, r2]\n\ + cmp r0, 0x17\n\ + bgt _0813DB78\n\ + adds r0, r1, 0x1\n\ + strh r0, [r4, 0x32]\n\ +_0813DB78:\n\ + ldrh r2, [r4, 0x34]\n\ + movs r1, 0x34\n\ + ldrsh r0, [r4, r1]\n\ + cmp r0, 0x3F\n\ + bgt _0813DB86\n\ + adds r0, r2, 0x2\n\ + b _0813DB92\n\ +_0813DB86:\n\ + ldrh r1, [r4, 0x3C]\n\ + movs r0, 0x3\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0813DB94\n\ + adds r0, r2, 0x1\n\ +_0813DB92:\n\ + strh r0, [r4, 0x34]\n\ +_0813DB94:\n\ + add sp, 0x4\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .syntax divided\n"); +} +#endif + +static void sub_813DB9C(struct Sprite *sprite) +{ + switch (sprite->data0) + { + case 0: + default: + if (sprite->data2 != 0) + sprite->hFlip = TRUE; + else + sprite->hFlip = FALSE; + sprite->data0 = 1; + //fall through + case 1: + if (sprite->pos1.y > 96) + { + sprite->pos1.y -= 4; + if (sprite->data2 != 0) + sprite->pos1.x += 2; + else + sprite->pos1.x -= 2; + } + else + { + sprite->data0++; + sprite->data3 = 8; + } + break; + case 2: + if (sprite->data3 != 0) + { + sprite->data3--; + } + else + { + sprite->data0++; + sprite->data3 = 0; //redundant? + } + break; + case 3: + sprite->oam.affineMode = 3; + sprite->oam.matrixNum = sprite->data1; + CalcCenterToCornerVec(sprite, 0, 3, 3); + if (sprite->data2 != 0) + SetOamMatrix(sprite->data1, -256, 0, 0, 256); + else + SetOamMatrix(sprite->data1, 256, 0, 0, 256); + sprite->data0++; + sprite->data4 = 0; + break; + case 4: + sprite->data4++; + if (sprite->pos1.y + sprite->pos2.y > -32 + && sprite->pos1.x + sprite->pos2.x > -64) + { + u16 r2; + + sprite->pos2.y = -(sprite->data4 * sprite->data4) / 8; + if (sprite->data2 != 0) + sprite->pos2.x += sprite->data4; + else + sprite->pos2.x -= sprite->data4; + if (sprite->data3 < 128) + sprite->data3 += 8; + r2 = 256 - sprite->data3; + if (sprite->data2 != 0) + SetOamMatrix(sprite->data1, -r2, 0, 0, r2); + else + SetOamMatrix(sprite->data1, r2, 0, 0, r2); + } + else + { + DestroySprite(sprite); + } + } +} + +static void sub_813DD58(struct Sprite *sprite) +{ + switch (sprite->data0) + { + case 0: + default: + sprite->invisible = FALSE; + sprite->oam.affineMode = 1; + sprite->oam.matrixNum = sprite->data1; + sprite->data3 = 2048; + sprite->data0 = 1; + //fall through + case 1: + if (sprite->data3 > 256) + { + sprite->data3 -= 128; + if (sprite->data2 != 0) + SetOamMatrix(sprite->data1, -sprite->data3, 0, 0, sprite->data3); + else + SetOamMatrix(sprite->data1, sprite->data3, 0, 0, sprite->data3); + } + else + { + if (sprite->data2 != 0) + SetOamMatrix(sprite->data1, -256, 0, 0, 256); + else + SetOamMatrix(sprite->data1, 256, 0, 0, 256); + sprite->data0++; + } + break; + case 2: + break; + case 3: + sprite->data4++; + sprite->pos2.y = sprite->data4 * sprite->data4 / 32; + if (sprite->data2 != 0) + sprite->pos2.x = sprite->data4 / 4; + else + sprite->pos2.x = -(sprite->data4 / 4); + break; + } +} + +static void sub_813DE70(struct Sprite *sprite) +{ + switch (sprite->data0) + { + case 0: + default: + if (sprite->pos1.x > 40) + { + sprite->pos1.x -= 4; + } + else + { + StartSpriteAnim(sprite, 1); + sprite->data6 = CreateSprite(&gSpriteTemplate_840B084, 16, 104, 100); + sprite->data7 = CreateSprite(&gSpriteTemplate_840B084, 12, 106, 101); + sprite->data0 = 1; + } + break; + case 1: + break; + case 2: + StartSpriteAnim(sprite, 2); + gSprites[sprite->data6].data0 = 1; + gSprites[sprite->data7].data0 = 2; + sprite->data0++; + break; + case 3: + if (sprite->pos1.y > 160) + { + sprite->invisible = 1; + sprite->data0 = 1; + } + else + { + sprite->pos1.y += 2; + sprite->pos1.x--; + } + break; + case 4: + { + s16 r4, r5; + + r5 = gSprites[sprite->data6].pos1.x + gSprites[sprite->data6].pos2.x; + r4 = gSprites[sprite->data6].pos1.y + gSprites[sprite->data6].pos2.y; + DestroySprite(&gSprites[sprite->data6]); + sprite->data6 = sub_813CE88(SPECIES_TORCHIC, r5, r4, 2, 1); + gSprites[sprite->data6].callback = sub_813DD58; + gSprites[sprite->data6].invisible = TRUE; + gSprites[sprite->data6].data1 = 1; + gSprites[sprite->data6].data2 = 1; + sub_813E580(r5, r4); + + r5 = gSprites[sprite->data7].pos1.x + gSprites[sprite->data7].pos2.x; + r4 = gSprites[sprite->data7].pos1.y + gSprites[sprite->data7].pos2.y; + DestroySprite(&gSprites[sprite->data7]); + sprite->data7 = sub_813CE88(SPECIES_MUDKIP, r5, r4, 3, 1); + gSprites[sprite->data7].callback = sub_813DD58; + gSprites[sprite->data7].invisible = TRUE; + gSprites[sprite->data7].data1 = 2; + gSprites[sprite->data7].data2 = 0; + sub_813E580(r5, r4); + + BeginNormalPaletteFade(0xFF0000, 0, 16, 16, RGB(31, 23, 31)); + sprite->data0 = 1; + break; + } + case 5: + gSprites[sprite->data6].data0 = 3; + gSprites[sprite->data7].data0 = 3; + break; + case 6: + DestroySprite(&gSprites[sprite->data6]); + DestroySprite(&gSprites[sprite->data7]); + DestroySprite(sprite); + break; + } +} + +static void sub_813E10C(struct Sprite *sprite) +{ + switch (sprite->data0) + { + case 0: + default: + if (sprite->pos2.x > -56) + { + sprite->pos2.x -= 8; + sprite->pos2.y += 6; + } + else + { + sprite->data6 = sprite->pos1.x; + sprite->data7 = sprite->pos1.y; + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->data0 = 1; + sprite->data1 = 0; + } + break; + case 1: + if (!(sprite->data1 & 1)) + { + if (sprite->data1 & 2) + { + sprite->pos2.x = -1; + sprite->pos2.y = 1; + } + else + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + } + } + sprite->data1++; + break; + case 2: + sprite->invisible = TRUE; + sprite->pos1.x = sprite->data6; + sprite->pos1.y = sprite->data7; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + break; + case 3: + sprite->invisible = FALSE; + sprite->data1++; + //fall through + case 4: + if (sprite->pos2.x > -56) + { + sprite->pos2.x -= 4; + sprite->pos2.y += 3; + } + else + { + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->data0 = 1; + } + break; + } +} + +static void sub_813E210(struct Sprite *sprite) +{ + switch (sprite->data0) + { + case 0: + default: + if (sprite->pos2.x < 56) + { + sprite->pos2.x += 8; + sprite->pos2.y -= 6; + } + else + { + sprite->data6 = sprite->pos1.x; + sprite->data7 = sprite->pos1.y; + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->data0 = 1; + sprite->data1 = 0; + } + break; + case 1: + if (!(sprite->data1 & 1)) + { + if (sprite->data1 & 2) + { + sprite->pos2.x = 1; + sprite->pos2.y = -1; + } + else + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + } + } + sprite->data1++; + break; + case 2: + sprite->invisible = TRUE; + sprite->pos1.x = sprite->data6; + sprite->pos1.y = sprite->data7; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + break; + case 3: + sprite->invisible = FALSE; + sprite->data1++; + //fall through + case 4: + if (sprite->pos2.x < 56) + { + sprite->pos2.x += 4; + sprite->pos2.y -= 3; + } + else + { + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->data0 = 1; + } + break; + } +} + +static void sub_813E30C(struct Sprite *sprite) +{ + u16 r4, r1; + + sprite->data7++; + switch (sprite->data0) + { + case 0: + default: + break; + case 1: + sprite->oam.affineMode = 1; + sprite->oam.matrixNum = 1; + sprite->data0 = 10; + sprite->data4 = 36; + //fall through + case 10: + if (sprite->pos1.x <= 144) + { + sprite->pos1.x += 4; + sprite->pos1.y -= 1; + sprite->pos2.y = -Sin((u8)sprite->data2, 24); + sprite->data2 += 4; + } + sprite->data3 -= sprite->data4; + if ((sprite->data7 & 1) && sprite->data4 != 0) + sprite->data4--; + r4 = gSineTable[(u8)sprite->data3]; + r1 = gSineTable[(u8)(sprite->data3 + 64)]; + SetOamMatrix(1, r1, r4, -r4, r1); + break; + case 2: + sprite->oam.affineMode = 1; + sprite->oam.matrixNum = 2; + sprite->data0 = 20; + sprite->data4 = 36; + //fall through + case 20: + if (sprite->pos1.x <= 96) + { + sprite->pos1.x += 3; + sprite->pos1.y -= 1; + sprite->pos2.y = -Sin((u8)sprite->data2, 24); + sprite->data2 += 4; + } + sprite->data3 -= sprite->data4; + if ((sprite->data7 & 1) && sprite->data4 != 0) + sprite->data4--; + r4 = gSineTable[(u8)sprite->data3]; + r1 = gSineTable[(u8)(sprite->data3 + 64)]; + SetOamMatrix(2, r1, r4, -r4, r1); + break; + } +} + +static void sub_813E4B8(struct Sprite *sprite) +{ + u16 r4; + u16 r2; + u16 r1; + + sprite->data7++; + if (sprite->data7 & 1) + sprite->invisible = FALSE; + else + sprite->invisible = TRUE; + if (sprite->data2 >= 64) + { + DestroySprite(sprite); + return; + } + sprite->data2 += 2; + r4 = Sin((u8)sprite->data2, 40); + sprite->pos2.x = Cos((u8)(sprite->data0 * 32), r4); + sprite->pos2.y = Sin((u8)(sprite->data0 * 32), r4); + if (sprite->data0 == 0) + { + sprite->data3 -= sprite->data1; + if ((sprite->data7 & 1) && sprite->data1 != 0) + sprite->data1--; + r2 = gSineTable[(u8)sprite->data3]; + r1 = gSineTable[(u8)(sprite->data3 + 64)]; + SetOamMatrix(16, r1, r2, -r2, r1); + } +} + +static void sub_813E580(u16 x, u16 y) +{ + u8 i; + u8 spriteId; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gSpriteTemplate_840B0B0, x, y, 0); + gSprites[spriteId].oam.affineMode = 1; + gSprites[spriteId].oam.matrixNum = 16; + gSprites[spriteId].data0 = i; + gSprites[spriteId].data1 = 32; + } +} + +static void sub_813E5E0(struct Sprite *sprite) +{ + if (gUnknown_0203931A != 0) + { + DestroySprite(sprite); + } + else + { + sprite->invisible = gSprites[sprite->data0].invisible; + if (sprite->data7 < 12) + sprite->data7++; + sprite->data6 += 4; + sprite->pos1.x = sprite->data4 + gSineTable[(u8)(sprite->data3 + 64)] * sprite->data6 / 256; + //This useless '+ 0' is needed to make the asm match + sprite->pos1.y = sprite->data5 + gSineTable[(u8)(sprite->data3 + 0)] * sprite->data6 / 256; + sprite->pos2.y = gSineTable[(u8)(sprite->data1 + 0)] * sprite->data7 / 256; + sprite->data1 += 16; + if (sprite->pos1.y > sprite->data2) + DestroySprite(sprite); + } +} + +static void sub_813E6C0(struct Sprite *sprite) +{ + u8 spriteId; + u8 i; + s16 var1; + s16 var2; + + if (gUnknown_0203931A != 0) + { + DestroySprite(sprite); + } + else + { + sprite->data7++; + sprite->invisible = TRUE; + if (gSprites[sprite->data0].data0 == 1 && !(sprite->data7 & 3)) + { + var1 = sprite->data1 + gSprites[sprite->data0].pos1.x; + var2 = sprite->data2 + gSprites[sprite->data0].pos1.y; + for (i = 0; i < 3; i++) + { + u8 r3 = gSprites[sprite->data0].subpriority - 1; + //Make redundant copies of these variables to get the asm to match + s16 _var1 = var1; + s16 _var2 = var2; + + spriteId = CreateSprite(&gSpriteTemplate_840B0DC, _var1, _var2, r3); + if (spriteId != 64) + { + gSprites[spriteId].data0 = sprite->data0; + gSprites[spriteId].data1 = (((sprite->data7 >> 2) & 7) << 5) + i * 85; + gSprites[spriteId].data2 = sprite->data3; + gSprites[spriteId].data3 = 104; + gSprites[spriteId].data4 = var1; + gSprites[spriteId].data5 = var2; + gSprites[spriteId].data6 = 0; + } + } + } + } +} + +static void sub_813E7C0(u8 a) +{ + u8 spriteId; + + spriteId = CreateSprite(&gSpriteTemplate_840B0F4, 0, 0, 0); + if (spriteId != 64) + { + gSprites[spriteId].data0 = a; + gSprites[spriteId].data1 = -12; + gSprites[spriteId].data2 = 0; + gSprites[spriteId].data3 = 136; + } +} + +static void sub_813E804(struct Sprite *sprite) +{ + if (gUnknown_0203931A != 0) + { + DestroySprite(sprite); + } + else + { + sprite->invisible = gSprites[sprite->data0].invisible; + sprite->data7++; + if (sprite->data3 < 40) + sprite->data3 += 2; + //This useless '+ 0' is needed to make the asm match + sprite->pos1.x = gSprites[sprite->data0].pos1.x + gSprites[sprite->data0].pos2.x + gSineTable[(u8)(sprite->data1 + 64)] * sprite->data3 / 256; + sprite->pos1.y = gSprites[sprite->data0].pos1.y + gSprites[sprite->data0].pos2.y + gSineTable[(u8)(sprite->data1 + 0)] * sprite->data3 / 512; + sprite->data1 += 2; + sprite->pos2.y = gSineTable[(u8)(sprite->data2 + 0)] / 32; + sprite->data2 += 8; + if ((sprite->data1 & 0xFF) < 128) + sprite->subpriority = gSprites[sprite->data0].subpriority - 1; + else + sprite->subpriority = gSprites[sprite->data0].subpriority + 1; + } +} + +static void sub_813E930(u8 a) +{ + u8 i; + u8 spriteId; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gSpriteTemplate_840B124, gSprites[a].pos1.x, gSprites[a].pos1.y, 0); + if (spriteId != 64) + { + gSprites[spriteId].data0 = a; + gSprites[spriteId].data1 = i * 32; + } + } +} + +static void sub_813E980(struct Sprite *sprite) +{ + if (gUnknown_0203931A != 0) + { + DestroySprite(sprite); + } + else + { + u8 r0; + u16 matrixNum; + + sprite->invisible = gSprites[sprite->data0].invisible; + sprite->data7++; + sprite->data6 += 8; + sprite->pos1.x = sprite->data4 + gSineTable[(u8)(sprite->data3 + 64)] * sprite->data6 / 256; + sprite->pos1.y = sprite->data5 + gSineTable[(u8)(sprite->data3 + 0)] * sprite->data6 / 256; + r0 = sprite->data6 / 16; + if (r0 > 9) + r0 = 9; + matrixNum = (r0 + 18) & 31; + sprite->oam.matrixNum = matrixNum; + if (sprite->data6 > 160) + DestroySprite(sprite); + } +} + +static void sub_813EA60(struct Sprite *sprite) +{ + bool32 r6; + s16 r1, r2; + u8 spriteId; + + if (gUnknown_0203931A != 0) + { + DestroySprite(sprite); + } + else + { + sprite->data7++; + sprite->invisible = TRUE; + if (gSprites[sprite->data0].data0 == 1) + { + r6 = (sprite->data7 & 1); + if (!r6) + { + r1 = sprite->data1 + gSprites[sprite->data0].pos1.x; + r2 = sprite->data2 + gSprites[sprite->data0].pos1.y; + spriteId = CreateSprite(&gSpriteTemplate_840B150, r1, r2, gSprites[sprite->data0].subpriority + 1); + if (spriteId != 64) + { + gSprites[spriteId].oam.affineMode = 3; + gSprites[spriteId].oam.matrixNum = 18; + CalcCenterToCornerVec(&gSprites[spriteId], 0, 1, 3); + gSprites[spriteId].data0 = sprite->data0; + gSprites[spriteId].data3 = gUnknown_0840B168[(sprite->data7 >> 1) & 7]; + gSprites[spriteId].data4 = r1; + gSprites[spriteId].data5 = r2; + gSprites[spriteId].data6 = r6; + } + } + } + } +} + +static void InitIntroTorchicAttackAnim(u8 a) +{ + u8 spriteId; + u8 i; + + spriteId = CreateSprite(&gSpriteTemplate_840B170, 0, 0, 0); + if (spriteId != 64) + { + gSprites[spriteId].data0 = a; + gSprites[spriteId].data1 = 0; + gSprites[spriteId].data2 = 8; + gSprites[spriteId].data3 = 24; + } + for (i = 0; i < 10; i++) + { + SetOamMatrix(18 + i, gUnknown_0840B188[i], 0, 0, gUnknown_0840B188[i]); + } +} + +static void sub_813EBBC(struct Sprite *sprite) +{ + if (gUnknown_0203931A != 0) + { + DestroySprite(sprite); + } + else + { + sprite->invisible = gSprites[sprite->data0].invisible; + sprite->data7 += 1; + sprite->data6 += 8; + sprite->pos1.x = sprite->data4 + gSineTable[(u8)(sprite->data3 + 64)] * sprite->data6 / 256; + sprite->pos1.y = sprite->data5 + gSineTable[(u8)(sprite->data3 + 0)] * sprite->data6 / 256; + sprite->pos2.y = gSineTable[(u8)(sprite->data1 + 0)] / 64; + sprite->data1 += 16; + if (sprite->pos1.y < sprite->data2) + DestroySprite(sprite); + } +} + +static void sub_813EC90(struct Sprite *sprite) +{ + bool32 r6; + s16 r1, r2; + u8 spriteId; + u16 foo; + + if (gUnknown_0203931A != 0) + { + DestroySprite(sprite); + } + else + { + sprite->data7++; + sprite->invisible = TRUE; + if (gSprites[sprite->data0].data0 == 1) + { + r6 = sprite->data7 & 1; + if (!r6) + { + r1 = sprite->data1 + gSprites[sprite->data0].pos1.x; + r2 = sprite->data2 + gSprites[sprite->data0].pos1.y; + spriteId = CreateSprite(&gSpriteTemplate_840B1B0, r1, r2, gSprites[sprite->data0].subpriority + 1); + if (spriteId != 64) + { + gSprites[spriteId].oam.affineMode = 3; + gSprites[spriteId].oam.matrixNum = 17; + CalcCenterToCornerVec(&gSprites[spriteId], 0, 1, 3); + gSprites[spriteId].data0 = sprite->data0; + gSprites[spriteId].data1 = ((sprite->data7 >> 2) & 7) << 5; + gSprites[spriteId].data2 = sprite->data3; + gSprites[spriteId].data3 = 232; + gSprites[spriteId].data4 = r1; + gSprites[spriteId].data5 = r2; + gSprites[spriteId].data6 = r6; + } + } + if (sprite->data6 < 112) + sprite->data6 += 4; + } + foo = 256 - gSineTable[(u8)sprite->data6] / 2; + SetOamMatrix(17, foo, 0, 0, foo); + } +} + +static void InitIntroMudkipAttackAnim(u8 a) +{ + u8 spriteId; + + spriteId = CreateSprite(&gSpriteTemplate_840B1C8, 0, 0, 0); + if (spriteId != 64) + { + gSprites[spriteId].data0 = a; + gSprites[spriteId].data1 = 0; + gSprites[spriteId].data2 = 12; + gSprites[spriteId].data3 = 24; + } +} + +static void sub_813EDFC(struct Sprite *sprite) +{ + u16 foo; + + //I'm not sure why a switch statement was used here. + //if (sprite->data0 != 1) would have been more appropriate. + switch (sprite->data0) + { + case 0: + default: + sprite->invisible = FALSE; + sprite->oam.affineMode = 3; + sprite->oam.matrixNum = 18; + CalcCenterToCornerVec(sprite, 0, 3, 3); + sprite->data1 = 0; + sprite->data0 = 1; + //fall through + case 1: + break; + } + sprite->data7++; + if (sprite->data7 & 1) + { + sprite->invisible = TRUE; + } + else + { + sprite->invisible = FALSE; + if (sprite->data1 < 64) + sprite->data1++; + } + foo = 256 - gSineTable[(u8)sprite->data1] / 2; + SetOamMatrix(18, foo, 0, 0, foo); +} diff --git a/src/item.c b/src/item.c index 3f74b5925..2eb013490 100644 --- a/src/item.c +++ b/src/item.c @@ -1,30 +1,11 @@ #include "global.h" #include "item.h" +#include "items.h" +#include "berry.h" #include "string_util.h" +#include "strings.h" -extern struct Berry *GetBerryInfo(u8 berry); - -extern u8 gOtherText_Berry2[]; extern u8 gUnknown_02038560; - -struct Item -{ - u8 name[14]; - u16 itemId; - u16 price; - u8 holdEffect; - u8 holdEffectParam; - u8 *description; - u8 importance; - u8 unk19; - u8 pocket; - u8 type; - ItemUseFunc fieldUseFunc; - u8 battleUsage; - ItemUseFunc battleUseFunc; - u8 secondaryId; -}; - extern struct Item gItems[]; struct BagPocket @@ -48,9 +29,9 @@ static void CompactPCItems(void); void CopyItemName(u16 itemId, u8 *string) { - if (itemId == 0xAF) + if (itemId == ITEM_ENIGMA_BERRY) { - StringCopy(string, GetBerryInfo(0x2B)->name); + StringCopy(string, GetBerryInfo(0x2B)->name); // berry 0x2b = enigma berry StringAppend(string, gOtherText_Berry2); } else @@ -61,7 +42,7 @@ void CopyItemName(u16 itemId, u8 *string) s8 CountUsedBagPocketSlots(u8 pocket) { u8 i; - + for (i = 0; i < gBagPockets[pocket].capacity; i++) { if (gBagPockets[pocket].itemSlots[i].itemId == 0) @@ -73,7 +54,7 @@ s8 CountUsedBagPocketSlots(u8 pocket) bool8 IsBagPocketNonEmpty(u8 pocket) { u8 i; - + for (i = 0; i < gBagPockets[pocket - 1].capacity; i++) { if (gBagPockets[pocket - 1].itemSlots[i].itemId != 0) @@ -86,7 +67,7 @@ bool8 CheckBagHasItem(u16 itemId, u16 count) { u8 i; u8 pocket; - + if (ItemId_GetPocket(itemId) == 0) return FALSE; pocket = ItemId_GetPocket(itemId) - 1; @@ -112,7 +93,7 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count) u8 i; u8 pocket; u16 slotCapacity; - + if (ItemId_GetPocket(itemId) == 0) return FALSE; pocket = ItemId_GetPocket(itemId) - 1; @@ -120,7 +101,7 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count) slotCapacity = 99; else slotCapacity = 999; - + //Check space in any existing item slots that already contain this item for (i = 0; i < gBagPockets[pocket].capacity; i++) { @@ -135,7 +116,7 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count) return TRUE; } } - + //Check space in empty item slots if (count > 0) { @@ -152,7 +133,7 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count) if (count > 0) return FALSE; //No more item slots. The bag is full } - + return TRUE; } @@ -162,7 +143,7 @@ bool8 AddBagItem(u16 itemId, u16 count) u8 pocket; u16 slotCapacity; struct ItemSlot newItems[64]; - + if (ItemId_GetPocket(itemId) == 0) return FALSE; pocket = ItemId_GetPocket(itemId) - 1; @@ -172,7 +153,7 @@ bool8 AddBagItem(u16 itemId, u16 count) slotCapacity = 99; else slotCapacity = 999; - + //Use any item slots that already contain this item for (i = 0; i < gBagPockets[pocket].capacity; i++) { @@ -193,7 +174,7 @@ bool8 AddBagItem(u16 itemId, u16 count) goto copy_items; } } - + //Put any remaining items into new item slots. if (count > 0) { @@ -214,7 +195,7 @@ bool8 AddBagItem(u16 itemId, u16 count) if (count > 0) return FALSE; //No more empty item slots. The bag is full. } - + copy_items: //Copy pocket back into the bag. memcpy(gBagPockets[pocket].itemSlots, newItems, gBagPockets[pocket].capacity * sizeof(struct ItemSlot)); @@ -226,11 +207,11 @@ bool8 RemoveBagItem(u16 itemId, u16 count) u8 i; u8 pocket; u16 totalQuantity = 0; - + if (ItemId_GetPocket(itemId) == 0 || itemId == 0) return FALSE; pocket = ItemId_GetPocket(itemId) - 1; - + for (i = 0; i < gBagPockets[pocket].capacity; i++) { if (gBagPockets[pocket].itemSlots[i].itemId == itemId) @@ -238,7 +219,7 @@ bool8 RemoveBagItem(u16 itemId, u16 count) } if (totalQuantity < count) return FALSE; //We don't have enough of the item - + if (gBagPockets[pocket].capacity > gUnknown_02038560 && gBagPockets[pocket].itemSlots[gUnknown_02038560].itemId == itemId) { @@ -257,7 +238,7 @@ bool8 RemoveBagItem(u16 itemId, u16 count) if (count == 0) return TRUE; } - + for (i = 0; i < gBagPockets[pocket].capacity; i++) { if (gBagPockets[pocket].itemSlots[i].itemId == itemId) @@ -289,7 +270,7 @@ u8 GetPocketByItemId(u16 itemId) void ClearItemSlots(struct ItemSlot *itemSlots, u8 b) { u16 i; - + for (i = 0; i < b; i++) { itemSlots[i].itemId = 0; @@ -300,7 +281,7 @@ void ClearItemSlots(struct ItemSlot *itemSlots, u8 b) static s32 FindFreePCItemSlot(void) { s8 i; - + for (i = 0; i < 50; i++) { if (gSaveBlock1.pcItems[i].itemId == 0) @@ -313,7 +294,7 @@ u8 CountUsedPCItemSlots(void) { u8 usedSlots = 0; u8 i; - + for (i = 0; i < 50; i++) { if (gSaveBlock1.pcItems[i].itemId != 0) @@ -325,7 +306,7 @@ u8 CountUsedPCItemSlots(void) bool8 CheckPCHasItem(u16 itemId, u16 count) { u8 i; - + for (i = 0; i < 50; i++) { if (gSaveBlock1.pcItems[i].itemId == itemId && gSaveBlock1.pcItems[i].quantity >= count) @@ -339,10 +320,10 @@ bool8 AddPCItem(u16 itemId, u16 count) u8 i; s8 freeSlot; struct ItemSlot newItems[50]; - + //Copy PC items memcpy(newItems, gSaveBlock1.pcItems, sizeof(newItems)); - + //Use any item slots that already contain this item for (i = 0; i < 50; i++) { @@ -363,7 +344,7 @@ bool8 AddPCItem(u16 itemId, u16 count) } } } - + //Put any remaining items into a new item slot. if (count > 0) { @@ -373,7 +354,7 @@ bool8 AddPCItem(u16 itemId, u16 count) newItems[freeSlot].itemId = itemId; newItems[freeSlot].quantity = count; } - + //Copy items back to the PC memcpy(gSaveBlock1.pcItems, newItems, sizeof(gSaveBlock1.pcItems)); return TRUE; @@ -393,7 +374,7 @@ static void CompactPCItems(void) { u16 i; u16 j; - + for (i = 0; i < 49; i++) { for (j = i + 1; j <= 49; j++) @@ -410,7 +391,7 @@ static void CompactPCItems(void) void SwapRegisteredBike(void) { - switch(gSaveBlock1.registeredItem) + switch (gSaveBlock1.registeredItem) { case 0x103: gSaveBlock1.registeredItem = 0x110; @@ -464,7 +445,7 @@ bool8 ItemId_CopyDescription(u8 *a, u32 itemId, u32 c) u32 r5 = c + 1; u8 *description = gItems[SanitizeItemId(itemId)].description; u8 *str = a; - + for (;;) { if (*description == 0xFF || *description == 0xFE) diff --git a/src/item_use.c b/src/item_use.c new file mode 100644 index 000000000..a92161e9a --- /dev/null +++ b/src/item_use.c @@ -0,0 +1,1199 @@ +#include "global.h" +#include "item_use.h" +#include "battle.h" +#include "berry.h" +#include "bike.h" +#include "coins.h" +#include "data2.h" +#include "event_data.h" +#include "field_effect.h" +#include "field_fadetransition.h" +#include "field_map_obj_helpers.h" +#include "field_player_avatar.h" +#include "field_weather.h" +#include "fieldmap.h" +#include "item.h" +#include "item_menu.h" +#include "items.h" +#include "mail.h" +#include "main.h" +#include "map_obj_lock.h" +#include "menu.h" +#include "menu_helpers.h" +#include "metatile_behavior.h" +#include "palette.h" +#include "party_menu.h" +#include "pokeblock.h" +#include "pokemon_item_effect.h" +#include "pokemon_menu.h" +#include "rom4.h" +#include "rom_8094928.h" +#include "script.h" +#include "songs.h" +#include "sound.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "vars.h" + +extern void (* gUnknown_03005D00)(u8); +extern void (* gFieldCallback)(void); +extern void (* gUnknown_0300485C)(void); +extern void (* gUnknown_03004AE4)(u8, u16, TaskFunc); + +extern u8 gUnknown_02038561; +extern u8 gLastFieldPokeMenuOpened; +extern u8 gBankInMenu; + +extern u8 gUnknown_081A1654[]; +extern u8 gUnknown_081A168F[]; + +extern u16 gBattlePartyID[]; + +extern u16 gScriptItemId; +extern u16 gBattleTypeFlags; + +static const u8 gSSTidalBetaString[] = _("この チケットで ふねに のりほうだい\nはやく のってみたいな"); +static const u8 gSSTidalBetaString2[] = _("この チケットで ふねに のりほうだい\nはやく のってみたいな"); + +static const struct TextStruct gUnknown_083D61DC[2] = +{ + gSSTidalBetaString, + gSSTidalBetaString2, +}; + +static const MainCallback gExitToOverworldFuncList[] = +{ + sub_808B020, + c2_exit_to_overworld_2_switch, + sub_810B96C, +}; + +static const u8 gItemFinderDirections[] = { DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_WEST }; + +static const struct YesNoFuncTable gUnknown_083D61F4 = +{ + .yesFunc = sub_80C9FC0, + .noFunc = CleanUpItemMenuMessage, +}; + +void ExecuteSwitchToOverworldFromItemUse(u8 taskId) +{ + u8 taskData; + + if (gScriptItemId == 0xAF) + taskData = gTasks[taskId].data[15] - 1; + else + taskData = ItemId_GetType(gScriptItemId) - 1; + + gTasks[taskId].data[8] = (u32)gExitToOverworldFuncList[taskData] >> 16; + gTasks[taskId].data[9] = (u32)gExitToOverworldFuncList[taskData]; + gTasks[taskId].func = HandleItemMenuPaletteFade; +} + +void ItemMenu_ConfirmNormalFade(u8 var) +{ + ExecuteSwitchToOverworldFromItemUse(var); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); +} + +void ItemMenu_ConfirmComplexFade(u8 var) +{ + ExecuteSwitchToOverworldFromItemUse(var); + fade_screen(1, 0); +} + +void SetUpItemUseOnFieldCallback(u8 taskId) +{ + if (gTasks[taskId].data[2] != 1) + { + gFieldCallback = (void *)ExecuteItemUseFromBlackPalette; + ItemMenu_ConfirmNormalFade(taskId); + } + else + gUnknown_03005D00(taskId); +} + +void HandleDeniedItemUseMessage(u8 var1, u8 playerMenuStatus, const u8 *text) +{ + StringExpandPlaceholders(gStringVar4, text); + + switch (playerMenuStatus) + { + case 0: // Item Menu + MenuZeroFillWindowRect(0, 13, 13, 20); + DisplayItemMessageOnField(var1, gStringVar4, CleanUpItemMenuMessage, 1); + break; + default: // Field + DisplayItemMessageOnField(var1, gStringVar4, CleanUpOverworldMessage, 0); + break; + } +} + +void DisplayDadsAdviceCannotUseItemMessage(u8 var1, u8 playerMenuStatus) +{ + HandleDeniedItemUseMessage(var1, playerMenuStatus, gOtherText_DadsAdvice); +} + +void DisplayCantGetOffBikeItemMessage(u8 var1, u8 playerMenuStatus) +{ + HandleDeniedItemUseMessage(var1, playerMenuStatus, gOtherText_CantGetOffBike); +} + +u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId) +{ + if (ItemId_GetFieldFunc(itemId) == ItemUseOutOfBattle_TMHM) + return 1; + else if (ItemId_GetFieldFunc(itemId) == ItemUseOutOfBattle_EvolutionStone) + return 2; + else + return 0; +} + +void ItemMenu_ReadMail(u8 taskId) +{ + struct MailStruct mailStruct; + + if (!gPaletteFade.active) + { + mailStruct.itemId = gScriptItemId; + HandleReadMail(&mailStruct, sub_80A5D04, 0); + DestroyTask(taskId); + } +} + +void ItemUseOutOfBattle_Mail(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = ItemMenu_ReadMail; +} + +void ItemUseOutOfBattle_Bike(u8 taskId) +{ + s16 x, y; + u8 tileBehavior; + + PlayerGetDestCoords(&x, &y); + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + + if (FlagGet(SYS_CYCLING_ROAD) == TRUE // on cycling road? + || MetatileBehavior_IsVerticalRail(tileBehavior) == TRUE + || MetatileBehavior_IsHorizontalRail(tileBehavior) == TRUE + || MetatileBehavior_IsIsolatedVerticalRail(tileBehavior) == TRUE + || MetatileBehavior_IsIsolatedHorizontalRail(tileBehavior) == TRUE) + { + DisplayCantGetOffBikeItemMessage(taskId, gTasks[taskId].data[2]); + } + else + { + if (IsBikingAllowedByMap() == TRUE && IsBikingDisallowedByPlayer() == FALSE) + { + gUnknown_03005D00 = (void *)ItemUseOnFieldCB_Bike; + SetUpItemUseOnFieldCallback(taskId); + } + else + DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].data[2]); + } +} + +void ItemUseOnFieldCB_Bike(u8 taskId) +{ + if (ItemId_GetSecondaryId(gScriptItemId) == 0) + GetOnOffBike(2); + if (ItemId_GetSecondaryId(gScriptItemId) == 1) + GetOnOffBike(4); + + sub_8064E2C(); + ScriptContext2_Disable(); + DestroyTask(taskId); +} + +bool32 CanFish(void) +{ + s16 x, y; + u16 tileBehavior; + + GetXYCoordsOneStepInFrontOfPlayer(&x, &y); + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + + if (MetatileBehavior_IsWaterfall(tileBehavior)) + return FALSE; + + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_4)) + return FALSE; + + if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) + { + if (IsPlayerFacingSurfableFishableWater()) + return TRUE; + } + else + { + if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior) && !MapGridIsImpassableAt(x, y)) + return TRUE; + if (MetatileBehavior_IsBridge(tileBehavior) == TRUE) + return TRUE; + } + + return FALSE; +} + +void ItemUseOutOfBattle_Rod(u8 taskId) +{ + if (CanFish() == TRUE) + { + gUnknown_03005D00 = (void *)ItemUseOnFieldCB_Rod; + SetUpItemUseOnFieldCallback(taskId); + } + else + DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].data[2]); +} + +void ItemUseOnFieldCB_Rod(u8 taskId) +{ + StartFishing(ItemId_GetSecondaryId(gScriptItemId)); + DestroyTask(taskId); +} + +void ItemUseOutOfBattle_Itemfinder(u8 var) +{ + IncrementGameStat(0x27); + gUnknown_03005D00 = (void *)ItemUseOnFieldCB_Itemfinder; + SetUpItemUseOnFieldCallback(var); +} + +void ItemUseOnFieldCB_Itemfinder(u8 taskId) +{ + if (ItemfinderCheckForHiddenItems(gMapHeader.events, taskId) == TRUE) + gTasks[taskId].func = RunItemfinderResults; + else + DisplayItemMessageOnField(taskId, gOtherText_NoResponse, ExitItemfinder, 0); +} + +void RunItemfinderResults(u8 taskId) +{ + u8 playerDir; + u8 playerDirToItem; + u8 i; + s16 *data = gTasks[taskId].data; + + if (!data[3]) + { + if (data[4] == 4) + { + playerDirToItem = GetPlayerDirectionTowardsHiddenItem(data[0], data[1]); + if (playerDirToItem) + { + SetPlayerDirectionTowardsItem(gItemFinderDirections[playerDirToItem - 1]); + gTasks[taskId].func = DisplayItemRespondingMessageAndExitItemfinder; + } + else // player is above hidden item. + { + playerDir = player_get_direction_lower_nybble(); + + // rotate player clockwise depending on current direction. + for (i = 0; i < 4; i++) + if (playerDir == gItemFinderDirections[i]) + data[5] = (i + 1) & 3; + + gTasks[taskId].func = RotatePlayerAndExitItemfinder; + data[3] = 0; + data[2] = 0; + } + return; + } + PlaySE(SE_DAUGI); // play the itemfinder jingle 4 times before executing the itemfinder. + data[4]++; + } + data[3] = (data[3] + 1) & 0x1F; +} + +void ExitItemfinder(u8 taskId) +{ + MenuZeroFillWindowRect(0, 14, 29, 19); + sub_8064E2C(); + ScriptContext2_Disable(); + DestroyTask(taskId); +} + +bool8 ItemfinderCheckForHiddenItems(struct MapEvents *events, u8 taskId) +{ + int distanceX, distanceY; + u16 x, y; + s16 newDistanceX, newDistanceY, i; + + PlayerGetDestCoords(&x, &y); + gTasks[taskId].data[2] = FALSE; + + for (i = 0; i < events->bgEventCount; i++) + { + if ((events -> bgEvents[i].kind == 7) && !FlagGet(events -> bgEvents[i].bgUnion.hiddenItem.hiddenItemId + 600)) + { + // do a distance lookup of each item so long as the index remains less than the objects on the current map. + distanceX = (u16)events -> bgEvents[i].x + 7; + newDistanceX = distanceX - x; + distanceY = (u16)events -> bgEvents[i].y + 7; + newDistanceY = distanceY - y; + + // is item in range? + if ((u16)(newDistanceX + 7) < 15 && (newDistanceY >= -5) && (newDistanceY < 6)) + sub_80C9838(taskId, newDistanceX, newDistanceY); // send coordinates of the item relative to the player + } + } + sub_80C9720(taskId); + + // hidden item detected? + if(gTasks[taskId].data[2] == TRUE) + return TRUE; + else + return FALSE; +} + +bool8 HiddenItemAtPos(struct MapEvents *events, s16 x, s16 y) +{ + u8 bgEventCount = events->bgEventCount; + struct BgEvent *bgEvent = events->bgEvents; + int i; + + for(i = 0; i < bgEventCount; i++) + { + if(bgEvent[i].kind == 7 && x == (u16)bgEvent[i].x && y == (u16)bgEvent[i].y) // hidden item and coordinates matches x and y passed? + { + if(!FlagGet(bgEvent[i].bgUnion.hiddenItem.hiddenItemId + 600)) + return TRUE; + else + return FALSE; + } + } + return FALSE; +} + +bool8 sub_80C9688(struct MapConnection *connection, int x, int y) +{ + struct MapHeader *mapHeader; + u16 localX, localY; + u32 localOffset; + s32 localLength; + + mapHeader = mapconnection_get_mapheader(connection); + + switch(connection->direction) + { + // same weird temp variable behavior seen in HiddenItemAtPos + case 2: + localOffset = connection->offset + 7; + localX = x - localOffset; + localLength = mapHeader->mapData->height - 7; + localY = localLength + y; // additions are reversed for some reason + break; + case 1: + localOffset = connection->offset + 7; + localX = x - localOffset; + localLength = gMapHeader.mapData->height + 7; + localY = y - localLength; + break; + case 3: + localLength = mapHeader->mapData->width - 7; + localX = localLength + x; // additions are reversed for some reason + localOffset = connection->offset + 7; + localY = y - localOffset; + break; + case 4: + localLength = gMapHeader.mapData->width + 7; + localX = x - localLength; + localOffset = connection->offset + 7; + localY = y - localOffset; + break; + default: + return FALSE; + } + return HiddenItemAtPos(mapHeader->events, localX, localY); +} + +// weird math +#ifdef NONMATCHING +void sub_80C9720(u8 taskId) +{ + s16 x, y; + s16 curX, curY; + s16 width = gMapHeader.mapData->width + 7; + s16 height = gMapHeader.mapData->height + 7; + + PlayerGetDestCoords(&x, &y); + + for (curX = x - 7; curX <= x + 7; curX++) + { + for (curY = y - 5; curY <= y + 5; curY++) + { + if (7 > curX + || curX >= width + || 7 > curY + || curY >= height) + { + struct MapConnection *conn = sub_8056BA0(curX, curY); + if (conn && sub_80C9688(conn, curX, curY) == TRUE) + sub_80C9838(taskId, curX - x, curY - y); + } + } + } +} +#else +__attribute__((naked)) +void sub_80C9720(u8 taskId) +{ + 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, 0x14\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x4]\n\ + ldr r0, _080C9834 @ =gMapHeader\n\ + ldr r1, [r0]\n\ + ldr r0, [r1]\n\ + adds r0, 0x7\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x8]\n\ + ldr r0, [r1, 0x4]\n\ + adds r0, 0x7\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0xC]\n\ + mov r4, sp\n\ + adds r4, 0x2\n\ + mov r0, sp\n\ + adds r1, r4, 0\n\ + bl PlayerGetDestCoords\n\ + mov r0, sp\n\ + ldrh r0, [r0]\n\ + subs r0, 0x7\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + asrs r0, 16\n\ + mov r1, sp\n\ + movs r2, 0\n\ + ldrsh r1, [r1, r2]\n\ + adds r1, 0x7\n\ + cmp r0, r1\n\ + bgt _080C9824\n\ +_080C976E:\n\ + mov r5, sp\n\ + ldrh r0, [r5, 0x2]\n\ + subs r0, 0x5\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + lsls r2, r4, 16\n\ + asrs r1, r2, 16\n\ + movs r6, 0x2\n\ + ldrsh r0, [r5, r6]\n\ + adds r0, 0x5\n\ + lsls r3, 16\n\ + mov r8, r3\n\ + cmp r1, r0\n\ + bgt _080C980E\n\ + movs r0, 0x7\n\ + str r0, [sp, 0x10]\n\ + mov r1, r8\n\ + asrs r1, 16\n\ + mov r9, r1\n\ + mov r10, r0\n\ +_080C9796:\n\ + ldr r3, [sp, 0x10]\n\ + cmp r3, r9\n\ + bgt _080C97B8\n\ + ldr r5, [sp, 0x8]\n\ + lsls r0, r5, 16\n\ + asrs r0, 16\n\ + cmp r9, r0\n\ + bge _080C97B8\n\ + asrs r1, r2, 16\n\ + cmp r10, r1\n\ + bgt _080C97B8\n\ + ldr r6, [sp, 0xC]\n\ + lsls r0, r6, 16\n\ + asrs r0, 16\n\ + lsls r7, r4, 16\n\ + cmp r1, r0\n\ + blt _080C97F6\n\ +_080C97B8:\n\ + mov r0, r8\n\ + asrs r5, r0, 16\n\ + lsls r4, 16\n\ + asrs r6, r4, 16\n\ + adds r0, r5, 0\n\ + adds r1, r6, 0\n\ + bl sub_8056BA0\n\ + adds r7, r4, 0\n\ + cmp r0, 0\n\ + beq _080C97F6\n\ + adds r1, r5, 0\n\ + adds r2, r6, 0\n\ + bl sub_80C9688\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + bne _080C97F6\n\ + mov r0, sp\n\ + ldrh r1, [r0]\n\ + subs r1, r5, r1\n\ + lsls r1, 16\n\ + asrs r1, 16\n\ + ldrh r2, [r0, 0x2]\n\ + subs r2, r6, r2\n\ + lsls r2, 16\n\ + asrs r2, 16\n\ + ldr r0, [sp, 0x4]\n\ + bl sub_80C9838\n\ +_080C97F6:\n\ + movs r1, 0x80\n\ + lsls r1, 9\n\ + adds r0, r7, r1\n\ + lsrs r4, r0, 16\n\ + lsls r2, r4, 16\n\ + asrs r1, r2, 16\n\ + mov r3, sp\n\ + movs r5, 0x2\n\ + ldrsh r0, [r3, r5]\n\ + adds r0, 0x5\n\ + cmp r1, r0\n\ + ble _080C9796\n\ +_080C980E:\n\ + movs r1, 0x80\n\ + lsls r1, 9\n\ + add r1, r8\n\ + lsrs r3, r1, 16\n\ + asrs r1, 16\n\ + mov r0, sp\n\ + movs r6, 0\n\ + ldrsh r0, [r0, r6]\n\ + adds r0, 0x7\n\ + cmp r1, r0\n\ + ble _080C976E\n\ +_080C9824:\n\ + add sp, 0x14\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\ + .align 2, 0\n\ +_080C9834: .4byte gMapHeader\n\ + .syntax divided"); +} +#endif + +void sub_80C9838(u8 taskId, s16 x, s16 y) +{ + s16 *data = gTasks[taskId].data; + s16 var1, var2, var3, var4; + + if(data[2] == FALSE) + { + data[0] = x; + data[1] = y; + data[2] = TRUE; + } + else + { + // data[0] and data[1] contain the player's coordinates. + // x and y contain the item's coordinates. + if(data[0] < 0) + var1 = data[0] * -1; // item is to the left + else + var1 = data[0]; // item is to the right + + if(data[1] < 0) + var2 = data[1] * -1; // item is to the north + else + var2 = data[1]; // item is to the south + + if(x < 0) + var3 = x * -1; + else + var3 = x; + + if(y < 0) + var4 = y * -1; + else + var4 = y; + + if(var1 + var2 > var3 + var4) + { + data[0] = x; + data[1] = y; + } + else + { + if(var1 + var2 == var3 + var4 && (var2 > var4 || (var2 == var4 && data[1] < y))) + { + data[0] = x; + data[1] = y; + } + } + } +} + +u8 GetPlayerDirectionTowardsHiddenItem(s16 itemX, s16 itemY) +{ + s16 abX, abY; + + if(itemX == 0 && itemY == 0) + return DIR_NONE; // player is standing on the item. + + // get absolute X distance. + if(itemX < 0) + abX = itemX * -1; + else + abX = itemX; + + // get absolute Y distance. + if(itemY < 0) + abY = itemY * -1; + else + abY = itemY; + + if(abX > abY) + { + if(itemX < 0) + return DIR_EAST; + else + return DIR_NORTH; + } + else + { + if(abX < abY) + { + if(itemY < 0) + return DIR_SOUTH; + else + return DIR_WEST; + } + if(abX == abY) + { + if(itemY < 0) + return DIR_SOUTH; + else + return DIR_WEST; + } + return DIR_NONE; // should never get here. return something so it doesnt crash. + } +} + +void SetPlayerDirectionTowardsItem(u8 direction) +{ + FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)]); + FieldObjectClearAnim(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)]); + UnfreezeMapObject(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)]); + PlayerTurnInPlace(direction); +} + +void DisplayItemRespondingMessageAndExitItemfinder(u8 taskId) +{ + if(FieldObjectCheckIfSpecialAnimFinishedOrInactive(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)]) == TRUE) + DisplayItemMessageOnField(taskId, gOtherText_ItemfinderResponding, ExitItemfinder, 0); +} + +void RotatePlayerAndExitItemfinder(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + if(FieldObjectCheckIfSpecialAnimFinishedOrInactive(&gMapObjects[GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0)]) == TRUE + || data[2] == FALSE) + { + SetPlayerDirectionTowardsItem(gItemFinderDirections[data[5]]); + data[2] = 1; + data[5] = (data[5] + 1) & 3; + data[3]++; + + if(data[3] == 4) + DisplayItemMessageOnField(taskId, gOtherText_ItemfinderItemUnderfoot, ExitItemfinder, 0); + } +} + +void ItemUseOutOfBattle_PokeblockCase(u8 taskId) +{ + if(sub_80F9344() == TRUE) + { + DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].data[2]); + } + else if(gTasks[taskId].data[2] != TRUE) + { + sub_810BA7C(0); + ItemMenu_ConfirmNormalFade(taskId); + } + else + { + gFieldCallback = (void *)sub_8080E28; + sub_810BA7C(1); + ItemMenu_ConfirmComplexFade(taskId); + } +} + +void ItemUseOutOfBattle_CoinCase(u8 taskId) +{ + ConvertIntToDecimalStringN(gStringVar1, GetCoins(), 0, 4); + StringExpandPlaceholders(gStringVar4, gOtherText_Coins3); + + if(!gTasks[taskId].data[2]) + { + MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + DisplayItemMessageOnField(taskId, gStringVar4, CleanUpItemMenuMessage, 1); + } + else + { + DisplayItemMessageOnField(taskId, gStringVar4, CleanUpOverworldMessage, 0); + } +} + +void sub_80C9BB8(u8 var) +{ + if(gMain.newKeys & A_BUTTON) + CleanUpItemMenuMessage(var); +} + +void sub_80C9BD8(u8 var) +{ + if(gMain.newKeys & A_BUTTON) + CleanUpOverworldMessage(var); +} + +// unused +void ItemUseOutOfBattle_SSTicket(u8 taskId) +{ + if(gTasks[taskId].data[2] == 0) + { + MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + DisplayItemMessageOnField(taskId, (u8 *)gUnknown_083D61DC[ItemId_GetSecondaryId(gScriptItemId)].text, sub_80C9BB8, 1); + } + else + { + DisplayItemMessageOnField(taskId, (u8 *)gUnknown_083D61DC[ItemId_GetSecondaryId(gScriptItemId)].text, sub_80C9BD8, 0); + } +} + +void sub_80C9C7C(u8 taskId) +{ + if(IsPlayerFacingPlantedBerryTree() == TRUE) + { + gUnknown_03005D00 = sub_80C9D00; + gFieldCallback = ExecuteItemUseFromBlackPalette; + gTasks[taskId].data[8] = (u32)c2_exit_to_overworld_2_switch >> 16; + gTasks[taskId].data[9] = (u32)c2_exit_to_overworld_2_switch; + gTasks[taskId].func = HandleItemMenuPaletteFade; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + } + else + { + ItemId_GetFieldFunc(gScriptItemId)(taskId); + } +} + +void sub_80C9D00(u8 taskId) +{ + RemoveBagItem(gScriptItemId, 1); + ScriptContext2_Enable(); + ScriptContext1_SetupScript(gUnknown_081A1654); + DestroyTask(taskId); +} + +void ItemUseOutOfBattle_WailmerPail(u8 taskId) +{ + if(TryToWaterBerryTree() == TRUE) + { + gUnknown_03005D00 = sub_80C9D74; + SetUpItemUseOnFieldCallback(taskId); + } + else + { + DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].data[2]); + } +} + +void sub_80C9D74(u8 taskId) +{ + ScriptContext2_Enable(); + ScriptContext1_SetupScript(gUnknown_081A168F); + DestroyTask(taskId); +} + +void sub_80C9D98(u8 taskId) +{ + gUnknown_02038561 = 0; + ItemMenu_ConfirmNormalFade(taskId); +} + +void ItemUseOutOfBattle_Medicine(u8 taskId) +{ + gUnknown_03004AE4 = UseMedicine; + sub_80C9D98(taskId); +} + +void ItemUseOutOfBattle_SacredAsh(u8 taskId) +{ + u8 i; + + gLastFieldPokeMenuOpened = 0; + + for(i = 0; i < 6; i++) + { + if(GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0 && GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) + { + gLastFieldPokeMenuOpened = i; + break; + } + } + gUnknown_03004AE4 = sub_8070048; + gUnknown_02038561 = 4; + ItemMenu_ConfirmNormalFade(taskId); +} + +void ItemUseOutOfBattle_PPRecovery(u8 taskId) +{ + gUnknown_03004AE4 = DoPPRecoveryItemEffect; + sub_80C9D98(taskId); +} + +void ItemUseOutOfBattle_PPUp(u8 taskId) +{ + gUnknown_03004AE4 = DoPPUpItemEffect; + sub_80C9D98(taskId); +} + +void ItemUseOutOfBattle_RareCandy(u8 taskId) +{ + gUnknown_03004AE4 = DoRareCandyItemEffect; + sub_80C9D98(taskId); +} + +void ItemUseOutOfBattle_TMHM(u8 taskId) +{ + MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + + if(gScriptItemId >= ITEM_HM01) + DisplayItemMessageOnField(taskId, gOtherText_BootedHM, sub_80C9EE4, 1); // HM + else + DisplayItemMessageOnField(taskId, gOtherText_BootedTM, sub_80C9EE4, 1); // TM +} + +void sub_80C9EE4(u8 taskId) +{ + PlaySE(2); + gTasks[taskId].func = sub_80C9F10; +} + +void sub_80C9F10(u8 taskId) +{ + if(gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + { + StringCopy(gStringVar1, gMoveNames[ItemIdToBattleMoveId(gScriptItemId)]); + StringExpandPlaceholders(gStringVar4, gOtherText_ContainsMove); + DisplayItemMessageOnField(taskId, gStringVar4, sub_80C9F80, 1); + } +} + +void sub_80C9F80(u8 var) +{ + DisplayYesNoMenu(7, 7, 1); + sub_80A3FA0(gBGTilemapBuffers[1], 8, 8, 5, 4, 1); + DoYesNoFuncWithChoice(var, &gUnknown_083D61F4); +} + +void sub_80C9FC0(u8 var) +{ + gUnknown_03004AE4 = TeachMonTMMove; + sub_80C9D98(var); +} + +void sub_80C9FDC(void) +{ + RemoveBagItem(gScriptItemId, 1); + sub_80A3E0C(); + CopyItemName(gScriptItemId, gStringVar2); + StringExpandPlaceholders(gStringVar4, gOtherText_UsedItem); +} + +void ItemUseOutOfBattle_Repel(u8 var) +{ + if(VarGet(VAR_REPEL_STEP_COUNT) == FALSE) + { + VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gScriptItemId)); + sub_80C9FDC(); + DisplayItemMessageOnField(var, gStringVar4, CleanUpItemMenuMessage, 1); + } + else + { + DisplayItemMessageOnField(var, gOtherText_RepelLingers, CleanUpItemMenuMessage, 1); + } +} + +void sub_80CA07C(void) +{ + sub_80A3E0C(); + CopyItemName(gScriptItemId, gStringVar2); +} + +void sub_80CA098(u8 taskId) +{ + if(++gTasks[taskId].data[15] > 7) + { + PlaySE(0x75); + DisplayItemMessageOnField(taskId, gStringVar4, CleanUpItemMenuMessage, 1); + } +} + +void ItemUseOutOfBattle_BlackWhiteFlute(u8 taskId) +{ + if(gScriptItemId == 43) + { + FlagSet(SYS_ENC_UP_ITEM); + FlagReset(SYS_ENC_DOWN_ITEM); + sub_80CA07C(); + StringExpandPlaceholders(gStringVar4, gOtherText_UsedFlute); + gTasks[taskId].func = sub_80CA098; + gTasks[taskId].data[15] = 0; + } + else if(gScriptItemId == 42) + { + FlagSet(SYS_ENC_DOWN_ITEM); + FlagReset(SYS_ENC_UP_ITEM); + sub_80CA07C(); + StringExpandPlaceholders(gStringVar4, gOtherText_UsedRepel); + gTasks[taskId].func = sub_80CA098; + gTasks[taskId].data[15] = 0; + } +} + +void task08_080A1C44(u8 taskId) +{ + player_avatar_init_params_reset(); + sub_80878A8(); + DestroyTask(taskId); +} + +void sub_80CA18C(u8 taskId) +{ + sub_8053014(); + sub_80C9FDC(); + gTasks[taskId].data[0] = 0; + DisplayItemMessageOnField(taskId, gStringVar4, task08_080A1C44, 0); +} + +bool8 sub_80CA1C8(void) +{ + if(gMapHeader.mapType == MAP_TYPE_UNDERGROUND) + return TRUE; + else + return FALSE; +} + +void ItemUseOutOfBattle_EscapeRope(u8 taskId) +{ + if(sub_80CA1C8() == TRUE) // is map type an area you can use escape rope? + { + gUnknown_03005D00 = sub_80CA18C; + SetUpItemUseOnFieldCallback(taskId); + } + else + { + DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].data[2]); + } +} + +void ItemUseOutOfBattle_EvolutionStone(u8 var) +{ + gUnknown_03004AE4 = DoEvolutionStoneItemEffect; + sub_80C9D98(var); +} + +void ItemUseInBattle_PokeBall(u8 var) +{ + if(PlayerPartyAndPokemonStorageFull() == FALSE) // have room for mon? + { + RemoveBagItem(gScriptItemId, 1); + sub_80A7094(var); + } + else + { + MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + DisplayItemMessageOnField(var, gOtherText_BoxIsFull, CleanUpItemMenuMessage, 1); + } +} + +void sub_80CA294(u8 var) +{ + if(gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + sub_80A7094(var); +} + +void sub_80CA2BC(u8 taskId) +{ + if(++gTasks[taskId].data[15] > 7) + { + PlaySE(1); + RemoveBagItem(gScriptItemId, 1); + DisplayItemMessageOnField(taskId, sub_803F378(gScriptItemId), sub_80CA294, 1); + } +} + +void ItemUseInBattle_StatIncrease(u8 taskId) +{ + u16 partyId = gBattlePartyID[gBankInMenu]; + + MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + + if(ExecuteTableBasedItemEffect_(&gPlayerParty[partyId], gScriptItemId, partyId, 0) != FALSE) + { + DisplayItemMessageOnField(taskId, gOtherText_WontHaveAnyEffect, CleanUpItemMenuMessage, 1); + } + else + { + gTasks[taskId].func = sub_80CA2BC; + gTasks[taskId].data[15] = 0; + } +} + +void sub_80CA394(u8 taskId) +{ + if(!gPaletteFade.active) + { + sub_8094E4C(); + gpu_pal_allocator_reset__manage_upper_four(); + DestroyTask(taskId); + } +} + +void sub_80CA3C0(u8 taskId) +{ + gTasks[taskId].func = sub_80CA394; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); +} + +void ItemUseInBattle_Medicine(u8 var) +{ + gUnknown_03004AE4 = UseMedicine; + sub_80CA3C0(var); +} + +void unref_sub_80CA410(u8 var) +{ + gUnknown_03004AE4 = sub_8070048; + sub_80CA3C0(var); +} + +void ItemUseInBattle_PPRecovery(u8 var) +{ + gUnknown_03004AE4 = DoPPRecoveryItemEffect; + sub_80CA3C0(var); +} + +void unref_sub_80CA448(u8 var) +{ + MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + + if(ExecuteTableBasedItemEffect__(0, gScriptItemId, 0) == FALSE) + { + RemoveBagItem(gScriptItemId, 1); + GetMonNickname(&gPlayerParty[0], gStringVar1); + StringExpandPlaceholders(gStringVar4, gOtherText_SnapConfusion); + DisplayItemMessageOnField(var, gStringVar4, sub_80A7094, 1); + } + else + { + DisplayItemMessageOnField(var, gOtherText_WontHaveAnyEffect, CleanUpItemMenuMessage, 1); + } +} + +void ItemUseInBattle_Escape(u8 taskId) +{ + MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + + if((gBattleTypeFlags & BATTLE_TYPE_TRAINER) == FALSE) + { + sub_80C9FDC(); + DisplayItemMessageOnField(taskId, gStringVar4, sub_80A7094, 1); + } + else + { + DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].data[2]); + } +} + +void ItemUseOutOfBattle_EnigmaBerry(u8 taskId) +{ + switch(GetItemEffectType(gScriptItemId) - 1) + { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + gTasks[taskId].data[15] = 1; + ItemUseOutOfBattle_Medicine(taskId); + break; + case 9: + gTasks[taskId].data[15] = 1; + ItemUseOutOfBattle_SacredAsh(taskId); + break; + case 0: + gTasks[taskId].data[15] = 1; + ItemUseOutOfBattle_RareCandy(taskId); + break; + case 18: + case 19: + gTasks[taskId].data[15] = 1; + ItemUseOutOfBattle_PPUp(taskId); + break; + case 20: + gTasks[taskId].data[15] = 1; + ItemUseOutOfBattle_PPRecovery(taskId); + break; + default: + gTasks[taskId].data[15] = 4; + ItemUseOutOfBattle_CannotUse(taskId); + } +} + +void ItemUseInBattle_EnigmaBerry(u8 taskId) +{ + switch(GetItemEffectType(gScriptItemId)) + { + case 0: + ItemUseInBattle_StatIncrease(taskId); + break; + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 11: + ItemUseInBattle_Medicine(taskId); + break; + case 21: + ItemUseInBattle_PPRecovery(taskId); + break; + default: + ItemUseOutOfBattle_CannotUse(taskId); + } +} + +void ItemUseOutOfBattle_CannotUse(u8 taskId) +{ + DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].data[2]); +} diff --git a/src/landmark.c b/src/landmark.c index 4657a0083..6a53716bb 100644 --- a/src/landmark.c +++ b/src/landmark.c @@ -1,6 +1,6 @@ #include "global.h" #include "landmark.h" -#include "flag.h" +#include "event_data.h" #define MAPSEC_NONE 0x58 diff --git a/src/libc.c b/src/libc.c index 370981878..920673e3e 100644 --- a/src/libc.c +++ b/src/libc.c @@ -19,13 +19,13 @@ void *memcpy(void *dst0, const void *src0, size_t len0) // If the size is small, or either src or dst is unaligned, // then go to the byte copy loop. This should be rare. - if(len >= 16 && !(UNALIGNED(src) | UNALIGNED(dst))) + if (len >= 16 && !(UNALIGNED(src) | UNALIGNED(dst))) { aligned_dst = (long *)dst; aligned_src = (long *)src; // Copy 4X long words at a time if possible. - while(len >= 16) + while (len >= 16) { *aligned_dst++ = *aligned_src++; *aligned_dst++ = *aligned_src++; @@ -35,7 +35,7 @@ void *memcpy(void *dst0, const void *src0, size_t len0) } // Copy one long word at a time if possible - while(len >= 4) + while (len >= 4) { *aligned_dst++ = *aligned_src++; len -= 4; @@ -46,7 +46,7 @@ void *memcpy(void *dst0, const void *src0, size_t len0) } // Pick up any remaining bytes with a byte copier. - while(len--) + while (len--) *dst++ = *src++; return dst0; @@ -62,7 +62,7 @@ void *memset(void *m, int c, size_t n) // If the size is small or m is unaligned, // then go to the byte copy loop. This should be rare. - if(n >= LBLOCKSIZE && !UNALIGNED(m)) + if (n >= LBLOCKSIZE && !UNALIGNED(m)) { // We know that n is large and m is word-aligned. aligned_addr = (unsigned long *)m; @@ -70,7 +70,7 @@ void *memset(void *m, int c, size_t n) // Store C into each char sized location in buffer so that // we can set large blocks quickly. c &= 0xFF; - if(LBLOCKSIZE == 4) + if (LBLOCKSIZE == 4) { buffer = (c << 8) | c; buffer |= (buffer << 16); @@ -78,11 +78,11 @@ void *memset(void *m, int c, size_t n) else { buffer = 0; - for(i = 0; i < LBLOCKSIZE; i++) + for (i = 0; i < LBLOCKSIZE; i++) buffer = (buffer << 8) | c; } - while(n >= LBLOCKSIZE * 4) + while (n >= LBLOCKSIZE * 4) { *aligned_addr++ = buffer; *aligned_addr++ = buffer; @@ -90,7 +90,7 @@ void *memset(void *m, int c, size_t n) *aligned_addr++ = buffer; n -= LBLOCKSIZE * 4; } - while(n >= LBLOCKSIZE) + while (n >= LBLOCKSIZE) { *aligned_addr++ = buffer; n -= LBLOCKSIZE; @@ -100,7 +100,7 @@ void *memset(void *m, int c, size_t n) } // Pick up the remainder with a bytewise loop. - while(n--) + while (n--) *s++ = (char)c; return m; @@ -112,16 +112,16 @@ int strcmp(const char *s1, const char *s2) unsigned long *a2; // If s1 or s2 are unaligned, then skip this and compare bytes. - if(!(UNALIGNED(s1) | UNALIGNED(s2))) + if (!(UNALIGNED(s1) | UNALIGNED(s2))) { // Compare them a word at a time. a1 = (unsigned long *)s1; a2 = (unsigned long *)s2; - while(*a1 == *a2) + while (*a1 == *a2) { // If *a1 == *a2, and we find a null in *a1, // then the strings must be equal, so return zero. - if(CONTAINSNULL(*a1)) + if (CONTAINSNULL(*a1)) return 0; a1++; @@ -133,7 +133,7 @@ int strcmp(const char *s1, const char *s2) } // Check the remaining few bytes. - while(*s1 != '\0' && *s1 == *s2) + while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; diff --git a/src/link.c b/src/link.c index d2b5770e9..363a8b494 100644 --- a/src/link.c +++ b/src/link.c @@ -1,16 +1,20 @@ #include "global.h" #include "link.h" -#include "asm.h" +#include "battle.h" +#include "berry.h" +#include "berry_blender.h" +#include "hall_of_fame.h" #include "main.h" -#include "task.h" -#include "text.h" -#include "sprite.h" -#include "songs.h" +#include "menu.h" #include "palette.h" #include "rng.h" -#include "menu.h" -#include "sound.h" #include "save.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "strings2.h" +#include "task.h" +#include "text.h" #define SIO_MULTI_CNT ((struct SioMultiCnt *)REG_ADDR_SIOCNT) @@ -33,13 +37,11 @@ struct LinkTestBGInfo extern u8 unk_2000000[]; extern u8 unk_2004000[]; -extern u16 gUnknown_020239F8; +extern u16 gBattleTypeFlags; extern u16 gScriptItemId; extern u16 word_3004858; -extern u8 gMultiText_LinkError[]; - static void InitLinkTestBG(u8, u8, u8, u8); void InitLinkTestBG_Unused(u8, u8, u8, u8); void LinkTestScreen(); @@ -75,6 +77,7 @@ static void sub_80083E0(void); static void sub_8008454(void); static void sub_80084C8(void); static void sub_80084F4(void); + static void CheckErrorStatus(void); static void CB2_PrintErrorMessage(void); static u8 IsSioMultiMaster(void); @@ -148,42 +151,47 @@ struct Link gLink; u8 gLastRecvQueueCount; u16 gLinkSavedIme; +#ifdef GERMAN +u8 deUnkValue1; +u8 deUnkValue2; +#endif + EWRAM_DATA bool8 gLinkTestDebugValuesEnabled = {0}; EWRAM_DATA bool8 gLinkTestDummyBool = {0}; EWRAM_DATA u32 gFiller_20238B8 = {0}; EWRAM_DATA u32 dword_20238BC = {0}; EWRAM_DATA bool8 gLinkOpen = {0}; -#include "link/digit_palette.h" -#include "link/digit_tiles.h" +static const u16 sLinkTestDigitPalette[] = INCBIN_U16("graphics/interface/link_test_digits.gbapal"); +static const u32 sLinkTestDigitTiles[] = INCBIN_U32("graphics/interface/link_test_digits.4bpp"); static const u8 sDebugMessages[7][12] = { - _"せつぞく ちゅうです", - _"せつぞく できません", - _"かくにん ちゅうです", - _"かくにん できました", - _"かくにん できません", - _"かくにん を かくにん", - _"かくにん は しっぱい", + _("せつぞく ちゅうです"), + _("せつぞく できません"), + _("かくにん ちゅうです"), + _("かくにん できました"), + _("かくにん できません"), + _("かくにん を かくにん"), + _("かくにん は しっぱい"), }; -static const u8 sColorCodes[] = _"{HIGHLIGHT TRANSPARENT}{COLOR WHITE2}"; +static const u8 sColorCodes[] = _("{HIGHLIGHT TRANSPARENT}{COLOR WHITE2}"); -static const u32 sBlockRequestLookupTable[5 * 2] = +const struct BlockRequest sBlockRequestLookupTable[5] = { - (u32)gBlockSendBuffer, 200, - (u32)gBlockSendBuffer, 200, - (u32)gBlockSendBuffer, 100, - (u32)gBlockSendBuffer, 220, - (u32)gBlockSendBuffer, 40, + {gBlockSendBuffer, 200}, + {gBlockSendBuffer, 200}, + {gBlockSendBuffer, 100}, + {gBlockSendBuffer, 220}, + {gBlockSendBuffer, 40}, }; -static const u8 sTestString[] = _"テストな"; +static const u8 sTestString[] = _("テストな"); ALIGNED(4) static const u8 sMagic[] = "GameFreak inc."; -ALIGNED(4) static const u8 sEmptyString[] = _""; +ALIGNED(4) static const u8 sEmptyString[] = _(""); void Task_DestroySelf(u8 taskId) { @@ -201,13 +209,13 @@ static void InitLinkTestBG(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charB switch (bgNum) { case 1: - REG_BG1CNT = 1 | (screenBaseBlock << 8) | (charBaseBlock << 2); + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock); break; case 2: - REG_BG2CNT = 1 | (screenBaseBlock << 8) | (charBaseBlock << 2); + REG_BG2CNT = BGCNT_PRIORITY(1) | BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock); break; case 3: - REG_BG3CNT = 1 | (screenBaseBlock << 8) | (charBaseBlock << 2); + REG_BG3CNT = BGCNT_PRIORITY(1) | BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock); break; } } @@ -249,7 +257,7 @@ void LinkTestScreen(void) } InitLinkTestBG(0, 2, 4, 0); - REG_DISPCNT = DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_1D_MAP; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_1D_MAP; CreateTask(Task_DestroySelf, 0); RunTasks(); AnimateSprites(); @@ -401,7 +409,7 @@ static void LinkTestProcessKeyInput(void) if (gMain.newKeys & START_BUTTON) SetSuppressLinkErrorMessage(TRUE); if (gMain.newKeys & R_BUTTON) - sub_8125D44(1); + TrySavingData(LINK_SAVE); if (gMain.newKeys & SELECT_BUTTON) sub_800832C(); if (gLinkTestDebugValuesEnabled) @@ -461,7 +469,7 @@ static void HandleReceiveRemoteLinkPlayer(u8 multiplayerId) gReceivedRemoteLinkPlayers = TRUE; } -static void ProcessRecvCmds(u8 a1) +static void ProcessRecvCmds(u8 unusedParam) { u16 i; for (i = 0; i < MAX_LINK_PLAYERS; i++) @@ -474,10 +482,13 @@ static void ProcessRecvCmds(u8 a1) case 0x2222: InitLocalLinkPlayer(); localLinkPlayerBlock.linkPlayer = localLinkPlayer; - memcpy(localLinkPlayerBlock.magic1, sMagic, 15); - memcpy(localLinkPlayerBlock.magic2, sMagic, 15); + memcpy(localLinkPlayerBlock.magic1, sMagic, sizeof(localLinkPlayerBlock.magic1) - 1); + memcpy(localLinkPlayerBlock.magic2, sMagic, sizeof(localLinkPlayerBlock.magic2) - 1); InitBlockSend(&localLinkPlayerBlock, sizeof(localLinkPlayerBlock)); break; + case 0x4444: + word_3002910[i] = gRecvCmds[1][i]; + break; case 0x5555: byte_3002A68 = 1; break; @@ -548,23 +559,28 @@ static void ProcessRecvCmds(u8 a1) sub_80516C4(i, gRecvCmds[1][i]); break; case 0xCCCC: - { - const u32 *addresses; - const u32 *sizes; - void *data; - u16 size; - - addresses = sBlockRequestLookupTable; - data = (void *)addresses[gRecvCmds[1][i] * 2]; - - sizes = addresses + 1; - size = sizes[gRecvCmds[1][i] * 2]; +#if defined(ENGLISH) + SendBlock(0, sBlockRequestLookupTable[gRecvCmds[1][i]].address, sBlockRequestLookupTable[gRecvCmds[1][i]].size); +#elif defined(GERMAN) + if (deUnkValue2 == 1) + { + deUnkValue2 = 2; + deUnkValue1 = gRecvCmds[1][i]; + } + else if (deUnkValue2 == 2 || deUnkValue2 == 3) + { + SendBlock(0, sBlockRequestLookupTable[gRecvCmds[1][i]].address, sBlockRequestLookupTable[gRecvCmds[1][i]].size); - SendBlock(0, data, size); - break; - } - case 0x4444: - word_3002910[i] = gRecvCmds[1][i]; + if (deUnkValue2 == 2) + deUnkValue2 = 1; + else + deUnkValue2 = 0; + } + else + { + SendBlock(0, sBlockRequestLookupTable[gRecvCmds[1][i]].address, sBlockRequestLookupTable[gRecvCmds[1][i]].size); + } +#endif break; case 0xCAFE: word_3002910[i] = gRecvCmds[1][i]; @@ -629,7 +645,7 @@ static void BuildSendCmd(u16 code) gSendCmd[0] = 0x5FFF; break; case 0xCAFE: - if (!word_3004858 || gUnknown_3001764) + if (!word_3004858 || gLinkTransferringData) break; gSendCmd[0] = 0xCAFE; gSendCmd[1] = word_3004858; @@ -675,6 +691,9 @@ void OpenLinkTimed(void) { sPlayerDataExchangeStatus = EXCHANGE_NOT_STARTED; gLinkTimeOutCounter = 0; +#if defined(GERMAN) + ResetBlockSend(); +#endif OpenLink(); } @@ -829,7 +848,7 @@ static void LinkCB_BlockSendEnd(void) static void sub_8007E04(void) { - GetMultiplayerId(); + GetMultiplayerId(); // whats the point of calling this if you dont use the multiplayer ID? BuildSendCmd(0x4444); dword_20238BC++; } @@ -1107,7 +1126,7 @@ static void sub_800837C(void) if (count == totalCount) { - gUnknown_020239F8 &= 0xFFDF; + gBattleTypeFlags &= ~BATTLE_TYPE_20; gLinkVSyncDisabled = TRUE; CloseLink(); gLinkCallback = NULL; @@ -1131,7 +1150,7 @@ static void sub_80083E0(void) if (count == totalCount) { - gUnknown_020239F8 &= 0xFFDF; + gBattleTypeFlags &= ~BATTLE_TYPE_20; gLinkVSyncDisabled = TRUE; CloseLink(); gLinkCallback = 0; @@ -1224,7 +1243,7 @@ void CB2_LinkError(void) REG_BG0VOFS = 0; REG_BG0HOFS = 0; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON; - gUnknown_3001BB4 = 0; + gSoftResetDisabled = FALSE; CreateTask(Task_DestroySelf, 0); StopMapMusic(); RunTasks(); diff --git a/src/load_save.c b/src/load_save.c index 0d4f1238d..0630f060c 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -1,12 +1,13 @@ #include "global.h" +#include "gba/flash_internal.h" #include "load_save.h" -#include "asm.h" #include "main.h" #include "pokemon.h" #include "rom4.h" extern u8 gPlayerPartyCount; -extern u32 gUnknown_3004820; + +bool32 gFlashMemoryPresent; struct LoadedSaveData { @@ -15,20 +16,20 @@ struct LoadedSaveData struct ItemSlot pokeBalls[16]; struct ItemSlot TMsHMs[64]; struct ItemSlot berries[46]; - struct SaveBlock1_2B4C_Struct unknownSaveData[16]; + struct MailStruct mail[16]; }; extern struct LoadedSaveData gLoadedSaveData[]; void CheckForFlashMemory(void) { - if(!IdentifyFlash()) + if (!IdentifyFlash()) { - gUnknown_3004820 = 1; + gFlashMemoryPresent = TRUE; InitFlashTimer(); } else - gUnknown_3004820 = 0; + gFlashMemoryPresent = FALSE; } bool32 GetSecretBase2Field_9(void) @@ -80,16 +81,16 @@ void LoadPlayerParty(void) static void SaveMapObjects(void) { int i; - - for(i = 0; i < 16; i++) + + for (i = 0; i < 16; i++) gSaveBlock1.mapObjects[i] = gMapObjects[i]; } static void LoadMapObjects(void) { int i; - - for(i = 0; i < 16; i++) + + for (i = 0; i < 16; i++) gMapObjects[i] = gSaveBlock1.mapObjects[i]; } @@ -105,60 +106,60 @@ void LoadSerializedGame(void) LoadMapObjects(); } -void LoadPlayerData(void) +void LoadPlayerBag(void) { int i; // load player items. - for(i = 0; i < 20; i++) + for (i = 0; i < 20; i++) gLoadedSaveData->items[i] = gSaveBlock1.bagPocket_Items[i]; // load player key items. - for(i = 0; i < 20; i++) + for (i = 0; i < 20; i++) gLoadedSaveData->keyItems[i] = gSaveBlock1.bagPocket_KeyItems[i]; // load player pokeballs. - for(i = 0; i < 16; i++) + for (i = 0; i < 16; i++) gLoadedSaveData->pokeBalls[i] = gSaveBlock1.bagPocket_PokeBalls[i]; // load player TMs and HMs. - for(i = 0; i < 64; i++) + for (i = 0; i < 64; i++) gLoadedSaveData->TMsHMs[i] = gSaveBlock1.bagPocket_TMHM[i]; // load player berries. - for(i = 0; i < 46; i++) + for (i = 0; i < 46; i++) gLoadedSaveData->berries[i] = gSaveBlock1.bagPocket_Berries[i]; - // load misc data. - for(i = 0; i < 16; i++) - gLoadedSaveData->unknownSaveData[i] = gSaveBlock1.unkSave[i]; + // load mail. + for (i = 0; i < 16; i++) + gLoadedSaveData->mail[i] = gSaveBlock1.mail[i]; } -void SavePlayerData(void) +void SavePlayerBag(void) { int i; // save player items. - for(i = 0; i < 20; i++) + for (i = 0; i < 20; i++) gSaveBlock1.bagPocket_Items[i] = gLoadedSaveData->items[i]; // save player key items. - for(i = 0; i < 20; i++) + for (i = 0; i < 20; i++) gSaveBlock1.bagPocket_KeyItems[i] = gLoadedSaveData->keyItems[i]; // save player pokeballs. - for(i = 0; i < 16; i++) + for (i = 0; i < 16; i++) gSaveBlock1.bagPocket_PokeBalls[i] = gLoadedSaveData->pokeBalls[i]; // save player TMs and HMs. - for(i = 0; i < 64; i++) + for (i = 0; i < 64; i++) gSaveBlock1.bagPocket_TMHM[i] = gLoadedSaveData->TMsHMs[i]; // save player berries. - for(i = 0; i < 46; i++) + for (i = 0; i < 46; i++) gSaveBlock1.bagPocket_Berries[i] = gLoadedSaveData->berries[i]; - // save misc data. - for(i = 0; i < 16; i++) - gSaveBlock1.unkSave[i] = gLoadedSaveData->unknownSaveData[i]; + // save mail. + for (i = 0; i < 16; i++) + gSaveBlock1.mail[i] = gLoadedSaveData->mail[i]; } diff --git a/src/lottery_corner.c b/src/lottery_corner.c index f073688e0..c2c25b9ac 100644 --- a/src/lottery_corner.c +++ b/src/lottery_corner.c @@ -1,109 +1,119 @@ #include "global.h" #include "lottery_corner.h" +#include "event_data.h" +#include "items.h" #include "rng.h" +#include "species.h" #include "string_util.h" -#include "var.h" +#include "text.h" extern u16 gScriptResult; extern u16 gSpecialVar_0x8004; -extern struct Pokemon gPlayerParty[6]; extern struct PokemonStorage gPokemonStorage; extern u16 gSpecialVar_0x8005; -extern u16 gUnknown_0840CB04[]; extern u16 gSpecialVar_0x8006; static EWRAM_DATA u16 sWinNumberDigit = 0; static EWRAM_DATA u16 sOtIdDigit = 0; +static const u16 sLotteryPrizes[] = +{ + ITEM_PP_UP, + ITEM_EXP_SHARE, + ITEM_MAX_REVIVE, + ITEM_MASTER_BALL, +}; + static u8 GetMatchingDigits(u16, u16); -void sub_8145A78(void) +void ResetLotteryCorner(void) { u16 rand = Random(); - sub_8145D14((Random() << 16) | rand); - VarSet(0x4045, 0); + SetLotteryNumber((Random() << 16) | rand); + VarSet(VAR_POKELOT_PRIZE, 0); } -void sub_8145AA4(u16 a) +void SetRandomLotteryNumber(u16 i) { u32 var = Random(); - - while(--a != 0xFFFF) - { + + while (--i != 0xFFFF) var = var * 1103515245 + 12345; - } - sub_8145D14(var); + + SetLotteryNumber(var); } -void sub_8145AEC(void) +void RetrieveLotteryNumber(void) { - u16 a = sub_8145D3C(); - gScriptResult = a; + u16 lottoNumber = GetLotteryNumber(); + gScriptResult = lottoNumber; } -//Script special function void PickLotteryCornerTicket(void) { u16 i; u16 j; u32 box; u32 slot; - + gSpecialVar_0x8004 = 0; slot = 0; box = 0; - for(i = 0; i < 6; i++) + for (i = 0; i < 6; i++) { struct Pokemon *pkmn = &gPlayerParty[i]; - + // UB: Too few arguments for function GetMonData - if(GetMonData(pkmn, MON_DATA_SPECIES) != 0) + if (GetMonData(pkmn, MON_DATA_SPECIES) != SPECIES_NONE) { - if(!GetMonData(pkmn, MON_DATA_IS_EGG)) + // do not calculate ticket values for eggs. + if (!GetMonData(pkmn, MON_DATA_IS_EGG)) { u32 otId = GetMonData(pkmn, MON_DATA_OT_ID); - u8 a = GetMatchingDigits(gScriptResult, otId); - - if(a > gSpecialVar_0x8004 && a > 1) + u8 numMatchingDigits = GetMatchingDigits(gScriptResult, otId); + + if (numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1) { - gSpecialVar_0x8004 = a - 1; + gSpecialVar_0x8004 = numMatchingDigits - 1; box = 14; slot = i; } } } - else + else // pokemon are always arranged from populated spots first to unpopulated, so the moment a NONE species is found, that's the end of the list. break; } - - for(i = 0; i < 14; i++) + + // player has 14 boxes. + for (i = 0; i < 14; i++) { - for(j = 0; j < 0x1E; j++) + // player has 30 slots per box. + for (j = 0; j < 30; j++) { struct BoxPokemon *pkmn = &gPokemonStorage.boxes[i][j]; - + // UB: Too few arguments for function GetMonData - if(GetBoxMonData(pkmn, MON_DATA_SPECIES) != 0 && + if (GetBoxMonData(pkmn, MON_DATA_SPECIES) != SPECIES_NONE && !GetBoxMonData(pkmn, MON_DATA_IS_EGG)) { u32 otId = GetBoxMonData(pkmn, MON_DATA_OT_ID); - u8 a = GetMatchingDigits(gScriptResult, otId); - - if(a > gSpecialVar_0x8004 && a > 1) + u8 numMatchingDigits = GetMatchingDigits(gScriptResult, otId); + + if (numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1) { - gSpecialVar_0x8004 = a - 1; + gSpecialVar_0x8004 = numMatchingDigits - 1; box = i; slot = j; } } } } - - if(gSpecialVar_0x8004 != 0) + + if (gSpecialVar_0x8004 != 0) { - gSpecialVar_0x8005 = gUnknown_0840CB04[gSpecialVar_0x8004 - 1]; - - if(box == 14) + gSpecialVar_0x8005 = sLotteryPrizes[gSpecialVar_0x8004 - 1]; + + if (box == 14) { gSpecialVar_0x8006 = 0; GetMonData(&gPlayerParty[slot], MON_DATA_NICKNAME, gStringVar1); @@ -120,14 +130,14 @@ void PickLotteryCornerTicket(void) static u8 GetMatchingDigits(u16 winNumber, u16 otId) { u8 i; - u8 matchingDigits = 0; //Why not just use i? - - for(i = 0; i < 5; i++) + u8 matchingDigits = 0; + + for (i = 0; i < 5; i++) { sWinNumberDigit = winNumber % 10; sOtIdDigit = otId % 10; - - if(sWinNumberDigit == sOtIdDigit) + + if (sWinNumberDigit == sOtIdDigit) { winNumber = winNumber / 10; otId = otId / 10; @@ -139,24 +149,26 @@ static u8 GetMatchingDigits(u16 winNumber, u16 otId) return matchingDigits; } -void sub_8145D14(u32 a) +// lottery numbers go from 0 to 99999, not 65535 (0xFFFF). interestingly enough, the function that calls GetLotteryNumber shifts to u16, so it cant be anything above 65535 anyway. +void SetLotteryNumber(u32 lotteryNum) { - u16 b = a >> 16; - u16 c = a; - - VarSet(0x404B, c); - VarSet(0x404C, b); + u16 lowNum = lotteryNum >> 16; + u16 highNum = lotteryNum; + + VarSet(VAR_POKELOT_RND1, highNum); + VarSet(VAR_POKELOT_RND2, lowNum); } -u32 sub_8145D3C(void) +u32 GetLotteryNumber(void) { - u16 var1 = VarGet(0x404B); - u16 var2 = VarGet(0x404C); - - return (var2 << 16) | var1; + u16 highNum = VarGet(VAR_POKELOT_RND1); + u16 lowNum = VarGet(VAR_POKELOT_RND2); + + return (lowNum << 16) | highNum; } -void unref_sub_8145D64(u16 a) +// interestingly, this may have been the original lottery number set function, but GF tried to change it to 32-bit later but didnt finish changing all calls as one GetLotteryNumber still shifts to u16. +void SetLotteryNumber16_Unused(u16 lotteryNum) { - sub_8145D14(a); + SetLotteryNumber(lotteryNum); } diff --git a/src/mail.c b/src/mail.c index a9e21cbc6..658d37976 100644 --- a/src/mail.c +++ b/src/mail.c @@ -1,13 +1,20 @@ #include "global.h" #include "mail.h" -#include "asm.h" +#include "easy_chat.h" +#include "items.h" +#include "mail_data.h" #include "menu.h" +#include "menu_helpers.h" +#include "name_string_util.h" #include "palette.h" +#include "pokemon_icon.h" #include "rom4.h" #include "sprite.h" #include "string_util.h" +#include "strings2.h" #include "task.h" #include "text.h" +#include "unknown_task.h" struct UnkMailStruct { @@ -16,7 +23,8 @@ struct UnkMailStruct u8 unk_0_4:4; }; -struct MailLayout { +struct MailLayout +{ u8 var0; u8 var1; u8 var2; @@ -25,28 +33,30 @@ struct MailLayout { struct UnkMailStruct *var4; }; -struct Unk2000000 { - /* 0x00 */ u8 words[8][27]; - /* 0xEC */ u8 varD8[20]; - /* 0xEC */ MainCallback varEC; - /* 0xF0 */ MainCallback varF0; - /* 0xFF */ struct MailStruct *varF4; - /* 0xF8 */ u8 varF8; - /* 0xF9 */ u8 varF9; - /* 0xFA */ u8 varFA; - /* 0xFB */ u8 varFB; - /* 0xFC */ u8 varFC; +struct Unk2000000 +{ + /* 0x00*/ u8 words[8][27]; + /* 0xD8*/ u8 varD8[20]; + /* 0xEC*/ MainCallback varEC; + /* 0xF0*/ MainCallback varF0; + /* 0xF4*/ struct MailStruct *varF4; + /* 0xF8*/ u8 varF8; + /* 0xF9*/ u8 varF9; + /* 0xFA*/ u8 varFA; + /* 0xFB*/ u8 varFB; + /* 0xFC*/ u8 varFC; u8 padFD[1]; - /* 0xFE */ u8 varFE; - /* 0xFF */ u8 varFF; - /* 0x100 */ u8 var100; + /* 0xFE*/ u8 varFE; + /* 0xFF*/ u8 varFF; + /*0x100*/ u8 var100; u8 pad101[3]; - /* 0x104 */ MainCallback var104; - /* 0x108 */ MainCallback var108; - /* 0x10C */ struct MailLayout *var10C; + /*0x104*/ MainCallback var104; + /*0x108*/ MainCallback var108; + /*0x10C*/ struct MailLayout *var10C; }; -struct MailGraphics { +struct MailGraphics +{ u16 (*palette)[]; u8 (*tiles)[]; u8 (*tileMap)[]; @@ -56,39 +66,17 @@ struct MailGraphics { u16 color12; }; -enum { - LANGUAGE_JAPANESE = 0, - LANGUAGE_ENGLISH = 1, - LANGUAGE_GERMAN = 5, -}; - -enum { - ITEM_ORANGE_MAIL = 0x79, - ITEM_HARBOR_MAIL, - ITEM_GLITTER_MAIL, - ITEM_MECH_MAIL, - ITEM_WOOD_MAIL, - ITEM_WAVE_MAIL, - ITEM_BEAD_MAIL, - ITEM_SHADOW_MAIL, - ITEM_TROPIC_MAIL, - ITEM_DREAM_MAIL, - ITEM_FAB_MAIL, - ITEM_RETRO_MAIL, -}; +extern u8 ewram[]; +#define ewram0 (*(struct Unk2000000 *)(ewram)) -extern struct Unk2000000 unk_2000000; extern struct MailGraphics gMailGraphicsTable[]; extern u16 gUnknown_083E562C[][2]; extern struct MailLayout gUnknown_083E5730[]; extern struct MailLayout gUnknown_083E57A4[]; -extern u8 gOtherText_From[]; - static u8 sub_80F8A28(void); -// static void sub_80F8D50(void); -// static u8 *sub_80F8D7C(u8 *dest, u8 *src); +static void sub_80F8D50(void); static void sub_80F8DA0(void); static void sub_80F8E80(void); static void sub_80F8F18(void); @@ -97,593 +85,353 @@ static void sub_80F8F58(void); static void sub_80F8F78(void); static void sub_80F8FB4(void); -#ifdef NONMATCHING -void sub_80F890C(struct MailStruct *arg0, MainCallback arg1, bool8 arg2) { +void HandleReadMail(struct MailStruct *arg0, MainCallback arg1, bool8 arg2) +{ u16 mailDesign; - u8 buffer[4]; - u8 local1; - - unk_2000000.varFF = 2; + u16 buffer[2]; - // Compiler uses [sub 1], while asm uses [ptr + FE] - unk_2000000.varFE = 1; - unk_2000000.var104 = (MainCallback) sub_80EB3FC; - unk_2000000.var108 = (MainCallback) ConvertEasyChatWordsToString; + ewram0.varFF = GAME_LANGUAGE; + ewram0.var100 = 1; + ewram0.var104 = (MainCallback)sub_80EB3FC; + ewram0.var108 = (MainCallback)ConvertEasyChatWordsToString; - mailDesign = arg0->var20 - ITEM_ORANGE_MAIL; + mailDesign = arg0->itemId - ITEM_ORANGE_MAIL; - if (mailDesign <= 11) { - unk_2000000.varFA = arg0->var20 - ITEM_ORANGE_MAIL; - } else { - unk_2000000.varFA = 0; + if (mailDesign <= 11) + { + ewram0.varFA = arg0->itemId - ITEM_ORANGE_MAIL; + } + else + { + ewram0.varFA = 0; arg2 = FALSE; } - switch (unk_2000000.var100) { - case 0: - default: - unk_2000000.var10C = &gUnknown_083E5730[unk_2000000.varFA]; - break; + switch (ewram0.var100) + { + case 0: + default: + ewram0.var10C = &gUnknown_083E5730[ewram0.varFA]; + break; - case 1: - unk_2000000.var10C = &gUnknown_083E57A4[unk_2000000.varFA]; - break; + case 1: + ewram0.var10C = &gUnknown_083E57A4[ewram0.varFA]; + break; } - if (((sub_80A2D64(arg0->var1E, buffer) << 16) +0xFFFF0000) <= (410 << 16)) { - switch (unk_2000000.varFA) { - case 6: - unk_2000000.varFB = 1; - break; + if (((MailSpeciesToSpecies(arg0->species, buffer) << 16) + 0xFFFF0000) <= (410 << 16)) + { + switch (ewram0.varFA) + { + case 6: + ewram0.varFB = 1; + break; - case 9: - unk_2000000.varFB = 2; - break; + case 9: + ewram0.varFB = 2; + break; - default: - unk_2000000.varFB = 0; - break; + default: + ewram0.varFB = 0; + break; } - } else { - unk_2000000.varFB = 0; + } + else + { + ewram0.varFB = 0; } - unk_2000000.varF4 = arg0; - unk_2000000.varEC = arg1; - unk_2000000.varF8 = arg2; + ewram0.varF4 = arg0; + ewram0.varEC = arg1; + ewram0.varF8 = arg2; SetMainCallback2(sub_80F8D50); } -#else -__attribute__((naked)) -void sub_80F890C(struct MailStruct *arg0, MainCallback arg1, bool8 arg2) { - asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - sub sp, 0x4\n\ - adds r4, r0, 0\n\ - adds r6, r1, 0\n\ - lsls r2, 24\n\ - lsrs r5, r2, 24\n\ - ldr r2, _080F8958 @ =0x02000000\n\ - adds r1, r2, 0\n\ - adds r1, 0xFF\n\ - movs r0, 0x2\n\ - strb r0, [r1]\n\ - adds r0, 0xFE\n\ - adds r1, r2, r0\n\ - movs r0, 0x1\n\ - strb r0, [r1]\n\ - movs r0, 0x82\n\ - lsls r0, 1\n\ - adds r1, r2, r0\n\ - ldr r0, _080F895C @ =sub_80EB3FC\n\ - str r0, [r1]\n\ - movs r0, 0x84\n\ - lsls r0, 1\n\ - adds r1, r2, r0\n\ - ldr r0, _080F8960 @ =ConvertEasyChatWordsToString\n\ - str r0, [r1]\n\ - ldrh r1, [r4, 0x20]\n\ - adds r0, r1, 0\n\ - subs r0, 0x79\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - cmp r0, 0xB\n\ - bhi _080F8964\n\ - subs r1, 0x79\n\ - adds r0, r2, 0\n\ - adds r0, 0xFA\n\ - strb r1, [r0]\n\ - b _080F896E\n\ - .align 2, 0\n\ -_080F8958: .4byte 0x02000000\n\ -_080F895C: .4byte sub_80EB3FC\n\ -_080F8960: .4byte ConvertEasyChatWordsToString\n\ -_080F8964:\n\ - adds r1, r2, 0\n\ - adds r1, 0xFA\n\ - movs r0, 0\n\ - strb r0, [r1]\n\ - movs r5, 0\n\ -_080F896E:\n\ - ldr r1, _080F8994 @ =0x02000000\n\ - movs r2, 0x80\n\ - lsls r2, 1\n\ - adds r0, r1, r2\n\ - ldrb r0, [r0]\n\ - cmp r0, 0\n\ - beq _080F8980\n\ - cmp r0, 0x1\n\ - beq _080F899C\n\ -_080F8980:\n\ - movs r0, 0x86\n\ - lsls r0, 1\n\ - adds r2, r1, r0\n\ - adds r0, r1, 0\n\ - adds r0, 0xFA\n\ - ldrb r0, [r0]\n\ - lsls r0, 3\n\ - ldr r1, _080F8998 @ =gUnknown_083E5730\n\ - b _080F89AC\n\ - .align 2, 0\n\ -_080F8994: .4byte 0x02000000\n\ -_080F8998: .4byte gUnknown_083E5730\n\ -_080F899C:\n\ - movs r0, 0x86\n\ - lsls r0, 1\n\ - adds r2, r1, r0\n\ - adds r0, r1, 0\n\ - adds r0, 0xFA\n\ - ldrb r0, [r0]\n\ - lsls r0, 3\n\ - ldr r1, _080F89DC @ =gUnknown_083E57A4\n\ -_080F89AC:\n\ - adds r0, r1\n\ - str r0, [r2]\n\ - ldrh r0, [r4, 0x1E]\n\ - mov r1, sp\n\ - bl sub_80A2D64\n\ - lsls r0, 16\n\ - ldr r1, _080F89E0 @ =0xffff0000\n\ - adds r0, r1\n\ - movs r1, 0xCD\n\ - lsls r1, 17\n\ - cmp r0, r1\n\ - bhi _080F89F8\n\ - ldr r0, _080F89E4 @ =0x02000000\n\ - adds r1, r0, 0\n\ - adds r1, 0xFA\n\ - ldrb r2, [r1]\n\ - adds r1, r0, 0\n\ - cmp r2, 0x6\n\ - beq _080F89E8\n\ - cmp r2, 0x9\n\ - beq _080F89F0\n\ - b _080F89FA\n\ - .align 2, 0\n\ -_080F89DC: .4byte gUnknown_083E57A4\n\ -_080F89E0: .4byte 0xffff0000\n\ -_080F89E4: .4byte 0x02000000\n\ -_080F89E8:\n\ - adds r2, r1, 0\n\ - adds r2, 0xFB\n\ - movs r0, 0x1\n\ - b _080F8A00\n\ -_080F89F0:\n\ - adds r2, r1, 0\n\ - adds r2, 0xFB\n\ - movs r0, 0x2\n\ - b _080F8A00\n\ -_080F89F8:\n\ - ldr r1, _080F8A20 @ =0x02000000\n\ -_080F89FA:\n\ - adds r2, r1, 0\n\ - adds r2, 0xFB\n\ - movs r0, 0\n\ -_080F8A00:\n\ - strb r0, [r2]\n\ - adds r0, r1, 0\n\ - adds r0, 0xF4\n\ - str r4, [r0]\n\ - subs r0, 0x8\n\ - str r6, [r0]\n\ - adds r0, 0xC\n\ - strb r5, [r0]\n\ - ldr r0, _080F8A24 @ =sub_80F8D50\n\ - bl SetMainCallback2\n\ - add sp, 0x4\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_080F8A20: .4byte 0x02000000\n\ -_080F8A24: .4byte sub_80F8D50\n\ - .syntax divided\n"); -} - -#endif #define RETURN_UP_STATE break #define RETURN_SKIP_STATE return FALSE -static u8 sub_80F8A28(void) { - switch (gMain.state) { - case 0: - SetVBlankCallback(NULL); - remove_some_task(); - REG_DISPCNT = 0; - RETURN_UP_STATE; - - case 1: CpuFill16(0, (void *) OAM, OAM_SIZE); - RETURN_UP_STATE; - - case 2: - ResetPaletteFade(); - RETURN_UP_STATE; - - case 3: - ResetTasks(); - RETURN_UP_STATE; - - case 4: - ResetSpriteData(); - RETURN_UP_STATE; - - case 5: - FreeAllSpritePalettes(); - REG_BG0HOFS = 0; - REG_BG0VOFS = 0; - REG_BG1HOFS = 0; - REG_BG1VOFS = 0; - REG_BG2VOFS = 0; - REG_BG2HOFS = 0; - REG_BG3HOFS = 0; - REG_BG3VOFS = 0; - REG_BLDCNT = 0; - REG_BLDALPHA = 0; - RETURN_UP_STATE; - - case 6: - SetUpWindowConfig(&gWindowConfig_81E6DFC); - RETURN_UP_STATE; - - case 7: - MultistepInitMenuWindowBegin(&gWindowConfig_81E6DFC); - RETURN_UP_STATE; +static u8 sub_80F8A28(void) +{ + switch (gMain.state) + { + case 0: + SetVBlankCallback(NULL); + remove_some_task(); + REG_DISPCNT = 0; + RETURN_UP_STATE; + + case 1: CpuFill16(0, (void *)OAM, OAM_SIZE); + RETURN_UP_STATE; + + case 2: + ResetPaletteFade(); + RETURN_UP_STATE; + + case 3: + ResetTasks(); + RETURN_UP_STATE; + + case 4: + ResetSpriteData(); + RETURN_UP_STATE; + + case 5: + FreeAllSpritePalettes(); + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG2VOFS = 0; + REG_BG2HOFS = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + RETURN_UP_STATE; + + case 6: + SetUpWindowConfig(&gWindowConfig_81E6DFC); + RETURN_UP_STATE; + + case 7: + MultistepInitMenuWindowBegin(&gWindowConfig_81E6DFC); + RETURN_UP_STATE; + + case 8: + if (MultistepInitMenuWindowContinue() == 0) + { + return FALSE; + } + RETURN_UP_STATE; - case 8: - if (MultistepInitMenuWindowContinue() == 0) { - return FALSE; - } - RETURN_UP_STATE; + case 9: + MenuZeroFillScreen(); + RETURN_UP_STATE; - case 9: - MenuZeroFillScreen(); - RETURN_UP_STATE; + case 10: CpuFill16(1, (void *)(VRAM + 0x4800), 0x800); + RETURN_UP_STATE; - case 10: CpuFill16(1, (void *) (VRAM + 0x4800), 0x800); - RETURN_UP_STATE; + case 11: + LoadPalette(gMailGraphicsTable[ewram0.varFA].palette, 0, 16 * 2); + RETURN_UP_STATE; - case 11: - LoadPalette(gMailGraphicsTable[unk_2000000.varFA].palette, 0, 16 * 2); - RETURN_UP_STATE; + case 12: + LZ77UnCompVram(gMailGraphicsTable[ewram0.varFA].tileMap, (void *)(VRAM + 0x4000)); + RETURN_UP_STATE; - case 12: - LZ77UnCompVram(gMailGraphicsTable[unk_2000000.varFA].tileMap, (void *) (VRAM + 0x4000)); - RETURN_UP_STATE; + case 13: + LZ77UnCompVram(gMailGraphicsTable[ewram0.varFA].tiles, (void *)(VRAM)); - case 13: - LZ77UnCompVram(gMailGraphicsTable[unk_2000000.varFA].tiles, (void *) (VRAM)); + gPlttBufferUnfaded[241] = gMailGraphicsTable[ewram0.varFA].color10; + gPlttBufferUnfaded[248] = gMailGraphicsTable[ewram0.varFA].color12; + gPlttBufferUnfaded[10] = gUnknown_083E562C[gSaveBlock2.playerGender][0]; + gPlttBufferUnfaded[11] = gUnknown_083E562C[gSaveBlock2.playerGender][1]; + RETURN_UP_STATE; - gPlttBufferUnfaded[241] = gMailGraphicsTable[unk_2000000.varFA].color10; - gPlttBufferUnfaded[248] = gMailGraphicsTable[unk_2000000.varFA].color12; - gPlttBufferUnfaded[10] = gUnknown_083E562C[gSaveBlock2.playerGender][0]; - gPlttBufferUnfaded[11] = gUnknown_083E562C[gSaveBlock2.playerGender][1]; - RETURN_UP_STATE; + case 14: + if (ewram0.varF8 != 0) + { + sub_80F8DA0(); + } + RETURN_UP_STATE; - case 14: - if (unk_2000000.varF8 != 0) { - sub_80F8DA0(); - } - RETURN_UP_STATE; + case 15: + if (ewram0.varF8 != 0) + { + sub_80F8E80(); + } - case 15: - if (unk_2000000.varF8 != 0) { - sub_80F8E80(); - } + SetVBlankCallback(sub_80F8F18); + gPaletteFade.bufferTransferDisabled = 1; + RETURN_UP_STATE; - SetVBlankCallback(sub_80F8F18); - gPaletteFade.bufferTransferDisabled = 1; - RETURN_UP_STATE; + case 16: + { + u16 local1; - case 16: { - u16 local1; + local1 = sub_809D4A8(ewram0.varF4->species); - local1 = sub_809D4A8(unk_2000000.varF4->var1E); + switch (ewram0.varFB) + { + case 1: + sub_809D580(local1); + ewram0.varFC = sub_809D3A4(local1, SpriteCallbackDummy, 96, 128, 0); + break; - switch (unk_2000000.varFB) { - case 1: - sub_809D580(local1); - unk_2000000.varFC = sub_809D3A4(local1, SpriteCallbackDummy, 96, 128, 0); - break; + case 2: + sub_809D580(local1); + ewram0.varFC = sub_809D3A4(local1, SpriteCallbackDummy, 40, 128, 0); + break; + } + RETURN_UP_STATE; + } - case 2: - sub_809D580(local1); - unk_2000000.varFC = sub_809D3A4(local1, SpriteCallbackDummy, 40, 128, 0); - break; - } + case 17: + if (sub_8055870() != TRUE) + { RETURN_UP_STATE; } - - case 17: - if (sub_8055870() != TRUE) { - RETURN_UP_STATE; - } - RETURN_SKIP_STATE; - - case 18: - REG_BG0CNT = 0x9F08; - REG_BG1CNT = 0x0801; - REG_BG2CNT = 0x0902; - REG_BLDCNT = 0; - REG_DISPCNT = DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; - BeginNormalPaletteFade(-1, 0, 16, 0, 0); - gPaletteFade.bufferTransferDisabled = 0; - unk_2000000.varF0 = sub_80F8F58; - return TRUE; - - default: - return FALSE; + RETURN_SKIP_STATE; + + case 18: + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x512; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(8) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(9) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BLDCNT = 0; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; + BeginNormalPaletteFade(-1, 0, 16, 0, 0); + gPaletteFade.bufferTransferDisabled = 0; + ewram0.varF0 = sub_80F8F58; + return TRUE; + + default: + return FALSE; } gMain.state += 1; return FALSE; } -void sub_80F8D50(void) { - do { - if (sub_80F8A28() == 1) { +static void sub_80F8D50(void) +{ + do + { + if (sub_80F8A28() == 1) + { SetMainCallback2(sub_80F8F2C); return; } } while (sub_80F9344() != 1); } -u8 *sub_80F8D7C(u8 *dest, u8 *src) { +static u8 *sub_80F8D7C(u8 *dest, u8 *src) +{ u16 length; StringCopy(dest, src); - sub_814A568(dest); + SanitizeNameString(dest); length = StringLength(dest); return dest + length; } -#ifdef NONMATCHING -static void sub_80F8DA0(void) { - u8 local0; - - local0 = unk_2000000.var10C->var0; - - // No idea what's happening in this loop. - if (local0 <= 0) { - u8 i; - u8 i2 = 0; - - for (i = 0; i < unk_2000000.var10C->var0; i++) { - ConvertEasyChatWordsToString(unk_2000000.words[i], &unk_2000000.varF4->words[i2], - ((*unk_2000000.var10C->var4)[i] << 28) >> 30, 1); - i2 += ((*unk_2000000.var10C->var4)[i] << 28) >> 30; - } +static void sub_80F8DA0(void) +{ + u16 i; + u8 r6; + u8 *ptr; + + r6 = 0; + for (i = 0; i < ewram0.var10C->var0; i++) + { + ConvertEasyChatWordsToString(ewram0.words[i], &ewram0.varF4->words[r6], ewram0.var10C->var4[i].unk_0_2, 1); + r6 += ewram0.var10C->var4[i].unk_0_2; } - - if (unk_2000000.var100 == LANGUAGE_JAPANESE) { - u8 *ptr; - u16 length; - - ptr = sub_80F8D7C(unk_2000000.varD8, unk_2000000.varF4->var12); + ptr = ewram0.varD8; + if (ewram0.var100 == 0) + { + ptr = sub_80F8D7C(ptr, ewram0.varF4->playerName); StringCopy(ptr, gOtherText_From); + ewram0.varF9 = ewram0.var10C->var2 - StringLength(ewram0.varD8); - length = StringLength(unk_2000000.varD8); - - unk_2000000.varF9 = unk_2000000.var10C->var2 - length; - } else { - u8 *ptr; - - ptr = StringCopy(unk_2000000.varD8, gOtherText_From); - sub_80F8D7C(ptr, unk_2000000.varF4->var12); - - unk_2000000.varF9 = unk_2000000.var10C->var2; + } + else + { + ptr = StringCopy(ptr, gOtherText_From); + sub_80F8D7C(ptr, ewram0.varF4->playerName); + ewram0.varF9 = ewram0.var10C->var2; } } -#else -__attribute__((naked)) -static void sub_80F8DA0(void) { - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - movs r6, 0\n\ - movs r5, 0\n\ - ldr r2, _080F8E3C @ =0x02000000\n\ - movs r0, 0x86\n\ - lsls r0, 1\n\ - adds r1, r2, r0\n\ - ldr r0, [r1]\n\ - ldrb r0, [r0]\n\ - cmp r5, r0\n\ - bcs _080F8E04\n\ - mov r8, r2\n\ - adds r7, r1, 0\n\ -_080F8DBE:\n\ - lsls r0, r5, 3\n\ - subs r0, r5\n\ - lsls r0, 2\n\ - subs r0, r5\n\ - add r0, r8\n\ - mov r1, r8\n\ - adds r1, 0xF4\n\ - lsls r2, r6, 1\n\ - ldr r1, [r1]\n\ - adds r1, r2\n\ - ldr r2, [r7]\n\ - ldr r2, [r2, 0x4]\n\ - lsls r4, r5, 2\n\ - adds r2, r4, r2\n\ - ldr r2, [r2]\n\ - lsls r2, 28\n\ - lsrs r2, 30\n\ - movs r3, 0x1\n\ - bl ConvertEasyChatWordsToString\n\ - ldr r1, [r7]\n\ - ldr r0, [r1, 0x4]\n\ - adds r4, r0\n\ - ldr r0, [r4]\n\ - lsls r0, 28\n\ - lsrs r0, 30\n\ - adds r0, r6, r0\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r0, r5, 0x1\n\ - lsls r0, 16\n\ - lsrs r5, r0, 16\n\ - ldrb r1, [r1]\n\ - cmp r5, r1\n\ - bcc _080F8DBE\n\ -_080F8E04:\n\ - ldr r2, _080F8E40 @ =0x020000d8\n\ - adds r4, r2, 0\n\ - subs r4, 0xD8\n\ - adds r0, r2, 0\n\ - adds r0, 0x28\n\ - ldrb r0, [r0]\n\ - cmp r0, 0\n\ - bne _080F8E48\n\ - ldr r1, [r2, 0x1C]\n\ - adds r1, 0x12\n\ - adds r0, r2, 0\n\ - bl sub_80F8D7C\n\ - adds r2, r0, 0\n\ - ldr r1, _080F8E44 @ =gOtherText_From\n\ - bl StringCopy\n\ - ldr r0, _080F8E40 @ =0x020000d8\n\ - bl StringLength\n\ - movs r2, 0x86\n\ - lsls r2, 1\n\ - adds r1, r4, r2\n\ - ldr r1, [r1]\n\ - ldrb r1, [r1, 0x2]\n\ - subs r1, r0\n\ - b _080F8E6A\n\ - .align 2, 0\n\ -_080F8E3C: .4byte 0x02000000\n\ -_080F8E40: .4byte 0x020000d8\n\ -_080F8E44: .4byte gOtherText_From\n\ -_080F8E48:\n\ - ldr r1, _080F8E7C @ =gOtherText_From\n\ - adds r0, r2, 0\n\ - bl StringCopy\n\ - adds r2, r0, 0\n\ - adds r0, r4, 0\n\ - adds r0, 0xF4\n\ - ldr r1, [r0]\n\ - adds r1, 0x12\n\ - adds r0, r2, 0\n\ - bl sub_80F8D7C\n\ - movs r1, 0x86\n\ - lsls r1, 1\n\ - adds r0, r4, r1\n\ - ldr r0, [r0]\n\ - ldrb r1, [r0, 0x2]\n\ -_080F8E6A:\n\ - adds r0, r4, 0\n\ - adds r0, 0xF9\n\ - strb r1, [r0]\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_080F8E7C: .4byte gOtherText_From\n\ - .syntax divided\n"); -} -#endif -static void sub_80F8E80(void) { +static void sub_80F8E80(void) +{ u16 pos; u8 x; u8 y = 0; - for (pos = 0; pos < unk_2000000.var10C->var0; pos++) { - if (unk_2000000.words[pos][0] == 0xFF) { + for (pos = 0; pos < ewram0.var10C->var0; pos++) + { + if (ewram0.words[pos][0] == 0xFF) + { continue; } - if (unk_2000000.words[pos][0] == 0x00) { + if (ewram0.words[pos][0] == 0x00) + { continue; } - x = unk_2000000.var10C->var4[pos].unk_0_4; - y += unk_2000000.var10C->var4[pos].unk_0_0; - MenuPrint(unk_2000000.words[pos], unk_2000000.var10C->var3_4 + x, unk_2000000.var10C->var3_0 + y); + x = ewram0.var10C->var4[pos].unk_0_4; + y += ewram0.var10C->var4[pos].unk_0_0; + MenuPrint(ewram0.words[pos], ewram0.var10C->var3_4 + x, ewram0.var10C->var3_0 + y); y += 2; } - MenuPrint(unk_2000000.varD8, unk_2000000.varF9, unk_2000000.var10C->var1); + MenuPrint(ewram0.varD8, ewram0.varF9, ewram0.var10C->var1); } -static void sub_80F8F18(void) { +static void sub_80F8F18(void) +{ LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -static void sub_80F8F2C(void) { - if(unk_2000000.varFB != 0) { +static void sub_80F8F2C(void) +{ + if (ewram0.varFB != 0) + { AnimateSprites(); BuildOamBuffer(); } - unk_2000000.varF0(); + ewram0.varF0(); } -static void sub_80F8F58(void) { +static void sub_80F8F58(void) +{ u8 local0; local0 = UpdatePaletteFade(); - if(local0 == 0) { - unk_2000000.varF0 = sub_80F8F78; + if (local0 == 0) + { + ewram0.varF0 = sub_80F8F78; } } -static void sub_80F8F78(void) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { +static void sub_80F8F78(void) +{ + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { BeginNormalPaletteFade(-1, 0, 0, 16, 0); - unk_2000000.varF0 = sub_80F8FB4; + ewram0.varF0 = sub_80F8FB4; } } -static void sub_80F8FB4(void) { +static void sub_80F8FB4(void) +{ u16 local1; - if (UpdatePaletteFade()) { + if (UpdatePaletteFade()) + { return; } - SetMainCallback2(unk_2000000.varEC); - switch (unk_2000000.varFB) { - case 2: - case 1: - local1 = sub_809D4A8(unk_2000000.varF4->var1E); - sub_809D608(local1); + SetMainCallback2(ewram0.varEC); + switch (ewram0.varFB) + { + case 2: + case 1: + local1 = sub_809D4A8(ewram0.varF4->species); + sub_809D608(local1); - sub_809D510(&gSprites[unk_2000000.varFC]); - break; + sub_809D510(&gSprites[ewram0.varFC]); + break; } - memset(&unk_2000000, 0, 0x110); + memset(&ewram0, 0, 0x110); ResetPaletteFade(); } diff --git a/src/mail_data.c b/src/mail_data.c new file mode 100644 index 000000000..ae3f4b3e8 --- /dev/null +++ b/src/mail_data.c @@ -0,0 +1,208 @@ +#include "global.h" +#include "mail_data.h" +#include "items.h" +#include "name_string_util.h" +#include "pokemon.h" +#include "pokemon_icon.h" +#include "species.h" +#include "text.h" + +void ClearMailData(void) +{ + u8 i; + + for (i = 0; i < 16; i++) + ClearMailStruct(&gSaveBlock1.mail[i]); +} + +void ClearMailStruct(struct MailStruct *mail) +{ + int i; + + for (i = 0; i < 9; i++) + mail->words[i] = -1; + + for (i = 0; i < 8; i++) + mail->playerName[i] = -1; + + for (i = 0; i < 4; i++) + mail->trainerId[i] = 0; + + mail->species = 1; + mail->itemId = 0; +} + +bool8 MonHasMail(struct Pokemon *mon) +{ + u16 heldItem = GetMonData(mon, MON_DATA_HELD_ITEM); + if (ItemIsMail(heldItem) && GetMonData(mon, MON_DATA_MAIL) != 0xFF) + return TRUE; + else + return FALSE; +} + +u8 GiveMailToMon(struct Pokemon *mon, u16 itemId) +{ + u16 _itemId; + u8 heldItem[2]; + u8 id; + u8 i; + u16 species; + u32 personality; + + _itemId = itemId; + heldItem[0] = _itemId; + heldItem[1] = _itemId >> 8; + id = 0; + + while (id < 6) + { + if (gSaveBlock1.mail[id].itemId == 0) + { + for (i = 0; i < 9; i++) + gSaveBlock1.mail[id].words[i] = -1; + + for (i = 0; i < 7; i++) + gSaveBlock1.mail[id].playerName[i] = gSaveBlock2.playerName[i]; + gSaveBlock1.mail[id].playerName[i] = EOS; + PadNameString(gSaveBlock1.mail[id].playerName, 0); + + for (i = 0; i < 4; i++) + gSaveBlock1.mail[id].trainerId[i] = gSaveBlock2.playerTrainerId[i]; + + species = GetBoxMonData(&mon->box, MON_DATA_SPECIES); + personality = GetBoxMonData(&mon->box, MON_DATA_PERSONALITY); + gSaveBlock1.mail[id].species = SpeciesToMailSpecies(species, personality); + gSaveBlock1.mail[id].itemId = _itemId; + SetMonData(mon, MON_DATA_MAIL, &id); + SetMonData(mon, MON_DATA_HELD_ITEM, heldItem); + return id; + } + id++; + } + + return -1; +} + +u16 SpeciesToMailSpecies(u16 species, u32 personality) +{ + if (species == SPECIES_UNOWN) + { + int mailSpecies = GetUnownLetterByPersonality(personality) + 30000; + return mailSpecies; + } + + return species; +} + +u16 MailSpeciesToSpecies(u16 a1, u16 *a2) +{ + u16 result; + + if (a1 >= 30000 && a1 < (30000 + UNOWN_FORM_COUNT)) + { + result = SPECIES_UNOWN; + *a2 = a1 - 30000; + } + else + { + result = a1; + } + + return result; +} + +u8 GiveMailToMon2(struct Pokemon *mon, struct MailStruct *mail) +{ + u8 heldItem[2]; + u16 itemId = mail->itemId; + u8 mailId = GiveMailToMon(mon, itemId); + + if (mailId == 0xFF) + return 0xFF; + + gSaveBlock1.mail[mailId] = *mail; + + SetMonData(mon, MON_DATA_MAIL, &mailId); + + heldItem[0] = itemId; + heldItem[1] = itemId >> 8; + + SetMonData(mon, MON_DATA_HELD_ITEM, heldItem); + + return mailId; +} + +int unref_sub_80A2DF4(void) +{ + return 0; +} + +void TakeMailFromMon(struct Pokemon *mon) +{ + u8 heldItem[2]; + u8 mailId; + + if (MonHasMail(mon)) + { + mailId = GetMonData(mon, MON_DATA_MAIL); + gSaveBlock1.mail[mailId].itemId = 0; + mailId = 0xFF; + heldItem[0] = 0; + heldItem[1] = 0; + SetMonData(mon, MON_DATA_MAIL, &mailId); + SetMonData(mon, MON_DATA_HELD_ITEM, heldItem); + } +} + +void DeleteMail(u8 mailId) +{ + gSaveBlock1.mail[mailId].itemId = 0; +} + +u8 TakeMailFromMon2(struct Pokemon *mon) +{ + u8 i; + u8 newHeldItem[2]; + u8 newMailId; + + newHeldItem[0] = 0; + newHeldItem[1] = 0; + newMailId = 0xFF; + + for (i = 6; i < 16; i++) + { + if (gSaveBlock1.mail[i].itemId == 0) + { + memcpy(&gSaveBlock1.mail[i], &gSaveBlock1.mail[GetMonData(mon, MON_DATA_MAIL)], sizeof(struct MailStruct)); + gSaveBlock1.mail[GetMonData(mon, MON_DATA_MAIL)].itemId = 0; + SetMonData(mon, MON_DATA_MAIL, &newMailId); + SetMonData(mon, MON_DATA_HELD_ITEM, newHeldItem); + return i; + } + } + + return 0xFF; +} + +bool8 ItemIsMail(u16 itemId) +{ + switch (itemId) + { + case ITEM_ORANGE_MAIL: + case ITEM_HARBOR_MAIL: + case ITEM_GLITTER_MAIL: + case ITEM_MECH_MAIL: + case ITEM_WOOD_MAIL: + case ITEM_WAVE_MAIL: + case ITEM_BEAD_MAIL: + case ITEM_SHADOW_MAIL: + case ITEM_TROPIC_MAIL: + case ITEM_DREAM_MAIL: + case ITEM_FAB_MAIL: + case ITEM_RETRO_MAIL: + return TRUE; + default: + return FALSE; + } +} diff --git a/src/main.c b/src/main.c index c443de69b..afaa0e77a 100644 --- a/src/main.c +++ b/src/main.c @@ -1,21 +1,21 @@ #include "global.h" -#include "main.h" -#include "asm.h" #include "gba/flash_internal.h" #include "gba/m4a_internal.h" +#include "main.h" #include "intro.h" #include "link.h" #include "load_save.h" #include "m4a.h" #include "play_time.h" #include "rng.h" +#include "rom3.h" #include "rom4.h" #include "rtc.h" #include "siirtc.h" #include "sound.h" +#include "unknown_task.h" extern struct SoundInfo gSoundInfo; -extern u32 gUnknown_3004820; extern u32 IntrMain[]; static void VBlankIntr(void); @@ -32,9 +32,13 @@ static void IntrDummy(void); const u8 gGameVersion = GAME_VERSION; -const u8 gGameLanguage = 2; // English +const u8 gGameLanguage = GAME_LANGUAGE; +#if defined(ENGLISH) const char BuildDateTime[] = "2002 10 15 20:34"; +#elif defined(GERMAN) +const char BuildDateTime[] = "$Name: debug-Euro-2003-05-09-A $"; +#endif const IntrFunc gIntrTableTemplate[] = { @@ -57,10 +61,10 @@ const IntrFunc gIntrTableTemplate[] = #define INTR_COUNT ((int)(sizeof(gIntrTableTemplate)/sizeof(IntrFunc))) u16 gKeyRepeatStartDelay; -u8 gUnknown_3001764; +bool8 gLinkTransferringData; struct Main gMain; u16 gKeyRepeatContinueDelay; -u8 gUnknown_3001BB4; +u8 gSoftResetDisabled; IntrFunc gIntrTable[INTR_COUNT]; bool8 gLinkVSyncDisabled; u32 IntrMain_Buffer[0x200]; @@ -91,31 +95,31 @@ void AgbMain() InitMapMusic(); SeedRngWithRtc(); - gUnknown_3001BB4 = 0; + gSoftResetDisabled = FALSE; - if (gUnknown_3004820 != 1) - SetMainCallback2(0); + if (gFlashMemoryPresent != TRUE) + SetMainCallback2(NULL); - gUnknown_3001764 = 0; + gLinkTransferringData = FALSE; for (;;) { ReadKeys(); - if (!gUnknown_3001BB4 + if (gSoftResetDisabled == FALSE && (gMain.heldKeysRaw & A_BUTTON) && (gMain.heldKeysRaw & B_START_SELECT) == B_START_SELECT) DoSoftReset(); if (gLink.sendQueue.count > 1 && sub_8055910() == 1) { - gUnknown_3001764 = 1; + gLinkTransferringData = TRUE; UpdateLinkAndCallCallbacks(); - gUnknown_3001764 = 0; + gLinkTransferringData = FALSE; } else { - gUnknown_3001764 = 0; + gLinkTransferringData = FALSE; UpdateLinkAndCallCallbacks(); if (gLink.recvQueue.count > 1) @@ -123,9 +127,9 @@ void AgbMain() if (sub_80558AC() == 1) { gMain.newKeys = 0; - gUnknown_3001764 = 1; + gLinkTransferringData = TRUE; UpdateLinkAndCallCallbacks(); - gUnknown_3001764 = 0; + gLinkTransferringData = FALSE; } } } @@ -149,7 +153,7 @@ static void InitMainCallbacks(void) gMain.vblankCounter1 = 0; gMain.vblankCounter2 = 0; gMain.callback1 = NULL; - SetMainCallback2(c2_copyright_1); + SetMainCallback2(CB2_InitCopyrightScreenAfterBootup); } static void CallCallbacks(void) @@ -333,8 +337,7 @@ static void SerialIntr(void) } static void IntrDummy(void) -{ -} +{} static void WaitForVBlank(void) { diff --git a/src/main_menu.c b/src/main_menu.c index 274386b03..09fd06d9e 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -1,10 +1,15 @@ #include "global.h" #include "main_menu.h" -#include "asm.h" +#include "data2.h" #include "decompress.h" +#include "event_data.h" +#include "field_effect.h" #include "menu.h" +#include "mystery_event_menu.h" +#include "naming_screen.h" #include "option_menu.h" #include "palette.h" +#include "pokeball.h" #include "rom4.h" #include "rtc.h" #include "save_menu_util.h" @@ -12,35 +17,20 @@ #include "sound.h" #include "species.h" #include "string_util.h" +#include "strings.h" #include "task.h" #include "text.h" #include "title_screen.h" +#include "unknown_task.h" #define BirchSpeechUpdateWindowText() ((u8)MenuUpdateWindowText_OverrideLineLength(24)) -struct MonCoords -{ - u8 x, y; -}; - extern struct PaletteFadeControl gPaletteFade; -extern u8 gSaveFileDeletedMessage[]; -extern u8 gSaveFileCorruptMessage[]; -extern u8 gBoardNotInstalledMessage[]; -extern u8 gBatteryDryMessage[]; + extern u16 gSaveFileStatus; -extern u8 gMainMenuString_Continue[]; -extern u8 gMainMenuString_NewGame[]; -extern u8 gMainMenuString_MysteryEvents[]; -extern u8 gMainMenuString_Option[]; -extern u8 gMainMenuString_Player[]; -extern u8 gMainMenuString_Time[]; -extern u8 gMainMenuString_Pokedex[]; -extern u8 gMainMenuString_Badges[]; extern u16 gMainMenuPalette[]; -//Text Strings extern const u8 gBirchSpeech_Welcome[]; extern const u8 gBirchSpeech_ThisIsPokemon[]; extern const u8 gBirchSpeech_WorldInhabitedByPokemon[]; @@ -51,25 +41,18 @@ extern u8 gBirchSpeech_SoItsPlayer[]; extern u8 gBirchSpeech_AhOkayYouArePlayer[]; extern u8 gBirchSpeech_AreYouReady[]; -extern const struct MonCoords gMonFrontPicCoords[]; -extern const struct SpriteSheet gMonFrontPicTable[]; -extern const struct SpritePalette gMonPaletteTable[]; extern struct SpriteTemplate gUnknown_02024E8C; -extern void * const gUnknown_081FAF4C[]; extern u16 gUnknown_081E795C[]; extern const struct MenuAction gUnknown_081E79B0[]; extern const struct MenuAction gMalePresetNames[]; extern const struct MenuAction gFemalePresetNames[]; extern const u8 gUnknown_081E764C[]; -extern const u8 gUnknown_081E768C[]; +extern const u8 gBirchIntroShadowGfx[]; extern const u8 gUnknown_081E7834[]; extern const u8 gUnknown_081E796C[]; -extern const u8 gSystemText_NewPara[]; - -extern u8 gSpriteAffineAnimTable_81E79AC[]; -extern u8 gStringVar4[]; +extern const union AffineAnimCmd *const gSpriteAffineAnimTable_81E79AC[]; extern u8 unk_2000000[]; @@ -101,7 +84,7 @@ enum { static void CB2_MainMenu(void); static void VBlankCB_MainMenu(void); -static void sub_80096FC(void); +static void CB2_InitMainMenuFromOptions(void); static u32 InitMainMenu(bool8 a1); static void Task_MainMenuCheckSave(u8 taskId); static void Task_MainMenuWaitForSaveErrorAck(u8 taskId); @@ -114,7 +97,7 @@ static void Task_MainMenuProcessKeyInput(u8 taskId); static void Task_MainMenuPressedA(u8 taskId); static void Task_MainMenuPressedB(u8 taskId); static void HighlightCurrentMenuItem(u8 layout, u8 menuItem); -static void PrintMainMenuItem(u8 *text, u8 left, u8 top); +static void PrintMainMenuItem(const u8 *text, u8 left, u8 top); static void PrintSaveFileInfo(void); static void PrintPlayerName(void); static void PrintPlayTime(void); @@ -155,16 +138,16 @@ static void Task_NewGameSpeech32(u8 taskId); static void Task_NewGameSpeech33(u8 taskId); static void CB_ContinueNewGameSpeechPart2(); static void nullsub_34(struct Sprite *sprite); -static void sub_800B240(struct Sprite *sprite); +static void ShrinkPlayerSprite(struct Sprite *sprite); static u8 CreateAzurillSprite(u8 x, u8 y); static void AddBirchSpeechObjects(u8 taskId); static void Task_SpriteFadeOut(u8 taskId); static void StartSpriteFadeOut(u8 taskId, u8 interval); static void Task_SpriteFadeIn(u8 taskId); static void StartSpriteFadeIn(u8 taskId, u8 interval); -static void sub_800B5A8(u8 taskId); +static void HandleFloorShadowFadeOut(u8 taskId); static void StartBackgroundFadeOut(u8 taskId, u8 interval); -static void sub_800B654(u8 taskId); +static void HandleFloorShadowFadeIn(u8 taskId); static void StartBackgroundFadeIn(u8 taskId, u8 interval); static void CreateGenderMenu(u8 left, u8 top); static s8 GenderMenuProcessInput(void); @@ -192,7 +175,7 @@ void CB2_InitMainMenu(void) InitMainMenu(FALSE); } -static void sub_80096FC(void) +static void CB2_InitMainMenuFromOptions(void) { InitMainMenu(TRUE); } @@ -249,7 +232,8 @@ u32 InitMainMenu(u8 a1) SetVBlankCallback(VBlankCB_MainMenu); SetMainCallback2(CB2_MainMenu); - REG_DISPCNT = DISPCNT_OBJ_1D_MAP + REG_DISPCNT = DISPCNT_MODE_0 + | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON; @@ -276,7 +260,7 @@ void Task_MainMenuCheckSave(u8 taskId) switch (gSaveFileStatus) { case 1: - if (IsMysteryGiftAvailable() == TRUE) + if (IsMysteryGiftEnabled() == TRUE) gTasks[taskId].data[TD_MENULAYOUT] = HAS_MYSTERY_GIFT; else gTasks[taskId].data[TD_MENULAYOUT] = HAS_SAVED_GAME; @@ -299,7 +283,7 @@ void Task_MainMenuCheckSave(u8 taskId) gTasks[taskId].data[TD_MENULAYOUT] = HAS_SAVED_GAME; gTasks[taskId].func = Task_MainMenuWaitForSaveErrorAck; - if (IsMysteryGiftAvailable() == TRUE) + if (IsMysteryGiftEnabled() == TRUE) gTasks[taskId].data[TD_MENULAYOUT] = HAS_MYSTERY_GIFT; else gTasks[taskId].data[TD_MENULAYOUT] = HAS_SAVED_GAME; @@ -580,7 +564,7 @@ void Task_MainMenuPressedA(u8 taskId) DestroyTask(taskId); break; case OPTION: - gMain.field_8 = sub_80096FC; + gMain.savedCallback = CB2_InitMainMenuFromOptions; SetMainCallback2(CB2_InitOptionMenu); DestroyTask(taskId); break; @@ -655,7 +639,7 @@ void HighlightCurrentMenuItem(u8 layout, u8 menuItem) } } -void PrintMainMenuItem(u8 *text, u8 left, u8 top) +void PrintMainMenuItem(const u8 *text, u8 left, u8 top) { u8 i; u8 buffer[32]; @@ -691,10 +675,17 @@ void PrintPlayTime(void) u8 playTime[16]; u8 alignedPlayTime[32]; +#if defined(ENGLISH) MenuPrint(gMainMenuString_Time, 16, 3); FormatPlayTime(playTime, gSaveBlock2.playTimeHours, gSaveBlock2.playTimeMinutes, 1); sub_8072C74(alignedPlayTime, playTime, 48, 1); MenuPrint(alignedPlayTime, 22, 3); +#elif defined(GERMAN) + MenuPrint_PixelCoords(gMainMenuString_Time, 124, 24, TRUE); + FormatPlayTime(playTime, gSaveBlock2.playTimeHours, gSaveBlock2.playTimeMinutes, 1); + sub_8072C74(alignedPlayTime, playTime, 40, 1); + MenuPrint(alignedPlayTime, 23, 3); +#endif } void PrintPokedexCount(void) @@ -710,7 +701,11 @@ void PrintBadgeCount(void) { u8 buffer[16]; +#if defined(ENGLISH) MenuPrint(gMainMenuString_Badges, 16, 5); +#elif defined(GERMAN) + MenuPrint_PixelCoords(gMainMenuString_Badges, 124, 40, TRUE); +#endif ConvertIntToDecimalString(buffer, GetBadgeCount()); MenuPrint_PixelCoords(buffer, 205, 40, 1); } @@ -726,7 +721,7 @@ static void Task_NewGameSpeech1(u8 taskId) REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; - LZ77UnCompVram(gUnknown_081E768C, (void *)BG_VRAM); + LZ77UnCompVram(gBirchIntroShadowGfx, (void *)BG_VRAM); LZ77UnCompVram(gUnknown_081E7834, (void *)(BG_VRAM + 0x3800)); LoadPalette(gUnknown_081E764C, 0, 0x40); LoadPalette(gUnknown_081E796C, 1, 0x10); @@ -735,8 +730,8 @@ static void Task_NewGameSpeech1(u8 taskId) FreeAllSpritePalettes(); AddBirchSpeechObjects(taskId); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - REG_BG1CNT = 0x00000703; - REG_DISPCNT = DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP; + REG_BG1CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP; gTasks[taskId].data[TD_BGHOFS] = 0; gTasks[taskId].func = Task_NewGameSpeech2; gTasks[taskId].data[TD_TRAINER_SPRITE_ID] = 0xFF; @@ -952,14 +947,14 @@ static void Task_NewGameSpeech16(u8 taskId) switch (GenderMenuProcessInput()) { case MALE: - sub_8072DEC(); + HandleDestroyMenuCursors(); PlaySE(SE_SELECT); gSaveBlock2.playerGender = MALE; MenuZeroFillWindowRect(2, 4, 8, 9); gTasks[taskId].func = Task_NewGameSpeech19; break; case FEMALE: - sub_8072DEC(); + HandleDestroyMenuCursors(); PlaySE(SE_SELECT); gSaveBlock2.playerGender = FEMALE; MenuZeroFillWindowRect(2, 4, 8, 9); @@ -1055,7 +1050,7 @@ static void Task_NewGameSpeech21(u8 taskId) case 2: case 3: case 4: - sub_8072DEC(); + HandleDestroyMenuCursors(); PlaySE(SE_SELECT); MenuZeroFillWindowRect(2, 1, 22, 12); SetPresetPlayerName(selection); @@ -1067,7 +1062,7 @@ static void Task_NewGameSpeech21(u8 taskId) gTasks[taskId].func = Task_NewGameSpeech22; break; case -1: //B button - sub_8072DEC(); + HandleDestroyMenuCursors(); PlaySE(SE_SELECT); MenuZeroFillWindowRect(2, 1, 22, 12); gTasks[taskId].func = Task_NewGameSpeech14; //Go back to gender menu @@ -1081,7 +1076,7 @@ static void Task_NewGameSpeech22(u8 taskId) if (!gPaletteFade.active) { SetPresetPlayerName(1); - DoNamingScreen(0, &gSaveBlock2, gSaveBlock2.playerGender, 0, 0, CB_ContinueNewGameSpeechPart2); + DoNamingScreen(0, gSaveBlock2.playerName, gSaveBlock2.playerGender, 0, 0, CB_ContinueNewGameSpeechPart2); } } @@ -1256,10 +1251,10 @@ static void Task_NewGameSpeech30(u8 taskId) spriteId = gTasks[taskId].data[TD_TRAINER_SPRITE_ID]; gSprites[spriteId].oam.affineMode = 1; - gSprites[spriteId].affineAnims = (union AffineAnimCmd **)gSpriteAffineAnimTable_81E79AC; + gSprites[spriteId].affineAnims = gSpriteAffineAnimTable_81E79AC; InitSpriteAffineAnim(&gSprites[spriteId]); StartSpriteAffineAnim(&gSprites[spriteId], 0); - gSprites[spriteId].callback = sub_800B240; + gSprites[spriteId].callback = ShrinkPlayerSprite; BeginNormalPaletteFade(0x0000FFFF, 0, 0, 0x10, 0); FadeOutBGM(4); gTasks[taskId].func = Task_NewGameSpeech31; @@ -1324,7 +1319,7 @@ void CB_ContinueNewGameSpeechPart2() ResetPaletteFade(); - LZ77UnCompVram(gUnknown_081E768C, (void *)BG_VRAM); + LZ77UnCompVram(gBirchIntroShadowGfx, (void *)BG_VRAM); LZ77UnCompVram(gUnknown_081E7834, (void *)(BG_VRAM + 0x3800)); LoadPalette(gUnknown_081E764C, 0, 0x40); @@ -1379,7 +1374,7 @@ void CB_ContinueNewGameSpeechPart2() SetVBlankCallback(VBlankCB_MainMenu); SetMainCallback2(CB2_MainMenu); - REG_BG1CNT = 1795; + REG_BG1CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON; } @@ -1388,7 +1383,7 @@ void nullsub_34(struct Sprite *sprite) { } -void sub_800B240(struct Sprite *sprite) +void ShrinkPlayerSprite(struct Sprite *sprite) { u32 y = (sprite->pos1.y << 16) + sprite->data0 + 0xC000; sprite->pos1.y = y >> 16; @@ -1399,8 +1394,8 @@ u8 CreateAzurillSprite(u8 x, u8 y) { DecompressPicFromTable_2( &gMonFrontPicTable[SPECIES_AZURILL], - gMonFrontPicCoords[SPECIES_AZURILL].x, - gMonFrontPicCoords[SPECIES_AZURILL].y, + gMonFrontPicCoords[SPECIES_AZURILL].coords, + gMonFrontPicCoords[SPECIES_AZURILL].y_offset, gUnknown_081FAF4C[0], gUnknown_081FAF4C[1], SPECIES_AZURILL); @@ -1532,22 +1527,16 @@ enum { TD_DELAY, }; -static void sub_800B5A8(u8 taskId) +static void HandleFloorShadowFadeOut(u8 taskId) { if (gTasks[taskId].data[TD_DELAY]) - { gTasks[taskId].data[TD_DELAY]--; - } else { if (gTasks[taskId].data[TD_FADELEVEL] == 8) - { DestroyTask(taskId); - } else if (gTasks[taskId].data[TD_FRAMECOUNTER]) - { gTasks[taskId].data[TD_FRAMECOUNTER]--; - } else { gTasks[taskId].data[TD_FRAMECOUNTER] = gTasks[taskId].data[TD_INTERVAL]; @@ -1560,7 +1549,7 @@ static void sub_800B5A8(u8 taskId) //Launches a helper task to fade out the background static void StartBackgroundFadeOut(u8 taskId, u8 interval) { - u8 newTaskId = CreateTask(sub_800B5A8, 0); + u8 newTaskId = CreateTask(HandleFloorShadowFadeOut, 0); gTasks[newTaskId].data[TD_PARENT_TASK_ID] = taskId; gTasks[newTaskId].data[TD_FADELEVEL] = 0; gTasks[newTaskId].data[TD_DELAY] = 8; @@ -1568,24 +1557,18 @@ static void StartBackgroundFadeOut(u8 taskId, u8 interval) gTasks[newTaskId].data[TD_FRAMECOUNTER] = interval; } -static void sub_800B654(u8 taskId) +static void HandleFloorShadowFadeIn(u8 taskId) { if (gTasks[taskId].data[TD_DELAY]) - { gTasks[taskId].data[TD_DELAY]--; - } else { if (gTasks[taskId].data[TD_FADELEVEL] == 0) - { DestroyTask(taskId); - } else { if (gTasks[taskId].data[TD_FRAMECOUNTER]) - { gTasks[taskId].data[TD_FRAMECOUNTER]--; - } else { gTasks[taskId].data[TD_FRAMECOUNTER] = gTasks[taskId].data[TD_INTERVAL]; @@ -1599,7 +1582,7 @@ static void sub_800B654(u8 taskId) //Launches a helper task to fade in the background static void StartBackgroundFadeIn(u8 taskId, u8 interval) { - u8 newTaskId = CreateTask(sub_800B654, 0); + u8 newTaskId = CreateTask(HandleFloorShadowFadeIn, 0); gTasks[newTaskId].data[TD_PARENT_TASK_ID] = taskId; gTasks[newTaskId].data[TD_FADELEVEL] = 8; gTasks[newTaskId].data[TD_DELAY] = 8; @@ -1645,9 +1628,9 @@ static void SetPresetPlayerName(u8 index) u8 *name; if (gSaveBlock2.playerGender == MALE) - name = gMalePresetNames[index].text; + name = (u8 *) gMalePresetNames[index].text; else - name = gFemalePresetNames[index].text; + name = (u8 *) gFemalePresetNames[index].text; for (i = 0; i < 7; i++) gSaveBlock2.playerName[i] = name[i]; diff --git a/src/map_name_popup.c b/src/map_name_popup.c new file mode 100644 index 000000000..303cc3d07 --- /dev/null +++ b/src/map_name_popup.c @@ -0,0 +1,107 @@ +#include "global.h" +#include "map_name_popup.h" +#include "event_data.h" +#include "menu.h" +#include "region_map.h" +#include "task.h" + +EWRAM_DATA static u8 sTaskId = 0; + +static void Task_MapNamePopup(u8); +static void DrawMapNamePopup(void); + +bool8 unref_sub_80A2F44(void) +{ + CloseMenu(); + ShowMapNamePopup(); + return 1; +} + +void ShowMapNamePopup(void) +{ + if (FlagGet(0x4000) != TRUE) + { + if (!FuncIsActiveTask(Task_MapNamePopup)) + { + sTaskId = CreateTask(Task_MapNamePopup, 90); + REG_BG0VOFS = 32; + DrawMapNamePopup(); + gTasks[sTaskId].data[0] = 0; + gTasks[sTaskId].data[2] = 32; + } + else + { + if (gTasks[sTaskId].data[0] != 2) + gTasks[sTaskId].data[0] = 2; + gTasks[sTaskId].data[3] = 1; + } + } +} + +void Task_MapNamePopup(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + task->data[2] -= 2; + if (task->data[2] <= 0 ) + { + task->data[0] = 1; + gTasks[sTaskId].data[1] = 0; + } + break; + case 1: + task->data[1]++; + if (task->data[1] > 120 ) + { + task->data[1] = 0; + task->data[0] = 2; + } + break; + case 2: + task->data[2] += 2; + if (task->data[2] > 31) + { + if (task->data[3]) + { + DrawMapNamePopup(); + task->data[0] = 0; + task->data[3] = 0; + } + else + { + task->data[0] = 4; + return; + } + } + break; + case 4: + HideMapNamePopup(); + return; + } + + REG_BG0VOFS = task->data[2]; +} + +void HideMapNamePopup(void) +{ + if (FuncIsActiveTask(Task_MapNamePopup)) + { + MenuLoadTextWindowGraphics(); + MenuZeroFillWindowRect(0, 0, 13, 3); + REG_BG0VOFS = 0; + DestroyTask(sTaskId); + } +} + +void DrawMapNamePopup(void) +{ + u8 name[20]; + + MenuLoadTextWindowGraphics_OverrideFrameType(0); + sub_80FBFB4(name, gMapHeader.name, 0); + MenuDrawTextWindow(0, 0, 13, 3); + sub_8072BD8(name, 1, 1, 0x60); +} diff --git a/src/map_obj_lock.c b/src/map_obj_lock.c index cc2befa6d..bd40bcacc 100644 --- a/src/map_obj_lock.c +++ b/src/map_obj_lock.c @@ -1,7 +1,9 @@ #include "global.h" #include "map_obj_lock.h" -#include "asm.h" +#include "field_map_obj.h" +#include "field_map_obj_helpers.h" #include "field_player_avatar.h" +#include "script_movement.h" #include "task.h" extern u16 gScriptFacing; @@ -36,9 +38,9 @@ bool8 sub_8064CFC(void) } } -void sub_8064D20(void) +void ScriptFreezeMapObjects(void) { - player_bitmagic(); + FreezeMapObjects(); CreateTask(sub_8064CDC, 80); } @@ -53,7 +55,7 @@ void sub_8064D38(u8 taskId) } if (!task->data[1] && !gMapObjects[gSelectedMapObject].mapobj_bit_1) { - sub_80643A4(&gMapObjects[gSelectedMapObject]); + FreezeMapObject(&gMapObjects[gSelectedMapObject]); task->data[1] = 1; } if (task->data[0] && task->data[1]) @@ -76,11 +78,11 @@ bool8 sub_8064DB4(void) void sub_8064DD8(void) { u8 taskId; - sub_8064470(gSelectedMapObject); + FreezeMapObjectsExceptOne(gSelectedMapObject); taskId = CreateTask(sub_8064D38, 80); if (!gMapObjects[gSelectedMapObject].mapobj_bit_1) { - sub_80643A4(&gMapObjects[gSelectedMapObject]); + FreezeMapObject(&gMapObjects[gSelectedMapObject]); gTasks[taskId].data[1] = 1; } } @@ -90,7 +92,7 @@ void sub_8064E2C(void) u8 objectId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[objectId]); sub_80A2178(); - sub_806451C(); + UnfreezeMapObjects(); } void unref_sub_8064E5C(void) @@ -102,7 +104,7 @@ void unref_sub_8064E5C(void) objectId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[objectId]); sub_80A2178(); - sub_806451C(); + UnfreezeMapObjects(); } void sub_8064EAC(void) diff --git a/src/matsuda_debug_menu.c b/src/matsuda_debug_menu.c index df2ca3206..3665cabd8 100644 --- a/src/matsuda_debug_menu.c +++ b/src/matsuda_debug_menu.c @@ -1,5 +1,9 @@ #include "global.h" -#include "asm.h" +#include "matsuda_debug_menu.h" +#include "contest.h" +#include "contest_link_80C2020.h" +#include "contest_link_80C857C.h" +#include "data2.h" #include "link.h" #include "main.h" #include "menu.h" @@ -10,17 +14,20 @@ #include "string_util.h" #include "task.h" #include "text.h" +#include "unknown_task.h" -#define BIT(n) (1 << (n)) - -extern u8 gUnknown_0203869A; +extern u8 gUnknown_0203856C; +extern u8 gUnknown_0203857D[][64]; +extern u16 gUnknown_02038670[]; +extern u16 gUnknown_02038678[]; +extern u16 gUnknown_02038680[]; +extern u8 gUnknown_02038690[]; +extern u8 gUnknown_02038694; +extern u8 gIsLinkContest; extern u8 gUnknown_0203869B; extern u8 gContestPlayerMonIndex; extern u16 gScriptContestCategory; extern u16 gScriptContestRank; -extern u8 (*gCallback_03004AE8)(void); - -extern struct Window gMenuWindow; extern u16 gUnknown_030042A4; extern u16 gUnknown_030042A0; @@ -30,14 +37,14 @@ extern u16 gUnknown_03004288; extern u16 gUnknown_03004280; extern u16 gUnknown_030041B0; extern u16 gUnknown_030041B8; +extern struct Window gUnknown_03004210; +extern u8 (*gCallback_03004AE8)(void); -extern u8 gUnknown_02038694; -extern u8 gUnknown_083C9296[]; -extern u8 gUnknown_083C92A8[]; -extern u8 gUnknown_083C9282[]; -extern u8 gUnknown_0203857D[][64]; extern u8 gUnknown_083C926E[][2]; +extern u8 gUnknown_083C9282[]; extern const u8 gUnknown_083C928E[][2]; +extern u8 gUnknown_083C9296[]; +extern u8 gUnknown_083C92A8[]; extern u8 unk_2000000[]; extern u8 gMatsudaDebugMenu_GoBackText[]; extern u8 gMatsudaDebugMenu_BattlePointsText[]; @@ -46,8 +53,9 @@ extern u8 gMatsudaDebugMenu_StartText[]; extern struct SpritePalette gUnknown_083C92BC; extern struct SpriteSheet gUnknown_083C92B4; extern struct SpriteTemplate gSpriteTemplate_83C92CC; +extern void (*gUnknown_083C92E4[][2])(struct Sprite *, s8); +extern u32 gUnknown_083C9400[2]; -extern u8 gMoveNames[][13]; extern u8 gMatsudaDebugMenu_UnknownByteArray[]; extern u8* gMatsudaDebugMenuTextList1[]; @@ -55,26 +63,7 @@ extern u8* gMatsudaDebugMenuTextList2[]; extern u8* gMatsudaDebugMenuTextList3[]; extern u8 gMatsudaDebugMenuContestTopLeft[][2]; -struct ContestPokemon -{ - /* 0x00 */ u16 species; - /* 0x02 */ u8 nickname[POKEMON_NAME_LENGTH]; - /* 0x0D */ u8 trainerName[8]; - /* 0x15 */ u8 filler15[9]; - /* 0x1E */ u16 moves[4]; // moves - /* 0x26 */ u8 cool; // cool - /* 0x27 */ u8 beauty; // beauty - /* 0x28 */ u8 cute; // cute - /* 0x29 */ u8 smart; // smart - /* 0x2A */ u8 tough; // tough - /* 0x2B */ u8 sheen; // sheen - /* 0x2C */ u8 filler2C[20]; -}; - -extern struct ContestPokemon gContestMons[]; - extern bool8 gReceivedRemoteLinkPlayers; -extern u16 gBlockRecvBuffer[MAX_LINK_PLAYERS][BLOCK_BUFFER_SIZE / 2]; extern struct MenuAction gMatsudaDebugMenuActions[]; @@ -94,6 +83,7 @@ static void sub_80A9F10(u8); static void sub_80AA10C(void); static void sub_80AA5BC(u8); static void sub_80AA614(u8, u8); +static void sub_80AAD08(struct Sprite *, s8); u8 unref_sub_80A9B28(void) { @@ -108,8 +98,8 @@ u8 unref_sub_80A9B28(void) static bool8 sub_80A9B78(void) { s8 choice = ProcessMenuInput(); - - switch(choice) + + switch (choice) { case -2: return FALSE; @@ -117,7 +107,7 @@ static bool8 sub_80A9B78(void) gCallback_03004AE8 = gMatsudaDebugMenuActions[choice].func; return FALSE; case -1: - sub_8071C20(); + CloseMenu(); return TRUE; } } @@ -131,11 +121,11 @@ s8 MatsudaDebugMenu_ContestResults(void) static void sub_80A9BE4(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { DestroyTask(taskId); - if(!(gUnknown_0203869A & 1)) + if (!(gIsLinkContest & 1)) sub_80AF668(); sub_80C2358(); @@ -144,7 +134,7 @@ static void sub_80A9BE4(u8 taskId) s8 MatsudaDebugMenu_Contest(void) { - gUnknown_0203869A = 0; + gIsLinkContest = 0; sub_80AA10C(); return 0; } @@ -159,7 +149,7 @@ s8 MatsudaDebugMenu_CommTest(void) { u8 newTaskId; u8 newTaskId2; - + newTaskId = CreateTask(sub_80A9E3C, 0); SetTaskFuncWithFollowupFunc(newTaskId, sub_80A9E3C, sub_80A9C98); newTaskId2 = CreateTask(sub_80A9E04, 1); @@ -186,11 +176,11 @@ static void sub_80A9CDC(u8 taskId) static void sub_80A9CF8(u8 taskId) { - if(gReceivedRemoteLinkPlayers == FALSE) + if (gReceivedRemoteLinkPlayers == FALSE) { DestroyTask(gTasks[taskId].data[10]); DestroyTask(taskId); - sub_8071C20(); + CloseMenu(); } } @@ -205,7 +195,7 @@ static void sub_80A9D58(u8 taskId) int i; u8 dest[4]; - for(i = 0; i < 4; i++) + for (i = 0; i < 4; i++) dest[i] = gTasks[taskId].data[5 + i]; gUnknown_0203869B = sub_80C4B34(dest); @@ -223,22 +213,22 @@ static void sub_80A9DD8(u8 taskId) { DestroyTask(gTasks[taskId].data[10]); DestroyTask(taskId); - sub_8071C20(); + CloseMenu(); } static void sub_80A9E04(u8 taskId) { - if(gMain.newKeys == 2) + if (gMain.newKeys == 2) gTasks[(u8)gTasks[taskId].data[10]].func = sub_80A9D30; } static void sub_80A9E3C(u8 taskId) { u8 i; - + OpenLink(); - for(i = 0; i < 4; i++) + for (i = 0; i < 4; i++) gBlockRecvBuffer[i][0] = 255; gTasks[taskId].data[0] = 0; @@ -249,15 +239,15 @@ static void sub_80A9E80(u8 taskId) { TaskFunc func; - if(gTasks[taskId].data[0] < 10) + if (gTasks[taskId].data[0] < 10) gTasks[taskId].data[0]++; else { - if(GetLinkPlayerCount_2() > 3) + if (GetLinkPlayerCount_2() > 3) { gTasks[taskId].data[0] = 0; - - if(IsLinkMaster()) + + if (IsLinkMaster()) { func = sub_80A9ED8; gTasks[taskId].func = (TaskFunc)func; @@ -274,7 +264,7 @@ static void sub_80A9E80(u8 taskId) static void sub_80A9ED8(u8 taskId) { gTasks[taskId].data[0] = gTasks[taskId].data[0] + 1; - if((gTasks[taskId].data[0]) == 101) + if ((gTasks[taskId].data[0]) == 101) { sub_8007F4C(); gTasks[taskId].data[0] = 0; @@ -284,12 +274,12 @@ static void sub_80A9ED8(u8 taskId) static void sub_80A9F10(u8 taskId) { - if(gReceivedRemoteLinkPlayers) + if (gReceivedRemoteLinkPlayers) { gContestPlayerMonIndex = GetMultiplayerId(); - if(GetLinkPlayerCount() == 4) + if (GetLinkPlayerCount() == 4) { - gUnknown_0203869A = 1; + gIsLinkContest = 1; SwitchTaskToFollowupFunc(taskId); } } @@ -297,7 +287,7 @@ static void sub_80A9F10(u8 taskId) static void sub_80A9F50(void) { - REG_DISPCNT = DISPCNT_OBJ_1D_MAP; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP; REG_DISPCNT |= DISPCNT_OBJ_ON | DISPCNT_BG0_ON; SetUpWindowConfig(&gWindowConfig_81E6C3C); InitWindowFromConfig(&gMenuWindow, &gWindowConfig_81E6C3C); @@ -322,18 +312,18 @@ static void sub_80A9FE4(void) u8 *addr; u32 i; u8 ptr[5]; - + memcpy(ptr, gMatsudaDebugMenu_UnknownByteArray, 5); addr = (void *)VRAM; i = VRAM_SIZE; - while(1) + while (1) { DmaFill32(3, 0, addr, 0x1000); addr += 0x1000; i -= 0x1000; - if(i <= 0x1000) + if (i <= 0x1000) { DmaFill32(3, 0, addr, i); break; @@ -349,7 +339,7 @@ static void sub_80AA064(void) BuildOamBuffer(); RunTasks(); UpdatePaletteFade(); - if(gMain.newKeys == 4) + if (gMain.newKeys == 4) SetMainCallback2(sub_805469C); } @@ -383,21 +373,21 @@ static void sub_80AA10C(void) ResetSpriteData(); ResetTasks(); FreeAllSpritePalettes(); - sub_80A9FE4(); + sub_80A9FE4(); SetVBlankCallback(sub_80AA090); SetMainCallback2(sub_80AA064); gPaletteFade.bufferTransferDisabled = 0; gUnknown_02038694 = 0; - if(!(gContestMons[0].nickname[0])) + if (!(gContestMons[0].nickname[0])) sub_80AE398(0, 0); sub_80AE098(gUnknown_02038694); - for(i = 0; i < 6; i++) + for (i = 0; i < 6; i++) { - sub_8003460(&gMenuWindow, gMatsudaDebugMenuTextList1[i], - (0xA * i + 0x2A), gMatsudaDebugMenuContestTopLeft[i][0], + sub_8003460(&gMenuWindow, gMatsudaDebugMenuTextList1[i], + (0xA * i + 0x2A), gMatsudaDebugMenuContestTopLeft[i][0], gMatsudaDebugMenuContestTopLeft[i][1]); } @@ -419,7 +409,7 @@ static void sub_80AA10C(void) gSprites[spriteId].data3 = zero; // only this assignment of zero is necessary. other replacements of 0 with zero do not change the asm, compiler will treat it the same. } -void sub_80AA280(u8 var) +void sub_80AA280(u8 var) // no? { u8 i; @@ -427,9 +417,9 @@ void sub_80AA280(u8 var) StringCopy(unk_2000000, gMatsudaDebugMenu_StartText); StringAppend(unk_2000000, &gUnknown_0203857D[var][0]); - for(i = 0; i < 4; i++) + for (i = 0; i < 4; i++) { - if(var == i) + if (var == i) { sub_8003460(&gMenuWindow, unk_2000000, (10 * i + 2), gUnknown_083C926E[i][0], gUnknown_083C926E[i][1]); } @@ -487,261 +477,123 @@ static void sub_80AA4F0(u8 var1, u8 var2) static void sub_80AA5BC(u8 var) { - sub_8003460(&gMenuWindow, gMatsudaDebugMenuTextList2[var], 0xC2, 3, 0x12); + sub_8003460(&gMenuWindow, gMatsudaDebugMenuTextList2[var], 0xC2, 3, 0x12); } void sub_80AA5E8(u8 var) { - sub_8003460(&gMenuWindow, gMatsudaDebugMenuTextList3[var], 0xE8, 3, 4); + sub_8003460(&gMenuWindow, gMatsudaDebugMenuTextList3[var], 0xE8, 3, 4); } static void sub_80AA614(u8 var1, u8 var2) { - u16 var = sub_80AE770(var1, var2); + u16 var = sub_80AE770(var1, var2); - ConvertIntToDecimalStringN(unk_2000000, var, STR_CONV_MODE_RIGHT_ALIGN, 3); - sub_8003460(&gMenuWindow, unk_2000000, 0xE2, 3, 0xC); + ConvertIntToDecimalStringN(unk_2000000, var, STR_CONV_MODE_RIGHT_ALIGN, 3); + sub_8003460(&gMenuWindow, unk_2000000, 0xE2, 3, 0xC); } void sub_80AA658(u8 var) { - u8 i; + u8 i; - sub_80AA340(var); - sub_80AA388(var); - sub_80AA3D0(var); - sub_80AA418(var); - sub_80AA460(var); - sub_80AA4A8(var); + sub_80AA340(var); + sub_80AA388(var); + sub_80AA3D0(var); + sub_80AA418(var); + sub_80AA460(var); + sub_80AA4A8(var); - for(i = 0; i < 4; i++) - sub_80AA4F0(var, i); + for (i = 0; i < 4; i++) + sub_80AA4F0(var, i); } void SetDebugMonForContest(void) { - SetMonData(&gPlayerParty[0], MON_DATA_COOL, &gContestMons[gContestPlayerMonIndex].cool); - SetMonData(&gPlayerParty[0], MON_DATA_CUTE, &gContestMons[gContestPlayerMonIndex].cute); - SetMonData(&gPlayerParty[0], MON_DATA_BEAUTY, &gContestMons[gContestPlayerMonIndex].beauty); - SetMonData(&gPlayerParty[0], MON_DATA_SMART, &gContestMons[gContestPlayerMonIndex].smart); - SetMonData(&gPlayerParty[0], MON_DATA_TOUGH, &gContestMons[gContestPlayerMonIndex].tough); - SetMonData(&gPlayerParty[0], MON_DATA_SHEEN, &gContestMons[gContestPlayerMonIndex].sheen); - SetMonData(&gPlayerParty[0], MON_DATA_MOVE1, (const u8 *) &gContestMons[gContestPlayerMonIndex].moves[0]); - SetMonData(&gPlayerParty[0], MON_DATA_MOVE2, (const u8 *) &gContestMons[gContestPlayerMonIndex].moves[1]); - SetMonData(&gPlayerParty[0], MON_DATA_MOVE3, (const u8 *) &gContestMons[gContestPlayerMonIndex].moves[2]); - SetMonData(&gPlayerParty[0], MON_DATA_MOVE4, (const u8 *) &gContestMons[gContestPlayerMonIndex].moves[3]); + SetMonData(&gPlayerParty[0], MON_DATA_COOL, &gContestMons[gContestPlayerMonIndex].cool); + SetMonData(&gPlayerParty[0], MON_DATA_CUTE, &gContestMons[gContestPlayerMonIndex].cute); + SetMonData(&gPlayerParty[0], MON_DATA_BEAUTY, &gContestMons[gContestPlayerMonIndex].beauty); + SetMonData(&gPlayerParty[0], MON_DATA_SMART, &gContestMons[gContestPlayerMonIndex].smart); + SetMonData(&gPlayerParty[0], MON_DATA_TOUGH, &gContestMons[gContestPlayerMonIndex].tough); + SetMonData(&gPlayerParty[0], MON_DATA_SHEEN, &gContestMons[gContestPlayerMonIndex].sheen); + SetMonData(&gPlayerParty[0], MON_DATA_MOVE1, (const u8 *) &gContestMons[gContestPlayerMonIndex].moves[0]); + SetMonData(&gPlayerParty[0], MON_DATA_MOVE2, (const u8 *) &gContestMons[gContestPlayerMonIndex].moves[1]); + SetMonData(&gPlayerParty[0], MON_DATA_MOVE3, (const u8 *) &gContestMons[gContestPlayerMonIndex].moves[2]); + SetMonData(&gPlayerParty[0], MON_DATA_MOVE4, (const u8 *) &gContestMons[gContestPlayerMonIndex].moves[3]); } -// too complicated -__attribute__((naked)) void sub_80AA754(struct Sprite *sprite) { - asm(".syntax unified\n\ - push {r4,lr}\n\ - adds r4, r0, 0\n\ - ldr r0, _080AA774 @ =gMain\n\ - ldrh r1, [r0, 0x30]\n\ - cmp r1, 0x20\n\ - beq _080AA7A2\n\ - cmp r1, 0x20\n\ - bgt _080AA782\n\ - cmp r1, 0x2\n\ - beq _080AA7F8\n\ - cmp r1, 0x2\n\ - bgt _080AA778\n\ - cmp r1, 0x1\n\ - beq _080AA7D8\n\ - b _080AA870\n\ - .align 2, 0\n\ -_080AA774: .4byte gMain\n\ -_080AA778:\n\ - cmp r1, 0x8\n\ - beq _080AA868\n\ - cmp r1, 0x10\n\ - beq _080AA7A2\n\ - b _080AA870\n\ -_080AA782:\n\ - cmp r1, 0x80\n\ - beq _080AA7C2\n\ - cmp r1, 0x80\n\ - bgt _080AA790\n\ - cmp r1, 0x40\n\ - beq _080AA7AC\n\ - b _080AA870\n\ -_080AA790:\n\ - movs r0, 0x80\n\ - lsls r0, 1\n\ - cmp r1, r0\n\ - beq _080AA814\n\ - movs r0, 0x80\n\ - lsls r0, 2\n\ - cmp r1, r0\n\ - beq _080AA834\n\ - b _080AA870\n\ -_080AA7A2:\n\ - ldrh r0, [r4, 0x2E]\n\ - movs r1, 0x1\n\ - eors r0, r1\n\ - strh r0, [r4, 0x2E]\n\ - b _080AA870\n\ -_080AA7AC:\n\ - ldrh r1, [r4, 0x30]\n\ - movs r2, 0x30\n\ - ldrsh r0, [r4, r2]\n\ - cmp r0, 0\n\ - bne _080AA7BC\n\ - movs r0, 0x8\n\ - strh r0, [r4, 0x30]\n\ - b _080AA870\n\ -_080AA7BC:\n\ - subs r0, r1, 0x1\n\ - strh r0, [r4, 0x30]\n\ - b _080AA870\n\ -_080AA7C2:\n\ - ldrh r1, [r4, 0x30]\n\ - movs r3, 0x30\n\ - ldrsh r0, [r4, r3]\n\ - cmp r0, 0x8\n\ - bne _080AA7D2\n\ - movs r0, 0\n\ - strh r0, [r4, 0x30]\n\ - b _080AA870\n\ -_080AA7D2:\n\ - adds r0, r1, 0x1\n\ - strh r0, [r4, 0x30]\n\ - b _080AA870\n\ -_080AA7D8:\n\ - ldr r2, _080AA7F4 @ =gUnknown_083C92E4\n\ - movs r1, 0x2E\n\ - ldrsh r0, [r4, r1]\n\ - lsls r0, 2\n\ - movs r3, 0x30\n\ - ldrsh r1, [r4, r3]\n\ - lsls r1, 3\n\ - adds r0, r1\n\ - adds r0, r2\n\ - ldr r2, [r0]\n\ - adds r0, r4, 0\n\ - movs r1, 0x1\n\ - b _080AA84E\n\ - .align 2, 0\n\ -_080AA7F4: .4byte gUnknown_083C92E4\n\ -_080AA7F8:\n\ - ldr r1, _080AA810 @ =gUnknown_083C92E4\n\ - movs r0, 0x2E\n\ - ldrsh r2, [r4, r0]\n\ - lsls r2, 2\n\ - movs r3, 0x30\n\ - ldrsh r0, [r4, r3]\n\ - lsls r0, 3\n\ - adds r2, r0\n\ - adds r2, r1\n\ - movs r1, 0x1\n\ - negs r1, r1\n\ - b _080AA84A\n\ - .align 2, 0\n\ -_080AA810: .4byte gUnknown_083C92E4\n\ -_080AA814:\n\ - ldr r2, _080AA830 @ =gUnknown_083C92E4\n\ - movs r1, 0x2E\n\ - ldrsh r0, [r4, r1]\n\ - lsls r0, 2\n\ - movs r3, 0x30\n\ - ldrsh r1, [r4, r3]\n\ - lsls r1, 3\n\ - adds r0, r1\n\ - adds r0, r2\n\ - ldr r2, [r0]\n\ - adds r0, r4, 0\n\ - movs r1, 0xA\n\ - b _080AA84E\n\ - .align 2, 0\n\ -_080AA830: .4byte gUnknown_083C92E4\n\ -_080AA834:\n\ - ldr r1, _080AA864 @ =gUnknown_083C92E4\n\ - movs r0, 0x2E\n\ - ldrsh r2, [r4, r0]\n\ - lsls r2, 2\n\ - movs r3, 0x30\n\ - ldrsh r0, [r4, r3]\n\ - lsls r0, 3\n\ - adds r2, r0\n\ - adds r2, r1\n\ - movs r1, 0xA\n\ - negs r1, r1\n\ -_080AA84A:\n\ - ldr r2, [r2]\n\ - adds r0, r4, 0\n\ -_080AA84E:\n\ - bl _call_via_r2\n\ - ldrh r0, [r4, 0x32]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - ldrh r1, [r4, 0x34]\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - bl sub_80AA614\n\ - b _080AA870\n\ - .align 2, 0\n\ -_080AA864: .4byte gUnknown_083C92E4\n\ -_080AA868:\n\ - adds r0, r4, 0\n\ - movs r1, 0x1\n\ - bl sub_80AAD08\n\ -_080AA870:\n\ - ldr r2, _080AA898 @ =gUnknown_083C9296\n\ - movs r0, 0x2E\n\ - ldrsh r1, [r4, r0]\n\ - movs r3, 0x30\n\ - ldrsh r0, [r4, r3]\n\ - lsls r0, 1\n\ - adds r1, r0\n\ - adds r1, r2\n\ - ldrb r0, [r1]\n\ - strh r0, [r4, 0x20]\n\ - ldr r1, _080AA89C @ =gUnknown_083C92A8\n\ - movs r2, 0x30\n\ - ldrsh r0, [r4, r2]\n\ - adds r0, r1\n\ - ldrb r0, [r0]\n\ - strh r0, [r4, 0x22]\n\ - pop {r4}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_080AA898: .4byte gUnknown_083C9296\n\ -_080AA89C: .4byte gUnknown_083C92A8\n\ - .syntax divided"); + switch (gMain.newAndRepeatedKeys) + { + case DPAD_RIGHT: + case DPAD_LEFT: + sprite->data0 ^= 1; + break; + case DPAD_UP: + if (sprite->data1 == 0) + sprite->data1 = 8; + else + sprite->data1--; + break; + case DPAD_DOWN: + if (sprite->data1 == 8) + sprite->data1 = 0; + else + sprite->data1++; + break; + case A_BUTTON: + gUnknown_083C92E4[sprite->data1][sprite->data0](sprite, 1); + sub_80AA614(sprite->data2, sprite->data3); + break; + case B_BUTTON: + gUnknown_083C92E4[sprite->data1][sprite->data0](sprite, -1); + sub_80AA614(sprite->data2, sprite->data3); + break; + case R_BUTTON: + gUnknown_083C92E4[sprite->data1][sprite->data0](sprite, 10); + sub_80AA614(sprite->data2, sprite->data3); + break; + case L_BUTTON: + gUnknown_083C92E4[sprite->data1][sprite->data0](sprite, -10); + sub_80AA614(sprite->data2, sprite->data3); + break; + case START_BUTTON: + sub_80AAD08(sprite, 1); + break; + } + sprite->pos1.x = gUnknown_083C9296[sprite->data0 + sprite->data1 * 2]; + sprite->pos1.y = gUnknown_083C92A8[sprite->data1]; } static void sub_80AA8A0(struct Sprite *sprite, s8 var1, u8 var2) { - if(var1 == 1) - { - sprite->data2 = var2; - sub_80AA280(var2); - sub_80AA658(sprite->data2); - } + if (var1 == 1) + { + sprite->data2 = var2; + sub_80AA280(var2); + sub_80AA658(sprite->data2); + } } void sub_80AA8C8(struct Sprite *sprite, s8 var1) { - sub_80AA8A0(sprite, var1, 0); + sub_80AA8A0(sprite, var1, 0); } void sub_80AA8D8(struct Sprite *sprite, s8 var1) { - sub_80AA8A0(sprite, var1, 1); + sub_80AA8A0(sprite, var1, 1); } void sub_80AA8E8(struct Sprite *sprite, s8 var1) { - sub_80AA8A0(sprite, var1, 2); + sub_80AA8A0(sprite, var1, 2); } void sub_80AA8F8(struct Sprite *sprite, s8 var1) { - sub_80AA8A0(sprite, var1, 3); + sub_80AA8A0(sprite, var1, 3); } static u8 sub_80AA908(u32 a1, u8 a2, s8 a3) // first param is unused. @@ -760,48 +612,48 @@ void sub_80AA930(struct Sprite *sprite, u8 var2) { u8 val = sprite->data2; - gContestMons[sprite->data2].cool = sub_80AA908(val, gContestMons[sprite->data2].cool, var2); - sub_80AA340(sprite->data2); + gContestMons[sprite->data2].cool = sub_80AA908(val, gContestMons[sprite->data2].cool, var2); + sub_80AA340(sprite->data2); } void sub_80AA974(struct Sprite *sprite, u8 var2) { u8 val = sprite->data2; - gContestMons[sprite->data2].cute = sub_80AA908(val, gContestMons[sprite->data2].cute, var2); - sub_80AA388(sprite->data2); + gContestMons[sprite->data2].cute = sub_80AA908(val, gContestMons[sprite->data2].cute, var2); + sub_80AA388(sprite->data2); } void sub_80AA9B8(struct Sprite *sprite, u8 var2) { u8 val = sprite->data2; - gContestMons[sprite->data2].beauty = sub_80AA908(val, gContestMons[sprite->data2].beauty, var2); - sub_80AA3D0(sprite->data2); + gContestMons[sprite->data2].beauty = sub_80AA908(val, gContestMons[sprite->data2].beauty, var2); + sub_80AA3D0(sprite->data2); } void sub_80AA9FC(struct Sprite *sprite, u8 var2) { u8 val = sprite->data2; - gContestMons[sprite->data2].smart = sub_80AA908(val, gContestMons[sprite->data2].smart, var2); - sub_80AA418(sprite->data2); + gContestMons[sprite->data2].smart = sub_80AA908(val, gContestMons[sprite->data2].smart, var2); + sub_80AA418(sprite->data2); } void sub_80AAA40(struct Sprite *sprite, u8 var2) { u8 val = sprite->data2; - gContestMons[sprite->data2].tough = sub_80AA908(val, gContestMons[sprite->data2].tough, var2); - sub_80AA460(sprite->data2); + gContestMons[sprite->data2].tough = sub_80AA908(val, gContestMons[sprite->data2].tough, var2); + sub_80AA460(sprite->data2); } void sub_80AAA84(struct Sprite *sprite, u8 var2) { u8 val = sprite->data2; - gContestMons[sprite->data2].sheen = sub_80AA908(val, gContestMons[sprite->data2].sheen, var2); - sub_80AA4A8(sprite->data2); + gContestMons[sprite->data2].sheen = sub_80AA908(val, gContestMons[sprite->data2].sheen, var2); + sub_80AA4A8(sprite->data2); } // a similar function is at 0x80AA908, however, it apparently returns the wrong type (u8 vs u16). @@ -821,326 +673,441 @@ void sub_80AAAF0(struct Sprite *sprite, u8 var2) { u8 val = sprite->data2; - gContestMons[sprite->data2].moves[0] = sub_80AAAC8(val, gContestMons[sprite->data2].moves[0], var2); - sub_80AA4F0(sprite->data2, 0); + gContestMons[sprite->data2].moves[0] = sub_80AAAC8(val, gContestMons[sprite->data2].moves[0], var2); + sub_80AA4F0(sprite->data2, 0); } void sub_80AAB30(struct Sprite *sprite, u8 var2) { u8 val = sprite->data2; - gContestMons[sprite->data2].moves[1] = sub_80AAAC8(val, gContestMons[sprite->data2].moves[1], var2); - sub_80AA4F0(sprite->data2, 1); + gContestMons[sprite->data2].moves[1] = sub_80AAAC8(val, gContestMons[sprite->data2].moves[1], var2); + sub_80AA4F0(sprite->data2, 1); } void sub_80AAB70(struct Sprite *sprite, u8 var2) { u8 val = sprite->data2; - gContestMons[sprite->data2].moves[2] = sub_80AAAC8(val, gContestMons[sprite->data2].moves[2], var2); - sub_80AA4F0(sprite->data2, 2); + gContestMons[sprite->data2].moves[2] = sub_80AAAC8(val, gContestMons[sprite->data2].moves[2], var2); + sub_80AA4F0(sprite->data2, 2); } void sub_80AABB0(struct Sprite *sprite, u8 var2) { u8 val = sprite->data2; - gContestMons[sprite->data2].moves[3] = sub_80AAAC8(val, gContestMons[sprite->data2].moves[3], var2); - sub_80AA4F0(sprite->data2, 3); + gContestMons[sprite->data2].moves[3] = sub_80AAAC8(val, gContestMons[sprite->data2].moves[3], var2); + sub_80AA4F0(sprite->data2, 3); } -// hard/weird function #2 -__attribute__((naked)) -void sub_80AABF0(struct Sprite *sprite, u8 var2) -{ - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - adds r5, r0, 0\n\ - lsls r1, 24\n\ - movs r0, 0xFF\n\ - cmp r1, 0\n\ - ble _080AABFE\n\ - movs r0, 0x1\n\ -_080AABFE:\n\ - lsls r0, 24\n\ - asrs r0, 24\n\ - ldrh r1, [r5, 0x34]\n\ - adds r0, r1\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - asrs r0, 24\n\ - cmp r0, 0\n\ - bge _080AAC14\n\ - movs r4, 0\n\ - b _080AAC1A\n\ -_080AAC14:\n\ - cmp r0, 0x4\n\ - ble _080AAC1A\n\ - movs r4, 0x4\n\ -_080AAC1A:\n\ - lsls r4, 24\n\ - lsrs r0, r4, 24\n\ - bl sub_80AA5BC\n\ - asrs r4, 24\n\ - strh r4, [r5, 0x34]\n\ - ldr r0, _080AAC54 @ =gScriptContestCategory\n\ - strh r4, [r0]\n\ - lsls r4, 24\n\ - lsrs r4, 24\n\ - ldr r0, _080AAC58 @ =gScriptContestRank\n\ - ldrb r1, [r0]\n\ - adds r0, r4, 0\n\ - bl sub_80AE398\n\ - ldrh r0, [r5, 0x32]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - bl sub_80AA280\n\ - ldrh r0, [r5, 0x32]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - bl sub_80AA658\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_080AAC54: .4byte gScriptContestCategory\n\ -_080AAC58: .4byte gScriptContestRank\n\ - .syntax divided"); +void sub_80AABF0(struct Sprite *sprite, s8 var2) +{ + s8 a = (var2 > 0) ? 1 : -1; + s8 r4 = sprite->data3 + a; + + if (r4 < 0) + r4 = 0; + else if (r4 > 4) + r4 = 4; + sub_80AA5BC(r4); + sprite->data3 = r4; + gScriptContestCategory = sprite->data3; + sub_80AE398(sprite->data3, gScriptContestRank); + sub_80AA280(sprite->data2); + sub_80AA658(sprite->data2); } -/* - thumb_func_start sub_80AABF0 -sub_80AABF0: @ 80AABF0 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r1, 24 - movs r0, 0xFF - cmp r1, 0 - ble _080AABFE - movs r0, 0x1 -_080AABFE: - lsls r0, 24 - asrs r0, 24 - ldrh r1, [r5, 0x34] - adds r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - asrs r0, 24 - cmp r0, 0 - bge _080AAC14 - movs r4, 0 - b _080AAC1A -_080AAC14: - cmp r0, 0x4 - ble _080AAC1A - movs r4, 0x4 -_080AAC1A: - lsls r4, 24 - lsrs r0, r4, 24 - bl sub_80AA5BC - asrs r4, 24 - strh r4, [r5, 0x34] - ldr r0, _080AAC54 @ =gScriptContestCategory - strh r4, [r0] - lsls r4, 24 - lsrs r4, 24 - ldr r0, _080AAC58 @ =gScriptContestRank - ldrb r1, [r0] - adds r0, r4, 0 - bl sub_80AE398 - ldrh r0, [r5, 0x32] - lsls r0, 24 - lsrs r0, 24 - bl sub_80AA280 - ldrh r0, [r5, 0x32] - lsls r0, 24 - lsrs r0, 24 - bl sub_80AA658 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_080AAC54: .4byte gScriptContestCategory -_080AAC58: .4byte gScriptContestRank - thumb_func_end sub_80AABF0 -*/ +void sub_80AAC5C(struct Sprite *sprite, s8 var2) +{ + if (var2 > 0) + gScriptContestRank++; + else if (gScriptContestRank != 0) + gScriptContestRank--; + if (gScriptContestRank > 3) + gScriptContestRank = 3; + sub_80AA5E8(gScriptContestRank); + sub_80AE398(gScriptContestCategory, gScriptContestRank); + sub_80AA280(sprite->data2); + sub_80AA658(sprite->data2); +} + +void sub_80AACC4(void) +{ + UpdatePaletteFade(); + if (!gPaletteFade.active) + { + SetDebugMonForContest(); + if (!(gIsLinkContest & 1)) + sub_80AE82C(unk_2000000[0]); + SetMainCallback2(sub_80AB47C); + } +} +void sub_80AAD08(struct Sprite *sprite, s8 var2) +{ + if (var2 == 1) + { + unk_2000000[0] = sprite->data3; + SetMainCallback2(sub_80AACC4); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + } +} + +void sub_80AAD44(struct Sprite *sprite, s8 var2) +{ + if (var2 == 1) + { + int i; + + SetDebugMonForContest(); + for (i = 0; i < 4; i++) + gUnknown_02038670[i] = sub_80AE770(i, gScriptContestCategory); + SetMainCallback2(sub_805469C); + } +} + +//Do this later /* - thumb_func_start sub_80AA754 -sub_80AA754: @ 80AA754 - push {r4,lr} - adds r4, r0, 0 - ldr r0, _080AA774 @ =gMain - ldrh r1, [r0, 0x30] - cmp r1, 0x20 - beq _080AA7A2 - cmp r1, 0x20 - bgt _080AA782 - cmp r1, 0x2 - beq _080AA7F8 - cmp r1, 0x2 - bgt _080AA778 - cmp r1, 0x1 - beq _080AA7D8 - b _080AA870 - .align 2, 0 -_080AA774: .4byte gMain -_080AA778: - cmp r1, 0x8 - beq _080AA868 - cmp r1, 0x10 - beq _080AA7A2 - b _080AA870 -_080AA782: - cmp r1, 0x80 - beq _080AA7C2 - cmp r1, 0x80 - bgt _080AA790 - cmp r1, 0x40 - beq _080AA7AC - b _080AA870 -_080AA790: - movs r0, 0x80 - lsls r0, 1 - cmp r1, r0 - beq _080AA814 - movs r0, 0x80 - lsls r0, 2 - cmp r1, r0 - beq _080AA834 - b _080AA870 -_080AA7A2: - ldrh r0, [r4, 0x2E] - movs r1, 0x1 - eors r0, r1 - strh r0, [r4, 0x2E] - b _080AA870 -_080AA7AC: - ldrh r1, [r4, 0x30] - movs r2, 0x30 - ldrsh r0, [r4, r2] - cmp r0, 0 - bne _080AA7BC - movs r0, 0x8 - strh r0, [r4, 0x30] - b _080AA870 -_080AA7BC: - subs r0, r1, 0x1 - strh r0, [r4, 0x30] - b _080AA870 -_080AA7C2: - ldrh r1, [r4, 0x30] - movs r3, 0x30 - ldrsh r0, [r4, r3] - cmp r0, 0x8 - bne _080AA7D2 - movs r0, 0 - strh r0, [r4, 0x30] - b _080AA870 -_080AA7D2: - adds r0, r1, 0x1 - strh r0, [r4, 0x30] - b _080AA870 -_080AA7D8: - ldr r2, _080AA7F4 @ =gUnknown_083C92E4 - movs r1, 0x2E - ldrsh r0, [r4, r1] - lsls r0, 2 - movs r3, 0x30 - ldrsh r1, [r4, r3] - lsls r1, 3 - adds r0, r1 - adds r0, r2 - ldr r2, [r0] - adds r0, r4, 0 - movs r1, 0x1 - b _080AA84E - .align 2, 0 -_080AA7F4: .4byte gUnknown_083C92E4 -_080AA7F8: - ldr r1, _080AA810 @ =gUnknown_083C92E4 - movs r0, 0x2E - ldrsh r2, [r4, r0] - lsls r2, 2 - movs r3, 0x30 - ldrsh r0, [r4, r3] - lsls r0, 3 - adds r2, r0 - adds r2, r1 - movs r1, 0x1 - negs r1, r1 - b _080AA84A - .align 2, 0 -_080AA810: .4byte gUnknown_083C92E4 -_080AA814: - ldr r2, _080AA830 @ =gUnknown_083C92E4 - movs r1, 0x2E - ldrsh r0, [r4, r1] - lsls r0, 2 - movs r3, 0x30 - ldrsh r1, [r4, r3] - lsls r1, 3 - adds r0, r1 - adds r0, r2 - ldr r2, [r0] - adds r0, r4, 0 - movs r1, 0xA - b _080AA84E - .align 2, 0 -_080AA830: .4byte gUnknown_083C92E4 -_080AA834: - ldr r1, _080AA864 @ =gUnknown_083C92E4 - movs r0, 0x2E - ldrsh r2, [r4, r0] - lsls r2, 2 - movs r3, 0x30 - ldrsh r0, [r4, r3] - lsls r0, 3 - adds r2, r0 - adds r2, r1 - movs r1, 0xA - negs r1, r1 -_080AA84A: - ldr r2, [r2] - adds r0, r4, 0 -_080AA84E: - bl _call_via_r2 - ldrh r0, [r4, 0x32] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x34] - lsls r1, 24 - lsrs r1, 24 - bl sub_80AA614 - b _080AA870 - .align 2, 0 -_080AA864: .4byte gUnknown_083C92E4 -_080AA868: - adds r0, r4, 0 - movs r1, 0x1 - bl sub_80AAD08 -_080AA870: - ldr r2, _080AA898 @ =gUnknown_083C9296 - movs r0, 0x2E - ldrsh r1, [r4, r0] - movs r3, 0x30 - ldrsh r0, [r4, r3] - lsls r0, 1 - adds r1, r0 - adds r1, r2 - ldrb r0, [r1] - strh r0, [r4, 0x20] - ldr r1, _080AA89C @ =gUnknown_083C92A8 - movs r2, 0x30 - ldrsh r0, [r4, r2] - adds r0, r1 - ldrb r0, [r0] - strh r0, [r4, 0x22] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080AA898: .4byte gUnknown_083C9296 -_080AA89C: .4byte gUnknown_083C92A8 - thumb_func_end sub_80AA754 +void sub_80AAD84(u8 *string, u8 b, u8 c, u8 d) +{ + u32 r5; + u16 r7; + u8 r7_2; + //u32 sp44; + //u32 sp48; + u32 sp58; + + gMain.state = 0; + + r5 = d + 1; + //Could also be DmaClear32 + DmaFill32(3, 0, (u8 *)VRAM + 0x18000 - r5 * 256, 0x100); + + r7 = StringLength(string); + if (r7 > 8) + r7 = 8; + sp58 = d * 2; + + //More stuff + + r7_2 = 0x7C - sp58; + +} */ + +__attribute__((naked)) +void sub_80AAD84(u8 *string, u8 b, u8 c, u8 d) +{ + 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, 0x64\n\ + mov r9, r0\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + str r1, [sp, 0x48]\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + str r2, [sp, 0x4C]\n\ + lsls r3, 24\n\ + lsrs r3, 24\n\ + mov r10, r3\n\ + mov r5, r10\n\ + adds r5, 0x1\n\ + lsls r1, r5, 8\n\ + ldr r0, _080AAEC4 @ =0x06018000\n\ + subs r1, r0, r1\n\ + movs r0, 0\n\ + str r0, [sp, 0x44]\n\ + ldr r4, _080AAEC8 @ =0x040000d4\n\ + add r0, sp, 0x44\n\ + str r0, [r4]\n\ + str r1, [r4, 0x4]\n\ + ldr r0, _080AAECC @ =0x85000040\n\ + str r0, [r4, 0x8]\n\ + ldr r0, [r4, 0x8]\n\ + mov r0, r9\n\ + bl StringLength\n\ + lsls r0, 16\n\ + lsrs r7, r0, 16\n\ + cmp r7, 0x8\n\ + bls _080AADD0\n\ + movs r7, 0x8\n\ +_080AADD0:\n\ + movs r6, 0\n\ + mov r8, r5\n\ + mov r1, r10\n\ + lsls r1, 1\n\ + str r1, [sp, 0x58]\n\ + ldr r2, [sp, 0x48]\n\ + adds r2, 0x20\n\ + str r2, [sp, 0x5C]\n\ + cmp r6, r7\n\ + bge _080AAE1E\n\ + add r5, sp, 0x40\n\ + add r0, sp, 0x20\n\ + mov r10, r0\n\ + ldr r2, _080AAEC4 @ =0x06018000\n\ +_080AADEC:\n\ + mov r1, r9\n\ + adds r0, r1, r6\n\ + ldrb r0, [r0]\n\ + strb r0, [r5]\n\ + movs r0, 0xFF\n\ + strb r0, [r5, 0x1]\n\ + mov r0, sp\n\ + adds r1, r5, 0\n\ + str r2, [sp, 0x60]\n\ + bl sub_80034D4\n\ + mov r1, r8\n\ + lsls r0, r1, 8\n\ + ldr r2, [sp, 0x60]\n\ + subs r0, r2, r0\n\ + mov r1, r10\n\ + str r1, [r4]\n\ + str r0, [r4, 0x4]\n\ + ldr r0, _080AAED0 @ =0x84000008\n\ + str r0, [r4, 0x8]\n\ + ldr r0, [r4, 0x8]\n\ + adds r2, 0x20\n\ + adds r6, 0x1\n\ + cmp r6, r7\n\ + blt _080AADEC\n\ +_080AAE1E:\n\ + movs r1, 0x7C\n\ + ldr r2, [sp, 0x58]\n\ + subs r1, r2\n\ + lsls r1, 24\n\ + lsrs r7, r1, 24\n\ + ldr r0, _080AAED4 @ =gMain\n\ + mov r9, r0\n\ + lsls r3, r7, 3\n\ + add r3, r9\n\ + ldr r0, _080AAED8 @ =gUnknown_083C9400\n\ + ldr r1, [r0]\n\ + ldr r2, [r0, 0x4]\n\ + str r1, [sp, 0x50]\n\ + str r2, [sp, 0x54]\n\ + str r1, [r3, 0x3C]\n\ + str r2, [r3, 0x40]\n\ + mov r2, r8\n\ + lsls r0, r2, 3\n\ + movs r1, 0x80\n\ + lsls r1, 3\n\ + adds r2, r1, 0\n\ + subs r2, r0\n\ + adds r6, r3, 0\n\ + adds r6, 0x40\n\ + ldr r0, _080AAEDC @ =0x000003ff\n\ + mov r8, r0\n\ + mov r1, r8\n\ + ands r2, r1\n\ + ldrh r5, [r6]\n\ + ldr r4, _080AAEE0 @ =0xfffffc00\n\ + adds r0, r4, 0\n\ + ands r0, r5\n\ + orrs r0, r2\n\ + strh r0, [r6]\n\ + ldrh r5, [r3, 0x3E]\n\ + ldr r2, _080AAEE4 @ =0xfffffe00\n\ + adds r0, r2, 0\n\ + ands r0, r5\n\ + ldr r1, [sp, 0x48]\n\ + orrs r0, r1\n\ + strh r0, [r3, 0x3E]\n\ + adds r3, 0x3C\n\ + add r0, sp, 0x4C\n\ + ldrb r0, [r0]\n\ + strb r0, [r3]\n\ + adds r1, r7, 0x1\n\ + lsls r1, 3\n\ + mov r0, r9\n\ + adds r7, r1, r0\n\ + ldr r0, [sp, 0x50]\n\ + ldr r1, [sp, 0x54]\n\ + str r0, [r7, 0x3C]\n\ + str r1, [r7, 0x40]\n\ + ldrh r0, [r6]\n\ + lsls r0, 22\n\ + lsrs r0, 22\n\ + adds r0, 0x4\n\ + adds r5, r7, 0\n\ + adds r5, 0x40\n\ + mov r1, r8\n\ + ands r0, r1\n\ + ldrh r3, [r5]\n\ + ands r4, r3\n\ + orrs r4, r0\n\ + strh r4, [r5]\n\ + ldrh r0, [r7, 0x3E]\n\ + ands r2, r0\n\ + ldr r0, [sp, 0x5C]\n\ + orrs r2, r0\n\ + strh r2, [r7, 0x3E]\n\ + adds r1, r7, 0\n\ + adds r1, 0x3C\n\ + add r2, sp, 0x4C\n\ + ldrb r2, [r2]\n\ + strb r2, [r1]\n\ + add sp, 0x64\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\ + .align 2, 0\n\ +_080AAEC4: .4byte 0x06018000\n\ +_080AAEC8: .4byte 0x040000d4\n\ +_080AAECC: .4byte 0x85000040\n\ +_080AAED0: .4byte 0x84000008\n\ +_080AAED4: .4byte gMain\n\ +_080AAED8: .4byte gUnknown_083C9400\n\ +_080AAEDC: .4byte 0x000003ff\n\ +_080AAEE0: .4byte 0xfffffc00\n\ +_080AAEE4: .4byte 0xfffffe00\n\ + .syntax divided\n"); +} + +void unref_sub_80AAEE8(s32 a, u8 b, u8 c, u8 d) +{ + u8 string[12]; + u8 offset = 0; + + if (a < 0) + { + string[0] = 0xAE; + offset = 1; + } + ConvertIntToDecimalStringN(string + offset, (a < 0) ? -a : a, 0, 8); + sub_80AAD84(string, b, c, d); +} + +void sub_80AAF30(void) +{ + s32 i; + + gUnknown_0203856C = 1; + gContestPlayerMonIndex = 3; + sub_80AE098(0); + + for (i = 3; i > -1; i--) + gUnknown_02038690[i] = 3 - i; + + for (i = 0; i < 3; i++) + { + gUnknown_02038670[i] = 0; + gUnknown_02038680[i] = 0; + gUnknown_02038678[i] = 0; + memcpy(&gContestMons[i], &gContestMons[3], sizeof(struct ContestPokemon)); + } + + gUnknown_02038670[3] = 0x12C; + gUnknown_02038680[3] = 0x190; + gUnknown_02038678[3] = 0x190; + sub_80B2A7C(0xFE); +} + +//Don't know size of return type +int MatsudaDebugMenu_SetHighScore(void) +{ + sub_80AAF30(); + CloseMenu(); + return 1; +} + +//Don't know size of return type +int MatsudaDebugMenu_ResetHighScore(void) +{ + s32 i; + + gUnknown_0203856C = 0; + for (i = 0; i < 4; i++) + { + gUnknown_02038670[i] = 0; + gUnknown_02038680[i] = 0; + gUnknown_02038678[i] = 0; + } + CloseMenu(); + return 1; +} + +//Don't know size of return type +int MatsudaDebugMenu_SetArtMuseumItems(void) +{ + s32 i; + + gContestPlayerMonIndex = 3; + sub_80AE098(0); + for (i = 3; i > -1; i--) + gUnknown_02038690[i] = 3 - i; + for (gScriptContestCategory = 0; gScriptContestCategory < 5; gScriptContestCategory++) + sub_80B2A7C(0xFF); + CloseMenu(); + return 1; +} + +void unref_sub_80AB084(u8 *text) +{ + u16 savedIme; + u8 *addr; + size_t size; + + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG2HOFS = 0; + REG_BG2VOFS = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; + REG_WIN0H = 0; + REG_WIN0V = 0; + REG_WIN1H = 0; + REG_WIN1V = 0; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON; + + savedIme = REG_IME; + REG_IME = 0; + REG_IE |= INTR_FLAG_VBLANK; + REG_IME = savedIme; + REG_DISPSTAT = 8; + ResetTasks(); + ResetSpriteData(); + SetMainCallback2(sub_80AB184); + + addr = (void *)VRAM; + size = 0x18000; + while (1) + { + DmaFill32(3, 0, addr, 0x1000); + addr += 0x1000; + size -= 0x1000; + if (size <= 0x1000) + { + DmaFill32(3, 0, addr, size); + break; + } + } + SetUpWindowConfig(&gWindowConfig_81E6FD8); + InitWindowFromConfig(&gUnknown_03004210, &gWindowConfig_81E6FD8); + LoadFontDefaultPalette(&gWindowConfig_81E6FD8); + sub_8003460(&gUnknown_03004210, text, 1, 9, 7); +} + +void sub_80AB184(void) +{ + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG2HOFS = 0; + REG_BG2VOFS = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; +} diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c new file mode 100644 index 000000000..93684fc60 --- /dev/null +++ b/src/mauville_old_man.c @@ -0,0 +1,247 @@ +#include "global.h" +#include "mauville_old_man.h" +#include "easy_chat.h" +#include "menu.h" +#include "rng.h" +#include "script.h" +#include "string_util.h" +#include "strings.h" +#include "trader.h" + +extern u16 gScriptResult; +extern u16 gSpecialVar_0x8004; + +extern u32 gUnknown_083E5388[]; +extern u32 gUnknown_083E53A8[]; + +extern u16 gUnknown_083E537C[]; + +void sub_80F7A34(void) +{ + u16 i; + OldMan *oldMan = &gSaveBlock1.oldMan; + + oldMan->oldMan1.unk_2D94 = 0; + oldMan->oldMan1.unk_2DBD = 0; + + for(i = 0; i < 6; i++) + oldMan->oldMan1.mauvilleOldMan_ecArray[i] = gUnknown_083E537C[i]; +} + +void sub_80F7A6C(void) +{ + struct UnkMauvilleOldManStruct *bard = &gSaveBlock1.oldMan.oldMan1; + + bard->unk_2D94 = 1; + bard->unk_2D95 = 0; +} + +void sub_80F7A7C(void) +{ + sub_80F83F8(); +} + +void sub_80F7A88(void) +{ + OldMan *oldMan = &gSaveBlock1.oldMan; + + oldMan->oldMan1.unk_2D94 = 4; + oldMan->oldMan1.unk_2D95 = 0; +} + +void sub_80F7A98(void) +{ + sub_81099CC(); +} + +void SetMauvilleOldMan(void) +{ + u32 var = ((u16)((gSaveBlock2.playerTrainerId[1] << 8 | gSaveBlock2.playerTrainerId[0])) % 10) / 2; + + switch(var) + { + case 0: + sub_80F7A34(); + break; + case 1: + sub_80F7A6C(); + break; + case 2: + sub_80F7A98(); + break; + case 3: + sub_80F7A7C(); + break; + case 4: + sub_80F7A88(); + break; + } + sub_80F83D0(); +} + +u8 GetCurrentMauvilleOldMan(void) +{ + OldMan *oldMan = &gSaveBlock1.oldMan; + + return oldMan->oldMan1.unk_2D94; +} + +void sub_80F7B14(void) +{ + gScriptResult = GetCurrentMauvilleOldMan(); +} + +void sub_80F7B2C(void) +{ + u16 *scriptPtr = &gScriptResult; // why?? + OldMan *oldMan = &gSaveBlock1.oldMan; + + *scriptPtr = oldMan->oldMan1.unk_2DBD; +} + +void sub_80F7B40(void) +{ + u16 i; + OldMan *oldMan = &gSaveBlock1.oldMan; + //struct UnkMauvilleOldManStruct *oldManStruct = &gSaveBlock1.oldManStruct; + + StringCopy(oldMan->oldMan1.playerName, gSaveBlock2.playerName); + + for(i = 0; i < 4; i++) + oldMan->oldMan1.playerTrainerId[i] = gSaveBlock2.playerTrainerId[i]; + + for(i = 0; i < 6; i++) + oldMan->oldMan1.mauvilleOldMan_ecArray[i] = oldMan->oldMan1.mauvilleOldMan_ecArray2[i]; + + oldMan->oldMan1.unk_2DBD = 1; +} + +void sub_80F7BA0(void) +{ + struct UnkMauvilleOldManStruct *oldMan = &gSaveBlock1.oldMan.oldMan1; + u16 specialVar = gSpecialVar_0x8004; // It's a bit odd to use this temp variable, but it seems needed to match. + u16 *r5; + u16 i; + u8 *ptr; + u8 *r4; + + r5 = oldMan->mauvilleOldMan_ecArray2; + if (specialVar == 0) + r5 = oldMan->mauvilleOldMan_ecArray; + ptr = gStringVar4; + r4 = ptr; + for (i = 0; i < 2; i++) + { + ptr = sub_80EB3FC(ptr, *(r5++)); + while (ptr != r4) + { + if (*r4 == 0) + *r4 = 0x37; + r4++; + } + r4++; + *(ptr++) = 0; + ptr = sub_80EB3FC(ptr, *(r5++)); + while (ptr != r4) + { + if (*r4 == 0) + *r4 = 0x37; + r4++; + } + r4++; + *(ptr++) = 0xFE; + ptr = sub_80EB3FC(ptr, *(r5++)); + while (ptr != r4) + { + if (*r4 == 0) + *r4 = 0x37; + r4++; + } + //_080F7C2A + if (i == 0) + { + *(ptr++) = EXT_CTRL_CODE_BEGIN; + *(ptr++) = 0xF; + } + } +} + +void sub_80F7C54(void) +{ + sub_80F7F80(gSpecialVar_0x8004); + MenuDisplayMessageBox(); + ScriptContext1_Stop(); +} + +void sub_80F7C70(void) +{ + u16 *scriptPtr = &gScriptResult; // again?? + OldMan *oldMan = &gSaveBlock1.oldMan; + + *scriptPtr = oldMan->oldMan1.unk_2D95; +} + +void sub_80F7C84(void) +{ + OldMan *oldMan = &gSaveBlock1.oldMan; + + oldMan->oldMan1.unk_2D95 = 1; +} + +void sub_80F7C90(void) +{ + u16 var = sub_80EB8EC(); + + if(var == 0xFFFF) + { + gScriptResult = FALSE; + } + else + { + sub_80EB3FC(gStringVar1, var); + gScriptResult = TRUE; + } +} + +void sub_80F7CC8(void) +{ + OldMan *oldMan = &gSaveBlock1.oldMan; + + if(oldMan->oldMan1.unk_2D95 == 10) + { + gScriptResult = FALSE; + oldMan->oldMan1.unk_2D95 = 0; + } + else + gScriptResult = TRUE; +} + +void sub_80F7CF4(void) +{ + struct UnkMauvilleOldManStruct2 *oldMan = &gSaveBlock1.oldMan.oldMan2; + + if(oldMan->unk1 == 0) + sub_80F7DC0(); + + if(oldMan->mauvilleOldMan_ecArray[oldMan->unk1] != 0xFFFF) // is not the last element of the array? + { + u8 *stringPtr; + u32 random = Random(); + + random %= 8; + stringPtr = sub_80EB3FC(gStringVar4, oldMan->mauvilleOldMan_ecArray[oldMan->unk1]); + stringPtr = StringCopy(stringPtr, gOtherText_Is); + stringPtr = StringCopy(stringPtr, (u8 *)gUnknown_083E5388[random]); + StringCopy(stringPtr, gOtherText_DontYouAgree); + } + else + { + StringCopy(gStringVar4, (u8 *)gUnknown_083E53A8[oldMan->mauvilleOldMan_ecArray2[oldMan->unk2++]]); + } + if(!(Random() % 10)) + oldMan->unk1 = 10; + else + oldMan->unk1++; + + gScriptResult = TRUE; +} diff --git a/src/menu.c b/src/menu.c index 0b5eab831..45cfbbc2f 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1,11 +1,15 @@ #include "global.h" #include "menu.h" #include "main.h" -#include "text.h" +#include "map_obj_lock.h" +#include "menu_cursor.h" +#include "script.h" #include "songs.h" -#include "text_window.h" #include "sound.h" -#include "menu_cursor.h" +#include "strings.h" +#include "text.h" +#include "text_window.h" +#include "string_util.h" struct Menu { @@ -24,8 +28,8 @@ static void MultistepInitMenuWindowInternal(const struct WindowConfig *, u16); static void InitMenuWindowInternal(const struct WindowConfig *, u16); static bool8 sub_80723D4(void); static u8 sub_8072484(u8, u8, u8, u8, u8, u8, u32); -static u8 sub_80724F4(u8, u8, u8, u8 * const [][2], u8); -static void sub_8072620(u8, u8, u8, u8 * const [][2], u8); +static u8 sub_80724F4(u8, u8, u8, const struct MenuAction[], u8); +static void sub_8072620(u8, u8, u8, const struct MenuAction[], u8); static void sub_8072D18(u8, u8); static struct Menu gMenu; @@ -39,7 +43,26 @@ EWRAM_DATA u16 gMenuTextWindowTileOffset = 0; EWRAM_DATA u16 gMenuTextWindowContentTileOffset = 0; EWRAM_DATA u16 gMenuMessageBoxContentTileOffset = 0; -extern const struct MenuAction gUnknown_08376D74[]; +const struct MenuAction gMenuYesNoItems[] = +{ + { OtherText_Yes, NULL }, + { OtherText_No, NULL }, +}; + +void CloseMenu(void) +{ + PlaySE(SE_SELECT); + MenuZeroFillScreen(); + sub_8064E2C(); + ScriptContext2_Disable(); + HandleDestroyMenuCursors(); +} + +void AppendToList(u8 *list, u8 *pindex, u32 value) +{ + list[*pindex] = value; + (*pindex)++; +} void InitMenuWindow(const struct WindowConfig *winConfig) { @@ -126,7 +149,7 @@ void BasicInitMenuWindow(const struct WindowConfig *winConfig) gMenuWindowPtr->tileDataStartOffset = gMenuTextTileOffset; } -void MenuPrint(u8 *str, u8 left, u8 top) +void MenuPrint(const u8 *str, u8 left, u8 top) { sub_8003460(gMenuWindowPtr, str, gMenuTextTileOffset, left, top); } @@ -151,7 +174,7 @@ void MenuDrawTextWindow(u8 left, u8 top, u8 right, u8 bottom) DrawTextWindow(gMenuWindowPtr, left, top, right, bottom); } -void sub_8071F40(u8 *str) +void sub_8071F40(const u8 *str) { MenuDrawTextWindow(2, 14, 28, 19); MenuPrint(str, 3, 15); @@ -248,14 +271,14 @@ s8 ProcessMenuInput(void) { PlaySE(SE_SELECT); if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); return gMenu.cursorPos; } if (gMain.newKeys & B_BUTTON) { if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); return -1; } @@ -283,14 +306,14 @@ s8 ProcessMenuInputNoWrap(void) { PlaySE(SE_SELECT); if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); return gMenu.cursorPos; } if (gMain.newKeys & B_BUTTON) { if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); return -1; } @@ -390,7 +413,7 @@ static u8 sub_8072484(u8 a1, u8 a2, u8 menuItemCount, u8 a4, u8 width, u8 a6, u3 return a4; } -static u8 sub_80724F4(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[][2], u8 columnCount) +static u8 sub_80724F4(u8 left, u8 top, u8 menuItemCount, const struct MenuAction menuItems[], u8 columnCount) { u8 i; u8 maxWidth; @@ -402,7 +425,7 @@ static u8 sub_80724F4(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[][ maxWidth = 0; for (i = 0; i < menuItemCount; i++) { - u8 width = (sub_8072CA4(menuItems[i][0]) + 7) / 8; + u8 width = (sub_8072CA4(menuItems[i].text) + 7) / 8; if (width > maxWidth) maxWidth = width; @@ -448,7 +471,7 @@ static u8 sub_80724F4(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[][ return maxWidth; } -static void sub_8072620(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[][2], u8 columnCount) +static void sub_8072620(u8 left, u8 top, u8 menuItemCount, const struct MenuAction menuItems[], u8 columnCount) { u8 i; u8 maxWidth; @@ -459,7 +482,7 @@ static void sub_8072620(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[ maxWidth = 0; for (i = 0; i < menuItemCount; i++) { - u8 width = (sub_8072CA4(menuItems[i][0]) + 7) / 8; + u8 width = (sub_8072CA4(menuItems[i].text) + 7) / 8; if (width > maxWidth) maxWidth = width; @@ -478,11 +501,11 @@ static void sub_8072620(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[ u8 row = 0; u8 j; for (j = 0; i + j < menuItemCount; j += columnCount, row++) - MenuPrint(menuItems[i + j][0], left + gMenu.columnXCoords[i % columnCount], top + 2 * row); + MenuPrint(menuItems[i + j].text, left + gMenu.columnXCoords[i % columnCount], top + 2 * row); } } -void sub_807274C(u8 left, u8 top, u8 menuItemCount, u8 a4, u8 * const menuItems[][2], u8 columnCount, u32 a7) +void sub_807274C(u8 left, u8 top, u8 menuItemCount, u8 a4, const struct MenuAction menuItems[], u8 columnCount, u32 a7) { u8 maxWidth = sub_80724F4(left, top, menuItemCount, menuItems, columnCount); @@ -495,7 +518,7 @@ s8 sub_80727CC(void) if (gMain.newKeys & A_BUTTON) { if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); PlaySE(SE_SELECT); return GetMenuCursorPos(); } @@ -503,7 +526,7 @@ s8 sub_80727CC(void) if (gMain.newKeys & B_BUTTON) { if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); return -1; } @@ -558,7 +581,7 @@ void PrintMenuItemsReordered(u8 left, u8 top, u8 menuItemCount, const struct Men void InitYesNoMenu(u8 left, u8 top, u8 a3) { - PrintMenuItems(left + 1, top + 1, 2, gUnknown_08376D74); + PrintMenuItems(left + 1, top + 1, 2, gMenuYesNoItems); InitMenu(0, left + 1, top + 1, 2, 0, a3); } @@ -574,12 +597,12 @@ s8 ProcessMenuInputNoWrap_(void) return ProcessMenuInputNoWrap(); } -u8 MenuPrint_PixelCoords(u8 *text, u8 left, u16 top, u8 a4) +u8 MenuPrint_PixelCoords(const u8 *text, u8 left, u16 top, u8 a4) { return sub_8004D04(gMenuWindowPtr, text, gMenuTextTileOffset, left, top, a4); } -u8 sub_8072A18(u8 *text, u8 left, u16 top, u8 width, u32 a5) +u8 sub_8072A18(const u8 *text, u8 left, u16 top, u8 width, u32 a5) { return sub_8004FD0(gMenuWindowPtr, 0, text, gMenuTextTileOffset, left, top, width, a5); } @@ -589,7 +612,8 @@ u8 unref_sub_8072A5C(u8 *dest, u8 *src, u8 left, u16 top, u8 width, u32 a6) return sub_8004FD0(gMenuWindowPtr, dest, src, gMenuTextTileOffset, left, top, width, a6); } -int sub_8072AB0(u8 *str, u8 left, u16 top, u8 width, u8 height, u32 a6) +#if ENGLISH +int sub_8072AB0(const u8 *str, u8 left, u16 top, u8 width, u8 height, u32 a6) { u8 newlineCount = sub_8004FD0(gMenuWindowPtr, NULL, str, gMenuTextTileOffset, left, top, width, a6); @@ -601,13 +625,97 @@ int sub_8072AB0(u8 *str, u8 left, u16 top, u8 width, u8 height, u32 a6) if (newlineCount < height) MenuFillWindowRectWithBlankTile(left, top + 2 * newlineCount, left + width - 1, height + top - 1); } +#elif GERMAN +__attribute__((naked)) +int sub_8072AB0(const u8 *str, u8 left, u16 top, u8 width, u8 height, u32 a6) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + sub sp, 0x10\n\ + mov r12, r0\n\ + ldr r0, [sp, 0x24]\n\ + ldr r4, [sp, 0x28]\n\ + str r4, [sp, 0xC]\n\ + lsls r1, 24\n\ + lsrs r5, r1, 24\n\ + lsls r2, 16\n\ + lsrs r4, r2, 16\n\ + lsls r3, 24\n\ + lsrs r6, r3, 24\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + ldr r0, _08072AF8 @ =gMenuWindowPtr\n\ + ldr r0, [r0]\n\ + ldr r1, _08072AFC @ =gMenuTextTileOffset\n\ + ldrh r3, [r1]\n\ + str r5, [sp]\n\ + str r4, [sp, 0x4]\n\ + str r6, [sp, 0x8]\n\ + movs r1, 0\n\ + mov r2, r12\n\ + bl sub_8004FD0\n\ + adds r1, r0, 0\n\ + lsls r1, 24\n\ + lsrs r2, r1, 24\n\ + movs r3, 0x7\n\ + ands r3, r5\n\ + cmp r3, 0\n\ + bne _08072B00\n\ + adds r1, r6, 0x7\n\ + asrs r1, 3\n\ + subs r1, 0x1\n\ + b _08072B0C\n\ + .align 2, 0\n\ +_08072AF8: .4byte gMenuWindowPtr\n\ +_08072AFC: .4byte gMenuTextTileOffset\n\ +_08072B00:\n\ + adds r3, r6, r3\n\ + subs r1, r3, 0x1\n\ + cmp r1, 0\n\ + bge _08072B0A\n\ + adds r1, r3, 0x6\n\ +_08072B0A:\n\ + asrs r1, 3\n\ +_08072B0C:\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + adds r6, r1, 0\n\ + lsrs r5, 3\n\ + adds r1, r7, 0x7\n\ + asrs r1, 3\n\ + lsls r1, 24\n\ + lsrs r7, r1, 24\n\ + lsrs r4, 3\n\ + cmp r2, r7\n\ + bcs _08072B3E\n\ + lsls r1, r2, 1\n\ + adds r1, r4, r1\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + adds r2, r5, r6\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + adds r3, r7, r4\n\ + subs r3, 0x1\n\ + lsls r3, 24\n\ + lsrs r3, 24\n\ + adds r0, r5, 0\n\ + bl MenuFillWindowRectWithBlankTile\n\ +_08072B3E:\n\ + add sp, 0x10\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .syntax divided\n"); +} +#endif void MenuPrint_RightAligned(u8 *str, u8 left, u8 top) { sub_8004D38(gMenuWindowPtr, str, gMenuTextTileOffset, left, top); } -void sub_8072B80(u8 *a1, u8 a2, u8 a3, u8 *a4) +void sub_8072B80(const u8 *a1, u8 a2, u8 a3, const u8 *a4) { u8 buffer[64]; u8 width = GetStringWidth(gMenuWindowPtr, a4); @@ -615,7 +723,7 @@ void sub_8072B80(u8 *a1, u8 a2, u8 a3, u8 *a4) sub_8003460(gMenuWindowPtr, buffer, gMenuTextTileOffset, a2, a3); } -void sub_8072BD8(u8 *a1, u8 a2, u8 a3, u16 a4) +void sub_8072BD8(const u8 *a1, u8 a2, u8 a3, u16 a4) { sub_8004DB0(gMenuWindowPtr, a1, gMenuTextTileOffset, a2, a3, a4); } @@ -630,12 +738,12 @@ u8 *sub_8072C44(u8 *a1, s32 a2, u8 a3, u8 a4) return AlignInt2(gMenuWindowPtr, a1, a2, a3, a4); } -u8 *sub_8072C74(u8 *a1, u8 *a2, u8 a3, u8 a4) +u8 *sub_8072C74(u8 *a1, const u8 *a2, u8 a3, u8 a4) { return AlignString(gMenuWindowPtr, a1, a2, a3, a4); } -u8 sub_8072CA4(u8 *str) +u8 sub_8072CA4(const u8 *str) { return GetStringWidth(gMenuWindowPtr, str); } @@ -709,7 +817,55 @@ void sub_8072DDC(u8 a1) sub_8072DCC(8 * a1); } -void sub_8072DEC(void) +void HandleDestroyMenuCursors(void) { - sub_814A7FC(); + DestroyMenuCursor(); +} + +#if GERMAN +void de_sub_8073110(u8 * buffer, u8 * name) { + u8 * ptr, *ptr2, *ptr3; + + ptr2 = buffer; + ptr = &gStringVar1[1 + StringLengthN(gStringVar1, 256)]; + ptr3 = ptr; + + for (;;) + { + if (*ptr2 == EOS) + break; + + if (*ptr2 == 0xFD) + { + + *ptr3 = EOS; + ptr2 += 2; + + StringAppend(ptr, name); + StringAppend(ptr, ptr2); + + buffer[0] = EOS; + StringAppend(buffer, ptr); + break; + } + + *ptr3 = *ptr2; + ptr2 += 1; + ptr3 += 1; + } +} + +u8 *de_sub_8073174(u8 *name, const u8 *format) { + u32 offset; + u8 *ptr; + + offset = StringLengthN(gStringVar2, 0x100); + ptr = &gStringVar2[1 + offset]; + + StringCopy(ptr, format); + + de_sub_8073110(ptr, name); + + return StringCopy(name, ptr); } +#endif diff --git a/src/menu_cursor.c b/src/menu_cursor.c index 5c1f0addf..2dc36cf32 100644 --- a/src/menu_cursor.c +++ b/src/menu_cursor.c @@ -1,24 +1,24 @@ #include "global.h" #include "menu_cursor.h" -#include "sprite.h" #include "palette.h" +#include "sprite.h" -extern struct SpriteSheet gUnknown_0842F140[]; -extern struct SpriteSheet gUnknown_0842F1C0[]; -extern struct SpritePalette gUnknown_0842F240; -extern struct SpritePalette gUnknown_0842F248; -extern struct SpriteTemplate gSpriteTemplate_842F250[]; -extern struct SpriteTemplate gSpriteTemplate_842F298[]; +extern const struct SpriteSheet gUnknown_0842F140[]; +extern const struct SpriteSheet gUnknown_0842F1C0[]; +extern const struct SpritePalette gUnknown_0842F240; +extern const struct SpritePalette gUnknown_0842F248; +extern const struct SpriteTemplate gSpriteTemplate_842F250[]; +extern const struct SpriteTemplate gSpriteTemplate_842F298[]; -extern struct Subsprite *gUnknown_0842F5BC[]; +extern struct Subsprite *const gUnknown_0842F5BC[]; -extern struct SubspriteTable gSubspriteTables_842F5C0[]; -extern struct SubspriteTable gUnknown_0842F6C0[]; -extern struct SubspriteTable gUnknown_0842F758[]; +extern const struct SubspriteTable gSubspriteTables_842F5C0[]; +extern const struct SubspriteTable gSubspriteTables_842F6C0[]; +extern const struct SubspriteTable gUnknown_0842F758[]; -extern struct Subsprite gUnknown_0842F780; -extern struct Subsprite gUnknown_0842F788; -extern struct Subsprite gUnknown_0842F790; +extern const struct Subsprite gUnknown_0842F780; +extern const struct Subsprite gUnknown_0842F788; +extern const struct Subsprite gUnknown_0842F790; extern u16 gUnknown_0203A360[]; @@ -45,7 +45,7 @@ u8 sub_814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5) struct Sprite *v10; if (gUnknown_0203A3D0 != 0x40 || gUnknown_0203A3D1 != 0x40) - sub_814A7FC(); + DestroyMenuCursor(); v9 = 1; if (a2 == 0xFFFF) @@ -120,7 +120,7 @@ u8 unref_sub_814A7AC(u8 a1, u16 a2, u8 a3) return sub_814A758(a1, val1, val2, a3); } -void sub_814A7FC(void) +void DestroyMenuCursor(void) { if (gUnknown_0203A3D0 != 0x40) { @@ -253,7 +253,7 @@ void sub_814A958(u8 a1) SetSubspriteTables(&gSprites[gUnknown_0203A3D1], &gSubspriteTables_842F5C0[v8]); return; } -#else +#elif ENGLISH __attribute__((naked)) void sub_814A958(u8 a1) { @@ -435,6 +435,189 @@ _0814AAB4: .4byte gSubspriteTables_842F5C0\n\ _0814AAB8: .4byte gUnknown_0203A3D1\n\ .syntax divided\n"); } +#elif GERMAN +__attribute__((naked)) +void sub_814A958(u8 a1) +{ + 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, 0x4\n\ + lsls r0, 24\n\ + ldr r4, _0814A9C4 @ =gMenuCursorSubsprites\n\ + ldr r2, _0814A9C8 @ =0x0000ffff\n\ + lsrs r0, 24\n\ + str r0, [sp]\n\ + ldr r0, _0814A9CC @ =gUnknown_0842F780\n\ + ldr r1, [r0, 0x4]\n\ + ldr r0, [r0]\n\ + str r0, [r4]\n\ + str r1, [r4, 0x4]\n\ + strh r2, [r4]\n\ + adds r4, 0x8\n\ + movs r7, 0x1\n\ + movs r2, 0x1\n\ + ldr r1, [sp]\n\ + subs r0, r1, 0x1\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + asrs r0, 16\n\ + cmp r0, 0x7\n\ + ble _0814AA3E\n\ + ldr r0, _0814A9D0 @ =gUnknown_0842F788\n\ + mov r12, r0\n\ + mov r8, r1\n\ + movs r1, 0x8\n\ + negs r1, r1\n\ + mov r10, r1\n\ + ldr r5, _0814A9D4 @ =gUnknown_0842F790\n\ + mov r9, r5\n\ +_0814A99E:\n\ + lsls r0, r3, 16\n\ + asrs r3, r0, 16\n\ + cmp r3, 0x1F\n\ + ble _0814A9D8\n\ + mov r6, r12\n\ + ldr r0, [r6]\n\ + ldr r1, [r6, 0x4]\n\ + str r0, [r4]\n\ + str r1, [r4, 0x4]\n\ + strh r2, [r4]\n\ + lsls r0, r2, 16\n\ + movs r1, 0x80\n\ + lsls r1, 14\n\ + adds r0, r1\n\ + lsrs r2, r0, 16\n\ + ldr r3, [sp]\n\ + lsls r5, r3, 16\n\ + b _0814AA24\n\ + .align 2, 0\n\ +_0814A9C4: .4byte gMenuCursorSubsprites\n\ +_0814A9C8: .4byte 0x0000ffff\n\ +_0814A9CC: .4byte gUnknown_0842F780\n\ +_0814A9D0: .4byte gUnknown_0842F788\n\ +_0814A9D4: .4byte gUnknown_0842F790\n\ +_0814A9D8:\n\ + ldr r6, [sp]\n\ + lsls r5, r6, 16\n\ + mov r0, r8\n\ + cmp r0, 0x27\n\ + ble _0814AA0E\n\ + cmp r3, 0x8\n\ + ble _0814AA0E\n\ + mov r6, r12\n\ + ldr r0, [r6]\n\ + ldr r1, [r6, 0x4]\n\ + str r0, [r4]\n\ + str r1, [r4, 0x4]\n\ + lsls r1, r2, 16\n\ + asrs r1, 16\n\ + adds r2, r1, 0\n\ + subs r2, 0x20\n\ + adds r0, r3, 0\n\ + mov r6, r10\n\ + ands r0, r6\n\ + adds r2, r0\n\ + strh r2, [r4]\n\ + movs r0, 0x18\n\ + ands r0, r3\n\ + adds r1, r0\n\ + lsls r1, 16\n\ + lsrs r2, r1, 16\n\ + b _0814AA24\n\ +_0814AA0E:\n\ + mov r3, r9\n\ + ldr r0, [r3]\n\ + ldr r1, [r3, 0x4]\n\ + str r0, [r4]\n\ + str r1, [r4, 0x4]\n\ + strh r2, [r4]\n\ + lsls r0, r2, 16\n\ + movs r6, 0x80\n\ + lsls r6, 12\n\ + adds r0, r6\n\ + lsrs r2, r0, 16\n\ +_0814AA24:\n\ + adds r4, 0x8\n\ + adds r0, r7, 0x1\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + asrs r1, r5, 16\n\ + lsls r0, r2, 16\n\ + asrs r0, 16\n\ + subs r1, r0\n\ + lsls r1, 16\n\ + lsrs r3, r1, 16\n\ + asrs r1, 16\n\ + cmp r1, 0x7\n\ + bgt _0814A99E\n\ +_0814AA3E:\n\ + ldr r5, _0814AAAC @ =0x0843d6d8\n\ + ldr r0, [r5]\n\ + ldr r1, [r5, 0x4]\n\ + str r0, [r4]\n\ + str r1, [r4, 0x4]\n\ + lsls r1, r2, 16\n\ + asrs r1, 16\n\ + subs r1, 0x7\n\ + lsls r0, r3, 16\n\ + asrs r0, 16\n\ + adds r0, r1\n\ + strh r0, [r4]\n\ + adds r0, r7, 0x1\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + ldr r6, _0814AAB0 @ =gUnknown_0203A3D0\n\ + ldrb r0, [r6]\n\ + cmp r0, 0x40\n\ + beq _0814AA7C\n\ + adds r1, r0, 0\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + ldr r1, _0814AAB4 @ =gSprites\n\ + adds r2, r0, r1\n\ + lsls r1, r7, 3\n\ + ldr r0, _0814AAB8 @ =gSubspriteTables_842F5C0\n\ + adds r1, r0\n\ + adds r0, r2, 0\n\ + bl SetSubspriteTables\n\ +_0814AA7C:\n\ + ldr r1, _0814AABC @ =gUnknown_0203A3D1\n\ + ldrb r0, [r1]\n\ + cmp r0, 0x40\n\ + beq _0814AA9C\n\ + adds r1, r0, 0\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + ldr r1, _0814AAB4 @ =gSprites\n\ + adds r2, r0, r1\n\ + lsls r1, r7, 3\n\ + ldr r0, _0814AAB8 @ =gSubspriteTables_842F5C0\n\ + adds r1, r0\n\ + adds r0, r2, 0\n\ + bl SetSubspriteTables\n\ +_0814AA9C:\n\ + add sp, 0x4\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\ + .align 2, 0\n\ +_0814AAAC: .4byte 0x0843d6d8\n\ +_0814AAB0: .4byte gUnknown_0203A3D0\n\ +_0814AAB4: .4byte gSprites\n\ +_0814AAB8: .4byte gSubspriteTables_842F5C0\n\ +_0814AABC: .4byte gUnknown_0203A3D1\n\ + .syntax divided\n"); +} #endif void sub_814AABC(void (*callback)(struct Sprite *)) @@ -542,7 +725,11 @@ u8 CreateBlendedOutlineCursor(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5) } LoadSpriteSheetDeferred(&gUnknown_0842F1C0[a3 & 0xF]); - gUnknown_0203A3D2 = CreateSprite(&gSpriteTemplate_842F298[v8], 0, 0xA0, a1); +#if ENGLISH + gUnknown_0203A3D2 = CreateSprite(&gSpriteTemplate_842F298[v8], 0, 160, a1); +#elif GERMAN + gUnknown_0203A3D2 = CreateSprite(&gSpriteTemplate_842F298[v8], 0, 161, a1); +#endif if (gUnknown_0203A3D2 != 0x40) { @@ -601,6 +788,12 @@ void sub_814ADF4(u8 a1) a1 = 0; if (gUnknown_0203A3D2 != 0x40) - SetSubspriteTables(&gSprites[gUnknown_0203A3D2], &gUnknown_0842F6C0[a1]); + SetSubspriteTables(&gSprites[gUnknown_0203A3D2], &gSubspriteTables_842F6C0[a1]); return; } + +#if GERMAN +void nullsub_814B200(void) +{ +} +#endif diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index a4d904afb..d05ba0b89 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -1,17 +1,262 @@ #include "global.h" - -extern u8 gUnknown_08308E2C[]; - -bool8 MetatileBehavior_IsWaterfall(u8); - -s8 sub_8056D9C(void) -{ - return 1; -} - -bool8 sub_8056DA0(u8 var) -{ - if((gUnknown_08308E2C[var] & 1) != 0) +#include "metatile_behavior.h" +#include "metatile_behaviors.h" + +#define TILE_ATTRIBUTES(three, two, one) (((one) ? 1 : 0) | ((two) ? 2 : 0) | ((three) ? 4 : 0)) + +static const u8 sTileBitAttributes[] = +{ + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE) +}; + +// only used as default case for checking jump landing in field_ground_effect. +bool8 MetatileBehavior_IsATile(u8 var) +{ + return TRUE; +} + +bool8 MetatileBehavior_IsEncounterTile(u8 var) +{ + if ((sTileBitAttributes[var] & 1) != 0) return TRUE; else return FALSE; @@ -19,7 +264,7 @@ bool8 sub_8056DA0(u8 var) bool8 MetatileBehavior_IsJumpEast(u8 var) { - if(var == 0x38) + if (var == MB_JUMP_EAST) return TRUE; else return FALSE; @@ -27,7 +272,7 @@ bool8 MetatileBehavior_IsJumpEast(u8 var) bool8 MetatileBehavior_IsJumpWest(u8 var) { - if(var == 0x39) + if (var == MB_JUMP_WEST) return TRUE; else return FALSE; @@ -35,7 +280,7 @@ bool8 MetatileBehavior_IsJumpWest(u8 var) bool8 MetatileBehavior_IsJumpNorth(u8 var) { - if(var == 0x3A) + if (var == MB_JUMP_NORTH) return TRUE; else return FALSE; @@ -43,15 +288,15 @@ bool8 MetatileBehavior_IsJumpNorth(u8 var) bool8 MetatileBehavior_IsJumpSouth(u8 var) { - if(var == 0x3B) + if (var == MB_JUMP_SOUTH) return TRUE; else return FALSE; } -bool8 sub_8056E14(u8 var) +bool8 MetatileBehavior_IsPokeGrass(u8 var) { - if(var == 2 || var == 3) + if (var == MB_TALL_GRASS || var == MB_LONG_GRASS) return TRUE; else return FALSE; @@ -59,7 +304,7 @@ bool8 sub_8056E14(u8 var) bool8 MetatileBehavior_IsSandOrDeepSand(u8 var) { - if(var == 0x21 || var == 0x6) + if (var == MB_SAND || var == MB_DEEP_SAND) return TRUE; else return FALSE; @@ -67,7 +312,7 @@ bool8 MetatileBehavior_IsSandOrDeepSand(u8 var) bool8 MetatileBehavior_IsDeepSand(u8 var) { - if(var == 0x6) + if (var == MB_DEEP_SAND) return TRUE; else return FALSE; @@ -75,7 +320,7 @@ bool8 MetatileBehavior_IsDeepSand(u8 var) bool8 MetatileBehavior_IsReflective(u8 var) { - if(var == 0x10 || var == 0x16 || var == 0x1A || var == 0x20 || var == 0x14 || var == 0x2B) + if (var == MB_POND_WATER || var == MB_PUDDLE || var == MB_1A || var == MB_ICE || var == MB_SOOTOPOLIS_DEEP_WATER || var == MB_REFLECTION_UNDER_BRIDGE) return TRUE; else return FALSE; @@ -83,15 +328,15 @@ bool8 MetatileBehavior_IsReflective(u8 var) bool8 MetatileBehavior_IsIce(u8 var) { - if(var == 0x20) + if (var == MB_ICE) return TRUE; else return FALSE; } -bool8 is_tile_x69_2_warp_door(u8 var) +bool8 MetatileBehavior_IsWarpDoor(u8 var) { - if(var == 0x69) + if (var == MB_ANIMATED_DOOR) return TRUE; else return FALSE; @@ -99,7 +344,7 @@ bool8 is_tile_x69_2_warp_door(u8 var) bool8 MetatileBehavior_IsDoor(u8 var) { - if(var == 0x8D || var == 0x69) + if (var == MB_8D || var == MB_ANIMATED_DOOR) return TRUE; else return FALSE; @@ -107,7 +352,7 @@ bool8 MetatileBehavior_IsDoor(u8 var) bool8 MetatileBehavior_IsEscalator(u8 var) { - if(var == 0x6A || var == 0x6B) + if (var == MB_UP_ESCALATOR || var == MB_DOWN_ESCALATOR) return TRUE; else return FALSE; @@ -115,7 +360,7 @@ bool8 MetatileBehavior_IsEscalator(u8 var) bool8 unref_sub_8056EE0(u8 var) { - if(var == 0x4) + if (var == MB_04) return TRUE; else return FALSE; @@ -123,23 +368,23 @@ bool8 unref_sub_8056EE0(u8 var) bool8 MetatileBehavior_IsLadder(u8 var) { - if(var == 0x61) + if (var == MB_LADDER) return TRUE; else return FALSE; } -bool8 sub_8056F08(u8 var) +bool8 MetatileBehavior_IsNonAnimDoor(u8 var) { - if(var == 0x60 || var == 0x6C || var == 0x6E) + if (var == MB_NON_ANIMATED_DOOR || var == MB_WATER_DOOR || var == MB_DEEP_SOUTH_WARP) return TRUE; else return FALSE; } -bool8 sub_8056F24(u8 var) +bool8 MetatileBehavior_IsDeepSouthWarp(u8 var) { - if(var == 0x6E) + if (var == MB_DEEP_SOUTH_WARP) return TRUE; else return FALSE; @@ -147,7 +392,7 @@ bool8 sub_8056F24(u8 var) bool8 MetatileBehavior_IsSurfableWaterOrUnderwater(u8 var) { - if((gUnknown_08308E2C[var] & 2) != 0) + if ((sTileBitAttributes[var] & 2) != 0) return TRUE; else return FALSE; @@ -155,7 +400,7 @@ bool8 MetatileBehavior_IsSurfableWaterOrUnderwater(u8 var) bool8 MetatileBehavior_IsEastArrowWarp(u8 var) { - if(var == 0x62) + if (var == MB_EAST_ARROW_WARP) return TRUE; else return FALSE; @@ -163,7 +408,7 @@ bool8 MetatileBehavior_IsEastArrowWarp(u8 var) bool8 MetatileBehavior_IsWestArrowWarp(u8 var) { - if(var == 0x63) + if (var == MB_WEST_ARROW_WARP) return TRUE; else return FALSE; @@ -171,7 +416,7 @@ bool8 MetatileBehavior_IsWestArrowWarp(u8 var) bool8 MetatileBehavior_IsNorthArrowWarp(u8 var) { - if(var == 0x64 || var == 0x1B) + if (var == MB_NORTH_ARROW_WARP || var == MB_STAIRS_OUTSIDE_ABANDONED_SHIP) return TRUE; else return FALSE; @@ -179,7 +424,7 @@ bool8 MetatileBehavior_IsNorthArrowWarp(u8 var) bool8 MetatileBehavior_IsSouthArrowWarp(u8 var) { - if(var == 0x65 || var == 0x6D || var == 0x1C) + if (var == MB_SOUTH_ARROW_WARP || var == MB_WATER_SOUTH_ARROW_WARP || var == MB_SHOAL_CAVE_ENTRANCE) return TRUE; else return FALSE; @@ -190,7 +435,7 @@ bool8 MetatileBehavior_IsArrowWarp(u8 var) { u8 var2 = 0; - if(MetatileBehavior_IsEastArrowWarp(var) + if (MetatileBehavior_IsEastArrowWarp(var) || MetatileBehavior_IsWestArrowWarp(var) || MetatileBehavior_IsNorthArrowWarp(var) || MetatileBehavior_IsSouthArrowWarp(var)) @@ -200,10 +445,10 @@ bool8 MetatileBehavior_IsArrowWarp(u8 var) return var2; } -bool8 sub_8056FFC(u8 var) +bool8 MetatileBehavior_IsMoveTile(u8 var) { - if((var >= 0x40 && var <= 0x48) || (var >= 0x50 && var <= 0x53) - || var == 0xD0 || var == 0xD2 || var == 0x13 || var == 0x20 || var == 0xBB || var == 0xBC) + if ((var >= MB_WALK_EAST && var <= MB_TRICK_HOUSE_PUZZLE_8_FLOOR) || (var >= MB_EASTWARD_CURRENT && var <= MB_SOUTHWARD_CURRENT) + || var == MB_MUDDY_SLOPE || var == MB_CRACKED_FLOOR || var == MB_WATERFALL || var == MB_ICE || var == MB_BB || var == MB_BC) return TRUE; else return FALSE; @@ -211,7 +456,7 @@ bool8 sub_8056FFC(u8 var) bool8 MetatileBehavior_IsIce_2(u8 var) { - if(var == 0x20) + if (var == MB_ICE) return TRUE; else return FALSE; @@ -219,7 +464,7 @@ bool8 MetatileBehavior_IsIce_2(u8 var) bool8 MetatileBehavior_IsTrickHouseSlipperyFloor(u8 var) { - if(var == 0x48) + if (var == MB_TRICK_HOUSE_PUZZLE_8_FLOOR) return TRUE; else return FALSE; @@ -227,7 +472,7 @@ bool8 MetatileBehavior_IsTrickHouseSlipperyFloor(u8 var) bool8 MetatileBehavior_0x05(u8 var) { - if(var == 0x5) + if (var == MB_05) return TRUE; else return FALSE; @@ -235,7 +480,7 @@ bool8 MetatileBehavior_0x05(u8 var) bool8 MetatileBehavior_IsWalkNorth(u8 var) { - if(var == 0x42) + if (var == MB_WALK_NORTH) return TRUE; else return FALSE; @@ -243,7 +488,7 @@ bool8 MetatileBehavior_IsWalkNorth(u8 var) bool8 MetatileBehavior_IsWalkSouth(u8 var) { - if(var == 0x43) + if (var == MB_WALK_SOUTH) return TRUE; else return FALSE; @@ -251,7 +496,7 @@ bool8 MetatileBehavior_IsWalkSouth(u8 var) bool8 MetatileBehavior_IsWalkWest(u8 var) { - if(var == 0x41) + if (var == MB_WALK_WEST) return TRUE; else return FALSE; @@ -259,7 +504,7 @@ bool8 MetatileBehavior_IsWalkWest(u8 var) bool8 MetatileBehavior_IsWalkEast(u8 var) { - if(var == 0x40) + if (var == MB_WALK_EAST) return TRUE; else return FALSE; @@ -267,7 +512,7 @@ bool8 MetatileBehavior_IsWalkEast(u8 var) bool8 MetatileBehavior_IsNorthwardCurrent(u8 var) { - if(var == 0x52) + if (var == MB_NORTHWARD_CURRENT) return TRUE; else return FALSE; @@ -275,7 +520,7 @@ bool8 MetatileBehavior_IsNorthwardCurrent(u8 var) bool8 MetatileBehavior_IsSouthwardCurrent(u8 var) { - if(var == 0x53) + if (var == MB_SOUTHWARD_CURRENT) return TRUE; else return FALSE; @@ -283,7 +528,7 @@ bool8 MetatileBehavior_IsSouthwardCurrent(u8 var) bool8 MetatileBehavior_IsWestwardCurrent(u8 var) { - if(var == 0x51) + if (var == MB_WESTWARD_CURRENT) return TRUE; else return FALSE; @@ -291,7 +536,7 @@ bool8 MetatileBehavior_IsWestwardCurrent(u8 var) bool8 MetatileBehavior_IsEastwardCurrent(u8 var) { - if(var == 0x50) + if (var == MB_EASTWARD_CURRENT) return TRUE; else return FALSE; @@ -299,7 +544,7 @@ bool8 MetatileBehavior_IsEastwardCurrent(u8 var) bool8 MetatileBehavior_IsSlideNorth(u8 var) { - if(var == 0x46) + if (var == MB_SLIDE_NORTH) return TRUE; else return FALSE; @@ -307,7 +552,7 @@ bool8 MetatileBehavior_IsSlideNorth(u8 var) bool8 MetatileBehavior_IsSlideSouth(u8 var) { - if(var == 0x47) + if (var == MB_SLIDE_SOUTH) return TRUE; else return FALSE; @@ -315,7 +560,7 @@ bool8 MetatileBehavior_IsSlideSouth(u8 var) bool8 MetatileBehavior_IsSlideWest(u8 var) { - if(var == 0x45) + if (var == MB_SLIDE_WEST) return TRUE; else return FALSE; @@ -323,7 +568,7 @@ bool8 MetatileBehavior_IsSlideWest(u8 var) bool8 MetatileBehavior_IsSlideEast(u8 var) { - if(var == 0x44) + if (var == MB_SLIDE_EAST) return TRUE; else return FALSE; @@ -331,7 +576,7 @@ bool8 MetatileBehavior_IsSlideEast(u8 var) bool8 MetatileBehavior_IsCounter(u8 var) { - if(var == 0x80) + if (var == MB_COUNTER) return TRUE; else return FALSE; @@ -339,9 +584,9 @@ bool8 MetatileBehavior_IsCounter(u8 var) bool8 MetatileBehavior_IsPlayerFacingTVScreen(u8 tile, u8 playerDir) { - if(playerDir != 2) // if the player isn't facing north, forget about it. + if (playerDir != CONNECTION_NORTH) // if the player isn't facing north, forget about it. return FALSE; - else if(tile == 0x86) // is the player's north tile a TV? + else if (tile == MB_TELEVISION) // is the player's north tile a TV? return TRUE; else return FALSE; @@ -349,7 +594,7 @@ bool8 MetatileBehavior_IsPlayerFacingTVScreen(u8 tile, u8 playerDir) bool8 MetatileBehavior_IsPC(u8 var) { - if(var == 0x83) + if (var == MB_PC) return TRUE; else return FALSE; @@ -357,7 +602,7 @@ bool8 MetatileBehavior_IsPC(u8 var) bool8 is_tile_x84(u8 var) { - if(var == 0x84) + if (var == MB_84) return TRUE; else return FALSE; @@ -365,40 +610,40 @@ bool8 is_tile_x84(u8 var) bool8 sub_80571C0(u8 var) { - if(var == 0x91 || var == 0x93 || var == 0x95 || var == 0x97 - || var == 0x99 || var == 0x9B || var == 0x9D) + if (var == MB_91 || var == MB_93 || var == MB_95 || var == MB_97 + || var == MB_99 || var == MB_9B || var == MB_9D) return TRUE; else return FALSE; } -bool8 sub_80571EC(u8 var) +bool8 MetatileBehavior_IsSecretBaseCave(u8 var) { - if(var == 0x90 || var == 0x92 || var == 0x94 || var == 0x9A) + if (var == MB_SECRET_BASE_SPOT_RED_CAVE || var == MB_SECRET_BASE_SPOT_BROWN_CAVE || var == MB_SECRET_BASE_SPOT_YELLOW_CAVE || var == MB_SECRET_BASE_SPOT_BLUE_CAVE) return TRUE; else return FALSE; } -bool8 sub_805720C(u8 var) +bool8 MetatileBehavior_IsSecretBaseTree(u8 var) { - if(var == 0x96 || var == 0x9C) + if (var == MB_SECRET_BASE_SPOT_TREE_1 || var == MB_SECRET_BASE_SPOT_TREE_2) return TRUE; else return FALSE; } -bool8 is_tile_x98(u8 var) +bool8 MetatileBehavior_IsSecretBaseShrub(u8 var) { - if(var == 0x98) + if (var == MB_SECRET_BASE_SPOT_SHRUB) return TRUE; else return FALSE; } -bool8 sub_8057238(u8 var) +bool8 MetatileBehavior_IsSecretBasePC(u8 var) { - if(var == 0xB0) + if (var == MB_SECRET_BASE_PC) return TRUE; else return FALSE; @@ -406,7 +651,7 @@ bool8 sub_8057238(u8 var) bool8 sub_805724C(u8 var) { - if(var == 0xB1) + if (var == MB_B1) return TRUE; else return FALSE; @@ -414,7 +659,7 @@ bool8 sub_805724C(u8 var) bool8 unref_sub_8057260(u8 var) { - if(var == 0xB2) + if (var == MB_B2) return TRUE; else return FALSE; @@ -422,7 +667,7 @@ bool8 unref_sub_8057260(u8 var) bool8 sub_8057274(u8 var) { - if(var == 0xB3) + if (var == MB_B3) return TRUE; else return FALSE; @@ -430,7 +675,7 @@ bool8 sub_8057274(u8 var) bool8 sub_8057288(u8 var) { - if(var == 0xB9) + if (var == MB_B9) return TRUE; else return FALSE; @@ -438,7 +683,7 @@ bool8 sub_8057288(u8 var) bool8 sub_805729C(u8 var) { - if(var == 0x0) + if (var == MB_NORMAL) return TRUE; else return FALSE; @@ -446,7 +691,7 @@ bool8 sub_805729C(u8 var) bool8 sub_80572B0(u8 var) { - if(var == 0xB7) + if (var == MB_B7) return TRUE; else return FALSE; @@ -454,7 +699,7 @@ bool8 sub_80572B0(u8 var) bool8 unref_sub_80572C4(u8 var) { - if(var == 0xB2) + if (var == MB_B2) return TRUE; else return FALSE; @@ -462,7 +707,7 @@ bool8 unref_sub_80572C4(u8 var) bool8 sub_80572D8(u8 var) { - if(var == 0xB5) + if (var == MB_B5) return TRUE; else return FALSE; @@ -470,7 +715,7 @@ bool8 sub_80572D8(u8 var) bool8 sub_80572EC(u8 var) { - if(var == 0xC3) + if (var == MB_C3) return TRUE; else return FALSE; @@ -478,7 +723,7 @@ bool8 sub_80572EC(u8 var) bool8 sub_8057300(u8 var) { - if(var == 0xC2) + if (var == MB_C2) return TRUE; else return FALSE; @@ -486,7 +731,7 @@ bool8 sub_8057300(u8 var) bool8 sub_8057314(u8 var) { - if(var == 0xB8) + if (var == MB_B8) return TRUE; else return FALSE; @@ -494,7 +739,7 @@ bool8 sub_8057314(u8 var) bool8 sub_8057328(u8 var) { - if(var == 0xBE) + if (var == MB_BE) return TRUE; else return FALSE; @@ -502,7 +747,7 @@ bool8 sub_8057328(u8 var) bool8 sub_805733C(u8 var) { - if(var == 0xBD) + if (var == MB_BD) return TRUE; else return FALSE; @@ -510,7 +755,7 @@ bool8 sub_805733C(u8 var) bool8 sub_8057350(u8 var) { - if(var == 0xBA) + if (var == MB_BA) return TRUE; else return FALSE; @@ -518,7 +763,7 @@ bool8 sub_8057350(u8 var) bool8 sub_8057364(u8 var) { - if(var == 0xBF) + if (var == MB_BF) return TRUE; else return FALSE; @@ -526,7 +771,7 @@ bool8 sub_8057364(u8 var) bool8 sub_8057378(u8 var) { - if(var == 0xC4) + if (var == MB_C4) return TRUE; else return FALSE; @@ -534,7 +779,7 @@ bool8 sub_8057378(u8 var) bool8 sub_805738C(u8 var) { - if(var == 0xC5) + if (var == MB_C5) return TRUE; else return FALSE; @@ -542,7 +787,7 @@ bool8 sub_805738C(u8 var) bool8 MetatileBehavior_HasRipples(u8 var) { - if(var == 0x10 || var == 0x16 || var == 0x14) + if (var == MB_POND_WATER || var == MB_PUDDLE || var == MB_SOOTOPOLIS_DEEP_WATER) return TRUE; else return FALSE; @@ -550,7 +795,7 @@ bool8 MetatileBehavior_HasRipples(u8 var) bool8 MetatileBehavior_IsPuddle(u8 var) { - if(var == 0x16) + if (var == MB_PUDDLE) return TRUE; else return FALSE; @@ -558,7 +803,7 @@ bool8 MetatileBehavior_IsPuddle(u8 var) bool8 MetatileBehavior_IsTallGrass(u8 var) { - if(var == 0x2) + if (var == MB_TALL_GRASS) return TRUE; else return FALSE; @@ -566,7 +811,7 @@ bool8 MetatileBehavior_IsTallGrass(u8 var) bool8 MetatileBehavior_IsLongGrass(u8 var) { - if(var == 0x3) + if (var == MB_LONG_GRASS) return TRUE; else return FALSE; @@ -574,15 +819,15 @@ bool8 MetatileBehavior_IsLongGrass(u8 var) bool8 MetatileBehavior_IsBerryTreeSoil(u8 var) { - if(var == 0xA0) + if (var == MB_BERRY_TREE_SOIL) return TRUE; else return FALSE; } -bool8 MetatileBehavior_IsAsh(u8 var) +bool8 MetatileBehavior_IsAshGrass(u8 var) { - if(var == 0x24) + if (var == MB_ASHGRASS) return TRUE; else return FALSE; @@ -590,7 +835,7 @@ bool8 MetatileBehavior_IsAsh(u8 var) bool8 MetatileBehavior_IsUnusedFootprintMetatile(u8 var) { - if(var == 0x25) + if (var == MB_25) return TRUE; else return FALSE; @@ -598,7 +843,7 @@ bool8 MetatileBehavior_IsUnusedFootprintMetatile(u8 var) bool8 MetatileBehavior_IsBridge(u8 var) { - if(var >= 0x70 && var <= 0x73) + if (var >= MB_WARP_OR_BRIDGE && var <= MB_ROUTE120_NORTH_BRIDGE_2) return TRUE; else return FALSE; @@ -606,9 +851,9 @@ bool8 MetatileBehavior_IsBridge(u8 var) u8 sub_8057450(u8 var) { - u8 result = var - 0x70; + u8 result = var - MB_WARP_OR_BRIDGE; - if(result > 3) + if (result > 3) result = 0; return result; @@ -616,7 +861,7 @@ u8 sub_8057450(u8 var) bool8 MetatileBehavior_IsLandWildEncounter(u8 var) { - if(MetatileBehavior_IsSurfableWaterOrUnderwater(var) == FALSE && sub_8056DA0(var) == TRUE) + if (MetatileBehavior_IsSurfableWaterOrUnderwater(var) == FALSE && MetatileBehavior_IsEncounterTile(var) == TRUE) return TRUE; else return FALSE; @@ -624,7 +869,7 @@ bool8 MetatileBehavior_IsLandWildEncounter(u8 var) bool8 MetatileBehavior_IsWaterWildEncounter(u8 var) { - if(MetatileBehavior_IsSurfableWaterOrUnderwater(var) == TRUE && sub_8056DA0(var) == TRUE) + if (MetatileBehavior_IsSurfableWaterOrUnderwater(var) == TRUE && MetatileBehavior_IsEncounterTile(var) == TRUE) return TRUE; else return FALSE; @@ -632,7 +877,7 @@ bool8 MetatileBehavior_IsWaterWildEncounter(u8 var) bool8 sub_80574C4(u8 var) { - if(var == 0xB) + if (var == MB_0B) return TRUE; else return FALSE; @@ -640,15 +885,15 @@ bool8 sub_80574C4(u8 var) bool8 sub_80574D8(u8 var) { - if(var == 0xC) + if (var == MB_MOUNTAIN_TOP) return TRUE; else - return FALSE; + return FALSE; } bool8 sub_80574EC(u8 var) { - if(var == 0x11 || var == 0x12 || var == 0x14) + if (var == MB_SEMI_DEEP_WATER || var == MB_DEEP_WATER || var == MB_SOOTOPOLIS_DEEP_WATER) return TRUE; else return FALSE; @@ -656,7 +901,7 @@ bool8 sub_80574EC(u8 var) bool8 sub_805750C(u8 var) { - if(var == 0x19 || var == 0x2A) + if (var == MB_NO_SURFACING || var == MB_SEAWEED_NO_SURFACING) return TRUE; else return FALSE; @@ -664,23 +909,23 @@ bool8 sub_805750C(u8 var) bool8 MetatileBehavior_IsShallowFlowingWater(u8 var) { - if(var == 0x17 || var == 0x1B || var == 0x1C) + if (var == MB_SHALLOW_WATER || var == MB_STAIRS_OUTSIDE_ABANDONED_SHIP || var == MB_SHOAL_CAVE_ENTRANCE) return TRUE; else return FALSE; } -bool8 sub_8057540(u8 var) +bool8 MetatileBehavior_IsThinIce(u8 var) { - if(var == 0x26) + if (var == MB_THIN_ICE) return TRUE; else return FALSE; } -bool8 sub_8057554(u8 var) +bool8 MetatileBehavior_IsCrackedIce(u8 var) { - if(var == 0x27) + if (var == MB_CRACKED_ICE) return TRUE; else return FALSE; @@ -688,7 +933,7 @@ bool8 sub_8057554(u8 var) bool8 sub_8057568(u8 var) { - if(var == 0x15 || var == 0x11 || var == 0x12) + if (var == MB_OCEAN_WATER || var == MB_SEMI_DEEP_WATER || var == MB_DEEP_WATER) return TRUE; else return FALSE; @@ -696,7 +941,7 @@ bool8 sub_8057568(u8 var) bool8 unref_sub_8057584(u8 var) { - if(var == 0x18 || var == 0x1A) + if (var == MB_18 || var == MB_1A) return TRUE; else return FALSE; @@ -704,7 +949,7 @@ bool8 unref_sub_8057584(u8 var) bool8 sub_805759C(u8 var) { - if(MetatileBehavior_IsSurfableWaterOrUnderwater(var) && MetatileBehavior_IsWaterfall(var) == FALSE) + if (MetatileBehavior_IsSurfableWaterOrUnderwater(var) && MetatileBehavior_IsWaterfall(var) == FALSE) return TRUE; else return FALSE; @@ -712,7 +957,7 @@ bool8 sub_805759C(u8 var) bool8 MetatileBehavior_IsEastBlocked(u8 var) { - if(var == 0x30 || var == 0x34 || var == 0x36 || var == 0xC1 || var == 0xBE) + if (var == MB_IMPASSABLE_EAST || var == MB_IMPASSABLE_NORTHEAST || var == MB_IMPASSABLE_SOUTHEAST || var == MB_C1 || var == MB_BE) return TRUE; else return FALSE; @@ -720,7 +965,7 @@ bool8 MetatileBehavior_IsEastBlocked(u8 var) bool8 MetatileBehavior_IsWestBlocked(u8 var) { - if(var == 0x31 || var == 0x35 || var == 0x37 || var == 0xC1 || var == 0xBE) + if (var == MB_IMPASSABLE_WEST || var == MB_IMPASSABLE_NORTHWEST || var == MB_IMPASSABLE_SOUTHWEST || var == MB_C1 || var == MB_BE) return TRUE; else return FALSE; @@ -728,7 +973,7 @@ bool8 MetatileBehavior_IsWestBlocked(u8 var) bool8 MetatileBehavior_IsNorthBlocked(u8 var) { - if(var == 0x32 || var == 0x34 || var == 0x35 || var == 0xC0) + if (var == MB_IMPASSABLE_NORTH || var == MB_IMPASSABLE_NORTHEAST || var == MB_IMPASSABLE_NORTHWEST || var == MB_BED) return TRUE; else return FALSE; @@ -736,7 +981,7 @@ bool8 MetatileBehavior_IsNorthBlocked(u8 var) bool8 MetatileBehavior_IsSouthBlocked(u8 var) { - if(var == 0x33 || var == 0x36 || var == 0x37 || var == 0xC0) + if (var == MB_IMPASSABLE_SOUTH || var == MB_IMPASSABLE_SOUTHEAST || var == MB_IMPASSABLE_SOUTHWEST || var == MB_BED) return TRUE; else return FALSE; @@ -744,7 +989,7 @@ bool8 MetatileBehavior_IsSouthBlocked(u8 var) bool8 MetatileBehavior_IsShortGrass(u8 var) { - if(var == 0x7) + if (var == MB_SHORT_GRASS) return TRUE; else return FALSE; @@ -752,7 +997,7 @@ bool8 MetatileBehavior_IsShortGrass(u8 var) bool8 MetatileBehavior_IsHotSprings(u8 var) { - if(var == 0x28) + if (var == MB_HOT_SPRINGS) return TRUE; else return FALSE; @@ -760,7 +1005,7 @@ bool8 MetatileBehavior_IsHotSprings(u8 var) bool8 MetatileBehavior_IsWaterfall(u8 var) { - if(var == 0x13) + if (var == MB_WATERFALL) return TRUE; else return FALSE; @@ -768,7 +1013,7 @@ bool8 MetatileBehavior_IsWaterfall(u8 var) bool8 MetatileBehavior_IsFortreeBridge(u8 var) { - if(var == 0x78) + if (var == MB_FORTREE_BRIDGE) return TRUE; else return FALSE; @@ -776,7 +1021,7 @@ bool8 MetatileBehavior_IsFortreeBridge(u8 var) bool8 sub_80576A0(u8 var) { - if(var == 0x74) + if (var == MB_PACIFIDLOG_VERTICAL_LOG_1) return TRUE; else return FALSE; @@ -784,7 +1029,7 @@ bool8 sub_80576A0(u8 var) bool8 sub_80576B4(u8 var) { - if(var == 0x75) + if (var == MB_PACIFIDLOG_VERTICAL_LOG_2) return TRUE; else return FALSE; @@ -792,7 +1037,7 @@ bool8 sub_80576B4(u8 var) bool8 sub_80576C8(u8 var) { - if(var == 0x76) + if (var == MB_PACIFIDLOG_HORIZONTAL_LOG_1) return TRUE; else return FALSE; @@ -800,7 +1045,7 @@ bool8 sub_80576C8(u8 var) bool8 sub_80576DC(u8 var) { - if(var == 0x77) + if (var == MB_PACIFIDLOG_HORIZONTAL_LOG_2) return TRUE; else return FALSE; @@ -808,47 +1053,47 @@ bool8 sub_80576DC(u8 var) bool8 MetatileBehavior_IsPacifidlogLog(u8 var) { - if(var >= 0x74 && var <= 0x77) + if (var >= MB_PACIFIDLOG_VERTICAL_LOG_1 && var <= MB_PACIFIDLOG_HORIZONTAL_LOG_2) return TRUE; else return FALSE; } -bool8 is_tile_x8C(u8 var) +bool8 MetatileBehavior_IsTrickHousePuzzleDoor(u8 var) { - if(var == 0x8C) + if (var == MB_TRICK_HOUSE_PUZZLE_DOOR) return TRUE; else return FALSE; } -bool8 is_tile_x85(u8 var) +bool8 MetatileBehavior_IsRegionMap(u8 var) { - if(var == 0x85) + if (var == MB_REGION_MAP) return TRUE; else return FALSE; } -bool8 is_tile_x8B(u8 var) +bool8 MetatileBehavior_IsClosedSootopolisGymDoor(u8 var) { - if(var == 0x8B) + if (var == MB_CLOSED_SOOTOPOLIS_GYM_DOOR) return TRUE; else return FALSE; } -bool8 is_tile_x8A(u8 var) +bool8 MetatileBehavior_IsRoulette(u8 var) { - if(var == 0x8A) + if (var == MB_ROULETTE) return TRUE; else return FALSE; } -bool8 is_tile_x87(u8 var) +bool8 MetatileBehavior_IsPokeblockFeeder(u8 var) { - if(var == 0x87) + if (var == MB_POKEBLOCK_FEEDER) return TRUE; else return FALSE; @@ -856,7 +1101,7 @@ bool8 is_tile_x87(u8 var) bool8 MetatileBehavior_0xBB(u8 var) { - if(var == 0xBB) + if (var == MB_BB) return TRUE; else return FALSE; @@ -864,23 +1109,23 @@ bool8 MetatileBehavior_0xBB(u8 var) bool8 MetatileBehavior_0xBC(u8 var) { - if(var == 0xBC) + if (var == MB_BC) return TRUE; else return FALSE; } -bool8 sub_8057798(u8 var) +bool8 MetatileBehavior_IsLavaridgeB1FWarp(u8 var) { - if(var == 0x29) + if (var == MB_LAVARIDGE_GYM_B1F_WARP) return TRUE; else return FALSE; } -bool8 is_role_x68(u8 var) +bool8 MetatileBehavior_IsLavaridge1FWarp(u8 var) { - if(var == 0x68) + if (var == MB_LAVARIDGE_GYM_1F_WARP) return TRUE; else return FALSE; @@ -888,7 +1133,7 @@ bool8 is_role_x68(u8 var) bool8 MetatileBehavior_IsAquaHideoutWarp(u8 var) { - if(var == 0x67) + if (var == MB_AQUA_HIDEOUT_WARP) return TRUE; else return FALSE; @@ -896,31 +1141,31 @@ bool8 MetatileBehavior_IsAquaHideoutWarp(u8 var) bool8 MetatileBehavior_IsSurfableFishableWater(u8 var) { - if(var == 0x10 || var == 0x15 || var == 0x11 || var == 0x12 || var == 0x14 || (u8)(var - 0x50) < 4) + if (var == MB_POND_WATER || var == MB_OCEAN_WATER || var == MB_SEMI_DEEP_WATER || var == MB_DEEP_WATER || var == MB_SOOTOPOLIS_DEEP_WATER || (var >= MB_EASTWARD_CURRENT && var <= MB_SOUTHWARD_CURRENT)) return TRUE; else return FALSE; } -bool8 sub_8057804(u8 var) +bool8 MetatileBehavior_IsMtPyreHole(u8 var) { - if(var == 0xF) + if (var == MB_MT_PYRE_HOLE) return TRUE; else return FALSE; } -bool8 sub_8057818(u8 var) +bool8 MetatileBehavior_IsCrackedFloorHole(u8 var) { - if(var == 0x66) + if (var == MB_CRACKED_FLOOR_HOLE) return TRUE; else return FALSE; } -bool8 sub_805782C(u8 var) +bool8 MetatileBehavior_IsCrackedFloor(u8 var) { - if(var == 0xD2) + if (var == MB_CRACKED_FLOOR) return TRUE; else return FALSE; @@ -928,7 +1173,7 @@ bool8 sub_805782C(u8 var) bool8 MetatileBehavior_IsMuddySlope(u8 var) { - if(var == 0xD0) + if (var == MB_MUDDY_SLOPE) return TRUE; else return FALSE; @@ -936,7 +1181,7 @@ bool8 MetatileBehavior_IsMuddySlope(u8 var) bool8 MetatileBehavior_IsBumpySlope(u8 var) { - if(var == 0xD1) + if (var == MB_BUMPY_SLOPE) return TRUE; else return FALSE; @@ -944,7 +1189,7 @@ bool8 MetatileBehavior_IsBumpySlope(u8 var) bool8 MetatileBehavior_IsIsolatedVerticalRail(u8 var) { - if(var == 0xD3) + if (var == MB_ISOLATED_VERTICAL_RAIL) return TRUE; else return FALSE; @@ -952,7 +1197,7 @@ bool8 MetatileBehavior_IsIsolatedVerticalRail(u8 var) bool8 MetatileBehavior_IsIsolatedHorizontalRail(u8 var) { - if(var == 0xD4) + if (var == MB_ISOLATED_HORIZONTAL_RAIL) return TRUE; else return FALSE; @@ -960,7 +1205,7 @@ bool8 MetatileBehavior_IsIsolatedHorizontalRail(u8 var) bool8 MetatileBehavior_IsVerticalRail(u8 var) { - if(var == 0xD5) + if (var == MB_VERTICAL_RAIL) return TRUE; else return FALSE; @@ -968,7 +1213,7 @@ bool8 MetatileBehavior_IsVerticalRail(u8 var) bool8 MetatileBehavior_IsHorizontalRail(u8 var) { - if(var == 0xD6) + if (var == MB_HORIZONTAL_RAIL) return TRUE; else return FALSE; @@ -976,7 +1221,7 @@ bool8 MetatileBehavior_IsHorizontalRail(u8 var) bool8 MetatileBehavior_IsSeaweed(u8 var) { - if(var == 0x22 || var == 0x2A) + if (var == MB_SEAWEED || var == MB_SEAWEED_NO_SURFACING) return TRUE; else return FALSE; @@ -984,15 +1229,15 @@ bool8 MetatileBehavior_IsSeaweed(u8 var) bool8 MetatileBehavior_IsRunningDisallowed(u8 var) { - if(var == 0xA || var == 0x3 || var == 0x28 || MetatileBehavior_IsPacifidlogLog(var) != FALSE) + if (var == MB_NO_RUNNING || var == MB_LONG_GRASS || var == MB_HOT_SPRINGS || MetatileBehavior_IsPacifidlogLog(var) != FALSE) return TRUE; else return FALSE; } -bool8 sub_80578F8(u8 var) +bool8 MetatileBehavior_IsCuttableGrass(u8 var) { - if(var == 0x02 || var == 0x03 || var == 0x24 || var == 0x9) + if (var == MB_TALL_GRASS || var == MB_LONG_GRASS || var == MB_ASHGRASS || var == MB_LONG_GRASS_SOUTH_EDGE) return TRUE; else return FALSE; @@ -1000,63 +1245,63 @@ bool8 sub_80578F8(u8 var) bool8 sub_805791C(u8 var) { - if(var == 0x8E) + if (var == MB_8E) return TRUE; else return FALSE; } -bool8 sub_8057930(u8 var) +bool8 MetatileBehavior_IsPictureBookShelf(u8 var) { - if(var == 0xE0) + if (var == MB_PICTURE_BOOK_SHELF) return TRUE; else return FALSE; } -bool8 sub_8057944(u8 var) +bool8 MetatileBehavior_IsBookShelf(u8 var) { - if(var == 0xE1) + if (var == MB_BOOKSHELF) return TRUE; else return FALSE; } -bool8 sub_8057958(u8 var) +bool8 MetatileBehavior_IsPokeCenterBookShelf(u8 var) { - if(var == 0xE2) + if (var == MB_POKEMON_CENTER_BOOKSHELF) return TRUE; else return FALSE; } -bool8 sub_805796C(u8 var) +bool8 MetatileBehavior_IsVase(u8 var) { - if(var == 0xE3) + if (var == MB_VASE) return TRUE; else return FALSE; } -bool8 sub_8057980(u8 var) +bool8 MetatileBehavior_IsTrashCan(u8 var) { - if(var == 0xE4) + if (var == MB_TRASH_CAN) return TRUE; else return FALSE; } -bool8 sub_8057994(u8 var) +bool8 MetatileBehavior_IsShopShelf(u8 var) { - if(var == 0xE5) + if (var == MB_SHOP_SHELF) return TRUE; else return FALSE; } -bool8 sub_80579A8(u8 var) +bool8 MetatileBehavior_IsBlueprint(u8 var) { - if(var == 0xE6) + if (var == MB_BLUEPRINT) return TRUE; else return FALSE; diff --git a/src/money.c b/src/money.c index 38ca5f817..ab4508a39 100644 --- a/src/money.c +++ b/src/money.c @@ -10,55 +10,78 @@ extern u16 gSpecialVar_0x8005; extern u8 gUnknown_02038734; -extern const struct SpriteSheet gUnknown_083CF584; -extern const struct SpritePalette gUnknown_083CF58C; +extern const struct CompressedSpriteSheet gUnknown_083CF584; +extern const struct CompressedSpritePalette gUnknown_083CF58C; extern const struct SpriteTemplate gSpriteTemplate_83CF56C; -bool8 IsEnoughMoney(u32 budget, u32 cost) { - if (budget >= cost) { +bool8 IsEnoughMoney(u32 budget, u32 cost) +{ + if (budget >= cost) + { return TRUE; } return FALSE; } -void sub_80B79B8(u32 *arg0, u32 arg1) { - if (*arg0 > *arg0 + arg1) { +void sub_80B79B8(u32 *arg0, u32 arg1) +{ + if (*arg0 > *arg0 + arg1) + { *arg0 = 999999; return; } *arg0 = *arg0 + arg1; - if (*arg0 > 999999) { + if (*arg0 > 999999) + { *arg0 = 999999; } } -void sub_80B79E0(u32 *arg0, u32 arg1) { - if (*arg0 < arg1) { +void sub_80B79E0(u32 *arg0, u32 arg1) +{ + if (*arg0 < arg1) + { *arg0 = 0; - } else { + } + else + { *arg0 = *arg0 - arg1; } } -void sub_80B79F8(u8 *buffer, u32 arg1, u8 arg2) { +void sub_80B79F8(u8 *buffer, u32 arg1, u8 arg2) +{ u8 width; u8 i; - if (arg1 > 999999) { + if (arg1 > 999999) + { width = 7; - } else if (arg1 > 99999) { + } + else if (arg1 > 99999) + { width = 6; - } else if (arg1 > 10000) { + } + else if (arg1 > 10000) + { width = 5; - } else if (arg1 > 999) { + } + else if (arg1 > 999) + { width = 4; - } else if (arg1 > 99) { + } + else if (arg1 > 99) + { width = 3; - } else if (arg1 > 9) { + } + else if (arg1 > 9) + { width = 2; - } else { + } + else + { width = 1; } @@ -67,7 +90,8 @@ void sub_80B79F8(u8 *buffer, u32 arg1, u8 arg2) { buffer[2] = 0x06; buffer += 3; - for (i = 0; i < arg2 - width; i++) { + for (i = 0; i < arg2 - width; i++) + { buffer[0] = CHAR_SPACE; buffer += 1; } @@ -83,74 +107,25 @@ void sub_80B79F8(u8 *buffer, u32 arg1, u8 arg2) { buffer[3] = EOS; } -#ifdef NONMATCHING -void sub_80B7A94(u32 arg0, u8 size, u8 x, u8 y) { +void sub_80B7A94(u32 arg0, u8 size, u8 x, u8 y) +{ u8 buffer[16]; u8 stringWidth; sub_80B79F8(buffer, arg0, size); stringWidth = sub_8072CA4(buffer); - if (stringWidth >= (size + 1) * 8) { + if (stringWidth >= (size + 1) * 8) MenuPrint(buffer, x, y); - } else { - u8 pixelX = (size + 1) * 8 - stringWidth; - MenuPrint_PixelCoords(buffer, pixelX, y * 8, 1); + else + { + int xPlusOne = x + 1; + MenuPrint_PixelCoords(buffer, (xPlusOne + size) * 8 - stringWidth, y * 8, 1); } } -#else -__attribute__((naked)) -void sub_80B7A94(u32 arg0, u8 arg1, u8 x, u8 y) { - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - sub sp, 0x10\n\ - adds r4, r0, 0\n\ - lsls r1, 24\n\ - lsrs r5, r1, 24\n\ - lsls r2, 24\n\ - lsrs r6, r2, 24\n\ - lsls r3, 24\n\ - lsrs r7, r3, 24\n\ - mov r0, sp\n\ - adds r1, r4, 0\n\ - adds r2, r5, 0\n\ - bl sub_80B79F8\n\ - mov r0, sp\n\ - bl sub_8072CA4\n\ - lsls r0, 24\n\ - lsrs r2, r0, 24\n\ - adds r0, r5, 0x1\n\ - lsls r0, 3\n\ - cmp r2, r0\n\ - blt _080B7ACE\n\ - mov r0, sp\n\ - adds r1, r6, 0\n\ - adds r2, r7, 0\n\ - bl MenuPrint\n\ - b _080B7AE4\n\ -_080B7ACE:\n\ - adds r1, r6, 0x1\n\ - adds r1, r5\n\ - lsls r1, 3\n\ - subs r1, r2\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - lsls r2, r7, 3\n\ - mov r0, sp\n\ - movs r3, 0x1\n\ - bl MenuPrint_PixelCoords\n\ -_080B7AE4:\n\ - add sp, 0x10\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided\n"); -} - -#endif - -void sub_80B7AEC(u32 arg0, u8 left, u8 top) { +void sub_80B7AEC(u32 arg0, u8 left, u8 top) +{ u8 buffer[32]; u8 *ptr; @@ -163,14 +138,17 @@ void sub_80B7AEC(u32 arg0, u8 left, u8 top) { MenuPrint_RightAligned(buffer, left, top); +#ifdef ENGLISH ptr[0] = 0xFC; ptr[1] = 0x14; ptr[2] = 0x00; ptr[3] = 0xFF; +#endif } __attribute__((naked)) -void sub_80B7B34(void) { +void sub_80B7B34(void) +{ asm(".syntax unified\n\ push {r4-r7,lr}\n\ mov r7, r9\n\ @@ -262,11 +240,13 @@ _080B7BE8: .4byte 0x0600f840\n\ .syntax divided\n"); } -void sub_80B7BEC(u32 arg0, u8 x, u8 y) { +void sub_80B7BEC(u32 arg0, u8 x, u8 y) +{ sub_80B7A94(arg0, 6, x + 6, y + 1); } -void sub_80B7C14(u32 arg0, u8 x, u8 y) { +void sub_80B7C14(u32 arg0, u8 x, u8 y) +{ MenuDrawTextWindow(x, y, x + 13, y + 3); sub_80B7BEC(arg0, x, y); @@ -276,16 +256,19 @@ void sub_80B7C14(u32 arg0, u8 x, u8 y) { gUnknown_02038734 = CreateSprite(&gSpriteTemplate_83CF56C, x * 8 + 19, y * 8 + 11, 0); } -void RemoveMoneyLabelObject(u8 x, u8 y) { +void RemoveMoneyLabelObject(u8 x, u8 y) +{ DestroySpriteAndFreeResources(&gSprites[gUnknown_02038734]); FreeSpritePaletteByTag(SPRITE_TAG_MONEY); MenuZeroFillWindowRect(x, y, x + 13, y + 3); } -bool8 sub_80B7CE8(void) { +bool8 sub_80B7CE8(void) +{ return IsEnoughMoney(gSaveBlock1.money, gSpecialVar_0x8005); } -void sub_80B7D0C(void) { +void sub_80B7D0C(void) +{ sub_80B79E0(&gSaveBlock1.money, gSpecialVar_0x8005); } diff --git a/src/mori_debug_menu.c b/src/mori_debug_menu.c index fbb796ca4..ba79261c0 100644 --- a/src/mori_debug_menu.c +++ b/src/mori_debug_menu.c @@ -1,26 +1,44 @@ #include "global.h" #include "mori_debug_menu.h" -#include "asm.h" -#include "start_menu.h" -#include "menu.h" +#include "data2.h" +#include "daycare.h" +#include "learn_move.h" +#include "link.h" #include "main.h" +#include "menu.h" +#include "pokeblock.h" +#include "start_menu.h" #include "string_util.h" +#define SIO_MULTI_CNT ((struct SioMultiCnt *)REG_ADDR_SIOCNT) + +extern u8 gUnknown_03004DA0[]; extern u8 (*gCallback_03004AE8)(void); +extern u8 gUnknown_0839B22C[][3]; +extern u8 gUnknown_0839B24A[]; extern u8 gUnknown_0839B24D[]; extern u8 gUnknown_0839B255[]; extern u8 gUnknown_0839B257[]; extern const struct MenuAction gMoriDebugMenuActions[]; -extern u8 gSpeciesNames[][11]; +void unref_sub_8083CF0(void) +{ + int i; + int id = SIO_MULTI_CNT->id; + gUnknown_03004DA0[0] = EOS; + StringAppend(gUnknown_03004DA0, gUnknown_0839B24A); + for (i = 0; i < 10; i++) + if ((word_3002910[id ^ 1] >> i) & 1) + StringAppend(gUnknown_03004DA0, gUnknown_0839B22C[i]); +} bool8 sub_8083D4C(void) { if ( gMain.newKeys & A_BUTTON ) { - sub_8071C20(); + CloseMenu(); return TRUE; } else @@ -32,7 +50,7 @@ u8 MoriDebugMenu_SearchChild(u8 a1, u8 a2, u8 *ptr) u8 localPtr[52]; u16 monData; u16 var; - + monData = GetMonData(gPlayerParty, 11, ptr); var = sub_8041870(monData); StringCopy(localPtr, gSpeciesNames[monData]); @@ -48,18 +66,18 @@ u8 MoriDebugMenu_SearchChild(u8 a1, u8 a2, u8 *ptr) s8 MoriDebugMenu_Egg(void) { - if ( daycare_count_pokemon(gSaveBlock1.filler_2F9C) == 2 && daycare_relationship_score_from_savegame() ) + if ( Daycare_CountPokemon(gSaveBlock1.daycareData) == 2 && daycare_relationship_score_from_savegame() ) sub_8041940(); - sub_8071C20(); + CloseMenu(); return 1; } s8 MoriDebugMenu_MaleEgg(void) { - if ( daycare_count_pokemon(gSaveBlock1.filler_2F9C) == 2 && daycare_relationship_score_from_savegame() ) + if ( Daycare_CountPokemon(gSaveBlock1.daycareData) == 2 && daycare_relationship_score_from_savegame() ) sub_8041950(); - sub_8071C20(); + CloseMenu(); return 1; } @@ -67,21 +85,21 @@ s8 MoriDebugMenu_MaleEgg(void) s8 MoriDebugMenu_1000Steps(void) { sub_8041790(1000); - sub_8071C20(); - return 1; + CloseMenu(); + return 1; } s8 MoriDebugMenu_10000Steps(void) { sub_8041790(10000); - sub_8071C20(); - return 1; + CloseMenu(); + return 1; } s8 MoriDebugMenu_MoveTutor(void) { sub_8132670(); - sub_8071C20(); + CloseMenu(); return 1; } @@ -89,7 +107,7 @@ s8 MoriDebugMenu_BreedEgg(void) { u8 loopCounter; - for(loopCounter = 0; loopCounter <= 5; loopCounter++) + for (loopCounter = 0; loopCounter <= 5; loopCounter++) { //UB: Too few arguments for function 'GetMonData' if ( GetMonData(&gPlayerParty[loopCounter], MON_DATA_IS_EGG) ) @@ -99,25 +117,25 @@ s8 MoriDebugMenu_BreedEgg(void) } } gSaveBlock1.filler_30B6 = -3; - sub_8071C20(); + CloseMenu(); return 1; } s8 MoriDebugMenu_LongName(void) { SetMonData(gPlayerParty, MON_DATA_NICKNAME, gUnknown_0839B257); - sub_8071C20(); + CloseMenu(); return 1; } s8 MoriDebugMenu_PokeblockCase(void) { s32 loopCounter; - - for(loopCounter = 0; loopCounter <= 39; loopCounter++) + + for (loopCounter = 0; loopCounter <= 39; loopCounter++) sub_810CA6C((u8)loopCounter); - - sub_8071C20(); + + CloseMenu(); return 1; } @@ -133,7 +151,7 @@ bool8 MoriDebugMenuProcessInput(void) case -2: return FALSE; case -1: - sub_8071C20(); + CloseMenu(); return TRUE; } } diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c new file mode 100644 index 000000000..4be5dec1c --- /dev/null +++ b/src/mystery_event_menu.c @@ -0,0 +1,340 @@ +#include "global.h" +#include "mystery_event_menu.h" +#include "link.h" +#include "main.h" +#include "menu.h" +#include "mystery_event_script.h" +#include "palette.h" +#include "save.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "string_util.h" +#include "strings2.h" +#include "task.h" +#include "text.h" + +extern u8 unk_2000000[]; +extern u8 gUnknown_02039338; + +static void VBlankCB(void); +static bool8 CheckLanguageMatch(void); +static bool8 GetEventLoadMessage(u8 *dest, u32 status); +static void CB2_MysteryEventMenu(void); + +static void VBlankCB(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +static bool8 CheckLanguageMatch(void) +{ + bool8 val = FALSE; + + if (gLinkPlayers[0].language == gLinkPlayers[1].language) + val = TRUE; + + return val; +} + +void CB2_InitMysteryEventMenu(void) +{ + ResetSpriteData(); + FreeAllSpritePalettes(); + ResetTasks(); + SetVBlankCallback(VBlankCB); + SetUpWindowConfig(&gWindowConfig_81E6CE4); + InitMenuWindow(&gWindowConfig_81E6CE4); + MenuZeroFillScreen(); + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON; + REG_BLDCNT = 0; + CreateTask(Task_DestroySelf, 0); + StopMapMusic(); + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); + FillPalette(0, 0, 2); + SetMainCallback2(CB2_MysteryEventMenu); +} + +static bool8 GetEventLoadMessage(u8 *dest, u32 status) +{ + bool8 retVal = 1; + + if (status == 0) + { + StringCopy(dest, gSystemText_EventLoadSuccess); + retVal = 0; + } + + if (status == 2) + retVal = 0; + + if (status == 1) + StringCopy(dest, gSystemText_LoadingError); + + return retVal; +} + +static void CB2_MysteryEventMenu(void) +{ + u16 unkVal; + + switch (gMain.state) + { + case 0: + MenuDrawTextWindow(0, 14, 29, 19); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + gMain.state++; + break; + case 1: + if (gPaletteFade.active) + break; + sub_8072044(gSystemText_LinkStandby); + gMain.state++; + break; + case 2: + if (MenuUpdateWindowText()) + { + gMain.state++; + gLinkType = 21761; + OpenLink(); + } + break; + case 3: + if ((gLinkStatus & 0x20) && (gLinkStatus & 0x1C) > 4) + { + PlaySE(SE_PIN); + sub_8072044(gSystemText_LoadEventPressA); + gMain.state++; + } + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + CloseLink(); + gMain.state = 15; + } + break; + case 4: + if (MenuUpdateWindowText()) + gMain.state++; + break; +#ifdef NONMATCHING + case 5: + if (GetLinkPlayerCount_2() != 2) + { + GetEventLoadMessage(gStringVar4, 1); + sub_8072044(gStringVar4); + gMain.state = 13; + break; + } + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + sub_8007F4C(); + MenuDrawTextWindow(6, 5, 23, 8); + MenuPrint(gSystemText_LoadingEvent, 7, 6); + gMain.state++; + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + CloseLink(); + gMain.state = 15; + } + break; + case 6: + if (IsLinkConnectionEstablished()) + { + if (!gReceivedRemoteLinkPlayers) + break; + + if (GetLinkPlayerDataExchangeStatusTimed() == 3) + { + sub_800832C(); + MenuZeroFillWindowRect(6, 5, 23, 8); + GetEventLoadMessage(gStringVar4, 1); + sub_8072044(gStringVar4); + gMain.state = 13; + break; + } + else if (CheckLanguageMatch()) + { + sub_8072044(gSystemText_DontCutLink); + gMain.state++; + break; + } + else + { + CloseLink(); + MenuZeroFillWindowRect(6, 5, 23, 8); + GetEventLoadMessage(gStringVar4, 1); + sub_8072044(gStringVar4); + gMain.state = 13; + break; + } + } + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + CloseLink(); + gMain.state = 15; + break; + } + break; +#else + case 5: + if (GetLinkPlayerCount_2() != 2) + { + goto label; + } + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + sub_8007F4C(); + MenuDrawTextWindow(6, 5, 23, 8); + MenuPrint(gSystemText_LoadingEvent, 7, 6); + gMain.state++; + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + CloseLink(); + gMain.state = 15; + } + break; + case 6: + if (IsLinkConnectionEstablished()) + { + register u8 *ptr asm("r0"); + register u32 offset1 asm("r2"); + register u32 offset2 asm("r1"); + + if (!gReceivedRemoteLinkPlayers) + break; + + if (GetLinkPlayerDataExchangeStatusTimed() == 3) + { + sub_800832C(); + MenuZeroFillWindowRect(6, 5, 23, 8); + GetEventLoadMessage(gStringVar4, 1); + sub_8072044(gStringVar4); + ptr = (u8 *)&gMain; + offset1 = offsetof(struct Main, state); + asm("" ::: "r1"); + ptr += offset1; + *ptr = 13; + } + else if (CheckLanguageMatch()) + { + register u8 *ptr2 asm("r1"); + register int offset3 asm("r0"); + register int dummy asm("r2"); + sub_8072044(gSystemText_DontCutLink); + ptr2 = (u8 *)&gMain; + offset3 = offsetof(struct Main, state); + if (dummy) + dummy++; + ptr2 += offset3; + (*ptr2)++; + break; + } + else + { + CloseLink(); + MenuZeroFillWindowRect(6, 5, 23, 8); + label: + GetEventLoadMessage(gStringVar4, 1); + sub_8072044(gStringVar4); + ptr = (u8 *)&gMain; + offset2 = offsetof(struct Main, state); + ptr += offset2; + *ptr = 13; + } + break; + } + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + CloseLink(); + gMain.state = 15; + break; + } + break; +#endif + case 7: + if (MenuUpdateWindowText()) + gMain.state++; + break; + case 8: + if (GetBlockReceivedStatus()) + { + ResetBlockReceivedFlags(); + gMain.state++; + } + break; + case 9: + gMain.state++; + break; + case 10: + sub_800832C(); + gMain.state++; + break; + case 11: + if (gReceivedRemoteLinkPlayers) + break; + unkVal = sub_812613C(unk_2000000); + CpuFill32(0, unk_2000000, 0x7D4); + if (!GetEventLoadMessage(gStringVar4, unkVal)) + TrySavingData(NORMAL_SAVE); + gMain.state++; + break; + case 12: + sub_8072044(gStringVar4); + gMain.state++; + break; + case 13: + MenuZeroFillWindowRect(6, 5, 23, 8); + if (MenuUpdateWindowText()) + { + gMain.state++; + gUnknown_02039338 = 0; + } + break; + case 14: + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + gMain.state++; + } + break; + case 15: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); + gMain.state++; + break; + case 16: + if (!gPaletteFade.active) + DoSoftReset(); + break; + } + + if (gLinkStatus & 0x40) + { + if (!IsLinkMaster()) + { + CloseLink(); + MenuZeroFillWindowRect(6, 5, 23, 8); + GetEventLoadMessage(gStringVar4, 1); + sub_8072044(gStringVar4); + gMain.state = 13; + } + } + + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c new file mode 100644 index 000000000..45ef719da --- /dev/null +++ b/src/mystery_event_script.c @@ -0,0 +1,103 @@ +#include "global.h" +#include "mystery_event_script.h" +#include "script.h" +#include "string_util.h" +#include "text.h" + +#if ENGLISH +#define UNK_MASK_1 0x2 +#elif GERMAN +#define UNK_MASK_1 0x4 +#endif + +#ifdef SAPPHIRE +#define UNK_MASK_2 0x100 +#else +#define UNK_MASK_2 0x80 +#endif + +extern struct ScriptContext gUnknown_02039288; + +extern ScrCmdFunc gScriptFuncs[]; +extern ScrCmdFunc gScriptFuncs_End[]; + +extern u8 gOtherText_DataCannotUseVersion[]; + +bool32 sub_8126098(u16 a1, u32 a2, u16 a3, u32 a4) +{ + if (!(a1 & UNK_MASK_1)) + return FALSE; + + if (!(a2 & UNK_MASK_1)) + return FALSE; + + if (!(a3 & 0x4)) + return FALSE; + + if (!(a4 & UNK_MASK_2)) + return FALSE; + + return TRUE; +} + +void sub_81260D0(void) +{ + StringExpandPlaceholders(gStringVar4, gOtherText_DataCannotUseVersion); + sub_8126160(3); +} + +void sub_81260EC(struct ScriptContext *ctx, u8 *ptr) +{ + InitScriptContext(ctx, gScriptFuncs, gScriptFuncs_End); + SetupBytecodeScript(ctx, ptr); + ctx->data[0] = (u32)ptr; + ctx->data[1] = 0; + ctx->data[2] = 0; + ctx->data[3] = 0; +} + +bool32 sub_812611C(struct ScriptContext *ctx) +{ + if (RunScript(ctx) && ctx->data[3]) + return TRUE; + else + return FALSE; +} + +u32 sub_812613C(u8 *ptr) +{ + struct ScriptContext *ctx = &gUnknown_02039288; + sub_81260EC(ctx, ptr); + while (sub_812611C(ctx)) + ; + return ctx->data[2]; +} + +void sub_8126160(u32 val) +{ + gUnknown_02039288.data[2] = val; +} + +int sub_812616C(u8 *a1, int a2) +{ + unsigned int i; + int sum = 0; + + for (i = 0; i < a2; i++) + sum += a1[i]; + + return sum; +} + +u32 sub_812618C(u8 *ptr) +{ + return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); +} + +void sub_81261A4(u8 *ptr, u32 val) +{ + ptr[0] = val; + ptr[1] = val >> 8; + ptr[2] = val >> 16; + ptr[3] = val >> 24; +} diff --git a/src/name_string_util.c b/src/name_string_util.c new file mode 100644 index 000000000..f1a935453 --- /dev/null +++ b/src/name_string_util.c @@ -0,0 +1,40 @@ +#include "global.h" +#include "name_string_util.h" +#include "string_util.h" +#include "text.h" + +void PadNameString(u8 *a1, u8 a2) +{ + u8 i; + + StripExtCtrlCodes(a1); + i = StringLength(a1); + + if (a2 == 0xFC) + { + while (i < 6) + { + a1[i] = 0xFC; + a1[i + 1] = 7; + i += 2; + } + } + else + { + while (i < 6) + { + a1[i] = a2; + i++; + } + } + + a1[i] = EOS; +} + +void SanitizeNameString(u8 *a1) +{ + if (StringLength(a1) < 6) + ConvertInternationalString(a1, 1); + else + StripExtCtrlCodes(a1); +} diff --git a/src/naming_screen.c b/src/naming_screen.c new file mode 100644 index 000000000..6c107f022 --- /dev/null +++ b/src/naming_screen.c @@ -0,0 +1,2038 @@ +#include "global.h" +#include "naming_screen.h" +#include "data2.h" +#include "field_effect.h" +#include "field_map_obj.h" +#include "field_player_avatar.h" +#include "main.h" +#include "menu.h" +#include "palette.h" +#include "pokemon_icon.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "string_util.h" +#include "strings2.h" +#include "task.h" +#include "text.h" +#include "trig.h" +#include "util.h" + +#ifdef ENGLISH +#define COLUMN_COUNT 9 +#elif GERMAN +#define COLUMN_COUNT 10 +#endif + +extern u16 gKeyRepeatStartDelay; + +extern u8 unk_2000000[]; + +#define namingScreenData (*(struct NamingScreenData *)(unk_2000000)) + +const u32 gSpriteImage_83CE094[] = INCBIN_U32("graphics/naming_screen/pc_icon/0.4bpp"); +const u32 gSpriteImage_83CE154[] = INCBIN_U32("graphics/naming_screen/pc_icon/1.4bpp"); + +//Some unused pointer, perhaps. +asm(".section .rodata\n\ +@ XXX: what is this?\n\ + .align 2\n\ + .4byte 0x2000000\n"); + +extern u16 *const gUnknown_083CE28C[]; +extern const struct SubspriteTable gSubspriteTables_83CE558[]; +extern const struct SubspriteTable gSubspriteTables_83CE560[]; +extern const struct SubspriteTable gSubspriteTables_83CE578[]; +extern const struct SubspriteTable gSubspriteTables_83CE580[]; +extern const struct SpriteTemplate gSpriteTemplate_83CE5C8; +extern const struct SpriteTemplate gSpriteTemplate_83CE5E0; +extern const struct SpriteTemplate gSpriteTemplate_83CE5F8; +extern const struct SpriteTemplate gSpriteTemplate_83CE610; +extern const struct SpriteTemplate gSpriteTemplate_83CE628; +extern const struct SpriteTemplate gSpriteTemplate_83CE640; +extern const struct SpriteTemplate gSpriteTemplate_83CE658; +extern const struct SpriteTemplate gSpriteTemplate_83CE670; +extern const struct SpriteTemplate gSpriteTemplate_83CE688; +extern const struct SpriteSheet gUnknown_083CE6A0[]; +extern const struct SpritePalette gUnknown_083CE708[]; +extern const u8 gNamingScreenMenu_Gfx[]; +extern const u16 gNamingScreenPalettes[]; +extern const u16 gUnknown_083CE748[]; +extern const u16 gUnknown_083CEBF8[]; +extern const u16 gUnknown_083CF0A8[]; +extern const u16 gUnknown_08E86258[]; + +static void C2_NamingScreen(void); +static void sub_80B5AA0(void); +static void StoreNamingScreenParameters(u8, u8 *, u16, u16, u32, MainCallback); +static void NamingScreen_TurnOffScreen(void); +static void NamingScreen_Init(void); +static void NamingScreen_ClearVram(void); +static void NamingScreen_ClearOam(void); +static void NamingScreen_SetUpVideoRegs(void); +static void NamingScreen_SetUpWindow(void); +static void NamingScreen_ResetObjects(void); +static void sub_80B5DFC(void); +static void sub_80B5E20(void); +static void sub_80B5E3C(void); +static void NamingScreen_InitDisplayMode(void); +static void Task_DoNothing(u8); +static void sub_80B7558(void); +static void sub_80B753C(void); +static void sub_80B7680(void); +static void sub_80B75C4(void); +static void sub_80B7794(void); +static void sub_80B78A8(void); +static void sub_80B7960(void); +static void CursorInit(void); +static void sub_80B6A80(void); +static void sub_80B6CA8(void); +static void sub_80B6D04(void); +static void sub_80B6E44(void); +static void InputInit(void); +static void sub_80B6438(void); +static void sub_80B5E50(void); +static void Task_NamingScreenMain(u8); +static void SetInputState(u8); +static void sub_80B68D8(u8); +static bool8 HandleKeyboardEvent(void); +static bool8 IsCursorAnimFinished(void); +static void MoveCursorToOKButton(void); +static void sub_80B6B14(void); +static void StartPageSwapAnim(void); +static void sub_80B6888(u8); +static void sub_80B6460(u8, u8, u8); +static bool8 IsPageSwapAnimNotInProgress(void); +static void sub_80B7614(void); +static void GetCursorPos(s16 *, s16 *); +static void SetCursorPos(s16, s16); +static void sub_80B77F8(void); +static void sub_80B74B0(void); +static void DisplaySentToPCMessage(void); +static u8 GetKeyRoleAtCursorPos(void); +static u8 sub_80B61C8(void); +static void DeleteTextCharacter(void); +static void sub_80B7090(void); +static u8 GetInputEvent(void); +static bool8 sub_80B7004(void); +static void sub_80B6914(void); +static void Task_HandlePageSwapAnim(u8); +static void sub_80B6C48(u8, struct Sprite *, struct Sprite *); +static u8 GetTextCaretPosition(void); +static u8 GetCharAtKeyboardPos(s16, s16); +static bool8 sub_80B7104(void); +static bool8 sub_80B713C(void); +static void AddTextCharacter(u8); +static bool8 sub_80B7198(u8); +static bool8 sub_80B7264(u8); +static void sub_80B7370(u8, u8); +static void sub_80B73CC(u8, u8); +static bool8 sub_80B71E4(u8); +static void sub_80B7474(u8, u8); +static void sub_80B72A4(u8, u8); +static bool8 sub_80B720C(u8); +static void sub_80B7568(void); +static void sub_80B75B0(void); +static void sub_80B7698(u16 *, const u16 *); +static void sub_80B76E0(); +static void nullsub_20(u8, u8); +static void PrintKeyboardCharacters(u8); + +void DoNamingScreen(u8 templateNum, u8 *destBuffer, u16 c, u16 d, u32 e, MainCallback returnCallback) +{ + StoreNamingScreenParameters(templateNum, destBuffer, c, d, e, returnCallback); + SetMainCallback2(C2_NamingScreen); +} + +static void C2_NamingScreen(void) +{ + switch (gMain.state) + { + case 0: + NamingScreen_TurnOffScreen(); + NamingScreen_Init(); + gMain.state++; + break; + case 1: + NamingScreen_ClearVram(); + gMain.state++; + break; + case 2: + NamingScreen_ClearOam(); + gMain.state++; + break; + case 3: + NamingScreen_SetUpVideoRegs(); + gMain.state++; + break; + case 4: + NamingScreen_SetUpWindow(); + gMain.state++; + break; + case 5: + NamingScreen_ResetObjects(); + gMain.state++; + break; + case 6: + sub_80B5DFC(); + gMain.state++; + break; + case 7: + sub_80B5E20(); + sub_80B5E3C(); + NamingScreen_InitDisplayMode(); + SetMainCallback2(sub_80B5AA0); + break; + } +} + +static void sub_80B5AA0(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +static void VBlankCB_NamingScreen(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); + REG_BG1VOFS = namingScreenData.bg1vOffset; + REG_BG2VOFS = namingScreenData.bg2vOffset; + REG_BG1CNT &= 0xFFFC; + REG_BG1CNT |= namingScreenData.unk8; + REG_BG2CNT &= 0xFFFC; + REG_BG2CNT |= namingScreenData.unkA; +} + +static void StoreNamingScreenParameters(u8 templateNum, u8 *destBuffer, u16 c, u16 d, u32 e, MainCallback returnCallback) +{ + struct Task *task; + + //Create a task that does nothing, and use it as a temporary space to store parameters + task = &gTasks[CreateTask(Task_DoNothing, 0xFF)]; + task->data[0] = templateNum; + task->data[1] = c; + task->data[2] = d; + task->data[3] = e >> 16; + task->data[4] = e; + StoreWordInTwoHalfwords(&task->data[5], (u32)destBuffer); + StoreWordInTwoHalfwords(&task->data[7], (u32)returnCallback); +} + +static void GetNamingScreenParameters(void) +{ + u8 taskId; + struct Task *task; + + taskId = FindTaskIdByFunc(Task_DoNothing); + task = &gTasks[taskId]; + namingScreenData.templateNum = task->data[0]; + namingScreenData.unk3E = task->data[1]; + namingScreenData.unk40 = task->data[2]; + namingScreenData.unk42 = (task->data[3] << 16) | (u16)task->data[4]; + LoadWordFromTwoHalfwords(&task->data[5], (u32 *)&namingScreenData.destBuffer); + LoadWordFromTwoHalfwords(&task->data[7], (u32 *)&namingScreenData.returnCallback); + DestroyTask(taskId); +} + +static void Task_DoNothing(u8 taskId) +{ +} + +static void NamingScreen_TurnOffScreen(void) +{ + SetVBlankCallback(NULL); + SetHBlankCallback(NULL); + REG_DISPCNT = 0; +} + +static void NamingScreen_InitDisplayMode(void) +{ + u16 savedIme; + + SetVBlankCallback(VBlankCB_NamingScreen); + savedIme = REG_IME; + REG_IME = 0; + REG_IE |= INTR_FLAG_VBLANK; + REG_IME = savedIme; + REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON; +} + +static void NamingScreen_ClearVram(void) +{ + u8 *addr = (void *)VRAM; + u32 size = 0x10000; + + while (1) + { + DmaFill16(3, 0, addr, 0x1000); + addr += 0x1000; + size -= 0x1000; + if (size <= 0x1000) + { + DmaFill16(3, 0, addr, size); + break; + } + } +} + +static void NamingScreen_ClearOam(void) +{ + DmaClear16(3, (void *)OAM, 0x400); +} + +static void NamingScreen_SetUpVideoRegs(void) +{ + REG_BG0CNT = 0; + REG_BG1CNT = 0; + REG_BG2CNT = 0; + REG_BG3CNT = 0; + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG2HOFS = 0; + REG_BG2VOFS = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(28) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(29) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(30) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BLDCNT = 0x640; + REG_BLDALPHA = 0x80C; +} + +static const struct NamingScreenTemplate *const sNamingScreenTemplates[]; //forward declaration + +static void NamingScreen_Init(void) +{ + GetNamingScreenParameters(); + namingScreenData.state = 0; + namingScreenData.bg1vOffset = 0; + namingScreenData.bg2vOffset = 0; + namingScreenData.unk8 = 1; + namingScreenData.unkA = 2; + namingScreenData.unkC = 0; + namingScreenData.unkD = 1; + namingScreenData.template = sNamingScreenTemplates[namingScreenData.templateNum]; + namingScreenData.currentPage = namingScreenData.template->unk4; + namingScreenData.unk2 = 14 - namingScreenData.template->maxChars / 2; + namingScreenData.unk3C = gKeyRepeatStartDelay; + memset(namingScreenData.textBuffer, 0xFF, sizeof(namingScreenData.textBuffer)); + if (namingScreenData.template->unk0 != 0) + StringCopy(namingScreenData.textBuffer, namingScreenData.destBuffer); + gKeyRepeatStartDelay = 16; +} + +static void NamingScreen_SetUpWindow(void) +{ + SetUpWindowConfig(&gWindowConfig_81E6E88); + InitMenuWindow(&gWindowConfig_81E6E88); +} + +static void NamingScreen_ResetObjects(void) +{ + ResetPaletteFade(); + ResetSpriteData(); + FreeAllSpritePalettes(); + ResetTasks(); +} + +static void sub_80B5DFC(void) +{ + sub_80B7558(); + sub_80B753C(); + sub_80B7680(); + sub_80B75C4(); + sub_80B7794(); + sub_80B78A8(); + sub_80B7960(); +} + +static void sub_80B5E20(void) +{ + CursorInit(); + sub_80B6A80(); + sub_80B6CA8(); + sub_80B6D04(); + sub_80B6E44(); +} + +static void sub_80B5E3C(void) +{ + InputInit(); + sub_80B6438(); + sub_80B5E50(); +} + +//-------------------------------------------------- +// Naming screen main +//-------------------------------------------------- + +static bool8 MainState_BeginFadeIn(struct Task *); +static bool8 MainState_WaitFadeIn(struct Task *); +static bool8 MainState_HandleInput(struct Task *); +static bool8 MainState_MoveToOKButton(struct Task *); +static bool8 MainState_StartPageSwap(struct Task *); +static bool8 MainState_WaitPageSwap(struct Task *); +static bool8 MainState_6(struct Task *); +static bool8 MainState_UpdateSentToPCMessage(struct Task *); +static bool8 MainState_BeginFadeInOut(struct Task *); +static bool8 MainState_WaitFadeOutAndExit(struct Task *); + +static bool8 (*const sMainStateFuncs[])(struct Task *) = +{ + MainState_BeginFadeIn, + MainState_WaitFadeIn, + MainState_HandleInput, + MainState_MoveToOKButton, + MainState_StartPageSwap, + MainState_WaitPageSwap, + MainState_6, + MainState_UpdateSentToPCMessage, + MainState_BeginFadeInOut, + MainState_WaitFadeOutAndExit, +}; + +static void sub_80B5E50(void) +{ + u8 taskId; + + taskId = CreateTask(Task_NamingScreenMain, 2); + Task_NamingScreenMain(taskId); +} + +static void Task_NamingScreenMain(u8 taskId) +{ + while (sMainStateFuncs[namingScreenData.state](&gTasks[taskId]) != 0) + ; +} + +static bool8 MainState_BeginFadeIn(struct Task *task) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + namingScreenData.state++; + return 0; +} + +static bool8 MainState_WaitFadeIn(struct Task *task) +{ + if (!gPaletteFade.active) + { + SetInputState(INPUT_STATE_ENABLED); + sub_80B68D8(1); + namingScreenData.state++; + } + return FALSE; +} + +static bool8 MainState_HandleInput(struct Task *task) +{ + return HandleKeyboardEvent(); +} + +static bool8 MainState_MoveToOKButton(struct Task *task) +{ + if (IsCursorAnimFinished()) + { + SetInputState(INPUT_STATE_ENABLED); + MoveCursorToOKButton(); + namingScreenData.state = MAIN_STATE_HANDLE_INPUT; + } + return FALSE; +} + +static bool8 MainState_StartPageSwap(struct Task *task) +{ + SetInputState(INPUT_STATE_DISABLED); + sub_80B6B14(); + StartPageSwapAnim(); + sub_80B6888(1); + sub_80B6460(0, 0, 1); + PlaySE(SE_WIN_OPEN); + namingScreenData.state = MAIN_STATE_WAIT_PAGE_SWAP; + return FALSE; +} + +static bool8 MainState_WaitPageSwap(struct Task *task) +{ + s16 cursorX; + s16 cursorY; + + if (IsPageSwapAnimNotInProgress()) + { + namingScreenData.state = MAIN_STATE_HANDLE_INPUT; + namingScreenData.currentPage++; + namingScreenData.currentPage %= 3; + sub_80B7614(); + sub_80B77F8(); + SetInputState(INPUT_STATE_ENABLED); + GetCursorPos(&cursorX, &cursorY); +#if ENGLISH + if (namingScreenData.currentPage == PAGE_OTHERS && (cursorX == 6 || cursorX == 7)) + cursorX = 5; +#elif GERMAN + if (namingScreenData.currentPage == PAGE_OTHERS && (cursorX == 7 || cursorX == 8)) + cursorX = 6; +#endif + SetCursorPos(cursorX, cursorY); + sub_80B6888(0); + } + return FALSE; +} + +static bool8 MainState_6(struct Task *task) +{ + sub_80B74B0(); + SetInputState(INPUT_STATE_DISABLED); + sub_80B68D8(0); + sub_80B6460(3, 0, 1); + gKeyRepeatStartDelay = namingScreenData.unk3C; + if (namingScreenData.templateNum == NAMING_SCREEN_TEMPLATE_MON_NAME + && CalculatePlayerPartyCount() >= 6) + { + DisplaySentToPCMessage(); + namingScreenData.state = MAIN_STATE_UPDATE_SENT_TO_PC_MESSAGE; + return FALSE; + } + else + { + namingScreenData.state = MAIN_STATE_BEGIN_FADE_OUT; + return TRUE; //Exit the naming screen + } +} + +static bool8 MainState_UpdateSentToPCMessage(struct Task *task) +{ + if (MenuUpdateWindowText()) + namingScreenData.state++; + return FALSE; +} + +static bool8 MainState_BeginFadeInOut(struct Task *task) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + namingScreenData.state++; + return FALSE; +} + +static bool8 MainState_WaitFadeOutAndExit(struct Task *task) +{ + if (!gPaletteFade.active) + SetMainCallback2(namingScreenData.returnCallback); + return FALSE; +} + +//-------------------------------------------------- +// Keyboard handling +//-------------------------------------------------- + +enum +{ + KEY_ROLE_CHAR, + KEY_ROLE_PAGE, + KEY_ROLE_BACKSPACE, + KEY_ROLE_OK, +}; + + +static bool8 KeyboardKeyHandler_Character(u8); +static bool8 KeyboardKeyHandler_Page(u8); +static bool8 KeyboardKeyHandler_Backspace(u8); +static bool8 KeyboardKeyHandler_OK(u8); + +static bool8 (*const sKeyboardKeyHandlers[])(u8) = +{ + KeyboardKeyHandler_Character, + KeyboardKeyHandler_Page, + KeyboardKeyHandler_Backspace, + KeyboardKeyHandler_OK, +}; + +static bool8 HandleKeyboardEvent(void) +{ + u8 event = GetInputEvent(); + u8 keyRole = GetKeyRoleAtCursorPos(); + + if (event == KBEVENT_PRESSED_SELECT) + return sub_80B61C8(); + else if (event == KBEVENT_PRESSED_B) + { + DeleteTextCharacter(); + return FALSE; + } + else if (event == 7) + { + sub_80B7090(); + return FALSE; + } + return sKeyboardKeyHandlers[keyRole](event); +} + +static bool8 KeyboardKeyHandler_Character(u8 event) +{ + sub_80B6460(3, 0, 0); + if (event == KBEVENT_PRESSED_A) + { + u8 var = sub_80B7004(); + + sub_80B6914(); + if (var) + { + SetInputState(INPUT_STATE_DISABLED); + namingScreenData.state = MAIN_STATE_MOVE_TO_OK_BUTTON; + } + } + return FALSE; +} + +static bool8 KeyboardKeyHandler_Page(u8 event) +{ + sub_80B6460(0, 1, 0); + if (event == KBEVENT_PRESSED_A) + return sub_80B61C8(); + else + return FALSE; +} + +static bool8 KeyboardKeyHandler_Backspace(u8 event) +{ + sub_80B6460(1, 1, 0); + if (event == KBEVENT_PRESSED_A) + DeleteTextCharacter(); + return FALSE; +} + +static bool8 KeyboardKeyHandler_OK(u8 event) +{ + sub_80B6460(2, 1, 0); + if (event == KBEVENT_PRESSED_A) + { + PlaySE(SE_SELECT); + namingScreenData.state = MAIN_STATE_6; + return TRUE; + } + else + return FALSE; +} + +static bool8 sub_80B61C8(void) +{ + namingScreenData.state = MAIN_STATE_START_PAGE_SWAP; + return TRUE; +} + +//-------------------------------------------------- +// Input handling +//-------------------------------------------------- + +enum +{ + FNKEY_CASE, + FNKEY_BACK, + FNKEY_OK, +}; + +#define tState data[0] +#define tKeyboardEvent data[1] +#define tKbFunctionKey data[2] + +static void InputState_Disabled(struct Task *); +static void InputState_Enabled(struct Task *); + +static void (*const sInputStateFuncs[])(struct Task *) = +{ + InputState_Disabled, + InputState_Enabled, +}; + +static void Task_HandleInput(u8); +static void HandleDpadMovement(struct Task *); + +static void InputInit(void) +{ + CreateTask(Task_HandleInput, 1); +} + +static u8 GetInputEvent(void) +{ + u8 taskId = FindTaskIdByFunc(Task_HandleInput); + + return gTasks[taskId].tKeyboardEvent; +} + +static void SetInputState(u8 state) +{ + u8 taskId = FindTaskIdByFunc(Task_HandleInput); + + gTasks[taskId].tState = state; +} + +static void Task_HandleInput(u8 taskId) +{ + sInputStateFuncs[gTasks[taskId].tState](&gTasks[taskId]); +} + +static void InputState_Disabled(struct Task *task) +{ + task->tKeyboardEvent = 0; +} + +static void InputState_Enabled(struct Task *task) +{ + task->tKeyboardEvent = 0; + if (gMain.newKeys & A_BUTTON) + { + task->tKeyboardEvent = KBEVENT_PRESSED_A; + return; + } + if (gMain.newKeys & B_BUTTON) + { + task->tKeyboardEvent = KBEVENT_PRESSED_B; + return; + } + if (gMain.newKeys & SELECT_BUTTON) + { + task->tKeyboardEvent = KBEVENT_PRESSED_SELECT; + return; + } + if (gMain.newKeys & START_BUTTON) + { + task->tKeyboardEvent = KBEVENT_PRESSED_START; + MoveCursorToOKButton(); + return; + } + HandleDpadMovement(task); +} + +static const s16 sDpadDeltaX[] = +{ + 0, //none + 0, //up + 0, //down + -1, //left + 1 //right +}; + +static const s16 sDpadDeltaY[] = +{ + 0, //none + -1, //up + 1, //down + 0, //left + 0 //right +}; + +static const s16 s4RowTo3RowTableY[] = {0, 1, 1, 2}; +static const s16 gUnknown_083CE274[] = {0, 0, 3, 0}; + +static void HandleDpadMovement(struct Task *task) +{ + s16 cursorX; + s16 cursorY; + u16 dpadDir; + s16 prevCursorX; + + GetCursorPos(&cursorX, &cursorY); + dpadDir = 0; + if (gMain.newAndRepeatedKeys & DPAD_UP) + dpadDir = 1; + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + dpadDir = 2; + if (gMain.newAndRepeatedKeys & DPAD_LEFT) + dpadDir = 3; + if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + dpadDir = 4; + + //Get new cursor position + prevCursorX = cursorX; + cursorX += sDpadDeltaX[dpadDir]; + cursorY += sDpadDeltaY[dpadDir]; + + //Wrap cursor position in the X direction + if (cursorX < 0) + cursorX = COLUMN_COUNT - 1; + if (cursorX > COLUMN_COUNT - 1) + cursorX = 0; + + //Handle cursor movement in X direction + if (sDpadDeltaX[dpadDir] != 0) + { + //The "others" page only has 5 columns +#if ENGLISH + if (namingScreenData.currentPage == PAGE_OTHERS && (cursorX == 6 || cursorX == 7)) +#elif GERMAN + if (namingScreenData.currentPage == PAGE_OTHERS && (cursorX == 6 || cursorX == 7 || cursorX == 8)) +#endif + { + if (sDpadDeltaX[dpadDir] > 0) + cursorX = COLUMN_COUNT - 1; + else + cursorX = 5; + } + + if (cursorX == COLUMN_COUNT - 1) + { + //We are now on the last column + task->tKbFunctionKey = cursorY; + cursorY = s4RowTo3RowTableY[cursorY]; + } + else if (prevCursorX == COLUMN_COUNT - 1) + { + if (cursorY == 1) + cursorY = task->tKbFunctionKey; + else + cursorY = gUnknown_083CE274[cursorY]; + } + } + + if (cursorX == COLUMN_COUNT - 1) + { + //There are only 3 keys on the last column, unlike the others, + //so wrap Y accordingly + if (cursorY < 0) + cursorY = 2; + if (cursorY > 2) + cursorY = 0; + if (cursorY == 0) + task->tKbFunctionKey = FNKEY_BACK; + else if (cursorY == 2) + task->tKbFunctionKey = FNKEY_OK; + } + else + { + if (cursorY < 0) + cursorY = 3; + if (cursorY > 3) + cursorY = 0; + } + SetCursorPos(cursorX, cursorY); +} + +#undef tState +#undef tKeyboardEvent +#undef tKbFunctionKey + +//-------------------------------------------------- +// +//-------------------------------------------------- + +static void Task_80B64D4(u8); +static u16 sub_80B654C(u8); +static void sub_80B65AC(u8); +static void sub_80B65D4(struct Task *, u8, u8); + +static void sub_80B6438(void) +{ + u8 taskId; + + taskId = CreateTask(Task_80B64D4, 3); + gTasks[taskId].data[0] = 3; +} + +static void sub_80B6460(u8 a, u8 b, u8 c) +{ + struct Task *task = &gTasks[FindTaskIdByFunc(Task_80B64D4)]; + + if (a == task->data[0] && c == 0) + { + task->data[1] = b; + task->data[2] = 1; + return; + } + if (a == 3 && task->data[1] == 0 && c == 0) + return; + if (task->data[0] != 3) + sub_80B65AC(task->data[0]); + sub_80B65D4(task, a, b); +} + +static void Task_80B64D4(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + if (task->data[0] == 3 || task->data[2] == 0) + return; + MultiplyInvertedPaletteRGBComponents(sub_80B654C(task->data[0]), task->data[3], task->data[3], task->data[3]); + if (task->data[5] != 0) + { + task->data[5]--; + if (task->data[5] != 0) + return; + } + task->data[5] = 2; + task->data[3] += task->data[4]; + if (task->data[3] == 16) + task->data[4] = -task->data[4]; + else if (task->data[3] == 0) + { + task->data[2] = task->data[1]; + task->data[4] = -task->data[4]; + } +} + +static u16 sub_80B654C(u8 a) +{ + const u16 arr[] = + { + IndexOfSpritePaletteTag(4) * 16 + 0x10E, + IndexOfSpritePaletteTag(6) * 16 + 0x10C, + IndexOfSpritePaletteTag(6) * 16 + 0x10E, + }; + + return arr[a]; +} + +static void sub_80B65AC(u8 a) +{ + u16 index = sub_80B654C(a); + + gPlttBufferFaded[index] = gPlttBufferUnfaded[index]; +} + +static void sub_80B65D4(struct Task *task, u8 b, u8 c) +{ + task->data[0] = b; + task->data[1] = c; + task->data[2] = 1; + task->data[3] = 15; + task->data[4] = 1; + task->data[5] = 0; +} + +//-------------------------------------------------- +// Page Swap +//-------------------------------------------------- + +#define tState data[0] +#define tFrameCount data[1] + +static bool8 PageSwapAnimState_Init(struct Task *); +static bool8 PageSwapAnimState_1(struct Task *); +static bool8 PageSwapAnimState_2(struct Task *); +static bool8 PageSwapAnimState_Done(struct Task *); + +static bool8 (*const sPageSwapAnimStateFuncs[])(struct Task *) = +{ + PageSwapAnimState_Init, + PageSwapAnimState_1, + PageSwapAnimState_2, + PageSwapAnimState_Done, +}; + +static void StartPageSwapAnim(void) +{ + u8 taskId; + + taskId = CreateTask(Task_HandlePageSwapAnim, 0); + Task_HandlePageSwapAnim(taskId); +} + +static bool8 IsPageSwapAnimNotInProgress(void) +{ + if (FindTaskIdByFunc(Task_HandlePageSwapAnim) == 0xFF) + return TRUE; + else + return FALSE; +} + +static void Task_HandlePageSwapAnim(u8 taskId) +{ + while (sPageSwapAnimStateFuncs[gTasks[taskId].tState](&gTasks[taskId]) != 0) + ; +} + +static bool8 PageSwapAnimState_Init(struct Task *task) +{ + namingScreenData.bg1vOffset = 0; + namingScreenData.bg2vOffset = 0; + task->tState++; + return 0; +} + +static bool8 PageSwapAnimState_1(struct Task *task) +{ + u16 *const arr[] = + { + &namingScreenData.bg2vOffset, + &namingScreenData.bg1vOffset + }; + + task->tFrameCount += 4; + *arr[namingScreenData.unkC] = Sin(task->tFrameCount, 40); + *arr[namingScreenData.unkD] = Sin((task->tFrameCount + 128) & 0xFF, 40); + if (task->tFrameCount >= 64) + { + u8 temp = namingScreenData.unk8; //Why u8 and not u16? + + namingScreenData.unk8 = namingScreenData.unkA; + namingScreenData.unkA = temp; + task->tState++; + } + return 0; +} + +static bool8 PageSwapAnimState_2(struct Task *task) +{ + u16 *const arr[] = {&namingScreenData.bg2vOffset, &namingScreenData.bg1vOffset}; + + task->tFrameCount += 4; + *arr[namingScreenData.unkC] = Sin(task->tFrameCount, 40); + *arr[namingScreenData.unkD] = Sin((task->tFrameCount + 128) & 0xFF, 40); + if (task->tFrameCount >= 128) + { + u8 temp = namingScreenData.unkC; + + namingScreenData.unkC = namingScreenData.unkD; + namingScreenData.unkD = temp; + task->tState++; + } + return 0; +} + +static bool8 PageSwapAnimState_Done(struct Task *task) +{ + DestroyTask(FindTaskIdByFunc(Task_HandlePageSwapAnim)); + return 0; +} + +#undef tState +#undef tFrameCount + +//-------------------------------------------------- +// Cursor +//-------------------------------------------------- + +static void CursorInit(void) +{ + namingScreenData.cursorSpriteId = CreateSprite(&gSpriteTemplate_83CE640, 0, 0, 0); + gSprites[namingScreenData.cursorSpriteId].oam.priority = 1; + gSprites[namingScreenData.cursorSpriteId].oam.objMode = 1; + gSprites[namingScreenData.cursorSpriteId].data6 = 1; + gSprites[namingScreenData.cursorSpriteId].data6 = 2; + SetCursorPos(0, 0); +} + +static const u8 sKeyboardSymbolPositions[][COLUMN_COUNT] = { +#if ENGLISH + {1, 3, 5, 8, 10, 12, 14, 17, 19}, //Upper page + {1, 3, 5, 8, 10, 12, 14, 17, 19}, //Lower page + {1, 4, 7, 10, 13, 16, 16, 16, 19}, //Others page +#elif GERMAN + {2, 3, 4, 5, 9, 10, 11, 12, 16, 19}, //Upper page + {2, 3, 4, 5, 9, 10, 11, 12, 16, 19}, //Lower page + {1, 4, 7, 10, 13, 16, 16, 16, 16, 19}, //Others page +#endif +}; + +static u8 CursorColToKeyboardCol(s16 x) +{ + return sKeyboardSymbolPositions[namingScreenData.currentPage][x]; +} + +static void SetCursorPos(s16 x, s16 y) +{ + struct Sprite *cursorSprite = &gSprites[namingScreenData.cursorSpriteId]; + + cursorSprite->pos1.x = CursorColToKeyboardCol(x) * 8 + 27; + cursorSprite->pos1.y = y * 16 + 80; + cursorSprite->data2 = cursorSprite->data0; + cursorSprite->data3 = cursorSprite->data1; + cursorSprite->data0 = x; + cursorSprite->data1 = y; +} + +static void GetCursorPos(s16 *x, s16 *y) +{ + struct Sprite *cursorSprite = &gSprites[namingScreenData.cursorSpriteId]; + + *x = cursorSprite->data0; + *y = cursorSprite->data1; +} + +static void MoveCursorToOKButton(void) +{ + SetCursorPos(COLUMN_COUNT - 1, 2); +} + +static void sub_80B6888(u8 a) +{ + gSprites[namingScreenData.cursorSpriteId].data4 &= -256; + gSprites[namingScreenData.cursorSpriteId].data4 |= a; + StartSpriteAnim(&gSprites[namingScreenData.cursorSpriteId], 0); +} + +static void sub_80B68D8(u8 a) +{ + gSprites[namingScreenData.cursorSpriteId].data4 &= 0xFF; + gSprites[namingScreenData.cursorSpriteId].data4 |= a << 8; +} + +static void sub_80B6914(void) +{ + StartSpriteAnim(&gSprites[namingScreenData.cursorSpriteId], 1); +} + +static bool8 IsCursorAnimFinished(void) +{ + return gSprites[namingScreenData.cursorSpriteId].animEnded; +} + +static u8 GetKeyRoleAtCursorPos(void) +{ + const u8 keyRoles[] = {KEY_ROLE_PAGE, KEY_ROLE_BACKSPACE, KEY_ROLE_OK}; + s16 cursorX; + s16 cursorY; + + GetCursorPos(&cursorX, &cursorY); + if (cursorX < COLUMN_COUNT - 1) + return KEY_ROLE_CHAR; + else + return keyRoles[cursorY]; +} + +void sub_80B6998(struct Sprite *sprite) +{ + if (sprite->animEnded) + StartSpriteAnim(sprite, 0); + sprite->invisible = (sprite->data4 & 0xFF); + if (sprite->data0 == COLUMN_COUNT - 1) + sprite->invisible = TRUE; + if (sprite->invisible || (sprite->data4 & 0xFF00) == 0 + || sprite->data0 != sprite->data2 || sprite->data1 != sprite->data3) + { + sprite->data5 = 0; + sprite->data6 = 1; + sprite->data7 = 2; + } + sprite->data7--; + if (sprite->data7 == 0) + { + sprite->data5 += sprite->data6; + if (sprite->data5 == 16 || sprite->data5 == 0) + sprite->data6 = -sprite->data6; + sprite->data7 = 2; + } + if ((sprite->data4 & 0xFF00) != 0) + { + s8 gb = sprite->data5; + s8 r = sprite->data5 >> 1; + u16 index = IndexOfSpritePaletteTag(5) * 16 + 0x0101; + + MultiplyInvertedPaletteRGBComponents(index, r, gb, gb); + } +} + +static void sub_80B6A80(void) +{ + u8 spriteId1; + u8 spriteId2; + u8 spriteId3; + + spriteId1 = CreateSprite(&gSpriteTemplate_83CE5C8, 0xCC, 0x50, 0); + namingScreenData.unk10 = spriteId1; + SetSubspriteTables(&gSprites[spriteId1], gSubspriteTables_83CE558); + + spriteId2 = CreateSprite(&gSpriteTemplate_83CE5F8, 0xCC, 0x4C, 1); + gSprites[spriteId1].data6 = spriteId2; + SetSubspriteTables(&gSprites[spriteId2], gSubspriteTables_83CE560); + + spriteId3 = CreateSprite(&gSpriteTemplate_83CE5E0, 0xCC, 0x4B, 2); + gSprites[spriteId3].oam.priority = 1; + gSprites[spriteId1].data7 = spriteId3; +} + +static void sub_80B6B14(void) +{ + struct Sprite *sprite = &gSprites[namingScreenData.unk10]; + + sprite->data0 = 2; + sprite->data1 = namingScreenData.currentPage; +} + +static u8 sub_80B6B5C(struct Sprite *); +static u8 sub_80B6B98(struct Sprite *); +static u8 sub_80B6B9C(struct Sprite *); +static u8 sub_80B6C08(struct Sprite *); + +static u8 (*const gUnknown_083CE2B4[])(struct Sprite *) = +{ + sub_80B6B5C, + sub_80B6B98, + sub_80B6B9C, + sub_80B6C08, +}; + +void sub_80B6B34(struct Sprite *sprite) +{ + while (gUnknown_083CE2B4[sprite->data0](sprite) != 0) + ; +} + +static u8 sub_80B6B5C(struct Sprite *sprite) +{ + struct Sprite *sprite1 = &gSprites[sprite->data6]; + struct Sprite *sprite2 = &gSprites[sprite->data7]; + + sub_80B6C48(namingScreenData.currentPage, sprite1, sprite2); + sprite->data0++; + return 0; +} + +static u8 sub_80B6B98(struct Sprite *sprite) +{ + return 0; +} + +static u8 sub_80B6B9C(struct Sprite *sprite) +{ + struct Sprite *r4 = &gSprites[sprite->data6]; + struct Sprite *r5 = &gSprites[sprite->data7]; + + r4->pos2.y++; + if (r4->pos2.y > 7) + { + sprite->data0++; + r4->pos2.y = -4; + r4->invisible = TRUE; + sub_80B6C48(((u8)sprite->data1 + 1) % 3, r4, r5); + } + return 0; +} + +static u8 sub_80B6C08(struct Sprite *sprite) +{ + struct Sprite *r2 = &gSprites[sprite->data6]; + + r2->invisible = FALSE; + r2->pos2.y++; + if (r2->pos2.y >= 0) + { + r2->pos2.y = 0; + sprite->data0 = 1; + } + return 0; +} + +static const u16 gUnknown_083CE2C4[] = {1, 3, 2}; +static const u16 gUnknown_083CE2CA[] = {4, 6, 5}; + +static void sub_80B6C48(u8 a, struct Sprite *b, struct Sprite *c) +{ + c->oam.paletteNum = IndexOfSpritePaletteTag(gUnknown_083CE2C4[a]); + b->sheetTileStart = GetSpriteTileStartByTag(gUnknown_083CE2CA[a]); + b->subspriteTableNum = a; +} + +// + +static void sub_80B6CA8(void) +{ + u8 spriteId; + + spriteId = CreateSprite(&gSpriteTemplate_83CE610, 0xCC, 0x6C, 0); + SetSubspriteTables(&gSprites[spriteId], gSubspriteTables_83CE578); + + spriteId = CreateSprite(&gSpriteTemplate_83CE628, 0xCC, 0x84, 0); + SetSubspriteTables(&gSprites[spriteId], gSubspriteTables_83CE578); +} + +static void sub_80B6D04(void) +{ + u8 spriteId; + s16 r1; + u8 i; + + r1 = (namingScreenData.unk2 - 1) * 8 + 4; + spriteId = CreateSprite(&gSpriteTemplate_83CE658, r1, 0x28, 0); + gSprites[spriteId].oam.priority = 3; + r1 = namingScreenData.unk2 * 8 + 4; + for (i = 0; i < namingScreenData.template->maxChars; i++, r1 += 8) + { + spriteId = CreateSprite(&gSpriteTemplate_83CE670, r1, 0x2C, 0); + gSprites[spriteId].oam.priority = 3; + gSprites[spriteId].data0 = i; + } +} + +void sub_80B6D9C(struct Sprite *sprite) +{ + const s16 arr[] = {0, -4, -2, -1}; + + if (sprite->data0 == 0 || --sprite->data0 == 0) + { + sprite->data0 = 8; + sprite->data1 = (sprite->data1 + 1) & 3; + } + sprite->pos2.x = arr[sprite->data1]; +} + +void sub_80B6DE8(struct Sprite *sprite) +{ + const s16 arr[] = {2, 3, 2, 1}; + u8 var; + + var = GetTextCaretPosition(); + if (var != (u8)sprite->data0) + { + sprite->pos2.y = 0; + sprite->data1 = 0; + sprite->data2 = 0; + } + else + { + sprite->pos2.y = arr[sprite->data1]; + sprite->data2++; + if (sprite->data2 > 8) + { + sprite->data1 = (sprite->data1 + 1) & 3; + sprite->data2 = 0; + } + } +} + +// + +static void nullsub_40(void); +static void sub_80B6E68(void); +static void sub_80B6EBC(void); +static void sub_80B6EFC(void); + +static void (*const gUnknown_083CE2E0[])(void) = +{ + nullsub_40, + sub_80B6E68, + sub_80B6EBC, + sub_80B6EFC, +}; + +static void sub_80B6E44(void) +{ + gUnknown_083CE2E0[namingScreenData.template->unk2](); +} + +static void nullsub_40(void) +{ +} + +static void sub_80B6E68(void) +{ + u8 rivalGfxId; + u8 spriteId; + + rivalGfxId = GetRivalAvatarGraphicsIdByStateIdAndGender(0, namingScreenData.unk3E); + spriteId = AddPseudoFieldObject(rivalGfxId, SpriteCallbackDummy, 0x38, 0x18, 0); + gSprites[spriteId].oam.priority = 3; + StartSpriteAnim(&gSprites[spriteId], 4); +} + +static void sub_80B6EBC(void) +{ + u8 spriteId; + + spriteId = CreateSprite(&gSpriteTemplate_83CE688, 0x34, 0x18, 0); + SetSubspriteTables(&gSprites[spriteId], gSubspriteTables_83CE580); + gSprites[spriteId].oam.priority = 3; +} + +static void sub_80B6EFC(void) +{ + u8 spriteId; + + sub_809D51C(); + spriteId = CreateMonIcon(namingScreenData.unk3E, SpriteCallbackDummy, 0x34, 0x18, 0, namingScreenData.unk42); + gSprites[spriteId].oam.priority = 3; +} + +static u8 GetTextCaretPosition(void) +{ + u8 i; + + for (i = 0; i < namingScreenData.template->maxChars; i++) + { + if (namingScreenData.textBuffer[i] == EOS) + return i; + } + return namingScreenData.template->maxChars - 1; +} + +static u8 GetPreviousTextCaretPosition(void) +{ + s8 i; + + for (i = namingScreenData.template->maxChars - 1; i > 0; i--) + { + if (namingScreenData.textBuffer[i] != EOS) + return i; + } + return 0; +} + +static void DeleteTextCharacter(void) +{ + u8 index; + u8 var2; + + index = GetPreviousTextCaretPosition(); + namingScreenData.textBuffer[index] = 0; + sub_80B7960(); + namingScreenData.textBuffer[index] = EOS; + var2 = GetKeyRoleAtCursorPos(); + if (var2 == 0 || var2 == 2) + sub_80B6460(1, 0, 1); + PlaySE(SE_BOWA); +} + +static bool8 sub_80B7004(void) +{ + s16 x; + s16 y; + u8 ch; + bool8 r4; + + GetCursorPos(&x, &y); + x = CursorColToKeyboardCol(x); + ch = GetCharAtKeyboardPos(x, y); + r4 = 1; + if (ch == 0xFF) + r4 = sub_80B7104(); + else if (ch == 0xFE) + r4 = sub_80B713C(); + else + AddTextCharacter(ch); + sub_80B7960(); + PlaySE(SE_SELECT); + if (r4) + { + if (GetPreviousTextCaretPosition() == namingScreenData.template->maxChars - 1) + return TRUE; + } + return FALSE; +} + +static void sub_80B7090(void) // DoInput? +{ + u8 r5; + u8 r4; + + r5 = GetPreviousTextCaretPosition(); + r4 = namingScreenData.textBuffer[r5]; + if (sub_80B7198(r4)) + { + if (sub_80B7264(r4)) + sub_80B7370(r4, r5); + else + sub_80B73CC(r4, r5); + } + else + { + if (sub_80B71E4(r4)) + sub_80B7474(r4, r5); + else + sub_80B72A4(r4, r5); + } + sub_80B7960(); + PlaySE(SE_SELECT); +} + +static bool8 sub_80B7104(void) +{ + u8 r5; + u8 r4; + + r5 = GetPreviousTextCaretPosition(); + r4 = namingScreenData.textBuffer[r5]; + if (sub_80B720C(r4)) + { + sub_80B72A4(r4, r5); + return TRUE; + } + return FALSE; +} + +static bool8 sub_80B713C(void) +{ + u8 r5; + u8 r4; + + r5 = GetPreviousTextCaretPosition(); + r4 = namingScreenData.textBuffer[r5]; + if (sub_80B7264(r4)) + { + sub_80B7370(r4, r5); + return TRUE; + } + return FALSE; +} + +static void AddTextCharacter(u8 ch) +{ + u8 index = GetTextCaretPosition(); + + namingScreenData.textBuffer[index] = ch; +} + +static bool8 sub_80B7198(u8 a) +{ + if ((a >= 55 && a <= 74) + || (a >= 135 && a <= 139) + || (a >= 140 && a <= 144) + || (a >= 145 && a <= 149) + || (a >= 150 && a <= 154)) + return TRUE; + else + return FALSE; +} + +static bool8 sub_80B71E4(u8 a) +{ + if ((a >= 75 && a <= 79) + || (a >= 155 && a <= 159)) + return TRUE; + else + return FALSE; +} + +static bool8 sub_80B720C(u8 a) +{ + if ((a >= 6 && a <= 20) + || (a >= 26 && a <= 30) + || (a >= 75 && a <= 79) + || (a >= 86 && a <= 100) + || (a >= 106 && a <= 110) + || (a >= 155 && a <= 159)) + return TRUE; + else + return FALSE; +} + +static bool8 sub_80B7264(u8 a) +{ + if ((a >= 26 && a <= 30) + || (a >= 70 && a <= 74) + || (a >= 106 && a <= 110) + || (a >= 150 && a <= 154)) + return TRUE; + else + return FALSE; +} + +static void sub_80B72A4(u8 a, u8 b) +{ + u8 chr = a; + + if (a >= 6 && a <= 10) + chr = a + 0x31; + else if (a >= 11 && a <= 15) + chr = a + 0x31; + else if (a >= 16 && a <= 20) + chr = a + 0x31; + else if (a >= 26 && a <= 30) + chr = a + 0x2C; + else if (a >= 75 && a <= 79) + chr = a + 0xFB; + else if (a >= 86 && a <= 90) + chr = a + 0x31; + else if (a >= 91 && a <= 95) + chr = a + 0x31; + else if (a >= 96 && a <= 100) + chr = a + 0x31; + else if (a >= 106 && a <= 110) + chr = a + 0x2C; + else if (a >= 155 && a <= 159) + chr = a + 0xFB; + namingScreenData.textBuffer[b] = chr; +} + +static void sub_80B7370(u8 a, u8 b) +{ + u8 chr = a; + + if (a >= 26 && a <= 30) + chr = a + 0x31; + else if (a >= 70 && a <= 74) + chr = a + 5; + else if (a >= 106 && a <= 110) + chr = a + 0x31; + else if (a >= 150 && a <= 154) + chr = a + 5; + namingScreenData.textBuffer[b] = chr; +} + +static void sub_80B73CC(u8 a, u8 b) +{ + u8 chr = a; + + if (a >= 55 && a <= 59) + chr = a + 0xCF; + else if (a >= 60 && a <= 64) + chr = a + 0xCF; + else if (a >= 65 && a <= 69) + chr = a + 0xCF; + else if (a >= 70 && a <= 74) + chr = a + 0xD4; + else if (a >= 135 && a <= 139) + chr = a + 0xCF; + else if (a >= 140 && a <= 144) + chr = a + 0xCF; + else if (a >= 145 && a <= 149) + chr = a + 0xCF; + else if (a >= 150 && a <= 154) + chr = a + 0xD4; + namingScreenData.textBuffer[b] = chr; +} + +static void sub_80B7474(u8 a, u8 b) +{ + u8 chr = a; + + if (a >= 75 && a <= 79) + chr = a + 0xCF; + else if (a >= 155 && a <= 159) + chr = a + 0xCF; + namingScreenData.textBuffer[b] = chr; +} + +static void sub_80B74B0(void) +{ + u8 i; + + for (i = 0; i < namingScreenData.template->maxChars; i++) + { + if (namingScreenData.textBuffer[i] != 0 && namingScreenData.textBuffer[i] != 0xFF) + { + StringCopyN(namingScreenData.destBuffer, namingScreenData.textBuffer, namingScreenData.template->maxChars + 1); + break; + } + } +} + +static void DisplaySentToPCMessage(void) +{ + StringCopy(gStringVar1, namingScreenData.destBuffer); + StringExpandPlaceholders(gStringVar4, gOtherText_SentToPC); + BasicInitMenuWindow(&gWindowConfig_81E6E88); + MenuDisplayMessageBox(); + sub_8072044(gStringVar4); +} + +static void sub_80B753C(void) +{ + LoadSpriteSheets(gUnknown_083CE6A0); + LoadSpritePalettes(gUnknown_083CE708); +} + +static void sub_80B7558(void) +{ + sub_80B7568(); + sub_80B75B0(); +} + +static void sub_80B7568(void) +{ + const void *src; + void *dst; + + src = gNamingScreenMenu_Gfx; + dst = (void *)(VRAM + gMenuMessageBoxContentTileOffset * 32); + DmaCopy16(3, src, dst, 0x800); + + src = gNamingScreenMenu_Gfx; + dst = (void *)(VRAM + 0x8000 + gMenuMessageBoxContentTileOffset * 32); + DmaCopy16(3, src, dst, 0x800); +} + +static void sub_80B75B0(void) +{ + LoadPalette(gNamingScreenPalettes, 0, 0x80); +} + +static void sub_80B7650(u16 *); +static void sub_80B7660(u16 *); +static void sub_80B7670(u16 *); + +static void (*const gUnknown_083CE2F0[][2])(u16 *) = +{ + {sub_80B7660, sub_80B7650}, + {sub_80B7650, sub_80B7670}, + {sub_80B7670, sub_80B7660}, +}; + +static void sub_80B75C4(void) +{ + u16 *const arr[] = + { + (u16 *)(VRAM + 0xE000), + (u16 *)(VRAM + 0xE800), + }; + + gUnknown_083CE2F0[namingScreenData.currentPage][0](arr[namingScreenData.unkC]); + gUnknown_083CE2F0[namingScreenData.currentPage][1](arr[namingScreenData.unkD]); +} + +static void sub_80B7614(void) +{ + u16 *const arr[] = + { + (u16 *)(VRAM + 0xE000), + (u16 *)(VRAM + 0xE800), + }; + + gUnknown_083CE2F0[namingScreenData.currentPage][1](arr[namingScreenData.unkD]); +} + +static void sub_80B7650(u16 *vramBuffer) +{ + sub_80B7698(vramBuffer, gUnknown_083CE748); +} + +static void sub_80B7660(u16 *vramBuffer) +{ + sub_80B7698(vramBuffer, gUnknown_083CEBF8); +} + +static void sub_80B7670(u16 *vramBuffer) +{ + sub_80B7698(vramBuffer, gUnknown_083CF0A8); +} + +static void sub_80B7680(void) +{ + sub_80B76E0(VRAM + 0xF000, gUnknown_08E86258); +} + +static void sub_80B7698(u16 *vramBuffer, const u16 *src) +{ + s16 i; + s16 j; + + for (i = 0; i < 20; i++) + { + for (j = 0; j < 30; j++, src++) + { + vramBuffer[i * 32 + j] = *src + gMenuMessageBoxContentTileOffset; + } + } +} + +static void sub_80B76E0(u16 *vramBuffer, const u16 *src) +{ + s16 i; + s16 j; + + for (i = 0; i < 20; i++) + { + for (j = 0; j < 30; j++, src++) + { + vramBuffer[i * 32 + j] = *src + gMenuMessageBoxContentTileOffset; + } + src += 2; + } +} + +static void sub_80B772C(void) +{ + nullsub_20(namingScreenData.currentPage, namingScreenData.unkC); +} + +static void sub_80B7740(void) +{ + nullsub_20((namingScreenData.currentPage + 1) % 3, namingScreenData.unkD); +} + +static void nullsub_20(u8 a, u8 b) +{ +} + +static void sub_80B7838(void); +static void sub_80B7844(void); +static void sub_80B7850(void); + +static void (*const gUnknown_083CE310[][2])(void) = +{ + sub_80B7844, + sub_80B7838, + sub_80B7838, + sub_80B7850, + sub_80B7850, + sub_80B7844, +}; + +static const struct WindowConfig *const gUnknown_083CE328[][2][2] = +{ + { + {&gWindowConfig_81E6EDC, &gWindowConfig_81E6EF8}, + {&gWindowConfig_81E6EA4, &gWindowConfig_81E6EC0}, + }, + { + {&gWindowConfig_81E6EA4, &gWindowConfig_81E6EC0}, + {&gWindowConfig_81E6F14, &gWindowConfig_81E6F30}, + }, + { + {&gWindowConfig_81E6F14, &gWindowConfig_81E6F30}, + {&gWindowConfig_81E6EDC, &gWindowConfig_81E6EF8}, + }, +}; + +static void nullsub_61(void); +static void sub_80B78F8(void); + +static void (*const gUnknown_083CE358[])(void) = +{ + nullsub_61, + nullsub_61, + sub_80B78F8, + sub_80B78F8, +}; + +static void nullsub_62(void); +static void sub_80B7924(void); + +static void (*const gUnknown_083CE368[])(void) = +{ + nullsub_62, + sub_80B7924, +}; + +static const u8 sKeyboardCharacters[][4][20]; //forward declaration + +static u8 GetCharAtKeyboardPos(s16 a, s16 b) +{ + return sKeyboardCharacters[namingScreenData.currentPage][b][a]; +} + +static void sub_80B7794(void) +{ + BasicInitMenuWindow(gUnknown_083CE328[namingScreenData.currentPage][0][namingScreenData.unkC]); + gUnknown_083CE310[namingScreenData.currentPage][0](); + BasicInitMenuWindow(gUnknown_083CE328[namingScreenData.currentPage][1][namingScreenData.unkD]); + gUnknown_083CE310[namingScreenData.currentPage][1](); + sub_80B772C(); + sub_80B7740(); +} + +static void sub_80B77F8(void) +{ + BasicInitMenuWindow(gUnknown_083CE328[namingScreenData.currentPage][1][namingScreenData.unkD]); + gUnknown_083CE310[namingScreenData.currentPage][1](); + sub_80B7740(); +} + +static void sub_80B7838(void) +{ + PrintKeyboardCharacters(1); +} + +static void sub_80B7844(void) +{ + PrintKeyboardCharacters(0); +} + +static void sub_80B7850(void) +{ + PrintKeyboardCharacters(2); +} + +static void PrintKeyboardCharacters(u8 page) //print letters on page +{ + s16 i; + s16 r5; + + for (i = 0, r5 = 9; i < 4; i++, r5 += 2) + MenuPrint(sKeyboardCharacters[page][i], 3, r5); +} + +static void sub_80B78A8(void) +{ + BasicInitMenuWindow(&gWindowConfig_81E6F4C); + gUnknown_083CE358[namingScreenData.templateNum](); + gUnknown_083CE368[namingScreenData.template->unk3](); + MenuPrint(namingScreenData.template->title, 9, 2); +} + +static void nullsub_61(void) +{ +} + +static void sub_80B78F8(void) +{ + StringCopy(gStringVar1, gSpeciesNames[(s16)namingScreenData.unk3E]); +} + +static void nullsub_62(void) +{ +} + +static void sub_80B7924(void) +{ + u8 genderSymbol[2] = _("♂"); + + if ((s16)namingScreenData.unk40 != MON_GENDERLESS) + { + if ((s16)namingScreenData.unk40 == MON_FEMALE) + genderSymbol[0] = 0xB6; //female symbol + MenuPrint(genderSymbol, 0x14, 4); + } +} + +static void sub_80B7960(void) +{ + u8 *string = gStringVar1; + + string[0] = 0xFC; + string[1] = 0x14; + string[2] = 8; + string[3] = 0xFC; + string[4] = 0x11; + string[5] = 1; + string += 6; + StringCopy(string, namingScreenData.textBuffer); + BasicInitMenuWindow(&gWindowConfig_81E6F4C); + MenuPrint(gStringVar1, namingScreenData.unk2, 4); +} + +//-------------------------------------------------- +// Forward-declared variables +//-------------------------------------------------- + +static const struct NamingScreenTemplate playerNamingScreenTemplate = +{ + .unk0 = 0, + .maxChars = 7, + .unk2 = 1, + .unk3 = 0, + .unk4 = 0, + .unk5 = 0, + .unk6 = 0, + .unk7 = 0, + .title = OtherText_YourName, +}; + +static const struct NamingScreenTemplate pcBoxNamingTemplate = +{ + .unk0 = 0, + .maxChars = 8, + .unk2 = 2, + .unk3 = 0, + .unk4 = 0, + .unk5 = 0, + .unk6 = 0, + .unk7 = 0, + .title = OtherText_BoxName, +}; + +static const struct NamingScreenTemplate monNamingScreenTemplate = +{ + .unk0 = 0, + .maxChars = 10, + .unk2 = 3, + .unk3 = 1, + .unk4 = 0, + .unk5 = 0, + .unk6 = 0, + .unk7 = 0, + .title = OtherText_PokeName, +}; + +static const struct NamingScreenTemplate *const sNamingScreenTemplates[] = +{ + &playerNamingScreenTemplate, + &pcBoxNamingTemplate, + &monNamingScreenTemplate, + &monNamingScreenTemplate, +}; + +static const u8 sKeyboardCharacters[][4][20] = +{ +#if ENGLISH + { + _(" A B C D E F . "), + _(" G H I J K L , "), + _(" M N O P Q R S "), + _(" T U V W X Y Z "), + }, + { + _(" a b c d e f . "), + _(" g h i j k l , "), + _(" m n o p q r s "), + _(" t u v w x y z "), + }, +#elif GERMAN + { + _(" ABCD EFGH . "), + _(" IJKL MNOP , "), + _(" QRST UVWX "), + _(" YZ ÄÖÜ "), + }, + { + _(" abcd efgh . "), + _(" ijkl mnop , "), + _(" qrst uvwx "), + _(" yz äöü "), + }, +#endif + { + _(" 0 1 2 3 4 "), + _(" 5 6 7 8 9 "), + _(" ! ? ♂ ♀ / - "), + _(" … “ ” ‘ ’ "), + }, +}; + +const struct OamData gOamData_83CE498 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +const struct OamData gOamData_83CE4A0 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +const struct OamData gOamData_83CE4A8 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 2, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +//TODO: dump sprite data diff --git a/src/new_game.c b/src/new_game.c index d63e50236..33aacd10a 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -1,45 +1,70 @@ #include "global.h" #include "new_game.h" -#include "asm.h" +#include "battle_records.h" #include "berry.h" +#include "contest.h" +#include "decoration_inventory.h" +#include "dewford_trend.h" +#include "easy_chat.h" +#include "event_data.h" +#include "field_specials.h" +#include "item_menu.h" +#include "lottery_corner.h" +#include "mail_data.h" +#include "mauville_old_man.h" #include "play_time.h" -#include "pokemon_size_record.h" -#include "script.h" -#include "rom4.h" +#include "player_pc.h" +#include "pokeblock.h" #include "pokedex.h" -#include "lottery_corner.h" +#include "pokemon_size_record.h" +#include "pokemon_storage_system.h" #include "rng.h" +#include "roamer.h" +#include "rom4.h" #include "rtc.h" +#include "script.h" +#include "secret_base.h" +#include "tv.h" -extern u8 gUnknown_020297EC; +extern u8 gDifferentSaveFile; extern u8 gPlayerPartyCount; extern u8 gUnknown_03005CE8; extern u16 gSaveFileStatus; extern u8 gUnknown_0819FA81[]; -extern const struct SB1_2EFC_Struct gUnknown_08216604; -void write_word_to_mem(u32 a1, u8 *a2) +const struct SB1_2EFC_Struct gUnknown_08216604 = +{ + 0x0000, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + } +}; + +void write_word_to_mem(u32 var, u8 *dataPtr) { - a2[0] = a1; - a2[1] = a1 >> 8; - a2[2] = a1 >> 16; - a2[3] = a1 >> 24; + dataPtr[0] = var; + dataPtr[1] = var >> 8; + dataPtr[2] = var >> 16; + dataPtr[3] = var >> 24; } -void sub_8052D10(u8 *a1, u8 *a2) +void copy_word_to_mem(u8 *copyTo, u8 *copyFrom) { s32 i; for (i = 0; i < 4; i++) - a1[i] = a2[i]; + copyTo[i] = copyFrom[i]; } -void set_player_trainer_id(void) +void InitPlayerTrainerId(void) { write_word_to_mem((Random() << 16) | Random(), gSaveBlock2.playerTrainerId); } +// L=A isnt set here for some reason. void SetDefaultOptions(void) { gSaveBlock2.optionsTextSpeed = OPTIONS_TEXT_SPEED_MID; @@ -50,7 +75,7 @@ void SetDefaultOptions(void) gSaveBlock2.regionMapZoom = FALSE; } -void sub_8052D78(void) +void ClearPokedexFlags(void) { gUnknown_03005CE8 = 0; memset(&gSaveBlock2.pokedex.owned, 0, sizeof(gSaveBlock2.pokedex.owned)); @@ -60,9 +85,10 @@ void sub_8052D78(void) void sub_8052DA8(void) { s32 i; + sub_80B2D1C(); for (i = 0; i < 5; i++) - gSaveBlock1.sb1_2EFC_struct[i] = gUnknown_08216604; + gSaveBlock1.sbStruct.unkSB1.sb1_2EFC_struct[i] = gUnknown_08216604; } void sub_8052DE4(void) @@ -70,7 +96,7 @@ void sub_8052DE4(void) CpuFill32(0, &gSaveBlock2.filler_A8, sizeof(gSaveBlock2.filler_A8)); } -void sub_8052E04(void) +void WarpToTruck(void) { warp1_set(25, 40, -1, -1, -1); // inside of truck warp_in(); @@ -84,7 +110,7 @@ void ClearSav2(void) void sub_8052E4C(void) { - gUnknown_020297EC = 0; + gDifferentSaveFile = 0; sub_808C0A0(); ZeroPlayerPartyMons(); ZeroEnemyPartyMons(); @@ -93,46 +119,47 @@ void sub_8052E4C(void) void NewGameInitData(void) { - if (!gSaveFileStatus || gSaveFileStatus == 2) + if (gSaveFileStatus == 0 || gSaveFileStatus == 2) RtcReset(); - gUnknown_020297EC = 1; + + gDifferentSaveFile = 1; ZeroPlayerPartyMons(); ZeroEnemyPartyMons(); - sub_808C02C(); + ResetPokedex(); sub_8052DE4(); memset(&gSaveBlock1, 0, sizeof(gSaveBlock1)); - sub_80A2B18(); + ClearMailData(); gSaveBlock2.specialSaveWarp = 0; - set_player_trainer_id(); + InitPlayerTrainerId(); PlayTimeCounter_Reset(); - sub_8052D78(); - sub_8069030(); - sub_80BD7A8(); - sub_80BDAB4(); - sub_80BB5B4(); - sub_80B4A90(); + ClearPokedexFlags(); + InitEventData(); + ClearTVShowData(); + ResetGabbyAndTy(); + ResetSecretBases(); + ClearBerryTrees(); gSaveBlock1.money = 3000; - sub_80AB1B0(); - sub_80530AC(); + ResetLinkContestBoolean(); + ResetGameStats(); sub_8052DA8(); InitLinkBattleRecords(); InitShroomishSizeRecord(); InitBarboachSizeRecord(); gPlayerPartyCount = 0; ZeroPlayerPartyMons(); - sub_80961D8(); - sub_81341F8(); - sub_813420C(); + ResetPokemonStorageSystem(); + ClearRoamerData(); + ClearRoamerLocationData(); gSaveBlock1.registeredItem = 0; - sub_80A3714(); + ClearBag(); NewGameInitPCItems(); - sub_810C994(); - sub_8133F80(); - sub_80E6764(); - sub_80F7AA4(); - sub_80FA17C(); - sub_810FA54(); - sub_8145A78(); - sub_8052E04(); + ClearPokeblocks(); + ClearDecorationInventories(); + InitEasyChatPhrases(); + SetMauvilleOldMan(); + InitDewfordTrend(); + ResetFanClub(); + ResetLotteryCorner(); + WarpToTruck(); ScriptContext2_RunNewScript(gUnknown_0819FA81); } diff --git a/src/option_menu.c b/src/option_menu.c index 6d6310b46..2463b11c6 100644 --- a/src/option_menu.c +++ b/src/option_menu.c @@ -4,6 +4,7 @@ #include "menu.h" #include "palette.h" #include "sprite.h" +#include "strings2.h" #include "task.h" extern void SetPokemonCryStereo(u32 val); @@ -33,28 +34,6 @@ enum { extern u8 gUnknown_0839F63C[]; extern u8 gUnknown_0839F5FC[]; //palette -extern u8 gSystemText_Normal[]; -extern u8 gSystemText_LR[]; -extern u8 gSystemText_LA[]; -extern u8 gSystemText_Terminator[]; -extern u8 gSystemText_Type[]; -extern u8 gSystemText_Mono[]; -extern u8 gSystemText_Stereo[]; -extern u8 gSystemText_Shift[]; -extern u8 gSystemText_Set[]; -extern u8 gSystemText_On[]; -extern u8 gSystemText_Off[]; -extern u8 gSystemText_Slow[]; -extern u8 gSystemText_Mid[]; -extern u8 gSystemText_Fast[]; -extern u8 gSystemText_OptionMenu[]; -extern u8 gSystemText_TextSpeed[]; -extern u8 gSystemText_BattleScene[]; -extern u8 gSystemText_BattleStyle[]; -extern u8 gSystemText_Sound[]; -extern u8 gSystemText_ButtonMode[]; -extern u8 gSystemText_Frame[]; -extern u8 gSystemText_Cancel[]; static void Task_OptionMenuFadeIn(u8 taskId); static void Task_OptionMenuProcessInput(u8 taskId); @@ -91,143 +70,143 @@ static void VBlankCB(void) void CB2_InitOptionMenu(void) { - switch(gMain.state) + switch (gMain.state) { - default: - case 0: + default: + case 0: + { + u8 *addr; + u32 size; + + SetVBlankCallback(NULL); + REG_DISPCNT = 0; + REG_BG2CNT = 0; + REG_BG1CNT = 0; + REG_BG0CNT = 0; + REG_BG2HOFS = 0; + REG_BG2VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + addr = (u8 *)VRAM; + size = 0x18000; + while (1) { - u8 *addr; - u32 size; - - SetVBlankCallback(NULL); - REG_DISPCNT = 0; - REG_BG2CNT = 0; - REG_BG1CNT = 0; - REG_BG0CNT = 0; - REG_BG2HOFS = 0; - REG_BG2VOFS = 0; - REG_BG1HOFS = 0; - REG_BG1VOFS = 0; - REG_BG0HOFS = 0; - REG_BG0VOFS = 0; - addr = (u8 *)VRAM; - size = 0x18000; - while(1) + DmaFill16(3, 0, addr, 0x1000); + addr += 0x1000; + size -= 0x1000; + if (size <= 0x1000) { - DmaFill16(3, 0, addr, 0x1000); - addr += 0x1000; - size -= 0x1000; - if(size <= 0x1000) - { - DmaFill16(3, 0, addr, size); - break; - } + DmaFill16(3, 0, addr, size); + break; } - DmaClear32(3, OAM, OAM_SIZE); - DmaClear16(3, PLTT, PLTT_SIZE); - gMain.state++; - break; - } - case 1: - ResetPaletteFade(); - remove_some_task(); - ResetTasks(); - ResetSpriteData(); - gMain.state++; - break; - case 2: - SetUpWindowConfig(&gWindowConfig_81E71B4); - gMain.state++; - break; - case 3: - MultistepInitMenuWindowBegin(&gWindowConfig_81E71B4); - gMain.state++; - break; - case 4: - if(!MultistepInitMenuWindowContinue()) - return; - gMain.state++; - break; - case 5: - LoadPalette(gUnknown_0839F5FC, 0x80, 0x40); - CpuCopy16(gUnknown_0839F63C, (void *)0x0600BEE0, 0x40); - gMain.state++; - break; - case 6: - BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - gMain.state++; - break; - case 7: - { - u16 savedIme; - - REG_WIN0H = 0; - REG_WIN0V = 0; - REG_WIN1H = 0; - REG_WIN1V = 0; - REG_WININ = 0x1111; - REG_WINOUT = 0x31; - REG_BLDCNT = 0xE1; - REG_BLDALPHA = 0; - REG_BLDY = 7; - savedIme = REG_IME; - REG_IME = 0; - REG_IE |= INTR_FLAG_VBLANK; - REG_IME = savedIme; - REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; - SetVBlankCallback(VBlankCB); - REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_OBJ_ON | - DISPCNT_WIN0_ON | DISPCNT_WIN1_ON; - gMain.state++; - break; - } - case 8: - { - u8 taskId = CreateTask(Task_OptionMenuFadeIn, 0); - - gTasks[taskId].data[TD_MENUSELECTION] = 0; - gTasks[taskId].data[TD_TEXTSPEED] = gSaveBlock2.optionsTextSpeed; - gTasks[taskId].data[TD_BATTLESCENE] = gSaveBlock2.optionsBattleSceneOff; - gTasks[taskId].data[TD_BATTLESTYLE] = gSaveBlock2.optionsBattleStyle; - gTasks[taskId].data[TD_SOUND] = gSaveBlock2.optionsSound; - gTasks[taskId].data[TD_BUTTONMODE] = gSaveBlock2.optionsButtonMode; - gTasks[taskId].data[TD_FRAMETYPE] = gSaveBlock2.optionsWindowFrameType; - - MenuDrawTextWindow(2, 0, 27, 3); - MenuDrawTextWindow(2, 4, 27, 19); - - MenuPrint(gSystemText_OptionMenu, 4, 1); - MenuPrint(gSystemText_TextSpeed, 4, 5); - MenuPrint(gSystemText_BattleScene, 4, 7); - MenuPrint(gSystemText_BattleStyle, 4, 9); - MenuPrint(gSystemText_Sound, 4, 11); - MenuPrint(gSystemText_ButtonMode, 4, 13); - MenuPrint(gSystemText_Frame, 4, 15); - MenuPrint(gSystemText_Cancel, 4, 17); - - TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]); - BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]); - BattleStyle_DrawChoices(gTasks[taskId].data[TD_BATTLESTYLE]); - Sound_DrawChoices(gTasks[taskId].data[TD_SOUND]); - ButtonMode_DrawChoices(gTasks[taskId].data[TD_BUTTONMODE]); - FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]); - - REG_WIN0H = WIN_RANGE(17, 223); - REG_WIN0V = WIN_RANGE(1, 31); - - HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]); - gMain.state++; - break; } - case 9: - SetMainCallback2(MainCB); + DmaClear32(3, OAM, OAM_SIZE); + DmaClear16(3, PLTT, PLTT_SIZE); + gMain.state++; + break; + } + case 1: + ResetPaletteFade(); + remove_some_task(); + ResetTasks(); + ResetSpriteData(); + gMain.state++; + break; + case 2: + SetUpWindowConfig(&gWindowConfig_81E71B4); + gMain.state++; + break; + case 3: + MultistepInitMenuWindowBegin(&gWindowConfig_81E71B4); + gMain.state++; + break; + case 4: + if (!MultistepInitMenuWindowContinue()) return; + gMain.state++; + break; + case 5: + LoadPalette(gUnknown_0839F5FC, 0x80, 0x40); + CpuCopy16(gUnknown_0839F63C, (void *)0x0600BEE0, 0x40); + gMain.state++; + break; + case 6: + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + gMain.state++; + break; + case 7: + { + u16 savedIme; + + REG_WIN0H = 0; + REG_WIN0V = 0; + REG_WIN1H = 0; + REG_WIN1V = 0; + REG_WININ = 0x1111; + REG_WINOUT = 0x31; + REG_BLDCNT = 0xE1; + REG_BLDALPHA = 0; + REG_BLDY = 7; + savedIme = REG_IME; + REG_IME = 0; + REG_IE |= INTR_FLAG_VBLANK; + REG_IME = savedIme; + REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; + SetVBlankCallback(VBlankCB); + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_OBJ_ON | + DISPCNT_WIN0_ON | DISPCNT_WIN1_ON; + gMain.state++; + break; + } + case 8: + { + u8 taskId = CreateTask(Task_OptionMenuFadeIn, 0); + + gTasks[taskId].data[TD_MENUSELECTION] = 0; + gTasks[taskId].data[TD_TEXTSPEED] = gSaveBlock2.optionsTextSpeed; + gTasks[taskId].data[TD_BATTLESCENE] = gSaveBlock2.optionsBattleSceneOff; + gTasks[taskId].data[TD_BATTLESTYLE] = gSaveBlock2.optionsBattleStyle; + gTasks[taskId].data[TD_SOUND] = gSaveBlock2.optionsSound; + gTasks[taskId].data[TD_BUTTONMODE] = gSaveBlock2.optionsButtonMode; + gTasks[taskId].data[TD_FRAMETYPE] = gSaveBlock2.optionsWindowFrameType; + + MenuDrawTextWindow(2, 0, 27, 3); + MenuDrawTextWindow(2, 4, 27, 19); + + MenuPrint(gSystemText_OptionMenu, 4, 1); + MenuPrint(gSystemText_TextSpeed, 4, 5); + MenuPrint(gSystemText_BattleScene, 4, 7); + MenuPrint(gSystemText_BattleStyle, 4, 9); + MenuPrint(gSystemText_Sound, 4, 11); + MenuPrint(gSystemText_ButtonMode, 4, 13); + MenuPrint(gSystemText_Frame, 4, 15); + MenuPrint(gSystemText_Cancel, 4, 17); + + TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]); + BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]); + BattleStyle_DrawChoices(gTasks[taskId].data[TD_BATTLESTYLE]); + Sound_DrawChoices(gTasks[taskId].data[TD_SOUND]); + ButtonMode_DrawChoices(gTasks[taskId].data[TD_BUTTONMODE]); + FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]); + + REG_WIN0H = WIN_RANGE(17, 223); + REG_WIN0V = WIN_RANGE(1, 31); + + HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]); + gMain.state++; + break; + } + case 9: + SetMainCallback2(MainCB); + return; } } static void Task_OptionMenuFadeIn(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { gTasks[taskId].func = Task_OptionMenuProcessInput; } @@ -235,26 +214,26 @@ static void Task_OptionMenuFadeIn(u8 taskId) static void Task_OptionMenuProcessInput(u8 taskId) { - if(gMain.newKeys & A_BUTTON) + if (gMain.newKeys & A_BUTTON) { - if(gTasks[taskId].data[TD_MENUSELECTION] == MENUITEM_CANCEL) + if (gTasks[taskId].data[TD_MENUSELECTION] == MENUITEM_CANCEL) gTasks[taskId].func = Task_OptionMenuSave; } - else if(gMain.newKeys & B_BUTTON) + else if (gMain.newKeys & B_BUTTON) { gTasks[taskId].func = Task_OptionMenuSave; } - else if(gMain.newKeys & DPAD_UP) + else if (gMain.newKeys & DPAD_UP) { - if(gTasks[taskId].data[TD_MENUSELECTION] > 0) + if (gTasks[taskId].data[TD_MENUSELECTION] > 0) gTasks[taskId].data[TD_MENUSELECTION]--; else gTasks[taskId].data[TD_MENUSELECTION] = 6; HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]); } - else if(gMain.newKeys & DPAD_DOWN) + else if (gMain.newKeys & DPAD_DOWN) { - if(gTasks[taskId].data[TD_MENUSELECTION] <= 5) + if (gTasks[taskId].data[TD_MENUSELECTION] <= 5) gTasks[taskId].data[TD_MENUSELECTION]++; else gTasks[taskId].data[TD_MENUSELECTION] = 0; @@ -262,32 +241,32 @@ static void Task_OptionMenuProcessInput(u8 taskId) } else { - switch(gTasks[taskId].data[TD_MENUSELECTION]) + switch (gTasks[taskId].data[TD_MENUSELECTION]) { - case MENUITEM_TEXTSPEED: - gTasks[taskId].data[TD_TEXTSPEED] = TextSpeed_ProcessInput(gTasks[taskId].data[TD_TEXTSPEED]); - TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]); - break; - case MENUITEM_BATTLESCENE: - gTasks[taskId].data[TD_BATTLESCENE] = BattleScene_ProcessInput(gTasks[taskId].data[TD_BATTLESCENE]); - BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]); - break; - case MENUITEM_BATTLESTYLE: - gTasks[taskId].data[TD_BATTLESTYLE] = BattleStyle_ProcessInput(gTasks[taskId].data[TD_BATTLESTYLE]); - BattleStyle_DrawChoices(gTasks[taskId].data[TD_BATTLESTYLE]); - break; - case MENUITEM_SOUND: - gTasks[taskId].data[TD_SOUND] = Sound_ProcessInput(gTasks[taskId].data[TD_SOUND]); - Sound_DrawChoices(gTasks[taskId].data[TD_SOUND]); - break; - case MENUITEM_BUTTONMODE: - gTasks[taskId].data[TD_BUTTONMODE] = ButtonMode_ProcessInput(gTasks[taskId].data[TD_BUTTONMODE]); - ButtonMode_DrawChoices(gTasks[taskId].data[TD_BUTTONMODE]); - break; - case MENUITEM_FRAMETYPE: - gTasks[taskId].data[TD_FRAMETYPE] = FrameType_ProcessInput(gTasks[taskId].data[TD_FRAMETYPE]); - FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]); - break; + case MENUITEM_TEXTSPEED: + gTasks[taskId].data[TD_TEXTSPEED] = TextSpeed_ProcessInput(gTasks[taskId].data[TD_TEXTSPEED]); + TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]); + break; + case MENUITEM_BATTLESCENE: + gTasks[taskId].data[TD_BATTLESCENE] = BattleScene_ProcessInput(gTasks[taskId].data[TD_BATTLESCENE]); + BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]); + break; + case MENUITEM_BATTLESTYLE: + gTasks[taskId].data[TD_BATTLESTYLE] = BattleStyle_ProcessInput(gTasks[taskId].data[TD_BATTLESTYLE]); + BattleStyle_DrawChoices(gTasks[taskId].data[TD_BATTLESTYLE]); + break; + case MENUITEM_SOUND: + gTasks[taskId].data[TD_SOUND] = Sound_ProcessInput(gTasks[taskId].data[TD_SOUND]); + Sound_DrawChoices(gTasks[taskId].data[TD_SOUND]); + break; + case MENUITEM_BUTTONMODE: + gTasks[taskId].data[TD_BUTTONMODE] = ButtonMode_ProcessInput(gTasks[taskId].data[TD_BUTTONMODE]); + ButtonMode_DrawChoices(gTasks[taskId].data[TD_BUTTONMODE]); + break; + case MENUITEM_FRAMETYPE: + gTasks[taskId].data[TD_FRAMETYPE] = FrameType_ProcessInput(gTasks[taskId].data[TD_FRAMETYPE]); + FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]); + break; } } } @@ -300,17 +279,17 @@ static void Task_OptionMenuSave(u8 taskId) gSaveBlock2.optionsSound = gTasks[taskId].data[TD_SOUND]; gSaveBlock2.optionsButtonMode = gTasks[taskId].data[TD_BUTTONMODE]; gSaveBlock2.optionsWindowFrameType = gTasks[taskId].data[TD_FRAMETYPE]; - + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); gTasks[taskId].func = Task_OptionMenuFadeOut; } static void Task_OptionMenuFadeOut(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { DestroyTask(taskId); - SetMainCallback2(gMain.field_8); + SetMainCallback2(gMain.savedCallback); } } @@ -323,14 +302,14 @@ static void HighlightOptionMenuItem(u8 index) REG_WIN1V = WIN_RANGE_(index * 16 + 40, index * 16 + 56); } -static void DrawOptionMenuChoice(u8 *text, u8 x, u8 y, u8 style) +static void DrawOptionMenuChoice(const u8 *text, u8 x, u8 y, u8 style) { u8 dst[16]; u16 i; - - for(i = 0; *text != EOS && i <= 14; i++) + + for (i = 0; *text != EOS && i <= 14; i++) dst[i] = *(text++); - + dst[2] = style; dst[i] = EOS; MenuPrint_PixelCoords(dst, x, y, 1); @@ -338,16 +317,16 @@ static void DrawOptionMenuChoice(u8 *text, u8 x, u8 y, u8 style) static u8 TextSpeed_ProcessInput(u8 selection) { - if(gMain.newKeys & DPAD_RIGHT) + if (gMain.newKeys & DPAD_RIGHT) { - if(selection <= 1) + if (selection <= 1) selection++; else selection = 0; } - if(gMain.newKeys & DPAD_LEFT) + if (gMain.newKeys & DPAD_LEFT) { - if(selection != 0) + if (selection != 0) selection--; else selection = 2; @@ -355,23 +334,34 @@ static u8 TextSpeed_ProcessInput(u8 selection) return selection; } +#if ENGLISH +#define TEXTSPEED_SLOW_LEFT (120) +#define TEXTSPEED_MIX_LEFT (155) +#define TEXTSPEED_FAST_LEFT (184) +#endif +#if GERMAN +#define TEXTSPEED_SLOW_LEFT (120) +#define TEXTSPEED_MIX_LEFT (161) +#define TEXTSPEED_FAST_LEFT (202) +#endif + static void TextSpeed_DrawChoices(u8 selection) { u8 styles[3]; - + styles[0] = 0xF; styles[1] = 0xF; styles[2] = 0xF; styles[selection] = 0x8; - - DrawOptionMenuChoice(gSystemText_Slow, 120, 40, styles[0]); - DrawOptionMenuChoice(gSystemText_Mid, 155, 40, styles[1]); - DrawOptionMenuChoice(gSystemText_Fast, 184, 40, styles[2]); + + DrawOptionMenuChoice(gSystemText_Slow, TEXTSPEED_SLOW_LEFT, 40, styles[0]); + DrawOptionMenuChoice(gSystemText_Mid, TEXTSPEED_MIX_LEFT, 40, styles[1]); + DrawOptionMenuChoice(gSystemText_Fast, TEXTSPEED_FAST_LEFT, 40, styles[2]); } static u8 BattleScene_ProcessInput(u8 selection) { - if(gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) + if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) selection ^= 1; return selection; } @@ -379,37 +369,45 @@ static u8 BattleScene_ProcessInput(u8 selection) static void BattleScene_DrawChoices(u8 selection) { u8 styles[2]; - + styles[0] = 0xF; styles[1] = 0xF; styles[selection] = 0x8; - + DrawOptionMenuChoice(gSystemText_On, 120, 56, styles[0]); DrawOptionMenuChoice(gSystemText_Off, 190, 56, styles[1]); } static u8 BattleStyle_ProcessInput(u8 selection) { - if(gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) + if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) selection ^= 1; return selection; } +#if ENGLISH +#define BATTLESTYLE_SHIFT (120) +#define BATTLESTYLE_SET (190) +#elif GERMAN +#define BATTLESTYLE_SHIFT (120) +#define BATTLESTYLE_SET (178) +#endif + static void BattleStyle_DrawChoices(u8 selection) { u8 styles[2]; - + styles[0] = 0xF; styles[1] = 0xF; styles[selection] = 0x8; - - DrawOptionMenuChoice(gSystemText_Shift, 120, 72, styles[0]); - DrawOptionMenuChoice(gSystemText_Set, 190, 72, styles[1]); + + DrawOptionMenuChoice(gSystemText_Shift, BATTLESTYLE_SHIFT, 72, styles[0]); + DrawOptionMenuChoice(gSystemText_Set, BATTLESTYLE_SET, 72, styles[1]); } static u8 Sound_ProcessInput(u8 selection) { - if(gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) + if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) { selection ^= 1; SetPokemonCryStereo(selection); @@ -420,28 +418,28 @@ static u8 Sound_ProcessInput(u8 selection) static void Sound_DrawChoices(u8 selection) { u8 styles[3]; - + styles[0] = 0xF; styles[1] = 0xF; styles[selection] = 0x8; - + DrawOptionMenuChoice(gSystemText_Mono, 120, 88, styles[0]); DrawOptionMenuChoice(gSystemText_Stereo, 172, 88, styles[1]); } static u8 FrameType_ProcessInput(u8 selection) { - if(gMain.newKeys & DPAD_RIGHT) + if (gMain.newKeys & DPAD_RIGHT) { - if(selection <= 18) + if (selection <= 18) selection++; else selection = 0; MenuLoadTextWindowGraphics_OverrideFrameType(selection); } - if(gMain.newKeys & DPAD_LEFT) + if (gMain.newKeys & DPAD_LEFT) { - if(selection != 0) + if (selection != 0) selection--; else selection = 19; @@ -452,17 +450,18 @@ static u8 FrameType_ProcessInput(u8 selection) #define CHAR_0 0xA1 //Character code of '0' character +#if ENGLISH static void FrameType_DrawChoices(u8 selection) { u8 text[8]; u8 n = selection + 1; u16 i; - - for(i = 0; gSystemText_Terminator[i] != EOS && i <= 5; i++) + + for (i = 0; gSystemText_Terminator[i] != EOS && i <= 5; i++) text[i] = gSystemText_Terminator[i]; - + //Convert number to decimal string - if(n / 10 != 0) + if (n / 10 != 0) { text[i] = n / 10 + CHAR_0; i++; @@ -476,24 +475,87 @@ static void FrameType_DrawChoices(u8 selection) text[i] = CHAR_SPACE; i++; } - + text[i] = EOS; MenuPrint(gSystemText_Type, 15, 15); MenuPrint(text, 18, 15); } +#elif GERMAN +__attribute__((naked)) +static void FrameType_DrawChoices(u8 selection) +{ + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + sub sp, 0x10\n\ + lsls r0, 24\n\ + movs r1, 0x80\n\ + lsls r1, 17\n\ + adds r0, r1\n\ + lsrs r5, r0, 24\n\ + ldr r1, _0808C368 @ =gSystemText_Type\n\ + mov r0, sp\n\ + bl StringCopy\n\ + ldr r1, _0808C36C @ =gSystemText_Terminator\n\ + mov r0, sp\n\ + bl StringAppend\n\ + adds r4, r0, 0\n\ + adds r0, r5, 0\n\ + movs r1, 0xA\n\ + bl __udivsi3\n\ + adds r1, r0, 0\n\ + lsls r0, r1, 24\n\ + lsrs r6, r0, 24\n\ + cmp r6, 0\n\ + beq _0808C370\n\ + adds r0, r1, 0\n\ + adds r0, 0xA1\n\ + strb r0, [r4]\n\ + adds r4, 0x1\n\ + adds r0, r5, 0\n\ + movs r1, 0xA\n\ + bl __umodsi3\n\ + adds r0, 0xA1\n\ + strb r0, [r4]\n\ + b _0808C380\n\ + .align 2, 0\n\ +_0808C368: .4byte gSystemText_Type\n\ +_0808C36C: .4byte gSystemText_Terminator\n\ +_0808C370:\n\ + adds r0, r5, 0\n\ + movs r1, 0xA\n\ + bl __umodsi3\n\ + adds r0, 0xA1\n\ + strb r0, [r4]\n\ + adds r4, 0x1\n\ + strb r6, [r4]\n\ +_0808C380:\n\ + adds r4, 0x1\n\ + movs r0, 0xFF\n\ + strb r0, [r4]\n\ + mov r0, sp\n\ + movs r1, 0xF\n\ + movs r2, 0xF\n\ + bl MenuPrint\n\ + add sp, 0x10\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .syntax divided\n"); +} +#endif static u8 ButtonMode_ProcessInput(u8 selection) { - if(gMain.newKeys & DPAD_RIGHT) + if (gMain.newKeys & DPAD_RIGHT) { - if(selection <= 1) + if (selection <= 1) selection++; else selection = 0; } - if(gMain.newKeys & DPAD_LEFT) + if (gMain.newKeys & DPAD_LEFT) { - if(selection != 0) + if (selection != 0) selection--; else selection = 2; @@ -504,12 +566,12 @@ static u8 ButtonMode_ProcessInput(u8 selection) static void ButtonMode_DrawChoices(u8 selection) { u8 styles[3]; - + styles[0] = 0xF; styles[1] = 0xF; styles[2] = 0xF; styles[selection] = 0x8; - + DrawOptionMenuChoice(gSystemText_Normal, 120, 104, styles[0]); DrawOptionMenuChoice(gSystemText_LR, 166, 104, styles[1]); DrawOptionMenuChoice(gSystemText_LA, 188, 104, styles[2]); diff --git a/src/palette.c b/src/palette.c index bf93a036c..94a4f8092 100644 --- a/src/palette.c +++ b/src/palette.c @@ -1,6 +1,5 @@ #include "global.h" #include "palette.h" -#include "asm.h" #include "blend_palette.h" #include "decompress.h" @@ -30,7 +29,7 @@ struct PaletteStructTemplate struct PaletteStruct { - struct PaletteStructTemplate *base; + const struct PaletteStructTemplate *base; u32 ps_field_4_0:1; u16 ps_field_4_1:1; u32 baseDestOffset:9; @@ -48,7 +47,19 @@ EWRAM_DATA u32 gFiller_202F394 = 0; EWRAM_DATA static u32 sPlttBufferTransferPending = 0; EWRAM_DATA static u8 sPaletteDecompressionBuffer[0x400] = {0}; -extern struct PaletteStructTemplate gDummyPaletteStructTemplate; +static const struct PaletteStructTemplate sDummyPaletteStructTemplate = +{ + 0xFFFF, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0 +}; static void unused_sub_8073DFC(struct PaletteStruct *, u32 *); static void unused_sub_8073F60(struct PaletteStruct *, u32 *); @@ -332,7 +343,7 @@ void ResetPaletteStructByUid(u16 a1) void ResetPaletteStruct(u8 paletteNum) { - sPaletteStructs[paletteNum].base = &gDummyPaletteStructTemplate; + sPaletteStructs[paletteNum].base = &sDummyPaletteStructTemplate; sPaletteStructs[paletteNum].ps_field_4_0 = 0; sPaletteStructs[paletteNum].baseDestOffset = 0; sPaletteStructs[paletteNum].destOffset = 0; @@ -603,7 +614,7 @@ static u8 UpdateFastPaletteFade(void) if (b < b0) b = b0; - gPlttBufferFaded[i] = r | (g << 5) | (b << 10); + gPlttBufferFaded[i] = RGB(r, g, b); } break; case FAST_FADE_OUT_TO_WHTIE: @@ -621,7 +632,7 @@ static u8 UpdateFastPaletteFade(void) if (b > 31) b = 31; - gPlttBufferFaded[i] = r | (g << 5) | (b << 10); + gPlttBufferFaded[i] = RGB(r, g, b); } break; case FAST_FADE_IN_FROM_BLACK: @@ -647,7 +658,7 @@ static u8 UpdateFastPaletteFade(void) if (b > b0) b = b0; - gPlttBufferFaded[i] = r | (g << 5) | (b << 10); + gPlttBufferFaded[i] = RGB(r, g, b); } break; case FAST_FADE_OUT_TO_BLACK: @@ -665,7 +676,7 @@ static u8 UpdateFastPaletteFade(void) if (b < 0) b = 0; - gPlttBufferFaded[i] = r | (g << 5) | (b << 10); + gPlttBufferFaded[i] = RGB(r, g, b); } } diff --git a/src/party_menu.c b/src/party_menu.c new file mode 100644 index 000000000..99bbb5f83 --- /dev/null +++ b/src/party_menu.c @@ -0,0 +1,1505 @@ +#include "global.h" +#include "party_menu.h" +#include "battle.h" +#include "battle_interface.h" +#include "battle_party_menu.h" +#include "data2.h" +#include "event_data.h" +#include "item.h" +#include "mail_data.h" +#include "main.h" +#include "menu.h" +#include "palette.h" +#include "pokemon.h" +#include "pokemon_item_effect.h" +#include "pokemon_menu.h" +#include "pokemon_summary_screen.h" +#include "rom_8077ABC.h" +#include "rom_8094928.h" +#include "songs.h" +#include "sound.h" +#include "species.h" +#include "sprite.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "sprite.h" +#include "palette.h" +#include "event_data.h" +#include "main.h" +#include "item.h" +#include "battle_interface.h" +#include "species.h" +#include "party_menu.h" + +#define DATA_COUNT (6) + +struct Unk2001000 +{ + u8 unk0; + u8 unk1; + u8 unk2; +}; + +struct Unk201C000 +{ + /*0x00*/ struct Pokemon *pokemon; + /*0x04*/ u8 unk4; + /*0x05*/ u8 unk5; + /*0x06*/ u16 unk6; + /*0x08*/ u16 unk8; + /*0x0A*/ u8 pad_0A[2]; + /*0x0C*/ s32 unkC; + /*0x10*/ TaskFunc unk10; + /*0x14*/ TaskFunc unk14; +}; + +struct Unk201F000 +{ + u8 filler0[0xE00]; + u8 unkE00[3]; // not sure if this is an array or struct, or how big it is +}; + +struct UnknownStruct5 +{ + u8 unk0; + u8 unk1; + u16 *unk4; +}; + +extern u8 ewram[]; +#define ewram01000 (*(struct Unk2001000 *)(ewram + 0x01000)) +#define ewram1C000 (*(struct Unk201C000 *)(ewram + 0x1C000)) +#define ewram1F000 (*(struct Unk201F000 *)(ewram + 0x1F000)) + +extern u8 gUnknown_0202E8F4; +extern u8 gUnknown_0202E8F6; +extern u16 gUnknown_0202E8F8; +extern u8 gUnknown_0202E8FA; +extern u8 gLastFieldPokeMenuOpened; +extern u8 gPlayerPartyCount; +extern u16 gScriptItemId; +extern s32 gBattleMoveDamage; + +//extern const u16 gUnknown_083769A8[][6]; +//extern const u8 gUnknown_083769A8[][12]; +extern void *const gUnknown_08376858[][6]; +extern const u8 gUnknown_083769A8[]; +extern const u8 gUnknown_08376D1C[DATA_COUNT]; +extern const u16 gUnknown_08376504[]; +extern void (*const gUnknown_08376B54[])(u8); +extern const u8 *const gUnknown_08376D04[DATA_COUNT]; +extern const struct UnknownStruct5 gUnknown_08376BB4[][6]; + +static void sub_806E884(u8 taskId); + +/* +void sub_806AEDC(void) +{ + const struct UnknownStruct5 *r5; + s32 i; + + AnimateSprites(); + BuildOamBuffer(); + r5 = gUnknown_08376BB4[gUnknown_0202E8FA]; + for (i = 0; i < 6; i++) + sub_800142C(r5[i].unk0 * 8, r5[i].unk1 * 8, r5[i].unk4, 0, (i << 5) | 0x200); + RunTasks(); + UpdatePaletteFade(); +} +*/ + +#if ENGLISH +#define WINDOW_LEFT (3) +#define WINDOW_RIGHT (26) +#elif GERMAN +#define WINDOW_LEFT (0) +#define WINDOW_RIGHT (29) +#endif + +u8 sub_806E834(const u8 *message, u8 arg1) +{ + u8 taskId; + + gUnknown_0202E8F6 = 1; + + MenuDrawTextWindow(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + MenuPrintMessage(message, WINDOW_LEFT + 1, 15); + + taskId = CreateTask(sub_806E884, 1); + gTasks[taskId].data[0] = arg1; + + return taskId; +} + +static void sub_806E884(u8 taskId) +{ + if (MenuUpdateWindowText()) + { + gUnknown_0202E8F6 = 0; + if (gTasks[taskId].data[0] == 0) + MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + DestroyTask(taskId); + } +} + +void sub_806E8D0(u8 taskId, u16 b, TaskFunc c) +{ + ewram1C000.unk10 = c; + ewram1C000.unk4 = taskId; + ewram1C000.unk5 = sub_806CA38(taskId); + ewram1C000.unk6 = b; + ewram1C000.pokemon = &gPlayerParty[ewram1C000.unk5]; +} + +bool8 PartyMenuUpdateMonHeldItem(struct Pokemon *pkmn, u16 item) +{ + u8 itemData[2]; + + if (ItemIsMail(item) == TRUE) + { + if (GiveMailToMon(pkmn, item) == 0xFF) + return TRUE; + gUnknown_0202E8F4 = 2; + } + else + { + gUnknown_0202E8F4 = 1; + } + + itemData[0] = item; + itemData[1] = item >> 8; + SetMonData(pkmn, MON_DATA_HELD_ITEM, itemData); + return FALSE; +} + +void PartyMenuTryGiveMonHeldItem(u8 taskId, u16 newItem, TaskFunc c) +{ + u16 currentItem; + + gTasks[taskId].func = TaskDummy; + sub_806E8D0(taskId, newItem, c); + currentItem = GetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM); + gUnknown_0202E8F4 = 0; + gUnknown_0202E8F8 = 0; + if (currentItem != 0) + { + if (ItemIsMail(currentItem) == TRUE) + { + sub_806E834(gOtherText_MailMustBeRemoved, 1); + CreateTask(party_menu_link_mon_held_item_object, 5); + } + else + { + GetMonNickname(ewram1C000.pokemon, gStringVar1); + CopyItemName(currentItem, gStringVar2); + StringExpandPlaceholders(gStringVar4, gOtherText_AlreadyHolding); + sub_806E834(gStringVar4, 1); + CreateTask(Task_ConfirmGiveHeldItem, 5); + if (ItemIsMail(newItem) == TRUE) + gUnknown_0202E8F8 = currentItem; + } + } + else + { + PartyMenuUpdateMonHeldItem(ewram1C000.pokemon, newItem); + RemoveBagItem(newItem, 1); + if (ItemIsMail(newItem)) + { + gTasks[taskId].func = c; + } + else + { + DisplayGiveHeldItemMessage(ewram1C000.unk5, newItem, 1); + CreateTask(party_menu_link_mon_held_item_object, 5); + } + } +} + +void party_menu_link_mon_held_item_object(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + SetHeldItemIconVisibility(ewram1C000.unk4, ewram1C000.unk5); + gTasks[ewram1C000.unk4].func = ewram1C000.unk10; + DestroyTask(taskId); + } +} + +void PartyMenuTryGiveMonHeldItem_806EACC(u8 taskId) +{ + s8 selection = ProcessMenuInputNoWrap_(); + + if (selection == 0) + { + u16 currentItem; + + MenuZeroFillWindowRect(23, 8, 29, 13); + currentItem = GetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM); + RemoveBagItem(ewram1C000.unk6, 1); + if (AddBagItem(currentItem, 1) == TRUE) + { + PartyMenuUpdateMonHeldItem(ewram1C000.pokemon, ewram1C000.unk6); + if (ItemIsMail(ewram1C000.unk6)) + { + DisplayTakeHeldItemMessage(ewram1C000.unk5, currentItem, 1); + } + else + { + CopyItemName(ewram1C000.unk6, gStringVar1); + StringExpandPlaceholders(gStringVar4, gOtherText_TakenAndReplaced); + sub_806E834(gStringVar4, 1); + } + } + else + { + sub_806E834(gOtherText_BagFullCannotRemoveItem, 0); + AddBagItem(ewram1C000.unk6, 1); + } + } + else + { + if (selection != 1 && selection != -1) + return; + if (selection == -1) + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(23, 8, 29, 13); + } + gTasks[taskId].func = party_menu_link_mon_held_item_object; +} + +void Task_ConfirmGiveHeldItem(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + DisplayYesNoMenu(23, 8, 1); + gTasks[taskId].func = PartyMenuTryGiveMonHeldItem_806EACC; + } +} + +void DisplayGiveHeldItemMessage(u8 a, u16 b, u8 c) +{ + GetMonNickname(&gPlayerParty[a], gStringVar1); + CopyItemName(b, gStringVar2); + StringExpandPlaceholders(gStringVar4, gOtherText_WasGivenToHold); + sub_806E834(gStringVar4, c); +} + + +// Not sure about this one for now. +/* +void PartyMenuTryGiveMonMail(u8 taskId, TaskFunc func) +{ + u16 currentItem; + struct MailStruct *r4; + + gTasks[taskId].func = TaskDummy; + sub_806E8D0(taskId, 0, func); + currentItem = GetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM); + gUnknown_0202E8F4 = 0; + r4 = &gSaveBlock1.mail[ewram1F000.unkE00[0] + ewram1F000.unkE00[2]]; + if (currentItem != 0) + { + sub_806E834(gOtherText_PokeHoldingItemCantMail, 1); + CreateTask(party_menu_link_mon_held_item_object, 5); + } + else + { + GiveMailToMon2(ewram1C000.pokemon, r4); + ClearMailStruct(r4); + sub_806E834(gOtherText_MailTransferredMailbox, 1); + CreateTask(party_menu_link_mon_held_item_object, 5); + } +} +*/ +__attribute__((naked)) +void PartyMenuTryGiveMonMail(u8 taskId, TaskFunc func) +{ + asm(".syntax unified\n\ + push {r4,r5,lr}\n\ + adds r2, r1, 0\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + ldr r3, _0806ECA0 @ =gTasks\n\ + lsls r1, r0, 2\n\ + adds r1, r0\n\ + lsls r1, 3\n\ + adds r1, r3\n\ + ldr r3, _0806ECA4 @ =TaskDummy\n\ + str r3, [r1]\n\ + movs r1, 0\n\ + bl sub_806E8D0\n\ + ldr r5, _0806ECA8 @ =0x0201c000\n\ + ldr r0, [r5]\n\ + movs r1, 0xC\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + ldr r2, _0806ECAC @ =gUnknown_0202E8F4\n\ + movs r1, 0\n\ + strb r1, [r2]\n\ + movs r1, 0xF8\n\ + lsls r1, 6\n\ + adds r2, r5, r1\n\ + ldrb r1, [r2]\n\ + adds r1, 0x6\n\ + ldrb r2, [r2, 0x2]\n\ + adds r1, r2\n\ + lsls r2, r1, 3\n\ + adds r2, r1\n\ + lsls r2, 2\n\ + ldr r1, _0806ECB0 @ =gSaveBlock1 + 0x2B4C\n\ + adds r4, r2, r1\n\ + cmp r0, 0\n\ + beq _0806ECBC\n\ + ldr r0, _0806ECB4 @ =gOtherText_PokeHoldingItemCantMail\n\ + movs r1, 0x1\n\ + bl sub_806E834\n\ + ldr r0, _0806ECB8 @ =party_menu_link_mon_held_item_object\n\ + movs r1, 0x5\n\ + bl CreateTask\n\ + b _0806ECDA\n\ + .align 2, 0\n\ +_0806ECA0: .4byte gTasks\n\ +_0806ECA4: .4byte TaskDummy\n\ +_0806ECA8: .4byte 0x0201c000\n\ +_0806ECAC: .4byte gUnknown_0202E8F4\n\ +_0806ECB0: .4byte gSaveBlock1 + 0x2B4C\n\ +_0806ECB4: .4byte gOtherText_PokeHoldingItemCantMail\n\ +_0806ECB8: .4byte party_menu_link_mon_held_item_object\n\ +_0806ECBC:\n\ + ldr r0, [r5]\n\ + adds r1, r4, 0\n\ + bl GiveMailToMon2\n\ + adds r0, r4, 0\n\ + bl ClearMailStruct\n\ + ldr r0, _0806ECE0 @ =gOtherText_MailTransferredMailbox\n\ + movs r1, 0x1\n\ + bl sub_806E834\n\ + ldr r0, _0806ECE4 @ =party_menu_link_mon_held_item_object\n\ + movs r1, 0x5\n\ + bl CreateTask\n\ +_0806ECDA:\n\ + pop {r4,r5}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_0806ECE0: .4byte gOtherText_MailTransferredMailbox\n\ +_0806ECE4: .4byte party_menu_link_mon_held_item_object\n\ + .syntax divided\n"); +} + +void PartyMenuTryGiveMonHeldItem_806ECE8(u8 taskId, TaskFunc func) +{ + u16 currentItem; + + gTasks[taskId].func = TaskDummy; + sub_806E8D0(taskId, 0, func); + currentItem = GetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM); + if (currentItem == 0) + { + StringExpandPlaceholders(gStringVar4, gOtherText_NotHoldingAnything); + sub_806E834(gStringVar4, 0); + CreateTask(party_menu_link_mon_held_item_object, 5); + } + else + { + u8 itemData[2]; + + itemData[0] = 0; + itemData[1] = 0; + if (AddBagItem(currentItem, 1) == TRUE) + { + if (ItemIsMail(currentItem) == TRUE) + TakeMailFromMon(ewram1C000.pokemon); + DisplayTakeHeldItemMessage(ewram1C000.unk5, currentItem, 0); + SetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM, itemData); + } + else + { + sub_806E834(gOtherText_BagFullCannotRemoveItem, 0); + } + CreateTask(party_menu_link_mon_held_item_object, 5); + } +} + +void DisplayTakeHeldItemMessage(u8 a, u16 b, u8 c) +{ + GetMonNickname(&gPlayerParty[a], gStringVar1); + CopyItemName(b, gStringVar2); + StringExpandPlaceholders(gStringVar4, gOtherText_ReceivedTheThingFrom); + sub_806E834(gStringVar4, c); +} + +void DoTakeMail(u8 taskId, TaskFunc func) +{ + gTasks[taskId].func = TaskDummy; + sub_806E8D0(taskId, 0, func); + ewram1C000.unk6 = GetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM); + sub_806E834(gOtherText_SendRemovedMailPrompt, 1); + CreateTask(Task_ConfirmTakeHeldMail, 5); +} + +void Task_LoseMailMessage(u8 taskId) +{ + s8 selection = ProcessMenuInputNoWrap_(); + + if (selection == 0) + { + if (AddBagItem(ewram1C000.unk6, 1) == TRUE) + { + TakeMailFromMon(ewram1C000.pokemon); + sub_806E834(gOtherText_MailTaken, 0); + } + else + { + sub_806E834(gOtherText_BagFullCannotRemoveItem, 0); + } + MenuZeroFillWindowRect(23, 8, 29, 13); + gTasks[taskId].func = party_menu_link_mon_held_item_object; + } + else + { + if (selection != 1 && selection != -1) + return; + if (selection == -1) + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(23, 8, 29, 13); + MenuZeroFillWindowRect(0, 14, 29, 19); + gTasks[taskId].func = party_menu_link_mon_held_item_object; + } +} + +void Task_ConfirmLoseMailMessage(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + DisplayYesNoMenu(23, 8, 1); + gTasks[taskId].func = Task_LoseMailMessage; + } +} + +void Task_TakeHeldMail(u8 taskId) +{ + s8 selection = ProcessMenuInputNoWrap_(); + + if (selection == 0) + { + MenuZeroFillWindowRect(23, 8, 29, 13); + if (TakeMailFromMon2(ewram1C000.pokemon) != 0xFF) + sub_806E834(gOtherText_MailWasSent, 0); + else + sub_806E834(gOtherText_MailboxIsFull, 0); + gTasks[taskId].func = party_menu_link_mon_held_item_object; + } + else + { + if (selection != 1 && selection != -1) + return; + if (selection == -1) + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(23, 8, 29, 13); + sub_806E834(gOtherText_MailRemovedMessageLost, 1); + gTasks[taskId].func = Task_ConfirmLoseMailMessage; + } +} + +void Task_ConfirmTakeHeldMail(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + DisplayYesNoMenu(23, 8, 1); + gTasks[taskId].func = Task_TakeHeldMail; + } +} + +u16 ItemIdToBattleMoveId(u16 item) +{ + u16 moveId = item - 289; + + return gUnknown_08376504[moveId]; +} + +bool8 pokemon_has_move(struct Pokemon *pkmn, u16 move) +{ + u8 i; + + for (i = 0; i < 4; i++) + { + if (GetMonData(pkmn, MON_DATA_MOVE1 + i) == move) + return TRUE; + } + return FALSE; +} + +void TeachMonTMMove(u8 taskId, u16 move, TaskFunc func) +{ + PlaySE(SE_SELECT); + gTasks[taskId].func = TaskDummy; + sub_806E8D0(taskId, move, func); + CreateTask(Task_TeamMonTMMove, 5); +} + +void Task_TeamMonTMMove(u8 taskId) +{ + GetMonNickname(ewram1C000.pokemon, gStringVar1); + ewram1C000.unk8 = ItemIdToBattleMoveId(ewram1C000.unk6); + StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]); + ewram1B000.unk282 = 0; + if (pokemon_has_move(ewram1C000.pokemon, ewram1C000.unk8)) + { + StringExpandPlaceholders(gStringVar4, gOtherText_AlreadyKnows); + sub_806E834(gStringVar4, 1); + gTasks[taskId].func = party_menu_link_mon_held_item_object; + } + else + { + if (!CanMonLearnTMHM(ewram1C000.pokemon, ewram1C000.unk6 - 33)) + { + StringExpandPlaceholders(gStringVar4, gOtherText_NotCompatible); + sub_806E834(gStringVar4, 1); + gTasks[taskId].func = party_menu_link_mon_held_item_object; + } + else + { + if (GiveMoveToMon(ewram1C000.pokemon, ewram1C000.unk8) != 0xFFFF) + { + Task_TeamMonTMMove2(taskId); + } + else + { + StringExpandPlaceholders(gStringVar4, gOtherText_WantsToLearn); + sub_806E834(gStringVar4, 1); + gTasks[taskId].func = sub_806F358; + } + } + } +} + +void Task_TeamMonTMMove2(u8 taskId) +{ + StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]); + StringExpandPlaceholders(gStringVar4, gOtherText_LearnedMove); + sub_806E834(gStringVar4, 1); + AdjustFriendship(ewram1C000.pokemon, 4); + if (ewram1B000.unk282 == 0 && ewram1C000.unk6 <= 0x152) + RemoveBagItem(ewram1C000.unk6, 1); + gTasks[taskId].func = Task_TeamMonTMMove3; +} + +void Task_TeamMonTMMove3(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + PlayFanfare(BGM_FANFA1); + gTasks[taskId].func = Task_TeamMonTMMove4; + } +} + +void Task_TeamMonTMMove4(u8 taskId) +{ + if (IsFanfareTaskInactive()) + { + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + { + SetHeldItemIconVisibility(ewram1C000.unk4, ewram1C000.unk5); + if (ewram1B000.unk282 == 1) + { + sub_8070C54(taskId); + } + else + { + gTasks[ewram1C000.unk4].func = ewram1C000.unk10; + DestroyTask(taskId); + } + } + } +} + +void sub_806F2FC(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + SetHeldItemIconVisibility(ewram1C000.unk4, ewram1C000.unk5); + if (ewram1B000.unk282 == 1) + { + sub_8070C54(taskId); + } + else + { + gTasks[ewram1C000.unk4].func = ewram1C000.unk10; + DestroyTask(taskId); + } + } +} + +void sub_806F358(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + DisplayYesNoMenu(23, 8, 1); + gTasks[taskId].func = sub_806F390; + } +} + +void sub_806F390(u8 taskId) +{ + s8 selection = ProcessMenuInputNoWrap_(); + + if (selection == 0) + { + MenuZeroFillWindowRect(23, 8, 29, 13); + sub_806E834(gOtherText_WhichMoveToForget2, 1); + gTasks[taskId].func = sub_806F44C; + } + else + { + if (selection != 1 && selection != -1) + return; + if (selection == -1) + PlaySE(SE_SELECT); + StopTryingToTeachMove_806F614(taskId); + } +} + +void sub_806F3FC(u8 taskId) +{ + if (!gPaletteFade.active) + { + sub_809D9F0(gPlayerParty, ewram1C000.unk5, gPlayerPartyCount - 1, sub_808B564, ewram1C000.unk8); + DestroyTask(taskId); + } +} + +void sub_806F44C(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_806F3FC; + } +} + +void TaughtMove(u8 taskId) +{ + if (!gPaletteFade.active) + { + u8 moveIndex; + u16 r4; + + gTasks[taskId].func = TaskDummy; + sub_806E8D0(taskId, gScriptItemId, sub_808B508); + moveIndex = sub_809FA30(); + r4 = GetMonData(ewram1C000.pokemon, MON_DATA_MOVE1 + moveIndex); + GetMonNickname(ewram1C000.pokemon, gStringVar1); + StringCopy(gStringVar2, gMoveNames[r4]); + StringExpandPlaceholders(gStringVar4, gOtherText_ForgetMove123_2); + sub_806E834(gStringVar4, 1); + CreateTask(TMMoveUpdateMoveSlot, 5); + } +} + +void TMMoveUpdateMoveSlot(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + RemoveMonPPBonus(ewram1C000.pokemon, sub_809FA30()); + SetMonMoveSlot(ewram1C000.pokemon, ewram1C000.unk8, sub_809FA30()); + Task_TeamMonTMMove2(taskId); + } +} + +void StopTryingToTeachMove_806F588(u8 taskId) +{ + if (!gPaletteFade.active) + { + gTasks[taskId].func = TaskDummy; + sub_806E8D0(taskId, gScriptItemId, sub_808B508); + StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]); + StringExpandPlaceholders(gStringVar4, gOtherText_StopTryingTo); + sub_806E834(gStringVar4, 1); + CreateTask(StopTryingToTeachMove_806F67C, 5); + } +} + +void StopTryingToTeachMove_806F614(u8 taskId) +{ + MenuZeroFillWindowRect(23, 8, 29, 13); + StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]); + StringExpandPlaceholders(gStringVar4, gOtherText_StopTryingTo); + sub_806E834(gStringVar4, 1); + gTasks[taskId].func = StopTryingToTeachMove_806F67C; +} + +void StopTryingToTeachMove_806F67C(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + DisplayYesNoMenu(23, 8, 1); + gTasks[taskId].func = StopTryingToTeachMove_806F6B4; + } +} + +void StopTryingToTeachMove_806F6B4(u8 taskId) +{ + s8 selection = ProcessMenuInputNoWrap_(); + + if (selection == 0) + { + MenuZeroFillWindowRect(23, 8, 29, 13); + GetMonNickname(ewram1C000.pokemon, gStringVar1); + StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]); + StringExpandPlaceholders(gStringVar4, gOtherText_DidNotLearnMove2); + sub_806E834(gStringVar4, 1); + gTasks[taskId].func = sub_806F2FC; + } + else + { + if (selection != 1 && selection != -1) + return; + if (selection == -1) + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(23, 8, 29, 13); + GetMonNickname(ewram1C000.pokemon, gStringVar1); + StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]); + StringExpandPlaceholders(gStringVar4, gOtherText_WantsToLearn); + sub_806E834(gStringVar4, 1); + gTasks[taskId].func = sub_806F358; + } +} + +bool8 IsHMMove(u16 move) +{ + u8 i; + + for (i = 0; i < 8; i++) + { + if (gUnknown_08376504[50 + i] == move) + return TRUE; + } + return FALSE; +} + +s16 sub_806F7E8(u8 taskId, struct BattleInterfaceStruct1 *b, s8 c) +{ + s16 *taskData; + u8 hpBarLevel; + void *vramPtr; + + taskData = gTasks[taskId].data; + + b->unk0 = taskData[10]; + b->unk4 = taskData[11]; + b->unk8 = taskData[12] * c; + b->unk10 = 0x100; + hpBarLevel = GetHPBarLevel(ewram1B000.unk282, b->unk0); + if (hpBarLevel > 2) + b->unkC_0 = 4; + if (hpBarLevel == 2) + b->unkC_0 = 5; + if (hpBarLevel < 2) + b->unkC_0 = 6; + vramPtr = gUnknown_08376858[IsDoubleBattle()][ewram1C000.unk5]; + return sub_80460C8(b, &ewram1C000.unkC, vramPtr, 0); +} + +void sub_806F8AC(u8 taskId) +{ + struct BattleInterfaceStruct1 sp0; + u16 sp14; + + ewram1B000.unk282 = sub_806F7E8(taskId, &sp0, -1); + if (ewram1B000.unk282 == -1) + { + ewram1C000.unkC = 0; + if (-sp0.unk8 + sp0.unk4 > sp0.unk0) + sp14 = sp0.unk0 - sp0.unk4; + else + sp14 = -sp0.unk8; + gBattleMoveDamage = -sp14; + GetMonNickname(ewram1C000.pokemon, gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, sp14, 0, 3); + if (gTasks[taskId].data[14] == 0) + StringExpandPlaceholders(gStringVar4, gOtherText_HPRestoredBy); + else + StringExpandPlaceholders(gStringVar4, gOtherText_RegainedHealth); + SetMonIconAnim(GetMonIconSpriteId_maybe(ewram1C000.unk4, ewram1C000.unk5), ewram1C000.pokemon); + task_pc_turn_off(&gUnknown_083769A8[IsDoubleBattle() * 12 + ewram1C000.unk5 * 2], 7); + ewram1B000.unk261 = 2; + sub_806E834(gStringVar4, 1); + sp14 += sp0.unk4; + SetMonData(ewram1C000.pokemon, MON_DATA_HP, (u8 *)&sp14); + RemoveBagItem(ewram1C000.unk6, 1); + sub_8032638(); + gTasks[taskId].func = sub_806FB44; + } + else + { + PartyMenuDoPrintHP(ewram1C000.unk5, IsDoubleBattle(), ewram1B000.unk282, sp0.unk0); + } +} + +void sub_806FA18(u8 taskId) +{ + struct BattleInterfaceStruct1 sp0; + + ewram1B000.unk282 = sub_806F7E8(taskId, &sp0, 1); + if (ewram1B000.unk282 == -1) + { + PlaySE(SE_KAIFUKU); + ewram1C000.unkC = 0; + gTasks[taskId].data[11] -= gTasks[taskId].data[12]; + SetMonData(ewram1C000.pokemon, MON_DATA_HP, (u8 *)&gTasks[taskId].data[11]); + SetMonIconAnim(GetMonIconSpriteId_maybe(ewram1C000.unk4, ewram01000.unk1), ewram1C000.pokemon); + ewram1C000.unk5 = gSprites[ewram01000.unk2].data0; + ewram1C000.pokemon = &gPlayerParty[ewram1C000.unk5]; + gTasks[taskId].data[10] = GetMonData(ewram1C000.pokemon, MON_DATA_MAX_HP); + gTasks[taskId].data[11] = GetMonData(ewram1C000.pokemon, MON_DATA_HP); + ewram1C000.unkC = -32768; + ewram1C000.unk14 = ewram1C000.unk10; + gTasks[taskId].func = sub_806F8AC; + ewram1B000.unk282 = gTasks[taskId].data[11]; + } + else + { + PartyMenuDoPrintHP(ewram1C000.unk5, IsDoubleBattle(), ewram1B000.unk282, sp0.unk0); + } +} + +void sub_806FB0C(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + gTasks[ewram1C000.unk4].func = ewram1C000.unk10; + DestroyTask(taskId); + } +} + +void sub_806FB44(u8 taskId) +{ + if (gUnknown_0202E8F6 == 0) + { + gTasks[ewram1C000.unk4].func = ewram1C000.unk14; + DestroyTask(taskId); + } +} + +bool8 IsHPRecoveryItem(u16 item) +{ + const u8 *itemEffect; + + if (item == 0xAF) + itemEffect = gSaveBlock1.enigmaBerry.itemEffect; + else + itemEffect = gItemEffectTable[item - 13]; + + if (itemEffect[4] & 4) + return TRUE; + else + return FALSE; +} + +void PartyMenuUpdateLevelOrStatus(struct Pokemon *pkmn, u8 b) +{ + PartyMenuClearLevelStatusTilemap(b); + PartyMenuPrintMonLevelOrStatus(b, pkmn); +} + +void GetMedicineItemEffectMessage(u16 item) +{ + switch (GetItemEffectType(item)) + { + case 3: + StringExpandPlaceholders(gStringVar4, gOtherText_CuredPoisoning); + break; + case 4: + StringExpandPlaceholders(gStringVar4, gOtherText_WokeUp); + break; + case 5: + StringExpandPlaceholders(gStringVar4, gOtherText_BurnHealed); + break; + case 6: + StringExpandPlaceholders(gStringVar4, gOtherText_ThawedOut); + break; + case 7: + StringExpandPlaceholders(gStringVar4, gOtherText_CuredParalysis); + break; + case 8: + StringExpandPlaceholders(gStringVar4, gOtherText_SnapConfusion); + break; + case 9: + StringExpandPlaceholders(gStringVar4, gOtherText_GotOverLove); + break; + case 11: + StringExpandPlaceholders(gStringVar4, gOtherText_BecameHealthy); + break; + case 13: + StringCopy(gStringVar2, gOtherText_Hp2); + StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised); + break; + case 12: + StringCopy(gStringVar2, gOtherText_Attack); + StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised); + break; + case 17: + StringCopy(gStringVar2, gOtherText_Defense); + StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised); + break; + case 16: + StringCopy(gStringVar2, gOtherText_Speed); + StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised); + break; + case 14: + StringCopy(gStringVar2, gOtherText_SpAtk2); + StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised); + break; + case 15: + StringCopy(gStringVar2, gOtherText_SpDef2); + StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised); + break; + case 19: + case 20: + StringExpandPlaceholders(gStringVar4, gOtherText_PPIncreased); + break; + case 21: + StringExpandPlaceholders(gStringVar4, gOtherText_PPRestored); + break; + default: + StringExpandPlaceholders(gStringVar4, gOtherText_WontHaveAnyEffect); + break; + } +} + +bool8 IsMedicineIneffective(struct Pokemon *pkmn, u16 item) +{ + if (GetItemEffectType(item) == 13 + && GetMonData(pkmn, MON_DATA_SPECIES) == SPECIES_SHEDINJA) + return TRUE; + else + return FALSE; +} + +bool8 ExecuteTableBasedItemEffect__(u8 a, u16 b, u8 c) +{ + if (gMain.inBattle) + return ExecuteTableBasedItemEffect_(&gPlayerParty[a], b, sub_8094C20(a), c); + else + return ExecuteTableBasedItemEffect_(&gPlayerParty[a], b, a, c); +} + +void UseMedicine(u8 taskId, u16 item, TaskFunc func) +{ + u8 r7; + bool8 r9 = FALSE; + bool8 r0; + + gTasks[taskId].func = TaskDummy; + r7 = CreateTask(TaskDummy, 5); + sub_806E8D0(taskId, item, func); + if (!IsMedicineIneffective(ewram1C000.pokemon, item)) + { + r9 = IsHPRecoveryItem(item); + if (r9 == TRUE) + { + gTasks[r7].data[10] = GetMonData(ewram1C000.pokemon, MON_DATA_MAX_HP); + gTasks[r7].data[11] = GetMonData(ewram1C000.pokemon, MON_DATA_HP); + if (gTasks[r7].data[10] == gTasks[r7].data[11]) + { + r9 = FALSE; + gTasks[r7].data[10] = 0; + gTasks[r7].data[11] = 0; + } + } + r0 = ExecuteTableBasedItemEffect__(ewram1C000.unk5, item, 0); + } + else + { + r0 = TRUE; + } + + if (r0) + { + gUnknown_0202E8F4 = 0; + PlaySE(SE_SELECT); + sub_806E834(gOtherText_WontHaveAnyEffect, 1); + gTasks[r7].func = sub_806FB0C; + } + else + { + u8 statusAndPkrs; + + gUnknown_0202E8F4 = 1; + if (!IsBlueYellowRedFlute(item)) + PlaySE(SE_KAIFUKU); + else + PlaySE(SE_BIDORO); + statusAndPkrs = GetMonStatusAndPokerus(ewram1C000.pokemon); + if (statusAndPkrs == 6 || statusAndPkrs == 0) + PartyMenuUpdateLevelOrStatus(ewram1C000.pokemon, ewram1C000.unk5); + if (r9 == TRUE) + { + gTasks[r7].data[12] = GetMonData(ewram1C000.pokemon, MON_DATA_HP) - gTasks[r7].data[11]; + ewram1C000.unkC = -32768; + if (gTasks[r7].data[11] == 0) + gTasks[r7].data[14] = 1; + else + gTasks[r7].data[14] = 0; + ewram1C000.unk14 = ewram1C000.unk10; + gTasks[r7].func = sub_806F8AC; + ewram1B000.unk282 = gTasks[r7].data[11]; + } + else + { + GetMonNickname(ewram1C000.pokemon, gStringVar1); + if (!IsBlueYellowRedFlute(item)) + RemoveBagItem(item, 1); + GetMedicineItemEffectMessage(item); + TryPrintPartyMenuMonNickname(ewram1C000.unk5, ewram1C000.pokemon); + sub_806E834(gStringVar4, 1); + gTasks[r7].func = sub_806FB0C; + } + } +} + +bool8 IsBlueYellowRedFlute(u16 item) +{ + if (item == 0x27 + || item == 0x29 + || item == 0x28) + return TRUE; + else + return FALSE; +} + +void sub_8070048(u8 taskId, u16 item, TaskFunc func) +{ + ewram1C000.unk10 = func; + ewram1C000.unk4 = taskId; + ewram1C000.unk6 = item; + ewram1C000.unk5 = 0; + ewram1C000.unk14 = sub_80701DC; + ewram1B000.unk27E = 0; + ewram1B000.unk280 = 0; + sub_8070088(taskId); +} + +void sub_8070088(u8 taskId) +{ + u8 taskId2; + + gTasks[taskId].func = TaskDummy; + if (GetMonData(&gPlayerParty[ewram1C000.unk5], MON_DATA_SPECIES) == 0) + { + gTasks[taskId].func = sub_80701DC; + } + else + { + s16 *taskData; + + taskId2 = CreateTask(TaskDummy, 5); + taskData = gTasks[taskId2].data; + ewram1C000.pokemon = &gPlayerParty[ewram1C000.unk5]; + taskData[10] = GetMonData(ewram1C000.pokemon, MON_DATA_MAX_HP); + taskData[11] = GetMonData(ewram1C000.pokemon, MON_DATA_HP); + if (ExecuteTableBasedItemEffect__(ewram1C000.unk5, ewram1C000.unk6, 0)) + { + DestroyTask(taskId2); + gTasks[taskId].func = sub_80701DC; + } + else + { + gUnknown_0202E8F4 = 1; + MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + PlaySE(SE_KAIFUKU); + PartyMenuUpdateLevelOrStatus(ewram1C000.pokemon, ewram1C000.unk5); + task_pc_turn_off(&gUnknown_083769A8[IsDoubleBattle() * 12 + ewram1C000.unk5 * 2], 9); + ewram1B000.unk261 = 2; + taskData[12] = GetMonData(ewram1C000.pokemon, MON_DATA_HP) - taskData[11]; + taskData[14] = 1; + ewram1B000.unk27E = 1; + ewram1B000.unk280 = 1; + ewram1B000.unk282 = taskData[11]; + ewram1C000.unkC = -32768; + gTasks[taskId2].func = sub_806F8AC; + } + } +} + +void sub_80701DC(u8 taskId) +{ + if (ewram1B000.unk27E == 1) + { + AddBagItem(ewram1C000.unk6, 1); + if (GetMonData(&gPlayerParty[ewram1C000.unk5], MON_DATA_SPECIES) != 0) + { + task_pc_turn_off(&gUnknown_083769A8[IsDoubleBattle() * 12 + ewram1C000.unk5 * 2], 3); + ewram1B000.unk261 = 2; + } + ewram1B000.unk27E = 0; + } + ewram1C000.unk5++; + if (ewram1C000.unk5 == 6) + { + gUnknown_0202E8F4 = 0; + if (ewram1B000.unk280 == 0) + { + gTasks[taskId].func = TaskDummy; + sub_806E834(gOtherText_WontHaveAnyEffect, 1); + CreateTask(sub_806FB0C, 8); + } + else + { + RemoveBagItem(ewram1C000.unk6, 1); + gTasks[taskId].func = ewram1C000.unk10; + } + gLastFieldPokeMenuOpened = 0; + } + else + { + sub_8070088(taskId); + } +} + +void CreateItemUseMoveMenu(u8 partyMonIndex) +{ + u8 r6; + u8 i; + + r6 = 0; + MenuDrawTextWindow(19, 10, 29, 19); + for (i = 0; i < 4; i++) + { + u16 move = GetMonData(&gPlayerParty[partyMonIndex], MON_DATA_MOVE1 + i); + + MenuPrint(gMoveNames[move], 20, i * 2 + 11); + if (move != 0) + r6++; + } + InitMenu(0, 20, 11, r6, 0, 9); +} + +void Task_HandleItemUseMoveMenuInput(u8 taskId) +{ + if (gMain.newKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + } + else if (gMain.newKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + } + else if (gMain.newKeys & A_BUTTON) + { + gUnknown_08376B54[0](taskId); + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + gUnknown_08376B54[1](taskId); + } +} + +void DoPPRecoveryItemEffect(u8 taskId, u16 b, TaskFunc c) +{ + const u8 *itemEffect; + u8 taskId2; + + if (b == 0xAF) + itemEffect = gSaveBlock1.enigmaBerry.itemEffect; + else + itemEffect = gItemEffectTable[b - 13]; + gTasks[taskId].func = TaskDummy; + taskId2 = CreateTask(TaskDummy, 5); + sub_806E8D0(taskId, b, c); + if (!(itemEffect[4] & 0x10)) + { + gTasks[taskId2].data[11] = 0; + DoRecoverPP(taskId2); + } + else + { + PlaySE(SE_SELECT); + sub_806D538(10, 3); + CreateItemUseMoveMenu(ewram1C000.unk5); + gTasks[taskId2].func = Task_HandleItemUseMoveMenuInput; + gMain.newKeys = 0; + } +} + +void ItemUseMoveMenu_HandleMoveSelection(u8 taskId) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(19, 10, 29, 19); + sub_806D5A4(); + gTasks[taskId].data[11] = GetMenuCursorPos(); + DoRecoverPP(taskId); +} + +void ItemUseMoveMenu_HandleCancel(u8 taskId) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(19, 10, 29, 19); + if (gMain.inBattle) + gTasks[ewram1C000.unk4].func = SetUpBattlePokemonMenu; + else + gTasks[ewram1C000.unk4].func = sub_808B0C0; + sub_806D538(3, 0); + DestroyTask(taskId); +} + +void DoRecoverPP(u8 taskId) +{ + u16 r5 = 0; + + if (ExecuteTableBasedItemEffect__(ewram1C000.unk5, ewram1C000.unk6, gTasks[taskId].data[11])) + { + gUnknown_0202E8F4 = r5; + PlaySE(SE_SELECT); + sub_806E834(gOtherText_WontHaveAnyEffect, 1); + } + else + { + gUnknown_0202E8F4 = 1; + PlaySE(SE_KAIFUKU); + RemoveBagItem(ewram1C000.unk6, 1); + r5 = GetMonData(ewram1C000.pokemon, MON_DATA_MOVE1 + gTasks[taskId].data[11]); + StringCopy(gStringVar1, gMoveNames[r5]); + GetMedicineItemEffectMessage(ewram1C000.unk6); + sub_806E834(gStringVar4, 1); + } + gTasks[taskId].func = sub_806FB0C; +} + +void DoPPUpItemEffect(u8 taskId, u16 b, TaskFunc c) +{ + gTasks[taskId].func = TaskDummy; + sub_806E8D0(taskId, b, c); + PlaySE(SE_SELECT); + sub_806D538(11, 3); + CreateItemUseMoveMenu(ewram1C000.unk5); + CreateTask(Task_HandleItemUseMoveMenuInput, 5); + gMain.newKeys = 0; +} + +void DoRareCandyItemEffect(u8 taskId, u16 b, TaskFunc c) +{ + u8 i; + bool8 r0; + + gTasks[taskId].func = TaskDummy; + sub_806E8D0(taskId, b, c); + + if (GetMonData(ewram1C000.pokemon, MON_DATA_LEVEL) != 100) + { + for (i = 0; i < 6; i++) + ewram1B000.unk264[i] = GetMonData(ewram1C000.pokemon, gUnknown_08376D1C[i]); + r0 = ExecuteTableBasedItemEffect__(ewram1C000.unk5, b, 0); + } + else + r0 = TRUE; + + if (r0) + { + gUnknown_0202E8F4 = 0; + PlaySE(SE_SELECT); + sub_806E834(gOtherText_WontHaveAnyEffect, 1); + CreateTask(sub_806FB0C, 5); + } + else + { + u8 level; + + gUnknown_0202E8F4 = 1; + PlayFanfareByFanfareNum(0); + sub_8070A20(ewram1C000.unk5, ewram1C000.pokemon); + RemoveBagItem(b, 1); + GetMonNickname(ewram1C000.pokemon, gStringVar1); + level = GetMonData(ewram1C000.pokemon, MON_DATA_LEVEL); + ConvertIntToDecimalStringN(gStringVar2, level, 0, 3); + StringExpandPlaceholders(gStringVar4, gOtherText_ElevatedTo); + sub_806E834(gStringVar4, 1); + CreateTask(Task_RareCandy1, 5); + } +} + +void Task_RareCandy1(u8 taskId) +{ + if (WaitFanfare(0) && gUnknown_0202E8F6 == 0) + { + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + { + PlaySE(SE_SELECT); + sub_8070848(taskId); + gTasks[taskId].func = Task_RareCandy2; + } + } +} + +void Task_RareCandy2(u8 taskId) +{ + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + { + PlaySE(SE_SELECT); + sub_8070968(taskId); + gTasks[taskId].func = Task_RareCandy3; + } +} + +#if ENGLISH +void sub_8070848(u8 taskId) +{ + u8 i; + + MenuDrawTextWindow(11, 0, 29, 7); + + for (i = 0; i < DATA_COUNT; i++) + { + u8 x; + u8 y; + u32 stat; + + stat = GetMonData(ewram1C000.pokemon, gUnknown_08376D1C[i]); + + ewram1B000.unk264[i + DATA_COUNT] = stat; + ewram1B000.unk264[i] = stat - ewram1B000.unk264[i]; + + x = (i / 3) * 9 + 11; + y = ((i % 3) << 1) + 1; + + MenuPrint_PixelCoords(gUnknown_08376D04[i], (x + 1) * 8, y * 8, 1); + + if (i == 2) + MenuPrint_PixelCoords(gOtherText_TallPlusAndRightArrow, (x + 6) * 8 + 6, y * 8, 0); + else + MenuPrint_PixelCoords(gOtherText_TallPlusAndRightArrow, (x + 6) * 8 + 6, y * 8, 1); + + gStringVar1[0] = EXT_CTRL_CODE_BEGIN; + gStringVar1[1] = 0x14; + gStringVar1[2] = 0x06; + + ConvertIntToDecimalStringN(gStringVar1 + 3, ewram1B000.unk264[i], 1, 2); + + MenuPrint_PixelCoords(gStringVar1, (x + 6) * 8 + 12, y * 8, 0); + } +} +#elif GERMAN +__attribute__((naked)) +void sub_8070848(u8 taskId) { + 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\ + movs r0, 0xB\n\ + movs r1, 0\n\ + movs r2, 0x1D\n\ + movs r3, 0x7\n\ + bl MenuDrawTextWindow\n\ + movs r7, 0\n\ + ldr r0, _0807092C @ =gStringVar1\n\ + mov r10, r0\n\ + movs r1, 0xFC\n\ + mov r9, r1\n\ + movs r2, 0x13\n\ + mov r8, r2\n\ +_0807086C:\n\ + ldr r1, _08070930 @ =0x0201c000\n\ + ldr r0, [r1]\n\ + ldr r1, _08070934 @ =gUnknown_08376D1C\n\ + adds r1, r7, r1\n\ + ldrb r1, [r1]\n\ + bl GetMonData\n\ + adds r1, r7, 0x6\n\ + lsls r1, 1\n\ + ldr r2, _08070938 @ =0x0201b264\n\ + adds r1, r2, r1\n\ + strh r0, [r1]\n\ + lsls r6, r7, 1\n\ + adds r6, r2, r6\n\ + ldrh r1, [r6]\n\ + subs r0, r1\n\ + strh r0, [r6]\n\ + adds r0, r7, 0\n\ + movs r1, 0x3\n\ + bl __udivsi3\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + lsls r4, r0, 3\n\ + adds r4, r0\n\ + adds r4, 0xB\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + adds r0, r7, 0\n\ + movs r1, 0x3\n\ + bl __umodsi3\n\ + adds r5, r0, 0\n\ + lsls r5, 1\n\ + adds r5, 0x1\n\ + lsls r5, 24\n\ + lsrs r5, 24\n\ + ldr r1, _0807093C @ =gUnknown_08376D04\n\ + lsls r0, r7, 2\n\ + adds r0, r1\n\ + ldr r1, [r0]\n\ + mov r0, r10\n\ + bl StringCopy\n\ + adds r2, r0, 0\n\ + mov r0, r9\n\ + strb r0, [r2]\n\ + adds r2, 0x1\n\ + mov r1, r8\n\ + strb r1, [r2]\n\ + adds r2, 0x1\n\ + movs r0, 0x2E\n\ + strb r0, [r2]\n\ + adds r2, 0x1\n\ + adds r0, r2, 0\n\ + ldr r1, _08070940 @ =gOtherText_TallPlusAndRightArrow\n\ + bl StringCopy\n\ + adds r2, r0, 0\n\ + mov r0, r9\n\ + strb r0, [r2]\n\ + adds r2, 0x1\n\ + mov r1, r8\n\ + strb r1, [r2]\n\ + adds r2, 0x1\n\ + movs r0, 0x34\n\ + strb r0, [r2]\n\ + adds r2, 0x1\n\ + movs r0, 0\n\ + ldrsh r1, [r6, r0]\n\ + adds r0, r2, 0\n\ + movs r2, 0x1\n\ + movs r3, 0x2\n\ + bl ConvertIntToDecimalStringN\n\ + adds r4, 0x1\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + mov r0, r10\n\ + adds r1, r4, 0\n\ + adds r2, r5, 0\n\ + bl MenuPrint\n\ + adds r0, r7, 0x1\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + cmp r7, 0x5\n\ + bls _0807086C\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\ + .align 2, 0\n\ +_0807092C: .4byte gStringVar1\n\ +_08070930: .4byte 0x0201c000\n\ +_08070934: .4byte gUnknown_08376D1C\n\ +_08070938: .4byte 0x0201b264\n\ +_0807093C: .4byte gUnknown_08376D04\n\ +_08070940: .4byte gOtherText_TallPlusAndRightArrow\n\ + .syntax divided\n"); +} +#endif diff --git a/src/player_pc.c b/src/player_pc.c new file mode 100644 index 000000000..9cb395432 --- /dev/null +++ b/src/player_pc.c @@ -0,0 +1,1371 @@ +#include "global.h" +#include "player_pc.h" +#include "decoration.h" +#include "field_fadetransition.h" +#include "field_weather.h" +#include "item.h" +#include "item_menu.h" +#include "items.h" +#include "main.h" +#include "menu.h" +#include "menu_helpers.h" +#include "palette.h" +#include "script.h" +#include "sound.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "songs.h" +#include "name_string_util.h" +#include "mail.h" +#include "rom4.h" +#include "player_pc.h" + +extern void DisplayItemMessageOnField(u8, const u8*, TaskFunc, u16); +extern void DoPlayerPCDecoration(u8); +extern void BuyMenuFreeMemory(void); +extern void DestroyVerticalScrollIndicator(u8); +extern void PauseVerticalScrollIndicator(u8); +extern void StartVerticalScrollIndicators(int); +extern void LoadScrollIndicatorPalette(void); +extern void ClearMailStruct(struct MailStruct *); +extern u8 sub_807D770(void); +extern void sub_808B020(void); +extern void sub_80A4164(u8 *, u16, enum StringConvertMode, u8); +extern void sub_80A418C(u16, enum StringConvertMode, int, int, int); +extern void sub_80A6A30(void); +extern void sub_80F944C(void); + +extern u8 *gPcItemMenuOptionOrder; +extern u8 gPcItemMenuOptionsNum; + +extern u8 gUnknown_02038561; + +// event scripts +extern u8 gBrendanHouse_TurnPCOff[]; +extern u8 gMayHouse_TurnPCOff[]; + +extern void (*gFieldCallback)(void); + +static void InitPlayerPCMenu(u8 taskId); +static void PlayerPCProcessMenuInput(u8 taskId); +static void InitItemStorageMenu(u8); +static void ItemStorageMenuPrint(const u8 *); +static void ItemStorageMenuProcessInput(u8); +static void ItemStorage_ProcessInput(u8); +static void ItemStorage_SetItemAndMailCount(u8); +static void ItemStorage_DoItemAction(u8); +static void ItemStorage_GoBackToPlayerPCMenu(u8); +static void ItemStorage_HandleQuantityRolling(u8); +static void ItemStorage_DoItemWithdraw(u8); +static void ItemStorage_DoItemToss(u8); +static void ItemStorage_HandleRemoveItem(u8); +static void ItemStorage_WaitPressHandleResumeProcessInput(u8); +static void ItemStorage_HandleResumeProcessInput(u8); +static void ItemStorage_DoItemSwap(u8, bool8); +static void ItemStorage_DrawItemList(u8); +static void ItemStorage_PrintItemPcResponse(u16); +static void ItemStorage_DrawBothListAndDescription(u8); +static void ItemStorage_GoBackToItemPCMenu(u8, u8); +static void ItemStorage_LoadPalette(void); +static u8 GetMailboxMailCount(void); +static void Mailbox_UpdateMailList(void); +static void Mailbox_DrawMailboxMenu(u8); +static void Mailbox_ProcessInput(u8); +static void Mailbox_CloseScrollIndicators(void); +static void Mailbox_PrintWhatToDoWithPlayerMailText(u8); +static void Mailbox_TurnOff(u8); +static void Mailbox_PrintMailOptions(u8); +static void Mailbox_MailOptionsProcessInput(u8); +static void Mailbox_FadeAndReadMail(u8); +static void Mailbox_ReturnToFieldFromReadMail(void); +static void Mailbox_DrawYesNoBeforeMove(u8); +static void Mailbox_DoGiveMailPokeMenu(u8); +static void Mailbox_NoPokemonForMail(u8); +static void Mailbox_Cancel(u8); +static void Mailbox_DrawMailMenuAndDoProcessInput(u8); +static void PlayerPC_ItemStorage(u8 taskId); +static void PlayerPC_Mailbox(u8 taskId); +static void PlayerPC_Decoration(u8 var); +static void PlayerPC_TurnOff(u8 taskId); +static void ItemStorage_Withdraw(u8); +static void ItemStorage_Deposit(u8); +static void ItemStorage_Toss(u8); +static void ItemStorage_Exit(u8); +static void ItemStorage_ResumeInputFromYesToss(u8); +static void ItemStorage_ResumeInputFromNoToss(u8); +static void Mailbox_DoMailMoveToBag(u8); +static void Mailbox_ReturnToInputAfterNo(u8); +static void Mailbox_DoMailRead(u8); +static void Mailbox_MoveToBag(u8); +static void Mailbox_Give(u8); +static void Mailbox_Cancel(u8); + +static const struct TextStruct gPCText_OptionDescList[] = +{ + PCText_TakeOutItems, + PCText_StoreItems, + PCText_ThrowAwayItems, + gMenuText_GoBackToPrev +}; + +static const struct MenuAction2 gPCText_PlayerPCOptionsText[] = +{ + { SecretBaseText_ItemStorage, PlayerPC_ItemStorage }, + { gPCText_Mailbox, PlayerPC_Mailbox }, + { SecretBaseText_Decoration, PlayerPC_Decoration }, + { SecretBaseText_TurnOff, PlayerPC_TurnOff } +}; + +static const u8 gBedroomPC_OptionOrder[] = +{ + PLAYERPC_MENU_ITEMSTORAGE, + PLAYERPC_MENU_MAILBOX, + PLAYERPC_MENU_DECORATION, + PLAYERPC_MENU_TURNOFF +}; + +static const u8 gPlayerPC_OptionOrder[] = +{ + PLAYERPC_MENU_ITEMSTORAGE, + PLAYERPC_MENU_MAILBOX, + PLAYERPC_MENU_TURNOFF +}; + +static const struct MenuAction2 gPCText_ItemPCOptionsText[] = +{ + { PCText_WithdrawItem, ItemStorage_Withdraw }, + { PCText_DepositItem, ItemStorage_Deposit }, + { PCText_TossItem, ItemStorage_Toss }, + { gUnknownText_Exit, ItemStorage_Exit } +}; + +static const struct YesNoFuncTable ResumeFromTossYesNoFuncList[] = // ResumeFromTossYesNoFuncList +{ + ItemStorage_ResumeInputFromYesToss, + ItemStorage_ResumeInputFromNoToss +}; + +static const struct YesNoFuncTable ResumeFromWithdrawYesNoFuncList[] = // ResumeFromWithdrawYesNoFuncList +{ + Mailbox_DoMailMoveToBag, + Mailbox_ReturnToInputAfterNo +}; + +// the use of this struct is meant to be an ItemSlot struct, but NewGameInitPCItems refuses to match without a weird pointer access. +static const struct ItemSlot gNewGamePCItems[] = +{ + { ITEM_POTION, 1 }, + { ITEM_NONE, 0 } +}; + +static const struct MenuAction2 gMailboxMailOptions[] = +{ + { OtherText_Read, Mailbox_DoMailRead }, + { gOtherText_MoveToBag, Mailbox_MoveToBag }, + { OtherText_Give, Mailbox_Give }, + { gOtherText_CancelNoTerminator, Mailbox_Cancel } +}; + +static const u8 gNonSelectedItemFormattedText[] = _("{STR_VAR_1}{CLEAR_TO 80}"); +static const u8 gSelectedItemFormattedText[] = _("{COLOR RED}{STR_VAR_1}{CLEAR_TO 80}"); +static const u8 gNonSelectedItemQuantityFormatText[] = _("{STR_VAR_1}"); +static const u8 gSelectedItemQuantityFormatText[] = _("{COLOR RED}{STR_VAR_1}"); +static const u8 gUnknown_08406330[] = _("{CLEAR_TO 32}"); + +static const u16 gUnknown_08406334[3] = +{ + 0x5294, + 0x6B5A, + 0x7FFF +}; + +static const u8 gHighlightedMoveToBagFormatText[] = _("{COLOR RED}{STR_VAR_1}"); + +extern u8 *gUnknown_02039314; +extern struct MenuAction gUnknown_08406298[]; + +extern u8 gUnknown_084062B8[]; +extern u8 gUnknown_084062BC[]; +extern u8 gUnknown_0840632A[]; +extern u8 gUnknown_08406327[]; +extern u8 gUnknown_0840631E[]; +extern u8 gUnknown_08406318[]; + +extern u8 gUnknown_030007B4; +extern u8 unk_201FE00[]; + +extern u8 gUnknown_08152850; +extern u8 gUnknown_08152C75; + +extern u32 gUnknown_08406288[]; +extern const struct MenuAction gUnknown_084062C0[]; +extern const struct YesNoFuncTable gUnknown_084062E0; + +void NewGameInitPCItems(void) +{ + u8 i; + + // because Game Freak don't know how to use a struct or a 2d array + for(i = 0, ClearItemSlots(gSaveBlock1.pcItems, ARRAY_COUNT(gSaveBlock1.pcItems)); NEW_GAME_PC_ITEMS(i, ITEM_ID) && NEW_GAME_PC_ITEMS(i, QUANTITY) && + AddPCItem(NEW_GAME_PC_ITEMS(i, ITEM_ID), NEW_GAME_PC_ITEMS(i, QUANTITY)) == TRUE; i++) + ; +} + +void BedroomPC(void) +{ + gPcItemMenuOptionOrder = (u8 *)gBedroomPC_OptionOrder; + gPcItemMenuOptionsNum = 4; + DisplayItemMessageOnField(CreateTask(TaskDummy, 0), gOtherText_WhatWillYouDo, InitPlayerPCMenu, 0); +} + +void PlayerPC(void) +{ + gPcItemMenuOptionOrder = (u8 *)gPlayerPC_OptionOrder; + gPcItemMenuOptionsNum = 3; + DisplayItemMessageOnField(CreateTask(TaskDummy, 0), gOtherText_WhatWillYouDo, InitPlayerPCMenu, 0); +} + +static void InitPlayerPCMenu(u8 taskId) +{ + MenuDrawTextWindow(0, 0, 10, gPcItemMenuOptionsNum * 2 + 1); + PrintMenuItemsReordered(1, 1, gPcItemMenuOptionsNum, (struct MenuAction *)gPCText_PlayerPCOptionsText, gPcItemMenuOptionOrder); + InitMenu(0, 1, 1, gPcItemMenuOptionsNum, 0, 9); + TASK.FUNC = PlayerPCProcessMenuInput; +} + +static void PlayerPCProcessMenuInput(u8 taskId) +{ + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + } + else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + } + else if (gMain.newKeys & A_BUTTON) + { + HandleDestroyMenuCursors(); + PlaySE(SE_SELECT); + gPCText_PlayerPCOptionsText[gPcItemMenuOptionOrder[GetMenuCursorPos()]].func(taskId); + } + else if (gMain.newKeys & B_BUTTON) + { + HandleDestroyMenuCursors(); + PlaySE(SE_SELECT); + gPCText_PlayerPCOptionsText[gPcItemMenuOptionsNum[gPcItemMenuOptionOrder - 1]].func(taskId); // run EXIT. + } +} + +void ReshowPlayerPC(u8 var) +{ + DisplayItemMessageOnField(var, gOtherText_WhatWillYouDo, InitPlayerPCMenu, 0); +} + +static void PlayerPC_ItemStorage(u8 taskId) +{ + InitItemStorageMenu(ITEMPC_MENU_WITHDRAW); + TASK.FUNC = ItemStorageMenuProcessInput; +} + +static void PlayerPC_Mailbox(u8 taskId) +{ + MenuZeroFillWindowRect(0, 0, 10, 9); + gMailboxInfo.count = GetMailboxMailCount(); + + if (gMailboxInfo.count == 0) + DisplayItemMessageOnField(taskId, gOtherText_NoMailHere, ReshowPlayerPC, 0); + else + { + gMailboxInfo.cursorPos = 0; + gMailboxInfo.itemsAbove = 0; + Mailbox_UpdateMailList(); + ItemStorage_SetItemAndMailCount(taskId); + Mailbox_DrawMailboxMenu(taskId); + TASK.FUNC = Mailbox_ProcessInput; + } +} + +static void PlayerPC_Decoration(u8 var) +{ + MenuZeroFillWindowRect(0, 0, 10, 9); + DoPlayerPCDecoration(var); +} + +static void PlayerPC_TurnOff(u8 taskId) +{ + if (gPcItemMenuOptionsNum == 4) // if the option count is 4, we are at the bedroom PC and not player PC, so do gender specific handling. + { + MenuZeroFillWindowRect(0, 0, 0x1D, 0x13); + + if (gSaveBlock2.playerGender == MALE) + ScriptContext1_SetupScript(gBrendanHouse_TurnPCOff); + else + ScriptContext1_SetupScript(gMayHouse_TurnPCOff); + } + else + { + MenuZeroFillWindowRect(0, 0, 10, 9); + EnableBothScriptContexts(); + } + DestroyTask(taskId); +} + +static void InitItemStorageMenu(u8 var) +{ + MenuZeroFillWindowRect(0, 0, 10, 9); + MenuDrawTextWindow(0, 0, 11, 9); + PrintMenuItems(1, 1, 4, (struct MenuAction *)gPCText_ItemPCOptionsText); + InitMenu(0, 1, 1, 4, var, 10); + ItemStorageMenuPrint(gPCText_OptionDescList[var].text); +} + +static void ItemStorageMenuPrint(const u8 *textPtr) +{ + MenuFillWindowRectWithBlankTile(2, 15, 27, 18); + MenuPrint(textPtr, 2, 15); +} + +static void ItemStorageMenuProcessInput(u8 var) +{ + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + ItemStorageMenuPrint(gPCText_OptionDescList[GetMenuCursorPos()].text); + } + else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + ItemStorageMenuPrint(gPCText_OptionDescList[GetMenuCursorPos()].text); + } + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + gPCText_ItemPCOptionsText[GetMenuCursorPos()].func(var); + } + else if (gMain.newKeys & B_BUTTON) + { + HandleDestroyMenuCursors(); + PlaySE(SE_SELECT); + gPCText_ItemPCOptionsText[ITEMPC_MENU_EXIT].func(var); + } +} + +static void Task_ItemStorage_Deposit(u8 taskId) +{ + if (!gPaletteFade.active) + { + sub_80A6A30(); + DestroyTask(taskId); + } +} + +static void ItemStorage_Deposit(u8 taskId) +{ + TASK.FUNC = Task_ItemStorage_Deposit; + fade_screen(1, 0); +} + +static void ItemStorage_HandleReturnToProcessInput(u8 taskId) +{ + if (sub_807D770() == TRUE) + TASK.FUNC = ItemStorageMenuProcessInput; +} + +void ItemStorage_ReturnToMenuAfterDeposit(void) +{ + MenuDisplayMessageBox(); + InitItemStorageMenu(ITEMPC_MENU_DEPOSIT); + CreateTask(ItemStorage_HandleReturnToProcessInput, 0); + pal_fill_black(); +} + +static void ItemStorage_Withdraw(u8 taskId) +{ + s16 *data = TASK.data; + + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 11, 9); + NUM_ITEMS = CountUsedPCItemSlots(); + + if (NUM_ITEMS != 0) + { + MenuZeroFillWindowRect(0, 14, 29, 19); + CURRENT_ITEM_STORAGE_MENU = ITEMPC_MENU_WITHDRAW; + PAGE_INDEX = 0; + ITEMS_ABOVE_TOP = 0; + ItemStorage_SetItemAndMailCount(taskId); + ItemStorage_GoBackToItemPCMenu(taskId, 0); + TASK.FUNC = ItemStorage_ProcessInput; + } + else + DisplayItemMessageOnField(taskId, gOtherText_NoItems, PlayerPC_ItemStorage, 0); +} + +static void ItemStorage_Toss(u8 taskId) +{ + s16 *data = TASK.data; + + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 11, 9); + NUM_ITEMS = CountUsedPCItemSlots(); + + if (NUM_ITEMS) + { + MenuZeroFillWindowRect(0, 14, 29, 19); + CURRENT_ITEM_STORAGE_MENU = ITEMPC_MENU_TOSS; + PAGE_INDEX = 0; + ITEMS_ABOVE_TOP = 0; + ItemStorage_SetItemAndMailCount(taskId); + ItemStorage_GoBackToItemPCMenu(taskId, 2); + TASK.FUNC = ItemStorage_ProcessInput; + } + else + DisplayItemMessageOnField(taskId, gOtherText_NoItems, PlayerPC_ItemStorage, 0); +} + +static void ItemStorage_Exit(u8 var) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 11, 9); + ReshowPlayerPC(var); +} + +static void ItemStorage_SetItemAndMailCount(u8 taskId) +{ + s16 *data = TASK.data; + + if (NUM_ITEMS > 7) // we have a full page, so set the num of page items appropriately. + NUM_PAGE_ITEMS = 8; + else + NUM_PAGE_ITEMS = NUM_ITEMS + 1; // there are not enough items to fill a full page; take the # of items and add 1 for the cancel button. + + if (gMailboxInfo.count > 7) + gMailboxInfo.pageItems = 8; + else + gMailboxInfo.pageItems = gMailboxInfo.count + 1; +} + +static void ItemStorage_ProcessInput(u8 taskId) +{ + s16 *data = TASK.data; + s16 trueIndex; + + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + if(PAGE_INDEX != 0) // did the cursor move physically upwards? + { + PlaySE(SE_SELECT); + PAGE_INDEX = MoveMenuCursor(-1); + trueIndex = ITEMS_ABOVE_TOP + PAGE_INDEX; + if (SWITCH_MODE_ACTIVE == FALSE) // are we not currently switching items? + { + if (trueIndex == NUM_ITEMS) // if the cursor is on top of cancel, print the go back to prev description. + { + ItemStorage_PrintItemPcResponse(ITEMPC_GO_BACK_TO_PREV); + } + else + { + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[trueIndex].itemId); + } + } + } + else // the page cursor is at the top. but we may not be at the top of the true index list, so do another check. + { + if (ITEMS_ABOVE_TOP == 0) // did the cursor not move due to being at the top of the list? + return; + + PlaySE(SE_SELECT); + ITEMS_ABOVE_TOP--; + ItemStorage_DrawBothListAndDescription(taskId); + + if (SWITCH_MODE_ACTIVE != FALSE) + MoveMenuCursor(0); // don't move the cursor. it's at the top of the page index, but not the true index. + } + } + else if(gMain.newAndRepeatedKeys & DPAD_DOWN) // _0813A306 + { + if(PAGE_INDEX != NUM_PAGE_ITEMS - 1) + { + PlaySE(SE_SELECT); + PAGE_INDEX = MoveMenuCursor(1); + trueIndex = ITEMS_ABOVE_TOP + PAGE_INDEX; + + if(SWITCH_MODE_ACTIVE != FALSE) + return; + + if (trueIndex == NUM_ITEMS) + ItemStorage_PrintItemPcResponse(ITEMPC_GO_BACK_TO_PREV); // probably further down + else + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[trueIndex].itemId); + } + else if(ITEMS_ABOVE_TOP + PAGE_INDEX != NUM_ITEMS) + { + PlaySE(SE_SELECT); + ITEMS_ABOVE_TOP++; + ItemStorage_DrawBothListAndDescription(taskId); + + if (SWITCH_MODE_ACTIVE != FALSE) + MoveMenuCursor(0); + } + } + else if(gMain.newKeys & SELECT_BUTTON) // _0813A3A0 + { + if (SWITCH_MODE_ACTIVE == FALSE) + { + if (PAGE_INDEX + ITEMS_ABOVE_TOP != NUM_ITEMS) // you cannot swap the Cancel button. + { + PlaySE(SE_SELECT); + SWITCH_MODE_ACTIVE = TRUE; + SWAP_ITEM_INDEX = ITEMS_ABOVE_TOP + PAGE_INDEX; + ItemStorage_PrintItemPcResponse(ITEMPC_SWITCH_WHICH_ITEM); + } + // _0813A3DC + ItemStorage_DrawItemList(taskId); + } + else // _0813A3E8 + { + PlaySE(SE_SELECT); + ItemStorage_DoItemSwap(taskId, FALSE); + ItemStorage_DrawBothListAndDescription(taskId); + } + } + else if(gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + if(SWITCH_MODE_ACTIVE == FALSE) + { + if(ITEMS_ABOVE_TOP + PAGE_INDEX != NUM_ITEMS) + { + ItemStorage_DoItemAction(taskId); + } + else + { + ItemStorage_GoBackToPlayerPCMenu(taskId); + } + } + else + { + ItemStorage_DoItemSwap(taskId, FALSE); + ItemStorage_DrawBothListAndDescription(taskId); + } + } + else if(gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + if(SWITCH_MODE_ACTIVE == FALSE) + { + HandleDestroyMenuCursors(); + ItemStorage_GoBackToPlayerPCMenu(taskId); + } + else + { + ItemStorage_DoItemSwap(taskId, TRUE); + ItemStorage_DrawBothListAndDescription(taskId); + } + } +} + +static void ItemStorage_GoBackToPlayerPCMenu(u8 taskId) +{ + BuyMenuFreeMemory(); + DestroyVerticalScrollIndicator(0); + DestroyVerticalScrollIndicator(1); + MenuZeroFillWindowRect(0, 0, 29, 19); + MenuDisplayMessageBox(); + InitItemStorageMenu(TASK.CURRENT_ITEM_STORAGE_MENU); + TASK.FUNC = ItemStorageMenuProcessInput; +} + +static void ItemStorage_DoItemAction(u8 taskId) +{ + s16 *data = TASK.data; + u8 trueIndex = PAGE_INDEX + ITEMS_ABOVE_TOP; + + PauseVerticalScrollIndicator(0); + PauseVerticalScrollIndicator(1); // PauseVerticalScrollIndicator + + if(CURRENT_ITEM_STORAGE_MENU == ITEMPC_MENU_WITHDRAW) + { + if(gSaveBlock1.pcItems[trueIndex].quantity == 1) + { + NUM_QUANTITY_ROLLER = 1; + ItemStorage_DoItemWithdraw(taskId); + return; + } + else // _0813A50C + { + ItemStorage_PrintItemPcResponse(ITEMPC_HOW_MANY_TO_WITHDRAW); + } + } + else if(gSaveBlock1.pcItems[trueIndex].quantity == 1) // _0813A518 + { + NUM_QUANTITY_ROLLER = 1; + ItemStorage_DoItemToss(taskId); + return; + } + else + { + ItemStorage_PrintItemPcResponse(ITEMPC_HOW_MANY_TO_TOSS); + } + NUM_QUANTITY_ROLLER = 1; + MenuDrawTextWindow(6, 8, 13, 11); + sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); + TASK.FUNC = ItemStorage_HandleQuantityRolling; +} + +static void ItemStorage_HandleQuantityRolling(u8 taskId) +{ + s16 *data = TASK.data; + u8 trueIndex = PAGE_INDEX + ITEMS_ABOVE_TOP; + + if(gMain.newAndRepeatedKeys & DPAD_UP) + { + if(NUM_QUANTITY_ROLLER != gSaveBlock1.pcItems[trueIndex].quantity) + NUM_QUANTITY_ROLLER++; + else + NUM_QUANTITY_ROLLER = 1; // you are at the max amount of items you have when you press Up, set your quantity back to 1. + + sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? + } + else if(gMain.newAndRepeatedKeys & DPAD_DOWN) + { + if(NUM_QUANTITY_ROLLER != 1) + NUM_QUANTITY_ROLLER--; + else + NUM_QUANTITY_ROLLER = gSaveBlock1.pcItems[trueIndex].quantity; // you are at 0 when you press down, set your quantity to the amount you have. + + sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? + } + else if(gMain.newAndRepeatedKeys & DPAD_LEFT) // reduce by 10. + { + NUM_QUANTITY_ROLLER -= 10; + + if(NUM_QUANTITY_ROLLER <= 0) + NUM_QUANTITY_ROLLER = 1; // dont underflow or allow 0! + + sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? + } + else if(gMain.newAndRepeatedKeys & DPAD_RIGHT) // add 10. + { + NUM_QUANTITY_ROLLER += 10; + + if(NUM_QUANTITY_ROLLER > gSaveBlock1.pcItems[trueIndex].quantity) + NUM_QUANTITY_ROLLER = gSaveBlock1.pcItems[trueIndex].quantity; // dont overflow! + + sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? + } + else if(gMain.newKeys & A_BUTTON) // confirm quantity. + { + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(6, 6, 0xD, 0xB); + + if(CURRENT_ITEM_STORAGE_MENU == ITEMPC_MENU_WITHDRAW) + ItemStorage_DoItemWithdraw(taskId); + else + ItemStorage_DoItemToss(taskId); + } + else if(gMain.newKeys & B_BUTTON) // cancel quantity. + { + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(6, 6, 0xD, 0xB); + StartVerticalScrollIndicators(0); + StartVerticalScrollIndicators(1); + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); // why not use trueIndex? + TASK.FUNC = ItemStorage_ProcessInput; + } +} + +static void ItemStorage_DoItemWithdraw(u8 taskId) +{ + s16 *data = TASK.data; + u8 trueIndex = PAGE_INDEX + ITEMS_ABOVE_TOP; + + if(AddBagItem(gSaveBlock1.pcItems[trueIndex].itemId, NUM_QUANTITY_ROLLER) == TRUE) // add item works. + { + CopyItemName(gSaveBlock1.pcItems[trueIndex].itemId, gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, NUM_QUANTITY_ROLLER, 0, 3); + ItemStorage_PrintItemPcResponse(ITEMPC_WITHDREW_THING); + TASK.FUNC = ItemStorage_HandleRemoveItem; + } + else + { + NUM_QUANTITY_ROLLER = 0; + ItemStorage_PrintItemPcResponse(ITEMPC_NO_MORE_ROOM); + TASK.FUNC = ItemStorage_WaitPressHandleResumeProcessInput; + } +} + +static void ItemStorage_DoItemToss(u8 taskId) +{ + s16 *data = TASK.data; + u8 var = PAGE_INDEX + ITEMS_ABOVE_TOP; + + if(ItemId_GetImportance(gSaveBlock1.pcItems[var].itemId) == FALSE) + { + CopyItemName(gSaveBlock1.pcItems[var].itemId, gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, NUM_QUANTITY_ROLLER, 0, 3); + ItemStorage_PrintItemPcResponse(ITEMPC_OKAY_TO_THROW_AWAY); + DisplayYesNoMenu(7, 6, 1); + DoYesNoFuncWithChoice(taskId, (struct YesNoFuncTable *)&ResumeFromTossYesNoFuncList); + } + else + { + NUM_QUANTITY_ROLLER = 0; + ItemStorage_PrintItemPcResponse(ITEMPC_TOO_IMPORTANT); + TASK.FUNC = ItemStorage_HandleRemoveItem; + } +} + +static void ItemStorage_ResumeInputFromYesToss(u8 taskId) +{ + MenuZeroFillWindowRect(0x6, 0x6, 0xD, 0xB); + ItemStorage_PrintItemPcResponse(ITEMPC_THREW_AWAY_ITEM); + TASK.FUNC = ItemStorage_HandleRemoveItem; +} + +static void ItemStorage_ResumeInputFromNoToss(u8 taskId) +{ + s16 *data = TASK.data; + + MenuZeroFillWindowRect(0x6, 0x6, 0xD, 0xB); + InitMenu(0, 16, 2, NUM_PAGE_ITEMS, PAGE_INDEX, 0xD); + StartVerticalScrollIndicators(0); + StartVerticalScrollIndicators(1); + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); + TASK.FUNC = ItemStorage_ProcessInput; +} + +static void ItemStorage_HandleRemoveItem(u8 taskId) +{ + s16 *data = TASK.data; + s16 oldNumItems; + + if(gMain.newKeys & A_BUTTON || gMain.newKeys == B_BUTTON) + { + RemovePCItem(PAGE_INDEX + ITEMS_ABOVE_TOP, NUM_QUANTITY_ROLLER); + oldNumItems = NUM_ITEMS; + NUM_ITEMS = CountUsedPCItemSlots(); + + if(oldNumItems != NUM_ITEMS && oldNumItems < NUM_PAGE_ITEMS + ITEMS_ABOVE_TOP && ITEMS_ABOVE_TOP != 0) + ITEMS_ABOVE_TOP--; + + ItemStorage_SetItemAndMailCount(taskId); + ItemStorage_HandleResumeProcessInput(taskId); + InitMenu(0, 16, 2, NUM_PAGE_ITEMS, PAGE_INDEX, 0xD); + } +} + +static void ItemStorage_WaitPressHandleResumeProcessInput(u8 taskId) +{ + s16 *data = TASK.data; + + if(gMain.newKeys & A_BUTTON || gMain.newKeys == B_BUTTON) + { + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); + StartVerticalScrollIndicators(0); + StartVerticalScrollIndicators(1); + TASK.FUNC = ItemStorage_ProcessInput; + } +} + +static void ItemStorage_HandleResumeProcessInput(u8 taskId) +{ + MenuZeroFillWindowRect(0x6, 0x6, 0xD, 0xB); + StartVerticalScrollIndicators(0); + StartVerticalScrollIndicators(1); + ItemStorage_DrawBothListAndDescription(taskId); + TASK.FUNC = ItemStorage_ProcessInput; +} + +static void ItemStorage_DoItemSwap(u8 taskId, bool8 switchModeDisabled) +{ + s16 *data = TASK.data; + u8 trueIndex = ITEMS_ABOVE_TOP + PAGE_INDEX; + + SWITCH_MODE_ACTIVE = FALSE; + + if((u8)NUM_ITEMS > trueIndex && (u8)SWAP_ITEM_INDEX != trueIndex && switchModeDisabled == FALSE) + { + struct ItemSlot itemSlot = gSaveBlock1.pcItems[SWAP_ITEM_INDEX]; // backup the itemSlot before swapping the two. + + gSaveBlock1.pcItems[SWAP_ITEM_INDEX] = gSaveBlock1.pcItems[trueIndex]; + gSaveBlock1.pcItems[trueIndex] = itemSlot; + return; + } + else if(trueIndex == NUM_ITEMS) + { + ItemStorage_PrintItemPcResponse(ITEMPC_GO_BACK_TO_PREV); + } + else + { + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[trueIndex].itemId); + } + + /* + THEORY: This check produces essentially dead code, but it might have been working in an earlier build + in which case it allows a programmer to easily duplicate items without the use of a debug menu. + This gets the page index of the swap index for some reason. It is currently unknown what it would have been used + for, but perhaps it was used to increase the quantity of the item without a debug menu. + With the removal of a lot of the debug menus close to release, a programmer may have added this to + help test things with a low key (such as planting a lot of duplicated berries, which requires this lazy "cheat") + without bringing the relevent debug menus back. The commented out line is intentionally left in below to show + what it may have looked like. + */ + if(SWAP_ITEM_INDEX - ITEMS_ABOVE_TOP <= 0) { // this check is arbitrary and used to generate the correct assembly using the subtraction, which is what matters. the 0 check doesn't. + //gSaveBlock1.pcItems[SWAP_ITEM_INDEX].quantity += 100; + gSaveBlock1.pcItems[SWAP_ITEM_INDEX].quantity += 0; // do not enforce item cap. + } +} + +static void ItemStorage_DrawItemQuantity(u16 arg1, enum StringConvertMode arg2, u8 arg3, u8 arg4, int isSwapSelected) +{ + sub_80A4164(gStringVar1, arg1, arg2, arg4); + + if(isSwapSelected != FALSE) + MenuPrint(gSelectedItemQuantityFormatText, 0x1A, arg3); + else + MenuPrint(gNonSelectedItemQuantityFormatText, 0x1A, arg3); +} + +static void ItemStorage_DrawItemVoidQuantity(u8 var) +{ + MenuPrint(gUnknown_08406330, 0x19, var); +} + +static void ItemStorage_DrawItemName(struct ItemSlot *itemSlot, u8 var, int isSwapSelected) +{ + CopyItemName(itemSlot->itemId, gStringVar1); + + if(isSwapSelected != FALSE) + MenuPrint(gSelectedItemFormattedText, 16, var); + else + MenuPrint(gNonSelectedItemFormattedText, 16, var); +} + +static void ItemStorage_DrawNormalItemEntry(struct ItemSlot *itemSlot, u8 var, int var2) +{ + ItemStorage_DrawItemName(itemSlot, var, var2); + ItemStorage_DrawItemQuantity(itemSlot->quantity, STR_CONV_MODE_RIGHT_ALIGN, var, 3, var2); +} + +static void ItemStorage_DrawKeyItemEntry(struct ItemSlot *itemSlot, u8 var, int var2) +{ + ItemStorage_DrawItemName(itemSlot, var, var2); + ItemStorage_DrawItemVoidQuantity(var); +} + +static void ItemStorage_DrawTMHMEntry(struct ItemSlot *itemSlot, u8 var, int var2) +{ + ItemStorage_DrawItemName(itemSlot, var, var2); + + if(itemSlot->itemId < ITEM_HM01) + ItemStorage_DrawItemQuantity(itemSlot->quantity, STR_CONV_MODE_RIGHT_ALIGN, var, 3, var2); + else + ItemStorage_DrawItemVoidQuantity(var); // HMs do not have a quantity. +} + +static void ItemStorage_DrawItemList(u8 taskId) +{ + s16 *data = TASK.data; + int tempArg; + u16 i; + u16 yCoord = 0; + + // r5 is i and is unsigned 16-bit. + + for(i = ITEMS_ABOVE_TOP; i < ITEMS_ABOVE_TOP + NUM_PAGE_ITEMS; i++) + { + yCoord = (i - ITEMS_ABOVE_TOP) * 2; + + if(i != NUM_ITEMS) + { + tempArg = 0; + + if(SWITCH_MODE_ACTIVE != FALSE && i == SWAP_ITEM_INDEX) + tempArg = 1; + + switch(GetPocketByItemId(gSaveBlock1.pcItems[i].itemId) - 1) + { + case 0: + case 1: + case 3: + ItemStorage_DrawNormalItemEntry((struct ItemSlot *)&gSaveBlock1.pcItems[i], yCoord + 2, tempArg); + break; + case 4: + ItemStorage_DrawKeyItemEntry((struct ItemSlot *)&gSaveBlock1.pcItems[i], yCoord + 2, tempArg); + break; + case 2: + ItemStorage_DrawTMHMEntry((struct ItemSlot *)&gSaveBlock1.pcItems[i], yCoord + 2, tempArg); + break; + } + } + else + { + goto weirdCase; // what??? + } + } + +beforeLabel: + if(i - ITEMS_ABOVE_TOP < 8) + MenuFillWindowRectWithBlankTile(16, yCoord + 4, 0x1C, 0x12); + + switch(ITEMS_ABOVE_TOP) + { + default: + CreateVerticalScrollIndicators(0, 0xB8, 8); + break; +weirdCase: + sub_8072A18(gOtherText_CancelNoTerminator, 0x80, (yCoord + 2) * 8, 0x68, 1); + goto beforeLabel; + case 0: + DestroyVerticalScrollIndicator(0); + break; + } + + if(ITEMS_ABOVE_TOP + NUM_PAGE_ITEMS <= NUM_ITEMS) + CreateVerticalScrollIndicators(1, 0xB8, 0x98); + else + DestroyVerticalScrollIndicator(1); +} + +static void ItemStorage_PrintItemPcResponse(u16 itemId) +{ + u8 *string; + + switch(itemId) + { + case ITEMPC_GO_BACK_TO_PREV: + string = (u8 *)gMenuText_GoBackToPrev; + break; + case ITEMPC_HOW_MANY_TO_WITHDRAW: + string = (u8 *)gOtherText_HowManyToWithdraw; + break; + case ITEMPC_WITHDREW_THING: + string = (u8 *)gOtherText_WithdrewThing; + break; + case ITEMPC_HOW_MANY_TO_TOSS: + string = (u8 *)gOtherText_HowManyToToss; + break; + case ITEMPC_THREW_AWAY_ITEM: + string = (u8 *)gOtherText_ThrewAwayItem; + break; + case ITEMPC_NO_MORE_ROOM: + string = (u8 *)gOtherText_NoMoreRoom; + break; + case ITEMPC_TOO_IMPORTANT: + string = (u8 *)gOtherText_TooImportant; + break; + case ITEMPC_OKAY_TO_THROW_AWAY: + string = (u8 *)gOtherText_OkayToThrowAwayPrompt; + break; + case ITEMPC_SWITCH_WHICH_ITEM: + string = (u8 *)gOtherText_SwitchWhichItem; + break; + default: + string = ItemId_GetDescription(itemId); + break; + } + + sub_8072AB0(string, 8, 0x68, 0x68, 0x30, 1); +} + +static void ItemStorage_DrawBothListAndDescription(u8 taskId) +{ + s16 *data = TASK.data; + s16 trueIndex = ITEMS_ABOVE_TOP + PAGE_INDEX; + + ItemStorage_DrawItemList(taskId); + + if(SWITCH_MODE_ACTIVE == FALSE) + { + if(trueIndex == NUM_ITEMS) + ItemStorage_PrintItemPcResponse(ITEMPC_GO_BACK_TO_PREV); + else + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[trueIndex].itemId); + } +} + +static void ItemStorage_GoBackToItemPCMenu(u8 taskId, u8 var) +{ + s16 *data = TASK.data; + + sub_80F944C(); + LoadScrollIndicatorPalette(); + ItemStorage_LoadPalette(); + MenuDrawTextWindow(0xF, 0, 0x1D, 0x13); + MenuDrawTextWindow(0, 0xC, 0xE, 0x13); + MenuDrawTextWindow(0, 0, 0xB, 3); + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[0].itemId); + MenuPrint(gPCText_ItemPCOptionsText[var].text, 1, 1); + ItemStorage_DrawItemList(taskId); + InitMenu(0, 0x10, 2, NUM_PAGE_ITEMS, PAGE_INDEX, 0xD); +} + +static void ItemStorage_LoadPalette(void) +{ + u16 arr[3]; + + memcpy(arr, gUnknown_08406334, sizeof(arr)); + LoadPalette(&arr[2], 0xDF, 2); + LoadPalette(&arr[1], 0xD1, 2); + LoadPalette(&arr[0], 0xD8, 2); +} + +static u8 GetMailboxMailCount(void) +{ + u8 i, j; + + for(i = 0, j = 6; j < 16; j++) + if(gSaveBlock1.mail[j].itemId != 0) + i++; + + return i; +} + +static void Mailbox_UpdateMailList(void) +{ + struct MailStruct mailBuffer; + u8 i, j; + + for (i=6; i<15; i++) + { + for (j=i+1; j<16; j++) + { + if (gSaveBlock1.mail[i].itemId == 0) + { + mailBuffer = gSaveBlock1.mail[i]; + gSaveBlock1.mail[i] = gSaveBlock1.mail[j]; + gSaveBlock1.mail[j] = mailBuffer; + } + } + } +} + +// WWHHHHHYYYYYYYY SOMEBODY PLEASE FIX THIS +static void Mailbox_DrawMailList(u8 taskId) // taskId is unused +{ + u16 yCoord = 0; + u16 i = gMailboxInfo.itemsAbove; + register struct MailboxStruct *tempMailbox asm("r1") = &gMailboxInfo; + register struct MailboxStruct *mailbox asm("r6"); + + if(i < i + tempMailbox->pageItems) + { + mailbox = tempMailbox; + goto forJump; + for(; i < mailbox->itemsAbove + mailbox->pageItems; i++) + { + forJump: + yCoord = (i - mailbox->itemsAbove) * 2; + MenuFillWindowRectWithBlankTile(0x15, yCoord + 2, 0x1C, yCoord + 3); + + if(i != mailbox->count) + { + StringCopy(gStringVar1, (u8 *)gSaveBlock1.mail[i + 6].playerName); + SanitizeNameString(gStringVar1); + MenuPrint(gStringVar1, 0x15, yCoord + 2); + } + else + { + goto weirdCase; // again, what??? + } + } + } + +beforeLabel: + if(i - gMailboxInfo.itemsAbove != 8) + MenuFillWindowRectWithBlankTile(0x15, yCoord + 4, 0x1C, 0x12); + + switch(gMailboxInfo.itemsAbove) + { + default: + CreateVerticalScrollIndicators(0, 0xC8, 8); + break; +weirdCase: + MenuPrint(gOtherText_CancelNoTerminator, 0x15, yCoord + 2); + goto beforeLabel; + case 0: + DestroyVerticalScrollIndicator(0); + break; + } + + if(gMailboxInfo.itemsAbove + gMailboxInfo.pageItems <= gMailboxInfo.count) + CreateVerticalScrollIndicators(1, 0xC8, 0x98); + else + DestroyVerticalScrollIndicator(1); +} + +static void Mailbox_DrawMailboxMenu(u8 taskId) +{ + sub_80F944C(); + LoadScrollIndicatorPalette(); + MenuZeroFillWindowRect(0, 0, 0x1D, 0x13); + MenuDrawTextWindow(0, 0, 0x8, 0x3); + MenuPrint(gPCText_Mailbox, 1, 1); + MenuDrawTextWindow(0x14, 0, 0x1D, 0x13); + Mailbox_DrawMailList(taskId); + InitMenu(0, 0x15, 2, gMailboxInfo.pageItems, gMailboxInfo.cursorPos, 8); +} + +// Mailbox_ProcessInput +static void Mailbox_ProcessInput(u8 taskId) +{ + if(!gPaletteFade.active) + { + if(gMain.newAndRepeatedKeys & DPAD_UP) + { + if(gMailboxInfo.cursorPos != 0) + { + PlaySE(SE_SELECT); + gMailboxInfo.cursorPos = MoveMenuCursor(-1); + } + else if(gMailboxInfo.itemsAbove != 0) + { + PlaySE(SE_SELECT); + gMailboxInfo.itemsAbove--; + Mailbox_DrawMailList(taskId); + } + } + else if(gMain.newAndRepeatedKeys & DPAD_DOWN) + { + if(gMailboxInfo.cursorPos != gMailboxInfo.pageItems - 1) + { + PlaySE(SE_SELECT); + gMailboxInfo.cursorPos = MoveMenuCursor(1); + } + else if(gMailboxInfo.itemsAbove + gMailboxInfo.cursorPos != gMailboxInfo.count) + { + PlaySE(SE_SELECT); + gMailboxInfo.itemsAbove++; + Mailbox_DrawMailList(taskId); + } + } + else if(gMain.newKeys & A_BUTTON) + { + HandleDestroyMenuCursors(); + PlaySE(SE_SELECT); + + if(gMailboxInfo.itemsAbove + gMailboxInfo.cursorPos == gMailboxInfo.count) + { + Mailbox_TurnOff(taskId); + } + else + { + Mailbox_CloseScrollIndicators(); + TASK.FUNC = Mailbox_PrintWhatToDoWithPlayerMailText; + } + } + else if(gMain.newKeys & B_BUTTON) + { + HandleDestroyMenuCursors(); + PlaySE(SE_SELECT); + Mailbox_TurnOff(taskId); + } + } +} + +static void Mailbox_CloseScrollIndicators(void) +{ + BuyMenuFreeMemory(); + DestroyVerticalScrollIndicator(0); + DestroyVerticalScrollIndicator(1); +} + +static void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId) +{ + MenuZeroFillWindowRect(0, 0, 0x1D, 0x13); + StringCopy(gStringVar1, gSaveBlock1.mail[gMailboxInfo.itemsAbove + 6 + gMailboxInfo.cursorPos].playerName); + SanitizeNameString(gStringVar1); + StringExpandPlaceholders(gStringVar4, gOtherText_WhatWillYouDoMail); + DisplayItemMessageOnField(taskId, gStringVar4, Mailbox_PrintMailOptions, 0); +} + +static void Mailbox_ReturnToPlayerPC(u8 taskId) +{ + MenuZeroFillWindowRect(0, 0, 0x1D, 0x13); + ReshowPlayerPC(taskId); +} + +static void Mailbox_TurnOff(u8 taskId) +{ + Mailbox_CloseScrollIndicators(); + TASK.FUNC = Mailbox_ReturnToPlayerPC; +} + +static void Mailbox_PrintMailOptions(u8 taskId) // Mailbox_PrintMailOptions +{ + MenuDrawTextWindow(0, 0, 0xC, 0x9); + PrintMenuItems(1, 1, 4, (struct MenuAction *)gMailboxMailOptions); + InitMenu(0, 1, 1, 4, 0, 0xB); + TASK.FUNC = Mailbox_MailOptionsProcessInput; +} + +static void Mailbox_MailOptionsProcessInput(u8 taskId) +{ + if(gMain.newAndRepeatedKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + } + else if(gMain.newAndRepeatedKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + } + else if(gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + gMailboxMailOptions[GetMenuCursorPos()].func(taskId); + } + else if(gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + Mailbox_Cancel(taskId); + } +} + +static void Mailbox_DoMailRead(u8 taskId) +{ + fade_screen(1, 0); + TASK.FUNC = Mailbox_FadeAndReadMail; +} + +static void Mailbox_FadeAndReadMail(u8 taskId) +{ + if(!gPaletteFade.active) + { + HandleReadMail(&gSaveBlock1.mail[gMailboxInfo.itemsAbove + 6 + gMailboxInfo.cursorPos], Mailbox_ReturnToFieldFromReadMail, 1); + DestroyTask(taskId); + } +} + +static void Mailbox_HandleReturnToProcessInput(u8 taskId) // Mailbox_HandleReturnToProcessInput +{ + if(sub_807D770() == TRUE) // is black fade finished? why not gPaletteFade.active? + TASK.FUNC = Mailbox_ProcessInput; +} + +static void Mailbox_DoRedrawMailboxMenuAfterReturn(void) +{ + Mailbox_DrawMailboxMenu(CreateTask(Mailbox_HandleReturnToProcessInput, 0)); + pal_fill_black(); +} + +static void Mailbox_ReturnToFieldFromReadMail(void) +{ + gFieldCallback = Mailbox_DoRedrawMailboxMenuAfterReturn; + SetMainCallback2(c2_exit_to_overworld_2_switch); +} + +static void Mailbox_MoveToBag(u8 taskId) +{ + HandleDestroyMenuCursors(); + StringCopy(gStringVar1, gOtherText_MoveToBag); + MenuPrint(gHighlightedMoveToBagFormatText, 1, 3); // gHighlightedMoveToBagFormatText + DisplayItemMessageOnField(taskId, gOtherText_MessageWillBeLost, Mailbox_DrawYesNoBeforeMove, 0); +} + +static void Mailbox_DrawYesNoBeforeMove(u8 taskId) +{ + DisplayYesNoMenu(0x14, 0x8, 0x1); + DoYesNoFuncWithChoice(taskId, (struct YesNoFuncTable *)&ResumeFromWithdrawYesNoFuncList); +} + +static void Mailbox_DoMailMoveToBag(u8 taskId) +{ + struct MailStruct *mail = &gSaveBlock1.mail[gMailboxInfo.itemsAbove + 6 + gMailboxInfo.cursorPos]; + + MenuZeroFillWindowRect(0x14, 8, 0x1A, 0xD); + + if(AddBagItem(mail->itemId, 1) == FALSE) + { + DisplayItemMessageOnField(taskId, gOtherText_BagIsFull, Mailbox_DrawMailMenuAndDoProcessInput, 0); + } + else + { + DisplayItemMessageOnField(taskId, gOtherText_MailWasReturned, Mailbox_DrawMailMenuAndDoProcessInput, 0); + ClearMailStruct(mail); + Mailbox_UpdateMailList(); + + gMailboxInfo.count--; + + if(gMailboxInfo.count < gMailboxInfo.pageItems + gMailboxInfo.itemsAbove && gMailboxInfo.itemsAbove != 0) + gMailboxInfo.itemsAbove--; + + ItemStorage_SetItemAndMailCount(taskId); + } +} + +static void Mailbox_ReturnToInputAfterNo(u8 taskId) // Mailbox_ReturnToInputAfterNo +{ + MenuZeroFillWindowRect(0x14, 0x8, 0x1A, 0xD); + Mailbox_DrawMailMenuAndDoProcessInput(taskId); +} + +static void Mailbox_Give(u8 taskId) +{ + if(CalculatePlayerPartyCount() == 0) + Mailbox_NoPokemonForMail(taskId); // cannot be reached normally + else + { + fade_screen(1, 0); + TASK.FUNC = Mailbox_DoGiveMailPokeMenu; + } +} + +static void Mailbox_DoGiveMailPokeMenu(u8 taskId) // Mailbox_DoGiveMailPokeMenu +{ + if(!gPaletteFade.active) + { + SetMainCallback2(sub_808B020); + gUnknown_02038561 = 3; + DestroyTask(taskId); + } +} + +static void Mailbox_UpdateMailListAfterDeposit(void) +{ + u8 taskId = CreateTask(Mailbox_HandleReturnToProcessInput, 0); + u8 oldCount = gMailboxInfo.count; + + gMailboxInfo.count = GetMailboxMailCount(); + Mailbox_UpdateMailList(); + + if(oldCount != gMailboxInfo.count && gMailboxInfo.count < gMailboxInfo.pageItems + gMailboxInfo.itemsAbove && gMailboxInfo.itemsAbove != 0) // did the count update? + gMailboxInfo.itemsAbove--; + + ItemStorage_SetItemAndMailCount(taskId); + Mailbox_DrawMailboxMenu(taskId); + pal_fill_black(); +} + +void Mailbox_ReturnToMailListAfterDeposit(void) +{ + gFieldCallback = Mailbox_UpdateMailListAfterDeposit; + SetMainCallback2(c2_exit_to_overworld_2_switch); +} + +// you always have at least 1 POKeMON and you cannot receive mail before you leave Littleroot: therefore this function cannot be reached normally. +static void Mailbox_NoPokemonForMail(u8 taskId) +{ + DisplayItemMessageOnField(taskId, gOtherText_NoPokemon, Mailbox_DrawMailMenuAndDoProcessInput, 0); +} + +static void Mailbox_Cancel(u8 taskId) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 0xC, 0x9); + Mailbox_DrawMailMenuAndDoProcessInput(taskId); +} + +static void Mailbox_DrawMailMenuAndDoProcessInput(u8 taskId) +{ + Mailbox_DrawMailboxMenu(taskId); + TASK.FUNC = Mailbox_ProcessInput; +} diff --git a/src/pokeball.c b/src/pokeball.c new file mode 100644 index 000000000..ee3b95678 --- /dev/null +++ b/src/pokeball.c @@ -0,0 +1,1193 @@ +#include "global.h" +#include "gba/m4a_internal.h" +#include "battle.h" +#include "decompress.h" +#include "graphics.h" +#include "m4a.h" +#include "main.h" +#include "pokeball.h" +#include "pokemon.h" +#include "rom_8077ABC.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "trig.h" +#include "util.h" + +extern struct MusicPlayerInfo gMPlay_BGM; +extern u16 gBattleTypeFlags; +extern u8 gBankTarget; +extern u8 gActiveBank; +extern u16 gBattlePartyID[]; +extern u8 gObjectBankIDs[]; +extern u8 gDoingBattleAnim; +extern u8 gHealthboxIDs[]; + +#define GFX_TAG_POKEBALL 55000 +#define GFX_TAG_GREATBALL 55001 +#define GFX_TAG_SAFARIBALL 55002 +#define GFX_TAG_ULTRABALL 55003 +#define GFX_TAG_MASTERBALL 55004 +#define GFX_TAG_NETBALL 55005 +#define GFX_TAG_DIVEBALL 55006 +#define GFX_TAG_NESTBALL 55007 +#define GFX_TAG_REPEATBALL 55008 +#define GFX_TAG_TIMERBALL 55009 +#define GFX_TAG_LUXURYBALL 55010 +#define GFX_TAG_PREMIERBALL 55011 + +static const struct CompressedSpriteSheet sBallSpriteSheets[] = +{ + {gInterfaceGfx_PokeBall, 384, GFX_TAG_POKEBALL}, + {gInterfaceGfx_GreatBall, 384, GFX_TAG_GREATBALL}, + {gInterfaceGfx_SafariBall, 384, GFX_TAG_SAFARIBALL}, + {gInterfaceGfx_UltraBall, 384, GFX_TAG_ULTRABALL}, + {gInterfaceGfx_MasterBall, 384, GFX_TAG_MASTERBALL}, + {gInterfaceGfx_NetBall, 384, GFX_TAG_NETBALL}, + {gInterfaceGfx_DiveBall, 384, GFX_TAG_DIVEBALL}, + {gInterfaceGfx_NestBall, 384, GFX_TAG_NESTBALL}, + {gInterfaceGfx_RepeatBall, 384, GFX_TAG_REPEATBALL}, + {gInterfaceGfx_TimerBall, 384, GFX_TAG_TIMERBALL}, + {gInterfaceGfx_LuxuryBall, 384, GFX_TAG_LUXURYBALL}, + {gInterfaceGfx_PremierBall, 384, GFX_TAG_PREMIERBALL}, +}; + +static const struct CompressedSpritePalette sBallSpritePalettes[] = +{ + {gInterfacePal_PokeBall, GFX_TAG_POKEBALL}, + {gInterfacePal_GreatBall, GFX_TAG_GREATBALL}, + {gInterfacePal_SafariBall, GFX_TAG_SAFARIBALL}, + {gInterfacePal_UltraBall, GFX_TAG_ULTRABALL}, + {gInterfacePal_MasterBall, GFX_TAG_MASTERBALL}, + {gInterfacePal_NetBall, GFX_TAG_NETBALL}, + {gInterfacePal_DiveBall, GFX_TAG_DIVEBALL}, + {gInterfacePal_NestBall, GFX_TAG_NESTBALL}, + {gInterfacePal_RepeatBall, GFX_TAG_REPEATBALL}, + {gInterfacePal_TimerBall, GFX_TAG_TIMERBALL}, + {gInterfacePal_LuxuryBall, GFX_TAG_LUXURYBALL}, + {gInterfacePal_PremierBall, GFX_TAG_PREMIERBALL}, +}; + +static const struct OamData sBallOamData = +{ + .y = 0, + .affineMode = 3, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 2, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd sBallAnimSeq3[] = +{ + ANIMCMD_FRAME(0, 5), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd sBallAnimSeq5[] = +{ + ANIMCMD_FRAME(4, 1), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd sBallAnimSeq4[] = +{ + ANIMCMD_FRAME(8, 5), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd sBallAnimSeq6[] = +{ + ANIMCMD_FRAME(12, 1), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd sBallAnimSeq0[] = +{ + ANIMCMD_FRAME(0, 1), + ANIMCMD_END, +}; + +static const union AnimCmd sBallAnimSeq1[] = +{ + ANIMCMD_FRAME(4, 5), + ANIMCMD_FRAME(8, 5), + ANIMCMD_END, +}; + +static const union AnimCmd sBallAnimSeq2[] = +{ + ANIMCMD_FRAME(4, 5), + ANIMCMD_FRAME(0, 5), + ANIMCMD_END, +}; + +static const union AnimCmd *const sBallAnimSequences[] = +{ + sBallAnimSeq0, + sBallAnimSeq1, + sBallAnimSeq2, + + // unused? + sBallAnimSeq3, + sBallAnimSeq4, + sBallAnimSeq5, + sBallAnimSeq6, +}; + +static const union AffineAnimCmd sBallAffineAnimSeq0[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 0, 1), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd sBallAffineAnimSeq1[] = +{ + AFFINEANIMCMD_FRAME(0, 0, -3, 1), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd sBallAffineAnimSeq2[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 3, 1), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd sBallAffineAnimSeq3[] = +{ + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sBallAffineAnimSeq4[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 25, 1), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd *const sBallAffineAnimSequences[] = +{ + sBallAffineAnimSeq0, + sBallAffineAnimSeq1, + sBallAffineAnimSeq2, + sBallAffineAnimSeq3, + sBallAffineAnimSeq4, +}; + +static void objc_0804ABD4(struct Sprite *sprite); +const struct SpriteTemplate gBallSpriteTemplates[] = +{ + { + .tileTag = GFX_TAG_POKEBALL, + .paletteTag = GFX_TAG_POKEBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_GREATBALL, + .paletteTag = GFX_TAG_GREATBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_SAFARIBALL, + .paletteTag = GFX_TAG_SAFARIBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_ULTRABALL, + .paletteTag = GFX_TAG_ULTRABALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_MASTERBALL, + .paletteTag = GFX_TAG_MASTERBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_NETBALL, + .paletteTag = GFX_TAG_NETBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_DIVEBALL, + .paletteTag = GFX_TAG_DIVEBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_NESTBALL, + .paletteTag = GFX_TAG_NESTBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_REPEATBALL, + .paletteTag = GFX_TAG_REPEATBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_TIMERBALL, + .paletteTag = GFX_TAG_TIMERBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_LUXURYBALL, + .paletteTag = GFX_TAG_LUXURYBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_PREMIERBALL, + .paletteTag = GFX_TAG_PREMIERBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, +}; + +extern u32 ball_number_to_ball_processing_index(u16); // not sure of return type +extern void sub_80786EC(); +extern bool8 sub_8078718(struct Sprite *); +extern u8 sub_814086C(u8, u8, int, int, u8); +extern u8 sub_8141314(u8, u8, int, u8); + +static void sub_8046464(u8); +static void sub_80466E8(struct Sprite *); +static void sub_80466F4(struct Sprite *); +static void sub_8046760(struct Sprite *); +static void sub_80467F8(struct Sprite *); +static void sub_804684C(struct Sprite *); +static void sub_8046944(struct Sprite *); +static void sub_8046984(struct Sprite *); +static void sub_8046C78(struct Sprite *); +static void sub_8046E7C(struct Sprite *); +static void sub_8046E9C(struct Sprite *); +static void sub_8046FBC(struct Sprite *); +static void sub_8047074(struct Sprite *); +static void sub_80470C4(struct Sprite *); +static void sub_8047230(struct Sprite *); +static void sub_8047254(struct Sprite *); +static void sub_80473D0(struct Sprite *); +static void sub_804748C(struct Sprite *); +static void sub_8047638(struct Sprite *); +static void sub_80476E0(struct Sprite *); +static void sub_8047754(struct Sprite *); +static void sub_804780C(struct Sprite *); +static void sub_8047830(struct Sprite *); +static void oamc_804BEB4(struct Sprite *); +static u16 sub_8047978(u8); + +u8 sub_8046400(u16 a, u8 b) +{ + u8 taskId; + + gDoingBattleAnim = 1; + ewram17810[gActiveBank].unk0_3 = 1; + taskId = CreateTask(sub_8046464, 5); + gTasks[taskId].data[1] = a; + gTasks[taskId].data[2] = b; + gTasks[taskId].data[3] = gActiveBank; + return 0; +} + +static void sub_8046464(u8 taskId) +{ + bool8 sp0 = FALSE; + u16 r8; + u8 r5; + u16 ball; + u8 r4; + u8 spriteId; + + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].data[0]++; + return; + } + r8 = gTasks[taskId].data[2]; + r5 = gTasks[taskId].data[3]; + if (GetBankSide(r5) != 0) + ball = GetMonData(&gEnemyParty[gBattlePartyID[r5]], MON_DATA_POKEBALL); + else + ball = GetMonData(&gPlayerParty[gBattlePartyID[r5]], MON_DATA_POKEBALL); + r4 = ball_number_to_ball_processing_index(ball); + sub_80478DC(r4); + spriteId = CreateSprite(&gBallSpriteTemplates[r4], 32, 80, 0x1D); + gSprites[spriteId].data0 = 0x80; + gSprites[spriteId].data1 = 0; + gSprites[spriteId].data7 = r8; + switch (r8) + { + case 0xFF: + gBankTarget = r5; + gSprites[spriteId].pos1.x = 24; + gSprites[spriteId].pos1.y = 68; + gSprites[spriteId].callback = sub_8047074; + break; + case 0xFE: + gSprites[spriteId].pos1.x = sub_8077ABC(r5, 0); + gSprites[spriteId].pos1.y = sub_8077ABC(r5, 1) + 24; + gBankTarget = r5; + gSprites[spriteId].data0 = 0; + gSprites[spriteId].callback = sub_8047254; + break; + default: + gBankTarget = GetBankByPlayerAI(1); + sp0 = TRUE; + break; + } + gSprites[spriteId].data6 = gBankTarget; + if (!sp0) + { + DestroyTask(taskId); + return; + } + gSprites[spriteId].data0 = 0x22; + gSprites[spriteId].data2 = sub_8077ABC(gBankTarget, 0); + gSprites[spriteId].data4 = sub_8077ABC(gBankTarget, 1) - 16; + gSprites[spriteId].data5 = -40; + sub_80786EC(&gSprites[spriteId]); + gSprites[spriteId].oam.affineParam = taskId; + gTasks[taskId].data[4] = gBankTarget; + gTasks[taskId].func = TaskDummy; + PlaySE(SE_NAGERU); +} + +static void objc_0804ABD4(struct Sprite *sprite) +{ + if (sub_8078718(sprite)) + { + u8 taskId = sprite->oam.affineParam; + u8 r5 = gTasks[taskId].data[4]; + u8 r8 = gTasks[taskId].data[2]; + u32 r4; // not sure of this type + + StartSpriteAnim(sprite, 1); + sprite->affineAnimPaused = TRUE; + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->data5 = 0; + r4 = ball_number_to_ball_processing_index(sub_8047978(r5)); + sub_814086C(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, r4); + sprite->data0 = sub_8141314(0, r5, 14, r4); + sprite->data6 = r5; + sprite->data7 = r8; + DestroyTask(taskId); + sprite->callback = sub_80466E8; + } +} + +static void sub_80466E8(struct Sprite *sprite) +{ + sprite->callback = sub_80466F4; +} + +static void sub_80466F4(struct Sprite *sprite) +{ + sprite->data5++; + if (sprite->data5 == 10) + { + sprite->data5 = 0; + sprite->callback = sub_8046760; + StartSpriteAffineAnim(&gSprites[gObjectBankIDs[sprite->data6]], 2); + AnimateSprite(&gSprites[gObjectBankIDs[sprite->data6]]); + gSprites[gObjectBankIDs[sprite->data6]].data1 = 0; + } +} + +static void sub_8046760(struct Sprite *sprite) +{ + sprite->data5++; + if (sprite->data5 == 11) + PlaySE(SE_SUIKOMU); + if (gSprites[gObjectBankIDs[sprite->data6]].affineAnimEnded) + { + StartSpriteAnim(sprite, 2); + gSprites[gObjectBankIDs[sprite->data6]].invisible = TRUE; + sprite->data5 = 0; + sprite->callback = sub_80467F8; + } + else + { + gSprites[gObjectBankIDs[sprite->data6]].data1 += 0x60; + gSprites[gObjectBankIDs[sprite->data6]].pos2.y = -gSprites[gObjectBankIDs[sprite->data6]].data1 >> 8; + } +} + +static void sub_80467F8(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + sprite->data5++; + if (sprite->data5 == 1) + { + sprite->data3 = 0; + sprite->data4 = 32; + sprite->data5 = 0; + sprite->pos1.y += Cos(0, 32); + sprite->pos2.y = -Cos(0, sprite->data4); + sprite->callback = sub_804684C; + } + } +} + +static void sub_804684C(struct Sprite *sprite) +{ + bool8 r5 = FALSE; + + switch (sprite->data3 & 0xFF) + { + case 0: + sprite->pos2.y = -Cos(sprite->data5, sprite->data4); + sprite->data5 += 4 + (sprite->data3 >> 8); + if (sprite->data5 >= 64) + { + sprite->data4 -= 10; + sprite->data3 += 0x101; + if (sprite->data3 >> 8 == 4) + r5 = TRUE; + switch (sprite->data3 >> 8) + { + case 1: + PlaySE(SE_KON); + break; + case 2: + PlaySE(SE_KON2); + break; + case 3: + PlaySE(SE_KON3); + break; + default: + PlaySE(SE_KON4); + break; + } + } + break; + case 1: + sprite->pos2.y = -Cos(sprite->data5, sprite->data4); + sprite->data5 -= 4 + (sprite->data3 >> 8); + if (sprite->data5 <= 0) + { + sprite->data5 = 0; + sprite->data3 &= 0xFF00; + } + break; + } + if (r5) + { + sprite->data3 = 0; + sprite->pos1.y += Cos(64, 32); + sprite->pos2.y = 0; + if (sprite->data7 == 0) + { + sprite->callback = sub_8046C78; + } + else + { + sprite->callback = sub_8046944; + sprite->data4 = 1; + sprite->data5 = 0; + } + } +} + +static void sub_8046944(struct Sprite *sprite) +{ + sprite->data3++; + if (sprite->data3 == 31) + { + sprite->data3 = 0; + sprite->affineAnimPaused = TRUE; + StartSpriteAffineAnim(sprite, 1); + sprite->callback = sub_8046984; + PlaySE(SE_BOWA); + } +} + +static void sub_8046984(struct Sprite *sprite) +{ + switch (sprite->data3 & 0xFF) + { + case 0: + case 2: + sprite->pos2.x += sprite->data4; + sprite->data5 += sprite->data4; + sprite->affineAnimPaused = FALSE; + if (sprite->data5 > 3 || sprite->data5 < -3) + { + sprite->data3++; + sprite->data5 = 0; + } + break; + case 1: + sprite->data5++; + if (sprite->data5 == 1) + { + sprite->data5 = 0; + sprite->data4 = -sprite->data4; + sprite->data3++; + sprite->affineAnimPaused = FALSE; + if (sprite->data4 < 0) + ChangeSpriteAffineAnim(sprite, 2); + else + ChangeSpriteAffineAnim(sprite, 1); + } + else + { + sprite->affineAnimPaused = TRUE; + } + break; + case 3: + sprite->data3 += 0x100; + if (sprite->data3 >> 8 == sprite->data7) + { + sprite->callback = sub_8046C78; + } + else + { + if (sprite->data7 == 4 && sprite->data3 >> 8 == 3) + { + sprite->callback = sub_8046E7C; + sprite->affineAnimPaused = TRUE; + } + else + { + sprite->data3++; + sprite->affineAnimPaused = TRUE; + } + } + break; + case 4: + default: + sprite->data5++; + if (sprite->data5 == 31) + { + sprite->data5 = 0; + sprite->data3 &= 0xFF00; + StartSpriteAffineAnim(sprite, 3); + if (sprite->data4 < 0) + StartSpriteAffineAnim(sprite, 2); + else + StartSpriteAffineAnim(sprite, 1); + PlaySE(SE_BOWA); + } + break; + } +} + +static void sub_8046AD0(u8 taskId) +{ + u8 r6 = gTasks[taskId].data[2]; + u8 r3 = gTasks[taskId].data[1]; + u16 species = gTasks[taskId].data[0]; + + switch (gTasks[taskId].data[15]) + { + case 0: + default: + if (gTasks[taskId].data[8] < 3) + gTasks[taskId].data[8]++; + else + gTasks[taskId].data[15] = r6 + 1; + break; + case 1: + PlayCry1(species, r3); + DestroyTask(taskId); + break; + case 2: + StopCryAndClearCrySongs(); + gTasks[taskId].data[10] = 3; + gTasks[taskId].data[15] = 20; + break; + case 20: + if (gTasks[taskId].data[10] != 0) + { + gTasks[taskId].data[10]--; + break; + } + PlayCry4(species, r3, 1); + DestroyTask(taskId); + break; + case 3: + gTasks[taskId].data[10] = 6; + gTasks[taskId].data[15] = 30; + break; + case 30: + if (gTasks[taskId].data[10] != 0) + { + gTasks[taskId].data[10]--; + break; + } + gTasks[taskId].data[15]++; + // fall through + case 31: + if (!IsCryPlayingOrClearCrySongs()) + { + StopCryAndClearCrySongs(); + gTasks[taskId].data[10] = 3; + gTasks[taskId].data[15]++; + } + break; + case 32: + if (gTasks[taskId].data[10] != 0) + { + gTasks[taskId].data[10]--; + break; + } + PlayCry4(species, r3, 0); + DestroyTask(taskId); + break; + } +} + +static void sub_8046C78(struct Sprite *sprite) +{ + u8 r5 = sprite->data6; + u32 r4; // not sure of this type + + StartSpriteAnim(sprite, 1); + r4 = ball_number_to_ball_processing_index(sub_8047978(r5)); + sub_814086C(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, r4); + sprite->data0 = sub_8141314(1, sprite->data6, 14, r4); + sprite->callback = sub_8046E9C; + if (gMain.inBattle) + { + struct Pokemon *pkmn; + u16 species; + s8 r8; + u16 r4_2; + u8 taskId; + + if (GetBankSide(r5) != 0) + { + pkmn = &gEnemyParty[gBattlePartyID[r5]]; + r8 = 25; + } + else + { + pkmn = &gPlayerParty[gBattlePartyID[r5]]; + r8 = -25; + } + species = GetMonData(pkmn, MON_DATA_SPECIES); + if ((r5 == GetBankByPlayerAI(0) || r5 == GetBankByPlayerAI(1)) + && IsDoubleBattle() && ewram17840.unk9_0) + { + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + if (IsBGMPlaying()) + m4aMPlayStop(&gMPlay_BGM); + } + else + { + m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 128); + } + } + if (!IsDoubleBattle() || !ewram17840.unk9_0) + r4_2 = 0; + else if (r5 == GetBankByPlayerAI(0) || r5 == GetBankByPlayerAI(1)) + r4_2 = 1; + else + r4_2 = 2; + taskId = CreateTask(sub_8046AD0, 3); + gTasks[taskId].data[0] = species; + gTasks[taskId].data[1] = r8; + gTasks[taskId].data[2] = r4_2; + gTasks[taskId].data[15] = 0; + } + StartSpriteAffineAnim(&gSprites[gObjectBankIDs[sprite->data6]], 1); + AnimateSprite(&gSprites[gObjectBankIDs[sprite->data6]]); + gSprites[gObjectBankIDs[sprite->data6]].data1 = 0x1000; +} + +static void sub_8046E7C(struct Sprite *sprite) +{ + sprite->animPaused = TRUE; + sprite->callback = sub_8046FBC; + sprite->data3 = 0; + sprite->data4 = 0; + sprite->data5 = 0; +} + +static void sub_8046E9C(struct Sprite *sprite) +{ + bool8 r7 = FALSE; + u8 r4 = sprite->data6; + + gSprites[gObjectBankIDs[r4]].invisible = FALSE; + if (sprite->animEnded) + sprite->invisible = TRUE; + if (gSprites[gObjectBankIDs[r4]].affineAnimEnded) + { + StartSpriteAffineAnim(&gSprites[gObjectBankIDs[r4]], 0); + r7 = TRUE; + } + else + { + gSprites[gObjectBankIDs[r4]].data1 -= 288; + gSprites[gObjectBankIDs[r4]].pos2.y = gSprites[gObjectBankIDs[r4]].data1 >> 8; + } + if (sprite->animEnded && r7) + { + s32 i; + u32 r3; + + gSprites[gObjectBankIDs[r4]].pos2.y = 0; + gDoingBattleAnim = 0; + ewram17810[r4].unk0_3 = 0; + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + for (r3 = 0, i = 0; i < 4; i++) + { + if (ewram17810[i].unk0_3 == 0) + r3++; + } + if (r3 == 4) + { + for (i = 0; i < 12; i++) + sub_804794C(i); + } + } +} + +static void sub_8046FBC(struct Sprite *sprite) +{ + u8 r7 = sprite->data6; + + sprite->data4++; + if (sprite->data4 == 40) + { + return; + } + else if (sprite->data4 == 95) + { + gDoingBattleAnim = 0; + m4aMPlayAllStop(); + PlaySE(BGM_FANFA5); + } + else if (sprite->data4 == 315) + { + FreeOamMatrix(gSprites[gObjectBankIDs[sprite->data6]].oam.matrixNum); + DestroySprite(&gSprites[gObjectBankIDs[sprite->data6]]); + DestroySpriteAndFreeResources(sprite); + if (gMain.inBattle) + ewram17810[r7].unk0_3 = 0; + } +} + +static void sub_8047074(struct Sprite *sprite) +{ + sprite->data0 = 25; + sprite->data2 = sub_8077ABC(sprite->data6, 2); + sprite->data4 = sub_8077ABC(sprite->data6, 3) + 24; + sprite->data5 = -30; + sprite->oam.affineParam = sprite->data6; + sub_80786EC(sprite); + sprite->callback = sub_80470C4; +} + +#define HIBYTE(x) (((x) >> 8) & 0xFF) + +static void sub_80470C4(struct Sprite *sprite) +{ + u32 r6; + u32 r7; + + if (HIBYTE(sprite->data7) >= 35 && HIBYTE(sprite->data7) < 80) + { + s16 r4; + + if ((sprite->oam.affineParam & 0xFF00) == 0) + { + r6 = sprite->data1 & 1; + r7 = sprite->data2 & 1; + sprite->data1 = ((sprite->data1 / 3) & ~1) | r6; + sprite->data2 = ((sprite->data2 / 3) & ~1) | r7; + StartSpriteAffineAnim(sprite, 4); + } + r4 = sprite->data0; + sub_8078B5C(sprite); + sprite->data7 += sprite->data6 / 3; + sprite->pos2.y += Sin(HIBYTE(sprite->data7), sprite->data5); + sprite->oam.affineParam += 0x100; + if ((sprite->oam.affineParam >> 8) % 3 != 0) + sprite->data0 = r4; + else + sprite->data0 = r4 - 1; + if (HIBYTE(sprite->data7) >= 80) + { + r6 = sprite->data1 & 1; + r7 = sprite->data2 & 1; + sprite->data1 = ((sprite->data1 * 3) & ~1) | r6; + sprite->data2 = ((sprite->data2 * 3) & ~1) | r7; + } + } + else + { + if (sub_8078718(sprite)) + { + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.y = 0; + sprite->pos2.x = 0; + sprite->data6 = sprite->oam.affineParam & 0xFF; + sprite->data0 = 0; + if (IsDoubleBattle() && ewram17840.unk9_0 + && sprite->data6 == GetBankByPlayerAI(2)) + sprite->callback = sub_8047230; + else + sprite->callback = sub_8046C78; + StartSpriteAffineAnim(sprite, 0); + } + } +} + +static void sub_8047230(struct Sprite *sprite) +{ + if (sprite->data0++ > 24) + { + sprite->data0 = 0; + sprite->callback = sub_8046C78; + } +} + +static void sub_8047254(struct Sprite *sprite) +{ + sprite->data0++; + if (sprite->data0 > 15) + { + sprite->data0 = 0; + if (IsDoubleBattle() && ewram17840.unk9_0 + && sprite->data6 == GetBankByPlayerAI(3)) + sprite->callback = sub_8047230; + else + sprite->callback = sub_8046C78; + } +} + +static u8 sub_80472B0(u8 a, u8 b, u8 c, u8 d) +{ + return sub_814086C(a, b, c, d, 0); +} + +static u8 sub_80472D8(u8 a, u8 b, u32 c) +{ + return sub_8141314(a, b, c, 0); +} + +void CreatePokeballSprite(u8 a, u8 b, u8 x, u8 y, u8 e, u8 f, u8 g, u32 h) +{ + u8 spriteId; + + LoadCompressedObjectPic(&sBallSpriteSheets[0]); + LoadCompressedObjectPalette(&sBallSpritePalettes[0]); + spriteId = CreateSprite(&gBallSpriteTemplates[0], x, y, f); + gSprites[spriteId].data0 = a; + gSprites[spriteId].data5 = gSprites[a].pos1.x; + gSprites[spriteId].data6 = gSprites[a].pos1.y; + gSprites[a].pos1.x = x; + gSprites[a].pos1.y = y; + gSprites[spriteId].data1 = g; + gSprites[spriteId].data2 = b; + gSprites[spriteId].data3 = h; + gSprites[spriteId].data4 = h >> 16; + gSprites[spriteId].oam.priority = e; + gSprites[spriteId].callback = sub_80473D0; + gSprites[a].invisible = TRUE; +} + +static void sub_80473D0(struct Sprite *sprite) +{ + if (sprite->data1 == 0) + { + u8 r5; + u8 r7 = sprite->data0; + u8 r8 = sprite->data2; + u32 r4 = (u16)sprite->data3 | ((u16)sprite->data4 << 16); + + if (sprite->subpriority != 0) + r5 = sprite->subpriority - 1; + else + r5 = 0; + StartSpriteAnim(sprite, 1); + sub_80472B0(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r5); + sprite->data1 = sub_80472D8(1, r8, r4); + sprite->callback = sub_804748C; + gSprites[r7].invisible = FALSE; + StartSpriteAffineAnim(&gSprites[r7], 1); + AnimateSprite(&gSprites[r7]); + gSprites[r7].data1 = 0x1000; + sprite->data7 = 0; + } + else + { + sprite->data1--; + } +} + +static void sub_804748C(struct Sprite *sprite) +{ + bool8 r12 = FALSE; + bool8 r6 = FALSE; + u8 r3 = sprite->data0; + u16 var1; + u16 var2; + + if (sprite->animEnded) + sprite->invisible = TRUE; + if (gSprites[r3].affineAnimEnded) + { + StartSpriteAffineAnim(&gSprites[r3], 0); + r12 = TRUE; + } + var1 = (sprite->data5 - sprite->pos1.x) * sprite->data7 / 128 + sprite->pos1.x; + var2 = (sprite->data6 - sprite->pos1.y) * sprite->data7 / 128 + sprite->pos1.y; + gSprites[r3].pos1.x = var1; + gSprites[r3].pos1.y = var2; + if (sprite->data7 < 128) + { + s16 sine = -(gSineTable[(u8)sprite->data7] / 8); + + sprite->data7 += 4; + gSprites[r3].pos2.x = sine; + gSprites[r3].pos2.y = sine; + } + else + { + gSprites[r3].pos1.x = sprite->data5; + gSprites[r3].pos1.y = sprite->data6; + gSprites[r3].pos2.x = 0; + gSprites[r3].pos2.y = 0; + r6 = TRUE; + } + if (sprite->animEnded && r12 && r6) + DestroySpriteAndFreeResources(sprite); +} + +u8 sub_8047580(u8 a, u8 b, u8 x, u8 y, u8 e, u8 f, u8 g, u32 h) +{ + u8 spriteId; + + LoadCompressedObjectPic(&sBallSpriteSheets[0]); + LoadCompressedObjectPalette(&sBallSpritePalettes[0]); + spriteId = CreateSprite(&gBallSpriteTemplates[0], x, y, f); + gSprites[spriteId].data0 = a; + gSprites[spriteId].data1 = g; + gSprites[spriteId].data2 = b; + gSprites[spriteId].data3 = h; + gSprites[spriteId].data4 = h >> 16; + gSprites[spriteId].oam.priority = e; + gSprites[spriteId].callback = sub_8047638; + return spriteId; +} + +static void sub_8047638(struct Sprite *sprite) +{ + if (sprite->data1 == 0) + { + u8 r6; + u8 r7 = sprite->data0; + u8 r8 = sprite->data2; + u32 r5 = (u16)sprite->data3 | ((u16)sprite->data4 << 16); + + if (sprite->subpriority != 0) + r6 = sprite->subpriority - 1; + else + r6 = 0; + StartSpriteAnim(sprite, 1); + sub_80472B0(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r6); + sprite->data1 = sub_80472D8(1, r8, r5); + sprite->callback = sub_80476E0; + StartSpriteAffineAnim(&gSprites[r7], 2); + AnimateSprite(&gSprites[r7]); + gSprites[r7].data1 = 0; + } + else + { + sprite->data1--; + } +} + +static void sub_80476E0(struct Sprite *sprite) +{ + u8 r1; + + sprite->data5++; + if (sprite->data5 == 11) + PlaySE(SE_SUIKOMU); + r1 = sprite->data0; + if (gSprites[r1].affineAnimEnded) + { + StartSpriteAnim(sprite, 2); + gSprites[r1].invisible = TRUE; + sprite->data5 = 0; + sprite->callback = sub_8047754; + } + else + { + gSprites[r1].data1 += 96; + gSprites[r1].pos2.y = -gSprites[r1].data1 >> 8; + } +} + +static void sub_8047754(struct Sprite *sprite) +{ + if (sprite->animEnded) + sprite->callback = SpriteCallbackDummy; +} + +void obj_delete_and_free_associated_resources_(struct Sprite *sprite) +{ + DestroySpriteAndFreeResources(sprite); +} + +void sub_804777C(u8 a) +{ + struct Sprite *sprite = &gSprites[gHealthboxIDs[a]]; + + sprite->data0 = 5; + sprite->data1 = 0; + sprite->pos2.x = 0x73; + sprite->pos2.y = 0; + sprite->callback = sub_8047830; + if (GetBankSide(a) != 0) + { + sprite->data0 = -sprite->data0; + sprite->data1 = -sprite->data1; + sprite->pos2.x = -sprite->pos2.x; + sprite->pos2.y = -sprite->pos2.y; + } + gSprites[sprite->data5].callback(&gSprites[sprite->data5]); + if (GetBankIdentity(a) == 2) + sprite->callback = sub_804780C; +} + +static void sub_804780C(struct Sprite *sprite) +{ + sprite->data1++; + if (sprite->data1 == 20) + { + sprite->data1 = 0; + sprite->callback = sub_8047830; + } +} + +static void sub_8047830(struct Sprite *sprite) +{ + sprite->pos2.x -= sprite->data0; + sprite->pos2.y -= sprite->data1; + if (sprite->pos2.x == 0 && sprite->pos2.y == 0) + sprite->callback = SpriteCallbackDummy; +} + +void sub_8047858(u8 a) +{ + u8 spriteId; + + spriteId = CreateInvisibleSpriteWithCallback(oamc_804BEB4); + gSprites[spriteId].data0 = 1; + gSprites[spriteId].data1 = gHealthboxIDs[a]; + gSprites[spriteId].callback = oamc_804BEB4; +} + +static void oamc_804BEB4(struct Sprite *sprite) +{ + u8 r1 = sprite->data1; + + gSprites[r1].pos2.y = sprite->data0; + sprite->data0 = -sprite->data0; + sprite->data2++; + if (sprite->data2 == 21) + { + gSprites[r1].pos2.x = 0; + gSprites[r1].pos2.y = 0; + DestroySprite(sprite); + } +} + +void sub_80478DC(u8 a) +{ + u16 var; + + if (GetSpriteTileStartByTag(sBallSpriteSheets[a].tag) == 0xFFFF) + { + LoadCompressedObjectPic(&sBallSpriteSheets[a]); + LoadCompressedObjectPalette(&sBallSpritePalettes[a]); + } + switch (a) + { + case 6: + case 10: + case 11: + break; + default: + var = GetSpriteTileStartByTag(sBallSpriteSheets[a].tag); + LZDecompressVram(gUnknown_08D030D0, (void *)(VRAM + 0x10100 + var * 32)); + break; + } +} + +void sub_804794C(u8 a) +{ + FreeSpriteTilesByTag(sBallSpriteSheets[a].tag); + FreeSpritePaletteByTag(sBallSpritePalettes[a].tag); +} + +static u16 sub_8047978(u8 a) +{ + if (GetBankSide(a) == 0) + return GetMonData(&gPlayerParty[gBattlePartyID[a]], MON_DATA_POKEBALL); + else + return GetMonData(&gEnemyParty[gBattlePartyID[a]], MON_DATA_POKEBALL); +} diff --git a/src/pokedex.c b/src/pokedex.c index 54fa5912c..2ef91e472 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -1,26 +1,84 @@ + #include "global.h" -#include "pokedex.h" -#include "asm.h" #include "gba/m4a_internal.h" -#include "string_util.h" -#include "m4a.h" +#include "pokedex.h" +#include "battle.h" +#include "data2.h" #include "decompress.h" +#include "event_data.h" +#include "graphics.h" +#include "m4a.h" #include "main.h" #include "menu.h" +#include "menu_cursor.h" #include "palette.h" +#include "pokedex_area_screen.h" +#include "pokedex_cry_screen.h" +#include "pokemon.h" #include "rng.h" +#include "rom4.h" #include "songs.h" #include "sound.h" +#include "species.h" +#include "string_util.h" +#include "strings.h" #include "task.h" +#include "trig.h" +#include "unknown_task.h" -// I'm #define-ing these just for now so I can keep using the old unkXXX member names -#define unk60E selectedPokemon -#define unk612 dexMode -#define unk616 dexOrder -#define unk64D selectedScreen -#define unk650 menuIsOpen -#define unk652 menuCursorPos -#define unk654 menuY +#define NATIONAL_DEX_COUNT 386 + +struct PokedexListItem +{ + u16 dexNum; + u16 seen:1; + u16 owned:1; +}; + +struct PokedexView +{ + struct PokedexListItem unk0[NATIONAL_DEX_COUNT]; + u16 unk608; + u8 unk60A_1:1; + u8 unk60A_2:1; + u8 unk60B; + u16 pokemonListCount; + u16 selectedPokemon; + u16 unk610; + u16 dexMode; + u16 unk614; + u16 dexOrder; + u16 unk618; + u16 unk61A; + u16 unk61C; + u16 unk61E[4]; + u16 selectedMonSpriteId; + u16 unk628; + u16 unk62A; + u8 unk62C; + u8 unk62D; + u8 unk62E; + u8 unk62F; + s16 unk630; + s16 unk632; + u16 unk634; + u16 unk636; + u16 unk638; + u16 unk63A[4]; + u8 filler642[8]; + u8 unk64A; + u8 unk64B; + u8 unk64C_1:1; + u8 selectedScreen; + u8 descriptionPageNum; + u8 unk64F; + u8 menuIsOpen; //menuIsOpen + u8 unk651; + u16 menuCursorPos; //Menu cursor position + s16 menuY; //Menu Y position (inverted because we use REG_BG0VOFS for this) + u8 unk656[8]; + u8 unk65E[8]; +}; enum { @@ -41,8 +99,8 @@ struct PokedexEntry /*0x00*/ u8 categoryName[12]; /*0x0C*/ u16 height; //in decimeters /*0x0E*/ u16 weight; //in hectograms - /*0x10*/ u8 *descriptionPage1; - /*0x14*/ u8 *descriptionPage2; + /*0x10*/ const u8 *descriptionPage1; + /*0x14*/ const u8 *descriptionPage2; /*0x18*/ u16 unused; /*0x1A*/ u16 pokemonScale; /*0x1C*/ u16 pokemonOffset; @@ -50,90 +108,1201 @@ struct PokedexEntry /*0x20*/ u16 trainerOffset; }; /*size = 0x24*/ -struct CryRelatedStruct +struct UnknownStruct2 +{ + const u8 *text1; + const u8 *text2; +}; + +struct UnknownStruct1 +{ + const struct UnknownStruct2 *unk0; + u8 unk4; + u8 unk5; + u16 unk6; +}; + +struct UnknownStruct3 +{ + const u8 *text; + u8 unk4; + u8 unk5; + u8 unk6; +}; + +struct UnknownStruct4 { - u16 unk0; - u8 unk2; - u8 unk3; + const u8 *text; u8 unk4; u8 unk5; + u8 unk6; + u8 unk7; + u8 unk8; + u8 unk9; }; extern struct MusicPlayerInfo gMPlay_BGM; extern u8 gReservedSpritePaletteCount; extern struct PokedexView *gPokedexView; +extern struct SpriteTemplate gUnknown_02024E8C; extern u16 gUnknown_0202FFB8; extern u8 gUnknown_0202FFBA; -extern u8 gUnknown_03005CE8; -extern u8 gPokedexMenu_Gfx[]; -extern u8 gUnknown_08E96738[]; -extern u8 gUnknown_08E9C6DC[]; -extern u8 gUnknown_08E96888[]; -extern u8 gUnknown_08E96994[]; -extern struct SpriteSheet gUnknown_083A05CC; -extern struct SpritePalette gUnknown_083A05DC[]; -extern u8 gUnknown_0839FA7C[]; -extern u8 gUnknown_0839F67C[]; -extern u8 gPokedexMenu_Pal[]; -extern u8 gUnknown_0839F73C[]; -extern u8 gUnknown_083A05EC[]; -extern u8 gUnknown_083A05F1[]; -extern struct SpriteTemplate gSpriteTemplate_83A053C; -extern struct SpriteTemplate gSpriteTemplate_83A0524; -extern struct SpriteTemplate gSpriteTemplate_83A0554; -extern struct SpriteTemplate gSpriteTemplate_83A056C; -extern struct SpriteTemplate gSpriteTemplate_83A0584; -extern struct SpriteTemplate gSpriteTemplate_83A059C; -extern struct SpriteTemplate gSpriteTemplate_83A05B4; -extern s16 gSineTable[]; extern struct PokedexListItem *gUnknown_0202FFBC; +extern u8 gUnknown_03005CE8; extern IntrCallback gUnknown_03005CEC; -extern u8 gUnknown_08E96BD4[]; -extern u8 gUnknown_083A05F8[]; -extern u8 gUnknown_0839F8A0[]; -extern u8 gUnknown_0839F988[]; extern u8 gUnknown_03005E98; -extern u8 gUnknown_083B4EC4[]; -extern u8 gUnknown_08E96ACC[]; -extern u8 gUnknown_08E96B58[]; - -extern struct PokedexEntry gPokedexEntries[]; -extern u8 gDexText_UnknownPoke[]; -extern u8 gDexText_UnknownHeight[]; -extern u8 gDexText_UnknownWeight[]; -extern u8 gDexText_CryOf[]; -extern u8 gDexText_SizeComparedTo[]; -extern u8 gDexText_RegisterComplete[]; - -extern void m4aMPlayVolumeControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u16 volume); -extern bool8 BeginNormalPaletteFade(u32, s8, u8, u8, u16); -extern void remove_some_task(void); -extern u8 sub_8091E3C(void); -extern void sub_80690C8(void); -extern void sub_805469C(void); -extern u16 HoennToNationalOrder(u16); -extern u16 NationalToHoennOrder(u16); -extern u16 gPokedexOrder_Alphabetical[]; -extern u16 gPokedexOrder_Weight[]; -extern u16 gPokedexOrder_Height[]; -extern u8 gSpeciesNames[][11]; - -u16 NationalPokedexNumToSpecies(u16); - -// asm/pokedex_area_screen -void ShowPokedexAreaScreen(u16 species, u8 *string); - -// asm/pokedex_cry_screen -u8 sub_8119E3C(struct CryRelatedStruct *, u8); -void sub_8119F88(u8 a); -void sub_811A050(u16 species); -u8 ShowPokedexCryScreen(struct CryRelatedStruct *, u8); -void DestroyCryMeterNeedleSprite(); - -void sub_808C02C(void) +extern const u8 gPokedexMenu_Gfx[]; +extern const u8 gUnknown_08E96738[]; +extern const u8 gUnknown_08E96888[]; +extern const u8 gUnknown_08E96994[]; +extern const u8 gUnknown_08E9C6DC[]; +extern const u8 gUnknown_08D00524[]; +extern const u8 gUnknown_08E96BD4[]; +extern const u8 gUnknown_08E96ACC[]; +extern const u8 gUnknown_08E96B58[]; +extern const u16 gPokedexMenu_Pal[]; +extern const u16 gPokedexMenu2_Pal[]; +extern const struct CompressedSpriteSheet gTrainerFrontPicTable[]; +extern const struct MonCoords gTrainerFrontPicCoords[]; +extern const struct PokedexEntry gPokedexEntries[]; +extern const u8 gPokedexMenuSearch_Gfx[]; +extern const u8 gUnknown_08E96D2C[]; +extern const u16 gPokedexMenuSearch_Pal[]; +extern const u8 gTypeNames[][7]; +extern const u8 gPokedexMenu2_Gfx[]; + +static u8 sub_8091E3C(void); + +static const u16 sPokedexSearchPalette[] = INCBIN_U16("graphics/pokedex/search.gbapal"); +static const u16 sNationalPokedexPalette[] = INCBIN_U16("graphics/pokedex/national.gbapal"); +const u8 gEmptySpacce_839F7FC[0xA4] = {0}; +static const u8 gUnknown_0839F8A0[] = INCBIN_U8("graphics/pokedex/pokedex_cry_layout.bin.lz"); +static const u8 gUnknown_0839F988[] = INCBIN_U8("graphics/pokedex/pokedex_size_layout.bin.lz"); +#if ENGLISH +static const u8 gUnknown_0839FA7C[] = INCBIN_U8("graphics/pokedex/noball.4bpp.lz"); +#elif GERMAN +extern const u8 gUnknown_0839FA7C[]; +#endif + +#include "data/pokedex_orders.h" +static const struct OamData gOamData_83A0404 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const struct OamData gOamData_83A040C = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const struct OamData gOamData_83A0414 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const struct OamData gOamData_83A041C = +{ + .y = 160, + .affineMode = 0, + .objMode = 2, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 2, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const struct OamData gOamData_83A0424 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const struct OamData gOamData_83A042C = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 2, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_83A0434[] = +{ + ANIMCMD_FRAME(3, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A043C[] = +{ + ANIMCMD_FRAME(1, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A0444[] = +{ + ANIMCMD_FRAME(16, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A044C[] = +{ + ANIMCMD_FRAME(32, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A0454[] = +{ + ANIMCMD_FRAME(64, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A045C[] = +{ + ANIMCMD_FRAME(96, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A0464[] = +{ + ANIMCMD_FRAME(128, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A046C[] = +{ + ANIMCMD_FRAME(160, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A0474[] = +{ + ANIMCMD_FRAME(192, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A047C[] = +{ + ANIMCMD_FRAME(224, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A0484[] = +{ + ANIMCMD_FRAME(226, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A048C[] = +{ + ANIMCMD_FRAME(228, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A0494[] = +{ + ANIMCMD_FRAME(230, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A049C[] = +{ + ANIMCMD_FRAME(232, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A04A4[] = +{ + ANIMCMD_FRAME(234, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A04AC[] = +{ + ANIMCMD_FRAME(236, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A04B4[] = +{ + ANIMCMD_FRAME(238, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A04BC[] = +{ + ANIMCMD_FRAME(240, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A04C4[] = +{ + ANIMCMD_FRAME(242, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83A04CC[] = +{ + ANIMCMD_FRAME(4, 30), + ANIMCMD_END, +}; +static const union AnimCmd *const gSpriteAnimTable_83A04D4[] = +{ + gSpriteAnim_83A0434, +}; +static const union AnimCmd *const gSpriteAnimTable_83A04D8[] = +{ + gSpriteAnim_83A043C, +}; +static const union AnimCmd *const gSpriteAnimTable_83A04DC[] = +{ + gSpriteAnim_83A0444, +}; +static const union AnimCmd *const gSpriteAnimTable_83A04E0[] = +{ + gSpriteAnim_83A044C, + gSpriteAnim_83A0454, + gSpriteAnim_83A045C, + gSpriteAnim_83A0464, +}; +static const union AnimCmd *const gSpriteAnimTable_83A04F0[] = +{ + gSpriteAnim_83A046C, + gSpriteAnim_83A0474, +}; +static const union AnimCmd *const gSpriteAnimTable_83A04F8[] = +{ + gSpriteAnim_83A047C, + gSpriteAnim_83A0484, + gSpriteAnim_83A048C, + gSpriteAnim_83A0494, + gSpriteAnim_83A049C, + gSpriteAnim_83A04A4, + gSpriteAnim_83A04AC, + gSpriteAnim_83A04B4, + gSpriteAnim_83A04BC, + gSpriteAnim_83A04C4, +}; +static const union AnimCmd *const gSpriteAnimTable_83A0520[] = +{ + gSpriteAnim_83A04CC, +}; +static void sub_808EF38(struct Sprite *); +static const struct SpriteTemplate gSpriteTemplate_83A0524 = +{ + .tileTag = 4096, + .paletteTag = 4096, + .oam = &gOamData_83A0404, + .anims = gSpriteAnimTable_83A04D4, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_808EF38, +}; +static void sub_808EF8C(struct Sprite *); +static const struct SpriteTemplate gSpriteTemplate_83A053C = +{ + .tileTag = 4096, + .paletteTag = 4096, + .oam = &gOamData_83A040C, + .anims = gSpriteAnimTable_83A04D8, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_808EF8C, +}; +static void sub_808F08C(struct Sprite *); +static const struct SpriteTemplate gSpriteTemplate_83A0554 = +{ + .tileTag = 4096, + .paletteTag = 4096, + .oam = &gOamData_83A0414, + .anims = gSpriteAnimTable_83A04E0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_808F08C, +}; +static void sub_808F0B4(struct Sprite *); +static const struct SpriteTemplate gSpriteTemplate_83A056C = +{ + .tileTag = 4096, + .paletteTag = 4096, + .oam = &gOamData_83A041C, + .anims = gSpriteAnimTable_83A04DC, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_808F0B4, +}; +static void sub_808ED94(struct Sprite *); +static const struct SpriteTemplate gSpriteTemplate_83A0584 = +{ + .tileTag = 4096, + .paletteTag = 4096, + .oam = &gOamData_83A0424, + .anims = gSpriteAnimTable_83A04F0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_808ED94, +}; +static const struct SpriteTemplate gSpriteTemplate_83A059C = +{ + .tileTag = 4096, + .paletteTag = 4096, + .oam = &gOamData_83A042C, + .anims = gSpriteAnimTable_83A04F8, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_808ED94, +}; +static void sub_808F168(struct Sprite *); +static const struct SpriteTemplate gSpriteTemplate_83A05B4 = +{ + .tileTag = 4096, + .paletteTag = 4096, + .oam = &gOamData_83A042C, + .anims = gSpriteAnimTable_83A0520, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_808F168, +}; +static const struct CompressedSpriteSheet gUnknown_083A05CC[] = +{ + {gPokedexMenu2_Gfx, 0x1F00, 0x1000}, + {NULL, 0, 0}, +}; +static const struct SpritePalette gUnknown_083A05DC[] = +{ + {gPokedexMenu_Pal, 0x1000}, + {NULL, 0}, +}; +static const u8 gUnknown_083A05EC[] = {2, 4, 8, 16, 32}; +static const u8 gUnknown_083A05F1[] = {16, 8, 4, 2, 1}; +const u8 gEmptySpacce_83A05F6[] = {0, 0}; // Padding, maybe? +static const u8 gUnknown_083A05F8[] = _(""); +#if ENGLISH +#include "data/pokedex_entries_en.h" +#elif GERMAN +#include "data/pokedex_entries_de.h" +#endif +static const u16 gUnknown_083B4EC4[16] = {0}; +static const u8 *const sMonFootprintTable[] = +{ + gMonFootprint_Bulbasaur, + gMonFootprint_Bulbasaur, + gMonFootprint_Ivysaur, + gMonFootprint_Venusaur, + gMonFootprint_Charmander, + gMonFootprint_Charmeleon, + gMonFootprint_Charizard, + gMonFootprint_Squirtle, + gMonFootprint_Wartortle, + gMonFootprint_Blastoise, + gMonFootprint_Caterpie, + gMonFootprint_Metapod, + gMonFootprint_Butterfree, + gMonFootprint_Weedle, + gMonFootprint_Kakuna, + gMonFootprint_Beedrill, + gMonFootprint_Pidgey, + gMonFootprint_Pidgeotto, + gMonFootprint_Pidgeot, + gMonFootprint_Rattata, + gMonFootprint_Raticate, + gMonFootprint_Spearow, + gMonFootprint_Fearow, + gMonFootprint_Ekans, + gMonFootprint_Arbok, + gMonFootprint_Pikachu, + gMonFootprint_Raichu, + gMonFootprint_Sandshrew, + gMonFootprint_Sandslash, + gMonFootprint_NidoranF, + gMonFootprint_Nidorina, + gMonFootprint_Nidoqueen, + gMonFootprint_NidoranM, + gMonFootprint_Nidorino, + gMonFootprint_Nidoking, + gMonFootprint_Clefairy, + gMonFootprint_Clefable, + gMonFootprint_Vulpix, + gMonFootprint_Ninetales, + gMonFootprint_Jigglypuff, + gMonFootprint_Wigglytuff, + gMonFootprint_Zubat, + gMonFootprint_Golbat, + gMonFootprint_Oddish, + gMonFootprint_Gloom, + gMonFootprint_Vileplume, + gMonFootprint_Paras, + gMonFootprint_Parasect, + gMonFootprint_Venonat, + gMonFootprint_Venomoth, + gMonFootprint_Diglett, + gMonFootprint_Dugtrio, + gMonFootprint_Meowth, + gMonFootprint_Persian, + gMonFootprint_Psyduck, + gMonFootprint_Golduck, + gMonFootprint_Mankey, + gMonFootprint_Primeape, + gMonFootprint_Growlithe, + gMonFootprint_Arcanine, + gMonFootprint_Poliwag, + gMonFootprint_Poliwhirl, + gMonFootprint_Poliwrath, + gMonFootprint_Abra, + gMonFootprint_Kadabra, + gMonFootprint_Alakazam, + gMonFootprint_Machop, + gMonFootprint_Machoke, + gMonFootprint_Machamp, + gMonFootprint_Bellsprout, + gMonFootprint_Weepinbell, + gMonFootprint_Victreebel, + gMonFootprint_Tentacool, + gMonFootprint_Tentacruel, + gMonFootprint_Geodude, + gMonFootprint_Graveler, + gMonFootprint_Golem, + gMonFootprint_Ponyta, + gMonFootprint_Rapidash, + gMonFootprint_Slowpoke, + gMonFootprint_Slowbro, + gMonFootprint_Magnemite, + gMonFootprint_Magneton, + gMonFootprint_Farfetchd, + gMonFootprint_Doduo, + gMonFootprint_Dodrio, + gMonFootprint_Seel, + gMonFootprint_Dewgong, + gMonFootprint_Grimer, + gMonFootprint_Muk, + gMonFootprint_Shellder, + gMonFootprint_Cloyster, + gMonFootprint_Gastly, + gMonFootprint_Haunter, + gMonFootprint_Gengar, + gMonFootprint_Onix, + gMonFootprint_Drowzee, + gMonFootprint_Hypno, + gMonFootprint_Krabby, + gMonFootprint_Kingler, + gMonFootprint_Voltorb, + gMonFootprint_Electrode, + gMonFootprint_Exeggcute, + gMonFootprint_Exeggutor, + gMonFootprint_Cubone, + gMonFootprint_Marowak, + gMonFootprint_Hitmonlee, + gMonFootprint_Hitmonchan, + gMonFootprint_Lickitung, + gMonFootprint_Koffing, + gMonFootprint_Weezing, + gMonFootprint_Rhyhorn, + gMonFootprint_Rhydon, + gMonFootprint_Chansey, + gMonFootprint_Tangela, + gMonFootprint_Kangaskhan, + gMonFootprint_Horsea, + gMonFootprint_Seadra, + gMonFootprint_Goldeen, + gMonFootprint_Seaking, + gMonFootprint_Staryu, + gMonFootprint_Starmie, + gMonFootprint_Mrmime, + gMonFootprint_Scyther, + gMonFootprint_Jynx, + gMonFootprint_Electabuzz, + gMonFootprint_Magmar, + gMonFootprint_Pinsir, + gMonFootprint_Tauros, + gMonFootprint_Magikarp, + gMonFootprint_Gyarados, + gMonFootprint_Lapras, + gMonFootprint_Ditto, + gMonFootprint_Eevee, + gMonFootprint_Vaporeon, + gMonFootprint_Jolteon, + gMonFootprint_Flareon, + gMonFootprint_Porygon, + gMonFootprint_Omanyte, + gMonFootprint_Omastar, + gMonFootprint_Kabuto, + gMonFootprint_Kabutops, + gMonFootprint_Aerodactyl, + gMonFootprint_Snorlax, + gMonFootprint_Articuno, + gMonFootprint_Zapdos, + gMonFootprint_Moltres, + gMonFootprint_Dratini, + gMonFootprint_Dragonair, + gMonFootprint_Dragonite, + gMonFootprint_Mewtwo, + gMonFootprint_Mew, + gMonFootprint_Chikorita, + gMonFootprint_Bayleef, + gMonFootprint_Meganium, + gMonFootprint_Cyndaquil, + gMonFootprint_Quilava, + gMonFootprint_Typhlosion, + gMonFootprint_Totodile, + gMonFootprint_Croconaw, + gMonFootprint_Feraligatr, + gMonFootprint_Sentret, + gMonFootprint_Furret, + gMonFootprint_Hoothoot, + gMonFootprint_Noctowl, + gMonFootprint_Ledyba, + gMonFootprint_Ledian, + gMonFootprint_Spinarak, + gMonFootprint_Ariados, + gMonFootprint_Crobat, + gMonFootprint_Chinchou, + gMonFootprint_Lanturn, + gMonFootprint_Pichu, + gMonFootprint_Cleffa, + gMonFootprint_Igglybuff, + gMonFootprint_Togepi, + gMonFootprint_Togetic, + gMonFootprint_Natu, + gMonFootprint_Xatu, + gMonFootprint_Mareep, + gMonFootprint_Flaaffy, + gMonFootprint_Ampharos, + gMonFootprint_Bellossom, + gMonFootprint_Marill, + gMonFootprint_Azumarill, + gMonFootprint_Sudowoodo, + gMonFootprint_Politoed, + gMonFootprint_Hoppip, + gMonFootprint_Skiploom, + gMonFootprint_Jumpluff, + gMonFootprint_Aipom, + gMonFootprint_Sunkern, + gMonFootprint_Sunflora, + gMonFootprint_Yanma, + gMonFootprint_Wooper, + gMonFootprint_Quagsire, + gMonFootprint_Espeon, + gMonFootprint_Umbreon, + gMonFootprint_Murkrow, + gMonFootprint_Slowking, + gMonFootprint_Misdreavus, + gMonFootprint_Unown, + gMonFootprint_Wobbuffet, + gMonFootprint_Girafarig, + gMonFootprint_Pineco, + gMonFootprint_Forretress, + gMonFootprint_Dunsparce, + gMonFootprint_Gligar, + gMonFootprint_Steelix, + gMonFootprint_Snubbull, + gMonFootprint_Granbull, + gMonFootprint_Qwilfish, + gMonFootprint_Scizor, + gMonFootprint_Shuckle, + gMonFootprint_Heracross, + gMonFootprint_Sneasel, + gMonFootprint_Teddiursa, + gMonFootprint_Ursaring, + gMonFootprint_Slugma, + gMonFootprint_Magcargo, + gMonFootprint_Swinub, + gMonFootprint_Piloswine, + gMonFootprint_Corsola, + gMonFootprint_Remoraid, + gMonFootprint_Octillery, + gMonFootprint_Delibird, + gMonFootprint_Mantine, + gMonFootprint_Skarmory, + gMonFootprint_Houndour, + gMonFootprint_Houndoom, + gMonFootprint_Kingdra, + gMonFootprint_Phanpy, + gMonFootprint_Donphan, + gMonFootprint_Porygon2, + gMonFootprint_Stantler, + gMonFootprint_Smeargle, + gMonFootprint_Tyrogue, + gMonFootprint_Hitmontop, + gMonFootprint_Smoochum, + gMonFootprint_Elekid, + gMonFootprint_Magby, + gMonFootprint_Miltank, + gMonFootprint_Blissey, + gMonFootprint_Raikou, + gMonFootprint_Entei, + gMonFootprint_Suicune, + gMonFootprint_Larvitar, + gMonFootprint_Pupitar, + gMonFootprint_Tyranitar, + gMonFootprint_Lugia, + gMonFootprint_HoOh, + gMonFootprint_Celebi, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_QuestionMark, + gMonFootprint_Treecko, + gMonFootprint_Grovyle, + gMonFootprint_Sceptile, + gMonFootprint_Torchic, + gMonFootprint_Combusken, + gMonFootprint_Blaziken, + gMonFootprint_Mudkip, + gMonFootprint_Marshtomp, + gMonFootprint_Swampert, + gMonFootprint_Poochyena, + gMonFootprint_Mightyena, + gMonFootprint_Zigzagoon, + gMonFootprint_Linoone, + gMonFootprint_Wurmple, + gMonFootprint_Silcoon, + gMonFootprint_Beautifly, + gMonFootprint_Cascoon, + gMonFootprint_Dustox, + gMonFootprint_Lotad, + gMonFootprint_Lombre, + gMonFootprint_Ludicolo, + gMonFootprint_Seedot, + gMonFootprint_Nuzleaf, + gMonFootprint_Shiftry, + gMonFootprint_Nincada, + gMonFootprint_Ninjask, + gMonFootprint_Shedinja, + gMonFootprint_Taillow, + gMonFootprint_Swellow, + gMonFootprint_Shroomish, + gMonFootprint_Breloom, + gMonFootprint_Spinda, + gMonFootprint_Wingull, + gMonFootprint_Pelipper, + gMonFootprint_Surskit, + gMonFootprint_Masquerain, + gMonFootprint_Wailmer, + gMonFootprint_Wailord, + gMonFootprint_Skitty, + gMonFootprint_Delcatty, + gMonFootprint_Kecleon, + gMonFootprint_Baltoy, + gMonFootprint_Claydol, + gMonFootprint_Nosepass, + gMonFootprint_Torkoal, + gMonFootprint_Sableye, + gMonFootprint_Barboach, + gMonFootprint_Whiscash, + gMonFootprint_Luvdisc, + gMonFootprint_Corphish, + gMonFootprint_Crawdaunt, + gMonFootprint_Feebas, + gMonFootprint_Milotic, + gMonFootprint_Carvanha, + gMonFootprint_Sharpedo, + gMonFootprint_Trapinch, + gMonFootprint_Vibrava, + gMonFootprint_Flygon, + gMonFootprint_Makuhita, + gMonFootprint_Hariyama, + gMonFootprint_Electrike, + gMonFootprint_Manectric, + gMonFootprint_Numel, + gMonFootprint_Camerupt, + gMonFootprint_Spheal, + gMonFootprint_Sealeo, + gMonFootprint_Walrein, + gMonFootprint_Cacnea, + gMonFootprint_Cacturne, + gMonFootprint_Snorunt, + gMonFootprint_Glalie, + gMonFootprint_Lunatone, + gMonFootprint_Solrock, + gMonFootprint_Azurill, + gMonFootprint_Spoink, + gMonFootprint_Grumpig, + gMonFootprint_Plusle, + gMonFootprint_Minun, + gMonFootprint_Mawile, + gMonFootprint_Meditite, + gMonFootprint_Medicham, + gMonFootprint_Swablu, + gMonFootprint_Altaria, + gMonFootprint_Wynaut, + gMonFootprint_Duskull, + gMonFootprint_Dusclops, + gMonFootprint_Roselia, + gMonFootprint_Slakoth, + gMonFootprint_Vigoroth, + gMonFootprint_Slaking, + gMonFootprint_Gulpin, + gMonFootprint_Swalot, + gMonFootprint_Tropius, + gMonFootprint_Whismur, + gMonFootprint_Loudred, + gMonFootprint_Exploud, + gMonFootprint_Clamperl, + gMonFootprint_Huntail, + gMonFootprint_Gorebyss, + gMonFootprint_Absol, + gMonFootprint_Shuppet, + gMonFootprint_Banette, + gMonFootprint_Seviper, + gMonFootprint_Zangoose, + gMonFootprint_Relicanth, + gMonFootprint_Aron, + gMonFootprint_Lairon, + gMonFootprint_Aggron, + gMonFootprint_Castform, + gMonFootprint_Volbeat, + gMonFootprint_Illumise, + gMonFootprint_Lileep, + gMonFootprint_Cradily, + gMonFootprint_Anorith, + gMonFootprint_Armaldo, + gMonFootprint_Ralts, + gMonFootprint_Kirlia, + gMonFootprint_Gardevoir, + gMonFootprint_Bagon, + gMonFootprint_Shelgon, + gMonFootprint_Salamence, + gMonFootprint_Beldum, + gMonFootprint_Metang, + gMonFootprint_Metagross, + gMonFootprint_Regirock, + gMonFootprint_Regice, + gMonFootprint_Registeel, + gMonFootprint_Kyogre, + gMonFootprint_Groudon, + gMonFootprint_Rayquaza, + gMonFootprint_Latias, + gMonFootprint_Latios, + gMonFootprint_Jirachi, + gMonFootprint_Deoxys, + gMonFootprint_Chimecho, + gMonFootprint_Bulbasaur, +}; +static const u8 gUnknown_083B5558[] = _("{CLEAR_TO 0}"); +const u8 gUnknown_083B555C[] = INCBIN_U8("graphics/unknown/unknown_3B555C.bin"); +static const struct OamData gOamData_83B557C = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static void *const gUnknown_083B5584[] = +{ + (void *)0x02008000, + (void *)0x0200C000, + (void *)0x02010000, + (void *)0x02014000, +}; +static const struct SpriteFrameImage gSpriteImageTable_83B5594[] = +{ + {(u8 *)0x02008000, 0x800}, + {(u8 *)0x02008800, 0x800}, + {(u8 *)0x02009000, 0x800}, + {(u8 *)0x02009800, 0x800}, + {(u8 *)0x0200A000, 0x800}, + {(u8 *)0x0200A800, 0x800}, + {(u8 *)0x0200B000, 0x800}, + {(u8 *)0x0200B800, 0x800}, + {(u8 *)0x0200C000, 0x800}, + {(u8 *)0x0200C800, 0x800}, + {(u8 *)0x0200D000, 0x800}, + {(u8 *)0x0200D800, 0x800}, + {(u8 *)0x0200E000, 0x800}, + {(u8 *)0x0200E800, 0x800}, + {(u8 *)0x0200F000, 0x800}, + {(u8 *)0x0200F800, 0x800}, +}; +static const struct SpriteFrameImage gSpriteImageTable_83B5614[] = +{ + {(u8 *)0x0200C000, 0x800}, + {(u8 *)0x0200C800, 0x800}, + {(u8 *)0x0200D000, 0x800}, + {(u8 *)0x0200D800, 0x800}, + {(u8 *)0x0200E000, 0x800}, + {(u8 *)0x0200E800, 0x800}, + {(u8 *)0x0200F000, 0x800}, + {(u8 *)0x0200F800, 0x800}, + {(u8 *)0x02010000, 0x800}, + {(u8 *)0x02010800, 0x800}, + {(u8 *)0x02011000, 0x800}, + {(u8 *)0x02011800, 0x800}, + {(u8 *)0x02012000, 0x800}, + {(u8 *)0x02012800, 0x800}, + {(u8 *)0x02013000, 0x800}, + {(u8 *)0x02013800, 0x800}, +}; +static const struct SpriteFrameImage gSpriteImageTable_83B5694[] = +{ + {(u8 *)0x02010000, 0x800}, + {(u8 *)0x02010800, 0x800}, + {(u8 *)0x02011000, 0x800}, + {(u8 *)0x02011800, 0x800}, + {(u8 *)0x02012000, 0x800}, + {(u8 *)0x02012800, 0x800}, + {(u8 *)0x02013000, 0x800}, + {(u8 *)0x02013800, 0x800}, + {(u8 *)0x02014000, 0x800}, + {(u8 *)0x02014800, 0x800}, + {(u8 *)0x02015000, 0x800}, + {(u8 *)0x02015800, 0x800}, + {(u8 *)0x02016000, 0x800}, + {(u8 *)0x02016800, 0x800}, + {(u8 *)0x02017000, 0x800}, + {(u8 *)0x02017800, 0x800}, +}; +static const struct SpriteFrameImage gSpriteImageTable_83B5714[] = +{ + {(u8 *)0x02014000, 0x800}, + {(u8 *)0x02014800, 0x800}, + {(u8 *)0x02015000, 0x800}, + {(u8 *)0x02015800, 0x800}, + {(u8 *)0x02016000, 0x800}, + {(u8 *)0x02016800, 0x800}, + {(u8 *)0x02017000, 0x800}, + {(u8 *)0x02017800, 0x800}, + {(u8 *)0x02018000, 0x800}, + {(u8 *)0x02018800, 0x800}, + {(u8 *)0x02019000, 0x800}, + {(u8 *)0x02019800, 0x800}, + {(u8 *)0x0201A000, 0x800}, + {(u8 *)0x0201A800, 0x800}, + {(u8 *)0x0201B000, 0x800}, + {(u8 *)0x0201B800, 0x800}, +}; +static const struct SpriteFrameImage *const gUnknown_083B5794[] = +{ + gSpriteImageTable_83B5594, + gSpriteImageTable_83B5614, + gSpriteImageTable_83B5694, + gSpriteImageTable_83B5714, +}; +static void nullsub_59(struct Sprite *); +static const struct SpriteTemplate gUnknown_083B57A4 = +{ + .tileTag = 0xFFFF, + .paletteTag = 0, + .oam = &gOamData_83B557C, + .anims = NULL, + .images = gSpriteImageTable_83B5594, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = nullsub_59, +}; +static const u8 gUnknown_083B57BC[][4] = +{ + {0, 0, 0, 0}, + {CHAR_A, 3, CHAR_a, 3}, + {CHAR_D, 3, CHAR_d, 3}, + {CHAR_G, 3, CHAR_g, 3}, + {CHAR_J, 3, CHAR_j, 3}, + {CHAR_M, 3, CHAR_m, 3}, + {CHAR_P, 3, CHAR_p, 3}, + {CHAR_S, 3, CHAR_s, 3}, + {CHAR_V, 3, CHAR_v, 3}, + {CHAR_Y, 2, CHAR_y, 2}, +}; +static const struct UnknownStruct3 gUnknown_083B57E4[] = +{ + {DexText_SearchForPoke, 0, 0, 5}, + {DexText_SwitchDex, 6, 0, 5}, + {DexText_ReturnToDex, 12, 0, 5}, +}; +static const struct UnknownStruct4 gUnknown_083B57FC[] = +{ + {DexText_ListByABC, 0, 2, 5, 5, 2, 12}, + {DexText_ListByColor, 0, 4, 5, 5, 4, 12}, + {DexText_ListByType, 0, 6, 5, 5, 6, 6}, + {DexText_ListByType, 0, 6, 5, 11, 6, 6}, + {DexText_SelectDexList, 0, 8, 5, 5, 8, 12}, + {DexText_SelectDexMode, 0, 10, 5, 5, 10, 12}, + {DexText_ExecuteSearchSwitch, 0, 12, 5, 0, 0, 0}, +}; +static const u8 gUnknown_083B5850[][4] = +{ + {0xFF, 0xFF, 0xFF, 1}, + {0xFF, 0xFF, 0, 2}, + {0xFF, 3, 1, 4}, + { 2, 0xFF, 1, 4}, + {0xFF, 0xFF, 2, 5}, + {0xFF, 0xFF, 4, 6}, + {0xFF, 0xFF, 5, 0xFF}, +}; +static const u8 gUnknown_083B586C[][4] = +{ + {0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xFF, 5}, + {0xFF, 0xFF, 4, 6}, + {0xFF, 0xFF, 5, 0xFF}, +}; +static const u8 gUnknown_083B5888[][4] = +{ + {0xFF, 0xFF, 0xFF, 1}, + {0xFF, 0xFF, 0, 2}, + {0xFF, 3, 1, 4}, + { 2, 0xFF, 1, 4}, + {0xFF, 0xFF, 2, 6}, + {0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 4, 0xFF}, +}; +static const u8 gUnknown_083B58A4[][4] = +{ + {0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xFF, 6}, + {0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 4, 0xFF}, +}; +static const struct UnknownStruct2 gUnknown_083B58C0[] = +{ + {DexText_HoennDex2, DexText_HoennDex}, + {DexText_NationalDex2, DexText_NationalDex}, + {NULL, NULL}, +}; +static const struct UnknownStruct2 gUnknown_083B58D8[] = +{ + {DexText_ListByNumber, DexText_NumericalMode}, + {DexText_ListByABC2, DexText_ABCMode}, + {DexText_ListByHeavyToLightest, DexText_HeaviestMode}, + {DexText_ListByLightToHeaviest, DexText_LightestMode}, + {DexText_ListByTallToSmallest, DexText_TallestMode}, + {DexText_ListBySmallToTallest, DexText_SmallestMode}, + {NULL, NULL}, +}; +static const struct UnknownStruct2 gUnknown_083B5910[] = +{ + {DexText_Terminator5, DexText_DontSpecify}, + {DexText_Terminator5, DexText_ABC}, + {DexText_Terminator5, DexText_DEF}, + {DexText_Terminator5, DexText_GHI}, + {DexText_Terminator5, DexText_JKL}, + {DexText_Terminator5, DexText_MNO}, + {DexText_Terminator5, DexText_PQR}, + {DexText_Terminator5, DexText_STU}, + {DexText_Terminator5, DexText_VWX}, + {DexText_Terminator5, DexText_YZ}, + {NULL, NULL}, +}; +static const struct UnknownStruct2 gUnknown_083B5968[] = +{ + {DexText_Terminator5, DexText_DontSpecify}, + {DexText_Terminator5, DexText_Red}, + {DexText_Terminator5, DexText_Blue}, + {DexText_Terminator5, DexText_Yellow}, + {DexText_Terminator5, DexText_Green}, + {DexText_Terminator5, DexText_Black}, + {DexText_Terminator5, DexText_Brown}, + {DexText_Terminator5, DexText_Purple}, + {DexText_Terminator5, DexText_Gray}, + {DexText_Terminator5, DexText_White}, + {DexText_Terminator5, DexText_Pink}, + {NULL, NULL}, +}; +static const struct UnknownStruct2 gUnknown_083B59C8[] = +{ + {DexText_Terminator5, DexText_None}, + {DexText_Terminator5, gTypeNames[TYPE_NORMAL]}, + {DexText_Terminator5, gTypeNames[TYPE_FIGHTING]}, + {DexText_Terminator5, gTypeNames[TYPE_FLYING]}, + {DexText_Terminator5, gTypeNames[TYPE_POISON]}, + {DexText_Terminator5, gTypeNames[TYPE_GROUND]}, + {DexText_Terminator5, gTypeNames[TYPE_ROCK]}, + {DexText_Terminator5, gTypeNames[TYPE_BUG]}, + {DexText_Terminator5, gTypeNames[TYPE_GHOST]}, + {DexText_Terminator5, gTypeNames[TYPE_STEEL]}, + {DexText_Terminator5, gTypeNames[TYPE_FIRE]}, + {DexText_Terminator5, gTypeNames[TYPE_WATER]}, + {DexText_Terminator5, gTypeNames[TYPE_GRASS]}, + {DexText_Terminator5, gTypeNames[TYPE_ELECTRIC]}, + {DexText_Terminator5, gTypeNames[TYPE_PSYCHIC]}, + {DexText_Terminator5, gTypeNames[TYPE_ICE]}, + {DexText_Terminator5, gTypeNames[TYPE_DRAGON]}, + {DexText_Terminator5, gTypeNames[TYPE_DARK]}, + {NULL, NULL}, +}; +static const u8 gUnknown_083B5A60[] = {0, 1}; +static const u8 gUnknown_083B5A62[] = {0, 1, 2, 3, 4, 5}; +static const u8 gUnknown_083B5A68[] = {0xFF, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17}; +static const struct UnknownStruct1 gUnknown_083B5A7C[] = +{ + {gUnknown_083B5910, 6, 7, 10}, + {gUnknown_083B5968, 8, 9, 11}, + {gUnknown_083B59C8, 10, 11, 18}, + {gUnknown_083B59C8, 12, 13, 18}, + {gUnknown_083B58D8, 4, 5, 6}, + {gUnknown_083B58C0, 2, 3, 2}, +}; +static const u8 gUnknown_083B5AAC[] = _("{STR_VAR_1}{CLEAR_TO 43}"); +static const u8 gUnknown_083B5AB2[] = _("{STR_VAR_1}{CLEAR_TO 96}"); + +static void MainCB(void); +static void Task_PokedexShowMainScreen(u8 taskId); +static void Task_PokedexMainScreen(u8 taskId); +static void sub_808C898(u8 taskId); +static void Task_PokedexMainScreenMenu(u8 taskId); +static void sub_808CA64(u8 taskId); +static void sub_808CAE4(u8 taskId); +static void sub_808CB8C(u8 taskId); +static void Task_ClosePokedex(u8 taskId); +static void sub_808CCC4(u8 taskId); +static void Task_PokedexResultsScreen(u8 taskId); +static void sub_808CEF8(u8 taskId); +static void Task_PokedexResultsScreenMenu(u8 taskId); +static void sub_808D118(u8 taskId); +static void sub_808D198(u8 taskId); +static void Task_PokedexResultsScreenReturnToMainScreen(u8 taskId); +static void Task_PokedexResultsScreenExitPokedex(u8 taskId); +static bool8 sub_808D344(u8 a); +static void sub_808D640(void); +static void SortPokedex(u8 dexMode, u8 sortMode); +static void sub_808DEB0(u16 a, u8 b, u8 c, u16 d); +static void sub_808DF88(u16 a, u8 b, u8 c, u16 d); +static u8 sub_808DFE4(u16 num, u8 b, u8 c); +static void sub_808E090(u8 a, u8 b, u16 c); +static void sub_808E0CC(u16 a, u16 b); +static bool8 sub_808E208(u8 a, u8 b, u8 c); +static u16 sub_808E48C(u16 a, u16 b); +static void sub_808E6BC(void); +static u8 sub_808E71C(void); +static u8 sub_808E82C(void); +static u16 sub_808E888(u16 a1); +static u32 sub_808E8C8(u16 a, s16 b, s16 c); +static void sub_808E978(u8 a); +static void sub_808EDB8(struct Sprite *sprite); +static void sub_808EE28(struct Sprite *sprite); +static u8 sub_808F210(struct PokedexListItem *, u8); +static bool8 sub_808F250(u8 taskId); +static u8 sub_808F284(struct PokedexListItem *, u8); +static void Task_InitPageScreenMultistep(u8 taskId); +static void Task_PageScreenProcessInput(u8 taskId); +static void sub_808F888(u8 taskId); +static void Task_ClosePageScreen(u8 taskId); +static void Task_InitAreaScreenMultistep(u8 taskId); +static void Task_AreaScreenProcessInput(u8 taskId); +static void sub_808FA00(u8 taskId); +static void Task_InitCryScreenMultistep(u8 taskId); +static void Task_CryScreenProcessInput(u8 taskId); +static void sub_808FFBC(u8 taskId); +static void sub_8090040(u8 a); +static void Task_InitSizeScreenMultistep(u8 taskId); +static void Task_SizeScreenProcessInput(u8 taskId); +static void sub_8090498(u8 taskId); +static void sub_80904FC(u16 a); +static void sub_8090540(u16 a); +static void sub_8090584(u8 a, u16 b); +static void sub_8090644(u8 a, u16 b); +static void sub_8090750(u8); +static void sub_8090A3C(u8); +static void sub_8090B8C(u8); +static void sub_8090C28(struct Sprite *); +static void sub_8090C68(void); +static void sub_8091060(u16); +static void sub_8091154(u16 order, u8, u8); +static u8 sub_80911C8(u16 num, u8, u8); +static u8 sub_8091260(u16 num, u8, u8, u8); +static void sub_8091304(const u8 *name, u8, u8); +static void sub_8091458(u16 height, u8 i, u8 i1); +static void sub_8091564(u16 weight, u8 i, u8 i1); +static void sub_8091738(u16, u16, u16); +static void sub_80917CC(u16 i, u16 i1); +static u16 sub_8091818(u8, u16, u16, u16); +static u16 sub_80918EC(u16 a, s16 b, s16 c, u16 d); +static u8 sub_8091A4C(u16 gender, s16, s16, u16); +static void sub_8091E54(u8); +static void sub_809204C(u8); +static void sub_809207C(u8); +static void sub_809217C(u8); +static void sub_80921B0(u8); +static void sub_80923FC(u8); +static void sub_80924A4(u8); +static void sub_8092508(u8); +static void sub_80925CC(u8); +static void sub_8092644(u8); +static void sub_80927B8(u8); +static void sub_80927F0(u8); +static void sub_8092AB0(u8); +static void sub_8092AD4(u8, u8); +static void sub_8092B68(u8); +static void sub_8092C8C(u8); +static void sub_8092D78(u8); +static u8 sub_8092E10(u8, u8); +static void sub_8092EB0(u8); +static void sub_809308C(u8); + + +void ResetPokedex(void) { u16 i; - + gUnknown_0202FFB8 = 0; gUnknown_0202FFBA = 0x40; gUnknown_03005CE8 = 0; @@ -144,8 +1313,8 @@ void sub_808C02C(void) gSaveBlock2.pokedex.unownPersonality = 0; gSaveBlock2.pokedex.spindaPersonality = 0; gSaveBlock2.pokedex.unknown3 = 0; - sub_80690C8(); - for(i = 0; i <= 51; i++) + DisableNationalPokedex(); + for (i = 0; i <= 51; i++) { gSaveBlock2.pokedex.owned[i] = 0; gSaveBlock2.pokedex.seen[i] = 0; @@ -160,18 +1329,18 @@ void sub_808C0A0(void) gUnknown_0202FFBA = 0x40; } -void sub_808C0B8(void) +static void sub_808C0B8(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -void ClearPokedexView(struct PokedexView *pokedexView) +static void ClearPokedexView(struct PokedexView *pokedexView) { u16 i; - - for(i = 0; i <= 385; i++) + + for (i = 0; i < NATIONAL_DEX_COUNT; i++) { pokedexView->unk0[i].dexNum |= 0xFFFF; pokedexView->unk0[i].seen = 0; @@ -180,7 +1349,7 @@ void ClearPokedexView(struct PokedexView *pokedexView) pokedexView->unk608 = 0; pokedexView->unk60A_1 = 0; pokedexView->unk60A_2 = 0; - pokedexView->unk60C = 0; + pokedexView->pokemonListCount = 0; pokedexView->selectedPokemon = 0; pokedexView->unk610 = 0; pokedexView->dexMode = 0; @@ -189,7 +1358,7 @@ void ClearPokedexView(struct PokedexView *pokedexView) pokedexView->unk618 = 0; pokedexView->unk61A = 0; pokedexView->unk61C = 0; - for(i = 0; i <= 3; i++) + for (i = 0; i <= 3; i++) pokedexView->unk61E[i] |= 0xFFFF; pokedexView->unk628 = 0; pokedexView->unk62A = 0; @@ -202,7 +1371,7 @@ void ClearPokedexView(struct PokedexView *pokedexView) pokedexView->unk634 = 0; pokedexView->unk636 = 0; pokedexView->unk638 = 0; - for(i = 0; i <= 3; i++) + for (i = 0; i <= 3; i++) pokedexView->unk63A[i] = 0; pokedexView->unk64A = 0; pokedexView->unk64B = 0; @@ -212,32 +1381,32 @@ void ClearPokedexView(struct PokedexView *pokedexView) pokedexView->menuIsOpen = 0; pokedexView->menuCursorPos = 0; pokedexView->menuY = 0; - for(i = 0; i <= 7; i++) + for (i = 0; i <= 7; i++) pokedexView->unk656[i] = 0; - for(i = 0; i <= 7; i++) + for (i = 0; i <= 7; i++) pokedexView->unk65E[i] = 0; } void CB2_InitPokedex(void) { - switch(gMain.state) + switch (gMain.state) { - case 0: - default: + case 0: + default: { u8 *addr; u32 size; - + SetVBlankCallback(NULL); sub_8091060(0); addr = (u8 *)VRAM; size = VRAM_SIZE; - while(1) + while (1) { DmaFill16(3, 0, addr, 0x1000); addr += 0x1000; size -= 0x1000; - if(size <= 0x1000) + if (size <= 0x1000) { DmaFill16(3, 0, addr, size); break; @@ -246,63 +1415,63 @@ void CB2_InitPokedex(void) DmaClear32(3, OAM, OAM_SIZE); DmaClear16(3, PLTT, PLTT_SIZE); gMain.state = 1; - break; } + break; + case 1: + remove_some_task(); + ResetTasks(); + ResetSpriteData(); + ResetPaletteFade(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 8; + SetUpWindowConfig(&gWindowConfig_81E7048); + InitMenuWindow(&gWindowConfig_81E7048); + gMain.state++; + break; + case 2: + switch (Random() & 3) + { + case 0: + default: + gPokedexView = (struct PokedexView *)0x02018000; + break; case 1: - remove_some_task(); - ResetTasks(); - ResetSpriteData(); - ResetPaletteFade(); - FreeAllSpritePalettes(); - gReservedSpritePaletteCount = 8; - SetUpWindowConfig(&gWindowConfig_81E7048); - InitMenuWindow(&gWindowConfig_81E7048); - gMain.state++; + gPokedexView = (struct PokedexView *)0x02018800; break; case 2: - switch(Random() & 3) - { - case 0: - default: - gPokedexView = (struct PokedexView *)0x02018000; - break; - case 1: - gPokedexView = (struct PokedexView *)0x02018800; - break; - case 2: - gPokedexView = (struct PokedexView *)0x02019000; - break; - case 3: - gPokedexView = (struct PokedexView *)0x02019800; - break; - } - ClearPokedexView(gPokedexView); - CreateTask(Task_PokedexShowMainScreen, 0); - gPokedexView->dexMode = gSaveBlock2.pokedex.unknown1; - if(!IsNationalPokedex()) - gPokedexView->dexMode = DEX_MODE_HOENN; - gPokedexView->dexOrder = gSaveBlock2.pokedex.order; - gPokedexView->selectedPokemon = gUnknown_0202FFB8; - gPokedexView->unk62C = gUnknown_0202FFBA; - gPokedexView->selectedScreen = PAGE_SCREEN; - gPokedexView->unk64E = 0; - if(!IsNationalPokedex()) - { - gPokedexView->unk61A = GetHoennPokedexCount(0); - gPokedexView->unk61C = GetHoennPokedexCount(1); - } - else - { - gPokedexView->unk61A = GetNationalPokedexCount(0); - gPokedexView->unk61C = GetNationalPokedexCount(1); - } - gPokedexView->unk62D = 8; - gMain.state++; + gPokedexView = (struct PokedexView *)0x02019000; break; case 3: + gPokedexView = (struct PokedexView *)0x02019800; + break; + } + ClearPokedexView(gPokedexView); + CreateTask(Task_PokedexShowMainScreen, 0); + gPokedexView->dexMode = gSaveBlock2.pokedex.unknown1; + if (!IsNationalPokedexEnabled()) + gPokedexView->dexMode = DEX_MODE_HOENN; + gPokedexView->dexOrder = gSaveBlock2.pokedex.order; + gPokedexView->selectedPokemon = gUnknown_0202FFB8; + gPokedexView->unk62C = gUnknown_0202FFBA; + gPokedexView->selectedScreen = PAGE_SCREEN; + gPokedexView->descriptionPageNum = 0; + if (!IsNationalPokedexEnabled()) + { + gPokedexView->unk61A = GetHoennPokedexCount(0); + gPokedexView->unk61C = GetHoennPokedexCount(1); + } + else + { + gPokedexView->unk61A = GetNationalPokedexCount(0); + gPokedexView->unk61C = GetNationalPokedexCount(1); + } + gPokedexView->unk62D = 8; + gMain.state++; + break; + case 3: { u16 savedIme; - + savedIme = REG_IME; REG_IME = 0; REG_IE |= 1; @@ -313,6 +1482,7 @@ void CB2_InitPokedex(void) SortPokedex(gPokedexView->dexMode, gPokedexView->dexOrder); m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x80); } + break; } } @@ -320,7 +1490,7 @@ u8 unref_sub_808C540(void (*func)(u8)) { u16 savedIme; u8 taskId; - + SetVBlankCallback(NULL); sub_8091060(0x200); remove_some_task(); @@ -333,7 +1503,7 @@ u8 unref_sub_808C540(void (*func)(u8)) REG_DISPSTAT |= 0x8; SetVBlankCallback(sub_808C0B8); SetMainCallback2(MainCB); - if(!gPokedexView->unk64B) + if (!gPokedexView->unk64B) taskId = CreateTask(sub_808CAE4, 0); else taskId = CreateTask(sub_808D198, 0); @@ -341,7 +1511,7 @@ u8 unref_sub_808C540(void (*func)(u8)) return gTasks[taskId].data[0]; } -void MainCB(void) +static void MainCB(void) { RunTasks(); AnimateSprites(); @@ -349,36 +1519,34 @@ void MainCB(void) UpdatePaletteFade(); } -void Task_PokedexShowMainScreen(u8 taskId) +static void Task_PokedexShowMainScreen(u8 taskId) { gPokedexView->unk64C_1 = 0; - if(sub_808D344(0)) - { + if (sub_808D344(0)) gTasks[taskId].func = Task_PokedexMainScreen; - } } //Hide menu and process input on main screen void Task_PokedexMainScreen(u8 taskId) { REG_BG0VOFS = gPokedexView->menuY; - + //If menu is open, slide it down, off screen - if(gPokedexView->menuY) + if (gPokedexView->menuY) gPokedexView->menuY -= 8; else { - if((gMain.newKeys & A_BUTTON) && gPokedexView->unk0[gPokedexView->selectedPokemon].seen) + if ((gMain.newKeys & A_BUTTON) && gPokedexView->unk0[gPokedexView->selectedPokemon].seen) { sub_808E6BC(); BeginNormalPaletteFade( - ~(1 << (gSprites[gPokedexView->unk626].oam.paletteNum + 16)), + ~(1 << (gSprites[gPokedexView->selectedMonSpriteId].oam.paletteNum + 16)), 0, 0, 0x10, 0); - gSprites[gPokedexView->unk626].callback = sub_808EDB8; + gSprites[gPokedexView->selectedMonSpriteId].callback = sub_808EDB8; gTasks[taskId].func = sub_808CA64; PlaySE(SE_PIN); } - else if(gMain.newKeys & START_BUTTON) + else if (gMain.newKeys & START_BUTTON) { //Open menu gPokedexView->menuY = 0; @@ -387,7 +1555,7 @@ void Task_PokedexMainScreen(u8 taskId) gTasks[taskId].func = Task_PokedexMainScreenMenu; PlaySE(SE_SELECT); } - else if(gMain.newKeys & SELECT_BUTTON) + else if (gMain.newKeys & SELECT_BUTTON) { PlaySE(SE_SELECT); BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); @@ -400,7 +1568,7 @@ void Task_PokedexMainScreen(u8 taskId) gTasks[taskId].func = sub_808CB8C; PlaySE(SE_PC_LOGON); } - else if(gMain.newKeys & B_BUTTON) + else if (gMain.newKeys & B_BUTTON) { BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); gTasks[taskId].func = Task_ClosePokedex; @@ -410,73 +1578,71 @@ void Task_PokedexMainScreen(u8 taskId) { //Handle D-pad gPokedexView->selectedPokemon = sub_808E48C(gPokedexView->selectedPokemon, 0xE); - if(gPokedexView->unk62E) + if (gPokedexView->unk62E) gTasks[taskId].func = sub_808C898; } } } -void sub_808C898(u8 taskId) +static void sub_808C898(u8 taskId) { - if(sub_808E208(gPokedexView->unk62F, gPokedexView->unk634, gPokedexView->unk636)) - { + if (sub_808E208(gPokedexView->unk62F, gPokedexView->unk634, gPokedexView->unk636)) gTasks[taskId].func = Task_PokedexMainScreen; - } } //Bring up menu and process menu input -void Task_PokedexMainScreenMenu(u8 taskId) +static void Task_PokedexMainScreenMenu(u8 taskId) { REG_BG0VOFS = gPokedexView->menuY; - + //If menu is not open, slide it up, on screen - if(gPokedexView->menuY != 80) + if (gPokedexView->menuY != 80) gPokedexView->menuY += 8; else { - if(gMain.newKeys & A_BUTTON) + if (gMain.newKeys & A_BUTTON) { - switch(gPokedexView->menuCursorPos) + switch (gPokedexView->menuCursorPos) { - case 0: //BACK TO LIST - default: - gMain.newKeys |= START_BUTTON; //Exit menu - break; - case 1: //LIST TOP - gPokedexView->selectedPokemon = 0; - gPokedexView->unk62C = 0x40; - sub_808E82C(); - sub_808E0CC(gPokedexView->selectedPokemon, 0xE); - gMain.newKeys |= START_BUTTON; //Exit menu - break; - case 2: //LIST BOTTOM - gPokedexView->selectedPokemon = gPokedexView->unk60C - 1; - gPokedexView->unk62C = gPokedexView->unk60C * 16 + 0x30; - sub_808E82C(); - sub_808E0CC(gPokedexView->selectedPokemon, 0xE); - gMain.newKeys |= START_BUTTON; //Exit menu - break; - case 3: //CLOSE POKEDEX - BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - gTasks[taskId].func = Task_ClosePokedex; - PlaySE(SE_PC_OFF); - break; + case 0: //BACK TO LIST + default: + gMain.newKeys |= START_BUTTON; //Exit menu + break; + case 1: //LIST TOP + gPokedexView->selectedPokemon = 0; + gPokedexView->unk62C = 0x40; + sub_808E82C(); + sub_808E0CC(gPokedexView->selectedPokemon, 0xE); + gMain.newKeys |= START_BUTTON; //Exit menu + break; + case 2: //LIST BOTTOM + gPokedexView->selectedPokemon = gPokedexView->pokemonListCount - 1; + gPokedexView->unk62C = gPokedexView->pokemonListCount * 16 + 0x30; + sub_808E82C(); + sub_808E0CC(gPokedexView->selectedPokemon, 0xE); + gMain.newKeys |= START_BUTTON; //Exit menu + break; + case 3: //CLOSE POKEDEX + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gTasks[taskId].func = Task_ClosePokedex; + PlaySE(SE_PC_OFF); + break; } } - + //Exit menu when Start or B is pressed - if(gMain.newKeys & (START_BUTTON | B_BUTTON)) + if (gMain.newKeys & (START_BUTTON | B_BUTTON)) { gPokedexView->menuIsOpen = 0; gTasks[taskId].func = Task_PokedexMainScreen; PlaySE(SE_SELECT); } - else if((gMain.newAndRepeatedKeys & DPAD_UP) && gPokedexView->menuCursorPos != 0) + else if ((gMain.newAndRepeatedKeys & DPAD_UP) && gPokedexView->menuCursorPos != 0) { gPokedexView->menuCursorPos--; PlaySE(SE_SELECT); } - else if((gMain.newAndRepeatedKeys & DPAD_DOWN) && gPokedexView->menuCursorPos <= 2) + else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && gPokedexView->menuCursorPos <= 2) { gPokedexView->menuCursorPos++; PlaySE(SE_SELECT); @@ -484,27 +1650,23 @@ void Task_PokedexMainScreenMenu(u8 taskId) } } -void sub_808CA64(u8 taskId) +static void sub_808CA64(u8 taskId) { - if(gSprites[gPokedexView->unk626].pos1.x == 0x30 && - gSprites[gPokedexView->unk626].pos1.y == 0x38) + if (gSprites[gPokedexView->selectedMonSpriteId].pos1.x == 48 + && gSprites[gPokedexView->selectedMonSpriteId].pos1.y == 56) { gPokedexView->unk64B = gPokedexView->unk64A; - gTasks[taskId].data[0] = sub_808F210(&gPokedexView->unk0[gPokedexView->selectedPokemon], gPokedexView->unk626); + gTasks[taskId].data[0] = sub_808F210(&gPokedexView->unk0[gPokedexView->selectedPokemon], gPokedexView->selectedMonSpriteId); gTasks[taskId].func = sub_808CAE4; } } -void sub_808CAE4(u8 taskId) +static void sub_808CAE4(u8 taskId) { - if(gTasks[gTasks[taskId].data[0]].isActive) + if (gTasks[gTasks[taskId].data[0]].isActive) { - if(gPokedexView->unk64A == 1 && - !sub_808F250(gTasks[taskId].data[0]) && - sub_808E71C()) - { + if (gPokedexView->unk64A == 1 && !sub_808F250(gTasks[taskId].data[0]) && sub_808E71C()) sub_808F284(&gPokedexView->unk0[gPokedexView->selectedPokemon], gTasks[taskId].data[0]); - } } else { @@ -514,13 +1676,13 @@ void sub_808CAE4(u8 taskId) } } -void sub_808CB8C(u8 taskId) +static void sub_808CB8C(u8 taskId) { bool8 isActive = gTasks[gTasks[taskId].data[0]].isActive; - - if(!isActive) + + if (!isActive) { - if(gPokedexView->unk64F) + if (gPokedexView->unk64F != 0) { gPokedexView->selectedPokemon = isActive; gPokedexView->unk62C = 0x40; @@ -531,7 +1693,7 @@ void sub_808CB8C(u8 taskId) gPokedexView->unk62C = gPokedexView->unk62A; gPokedexView->selectedPokemon = gPokedexView->unk610; gPokedexView->dexMode = gPokedexView->unk614; - if(!IsNationalPokedex()) + if (!IsNationalPokedexEnabled()) gPokedexView->dexMode = DEX_MODE_HOENN; gPokedexView->dexOrder = gPokedexView->unk618; gTasks[taskId].func = Task_PokedexShowMainScreen; @@ -539,12 +1701,12 @@ void sub_808CB8C(u8 taskId) } } -void Task_ClosePokedex(u8 taskId) +static void Task_ClosePokedex(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { gSaveBlock2.pokedex.unknown1 = gPokedexView->dexMode; - if(!IsNationalPokedex()) + if (!IsNationalPokedexEnabled()) gSaveBlock2.pokedex.unknown1 = 0; gSaveBlock2.pokedex.order = gPokedexView->dexOrder; DestroyTask(taskId); @@ -553,33 +1715,35 @@ void Task_ClosePokedex(u8 taskId) } } -void sub_808CCC4(u8 taskId) +static void sub_808CCC4(u8 taskId) { gPokedexView->unk64C_1 = 1; - if(sub_808D344(3)) + if (sub_808D344(3)) gTasks[taskId].func = Task_PokedexResultsScreen; } -void Task_PokedexResultsScreen(u8 taskId) +static void Task_PokedexResultsScreen(u8 taskId) { REG_BG0VOFS = gPokedexView->menuY; - - if(gPokedexView->menuY) + + if (gPokedexView->menuY) + { gPokedexView->menuY -= 8; + } else { - if((gMain.newKeys & A_BUTTON) && gPokedexView->unk0[gPokedexView->selectedPokemon].seen) + if ((gMain.newKeys & A_BUTTON) && gPokedexView->unk0[gPokedexView->selectedPokemon].seen) { u32 a; - + sub_808E6BC(); - a = (1 << (gSprites[gPokedexView->unk626].oam.paletteNum + 16)); - gSprites[gPokedexView->unk626].callback = sub_808EDB8; + a = (1 << (gSprites[gPokedexView->selectedMonSpriteId].oam.paletteNum + 16)); + gSprites[gPokedexView->selectedMonSpriteId].callback = sub_808EDB8; BeginNormalPaletteFade(~a, 0, 0, 0x10, 0); gTasks[taskId].func = sub_808D118; PlaySE(SE_PIN); } - else if(gMain.newKeys & START_BUTTON) + else if (gMain.newKeys & START_BUTTON) { gPokedexView->menuY = 0; gPokedexView->menuIsOpen = 1; @@ -587,7 +1751,7 @@ void Task_PokedexResultsScreen(u8 taskId) gTasks[taskId].func = Task_PokedexResultsScreenMenu; PlaySE(SE_SELECT); } - else if(gMain.newKeys & SELECT_BUTTON) + else if (gMain.newKeys & SELECT_BUTTON) { BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); gTasks[taskId].data[0] = sub_8091E3C(); @@ -595,7 +1759,7 @@ void Task_PokedexResultsScreen(u8 taskId) gTasks[taskId].func = sub_808CB8C; PlaySE(SE_PC_LOGON); } - else if(gMain.newKeys & B_BUTTON) + else if (gMain.newKeys & B_BUTTON) { BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); gTasks[taskId].func = Task_PokedexResultsScreenReturnToMainScreen; @@ -603,76 +1767,78 @@ void Task_PokedexResultsScreen(u8 taskId) } else { - //Handle D-pad + //Handle D-pad gPokedexView->selectedPokemon = sub_808E48C(gPokedexView->selectedPokemon, 0xE); - if(gPokedexView->unk62E) + if (gPokedexView->unk62E) gTasks[taskId].func = sub_808CEF8; } } } -void sub_808CEF8(u8 taskId) +static void sub_808CEF8(u8 taskId) { - if(sub_808E208(gPokedexView->unk62F, gPokedexView->unk634, gPokedexView->unk636)) + if (sub_808E208(gPokedexView->unk62F, gPokedexView->unk634, gPokedexView->unk636)) gTasks[taskId].func = Task_PokedexResultsScreen; } -void Task_PokedexResultsScreenMenu(u8 taskId) +static void Task_PokedexResultsScreenMenu(u8 taskId) { REG_BG0VOFS = gPokedexView->menuY; - - if(gPokedexView->menuY != 0x60) + + if (gPokedexView->menuY != 96) + { gPokedexView->menuY += 8; + } else { - if(gMain.newKeys & A_BUTTON) + if (gMain.newKeys & A_BUTTON) { - switch(gPokedexView->menuCursorPos) + switch (gPokedexView->menuCursorPos) { - case 0: //BACK TO LIST - default: - gMain.newKeys |= START_BUTTON; - break; - case 1: //LIST TOP - gPokedexView->selectedPokemon = 0; - gPokedexView->unk62C = 0x40; - sub_808E82C(); - sub_808E0CC(gPokedexView->selectedPokemon, 0xE); - gMain.newKeys |= START_BUTTON; - break; - case 2: //LIST BOTTOM - gPokedexView->selectedPokemon = gPokedexView->unk60C - 1; - gPokedexView->unk62C = gPokedexView->unk60C * 16 + 0x30; - sub_808E82C(); - sub_808E0CC(gPokedexView->selectedPokemon, 0xE); - gMain.newKeys |= START_BUTTON; - break; - case 3: //BACK TO POKEDEX - BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - gTasks[taskId].func = Task_PokedexResultsScreenReturnToMainScreen; - PlaySE(SE_TRACK_DOOR); - break; - case 4: //CLOSE POKEDEX - BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - gTasks[taskId].func = Task_PokedexResultsScreenExitPokedex; - PlaySE(SE_PC_OFF); - break; + case 0: //BACK TO LIST + default: + gMain.newKeys |= START_BUTTON; + break; + case 1: //LIST TOP + gPokedexView->selectedPokemon = 0; + gPokedexView->unk62C = 0x40; + sub_808E82C(); + sub_808E0CC(gPokedexView->selectedPokemon, 0xE); + gMain.newKeys |= START_BUTTON; + break; + case 2: //LIST BOTTOM + gPokedexView->selectedPokemon = gPokedexView->pokemonListCount - 1; + gPokedexView->unk62C = gPokedexView->pokemonListCount * 16 + 0x30; + sub_808E82C(); + sub_808E0CC(gPokedexView->selectedPokemon, 0xE); + gMain.newKeys |= START_BUTTON; + break; + case 3: //BACK TO POKEDEX + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gTasks[taskId].func = Task_PokedexResultsScreenReturnToMainScreen; + PlaySE(SE_TRACK_DOOR); + break; + case 4: //CLOSE POKEDEX + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gTasks[taskId].func = Task_PokedexResultsScreenExitPokedex; + PlaySE(SE_PC_OFF); + break; } } - + //Exit menu when Start or B is pressed - if(gMain.newKeys & (START_BUTTON | B_BUTTON)) + if (gMain.newKeys & (START_BUTTON | B_BUTTON)) { gPokedexView->menuIsOpen = 0; gTasks[taskId].func = Task_PokedexResultsScreen; PlaySE(SE_SELECT); } - else if((gMain.newAndRepeatedKeys & DPAD_UP) && gPokedexView->menuCursorPos) + else if ((gMain.newAndRepeatedKeys & DPAD_UP) && gPokedexView->menuCursorPos) { gPokedexView->menuCursorPos--; PlaySE(SE_SELECT); } - else if((gMain.newAndRepeatedKeys & DPAD_DOWN) && gPokedexView->menuCursorPos <= 3) + else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && gPokedexView->menuCursorPos <= 3) { gPokedexView->menuCursorPos++; PlaySE(SE_SELECT); @@ -680,27 +1846,23 @@ void Task_PokedexResultsScreenMenu(u8 taskId) } } -void sub_808D118(u8 taskId) +static void sub_808D118(u8 taskId) { - if(gSprites[gPokedexView->unk626].pos1.x == 0x30 && - gSprites[gPokedexView->unk626].pos1.y == 0x38) + if (gSprites[gPokedexView->selectedMonSpriteId].pos1.x == 48 + && gSprites[gPokedexView->selectedMonSpriteId].pos1.y == 56) { gPokedexView->unk64B = gPokedexView->unk64A; - gTasks[taskId].data[0] = sub_808F210(&gPokedexView->unk0[gPokedexView->selectedPokemon], gPokedexView->unk626); + gTasks[taskId].data[0] = sub_808F210(&gPokedexView->unk0[gPokedexView->selectedPokemon], gPokedexView->selectedMonSpriteId); gTasks[taskId].func = sub_808D198; } } -void sub_808D198(u8 taskId) +static void sub_808D198(u8 taskId) { - if(gTasks[gTasks[taskId].data[0]].isActive) + if (gTasks[gTasks[taskId].data[0]].isActive) { - if(gPokedexView->unk64A == 1 && - !sub_808F250(gTasks[taskId].data[0]) && - sub_808E71C()) - { + if (gPokedexView->unk64A == 1 && !sub_808F250(gTasks[taskId].data[0]) && sub_808E71C()) sub_808F284(&gPokedexView->unk0[gPokedexView->selectedPokemon], gTasks[taskId].data[0]); - } } else { @@ -708,271 +1870,267 @@ void sub_808D198(u8 taskId) } } -void Task_PokedexResultsScreenReturnToMainScreen(u8 taskId) +static void Task_PokedexResultsScreenReturnToMainScreen(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { gPokedexView->unk62C = gPokedexView->unk62A; gPokedexView->selectedPokemon = gPokedexView->unk610; gPokedexView->dexMode = gPokedexView->unk614; - if(!IsNationalPokedex()) + if (!IsNationalPokedexEnabled()) gPokedexView->dexMode = DEX_MODE_HOENN; gPokedexView->dexOrder = gPokedexView->unk618; gTasks[taskId].func = Task_PokedexShowMainScreen; } } -void Task_PokedexResultsScreenExitPokedex(u8 taskId) +static void Task_PokedexResultsScreenExitPokedex(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { gPokedexView->unk62C = gPokedexView->unk62A; gPokedexView->selectedPokemon = gPokedexView->unk610; gPokedexView->dexMode = gPokedexView->unk614; - if(!IsNationalPokedex()) + if (!IsNationalPokedexEnabled()) gPokedexView->dexMode = DEX_MODE_HOENN; gPokedexView->dexOrder = gPokedexView->unk618; gTasks[taskId].func = Task_ClosePokedex; } } - -bool8 sub_808D344(u8 a) +static bool8 sub_808D344(u8 a) { - switch(gMain.state) + switch (gMain.state) { - case 0: - default: - if(gPaletteFade.active) - return 0; - //_0808D39E - SetVBlankCallback(NULL); - gPokedexView->unk64A = a; - sub_8091060(0); - REG_BG2VOFS = gPokedexView->unk62D; - LZ77UnCompVram(gPokedexMenu_Gfx, (void *)(VRAM)); - LZ77UnCompVram(gUnknown_08E96738, (void *)(VRAM + 0x6800)); - LZ77UnCompVram(gUnknown_08E9C6DC, (void *)(VRAM + 0x7800)); - DmaClear16(3, VRAM + 0x6000, 0x500); - if(a == 0) - LZ77UnCompVram(gUnknown_08E96888, (void *)(VRAM + 0x6500)); - else - LZ77UnCompVram(gUnknown_08E96994, (void *)(VRAM + 0x6500)); - ResetPaletteFade(); - if(a == 0) - gPokedexView->unk64C_1 = 0; - else - gPokedexView->unk64C_1 = 1; - sub_808D640(); - gMain.state = 1; - break; - case 1: - ResetSpriteData(); - FreeAllSpritePalettes(); - gReservedSpritePaletteCount = 8; - LoadCompressedObjectPic(&gUnknown_083A05CC); - LoadSpritePalettes(gUnknown_083A05DC); - sub_808E978(a); - gMain.state++; - break; - case 2: - SetUpWindowConfig(&gWindowConfig_81E7048); - InitMenuWindow(&gWindowConfig_81E7048); - LZ77UnCompVram(gUnknown_0839FA7C, (void *)(VRAM + 0xFF80)); - gMain.state++; - break; - case 3: - if(a == 0) - SortPokedex(gPokedexView->dexMode, gPokedexView->dexOrder); - sub_808E0CC(gPokedexView->selectedPokemon, 0xE); - gPokedexView->menuIsOpen = 0; - gPokedexView->menuY = 0; - gMain.state++; - break; - case 4: - BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - SetVBlankCallback(sub_808C0B8); - gMain.state++; - break; - case 5: - REG_WININ = 0x3F3F; - REG_WINOUT = 0x1D3F; - REG_WIN0H = 0; - REG_WIN0V = 0; - REG_WIN1H = 0; - REG_WIN1V = 0; - REG_BLDCNT = 0; - REG_BLDALPHA = 0; - REG_BLDY = 0; - REG_BG3CNT = 0xF03; - REG_BG1CNT = 0xD01; - REG_BG0CNT = 0xC00; - REG_DISPCNT = 0x9F40; - gMain.state++; - break; - case 6: - if(!gPaletteFade.active) - { - gMain.state = 0; - return 1; - } - else - return 0; + case 0: + default: + if (gPaletteFade.active) + return 0; + SetVBlankCallback(NULL); + gPokedexView->unk64A = a; + sub_8091060(0); + REG_BG2VOFS = gPokedexView->unk62D; + LZ77UnCompVram(gPokedexMenu_Gfx, (void *)(VRAM)); + LZ77UnCompVram(gUnknown_08E96738, (void *)(VRAM + 0x6800)); + LZ77UnCompVram(gUnknown_08E9C6DC, (void *)(VRAM + 0x7800)); + DmaClear16(3, VRAM + 0x6000, 0x500); + if (a == 0) + LZ77UnCompVram(gUnknown_08E96888, (void *)(VRAM + 0x6500)); + else + LZ77UnCompVram(gUnknown_08E96994, (void *)(VRAM + 0x6500)); + ResetPaletteFade(); + if (a == 0) + gPokedexView->unk64C_1 = 0; + else + gPokedexView->unk64C_1 = 1; + sub_808D640(); + gMain.state = 1; + break; + case 1: + ResetSpriteData(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 8; + LoadCompressedObjectPic(&gUnknown_083A05CC[0]); + LoadSpritePalettes(gUnknown_083A05DC); + sub_808E978(a); + gMain.state++; + break; + case 2: + SetUpWindowConfig(&gWindowConfig_81E7048); + InitMenuWindow(&gWindowConfig_81E7048); + LZ77UnCompVram(gUnknown_0839FA7C, (void *)(VRAM + 0xFF80)); + gMain.state++; + break; + case 3: + if (a == 0) + SortPokedex(gPokedexView->dexMode, gPokedexView->dexOrder); + sub_808E0CC(gPokedexView->selectedPokemon, 0xE); + gPokedexView->menuIsOpen = 0; + gPokedexView->menuY = 0; + gMain.state++; + break; + case 4: + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + SetVBlankCallback(sub_808C0B8); + gMain.state++; + break; + case 5: + REG_WININ = 0x3F3F; + REG_WINOUT = 0x1D3F; + REG_WIN0H = 0; + REG_WIN0V = 0; + REG_WIN1H = 0; + REG_WIN1V = 0; + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + REG_BLDY = 0; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(15) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(13) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(12) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON | DISPCNT_OBJWIN_ON; + gMain.state++; + break; + case 6: + if (!gPaletteFade.active) + { + gMain.state = 0; + return TRUE; + } + break; } - return 0; + return FALSE; } -void sub_808D640(void) +static void sub_808D640(void) { - if(gPokedexView->unk64C_1) - LoadPalette(gUnknown_0839F67C + 0x2, 1, 0xBE); - else if(!IsNationalPokedex()) - LoadPalette(gPokedexMenu_Pal + 0x2, 1, 0xBE); + if (gPokedexView->unk64C_1) + LoadPalette(sPokedexSearchPalette + 1, 1, sizeof(sPokedexSearchPalette) - sizeof(u16)); + else if (!IsNationalPokedexEnabled()) + LoadPalette(gPokedexMenu_Pal + 1, 1, 0xBE); else - LoadPalette(gUnknown_0839F73C + 0x2, 1, 0xBE); + LoadPalette(sNationalPokedexPalette + 1, 1, sizeof(sNationalPokedexPalette) - sizeof(u16)); } -void SortPokedex(u8 dexMode, u8 sortMode) +static void SortPokedex(u8 dexMode, u8 sortMode) { u16 vars[3]; //I have no idea why three regular variables are stored in an array, but whatever. s16 i; - - gPokedexView->unk60C = 0; - - switch(dexMode) + + gPokedexView->pokemonListCount = 0; + + switch (dexMode) { - default: - case DEX_MODE_HOENN: + default: + case DEX_MODE_HOENN: + vars[0] = 202; + vars[1] = 1; + break; + case DEX_MODE_NATIONAL: + if (IsNationalPokedexEnabled()) + { + vars[0] = NATIONAL_DEX_COUNT; + vars[1] = 0; + } + else + { vars[0] = 202; vars[1] = 1; - break; - case DEX_MODE_NATIONAL: - if(IsNationalPokedex()) - { - vars[0] = 386; - vars[1] = 0; - } - else - { - vars[0] = 202; - vars[1] = 1; - } - break; + } + break; } - - switch(sortMode) + + switch (sortMode) { - case 0: + case 0: + if (vars[1]) { - if(vars[1]) + for (i = 0; i < vars[0]; i++) { - for(i = 0; i < vars[0]; i++) - { - vars[2] = HoennToNationalOrder(i + 1); - gPokedexView->unk0[i].dexNum = vars[2]; - gPokedexView->unk0[i].seen = sub_8090D90(vars[2], 0); - gPokedexView->unk0[i].owned = sub_8090D90(vars[2], 1); - if(gPokedexView->unk0[i].seen) - gPokedexView->unk60C = i + 1; - } + vars[2] = HoennToNationalOrder(i + 1); + gPokedexView->unk0[i].dexNum = vars[2]; + gPokedexView->unk0[i].seen = GetNationalPokedexFlag(vars[2], 0); + gPokedexView->unk0[i].owned = GetNationalPokedexFlag(vars[2], 1); + if (gPokedexView->unk0[i].seen) + gPokedexView->pokemonListCount = i + 1; } - else - { - bool32 r10; - s16 r5; + } + else + { + bool32 r10; + s16 r5; - r10 = r5 = i = 0; - for(i = 0; i < vars[0]; i++) + r10 = r5 = i = 0; + for (i = 0; i < vars[0]; i++) + { + vars[2] = i + 1; + if (GetNationalPokedexFlag(vars[2], 0)) + r10 = 1; + if (r10) { - vars[2] = i + 1; - if(sub_8090D90(vars[2], 0)) - r10 = 1; - if(r10) - { - asm(""); //Needed to match for some reason - gPokedexView->unk0[r5].dexNum = vars[2]; - gPokedexView->unk0[r5].seen = sub_8090D90(vars[2], 0); - gPokedexView->unk0[r5].owned = sub_8090D90(vars[2], 1); - if(gPokedexView->unk0[r5].seen) - gPokedexView->unk60C = r5 + 1; - r5++; - } + asm(""); //Needed to match for some reason + gPokedexView->unk0[r5].dexNum = vars[2]; + gPokedexView->unk0[r5].seen = GetNationalPokedexFlag(vars[2], 0); + gPokedexView->unk0[r5].owned = GetNationalPokedexFlag(vars[2], 1); + if (gPokedexView->unk0[r5].seen) + gPokedexView->pokemonListCount = r5 + 1; + r5++; } } - break; } - case 1: - for(i = 0; i < 411; i++) + break; + case 1: + for (i = 0; i < 411; i++) + { + vars[2] = gPokedexOrder_Alphabetical[i]; + + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetNationalPokedexFlag(vars[2], 0)) { - vars[2] = gPokedexOrder_Alphabetical[i]; - - if(NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 0)) - { - gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; - gPokedexView->unk0[gPokedexView->unk60C].seen = 1; - gPokedexView->unk0[gPokedexView->unk60C].owned = sub_8090D90(vars[2], 1); - gPokedexView->unk60C++; - } + gPokedexView->unk0[gPokedexView->pokemonListCount].dexNum = vars[2]; + gPokedexView->unk0[gPokedexView->pokemonListCount].seen = 1; + gPokedexView->unk0[gPokedexView->pokemonListCount].owned = GetNationalPokedexFlag(vars[2], 1); + gPokedexView->pokemonListCount++; } - break; - case 2: - for(i = 385; i >= 0; i--) + } + break; + case 2: + for (i = NATIONAL_DEX_COUNT - 1; i >= 0; i--) + { + vars[2] = gPokedexOrder_Weight[i]; + + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetNationalPokedexFlag(vars[2], 1)) { - vars[2] = gPokedexOrder_Weight[i]; - - if(NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) - { - gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; - gPokedexView->unk0[gPokedexView->unk60C].seen = 1; - gPokedexView->unk0[gPokedexView->unk60C].owned = 1; - gPokedexView->unk60C++; - } + gPokedexView->unk0[gPokedexView->pokemonListCount].dexNum = vars[2]; + gPokedexView->unk0[gPokedexView->pokemonListCount].seen = 1; + gPokedexView->unk0[gPokedexView->pokemonListCount].owned = 1; + gPokedexView->pokemonListCount++; } - break; - case 3: - for(i = 0; i < 386; i++) + } + break; + case 3: + for (i = 0; i < NATIONAL_DEX_COUNT; i++) + { + vars[2] = gPokedexOrder_Weight[i]; + + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetNationalPokedexFlag(vars[2], 1)) { - vars[2] = gPokedexOrder_Weight[i]; - - if(NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) - { - gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; - gPokedexView->unk0[gPokedexView->unk60C].seen = 1; - gPokedexView->unk0[gPokedexView->unk60C].owned = 1; - gPokedexView->unk60C++; - } + gPokedexView->unk0[gPokedexView->pokemonListCount].dexNum = vars[2]; + gPokedexView->unk0[gPokedexView->pokemonListCount].seen = 1; + gPokedexView->unk0[gPokedexView->pokemonListCount].owned = 1; + gPokedexView->pokemonListCount++; } - break; - case 4: - for(i = 385; i >=0; i--) + } + break; + case 4: + for (i = NATIONAL_DEX_COUNT - 1; i >=0; i--) + { + vars[2] = gPokedexOrder_Height[i]; + + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetNationalPokedexFlag(vars[2], 1)) { - vars[2] = gPokedexOrder_Height[i]; - - if(NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) - { - gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; - gPokedexView->unk0[gPokedexView->unk60C].seen = 1; - gPokedexView->unk0[gPokedexView->unk60C].owned = 1; - gPokedexView->unk60C++; - } + gPokedexView->unk0[gPokedexView->pokemonListCount].dexNum = vars[2]; + gPokedexView->unk0[gPokedexView->pokemonListCount].seen = 1; + gPokedexView->unk0[gPokedexView->pokemonListCount].owned = 1; + gPokedexView->pokemonListCount++; } - break; - case 5: - for(i = 0; i < 386; i++) + } + break; + case 5: + for (i = 0; i < NATIONAL_DEX_COUNT; i++) + { + vars[2] = gPokedexOrder_Height[i]; + + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetNationalPokedexFlag(vars[2], 1)) { - vars[2] = gPokedexOrder_Height[i]; - - if(NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) - { - gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; - gPokedexView->unk0[gPokedexView->unk60C].seen = 1; - gPokedexView->unk0[gPokedexView->unk60C].owned = 1; - gPokedexView->unk60C++; - } + gPokedexView->unk0[gPokedexView->pokemonListCount].dexNum = vars[2]; + gPokedexView->unk0[gPokedexView->pokemonListCount].seen = 1; + gPokedexView->unk0[gPokedexView->pokemonListCount].owned = 1; + gPokedexView->pokemonListCount++; } - break; + } + break; } - for(i = gPokedexView->unk60C; i < 386; i++) + + for (i = gPokedexView->pokemonListCount; i < NATIONAL_DEX_COUNT; i++) { gPokedexView->unk0[i].dexNum |= 0xFFFF; gPokedexView->unk0[i].seen = 0; @@ -980,118 +2138,116 @@ void SortPokedex(u8 dexMode, u8 sortMode) } } -void sub_808DBE8(u8 a, u16 b, u16 c) +static void sub_808DBE8(u8 a, u16 b, u16 c) { - switch(a) + s16 _b; + u16 i; + u16 r2; + + switch (a) { - case 0: - default: + case 0: + default: + _b = b - 5; + for (i = 0; i <= 10; i++) { - u16 i; - s16 _b = b - 5; - - for(i = 0; i <= 10; i++) + if (_b < 0 || _b >= NATIONAL_DEX_COUNT || gPokedexView->unk0[_b].dexNum == 0xFFFF) { - if((u16)_b > 385 || gPokedexView->unk0[_b].dexNum == 0xFFFF) - sub_808E090(0x11, i * 2, c); - else - { - sub_808E090(0x11, i * 2, c); - if(gPokedexView->unk0[_b].seen) - { - sub_808DEB0(_b, 0x12, i * 2, c); - sub_808DF88(gPokedexView->unk0[_b].owned, 0x11, i * 2, c); - sub_808DFE4(gPokedexView->unk0[_b].dexNum, 0x17, i * 2); - } - else - { - sub_808DEB0(_b, 0x12, i * 2, c); - sub_808DF88(0, 0x11, i * 2, c); - sub_808DFE4(0, 0x17, i * 2); - } - } - _b++; + sub_808E090(0x11, i * 2, c); } - break; - } - case 1: - { - s16 _b = b - 5; - - if((u16)_b > 385 || gPokedexView->unk0[_b].dexNum == 0xFFFF) - sub_808E090(0x11, gPokedexView->unk630 * 2, c); else { - sub_808E090(0x11, gPokedexView->unk630 * 2, c); - if(gPokedexView->unk0[_b].seen) + sub_808E090(0x11, i * 2, c); + if (gPokedexView->unk0[_b].seen) { - sub_808DEB0(_b, 0x12, gPokedexView->unk630 * 2, c); - sub_808DF88(gPokedexView->unk0[_b].owned, 0x11, gPokedexView->unk630 * 2, c); - sub_808DFE4(gPokedexView->unk0[_b].dexNum, 0x17, gPokedexView->unk630 * 2); + sub_808DEB0(_b, 0x12, i * 2, c); + sub_808DF88(gPokedexView->unk0[_b].owned, 0x11, i * 2, c); + sub_808DFE4(gPokedexView->unk0[_b].dexNum, 0x17, i * 2); } else { - sub_808DEB0(_b, 0x12, gPokedexView->unk630 * 2, c); - sub_808DF88(0, 0x11, gPokedexView->unk630 * 2, c); - sub_808DFE4(0, 0x17, gPokedexView->unk630 * 2); + sub_808DEB0(_b, 0x12, i * 2, c); + sub_808DF88(0, 0x11, i * 2, c); + sub_808DFE4(0, 0x17, i * 2); } } - break; + _b++; } - case 2: + break; + case 1: + _b = b - 5; + if (_b < 0 || _b >= NATIONAL_DEX_COUNT || gPokedexView->unk0[_b].dexNum == 0xFFFF) { - s16 _b = b + 5; - u16 r2 = gPokedexView->unk630 + 10; - - if(r2 > 15) - r2 -= 16; - if((u16)_b > 385 || gPokedexView->unk0[_b].dexNum == 0xFFFF) - sub_808E090(0x11, r2 * 2, c); + sub_808E090(0x11, gPokedexView->unk630 * 2, c); + } + else + { + sub_808E090(0x11, gPokedexView->unk630 * 2, c); + if (gPokedexView->unk0[_b].seen) + { + sub_808DEB0(_b, 0x12, gPokedexView->unk630 * 2, c); + sub_808DF88(gPokedexView->unk0[_b].owned, 0x11, gPokedexView->unk630 * 2, c); + sub_808DFE4(gPokedexView->unk0[_b].dexNum, 0x17, gPokedexView->unk630 * 2); + } else { - sub_808E090(0x11, r2 * 2, c); - if(gPokedexView->unk0[_b].seen) - { - sub_808DEB0(_b, 0x12, r2 * 2, c); - sub_808DF88(gPokedexView->unk0[_b].owned, 0x11, r2 * 2, c); - sub_808DFE4(gPokedexView->unk0[_b].dexNum, 0x17, r2 * 2); - } - else - { - sub_808DEB0(_b, 0x12, r2 * 2, c); - sub_808DF88(0, 0x11, r2 * 2, c); - sub_808DFE4(0, 0x17, r2 * 2); - } + sub_808DEB0(_b, 0x12, gPokedexView->unk630 * 2, c); + sub_808DF88(0, 0x11, gPokedexView->unk630 * 2, c); + sub_808DFE4(0, 0x17, gPokedexView->unk630 * 2); } - break; } + break; + case 2: + _b = b + 5; + r2 = gPokedexView->unk630 + 10; + if (r2 > 15) + r2 -= 16; + if (_b < 0 || _b >= NATIONAL_DEX_COUNT || gPokedexView->unk0[_b].dexNum == 0xFFFF) + sub_808E090(0x11, r2 * 2, c); + else + { + sub_808E090(0x11, r2 * 2, c); + if (gPokedexView->unk0[_b].seen) + { + sub_808DEB0(_b, 0x12, r2 * 2, c); + sub_808DF88(gPokedexView->unk0[_b].owned, 0x11, r2 * 2, c); + sub_808DFE4(gPokedexView->unk0[_b].dexNum, 0x17, r2 * 2); + } + else + { + sub_808DEB0(_b, 0x12, r2 * 2, c); + sub_808DF88(0, 0x11, r2 * 2, c); + sub_808DFE4(0, 0x17, r2 * 2); + } + } + break; } } -void sub_808DEB0(u16 a, u8 b, u8 c, u16 d) +static void sub_808DEB0(u16 a, u8 b, u8 c, u16 d) { u8 text[4]; u16 unk[2]; u16 r7 = gPokedexView->unk0[a].dexNum; - - if(gPokedexView->dexMode == DEX_MODE_HOENN) + + if (gPokedexView->dexMode == DEX_MODE_HOENN) r7 = NationalToHoennOrder(r7); unk[0] = 0x3FC; unk[1] = 0x3FD; - text[0] = r7 / 100 + 0xA1; - text[1] = (r7 % 100) / 10 + 0xA1; - text[2] = (r7 % 100) % 10 + 0xA1; - text[3] = 0xFF; + text[0] = CHAR_0 + r7 / 100; + text[1] = CHAR_0 + (r7 % 100) / 10; + text[2] = CHAR_0 + (r7 % 100) % 10; + text[3] = EOS; *(u16 *)(VRAM + d * 0x800 + c * 0x40 + b * 2) = unk[0]; - *(u16 *)(VRAM + 0x40 + d * 0x800 + c * 0x40 + b * 2) = unk[1]; + *(u16 *)(VRAM + d * 0x800 + (c + 1) * 0x40 + b * 2) = unk[1]; MenuPrint(text, b - 15, c); } -void sub_808DF88(u16 a, u8 b, u8 c, u16 d) +static void sub_808DF88(u16 a, u8 b, u8 c, u16 d) { u16 unk[2]; - - if(a) + + if (a) { unk[0] = 0x3FE; unk[1] = 0x3FF; @@ -1102,652 +2258,276 @@ void sub_808DF88(u16 a, u8 b, u8 c, u16 d) unk[1] = 0; } *(u16 *)(VRAM + d * 0x800 + c * 0x40 + b * 2) = unk[0]; - *(u16 *)(VRAM + 0x40 + d * 0x800 + c * 0x40 + b * 2) = unk[1]; + *(u16 *)(VRAM + d * 0x800 + (c + 1) * 0x40 + b * 2) = unk[1]; } -#ifdef NONMATCHING -//FixMe -u8 sub_808DFE4(u16 a, u8 b, u8 c) +static u8 sub_808DFE4(u16 num, u8 b, u8 c) { u8 text[10]; u8 i; - u32 species; - - for(i = 0; i < 10; i++) - text[i] = 0; + + for (i = 0; i < 10; i++) + text[i] = CHAR_SPACE; text[i] = EOS; - species = NationalPokedexNumToSpecies(a); - if(species) - { - for(i = 0; gSpeciesNames[species][i] != EOS && i < 10; i++) - text[i] = gSpeciesNames[species][i]; - } - else + + num = NationalPokedexNumToSpecies(num); + switch (num) { - for(i = 0; i < 10; i++) - text[i] = 0xAE; + default: + for (i = 0; gSpeciesNames[num][i] != EOS && i < 10; i++) + text[i] = gSpeciesNames[num][i]; + break; + case 0: + for (i = 0; i < 10; i++) + text[i] = CHAR_HYPHEN; + break; } MenuPrint_PixelCoords(text, (b - 0x11) * 8 + 0xFC, c * 8, 0); + return i; } -#else -__attribute__((naked)) -u8 sub_808DFE4(u16 a, u8 b, u8 c) -{ - asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - sub sp, 0xC\n\ - lsls r0, 16\n\ - lsrs r3, r0, 16\n\ - lsls r1, 24\n\ - lsrs r5, r1, 24\n\ - lsls r2, 24\n\ - lsrs r6, r2, 24\n\ - movs r4, 0\n\ - movs r1, 0\n\ -_0808DFF8:\n\ - mov r2, sp\n\ - adds r0, r2, r4\n\ - strb r1, [r0]\n\ - adds r0, r4, 0x1\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - cmp r4, 0x9\n\ - bls _0808DFF8\n\ - adds r0, r2, r4\n\ - movs r1, 0xFF\n\ - strb r1, [r0]\n\ - adds r0, r3, 0\n\ - bl NationalPokedexNumToSpecies\n\ - adds r3, r0, 0\n\ - cmp r3, 0\n\ - beq _0808E058\n\ - movs r4, 0\n\ - ldr r2, _0808E054\n\ - movs r0, 0xB\n\ - adds r1, r3, 0\n\ - muls r1, r0\n\ - adds r0, r1, r2\n\ - ldrb r0, [r0]\n\ - subs r5, 0x11\n\ - lsls r6, 19\n\ - cmp r0, 0xFF\n\ - beq _0808E070\n\ - adds r3, r1, 0\n\ -_0808E032:\n\ - mov r0, sp\n\ - adds r1, r0, r4\n\ - adds r0, r4, r3\n\ - adds r0, r2\n\ - ldrb r0, [r0]\n\ - strb r0, [r1]\n\ - adds r0, r4, 0x1\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - adds r0, r4, r3\n\ - adds r0, r2\n\ - ldrb r0, [r0]\n\ - cmp r0, 0xFF\n\ - beq _0808E070\n\ - cmp r4, 0x9\n\ - bls _0808E032\n\ - b _0808E070\n\ - .align 2, 0\n\ -_0808E054: .4byte gSpeciesNames\n\ -_0808E058:\n\ - movs r4, 0\n\ - subs r5, 0x11\n\ - lsls r6, 19\n\ - movs r1, 0xAE\n\ -_0808E060:\n\ - mov r2, sp\n\ - adds r0, r2, r4\n\ - strb r1, [r0]\n\ - adds r0, r4, 0x1\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - cmp r4, 0x9\n\ - bls _0808E060\n\ -_0808E070:\n\ - lsls r1, r5, 27\n\ - movs r0, 0xFC\n\ - lsls r0, 24\n\ - adds r1, r0\n\ - lsrs r1, 24\n\ - lsrs r2, r6, 16\n\ - mov r0, sp\n\ - movs r3, 0\n\ - bl MenuPrint_PixelCoords\n\ - adds r0, r4, 0\n\ - add sp, 0xC\n\ - pop {r4-r6}\n\ - pop {r1}\n\ - bx r1\n\ - .syntax divided\n"); -} -#endif -void sub_808E090(u8 a, u8 b, u16 c) +static void sub_808E090(u8 a, u8 b, u16 c) { u8 i; - - for(i = 0; i < 12; i++) + + for (i = 0; i < 12; i++) { *(u16 *)(VRAM + c * 0x800 + b * 64 + (a + i) * 2) = 0; - *(u16 *)(VRAM + 0x40 + c * 0x800 + b * 64 + (a + i) * 2) = 0; + *(u16 *)(VRAM + c * 0x800 + (b + 1) * 64 + (a + i) * 2) = 0; } } -void sub_808E0CC(u16 a, u16 b) +static void sub_808E0CC(u16 a, u16 b) { u8 i; u16 unk; u8 spriteId; - - for(i = 0; i < 4; i++) - gPokedexView->unk61E[i] |= 0xFFFF; - gPokedexView->unk626 = 0xFFFF; + + for (i = 0; i < 4; i++) + gPokedexView->unk61E[i] = 0xFFFF; + gPokedexView->selectedMonSpriteId = 0xFFFF; sub_808DBE8(0, a, b); REG_BG2VOFS = gPokedexView->unk62D; + unk = sub_808E888(a - 1); - if(unk != 0xFFFF) + if (unk != 0xFFFF) { spriteId = sub_808E8C8(unk, 0x60, 0x50); gSprites[spriteId].callback = sub_808EE28; gSprites[spriteId].data5 = -32; } + unk = sub_808E888(a); - if(unk != 0xFFFF) + if (unk != 0xFFFF) { spriteId = sub_808E8C8(unk, 0x60, 0x50); gSprites[spriteId].callback = sub_808EE28; gSprites[spriteId].data5 = 0; } + unk = sub_808E888(a + 1); - if(unk != 0xFFFF) + if (unk != 0xFFFF) { spriteId = sub_808E8C8(unk, 0x60, 0x50); gSprites[spriteId].callback = sub_808EE28; gSprites[spriteId].data5 = 32; } + gPokedexView->unk630 = 0; gPokedexView->unk632 = 0; } -bool8 sub_808E208(u8 a, u8 b, u8 c) +static bool8 sub_808E208(u8 a, u8 b, u8 c) { u16 i; u8 foo; - - if(gPokedexView->unk62E) + + if (gPokedexView->unk62E) { gPokedexView->unk62E--; - switch(a) + switch (a) { - case 1: - for(i = 0; i < 4; i++) - { - if(gPokedexView->unk61E[i] != 0xFFFF) - gSprites[gPokedexView->unk61E[i]].data5 += b; - } - foo = 16 * (c - gPokedexView->unk62E) / c; - REG_BG2VOFS = gPokedexView->unk62D + gPokedexView->unk632 * 16 - foo; - gPokedexView->unk62C -= gPokedexView->unk628; - break; - case 2: - for(i = 0; i < 4; i++) - { - if(gPokedexView->unk61E[i] != 0xFFFF) - gSprites[gPokedexView->unk61E[i]].data5 -= b; - } - foo = 16 * (c - gPokedexView->unk62E) / c; - REG_BG2VOFS = gPokedexView->unk62D + gPokedexView->unk632 * 16 + foo; - gPokedexView->unk62C += gPokedexView->unk628; - break; + case 1: + for (i = 0; i < 4; i++) + { + if (gPokedexView->unk61E[i] != 0xFFFF) + gSprites[gPokedexView->unk61E[i]].data5 += b; + } + foo = 16 * (c - gPokedexView->unk62E) / c; + REG_BG2VOFS = gPokedexView->unk62D + gPokedexView->unk632 * 16 - foo; + gPokedexView->unk62C -= gPokedexView->unk628; + break; + case 2: + for (i = 0; i < 4; i++) + { + if (gPokedexView->unk61E[i] != 0xFFFF) + gSprites[gPokedexView->unk61E[i]].data5 -= b; + } + foo = 16 * (c - gPokedexView->unk62E) / c; + REG_BG2VOFS = gPokedexView->unk62D + gPokedexView->unk632 * 16 + foo; + gPokedexView->unk62C += gPokedexView->unk628; + break; } - return 0; + return FALSE; } - //_0808E36C else { REG_BG2VOFS = gPokedexView->unk62D + gPokedexView->unk630 * 16; - return 1; + return TRUE; } } -void sub_808E398(u8 a, u16 b) +static void sub_808E398(u8 a, u16 b) { u16 unk; u8 spriteId; - + gPokedexView->unk632 = gPokedexView->unk630; - switch(a) + switch (a) { - case 1: + case 1: + unk = sub_808E888(b - 1); + if (unk != 0xFFFF) { - unk = sub_808E888(b - 1); - if(unk != 0xFFFF) - { - spriteId = sub_808E8C8(unk, 0x60, 0x50); - gSprites[spriteId].callback = sub_808EE28; - gSprites[spriteId].data5 = 0xFFC0; - } - if(gPokedexView->unk630 > 0) - gPokedexView->unk630--; - else - gPokedexView->unk630 = 0xF; - break; + spriteId = sub_808E8C8(unk, 0x60, 0x50); + gSprites[spriteId].callback = sub_808EE28; + gSprites[spriteId].data5 = -64; } - case 2: + if (gPokedexView->unk630 > 0) + gPokedexView->unk630--; + else + gPokedexView->unk630 = 15; + break; + case 2: + unk = sub_808E888(b + 1); + if (unk != 0xFFFF) { - unk = sub_808E888(b + 1); - if(unk != 0xFFFF) - { - spriteId = sub_808E8C8(unk, 0x60, 0x50); - gSprites[spriteId].callback = sub_808EE28; - gSprites[spriteId].data5 = 0x40; - } - if(gPokedexView->unk630 <= 0xE) - gPokedexView->unk630++; - else - gPokedexView->unk630 = 0; - break; + spriteId = sub_808E8C8(unk, 0x60, 0x50); + gSprites[spriteId].callback = sub_808EE28; + gSprites[spriteId].data5 = 0x40; } + if (gPokedexView->unk630 <= 0xE) + gPokedexView->unk630++; + else + gPokedexView->unk630 = 0; + break; } } -#ifdef NONMATCHING -//This one's ridiculous. Fix later -u16 sub_808E48C(u16 a, u16 b) + +// Ugly, ugly, ugly. I couldn't get it to match otherwise. +static u16 sub_808E48C(u16 a, u16 b) { u8 r3; u8 r5; - u32 r10 = 0; - if(!(gMain.heldKeys & 0x40) || a == 0) + u8 i; + u16 r6; + u8 r10 = 0; + + if (!((gMain.heldKeys & 0x40) && (a > 0))) { - u8 i; - u16 r6; - //_0808E4B6 - if(gMain.heldKeys & 0x80) - { - if(a < gPokedexView->unk60C - 1) - goto _0808E5C4; - } + if (!((gMain.heldKeys & 0x80) && (a < gPokedexView->pokemonListCount - 1))) //_0808E4CE - - if((gMain.newKeys & 0x20) && a != 0) { - r6 = a; - //_0808E4E0 - for(i = 0; i < 7; i++) + if ((gMain.newKeys & 0x20) && (a > 0)) { - a = sub_8091818(1, a, 0, gPokedexView->unk60C - 1); + r6 = a; + //_0808E4E0 + for (i = 0; i < 7; i++) + a = sub_8091818(1, a, 0, gPokedexView->pokemonListCount - 1); + gPokedexView->unk62C += 16 * (a - r6); + sub_808E82C(); + sub_808E0CC(a, 0xE); + PlaySE(0x6D); + } + //_0808E53C + else if ((gMain.newKeys & 0x10) && (a < gPokedexView->pokemonListCount - 1)) + { + r6 = a; + for (i = 0; i < 7; i++) + a = sub_8091818(0, a, 0, gPokedexView->pokemonListCount - 1); + gPokedexView->unk62C += (a - r6) * 16; + sub_808E82C(); + sub_808E0CC(a, 0xE); + PlaySE(0x6D); + } + _0808E5A2: + if (r10 == 0) + { + gPokedexView->unk638 = 0; + return a; } - - gPokedexView->unk62C += (a - r6) * 16; - sub_808E82C(); - sub_808E0CC(a, 0xE); - PlaySE(SE_Z_PAGE); - goto _0808E5A2; } - //_0808E53C - if(!(gMain.newKeys & 0x10) || a >= gPokedexView->unk60C - 1) - goto _0808E5A2; - - r6 = a; - for(i = 0; i < 7; i++) + else { - a = sub_8091818(0, a, 0, gPokedexView->unk60C - 1); + // to _0808E5C4 + r10 = 2; + a = sub_8091818(0, a, 0, gPokedexView->pokemonListCount - 1); + sub_808E398(2, a); + //goto _0808E60E + sub_808DBE8(2, a, b); + PlaySE(0x6C); + goto _0808E5A2; } - - gPokedexView->unk62C += (a - r6) * 16; - sub_808E82C(); - sub_808E0CC(a, 0xE); - PlaySE(SE_Z_PAGE); - goto _0808E5A2; - - _0808E5A2: - if(r10 != 0) - goto _0808E628; - gPokedexView->unk638 = r10; - return a; - - _0808E5C4: - r10 = 2; - a = sub_8091818(0, a, 0, gPokedexView->unk60C - 1); - sub_808E398(2, a); - //goto _0808E60E - sub_808DBE8(2, a, b); - PlaySE(SE_Z_SCROLL); } - //_0808E5E4 else { + //to _0808E5E4 r10 = 1; - a = sub_8091818(1, a, 0, gPokedexView->unk60C - 1); + a = sub_8091818(1, a, 0, gPokedexView->pokemonListCount - 1); sub_808E398(1, a); //_0808E60E sub_808DBE8(1, a, b); - PlaySE(SE_Z_SCROLL); + PlaySE(0x6C); + goto _0808E5A2; } - //_0808E60E - goto _0808E5A2; - - _0808E628: + //_0808E628 r5 = gUnknown_083A05EC[gPokedexView->unk638 / 4]; r3 = gUnknown_083A05F1[gPokedexView->unk638 / 4]; gPokedexView->unk62E = r3; gPokedexView->unk636 = r3; gPokedexView->unk634 = r5; gPokedexView->unk62F = r10; - gPokedexView->unk628 = r5; + gPokedexView->unk628 = r5 / 2; sub_808E208(gPokedexView->unk62F, gPokedexView->unk634, gPokedexView->unk636); - if(gPokedexView->unk638 <= 0xB) + if (gPokedexView->unk638 <= 0xB) gPokedexView->unk638++; return a; } -#else -__attribute__((naked)) -u16 sub_808E48C(u16 a, u16 b) -{ - 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\ - lsls r0, 16\n\ - lsrs r7, r0, 16\n\ - lsls r1, 16\n\ - lsrs r4, r1, 16\n\ - movs r0, 0\n\ - mov r10, r0\n\ - ldr r1, _0808E52C\n\ - ldrh r2, [r1, 0x2C]\n\ - movs r0, 0x40\n\ - ands r0, r2\n\ - adds r3, r1, 0\n\ - cmp r0, 0\n\ - beq _0808E4B6\n\ - cmp r7, 0\n\ - beq _0808E4B6\n\ - b _0808E5E4\n\ -_0808E4B6:\n\ - movs r0, 0x80\n\ - ands r0, r2\n\ - cmp r0, 0\n\ - beq _0808E4CE\n\ - ldr r0, _0808E530\n\ - ldr r0, [r0]\n\ - ldr r1, _0808E534\n\ - adds r0, r1\n\ - ldrh r0, [r0]\n\ - subs r0, 0x1\n\ - cmp r7, r0\n\ - blt _0808E5C4\n\ -_0808E4CE:\n\ - ldrh r1, [r3, 0x2E]\n\ - movs r0, 0x20\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _0808E53C\n\ - cmp r7, 0\n\ - beq _0808E53C\n\ - adds r6, r7, 0\n\ - movs r4, 0\n\ -_0808E4E0:\n\ - ldr r5, _0808E530\n\ - ldr r0, [r5]\n\ - ldr r2, _0808E534\n\ - adds r0, r2\n\ - ldrh r3, [r0]\n\ - subs r3, 0x1\n\ - lsls r3, 16\n\ - lsrs r3, 16\n\ - movs r0, 0x1\n\ - adds r1, r7, 0\n\ - movs r2, 0\n\ - bl sub_8091818\n\ - adds r7, r0, 0\n\ - adds r0, r4, 0x1\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - cmp r4, 0x6\n\ - bls _0808E4E0\n\ - ldr r1, [r5]\n\ - ldr r3, _0808E538\n\ - adds r1, r3\n\ - subs r0, r7, r6\n\ - lsls r0, 4\n\ - ldrb r2, [r1]\n\ - adds r0, r2\n\ - strb r0, [r1]\n\ - bl sub_808E82C\n\ - adds r0, r7, 0\n\ - movs r1, 0xE\n\ - bl sub_808E0CC\n\ - movs r0, 0x6D\n\ - bl PlaySE\n\ - b _0808E5A2\n\ - .align 2, 0\n\ -_0808E52C: .4byte gMain\n\ -_0808E530: .4byte gPokedexView\n\ -_0808E534: .4byte 0x0000060c\n\ -_0808E538: .4byte 0x0000062c\n\ -_0808E53C:\n\ - ldrh r1, [r3, 0x2E]\n\ - movs r0, 0x10\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _0808E5A2\n\ - ldr r0, _0808E5B8\n\ - ldr r0, [r0]\n\ - ldr r3, _0808E5BC\n\ - adds r0, r3\n\ - ldrh r0, [r0]\n\ - subs r0, 0x1\n\ - cmp r7, r0\n\ - bge _0808E5A2\n\ - adds r6, r7, 0\n\ - movs r4, 0\n\ -_0808E55A:\n\ - ldr r5, _0808E5B8\n\ - ldr r0, [r5]\n\ - ldr r1, _0808E5BC\n\ - adds r0, r1\n\ - ldrh r3, [r0]\n\ - subs r3, 0x1\n\ - lsls r3, 16\n\ - lsrs r3, 16\n\ - movs r0, 0\n\ - adds r1, r7, 0\n\ - movs r2, 0\n\ - bl sub_8091818\n\ - adds r7, r0, 0\n\ - adds r0, r4, 0x1\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - cmp r4, 0x6\n\ - bls _0808E55A\n\ - ldr r1, [r5]\n\ - ldr r2, _0808E5C0\n\ - adds r1, r2\n\ - subs r0, r7, r6\n\ - lsls r0, 4\n\ - ldrb r3, [r1]\n\ - adds r0, r3\n\ - strb r0, [r1]\n\ - bl sub_808E82C\n\ - adds r0, r7, 0\n\ - movs r1, 0xE\n\ - bl sub_808E0CC\n\ - movs r0, 0x6D\n\ - bl PlaySE\n\ -_0808E5A2:\n\ - mov r0, r10\n\ - cmp r0, 0\n\ - bne _0808E628\n\ - ldr r0, _0808E5B8\n\ - ldr r0, [r0]\n\ - movs r1, 0xC7\n\ - lsls r1, 3\n\ - adds r0, r1\n\ - mov r2, r10\n\ - strh r2, [r0]\n\ - b _0808E68E\n\ - .align 2, 0\n\ -_0808E5B8: .4byte gPokedexView\n\ -_0808E5BC: .4byte 0x0000060c\n\ -_0808E5C0: .4byte 0x0000062c\n\ -_0808E5C4:\n\ - movs r3, 0x2\n\ - mov r10, r3\n\ - lsls r3, r0, 16\n\ - lsrs r3, 16\n\ - movs r0, 0\n\ - adds r1, r7, 0\n\ - movs r2, 0\n\ - bl sub_8091818\n\ - adds r7, r0, 0\n\ - movs r0, 0x2\n\ - adds r1, r7, 0\n\ - bl sub_808E398\n\ - movs r0, 0x2\n\ - b _0808E60E\n\ -_0808E5E4:\n\ - movs r0, 0x1\n\ - mov r10, r0\n\ - ldr r0, _0808E620\n\ - ldr r0, [r0]\n\ - ldr r1, _0808E624\n\ - adds r0, r1\n\ - ldrh r3, [r0]\n\ - subs r3, 0x1\n\ - lsls r3, 16\n\ - lsrs r3, 16\n\ - movs r0, 0x1\n\ - adds r1, r7, 0\n\ - movs r2, 0\n\ - bl sub_8091818\n\ - adds r7, r0, 0\n\ - movs r0, 0x1\n\ - adds r1, r7, 0\n\ - bl sub_808E398\n\ - movs r0, 0x1\n\ -_0808E60E:\n\ - adds r1, r7, 0\n\ - adds r2, r4, 0\n\ - bl sub_808DBE8\n\ - movs r0, 0x6C\n\ - bl PlaySE\n\ - b _0808E5A2\n\ - .align 2, 0\n\ -_0808E620: .4byte gPokedexView\n\ -_0808E624: .4byte 0x0000060c\n\ -_0808E628:\n\ - ldr r1, _0808E6A0\n\ - ldr r6, _0808E6A4\n\ - ldr r2, [r6]\n\ - movs r3, 0xC7\n\ - lsls r3, 3\n\ - mov r9, r3\n\ - adds r0, r2, r3\n\ - ldrh r0, [r0]\n\ - lsrs r0, 2\n\ - adds r1, r0, r1\n\ - ldrb r5, [r1]\n\ - ldr r1, _0808E6A8\n\ - adds r0, r1\n\ - ldrb r3, [r0]\n\ - ldr r0, _0808E6AC\n\ - adds r2, r0\n\ - strb r3, [r2]\n\ - ldr r1, [r6]\n\ - ldr r2, _0808E6B0\n\ - mov r8, r2\n\ - adds r0, r1, r2\n\ - strh r3, [r0]\n\ - ldr r4, _0808E6B4\n\ - adds r0, r1, r4\n\ - strh r5, [r0]\n\ - ldr r3, _0808E6B8\n\ - adds r1, r3\n\ - mov r0, r10\n\ - strb r0, [r1]\n\ - ldr r2, [r6]\n\ - lsrs r5, 1\n\ - movs r1, 0xC5\n\ - lsls r1, 3\n\ - adds r0, r2, r1\n\ - strh r5, [r0]\n\ - adds r3, r2, r3\n\ - ldrb r0, [r3]\n\ - adds r4, r2, r4\n\ - ldrb r1, [r4]\n\ - add r2, r8\n\ - ldrb r2, [r2]\n\ - bl sub_808E208\n\ - ldr r0, [r6]\n\ - mov r2, r9\n\ - adds r1, r0, r2\n\ - ldrh r0, [r1]\n\ - cmp r0, 0xB\n\ - bhi _0808E68E\n\ - adds r0, 0x1\n\ - strh r0, [r1]\n\ -_0808E68E:\n\ - adds r0, r7, 0\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n\ - .align 2, 0\n\ -_0808E6A0: .4byte gUnknown_083A05EC\n\ -_0808E6A4: .4byte gPokedexView\n\ -_0808E6A8: .4byte gUnknown_083A05F1\n\ -_0808E6AC: .4byte 0x0000062e\n\ -_0808E6B0: .4byte 0x00000636\n\ -_0808E6B4: .4byte 0x00000634\n\ -_0808E6B8: .4byte 0x0000062f\n\ - .syntax divided\n"); -} -#endif -void sub_808E6BC(void) +static void sub_808E6BC(void) { u16 i; - - for(i = 0; i < 4; i++) + + for (i = 0; i < 4; i++) { u16 spriteId = gPokedexView->unk61E[i]; - - if(gSprites[spriteId].pos2.x == 0 && gSprites[spriteId].pos2.y == 0 && spriteId != 0xFFFF) - gPokedexView->unk626 = spriteId; + + if (gSprites[spriteId].pos2.x == 0 && gSprites[spriteId].pos2.y == 0 && spriteId != 0xFFFF) + gPokedexView->selectedMonSpriteId = spriteId; } } -u8 sub_808E71C(void) +static u8 sub_808E71C(void) { u16 r2; u16 r4 = gPokedexView->selectedPokemon; - - if((gMain.newKeys & DPAD_UP) && r4) + + if ((gMain.newKeys & DPAD_UP) && r4) { r2 = r4; - while(r2 != 0) + while (r2 != 0) { - r2 = sub_8091818(1, r2, 0, gPokedexView->unk60C - 1); - - if(gPokedexView->unk0[r2].seen) + r2 = sub_8091818(1, r2, 0, gPokedexView->pokemonListCount - 1); + + if (gPokedexView->unk0[r2].seen) { r4 = r2; break; } } - - if(gPokedexView->selectedPokemon == r4) + + if (gPokedexView->selectedPokemon == r4) return 0; else { @@ -1756,21 +2536,21 @@ u8 sub_808E71C(void) return 1; } } - else if((gMain.newKeys & DPAD_DOWN) && r4 < gPokedexView->unk60C - 1) + else if ((gMain.newKeys & DPAD_DOWN) && r4 < gPokedexView->pokemonListCount - 1) { r2 = r4; - while(r2 < gPokedexView->unk60C - 1) + while (r2 < gPokedexView->pokemonListCount - 1) { - r2 = sub_8091818(0, r2, 0, gPokedexView->unk60C - 1); - - if(gPokedexView->unk0[r2].seen) + r2 = sub_8091818(0, r2, 0, gPokedexView->pokemonListCount - 1); + + if (gPokedexView->unk0[r2].seen) { r4 = r2; break; } } - - if(gPokedexView->selectedPokemon == r4) + + if (gPokedexView->selectedPokemon == r4) return 0; else { @@ -1782,13 +2562,13 @@ u8 sub_808E71C(void) return 0; } -u8 sub_808E82C(void) +static u8 sub_808E82C(void) { u16 i; - - for(i = 0; i < 4; i++) + + for (i = 0; i < 4; i++) { - if(gPokedexView->unk61E[i] != 0xFFFF) + if (gPokedexView->unk61E[i] != 0xFFFF) { DestroySprite(&gSprites[gPokedexView->unk61E[i]]); gPokedexView->unk61E[i] |= 0xFFFF; @@ -1797,26 +2577,26 @@ u8 sub_808E82C(void) return 0; } -u16 sub_808E888(u16 a1) +static u16 sub_808E888(u16 a1) { - if(a1 > 385 || gPokedexView->unk0[a1].dexNum == 0xFFFF) + if (a1 >= NATIONAL_DEX_COUNT || gPokedexView->unk0[a1].dexNum == 0xFFFF) return 0xFFFF; - else if(gPokedexView->unk0[a1].seen) + else if (gPokedexView->unk0[a1].seen) return gPokedexView->unk0[a1].dexNum; else return 0; } -u32 sub_808E8C8(u16 a, u16 b, u16 c) +static u32 sub_808E8C8(u16 a, s16 b, s16 c) { u8 i; - - for(i = 0; i < 4; i++) + + for (i = 0; i < 4; i++) { - if(gPokedexView->unk61E[i] == 0xFFFF) + if (gPokedexView->unk61E[i] == 0xFFFF) { - u8 spriteId = sub_80918EC(a, (s16)b, (s16)c, i); - + u8 spriteId = sub_80918EC(a, b, c, i); + gSprites[spriteId].oam.affineMode = 1; gSprites[spriteId].oam.priority = 3; gSprites[spriteId].data0 = 0; @@ -1829,366 +2609,277 @@ u32 sub_808E8C8(u16 a, u16 b, u16 c) return 0xFFFF; } -void sub_808E978(u8 a) +static void sub_808E978(u8 a) { u8 spriteId; u16 r5; - - spriteId = CreateSprite(&gSpriteTemplate_83A053C, 0xB8, 4, 0); + + spriteId = CreateSprite(&gSpriteTemplate_83A053C, 184, 4, 0); gSprites[spriteId].data1 = 0; - - spriteId = CreateSprite(&gSpriteTemplate_83A053C, 0xB8, 0x9C, 0); + + spriteId = CreateSprite(&gSpriteTemplate_83A053C, 184, 156, 0); gSprites[spriteId].data1 = 1; - gSprites[spriteId].vFlip = 1; - - CreateSprite(&gSpriteTemplate_83A0524, 0xEA, 0x14, 0); - CreateSprite(&gSpriteTemplate_83A0554, 0x10, 0x8A, 0); - - spriteId = CreateSprite(&gSpriteTemplate_83A0554, 0x30, 0x8A, 0); + gSprites[spriteId].vFlip = TRUE; + + CreateSprite(&gSpriteTemplate_83A0524, 234, 20, 0); + CreateSprite(&gSpriteTemplate_83A0554, 16, 138, 0); + + spriteId = CreateSprite(&gSpriteTemplate_83A0554, 48, 138, 0); StartSpriteAnim(&gSprites[spriteId], 3); - - spriteId = CreateSprite(&gSpriteTemplate_83A0554, 0x10, 0x9E, 0); + + spriteId = CreateSprite(&gSpriteTemplate_83A0554, 16, 158, 0); StartSpriteAnim(&gSprites[spriteId], 2); gSprites[spriteId].data2 = 0x80; - - spriteId = CreateSprite(&gSpriteTemplate_83A0554, 0x30, 0x9E, 0); + + spriteId = CreateSprite(&gSpriteTemplate_83A0554, 48, 158, 0); StartSpriteAnim(&gSprites[spriteId], 1); - - spriteId = CreateSprite(&gSpriteTemplate_83A056C, 0, 0x50, 2); + + spriteId = CreateSprite(&gSpriteTemplate_83A056C, 0, 80, 2); gSprites[spriteId].oam.affineMode = 1; gSprites[spriteId].oam.matrixNum = 30; gSprites[spriteId].data0 = 0x1E; gSprites[spriteId].data1 = 0; - - spriteId = CreateSprite(&gSpriteTemplate_83A056C, 0, 0x50, 2); + + spriteId = CreateSprite(&gSpriteTemplate_83A056C, 0, 80, 2); gSprites[spriteId].oam.affineMode = 1; gSprites[spriteId].oam.matrixNum = 31; gSprites[spriteId].data0 = 0x1F; gSprites[spriteId].data1 = 0x80; - - if(a == 0) + + if (a == 0) { u32 _a; - - CreateSprite(&gSpriteTemplate_83A0584, 0x20, 0x28, 1); - - spriteId = CreateSprite(&gSpriteTemplate_83A0584, 0x20, 0x48, 1); + + CreateSprite(&gSpriteTemplate_83A0584, 32, 40, 1); + + spriteId = CreateSprite(&gSpriteTemplate_83A0584, 32, 72, 1); StartSpriteAnim(&gSprites[spriteId], 1); _a = 0; - - spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x1C, 0x30, 1); + + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 28, 48, 1); r5 = gPokedexView->unk61A / 100; StartSpriteAnim(&gSprites[spriteId], r5); - if(r5 != 0) + if (r5 != 0) _a = 1; else - gSprites[spriteId].invisible = 1; - - spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x22, 0x30, 1); + gSprites[spriteId].invisible = TRUE; + + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 34, 48, 1); r5 = (gPokedexView->unk61A % 100) / 10; - if(r5 != 0 || _a != 0) + if (r5 != 0 || _a != 0) StartSpriteAnim(&gSprites[spriteId], r5); else - gSprites[spriteId].invisible = 1; - - spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x28, 0x30, 1); + gSprites[spriteId].invisible = TRUE; + + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 40, 48, 1); r5 = (gPokedexView->unk61A % 100) % 10; StartSpriteAnim(&gSprites[spriteId], r5); _a = 0; - - spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x1C, 0x50, 1); + + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 28, 80, 1); r5 = gPokedexView->unk61C / 100; StartSpriteAnim(&gSprites[spriteId], r5); - if(r5 != 0) + if (r5 != 0) _a = 1; else - gSprites[spriteId].invisible = 1; - - spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x22, 0x50, 1); + gSprites[spriteId].invisible = TRUE; + + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 34, 80, 1); r5 = (gPokedexView->unk61C % 100) / 10; - if(r5 != 0 || _a != 0) + if (r5 != 0 || _a != 0) StartSpriteAnim(&gSprites[spriteId], r5); else - gSprites[spriteId].invisible = 1; - - spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x28, 0x50, 1); + gSprites[spriteId].invisible = TRUE; + + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 40, 80, 1); r5 = (gPokedexView->unk61C % 100) % 10; StartSpriteAnim(&gSprites[spriteId], r5); - - spriteId = CreateSprite(&gSpriteTemplate_83A05B4, 0x8C, 0x60, 1); - gSprites[spriteId].invisible = 1; + + spriteId = CreateSprite(&gSpriteTemplate_83A05B4, 140, 96, 1); + gSprites[spriteId].invisible = TRUE; } else { - spriteId = CreateSprite(&gSpriteTemplate_83A05B4, 0x8C, 0x50, 1); - gSprites[spriteId].invisible = 1; + spriteId = CreateSprite(&gSpriteTemplate_83A05B4, 140, 80, 1); + gSprites[spriteId].invisible = TRUE; } } -void nullsub_58(struct Sprite *sprite) +static void nullsub_58(struct Sprite *sprite) { } -void sub_808ED94(struct Sprite *sprite) +static void sub_808ED94(struct Sprite *sprite) { - if(gPokedexView->unk64A != 0) + if (gPokedexView->unk64A != 0) DestroySprite(sprite); } //Move Pokemon into position for description page -void sub_808EDB8(struct Sprite *sprite) +static void sub_808EDB8(struct Sprite *sprite) { sprite->oam.priority = 0; sprite->oam.affineMode = 0; sprite->pos2.x = 0; sprite->pos2.y = 0; - if(sprite->pos1.x != 0x30 || sprite->pos1.y != 0x38) + if (sprite->pos1.x != 48 || sprite->pos1.y != 56) { - if(sprite->pos1.x > 0x30) + if (sprite->pos1.x > 48) sprite->pos1.x--; - if(sprite->pos1.x < 0x30) + if (sprite->pos1.x < 48) sprite->pos1.x++; - if(sprite->pos1.y > 0x38) + + if (sprite->pos1.y > 56) sprite->pos1.y--; - if(sprite->pos1.y <0x38) + if (sprite->pos1.y < 56) sprite->pos1.y++; } - //_0808EE1C else + { sprite->callback = nullsub_58; + } } -void sub_808EE28(struct Sprite *sprite) +static void sub_808EE28(struct Sprite *sprite) { u8 data1 = sprite->data1; - - if(gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) + + if (gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) { DestroySprite(sprite); gPokedexView->unk61E[data1] = 0xFFFF; } else { - //_0808EE58 - s32 var; - + u32 var; + sprite->pos2.y = gSineTable[(u8)sprite->data5] * 76 / 256; var = 0x10000 / gSineTable[sprite->data5 + 0x40]; - if((u32)var > 0xFFFF) + if (var > 0xFFFF) var = 0xFFFF; SetOamMatrix(sprite->data1 + 1, 0x100, 0, 0, var); sprite->oam.matrixNum = data1 + 1; - - //ToDo: clean up these inequalities - if((u16)(sprite->data5 + 0x3F) <= 0x7E) + + if (sprite->data5 > -64 && sprite->data5 < 64) { - sprite->invisible = 0; + sprite->invisible = FALSE; sprite->data0 = 1; } else { - sprite->invisible = 1; + sprite->invisible = TRUE; } - //_0808EEF8 - if((u16)(sprite->data5 + 0x3F) > 0x7E && sprite->data0 != 0) + + if ((sprite->data5 <= -64 || sprite->data5 >= 64) && sprite->data0 != 0) { DestroySprite(sprite); gPokedexView->unk61E[data1] = 0xFFFF; } } - //_0808EF16 } -void sub_808EF38(struct Sprite *sprite) +static void sub_808EF38(struct Sprite *sprite) { - if(gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) + if (gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) DestroySprite(sprite); else - sprite->pos2.y = gPokedexView->selectedPokemon * 120 / (gPokedexView->unk60C - 1); + sprite->pos2.y = gPokedexView->selectedPokemon * 120 / (gPokedexView->pokemonListCount - 1); } -void sub_808EF8C(struct Sprite *sprite) +static void sub_808EF8C(struct Sprite *sprite) { - if(gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) + if (gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) + { DestroySprite(sprite); + } else { u8 r0; - - if(sprite->data1 != 0) - { - if(gPokedexView->selectedPokemon == gPokedexView->unk60C - 1) - sprite->invisible = 1; + + if (sprite->data1 != 0) + { + if (gPokedexView->selectedPokemon == gPokedexView->pokemonListCount - 1) + sprite->invisible = TRUE; else - sprite->invisible = 0; + sprite->invisible = FALSE; r0 = sprite->data2; } else { - if(gPokedexView->selectedPokemon == 0) - sprite->invisible = 1; + if (gPokedexView->selectedPokemon == 0) + sprite->invisible = TRUE; else - sprite->invisible = 0; - r0 = sprite->data2 - 0x80; + sprite->invisible = FALSE; + r0 = sprite->data2 - 128; } sprite->pos2.y = gSineTable[r0] / 64; sprite->data2 = sprite->data2 + 8; - if(gPokedexView->menuIsOpen == 0 && gPokedexView->menuY == 0 && sprite->invisible == 0) - sprite->invisible = 0; + if (gPokedexView->menuIsOpen == 0 && gPokedexView->menuY == 0 && sprite->invisible == 0) + sprite->invisible = FALSE; else - sprite->invisible = 1; + sprite->invisible = TRUE; } } -void sub_808F08C(struct Sprite *sprite) +static void sub_808F08C(struct Sprite *sprite) { - if(gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) + if (gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) DestroySprite(sprite); } -#ifdef NONMATCHING -void sub_808F0B4(struct Sprite *sprite) +static void sub_808F0B4(struct Sprite *sprite) { - if(gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) + if (gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) + { DestroySprite(sprite); + } else { + u8 val; s16 r3; - - u8 unk = gPokedexView->unk62C + sprite->data1; - u16 foo = gSineTable[unk]; - //u8 unk2 = sprite->data0; - //u16 bar = gSineTable[unk + 0x40]; - - SetOamMatrix(sprite->data0, foo, gSineTable[unk + 0x40], (-(u16)foo) >> 16, gSineTable[unk + 0x40]); - - r3 = gSineTable[sprite->data1 + gPokedexView->unk62C]; - sprite->pos2.x = gSineTable[sprite->data1 + gPokedexView->unk62C + 0x40] * 5 / 256; + s16 r0; + + val = gPokedexView->unk62C + sprite->data1; + r3 = gSineTable[val]; + r0 = gSineTable[val + 0x40]; + SetOamMatrix(sprite->data0, r0, r3, -r3, r0); + + val = gPokedexView->unk62C + (sprite->data1 + 0x40); + r3 = gSineTable[val]; + r0 = gSineTable[val + 0x40]; + sprite->pos2.x = r0 * 40 / 256; sprite->pos2.y = r3 * 40 / 256; } } -#else -__attribute__((naked)) -void sub_808F0B4(struct Sprite *sprite) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - sub sp, 0x4\n\ - adds r6, r0, 0\n\ - ldr r1, _0808F0D8 @ =gPokedexView\n\ - ldr r0, [r1]\n\ - ldr r2, _0808F0DC @ =0x0000064a\n\ - adds r0, r2\n\ - ldrb r0, [r0]\n\ - adds r7, r1, 0\n\ - cmp r0, 0\n\ - beq _0808F0E0\n\ - cmp r0, 0x3\n\ - beq _0808F0E0\n\ - adds r0, r6, 0\n\ - bl DestroySprite\n\ - b _0808F158\n\ - .align 2, 0\n\ -_0808F0D8: .4byte gPokedexView\n\ -_0808F0DC: .4byte 0x0000064a\n\ -_0808F0E0:\n\ - ldr r0, [r7]\n\ - ldr r5, _0808F160 @ =0x0000062c\n\ - adds r0, r5\n\ - ldrb r1, [r0]\n\ - ldrh r0, [r6, 0x30]\n\ - adds r1, r0\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - ldr r4, _0808F164 @ =gSineTable\n\ - lsls r0, r1, 1\n\ - adds r0, r4\n\ - ldrh r3, [r0]\n\ - adds r1, 0x40\n\ - lsls r1, 1\n\ - adds r1, r4\n\ - ldrh r0, [r6, 0x2E]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - ldrh r1, [r1]\n\ - lsls r3, 16\n\ - lsrs r2, r3, 16\n\ - negs r3, r3\n\ - lsrs r3, 16\n\ - str r1, [sp]\n\ - bl SetOamMatrix\n\ - ldr r1, [r7]\n\ - adds r1, r5\n\ - ldrh r0, [r6, 0x30]\n\ - adds r0, 0x40\n\ - ldrb r1, [r1]\n\ - adds r0, r1\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - lsls r1, r0, 1\n\ - adds r1, r4\n\ - ldrh r3, [r1]\n\ - adds r0, 0x40\n\ - lsls r0, 1\n\ - adds r0, r4\n\ - movs r2, 0\n\ - ldrsh r1, [r0, r2]\n\ - lsls r0, r1, 2\n\ - adds r0, r1\n\ - lsls r0, 3\n\ - cmp r0, 0\n\ - bge _0808F140\n\ - adds r0, 0xFF\n\ -_0808F140:\n\ - asrs r0, 8\n\ - strh r0, [r6, 0x24]\n\ - lsls r1, r3, 16\n\ - asrs r1, 16\n\ - lsls r0, r1, 2\n\ - adds r0, r1\n\ - lsls r0, 3\n\ - cmp r0, 0\n\ - bge _0808F154\n\ - adds r0, 0xFF\n\ -_0808F154:\n\ - asrs r0, 8\n\ - strh r0, [r6, 0x26]\n\ -_0808F158:\n\ - add sp, 0x4\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_0808F160: .4byte 0x0000062c\n\ -_0808F164: .4byte gSineTable\n\ - .syntax divided\n"); -} -#endif -void sub_808F168(struct Sprite *sprite) +static void sub_808F168(struct Sprite *sprite) { - if(gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) + if (gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) + { DestroySprite(sprite); + } else { - u16 r1 = gPokedexView->unk64A == 0 ? 0x50 : 0x60; - - if(gPokedexView->menuIsOpen != 0 && gPokedexView->menuY == r1) + u16 r1 = gPokedexView->unk64A == 0 ? 80 : 96; + + if (gPokedexView->menuIsOpen != 0 && gPokedexView->menuY == r1) { - sprite->invisible = 0; + sprite->invisible = FALSE; sprite->pos2.y = gPokedexView->menuCursorPos * 16; sprite->pos2.x = gSineTable[(u8)sprite->data2] / 64; sprite->data2 += 8; } else - sprite->invisible = 1; + { + sprite->invisible = TRUE; + } } } -u8 sub_808F210(struct PokedexListItem *item, u8 b) +static u8 sub_808F210(struct PokedexListItem *item, u8 b) { u8 taskId; - + gUnknown_0202FFBC = item; taskId = CreateTask(Task_InitPageScreenMultistep, 0); gTasks[taskId].data[0] = 0; @@ -2199,15 +2890,15 @@ u8 sub_808F210(struct PokedexListItem *item, u8 b) return taskId; } -bool8 sub_808F250(u8 taskId) +static bool8 sub_808F250(u8 taskId) { - if(gTasks[taskId].data[0] == 0 && gTasks[taskId].func == Task_PageScreenProcessInput) - return 0; + if (gTasks[taskId].data[0] == 0 && gTasks[taskId].func == Task_PageScreenProcessInput) + return FALSE; else - return 1; + return TRUE; } -u8 sub_808F284(struct PokedexListItem *item, u8 b) +static u8 sub_808F284(struct PokedexListItem *item, u8 b) { gUnknown_0202FFBC = item; gTasks[b].data[0] = 1; @@ -2217,148 +2908,153 @@ u8 sub_808F284(struct PokedexListItem *item, u8 b) return b; } -void Task_InitPageScreenMultistep(u8 taskId) +#if ENGLISH +#define CATEGORY_LEFT (11) +#elif GERMAN +#define CATEGORY_LEFT (16) +#endif + +static void Task_InitPageScreenMultistep(u8 taskId) { - switch(gMain.state) + switch (gMain.state) { - case 0: - default: - if(!gPaletteFade.active) - { - u16 r2; - - gPokedexView->unk64A = 1; - gPokedexView->unk64E = 0; - gUnknown_03005CEC = gMain.vblankCallback; - SetVBlankCallback(NULL); - r2 = 0; - if(gTasks[taskId].data[1] != 0) - r2 += 0x1000; - if(gTasks[taskId].data[2] != 0) - r2 |= 0x200; - sub_8091060(r2); - gMain.state = 1; - } - break; - case 1: - LZ77UnCompVram(gPokedexMenu_Gfx, (void *)VRAM); - LZ77UnCompVram(gUnknown_08E96BD4, (void *)(VRAM + 0x7800)); - sub_8091738(gUnknown_0202FFBC->dexNum, 2, 0x3FC); - gMain.state++; - break; - case 2: - sub_80904FC(0xD); - sub_8090584(gPokedexView->selectedScreen, 0xD); - sub_808D640(); - gMain.state++; - break; - case 3: - SetUpWindowConfig(&gWindowConfig_81E7064); - InitMenuWindow(&gWindowConfig_81E7064); - gMain.state++; - break; - case 4: - if(gPokedexView->dexMode == DEX_MODE_HOENN) - sub_8091154(NationalToHoennOrder(gUnknown_0202FFBC->dexNum), 0xD, 3); - else - sub_8091154(gUnknown_0202FFBC->dexNum, 0xD, 3); - //_0808F45A - sub_80911C8(gUnknown_0202FFBC->dexNum, 0x10, 3); - MenuPrint(gDexText_UnknownPoke, 11, 5); - MenuPrint(gDexText_UnknownHeight, 16, 7); - MenuPrint(gDexText_UnknownWeight, 16, 9); - if(gUnknown_0202FFBC->owned) - { - sub_8091304(gPokedexEntries[gUnknown_0202FFBC->dexNum].categoryName, 11, 5); - sub_8091458(gPokedexEntries[gUnknown_0202FFBC->dexNum].height, 16, 7); - sub_8091564(gPokedexEntries[gUnknown_0202FFBC->dexNum].weight, 16, 9); - MenuPrint(gPokedexEntries[gUnknown_0202FFBC->dexNum].descriptionPage1, 2, 13); - sub_80917CC(14, 0x3FC); - } - //_0808F50C - else - { - MenuPrint(gUnknown_083A05F8, 2, 13); - LoadPalette(gPlttBufferUnfaded + 1, 0x31, 0x1E); - } - gMain.state++; - break; - case 5: - if(gTasks[taskId].data[1] == 0) - { - //_0808F540 - gTasks[taskId].data[4] = (u16)sub_80918EC(gUnknown_0202FFBC->dexNum, 0x30, 0x38, 0); - gSprites[gTasks[taskId].data[4]].oam.priority = 0; - } - gMain.state++; - break; - case 6: + case 0: + default: + if (!gPaletteFade.active) + { + u16 r2; + + gPokedexView->unk64A = 1; + gPokedexView->descriptionPageNum = 0; + gUnknown_03005CEC = gMain.vblankCallback; + SetVBlankCallback(NULL); + r2 = 0; + if (gTasks[taskId].data[1] != 0) + r2 += 0x1000; + if (gTasks[taskId].data[2] != 0) + r2 |= 0x200; + sub_8091060(r2); + gMain.state = 1; + } + break; + case 1: + LZ77UnCompVram(gPokedexMenu_Gfx, (void *)VRAM); + LZ77UnCompVram(gUnknown_08E96BD4, (void *)(VRAM + 0x7800)); + sub_8091738(gUnknown_0202FFBC->dexNum, 2, 0x3FC); + gMain.state++; + break; + case 2: + sub_80904FC(0xD); + sub_8090584(gPokedexView->selectedScreen, 0xD); + sub_808D640(); + gMain.state++; + break; + case 3: + SetUpWindowConfig(&gWindowConfig_81E7064); + InitMenuWindow(&gWindowConfig_81E7064); + gMain.state++; + break; + case 4: + if (gPokedexView->dexMode == DEX_MODE_HOENN) + sub_8091154(NationalToHoennOrder(gUnknown_0202FFBC->dexNum), 0xD, 3); + else + sub_8091154(gUnknown_0202FFBC->dexNum, 0xD, 3); + sub_80911C8(gUnknown_0202FFBC->dexNum, 0x10, 3); + MenuPrint(gDexText_UnknownPoke, CATEGORY_LEFT, 5); + MenuPrint(gDexText_UnknownHeight, 16, 7); + MenuPrint(gDexText_UnknownWeight, 16, 9); + if (gUnknown_0202FFBC->owned) + { + sub_8091304(gPokedexEntries[gUnknown_0202FFBC->dexNum].categoryName, CATEGORY_LEFT, 5); + sub_8091458(gPokedexEntries[gUnknown_0202FFBC->dexNum].height, 16, 7); + sub_8091564(gPokedexEntries[gUnknown_0202FFBC->dexNum].weight, 16, 9); + MenuPrint(gPokedexEntries[gUnknown_0202FFBC->dexNum].descriptionPage1, 2, 13); + sub_80917CC(14, 0x3FC); + } + else + { + MenuPrint(gUnknown_083A05F8, 2, 13); + LoadPalette(gPlttBufferUnfaded + 1, 0x31, 0x1E); + } + gMain.state++; + break; + case 5: + if (gTasks[taskId].data[1] == 0) + { + gTasks[taskId].data[4] = (u16)sub_80918EC(gUnknown_0202FFBC->dexNum, 0x30, 0x38, 0); + gSprites[gTasks[taskId].data[4]].oam.priority = 0; + } + gMain.state++; + break; + case 6: { u32 r3 = 0; - - if(gTasks[taskId].data[2] != 0) + + if (gTasks[taskId].data[2] != 0) r3 = 0x14; - if(gTasks[taskId].data[1] != 0) - { - r3 |= (1 << (gSprites[gTasks[taskId].data[4]].oam.paletteNum + 0x10)); - } - BeginNormalPaletteFade(~r3, 0, 0x10, 0, 0); + if (gTasks[taskId].data[1] != 0) + r3 |= (1 << (gSprites[gTasks[taskId].data[4]].oam.paletteNum + 16)); + BeginNormalPaletteFade(~r3, 0, 16, 0, 0); SetVBlankCallback(gUnknown_03005CEC); gMain.state++; - break; } - case 7: - REG_BLDCNT = 0; - REG_BLDALPHA = 0; - REG_BLDY = 0; - REG_BG3CNT = 0xF03; - REG_BG1CNT = 0xD00; - REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; + break; + case 7: + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + REG_BLDY = 0; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(15) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(13) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; + gMain.state++; + break; + case 8: + if (!gPaletteFade.active) + { gMain.state++; - break; - case 8: - if(!gPaletteFade.active) + if (gTasks[taskId].data[3] == 0) { - gMain.state++; - if(gTasks[taskId].data[3] == 0) - { - StopCryAndClearCrySongs(); - PlayCry2(NationalPokedexNumToSpecies(gUnknown_0202FFBC->dexNum), 0, 0x7D, 0xA); - } - else - gMain.state++; + StopCryAndClearCrySongs(); + PlayCry2(NationalPokedexNumToSpecies(gUnknown_0202FFBC->dexNum), 0, 0x7D, 0xA); } - break; - case 9: - if(!IsCryPlayingOrClearCrySongs()) + else + { gMain.state++; - break; - case 10: - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[1] = 0; - gTasks[taskId].data[2] = 1; - gTasks[taskId].data[3] = 1; - gTasks[taskId].func = Task_PageScreenProcessInput; - gMain.state = 0; - break; + } + } + break; + case 9: + if (!IsCryPlayingOrClearCrySongs()) + gMain.state++; + break; + case 10: + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 1; + gTasks[taskId].data[3] = 1; + gTasks[taskId].func = Task_PageScreenProcessInput; + gMain.state = 0; + break; } } -void Task_PageScreenProcessInput(u8 taskId) +static void Task_PageScreenProcessInput(u8 taskId) { if (gTasks[taskId].data[0] != 0) { - BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + BeginNormalPaletteFade(-1, 0, 0, 16, 0); gTasks[taskId].func = sub_808F888; PlaySE(SE_Z_SCROLL); + return; } - else if (gMain.newKeys & B_BUTTON) + if (gMain.newKeys & B_BUTTON) { - BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + BeginNormalPaletteFade(-1, 0, 0, 16, 0); gTasks[taskId].func = Task_ClosePageScreen; PlaySE(SE_PC_OFF); + return; } - else if (gMain.newKeys & A_BUTTON) + if (gMain.newKeys & A_BUTTON) { switch (gPokedexView->selectedScreen) { @@ -2377,7 +3073,9 @@ void Task_PageScreenProcessInput(u8 taskId) break; case SIZE_SCREEN: if (!gUnknown_0202FFBC->owned) + { PlaySE(SE_HAZURE); + } else { BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); @@ -2386,38 +3084,41 @@ void Task_PageScreenProcessInput(u8 taskId) } break; } + return; } - else if (((gMain.newKeys & DPAD_LEFT) + if (((gMain.newKeys & DPAD_LEFT) || ((gMain.newKeys & L_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) && gPokedexView->selectedScreen > 0) { gPokedexView->selectedScreen--; sub_8090584(gPokedexView->selectedScreen, 0xD); PlaySE(SE_Z_PAGE); + return; } - else if (((gMain.newKeys & DPAD_RIGHT) + if (((gMain.newKeys & DPAD_RIGHT) || ((gMain.newKeys & R_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) && gPokedexView->selectedScreen < 3) { gPokedexView->selectedScreen++; sub_8090584(gPokedexView->selectedScreen, 0xD); PlaySE(SE_Z_PAGE); + return; } } -void sub_808F888(u8 taskId) +static void sub_808F888(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) gTasks[taskId].func = Task_InitPageScreenMultistep; } -void Task_ClosePageScreen(u8 taskId) +static void Task_ClosePageScreen(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) DestroyTask(taskId); } -void Task_InitAreaScreenMultistep(u8 taskId) +static void Task_InitAreaScreenMultistep(u8 taskId) { switch (gMain.state) { @@ -2437,7 +3138,7 @@ void Task_InitAreaScreenMultistep(u8 taskId) sub_8090540(0xD); sub_8090644(1, 0xD); sub_808D640(); - REG_BG1CNT = 0xD00; + REG_BG1CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(13) | BGCNT_16COLOR | BGCNT_TXT256x256; gMain.state++; break; case 2: @@ -2450,17 +3151,17 @@ void Task_InitAreaScreenMultistep(u8 taskId) } } -void Task_AreaScreenProcessInput(u8 taskId) +static void Task_AreaScreenProcessInput(u8 taskId) { - if(gPokedexView->unk64F != 0) + if (gPokedexView->unk64F != 0) gTasks[taskId].func = sub_808FA00; } -void sub_808FA00(u8 taskId) +static void sub_808FA00(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { - switch(gPokedexView->unk64F) + switch (gPokedexView->unk64F) { case 1: default: @@ -2473,115 +3174,113 @@ void sub_808FA00(u8 taskId) } } -void Task_InitCryScreenMultistep(u8 taskId) +static void Task_InitCryScreenMultistep(u8 taskId) { - switch(gMain.state) + switch (gMain.state) { - case 0: - default: - if(!gPaletteFade.active) - { - m4aMPlayStop(&gMPlay_BGM); - gPokedexView->unk64A = 6; - gUnknown_03005CEC = gMain.vblankCallback; - SetVBlankCallback(NULL); - sub_8091060(0x200); - gPokedexView->selectedScreen = CRY_SCREEN; - gMain.state = 1; - } - break; - case 1: - LZ77UnCompVram(gPokedexMenu_Gfx, (void *)VRAM); - LZ77UnCompVram(gUnknown_0839F8A0, (void *)(VRAM + 0x7000)); - gMain.state++; - break; - case 2: - sub_8090540(0xD); - sub_8090644(2, 0xD); - sub_808D640(); - DmaClear16(3, (void *)(VRAM + 0xF800), 0x500); - gMain.state++; - break; - case 3: - SetUpWindowConfig(&gWindowConfig_81E702C); - InitMenuWindow(&gWindowConfig_81E702C); - ResetPaletteFade(); - gMain.state++; - break; - case 4: - MenuPrint(gDexText_CryOf, 10, 4); - sub_8091260(gUnknown_0202FFBC->dexNum, 10, 6, 2); - gMain.state++; - break; - case 5: - gTasks[taskId].data[4] = sub_80918EC(gUnknown_0202FFBC->dexNum, 0x30, 0x38, 0); - gSprites[gTasks[taskId].data[4]].oam.priority = 0; - gUnknown_03005E98 = 0; - gMain.state++; - break; - case 6: + case 0: + default: + if (!gPaletteFade.active) + { + m4aMPlayStop(&gMPlay_BGM); + gPokedexView->unk64A = 6; + gUnknown_03005CEC = gMain.vblankCallback; + SetVBlankCallback(NULL); + sub_8091060(0x200); + gPokedexView->selectedScreen = CRY_SCREEN; + gMain.state = 1; + } + break; + case 1: + LZ77UnCompVram(gPokedexMenu_Gfx, (void *)VRAM); + LZ77UnCompVram(gUnknown_0839F8A0, (void *)(VRAM + 0x7000)); + gMain.state++; + break; + case 2: + sub_8090540(0xD); + sub_8090644(2, 0xD); + sub_808D640(); + DmaClear16(3, (void *)(VRAM + 0xF800), 0x500); + gMain.state++; + break; + case 3: + SetUpWindowConfig(&gWindowConfig_81E702C); + InitMenuWindow(&gWindowConfig_81E702C); + ResetPaletteFade(); + gMain.state++; + break; + case 4: + MenuPrint(gDexText_CryOf, 10, 4); + sub_8091260(gUnknown_0202FFBC->dexNum, 10, 6, 2); + gMain.state++; + break; + case 5: + gTasks[taskId].data[4] = sub_80918EC(gUnknown_0202FFBC->dexNum, 0x30, 0x38, 0); + gSprites[gTasks[taskId].data[4]].oam.priority = 0; + gUnknown_03005E98 = 0; + gMain.state++; + break; + case 6: { struct CryRelatedStruct sp8; - + sp8.unk0 = 0x4020; sp8.unk2 = 0x1F; - sp8.unk3 = 8; - sp8.unk5 = 0x1E; - sp8.unk4 = 0xC; - if(sub_8119E3C(&sp8, 0) != 0) + sp8.paletteNo = 8; + sp8.yPos = 0x1E; + sp8.xPos = 0xC; + if (sub_8119E3C(&sp8, 0) != 0) { gMain.state++; gUnknown_03005E98 = 0; } - break; - } - case 7: + } + break; + case 7: { struct CryRelatedStruct sp10; - + sp10.unk0 = 0x3000; sp10.unk2 = 0xE; - sp10.unk3 = 9; - sp10.unk4 = 0x12; - sp10.unk5 = 3; - if(ShowPokedexCryScreen(&sp10, 1) != 0) - { + sp10.paletteNo = 9; + sp10.xPos = 0x12; + sp10.yPos = 3; + if (ShowPokedexCryScreen(&sp10, 1) != 0) gMain.state++; - } - break; } - case 8: - BeginNormalPaletteFade(-0x15, 0, 0x10, 0, 0); - SetVBlankCallback(gUnknown_03005CEC); - gMain.state++; - break; - case 9: - REG_BLDCNT = 0; - REG_BLDALPHA = 0; - REG_BLDY = 0; - REG_BG2CNT = 0xE02; - REG_BG0CNT = 0x1F07; - REG_BG1CNT = 0xD00; - REG_DISPCNT = 0x1F07 + 0x39; - gMain.state++; - break; - case 10: - gPokedexView->unk64F = 0; - gMain.state = 0; - gTasks[taskId].func = Task_CryScreenProcessInput; - break; + break; + case 8: + BeginNormalPaletteFade(-0x15, 0, 0x10, 0, 0); + SetVBlankCallback(gUnknown_03005CEC); + gMain.state++; + break; + case 9: + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + REG_BLDY = 0; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(14) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(13) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON; + gMain.state++; + break; + case 10: + gPokedexView->unk64F = 0; + gMain.state = 0; + gTasks[taskId].func = Task_CryScreenProcessInput; + break; } } -void Task_CryScreenProcessInput(u8 taskId) +static void Task_CryScreenProcessInput(u8 taskId) { sub_8119F88(0); - + if (IsCryPlaying()) sub_8090040(1); else sub_8090040(0); - + if (gMain.newKeys & A_BUTTON) { sub_8090040(1); @@ -2597,8 +3296,9 @@ void Task_CryScreenProcessInput(u8 taskId) gPokedexView->unk64F = 1; gTasks[taskId].func = sub_808FFBC; PlaySE(SE_PC_OFF); + return; } - else if ((gMain.newKeys & DPAD_LEFT) + if ((gMain.newKeys & DPAD_LEFT) || ((gMain.newKeys & L_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); @@ -2606,12 +3306,15 @@ void Task_CryScreenProcessInput(u8 taskId) gPokedexView->unk64F = 2; gTasks[taskId].func = sub_808FFBC; PlaySE(SE_Z_PAGE); + return; } - else if ((gMain.newKeys & DPAD_RIGHT) + if ((gMain.newKeys & DPAD_RIGHT) || ((gMain.newKeys & R_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { if (!gUnknown_0202FFBC->owned) + { PlaySE(SE_HAZURE); + } else { BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); @@ -2620,74 +3323,76 @@ void Task_CryScreenProcessInput(u8 taskId) gTasks[taskId].func = sub_808FFBC; PlaySE(SE_Z_PAGE); } + return; } } } -void sub_808FFBC(u8 taskId) +static void sub_808FFBC(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { DestroyCryMeterNeedleSprite(); - switch(gPokedexView->unk64F) + switch (gPokedexView->unk64F) { - default: - case 1: - gTasks[taskId].func = Task_InitPageScreenMultistep; - break; - case 2: - gTasks[taskId].func = Task_InitAreaScreenMultistep; - break; - case 3: - gTasks[taskId].func = Task_InitSizeScreenMultistep; + default: + case 1: + gTasks[taskId].func = Task_InitPageScreenMultistep; + break; + case 2: + gTasks[taskId].func = Task_InitAreaScreenMultistep; + break; + case 3: + gTasks[taskId].func = Task_InitSizeScreenMultistep; + break; } } } -void sub_8090040(u8 a) +static void sub_8090040(u8 a) { u16 unk; - - if(a != 0) + + if (a != 0) unk = 0x392; else unk = 0x2AF; LoadPalette(&unk, 0x5D, 2); } -void Task_InitSizeScreenMultistep(u8 taskId) +static void Task_InitSizeScreenMultistep(u8 taskId) { u8 spriteId; - - switch(gMain.state) + + switch (gMain.state) { - default: - case 0: - if(!gPaletteFade.active) - { - gPokedexView->unk64A = 7; - gUnknown_03005CEC = gMain.vblankCallback; - SetVBlankCallback(NULL); - sub_8091060(0x200); - gPokedexView->selectedScreen = SIZE_SCREEN; - gMain.state = 1; - } - break; - case 1: - LZ77UnCompVram(gPokedexMenu_Gfx, (void *)VRAM); - LZ77UnCompVram(gUnknown_0839F988, (void *)(VRAM + 0x7000)); - gMain.state++; - break; - case 2: - sub_8090540(0xD); - sub_8090644(3, 0xD); - sub_808D640(); - gMain.state++; - break; - case 3: + default: + case 0: + if (!gPaletteFade.active) + { + gPokedexView->unk64A = 7; + gUnknown_03005CEC = gMain.vblankCallback; + SetVBlankCallback(NULL); + sub_8091060(0x200); + gPokedexView->selectedScreen = SIZE_SCREEN; + gMain.state = 1; + } + break; + case 1: + LZ77UnCompVram(gPokedexMenu_Gfx, (void *)VRAM); + LZ77UnCompVram(gUnknown_0839F988, (void *)(VRAM + 0x7000)); + gMain.state++; + break; + case 2: + sub_8090540(0xD); + sub_8090644(3, 0xD); + sub_808D640(); + gMain.state++; + break; + case 3: { u8 string[40]; //I hope this is the correct size - + SetUpWindowConfig(&gWindowConfig_81E702C); InitMenuWindow(&gWindowConfig_81E702C); string[0] = EOS; @@ -2695,67 +3400,66 @@ void Task_InitSizeScreenMultistep(u8 taskId) StringAppend(string, gSaveBlock2.playerName); sub_8072BD8(string, 3, 15, 0xC0); gMain.state++; - break; } - case 4: - ResetPaletteFade(); - gMain.state++; - break; - case 5: - spriteId = sub_8091A4C(gSaveBlock2.playerGender, 0x98, 0x38, 0); - gSprites[spriteId].oam.affineMode = 1; - gSprites[spriteId].oam.matrixNum = 1; - gSprites[spriteId].oam.priority = 0; - gSprites[spriteId].pos2.y = gPokedexEntries[gUnknown_0202FFBC->dexNum].trainerOffset; - SetOamMatrix(1, gPokedexEntries[gUnknown_0202FFBC->dexNum].trainerScale, 0, 0, gPokedexEntries[gUnknown_0202FFBC->dexNum].trainerScale); - LoadPalette(gUnknown_083B4EC4, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); - gMain.state++; - break; - case 6: - spriteId = sub_80918EC(gUnknown_0202FFBC->dexNum, 0x58, 0x38, 1); - gSprites[spriteId].oam.affineMode = 1; - gSprites[spriteId].oam.matrixNum = 2; - gSprites[spriteId].oam.priority = 0; - gSprites[spriteId].pos2.y = gPokedexEntries[gUnknown_0202FFBC->dexNum].pokemonOffset; - SetOamMatrix(2, gPokedexEntries[gUnknown_0202FFBC->dexNum].pokemonScale, 0, 0, gPokedexEntries[gUnknown_0202FFBC->dexNum].pokemonScale); - LoadPalette(gUnknown_083B4EC4, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); - gMain.state++; - break; - case 7: - BeginNormalPaletteFade(-0x15, 0, 0x10, 0, 0); - SetVBlankCallback(gUnknown_03005CEC); - gMain.state++; - break; - case 8: - REG_BLDCNT = 0; - REG_BLDALPHA = 0; - REG_BLDY = 0; - REG_BG2CNT = 0xE03; - REG_DISPCNT = 0x1E40; - gMain.state++; - break; - case 9: - if(!gPaletteFade.active) - { - gPokedexView->unk64F = 0; - gMain.state = 0; - gTasks[taskId].func = Task_SizeScreenProcessInput; - } - break; + break; + case 4: + ResetPaletteFade(); + gMain.state++; + break; + case 5: + spriteId = sub_8091A4C(gSaveBlock2.playerGender, 152, 56, 0); + gSprites[spriteId].oam.affineMode = 1; + gSprites[spriteId].oam.matrixNum = 1; + gSprites[spriteId].oam.priority = 0; + gSprites[spriteId].pos2.y = gPokedexEntries[gUnknown_0202FFBC->dexNum].trainerOffset; + SetOamMatrix(1, gPokedexEntries[gUnknown_0202FFBC->dexNum].trainerScale, 0, 0, gPokedexEntries[gUnknown_0202FFBC->dexNum].trainerScale); + LoadPalette(gUnknown_083B4EC4, (gSprites[spriteId].oam.paletteNum + 16) * 16, sizeof(gUnknown_083B4EC4)); + gMain.state++; + break; + case 6: + spriteId = sub_80918EC(gUnknown_0202FFBC->dexNum, 88, 56, 1); + gSprites[spriteId].oam.affineMode = 1; + gSprites[spriteId].oam.matrixNum = 2; + gSprites[spriteId].oam.priority = 0; + gSprites[spriteId].pos2.y = gPokedexEntries[gUnknown_0202FFBC->dexNum].pokemonOffset; + SetOamMatrix(2, gPokedexEntries[gUnknown_0202FFBC->dexNum].pokemonScale, 0, 0, gPokedexEntries[gUnknown_0202FFBC->dexNum].pokemonScale); + LoadPalette(gUnknown_083B4EC4, (gSprites[spriteId].oam.paletteNum + 16) * 16, sizeof(gUnknown_083B4EC4)); + gMain.state++; + break; + case 7: + BeginNormalPaletteFade(-0x15, 0, 0x10, 0, 0); + SetVBlankCallback(gUnknown_03005CEC); + gMain.state++; + break; + case 8: + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + REG_BLDY = 0; + REG_BG2CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(14) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; + gMain.state++; + break; + case 9: + if (!gPaletteFade.active) + { + gPokedexView->unk64F = 0; + gMain.state = 0; + gTasks[taskId].func = Task_SizeScreenProcessInput; + } + break; } } -void Task_SizeScreenProcessInput(u8 taskId) +static void Task_SizeScreenProcessInput(u8 taskId) { - if(gMain.newKeys & B_BUTTON) + if (gMain.newKeys & B_BUTTON) { BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); gPokedexView->unk64F = 1; gTasks[taskId].func = sub_8090498; PlaySE(SE_PC_OFF); } - //_08090430 - else if((gMain.newKeys & DPAD_LEFT) + else if ((gMain.newKeys & DPAD_LEFT) || ((gMain.newKeys & L_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); @@ -2765,11 +3469,11 @@ void Task_SizeScreenProcessInput(u8 taskId) } } -void sub_8090498(u8 taskId) +static void sub_8090498(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { - switch(gPokedexView->unk64F) + switch (gPokedexView->unk64F) { default: case 1: @@ -2782,35 +3486,35 @@ void sub_8090498(u8 taskId) } } -void sub_80904FC(u16 a) +static void sub_80904FC(u16 a) { LZ77UnCompVram(gUnknown_08E96ACC, (void *)(VRAM + a * 0x800)); DmaClear16(3, (void *)(VRAM + a * 0x800 + 0xC0), 0x440); } -void sub_8090540(u16 a) +static void sub_8090540(u16 a) { LZ77UnCompVram(gUnknown_08E96B58, (void *)(VRAM + a * 0x800)); DmaClear16(3, (void *)(VRAM + a * 0x800 + 0xC0), 0x440); } #ifdef NONMATCHING -void sub_8090584(u8 a, u16 b) +static void sub_8090584(u8 a, u16 b) { u8 i; //r1 u8 j; //r3 u32 r6; register u8 r7; - - for(i = 0; i < 4; i++) + + for (i = 0; i < 4; i++) { r7 = i * 5 + 1; r6 = 0x4000; - - if(i == a) + + if (i == a) r6 = 0x2000; - - for(j = 0; j < 5; j++) + + for (j = 0; j < 5; j++) { u32 r0 = b * 0x800 + (r7 + j) * 2; u8 *ptr; @@ -2822,11 +3526,11 @@ void sub_8090584(u8 a, u16 b) } } r6 = 0x4000; - for(j = 0; j < 5; j++) + for (j = 0; j < 5; j++) { u32 r0 = b * 0x800 + j * 2; u8 *ptr; - + ptr = VRAM + 0x32; *(u16 *)(ptr + r0) = *(u16 *)(ptr + r0) & 0xFFF | r6; ptr = VRAM + 0x72; @@ -2835,7 +3539,7 @@ void sub_8090584(u8 a, u16 b) } #else __attribute__((naked)) -void sub_8090584(u8 a, u16 b) +static void sub_8090584(u8 a, u16 b) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ @@ -2941,36 +3645,36 @@ _08090640: .4byte 0x06000072\n\ //Nope, can't get this one to match, either. #ifdef NONMATCHING -void sub_8090644(u8 a, u16 b) +static void sub_8090644(u8 a, u16 b) { u8 i; u8 j; - - for(i = 0; i < 4; i++) + + for (i = 0; i < 4; i++) { u8 r8 = i * 5 + 1; u32 r5; - - if(i == a || i == 0) + + if (i == a || i == 0) r5 = 0x2000; - else if(a != 0) + else if (a != 0) r5 = 0x4000; - - for(j = 0; j < 5; j++) + + for (j = 0; j < 5; j++) { u16 (*vramData)[0x400]; - + vramData = (u16 (*)[])VRAM; vramData[b][r8 + j] = vramData[b][r8 + j] & 0xFFF | r5; vramData = (u16 (*)[])(VRAM + 0x40); vramData[b][r8 + j] = vramData[b][r8 + j] & 0xFFF | r5; } } - - for(j = 0; j < 5; j++) + + for (j = 0; j < 5; j++) { u16 (*vramData)[0x400]; - + vramData = (u16 (*)[])(VRAM + 0x32); vramData[b][j] = vramData[b][j] & 0xFFF | 0x4000; vramData = (u16 (*)[])(VRAM + 0x72); @@ -2979,7 +3683,7 @@ void sub_8090644(u8 a, u16 b) } #else __attribute__((naked)) -void sub_8090644(u8 a, u16 b) +static void sub_8090644(u8 a, u16 b) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ @@ -3092,7 +3796,7 @@ _08090708: .4byte 0x06000072\n\ u8 sub_809070C(u16 dexNum, u32 b, u32 c) { u8 taskId = CreateTask(sub_8090750, 0); - + gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = dexNum; gTasks[taskId].data[12] = b; @@ -3102,88 +3806,1721 @@ u8 sub_809070C(u16 dexNum, u32 b, u32 c) return taskId; } -/* -void sub_8090750(u8 taskId) +static void sub_8090750(u8 taskId) { + u8 spriteId; u16 dexNum = gTasks[taskId].data[1]; - - switch(gTasks[taskId].data[0]) + u16 i; + + switch (gTasks[taskId].data[0]) { - default: - case 0: - if(!gPaletteFade.active) + case 0: + default: + if (!gPaletteFade.active) + { + gUnknown_03005CEC = gMain.vblankCallback; + SetVBlankCallback(NULL); + sub_8091060(0x100); + gTasks[taskId].data[0] = 1; + } + break; + case 1: + LZ77UnCompVram(gPokedexMenu_Gfx, (void *)(VRAM + 0x4000)); + LZ77UnCompVram(gUnknown_08E96BD4, (void *)(VRAM + 0x7800)); + for (i = 0; i < 0x280; i++) + { +#ifndef NONMATCHING + asm(""); +#endif + *(u16 *)(VRAM + 0x7800 + 2 * i) += 0x2000; + } + sub_8091738(gTasks[taskId].data[1], 2, 0x3FC); + ResetPaletteFade(); + LoadPalette(gPokedexMenu_Pal + 1, 0x21, 0x9E); + gTasks[taskId].data[0]++; + break; + case 2: + SetUpWindowConfig(&gWindowConfig_81E7064); + InitMenuWindow(&gWindowConfig_81E7064); + DmaClear16(3, (void *)(VRAM + 0xC000), 0x200); + gTasks[taskId].data[0]++; + break; + case 3: + sub_8072BD8(gDexText_RegisterComplete, 2, 0, 0xD0); + if (!IsNationalPokedexEnabled()) + sub_8091154(NationalToHoennOrder(dexNum), 13, 3); + else + sub_8091154(dexNum, 13, 3); + sub_80911C8(dexNum, 16, 3); + MenuPrint(gDexText_UnknownPoke, CATEGORY_LEFT, 5); + MenuPrint(gDexText_UnknownHeight, 16, 7); + MenuPrint(gDexText_UnknownWeight, 16, 9); + sub_8091304(gPokedexEntries[dexNum].categoryName, CATEGORY_LEFT, 5); + sub_8091458(gPokedexEntries[dexNum].height, 16, 7); + sub_8091564(gPokedexEntries[dexNum].weight, 16, 9); + MenuPrint(gPokedexEntries[dexNum].descriptionPage1, 2, 13); + sub_80917CC(14, 0x3FC); + gTasks[taskId].data[0]++; + break; + case 4: + spriteId = sub_80918EC(dexNum, 0x30, 0x38, 0); + gSprites[spriteId].oam.priority = 0; + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + SetVBlankCallback(gUnknown_03005CEC); + gTasks[taskId].data[3] = spriteId; + gTasks[taskId].data[0]++; + break; + case 5: + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + REG_BLDY = 0; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(15) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; + gTasks[taskId].data[0]++; + break; + case 6: + if (!gPaletteFade.active) + { + PlayCry1(NationalPokedexNumToSpecies(dexNum), 0); + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[4] = 0; + gTasks[taskId].func = sub_8090A3C; + } + break; + } +} + +static void sub_8090A3C(u8 taskId) +{ + if (gMain.newKeys & B_BUTTON) + { + BeginNormalPaletteFade(0x0000FFFC, 0, 0, 16, 0); + gSprites[gTasks[taskId].data[3]].callback = sub_8090C28; + gTasks[taskId].func = sub_8090B8C; + return; + } + else if (gMain.newKeys & A_BUTTON) + { + if (gTasks[taskId].data[4] == 0) + { + u16 r4 = gTasks[taskId].data[1]; + + MenuZeroFillWindowRect(2, 13, 27, 19); + MenuPrint(gPokedexEntries[r4].descriptionPage2, 2, 13); + (*(u16 *)(VRAM + 0x7ACA))++; + (*(u16 *)(VRAM + 0x7B0A))++; + gTasks[taskId].data[4] = 1; + PlaySE(SE_PIN); + } + else + { + BeginNormalPaletteFade(0x0000FFFC, 0, 0, 16, 0); + gSprites[gTasks[taskId].data[3]].callback = sub_8090C28; + gTasks[taskId].func = sub_8090B8C; + return; + } + } + gTasks[taskId].data[2]++; + if (gTasks[taskId].data[2] & 0x10) + LoadPalette(gPokedexMenu_Pal + 1, 0x51, 14); + else + LoadPalette(gPokedexMenu2_Pal + 1, 0x51, 14); +} + +static void sub_8090B8C(u8 taskId) +{ + if (!gPaletteFade.active) + { + u16 species; + u32 otId; + u32 personality; + u8 paletteNum; + const u8 *lzPaletteData; + + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; + CpuCopy16(gUnknown_08D00524, (void *)(VRAM + 0xC000), 0x1000); + sub_800D74C(); + species = NationalPokedexNumToSpecies(gTasks[taskId].data[1]); + otId = ((u16)gTasks[taskId].data[13] << 16) | (u16)gTasks[taskId].data[12]; + personality = ((u16)gTasks[taskId].data[15] << 16) | (u16)gTasks[taskId].data[14]; + paletteNum = gSprites[gTasks[taskId].data[3]].oam.paletteNum; + lzPaletteData = species_and_otid_get_pal(species, otId, personality); + LoadCompressedPalette(lzPaletteData, 0x100 | paletteNum * 16, 32); + DestroyTask(taskId); + } +} + +static void sub_8090C28(struct Sprite *sprite) +{ + if (sprite->pos1.x < 0x78) + sprite->pos1.x += 2; + if (sprite->pos1.x > 0x78) + sprite->pos1.x -= 2; + + if (sprite->pos1.y < 0x50) + sprite->pos1.y += 1; + if (sprite->pos1.y > 0x50) + sprite->pos1.y -= 1; +} + +static void sub_8090C68(void) +{ + if (gUnknown_0202FFBC->owned) + { + if (gPokedexView->descriptionPageNum == 0) + { + MenuZeroFillWindowRect(2, 13, 27, 19); + MenuPrint(gPokedexEntries[gUnknown_0202FFBC->dexNum].descriptionPage2, 2, 13); + gPokedexView->descriptionPageNum = 1; + (*(u16 *)(VRAM + 0x7ACA))++; + (*(u16 *)(VRAM + 0x7B0A))++; + PlaySE(SE_PIN); + } + else + { + MenuZeroFillWindowRect(2, 13, 27, 19); + MenuPrint(gPokedexEntries[gUnknown_0202FFBC->dexNum].descriptionPage1, 2, 13); + gPokedexView->descriptionPageNum = 0; + (*(u16 *)(VRAM + 0x7ACA))--; + (*(u16 *)(VRAM + 0x7B0A))--; + PlaySE(SE_PIN); + } + } +} + +const u8 *GetPokemonCategory(u16 dexNum) +{ + return gPokedexEntries[dexNum].categoryName; +} + +u16 GetPokedexHeightWeight(u16 dexNum, u8 data) +{ + switch (data) + { + case 0: // height + return gPokedexEntries[dexNum].height; + case 1: // weight + return gPokedexEntries[dexNum].weight; + default: + return 1; + } +} + +s8 GetNationalPokedexFlag(u16 a, u8 b) +{ + u8 index; + u8 bit; + u8 mask; + s8 retVal; + + a--; + index = a / 8; + bit = a % 8; + mask = 1 << bit; + retVal = 0; + switch (b) + { + case 0: + if (gSaveBlock2.pokedex.seen[index] & mask) + { + if ((gSaveBlock2.pokedex.seen[index] & mask) == (gSaveBlock1.unk938[index] & mask) + && (gSaveBlock2.pokedex.seen[index] & mask) == (gSaveBlock1.unk3A8C[index] & mask)) + retVal = 1; + else { - gUnknown_03005CEC = gMain.vblankCallback; - SetVBlankCallback(NULL); - sub_8091060(0x100); - gTasks[taskId].data[0] = 1; + gSaveBlock2.pokedex.seen[index] &= ~mask; + gSaveBlock1.unk938[index] &= ~mask; + gSaveBlock1.unk3A8C[index] &= ~mask; + retVal = 0; } + } + break; + case 1: + if (gSaveBlock2.pokedex.owned[index] & mask) + { + if ((gSaveBlock2.pokedex.owned[index] & mask) == (gSaveBlock2.pokedex.seen[index] & mask) + && (gSaveBlock2.pokedex.owned[index] & mask) == (gSaveBlock1.unk938[index] & mask) + && (gSaveBlock2.pokedex.owned[index] & mask) == (gSaveBlock1.unk3A8C[index] & mask)) + retVal = 1; + else + { + gSaveBlock2.pokedex.owned[index] &= ~mask; + gSaveBlock2.pokedex.seen[index] &= ~mask; + gSaveBlock1.unk938[index] &= ~mask; + gSaveBlock1.unk3A8C[index] &= ~mask; + retVal = 0; + } + } + break; + case 2: + gSaveBlock2.pokedex.seen[index] |= mask; + gSaveBlock1.unk938[index] |= mask; + gSaveBlock1.unk3A8C[index] |= mask; + break; + case 3: + gSaveBlock2.pokedex.owned[index] |= mask; + break; + } + return retVal; +} + +u16 GetNationalPokedexCount(u8 a) +{ + u16 count = 0; + u16 i; + + for (i = 0; i < NATIONAL_DEX_COUNT; i++) + { + switch (a) + { + case 0: + if (GetNationalPokedexFlag(i + 1, 0) != 0) + count++; break; case 1: + if (GetNationalPokedexFlag(i + 1, 1) != 0) + count++; + break; + } + } + return count; +} + +u16 GetHoennPokedexCount(u8 a) +{ + u16 count = 0; + u16 i; + + for (i = 0; i < 202; i++) + { + switch (a) { - u16 i; - - LZ77UnCompVram(gPokedexMenu_Gfx, (void *)(VRAM + 0x4000)); - LZ77UnCompVram(gUnknown_08E96BD4, (void *)(VRAM + 0x7800)); - for(i = 0; i < 0x280; i++) - ((u16 *)(VRAM + 0x7800))[i] += 0x2000; - sub_8091738(gTasks[taskId].data[1], 2, 0x3FC); - ResetPaletteFade(); - LoadPalette(gPokedexMenu_Pal + 2, 0x21, 0x9E); - gTasks[taskId].data[0]++; + case 0: + if (GetNationalPokedexFlag(HoennToNationalOrder(i + 1), 0) != 0) + count++; break; + case 1: + if (GetNationalPokedexFlag(HoennToNationalOrder(i + 1), 1) != 0) + count++; + break; + } + } + return count; +} + +bool8 sub_8090FC0(void) +{ + u16 i; + + for (i = 0; i < 200; i++) + { + if (GetNationalPokedexFlag(HoennToNationalOrder(i + 1), 1) == 0) + return FALSE; + } + return TRUE; +} + +u16 sub_8090FF4(void) +{ + u16 i; + + for (i = 0; i < 150; i++) + { + if (GetNationalPokedexFlag(i + 1, 1) == 0) + return 0; + } + for (i = 152; i < 250; i++) + { + if (GetNationalPokedexFlag(i + 1, 1) == 0) + return 0; + } + for (i = 252; i < 384; i++) + { + if (GetNationalPokedexFlag(i + 1, 1) == 0) + return 0; + } + return 1; +} + +static void sub_8091060(u16 a) +{ + if (!(a & 0x100)) + { + REG_DISPCNT &= 0xFEFF; + REG_BG0CNT = 0; + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + } + if (!(a & 0x200)) + { + REG_DISPCNT &= 0xFDFF; + REG_BG1CNT = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + } + if (!(a & 0x400)) + { + REG_DISPCNT &= 0xFBFF; + REG_BG2CNT = 0; + REG_BG2HOFS = 0; + REG_BG2VOFS = 0; + } + if (!(a & 0x800)) + { + REG_DISPCNT &= 0xF7FF; + REG_BG3CNT = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; + } + if (!(a & 0x1000)) + { + REG_DISPCNT &= 0xEFFF; + ResetSpriteData(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 8; + } +} + +static void sub_8091154(u16 order, u8 b, u8 c) +{ + u8 str[4]; + + str[0] = CHAR_0 + order / 100; + str[1] = CHAR_0 + (order % 100) / 10; + str[2] = CHAR_0 + (order % 100) % 10; + str[3] = EOS; + MenuPrint(str, b, c); +} + +static u8 sub_80911C8(u16 num, u8 b, u8 c) +{ + u8 str[11]; + u8 i; + + for (i = 0; i < 11; i++) + str[i] = EOS; + num = NationalPokedexNumToSpecies(num); + switch (num) + { + default: + for (i = 0; gSpeciesNames[num][i] != EOS && i < 10; i++) + str[i] = gSpeciesNames[num][i]; + break; + case 0: + for (i = 0; i < 10; i++) + str[i] = 0xAE; + break; + } + MenuPrint(str, b, c); + return i; +} + +static u8 sub_8091260(u16 num, u8 b, u8 c, u8 d) +{ + u8 str[40]; + u8 *end; + u8 i; + + end = StringCopy(str, gUnknown_083B5558); + str[2] = d; + num = NationalPokedexNumToSpecies(num); + switch (num) + { + default: + for (i = 0; gSpeciesNames[num][i] != EOS && i < 10; i++) + end[i] = gSpeciesNames[num][i]; + break; + case 0: + for (i = 0; i < 10; i++) + end[i] = 0xAE; + break; + } + end[i] = EOS; + MenuPrint(str, b, c); + return i; +} + +static void sub_8091304(const u8 *name, u8 left, u8 top) +{ + u8 str[32]; + u8 i; +#if ENGLISH + u8 j; +#endif + + for (i = 0; name[i] != EOS && i < 11; i++) + str[i] = name[i]; +#if ENGLISH + for (j = 0; gDexText_UnknownPoke[j] == 0xAC || gDexText_UnknownPoke[j] == 0; j++) + ; + j--; + while (gDexText_UnknownPoke[j] != EOS) + str[i++] = gDexText_UnknownPoke[j++]; +#endif + str[i] = EOS; + sub_8072B80(str, left, top, gDexText_UnknownPoke); +} + +#if ENGLISH +void unref_sub_80913A4(u16 a, u8 left, u8 top) +{ + u8 str[6]; + bool8 outputted = FALSE; + u8 result; + + result = a / 1000; + if (result == 0) + { + str[0] = CHAR_SPACE; + outputted = FALSE; + } + else + { + str[0] = CHAR_0 + result; + outputted = TRUE; + } + + result = (a % 1000) / 100; + if (result == 0 && !outputted) + { + str[1] = CHAR_SPACE; + outputted = FALSE; + } + else + { + str[1] = CHAR_0 + result; + outputted = TRUE; + } + + str[2] = CHAR_0 + ((a % 1000) % 100) / 10; + str[3] = CHAR_PERIOD; + str[4] = CHAR_0 + ((a % 1000) % 100) % 10; + str[5] = EOS; + MenuPrint(str, left, top); +} +#elif GERMAN +void unref_sub_80913A4(u16 arg0, u8 left, u8 top) { + u8 buffer[8]; + int offset; + u8 result; + + u8 r6 = 0; + offset = 0; + + + buffer[r6++] = 0xFC; + buffer[r6++] = 0x13; + r6++; + + result = (arg0 / 1000); + if (result == 0) + { + offset = 6; + } + else + { + buffer[r6++] = result + CHAR_0; + } + + + result = (arg0 % 1000) / 100; + + if (result == 0 && offset != 0) + { + offset += 6; + } + else + { + buffer[r6++] = result + CHAR_0; + } + + buffer[r6++] = (((arg0 % 1000) % 100) / 10) + CHAR_0; + buffer[r6++] = CHAR_COMMA; + buffer[r6++] = (((arg0 % 1000) % 100) % 10) + CHAR_0; + + buffer[r6++] = EOS; + buffer[2] = offset; + MenuPrint(buffer, left, top); +} +#endif + +#ifdef UNITS_IMPERIAL +#define CHAR_PRIME (0xB4) +#define CHAR_DOUBLE_PRIME (0xB2) +static void sub_8091458(u16 height, u8 left, u8 top) +{ + u8 buffer[16]; + u32 inches, feet; + u8 i = 0; + + inches = (height * 10000) / 254; + if (inches % 10 >= 5) + inches += 10; + feet = inches / 120; + inches = (inches - (feet * 120)) / 10; + + buffer[i++] = EXT_CTRL_CODE_BEGIN; + buffer[i++] = 0x13; + if (feet / 10 == 0) + { + buffer[i++] = 18; + buffer[i++] = feet + CHAR_0; + } + else + { + buffer[i++] = 12; + buffer[i++] = feet / 10 + CHAR_0; + buffer[i++] = (feet % 10) + CHAR_0; + } + buffer[i++] = CHAR_PRIME; + buffer[i++] = (inches / 10) + CHAR_0; + buffer[i++] = (inches % 10) + CHAR_0; + buffer[i++] = CHAR_DOUBLE_PRIME; + buffer[i++] = EOS; + MenuPrint(buffer, left, top); +} +#else +static void sub_8091458(u16 height, u8 left, u8 top) +{ + unref_sub_80913A4(height, left, top); +} +#endif + +#ifdef UNITS_IMPERIAL +static void sub_8091564(u16 weight, u8 left, u8 top) +{ + u8 buffer[16]; + u32 lbs; + u8 i = 0; + bool8 output; + + lbs = (weight * 100000) / 4536; + if (lbs % 10 >= 5) + lbs += 10; + output = FALSE; + + buffer[i] = (lbs / 100000) + CHAR_0; + if (buffer[i] == CHAR_0 && output == FALSE) + { + buffer[i++] = CHAR_SPACE; + buffer[i++] = CHAR_SPACE; + } + else + { + output = TRUE; + i++; + } + + lbs = (lbs % 100000); + buffer[i] = (lbs / 10000) + CHAR_0; + if (buffer[i] == CHAR_0 && output == FALSE) + { + buffer[i++] = CHAR_SPACE; + buffer[i++] = CHAR_SPACE; + } + else + { + output = TRUE; + i++; + } + + lbs = (lbs % 10000); + buffer[i] = (lbs / 1000) + CHAR_0; + if (buffer[i] == CHAR_0 && output == FALSE) + { + buffer[i++] = CHAR_SPACE; + buffer[i++] = CHAR_SPACE; + } + else + { + output = TRUE; + i++; + } + lbs = (lbs % 1000); + buffer[i++] = (lbs / 100) + CHAR_0; + lbs = (lbs % 100); + buffer[i++] = CHAR_PERIOD; + buffer[i++] = (lbs / 10) + CHAR_0; + buffer[i++] = CHAR_SPACE; + buffer[i++] = CHAR_l; + buffer[i++] = CHAR_b; + buffer[i++] = CHAR_s; + buffer[i++] = CHAR_PERIOD; + buffer[i++] = EOS; + MenuPrint(buffer, left, top); +} +#else +static void sub_8091564(u16 arg0, u8 left, u8 top) +{ + unref_sub_80913A4(arg0, left, top); +} +#endif + +static void sub_8091738(u16 num, u16 b, u16 c) +{ + u8 arr[0x80]; + u16 i; + u16 j; + const u8 *r12; + u16 r7; + u8 r3; + + r12 = sMonFootprintTable[NationalPokedexNumToSpecies(num)]; + for (r7 = 0, i = 0; i < 32; i++) + { + r3 = r12[i]; + for (j = 0; j < 4; j++) + { + u32 r1 = j * 2; + s32 r2 = (r3 >> r1) & 1; + + if (r3 & (2 << r1)) + r2 |= 0x10; + +// Needed to match +#ifndef NONMATCHING + asm("");asm("");asm("");asm("");asm(""); +#endif + + arr[r7] = r2; + r7++; + } + } + CpuCopy16(arr, (u16 *)(VRAM + b * 0x4000 + c * 0x20), 0x80); +} + +static void sub_80917CC(u16 a, u16 b) +{ + *(u16 *)(VRAM + a * 0x800 + 0x232) = 0xF000 + b + 0; + *(u16 *)(VRAM + a * 0x800 + 0x234) = 0xF000 + b + 1; + *(u16 *)(VRAM + a * 0x800 + 0x272) = 0xF000 + b + 2; + *(u16 *)(VRAM + a * 0x800 + 0x274) = 0xF000 + b + 3; +} + +static u16 sub_8091818(u8 a, u16 b, u16 c, u16 d) +{ + switch (a) + { + case 1: + if (b > c) + b--; + break; + case 0: + if (b < d) + b++; + break; + case 3: + if (b > c) + b--; + else + b = d; + break; + case 2: + if (b < d) + b++; + else + b = c; + break; + } + return b; +} + +static void nullsub_59(struct Sprite *sprite) +{ +} + +static void sub_8091878(u16 a, u8 b) +{ + gUnknown_02024E8C = gUnknown_083B57A4; + gUnknown_02024E8C.paletteTag = a; + gUnknown_02024E8C.images = gUnknown_083B5794[b]; + gUnknown_02024E8C.anims = gSpriteAnimTable_81E7C64; +} + +static void sub_80918B0(u16 a, u8 b) +{ + gUnknown_02024E8C = gUnknown_083B57A4; + gUnknown_02024E8C.paletteTag = a; + gUnknown_02024E8C.images = gUnknown_083B5794[b]; + gUnknown_02024E8C.anims = gUnknown_081EC2A4[0]; +} + +u16 sub_80918EC(u16 num, s16 x, s16 y, u16 paletteNum) +{ + u8 spriteId; + + num = NationalPokedexNumToSpecies(num); + switch (num) + { + default: + DecompressPicFromTable_2( + &gMonFrontPicTable[num], + gMonFrontPicCoords[num].coords, + gMonFrontPicCoords[num].y_offset, + (void *)0x02000000, + gUnknown_083B5584[paletteNum], + num); + break; + case SPECIES_SPINDA: + LoadSpecialPokePic( + &gMonFrontPicTable[num], + gMonFrontPicCoords[num].coords, + gMonFrontPicCoords[num].y_offset, + 0x02000000, + gUnknown_083B5584[paletteNum], + num, + gSaveBlock2.pokedex.spindaPersonality, + 1); + break; + case SPECIES_UNOWN: + LoadSpecialPokePic( + &gMonFrontPicTable[num], + gMonFrontPicCoords[num].coords, + gMonFrontPicCoords[num].y_offset, + 0x02000000, + gUnknown_083B5584[paletteNum], + num, + gSaveBlock2.pokedex.unownPersonality, + 1); + break; + } + LoadCompressedPalette(gMonPaletteTable[num].data, 0x100 + paletteNum * 16, 32); + sub_8091878(paletteNum, paletteNum); + spriteId = CreateSprite(&gUnknown_02024E8C, x, y, 0); + gSprites[spriteId].oam.paletteNum = paletteNum; + return spriteId; +} + +static u8 sub_8091A4C(u16 gender, s16 x, s16 y, u16 paletteNum) +{ + u8 spriteId; + + DecompressPicFromTable_2( + &gTrainerFrontPicTable[gender], + gTrainerFrontPicCoords[gender].coords, + gTrainerFrontPicCoords[gender].y_offset, + (void *)0x02000000, + gUnknown_083B5584[0], + gender); + sub_80918B0(gender, 0); + spriteId = CreateSprite(&gUnknown_02024E8C, x, y, 0); + gSprites[spriteId].oam.paletteNum = paletteNum; + return spriteId; +} + +int sub_8091AF8(u8 a, u8 b, u8 abcGroup, u8 bodyColor, u8 type1, u8 type2) +{ + u16 species; + u16 i; + u16 resultsCount; + u8 types[2]; + + SortPokedex(a, b); + + for (i = 0, resultsCount = 0; i < NATIONAL_DEX_COUNT; i++) + { + if (gPokedexView->unk0[i].seen) + { + gPokedexView->unk0[resultsCount] = gPokedexView->unk0[i]; + resultsCount++; + } + } + gPokedexView->pokemonListCount = resultsCount; + + // Search by name + if (abcGroup != 0xFF) + { + for (i = 0, resultsCount = 0; i < gPokedexView->pokemonListCount; i++) + { + u8 r3; + + species = NationalPokedexNumToSpecies(gPokedexView->unk0[i].dexNum); + r3 = gSpeciesNames[species][0]; + if ((r3 >= gUnknown_083B57BC[abcGroup][0] && r3 < gUnknown_083B57BC[abcGroup][0] + gUnknown_083B57BC[abcGroup][1]) + || (r3 >= gUnknown_083B57BC[abcGroup][2] && r3 < gUnknown_083B57BC[abcGroup][2] + gUnknown_083B57BC[abcGroup][3])) + { + gPokedexView->unk0[resultsCount] = gPokedexView->unk0[i]; + resultsCount++; + } } + gPokedexView->pokemonListCount = resultsCount; + } + + // Search by body color + if (bodyColor != 0xFF) + { + for (i = 0, resultsCount = 0; i < gPokedexView->pokemonListCount; i++) + { + species = NationalPokedexNumToSpecies(gPokedexView->unk0[i].dexNum); + + if (bodyColor == gBaseStats[species].bodyColor) + { + gPokedexView->unk0[resultsCount] = gPokedexView->unk0[i]; + resultsCount++; + } + } + gPokedexView->pokemonListCount = resultsCount; + } + + // Search by type + if (type1 != 0xFF || type2 != 0xFF) + { + if (type1 == 0xFF) + { + type1 = type2; + type2 = 0xFF; + } + + if (type2 == 0xFF) + { + for (i = 0, resultsCount = 0; i < gPokedexView->pokemonListCount; i++) + { + if (gPokedexView->unk0[i].owned) + { + species = NationalPokedexNumToSpecies(gPokedexView->unk0[i].dexNum); + + types[0] = gBaseStats[species].type1; + types[1] = gBaseStats[species].type2; + if (types[0] == type1 || types[1] == type1) + { + gPokedexView->unk0[resultsCount] = gPokedexView->unk0[i]; + resultsCount++; + } + } + } + } + else + { + for (i = 0, resultsCount = 0; i < gPokedexView->pokemonListCount; i++) + { + if (gPokedexView->unk0[i].owned) + { + species = NationalPokedexNumToSpecies(gPokedexView->unk0[i].dexNum); + + types[0] = gBaseStats[species].type1; + types[1] = gBaseStats[species].type2; + if ((types[0] == type1 && types[1] == type2) || (types[0] == type2 && types[1] == type1)) + { + gPokedexView->unk0[resultsCount] = gPokedexView->unk0[i]; + resultsCount++; + } + } + } + } + gPokedexView->pokemonListCount = resultsCount; + } + + if (gPokedexView->pokemonListCount != 0) + { + for (i = gPokedexView->pokemonListCount; i < NATIONAL_DEX_COUNT; i++) + { + gPokedexView->unk0[i].dexNum = 0xFFFF; + gPokedexView->unk0[i].seen = FALSE; + gPokedexView->unk0[i].owned = FALSE; + + } + } + + return resultsCount; +} + +#if ENGLISH +#define SUB_8091E20_WIDTH (208) +#elif GERMAN +#define SUB_8091E20_WIDTH (216) +#endif + +void sub_8091E20(const u8 *str) +{ + sub_8072AB0(str, 9, 120, SUB_8091E20_WIDTH, 32, 1); +} + +u8 sub_8091E3C(void) +{ + return CreateTask(sub_8091E54, 0); +} + +static void sub_8091E54(u8 taskId) +{ + u16 i; + + switch (gMain.state) + { + default: + case 0: + if (!gPaletteFade.active) + { + gPokedexView->unk64A = 2; + sub_8091060(0); + LZ77UnCompVram(gPokedexMenuSearch_Gfx, (void *)VRAM); + LZ77UnCompVram(gUnknown_08E96D2C, (void *)(VRAM + 0x7800)); + LoadPalette(gPokedexMenuSearch_Pal + 1, 1, 0x7E); + if (!IsNationalPokedexEnabled()) + { + for (i = 0; i < 17; i++) + { + ((u16 *)(VRAM + 0x7A80))[i] = ((u16 *)(VRAM + 0x7B00))[i]; + ((u16 *)(VRAM + 0x7AC0))[i] = ((u16 *)(VRAM + 0x7B40))[i]; + ((u16 *)(VRAM + 0x7B00))[i] = 1; + ((u16 *)(VRAM + 0x7B40))[i] = 1; + } + } + gMain.state = 1; + } + break; + case 1: + SetUpWindowConfig(&gWindowConfig_81E7064); + InitMenuWindow(&gWindowConfig_81E7064); + LoadCompressedObjectPic(&gUnknown_083A05CC[0]); + LoadSpritePalettes(gUnknown_083A05DC); + sub_809308C(taskId); + for (i = 0; i < 16; i++) + gTasks[taskId].data[i] = 0; + sub_8092EB0(taskId); + sub_8092AB0(0); + sub_8092B68(taskId); + gMain.state++; + break; + case 2: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + gMain.state++; + break; + case 3: + REG_BG3CNT = 0x0F03; + REG_DISPCNT = 0x1C40; + gMain.state++; + break; + case 4: + if (!gPaletteFade.active) + { + gTasks[taskId].func = sub_809204C; + gMain.state = 0; + } + break; + } +} + +static void sub_809204C(u8 taskId) +{ + sub_8092AB0(gTasks[taskId].data[0]); + sub_8092B68(taskId); + gTasks[taskId].func = sub_809207C; +} + +static void sub_809207C(u8 taskId) +{ + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_PC_OFF); + gTasks[taskId].func = sub_80927B8; + return; + } + if (gMain.newKeys & A_BUTTON) + { + switch (gTasks[taskId].data[0]) + { + case 0: + PlaySE(SE_PIN); + gTasks[taskId].data[1] = 0; + gTasks[taskId].func = sub_809217C; + break; + case 1: + PlaySE(SE_PIN); + gTasks[taskId].data[1] = 4; + gTasks[taskId].func = sub_809217C; + break; case 2: - SetUpWindowConfig(&gWindowConfig_81E7064); - InitMenuWindow(&gWindowConfig_81E7064); - DmaClear16(3, (void *)(VRAM + 0xC000), 0x200); - gTasks[taskId].data[0]++; + PlaySE(SE_PC_OFF); + gTasks[taskId].func = sub_80927B8; break; - case 3: - sub_8072BD8(gDexText_RegisterComplete, 2, 0, 0xD0); - if(!IsNationalPokedex()) - sub_8091154(NationalToHoennOrder(dexNum), 13, 3); + } + return; + } + if ((gMain.newKeys & DPAD_LEFT) && gTasks[taskId].data[0] > 0) + { + PlaySE(SE_Z_PAGE); + gTasks[taskId].data[0]--; + sub_8092AB0(gTasks[taskId].data[0]); + } + if ((gMain.newKeys & DPAD_RIGHT) && gTasks[taskId].data[0] < 2) + { + PlaySE(SE_Z_PAGE); + gTasks[taskId].data[0]++; + sub_8092AB0(gTasks[taskId].data[0]); + } +} + +static void sub_809217C(u8 taskId) +{ + sub_8092AD4(gTasks[taskId].data[0], gTasks[taskId].data[1]); + sub_8092B68(taskId); + gTasks[taskId].func = sub_80921B0; +} + +static void sub_80921B0(u8 taskId) +{ + const u8 (*r6)[4]; + + if (gTasks[taskId].data[0] != 0) + { + if (!IsNationalPokedexEnabled()) + r6 = gUnknown_083B58A4; + else + r6 = gUnknown_083B586C; + } + else + { + if (!IsNationalPokedexEnabled()) + r6 = gUnknown_083B5888; + else + r6 = gUnknown_083B5850; + } + + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_BOWA); + sub_8092EB0(taskId); + gTasks[taskId].func = sub_809204C; + return; + } + if (gMain.newKeys & A_BUTTON) + { + if (gTasks[taskId].data[1] == 6) + { + if (gTasks[taskId].data[0] != 0) + { + gUnknown_0202FFBA = 0x40; + gPokedexView->unk62A = 0x40; + gUnknown_0202FFB8 = 0; + gPokedexView->unk610 = 0; + gSaveBlock2.pokedex.unknown1 = sub_8092E10(taskId, 5); + if (!IsNationalPokedexEnabled()) + gSaveBlock2.pokedex.unknown1 = 0; + gPokedexView->unk614 = gSaveBlock2.pokedex.unknown1; + gSaveBlock2.pokedex.order = sub_8092E10(taskId, 4); + gPokedexView->unk618 = gSaveBlock2.pokedex.order; + PlaySE(SE_PC_OFF); + gTasks[taskId].func = sub_80927B8; + } else - sub_8091154(dexNum, 13, 3); - sub_80911C8(dexNum, 16, 3); - MenuPrint(gDexText_UnknownPoke, 11, 5); - MenuPrint(gDexText_UnknownHeight, 16, 7); - MenuPrint(gDexText_UnknownWeight, 16, 9); - sub_8091304(&gPokedexEntries[dexNum], 11, 5); - sub_8091458(gPokedexEntries[dexNum].height, 16, 7); - sub_8091564(gPokedexEntries[dexNum].weight, 16, 9); - MenuPrint(gPokedexEntries[dexNum].descriptionPage1, 2, 13); - sub_80917CC(14, 0x3FC); - gTasks[taskId].data[0]++; - break; - case 4: + { + sub_8091E20(gDexText_Searching); + gTasks[taskId].func = sub_80923FC; + PlaySE(SE_Z_SEARCH); + } + } + else { - u8 spriteId = sub_80918EC(dexNum, 0x30, 0x38, 0); - - gSprites[spriteId].oam.priority = 0; - BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - SetVBlankCallback(gUnknown_03005CEC); - gTasks[taskId].data[3] = spriteId; - gTasks[taskId].data[0]++; - break; + PlaySE(SE_PIN); + gTasks[taskId].func = sub_80925CC; } - case 5: - REG_BLDCNT = 0; - REG_BLDALPHA = 0; - REG_BLDY = 0; - REG_BG3CNT = 0xF07; - REG_DISPCNT = 0x1C40; - gTasks[taskId].data[0]++; - break; - case 6: - if(!gPaletteFade.active) + return; + } + + if ((gMain.newKeys & DPAD_LEFT) && r6[gTasks[taskId].data[1]][0] != 0xFF) + { + PlaySE(SE_SELECT); + gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][0]; + sub_8092AD4(gTasks[taskId].data[0], gTasks[taskId].data[1]); + } + if ((gMain.newKeys & DPAD_RIGHT) && r6[gTasks[taskId].data[1]][1] != 0xFF) + { + PlaySE(SE_SELECT); + gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][1]; + sub_8092AD4(gTasks[taskId].data[0], gTasks[taskId].data[1]); + } + if ((gMain.newKeys & DPAD_UP) && r6[gTasks[taskId].data[1]][2] != 0xFF) + { + PlaySE(SE_SELECT); + gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][2]; + sub_8092AD4(gTasks[taskId].data[0], gTasks[taskId].data[1]); + } + if ((gMain.newKeys & DPAD_DOWN) && r6[gTasks[taskId].data[1]][3] != 0xFF) + { + PlaySE(SE_SELECT); + gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][3]; + sub_8092AD4(gTasks[taskId].data[0], gTasks[taskId].data[1]); + } +} + +static void sub_80923FC(u8 taskId) +{ + u8 r10 = sub_8092E10(taskId, 5); + u8 r9 = sub_8092E10(taskId, 4); + u8 r8 = sub_8092E10(taskId, 0); + u8 r6 = sub_8092E10(taskId, 1); + u8 r4 = sub_8092E10(taskId, 2); + u8 r0 = sub_8092E10(taskId, 3); + + sub_8091AF8(r10, r9, r8, r6, r4, r0); + gTasks[taskId].func = sub_80924A4; +} + +static void sub_80924A4(u8 taskId) +{ + if (!IsSEPlaying()) + { + if (gPokedexView->pokemonListCount != 0) + { + PlaySE(SE_SEIKAI); + sub_8091E20(gDexText_SearchComplete); + } + else + { + PlaySE(SE_HAZURE); + sub_8091E20(gDexText_NoMatching); + } + gTasks[taskId].func = sub_8092508; + } +} + +static void sub_8092508(u8 taskId) +{ + if (gMain.newKeys & A_BUTTON) + { + if (gPokedexView->pokemonListCount != 0) + { + gPokedexView->unk64F = 1; + gPokedexView->dexMode = sub_8092E10(taskId, 5); + gPokedexView->dexOrder = sub_8092E10(taskId, 4); + gTasks[taskId].func = sub_80927B8; + PlaySE(SE_PC_OFF); + } + else + { + gTasks[taskId].func = sub_809217C; + PlaySE(SE_BOWA); + } + } +} + +static void sub_80925B4(u16 a, int unused) +{ + sub_814AD7C(0x90, (a * 2 + 1) * 8); +} + +static void sub_80925CC(u8 taskId) +{ + u8 r0; + u16 *p1; + u16 *p2; + + sub_8092C8C(0); + r0 = gTasks[taskId].data[1]; + p1 = &gTasks[taskId].data[gUnknown_083B5A7C[r0].unk4]; + p2 = &gTasks[taskId].data[gUnknown_083B5A7C[r0].unk5]; + gTasks[taskId].data[14] = *p1; + gTasks[taskId].data[15] = *p2; + sub_8092D78(taskId); + CreateBlendedOutlineCursor(16, 0xFFFF, 12, 0x2D9F, 11); + sub_80925B4(*p1, 1); + gTasks[taskId].func = sub_8092644; +} + +static void sub_8092644(u8 taskId) +{ + u8 r1; + const struct UnknownStruct2 *r8; + u16 *p1; + u16 *p2; + u16 r2; + bool8 r3; + + r1 = gTasks[taskId].data[1]; + r8 = gUnknown_083B5A7C[r1].unk0; + p1 = &gTasks[taskId].data[gUnknown_083B5A7C[r1].unk4]; + p2 = &gTasks[taskId].data[gUnknown_083B5A7C[r1].unk5]; + r2 = gUnknown_083B5A7C[r1].unk6 - 1; + if (gMain.newKeys & A_BUTTON) + { + sub_814ADC8(); + PlaySE(SE_PIN); + MenuZeroFillWindowRect(18, 1, 28, 12); + sub_8092C8C(1); + gTasks[taskId].func = sub_809217C; + return; + } + if (gMain.newKeys & B_BUTTON) + { + sub_814ADC8(); + PlaySE(SE_BOWA); + MenuZeroFillWindowRect(18, 1, 28, 12); + sub_8092C8C(1); + *p1 = gTasks[taskId].data[14]; + *p2 = gTasks[taskId].data[15]; + gTasks[taskId].func = sub_809217C; + return; + } + r3 = FALSE; + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + if (*p1 != 0) + { + sub_80925B4(*p1, 0); + (*p1)--; + sub_80925B4(*p1, 1); + r3 = TRUE; + } + else if (*p2 != 0) + { + (*p2)--; + sub_8092D78(taskId); + sub_80925B4(*p1, 1); + r3 = TRUE; + } + if (r3) + { + PlaySE(SE_SELECT); + sub_8091E20(r8[*p1 + *p2].text1); + } + return; + } + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + if (*p1 < 5 && *p1 < r2) + { + sub_80925B4(*p1, 0); + (*p1)++; + sub_80925B4(*p1, 1); + r3 = TRUE; + } + else if (r2 > 5 && *p2 < r2 - 5) + { + (*p2)++; + sub_8092D78(taskId); + sub_80925B4(5, 1); + r3 = TRUE; + } + if (r3) + { + PlaySE(SE_SELECT); + sub_8091E20(r8[*p1 + *p2].text1); + } + return; + } +} + +static void sub_80927B8(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_80927F0; +} + +static void sub_80927F0(u8 taskId) +{ + if (!gPaletteFade.active) + DestroyTask(taskId); +} + +#ifdef NONMATCHING +void sub_8092810(u8 a, u8 b, u8 c, u8 d) +{ + u16 i; + + for (i = 0; i < d; i++) + { + ((u16 *)VRAM)[15 * 0x400 + c * 32 + i + b] &= 0xFFF; + ((u16 *)VRAM)[15 * 0x400 + c * 32 + i + b] |= a << 12; + + ((u16 *)VRAM)[15 * 0x400 + (c + 1) * 32 + i + b] &= 0xFFF; + ((u16 *)VRAM)[15 * 0x400 + (c + 1) * 32 + i + b] |= a << 12; + } +} +#else +__attribute__((naked)) +void sub_8092810(u8 a, u8 b, u8 c, u8 d) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + mov r12, r1\n\ + lsls r2, 24\n\ + lsrs r1, r2, 24\n\ + lsls r3, 24\n\ + lsrs r5, r3, 8\n\ + movs r3, 0\n\ + cmp r5, 0\n\ + beq _0809285A\n\ + lsls r7, r1, 6\n\ + ldr r6, _08092860 @ =0x00000fff\n\ + lsls r4, r0, 12\n\ +_08092830:\n\ + mov r0, r12\n\ + adds r1, r0, r3\n\ + lsls r1, 1\n\ + adds r1, r7, r1\n\ + ldr r0, _08092864 @ =0x06007800\n\ + adds r2, r1, r0\n\ + ldrh r0, [r2]\n\ + ands r0, r6\n\ + orrs r0, r4\n\ + strh r0, [r2]\n\ + ldr r0, _08092868 @ =0x06007840\n\ + adds r1, r0\n\ + ldrh r0, [r1]\n\ + ands r0, r6\n\ + orrs r0, r4\n\ + strh r0, [r1]\n\ + adds r0, r3, 0x1\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + cmp r0, r5\n\ + bcc _08092830\n\ +_0809285A:\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_08092860: .4byte 0x00000fff\n\ +_08092864: .4byte 0x06007800\n\ +_08092868: .4byte 0x06007840\n\ + .syntax divided\n"); +} +#endif + +static void sub_809286C(u8 a, u8 b, u8 c) +{ + u8 r5 = (b & 1) | ((c & 1) << 1); + + switch (a) + { + case 0: + case 1: + case 2: + sub_8092810(r5, gUnknown_083B57E4[a].unk4, gUnknown_083B57E4[a].unk5, gUnknown_083B57E4[a].unk6); + break; + case 3: + case 4: + case 7: + case 8: + sub_8092810(r5, gUnknown_083B57FC[a - 3].unk4, gUnknown_083B57FC[a - 3].unk5, gUnknown_083B57FC[a - 3].unk6); + // fall through + case 5: + case 6: + sub_8092810(r5, gUnknown_083B57FC[a - 3].unk7, gUnknown_083B57FC[a - 3].unk8, gUnknown_083B57FC[a - 3].unk9); + break; + case 10: + sub_8092810(r5, gUnknown_083B57FC[2].unk4, gUnknown_083B57FC[2].unk5, gUnknown_083B57FC[2].unk6); + break; + case 9: + if (!IsNationalPokedexEnabled()) + sub_8092810(r5, gUnknown_083B57FC[a - 3].unk4, gUnknown_083B57FC[a - 3].unk5 - 2, gUnknown_083B57FC[a - 3].unk6); + else + sub_8092810(r5, gUnknown_083B57FC[a - 3].unk4, gUnknown_083B57FC[a - 3].unk5, gUnknown_083B57FC[a - 3].unk6); + break; + } +} + +static void sub_8092964(u8 a) +{ + switch (a) + { + case 0: + sub_809286C(0, 0, 0); + sub_809286C(1, 1, 0); + sub_809286C(2, 1, 0); + sub_809286C(3, 1, 0); + sub_809286C(4, 1, 0); + sub_809286C(10, 1, 0); + sub_809286C(5, 1, 0); + sub_809286C(6, 1, 0); + sub_809286C(7, 1, 0); + sub_809286C(8, 1, 0); + sub_809286C(9, 1, 0); + break; + case 1: + sub_809286C(0, 1, 0); + sub_809286C(1, 0, 0); + sub_809286C(2, 1, 0); + sub_809286C(3, 1, 1); + sub_809286C(4, 1, 1); + sub_809286C(10, 1, 1); + sub_809286C(5, 1, 1); + sub_809286C(6, 1, 1); + sub_809286C(7, 1, 0); + sub_809286C(8, 1, 0); + sub_809286C(9, 1, 0); + break; + case 2: + sub_809286C(0, 1, 0); + sub_809286C(1, 1, 0); + sub_809286C(2, 0, 0); + sub_809286C(3, 1, 1); + sub_809286C(4, 1, 1); + sub_809286C(10, 1, 1); + sub_809286C(5, 1, 1); + sub_809286C(6, 1, 1); + sub_809286C(7, 1, 1); + sub_809286C(8, 1, 1); + sub_809286C(9, 1, 1); + break; + } +} + +static void sub_8092AB0(u8 a) +{ + sub_8092964(a); + sub_8091E20(gUnknown_083B57E4[a].text); +} + +static void sub_8092AD4(u8 a, u8 b) +{ + sub_8092964(a); + switch (b) + { + case 0: + sub_809286C(3, 0, 0); + break; + case 1: + sub_809286C(4, 0, 0); + break; + case 2: + sub_809286C(10, 0, 0); + sub_809286C(5, 0, 0); + break; + case 3: + sub_809286C(10, 0, 0); + sub_809286C(6, 0, 0); + break; + case 4: + sub_809286C(7, 0, 0); + break; + case 5: + sub_809286C(8, 0, 0); + break; + case 6: + sub_809286C(9, 0, 0); + break; + } + sub_8091E20(gUnknown_083B57FC[b].text); +} + +static void sub_8092B68(u8 taskId) +{ + u16 var; + + var = gTasks[taskId].data[6] + gTasks[taskId].data[7]; + StringCopy(gStringVar1, gUnknown_083B5910[var].text2); + MenuPrint_PixelCoords(gUnknown_083B5AB2, 45, 16, 1); + + var = gTasks[taskId].data[8] + gTasks[taskId].data[9]; + StringCopy(gStringVar1, gUnknown_083B5968[var].text2); + MenuPrint_PixelCoords(gUnknown_083B5AB2, 45, 32, 1); + + var = gTasks[taskId].data[10] + gTasks[taskId].data[11]; + StringCopy(gStringVar1, gUnknown_083B59C8[var].text2); + MenuPrint_PixelCoords(gUnknown_083B5AAC, 45, 48, 1); + + var = gTasks[taskId].data[12] + gTasks[taskId].data[13]; + StringCopy(gStringVar1, gUnknown_083B59C8[var].text2); + MenuPrint_PixelCoords(gUnknown_083B5AAC, 93, 48, 1); + + var = gTasks[taskId].data[4] + gTasks[taskId].data[5]; + StringCopy(gStringVar1, gUnknown_083B58D8[var].text2); + MenuPrint_PixelCoords(gUnknown_083B5AB2, 45, 64, 1); + + if (IsNationalPokedexEnabled()) + { + var = gTasks[taskId].data[2] + gTasks[taskId].data[3]; + StringCopy(gStringVar1, gUnknown_083B58C0[var].text2); + MenuPrint_PixelCoords(gUnknown_083B5AB2, 45, 80, 1); + } +} + +static void sub_8092C8C(u8 a) +{ + u16 i; + u16 j; + + if (a == 0) + { + *((u16 *)(VRAM + 0x7800 + 0x22)) = 0xC0B; + for (i = 0x12; i < 0x1D; i++) + *((u16 *)(VRAM + 0x7800 + i * 2)) = 0x80D; + *((u16 *)(VRAM + 0x7800 + 0x3A)) = 0x80B; + for (j = 1; j < 13; j++) + { + *((u16 *)(VRAM + 0x7800 + 0x22 + j * 64)) = 0x40A; + for (i = 0x12; i < 0x1D; i++) + *((u16 *)(VRAM + 0x7800 + j * 64 + i * 2)) = 2; + *((u16 *)(VRAM + 0x7800 + 0x3A + j * 64)) = 0xA; + } + *((u16 *)(VRAM + 0x7800 + 0x362)) = 0x40B; + for (i = 0x12; i < 0x1D; i++) + *((u16 *)(VRAM + 0x7800 + 0x340 + i * 2)) = 0xD; + *((u16 *)(VRAM + 0x7800 + 0x37A)) = 0xB; + } + else + { + for (j = 0; j < 14; j++) + { + for (i = 0x11; i < 0x1E; i++) { - PlayCry1(NationalPokedexNumToSpecies(dexNum), 0); - gTasks[taskId].data[2] = 0; - gTasks[taskId].data[4] = 0; - gTasks[taskId].func = sub_8090A3C; + *((u16 *)(VRAM + 0x7800 + j * 64 + i * 2)) = 0x4F; } - break; + } + } +} + +static void sub_8092D78(u8 taskId) +{ + const struct UnknownStruct2 *r6 = gUnknown_083B5A7C[gTasks[taskId].data[1]].unk0; + const u16 *r8 = &gTasks[taskId].data[gUnknown_083B5A7C[gTasks[taskId].data[1]].unk4]; + const u16 *r7 = &gTasks[taskId].data[gUnknown_083B5A7C[gTasks[taskId].data[1]].unk5]; + u16 i; + u16 j; + + MenuZeroFillWindowRect(18, 1, 28, 12); + for (i = 0, j = *r7; i < 6 && r6[j].text2 != NULL; i++, j++) + { +#ifndef NONMATCHING + j += 0; // Useless statement needed to match +#endif + MenuPrint(r6[j].text2, 18, i * 2 + 1); + } + sub_8091E20(r6[*r8 + *r7].text1); +} + +static u8 sub_8092E10(u8 taskId, u8 b) +{ + const u16 *ptr1 = &gTasks[taskId].data[gUnknown_083B5A7C[b].unk4]; + const u16 *ptr2 = &gTasks[taskId].data[gUnknown_083B5A7C[b].unk5]; + u16 r2 = *ptr1 + *ptr2; + + switch (b) + { + default: + return 0; + case 5: + return gUnknown_083B5A60[r2]; + case 4: + return gUnknown_083B5A62[r2]; + case 0: + if (r2 == 0) + return 0xFF; + else + return r2; + case 1: + if (r2 == 0) + return 0xFF; + else + return r2 - 1; + case 2: + case 3: + return gUnknown_083B5A68[r2]; } } -*/
\ No newline at end of file + +static void sub_8092EB0(u8 taskId) +{ + u16 r3; + + switch (gPokedexView->unk614) + { + default: + case 0: + r3 = 0; + break; + case 1: + r3 = 1; + break; + } + gTasks[taskId].data[2] = r3; + + switch (gPokedexView->unk618) + { + default: + case 0: + r3 = 0; + break; + case 1: + r3 = 1; + break; + case 2: + r3 = 2; + break; + case 3: + r3 = 3; + break; + case 4: + r3 = 4; + break; + case 5: + r3 = 5; + break; + } + gTasks[taskId].data[4] = r3; +} + +static bool8 sub_8092F44(u8 taskId) +{ + u8 val1 = gTasks[taskId].data[1]; + const u16 *ptr = &gTasks[taskId].data[gUnknown_083B5A7C[val1].unk5]; + u16 val2 = gUnknown_083B5A7C[val1].unk6 - 1; + + if (val2 > 5 && *ptr != 0) + return FALSE; + else + return TRUE; +} + +static bool8 sub_8092F8C(u8 taskId) +{ + u8 val1 = gTasks[taskId].data[1]; + const u16 *ptr = &gTasks[taskId].data[gUnknown_083B5A7C[val1].unk5]; + u16 val2 = gUnknown_083B5A7C[val1].unk6 - 1; + + if (val2 > 5 && *ptr < val2 - 5) + return FALSE; + else + return TRUE; +} + +static void sub_8092FD8(struct Sprite *sprite) +{ + if (gTasks[sprite->data0].func == sub_8092644) + { + u8 val; + + if (sprite->data1 != 0) + { + if (sub_8092F8C(sprite->data0)) + sprite->invisible = TRUE; + else + sprite->invisible = FALSE; + } + else + { + if (sub_8092F44(sprite->data0)) + sprite->invisible = TRUE; + else + sprite->invisible = FALSE; + } + val = sprite->data2 + sprite->data1 * 128; + sprite->pos2.y = gSineTable[val] / 128; + sprite->data2 += 8; + } + else + { + sprite->invisible = TRUE; + } +} + +static void sub_809308C(u8 taskId) +{ + u8 spriteId; + + spriteId = CreateSprite(&gSpriteTemplate_83A053C, 184, 4, 0); + gSprites[spriteId].data0 = taskId; + gSprites[spriteId].data1 = 0; + gSprites[spriteId].callback = sub_8092FD8; + + spriteId = CreateSprite(&gSpriteTemplate_83A053C, 184, 108, 0); + gSprites[spriteId].data0 = taskId; + gSprites[spriteId].data1 = 1; + gSprites[spriteId].vFlip = TRUE; + gSprites[spriteId].callback = sub_8092FD8; +} diff --git a/src/pokedex_cry_screen.c b/src/pokedex_cry_screen.c new file mode 100644 index 000000000..92fd832fc --- /dev/null +++ b/src/pokedex_cry_screen.c @@ -0,0 +1,85 @@ +#include "global.h" +#include "pokedex_cry_screen.h" +#include "palette.h" +#include "sprite.h" + +struct Unk201C800 { + u8 unk_0; + u8 unk_1; + u8 unk_2; + u8 filler_3; + u16 unk_4; +}; + +#define EWRAM_1C800 (*(struct Unk201C800 *)(unk_201C000 + 0x800)) + +extern u8 unk_201C000[]; + +extern u8 gUnknown_03005E98; + +// data/pokedex_cry_screen.o +extern const u16 gUnknown_083FAE7C[]; +extern const u16 gUnknown_083FAF1C[]; +extern const u8 gUnknown_083FAF3C[]; +extern struct SpriteTemplate gSpriteTemplate_83FB774; +extern const struct SpriteSheet gCryMeterNeedleSpriteSheets[]; +extern const struct SpritePalette gCryMeterNeedleSpritePalettes[]; + +#if ENGLISH +#define CRY_METER_MAP_WIDTH 10 +#elif GERMAN +#define CRY_METER_MAP_WIDTH 32 +#endif + +u8 ShowPokedexCryScreen(struct CryRelatedStruct *cry, u8 arg1) { + int returnVal = FALSE; + + switch (gUnknown_03005E98) + { + case 0: + LZ77UnCompVram(gUnknown_083FAF3C, (void *) (VRAM + cry->unk0)); + LoadPalette(&gUnknown_083FAF1C, cry->paletteNo * 16, 0x20); + gUnknown_03005E98 += 1; + break; + + case 1: + { + void *vram; + u8 row, col; + u32 r12; + int x, y; + + vram = (void *) BG_SCREEN_ADDR(cry->unk2); + + r12 = (u32) (cry->unk0 << 18) >> 23; + + for (row = 0; row < 8; row++) + { + for (col = 0; col < 10; col++) + { + y = row + cry->yPos; + x = col + cry->xPos; + *(u16 *) (vram + (y * 64 + x * 2)) = (gUnknown_083FAE7C[row * CRY_METER_MAP_WIDTH + col] | (cry->paletteNo << 12)) + r12; + } + } + + gUnknown_03005E98 += 1; + break; + } + + case 2: + { + LoadSpriteSheets(gCryMeterNeedleSpriteSheets); + LoadSpritePalettes(gCryMeterNeedleSpritePalettes); + EWRAM_1C800.unk_4 = CreateSprite(&gSpriteTemplate_83FB774, 40 + cry->xPos * 8, 56 + cry->yPos * 8, 1); + EWRAM_1C800.unk_0 = 0x20; + EWRAM_1C800.unk_1 = 0x20; + EWRAM_1C800.unk_2 = 0; + + returnVal = TRUE; + break; + } + } + + return returnVal; +} diff --git a/src/pokemon_1.c b/src/pokemon_1.c index 7ee413a18..c55105ef3 100644 --- a/src/pokemon_1.c +++ b/src/pokemon_1.c @@ -1,13 +1,14 @@ #include "global.h" -#include "asm.h" -#include "text.h" -#include "string_util.h" +#include "data2.h" +#include "items.h" +#include "main.h" #include "pokemon.h" +#include "rng.h" #include "rom4.h" #include "species.h" -#include "main.h" -#include "rng.h" #include "sprite.h" +#include "string_util.h" +#include "text.h" //Extracts the upper 16 bits of a 32-bit number #define HIHALF(n) (((n) & 0xFFFF0000) >> 16) @@ -15,18 +16,10 @@ //Extracts the lower 16 bits of a 32-bit number #define LOHALF(n) ((n) & 0xFFFF) -extern struct Pokemon gPlayerParty[6]; // 0x3004360 -extern struct Pokemon gEnemyParty[6]; // 0x30045C0 - extern u8 unk_2000000[]; extern u16 word_2024E82; extern u8 byte_2024E88; -extern u32 gExperienceTables[8][101]; -extern struct BaseStats gBaseStats[]; -extern struct BattleMove gBattleMoves[]; -extern const u16 *gLevelUpLearnsets[]; - void ZeroBoxMonData(struct BoxPokemon *boxMon) { u8 *raw = (u8 *)boxMon; @@ -50,7 +43,7 @@ void ZeroMonData(struct Pokemon *mon) SetMonData(mon, MON_DATA_SPATK, (u8 *)&arg); SetMonData(mon, MON_DATA_SPDEF, (u8 *)&arg); arg = 255; - SetMonData(mon, MON_DATA_64, (u8 *)&arg); + SetMonData(mon, MON_DATA_MAIL, (u8 *)&arg); } void ZeroPlayerPartyMons(void) @@ -74,7 +67,7 @@ void CreateMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFix CreateBoxMon(&mon->box, species, level, fixedIV, hasFixedPersonality, fixedPersonality, otIdType, fixedOtId); SetMonData(mon, MON_DATA_LEVEL, &level); arg = 255; - SetMonData(mon, MON_DATA_64, (u8 *)&arg); + SetMonData(mon, MON_DATA_MAIL, (u8 *)&arg); CalculateMonStats(mon); } @@ -302,9 +295,9 @@ void sub_803ADE8(struct Pokemon *mon, struct UnknownPokemonStruct *src) StringCopy(nickname, src->nickname); if (nickname[0] == 0xFC && nickname[1] == 0x15) - language = 1; + language = LANGUAGE_JAPANESE; else - language = 2; + language = GAME_LANGUAGE; SetMonData(mon, MON_DATA_LANGUAGE, &language); StripExtCtrlCodes(nickname); @@ -341,7 +334,7 @@ void sub_803AF78(struct Pokemon *mon, struct UnknownPokemonStruct *dest) dest->species = GetMonData(mon, MON_DATA_SPECIES, NULL); heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); - if (heldItem == 175) + if (heldItem == ITEM_ENIGMA_BERRY) heldItem = 0; dest->heldItem = heldItem; @@ -477,7 +470,7 @@ void sub_803B4B4(struct Pokemon *src, struct Pokemon *dest) SetMonData(dest, MON_DATA_HP, (u8 *)&value); SetMonData(dest, MON_DATA_MAX_HP, (u8 *)&value); value = 255; - SetMonData(dest, MON_DATA_64, (u8 *)&value); + SetMonData(dest, MON_DATA_MAIL, (u8 *)&value); CalculateMonStats(dest); } diff --git a/src/pokemon_2.c b/src/pokemon_2.c index aeffb29a0..5acdae4d3 100644 --- a/src/pokemon_2.c +++ b/src/pokemon_2.c @@ -1,32 +1,34 @@ #include "global.h" -#include "asm.h" -#include "text.h" -#include "string_util.h" +#include "battle.h" +#include "data2.h" +#include "event_data.h" +#include "main.h" #include "pokemon.h" #include "rng.h" +#include "rom_8077ABC.h" #include "species.h" -#include "main.h" #include "sprite.h" -#include "flag.h" +#include "string_util.h" +#include "strings2.h" +#include "text.h" +#include "util.h" extern u8 gPlayerPartyCount; -extern struct Pokemon gPlayerParty[6]; extern u8 gEnemyPartyCount; -extern struct Pokemon gEnemyParty[6]; extern u16 unk_20160BC[]; extern struct SecretBaseRecord gSecretBaseRecord; extern u32 dword_2017100[]; -extern u16 gUnknown_020239F8; -extern u8 gUnknown_02024A60; +extern u16 gBattleTypeFlags; +extern u8 gActiveBank; extern struct BattlePokemon gBattleMons[4]; -extern u16 gUnknown_02024BE6; -extern u8 byte_2024C06; -extern u8 gUnknown_02024C07; -extern u8 gUnknown_02024C08; -extern u8 gUnknown_02024C0C; +extern u16 gCurrentMove; +extern u8 gLastUsedAbility; +extern u8 gBankAttacker; +extern u8 gBankTarget; +extern u8 gAbsentBankFlags; extern u8 gXXX_CritRelated; -extern u16 word_2024DB8; +extern u16 gBattleWeather; extern struct BattleEnigmaBerry gEnigmaBerries[]; extern u16 gBattleMovePower; extern struct SpriteTemplate gUnknown_02024E8C; @@ -34,24 +36,12 @@ extern u16 gTrainerBattleOpponent; extern struct PokemonStorage gPokemonStorage; extern u8 gBadEggNickname[]; -extern u8 gEggNickname[]; -extern u32 gBitTable[]; -extern struct BaseStats gBaseStats[]; -extern u8 gSpeciesNames[][11]; -extern struct BattleMove gBattleMoves[]; -extern struct SpriteTemplate gSpriteTemplate_8208288[]; -extern union AmimCmd *gSpriteAnimTable_81E7C64[]; -extern union AnimCmd **gUnknown_081EC2A4[]; -extern union AnimCmd **gUnknown_081ECACC[]; -extern u8 gTrainerClassToPicIndex[]; -extern u8 gTrainerClassToNameIndex[]; +extern const struct SpriteTemplate gSpriteTemplate_8208288[]; +//array of pointers to arrays of pointers to union AnimCmd (We probably need to typedef this.) extern u8 gSecretBaseTrainerClasses[]; -extern u8 gUnknown_08208238[]; -extern u8 gUnknown_0820823C[]; -extern u8 gStatStageRatios[][2]; extern u8 gHoldEffectToType[][2]; -u8 sub_803C348(u8 a1) +u8 CountAliveMons(u8 a1) { s32 i; u8 retVal = 0; @@ -61,21 +51,21 @@ u8 sub_803C348(u8 a1) case 0: for (i = 0; i < 4; i++) { - if (i != gUnknown_02024A60 && !(gUnknown_02024C0C & gBitTable[i])) + if (i != gActiveBank && !(gAbsentBankFlags & gBitTable[i])) retVal++; } break; case 1: for (i = 0; i < 4; i++) { - if (battle_side_get_owner(i) == battle_side_get_owner(gUnknown_02024C07) && !(gUnknown_02024C0C & gBitTable[i])) + if (GetBankSide(i) == GetBankSide(gBankAttacker) && !(gAbsentBankFlags & gBitTable[i])) retVal++; } break; case 2: for (i = 0; i < 4; i++) { - if (battle_side_get_owner(i) == battle_side_get_owner(gUnknown_02024C08) && !(gUnknown_02024C0C & gBitTable[i])) + if (GetBankSide(i) == GetBankSide(gBankTarget) && !(gAbsentBankFlags & gBitTable[i])) retVal++; } break; @@ -87,7 +77,7 @@ u8 sub_803C348(u8 a1) #ifdef NONMATCHING u8 sub_803C434(u8 a1) { - u32 status0 = battle_get_per_side_status(a1); + u32 status0 = GetBankIdentity(a1); register u8 status_ asm("r4"); u8 status; register u32 mask1 asm("r1") = 1; @@ -98,16 +88,16 @@ u8 sub_803C434(u8 a1) status = status_ ^ mask1; { - register u16 val_ asm("r1") = gUnknown_020239F8; + register u16 val_ asm("r1") = gBattleTypeFlags; u32 val = mask2; val &= val_; if (!val) { - return battle_get_side_with_given_state(status); + return GetBankByPlayerAI(status); } } - if (sub_803C348(0) > 1) + if (CountAliveMons(0) > 1) { u16 r = Random(); register u32 val asm("r1") = mask2; @@ -116,89 +106,90 @@ u8 sub_803C434(u8 a1) { u32 status2 = 2; status2 ^= status; - return battle_get_side_with_given_state(status2); + return GetBankByPlayerAI(status2); } else { - return battle_get_side_with_given_state(status); + return GetBankByPlayerAI(status); } } else { - if (gUnknown_02024C0C & gBitTable[status]) - return battle_get_side_with_given_state(status ^ 2); + if (gAbsentBankFlags & gBitTable[status]) + return GetBankByPlayerAI(status ^ 2); else - return battle_get_side_with_given_state(status); + return GetBankByPlayerAI(status); } } #else __attribute__((naked)) -u8 sub_803C434(u8 a1) { +u8 sub_803C434(u8 a1) +{ asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - bl battle_get_per_side_status\n\ - movs r1, 0x1\n\ - movs r6, 0x1\n\ - adds r4, r6, 0\n\ - ands r4, r0\n\ - eors r4, r1\n\ - adds r5, r4, 0\n\ - ldr r0, _0803C45C\n\ - ldrh r1, [r0]\n\ - adds r0, r6, 0\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - bne _0803C460\n\ - adds r0, r4, 0\n\ - b _0803C4AA\n\ - .align 2, 0\n\ -_0803C45C: .4byte gUnknown_020239F8\n\ + push {r4-r6,lr}\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + bl GetBankIdentity\n\ + movs r1, 0x1\n\ + movs r6, 0x1\n\ + adds r4, r6, 0\n\ + ands r4, r0\n\ + eors r4, r1\n\ + adds r5, r4, 0\n\ + ldr r0, _0803C45C\n\ + ldrh r1, [r0]\n\ + adds r0, r6, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0803C460\n\ + adds r0, r4, 0\n\ + b _0803C4AA\n\ + .align 2, 0\n\ +_0803C45C: .4byte gBattleTypeFlags\n\ _0803C460:\n\ - movs r0, 0\n\ - bl sub_803C348\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x1\n\ - bls _0803C484\n\ - bl Random\n\ - adds r1, r6, 0\n\ - ands r1, r0\n\ - cmp r1, 0\n\ - bne _0803C480\n\ - movs r0, 0x2\n\ - eors r0, r4\n\ - b _0803C4AA\n\ + movs r0, 0\n\ + bl CountAliveMons\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + bls _0803C484\n\ + bl Random\n\ + adds r1, r6, 0\n\ + ands r1, r0\n\ + cmp r1, 0\n\ + bne _0803C480\n\ + movs r0, 0x2\n\ + eors r0, r4\n\ + b _0803C4AA\n\ _0803C480:\n\ - adds r0, r4, 0\n\ - b _0803C4AA\n\ + adds r0, r4, 0\n\ + b _0803C4AA\n\ _0803C484:\n\ - ldr r0, _0803C49C\n\ - ldrb r1, [r0]\n\ - ldr r2, _0803C4A0\n\ - lsls r0, r4, 2\n\ - adds r0, r2\n\ - ldr r0, [r0]\n\ - ands r1, r0\n\ - cmp r1, 0\n\ - bne _0803C4A4\n\ - adds r0, r4, 0\n\ - b _0803C4AA\n\ - .align 2, 0\n\ -_0803C49C: .4byte gUnknown_02024C0C\n\ + ldr r0, _0803C49C\n\ + ldrb r1, [r0]\n\ + ldr r2, _0803C4A0\n\ + lsls r0, r4, 2\n\ + adds r0, r2\n\ + ldr r0, [r0]\n\ + ands r1, r0\n\ + cmp r1, 0\n\ + bne _0803C4A4\n\ + adds r0, r4, 0\n\ + b _0803C4AA\n\ + .align 2, 0\n\ +_0803C49C: .4byte gAbsentBankFlags\n\ _0803C4A0: .4byte gBitTable\n\ _0803C4A4:\n\ - movs r0, 0x2\n\ - eors r5, r0\n\ - adds r0, r5, 0\n\ + movs r0, 0x2\n\ + eors r5, r0\n\ + adds r0, r5, 0\n\ _0803C4AA:\n\ - bl battle_get_side_with_given_state\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - pop {r4-r6}\n\ - pop {r1}\n\ - bx r1\n\ + bl GetBankByPlayerAI\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + pop {r4-r6}\n\ + pop {r1}\n\ + bx r1\n\ .syntax divided\n"); } #endif @@ -247,7 +238,7 @@ void GetMonSpriteTemplate_803C56C(u16 species, u8 a2) { gUnknown_02024E8C = gSpriteTemplate_8208288[a2]; gUnknown_02024E8C.paletteTag = species; - gUnknown_02024E8C.anims = (union AnimCmd **)gSpriteAnimTable_81E7C64; + gUnknown_02024E8C.anims = (const union AnimCmd *const *)gSpriteAnimTable_81E7C64; //Why do I have to cast this? } void GetMonSpriteTemplate_803C5A0(u16 species, u8 a2) @@ -381,8 +372,8 @@ u32 GetMonData(struct Pokemon *mon, s32 field, u8 *data) return mon->spAttack; case MON_DATA_SPDEF: return mon->spDefense; - case MON_DATA_64: - return mon->pokerus; + case MON_DATA_MAIL: + return mon->mail; default: return GetBoxMonData(&mon->box, field, data); } @@ -415,307 +406,307 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) switch (field) { - case MON_DATA_PERSONALITY: - retVal = boxMon->personality; - break; - case MON_DATA_OT_ID: - retVal = boxMon->otId; - break; - case MON_DATA_NICKNAME: + case MON_DATA_PERSONALITY: + retVal = boxMon->personality; + break; + case MON_DATA_OT_ID: + retVal = boxMon->otId; + break; + case MON_DATA_NICKNAME: + { + if (boxMon->isBadEgg) { - if (boxMon->isBadEgg) - { - StringCopy(data, gBadEggNickname); - retVal = StringLength(data); - } - else if (boxMon->isEgg) - { - StringCopy(data, gEggNickname); - retVal = StringLength(data); - } - else - { - retVal = 0; - - while (retVal < POKEMON_NAME_LENGTH && boxMon->nickname[retVal] != EOS) - { - data[retVal] = boxMon->nickname[retVal]; - retVal++; - } - - data[retVal] = EOS; - ConvertInternationalString(data, boxMon->language); - retVal = StringLength(data); - } - break; + StringCopy(data, gBadEggNickname); + retVal = StringLength(data); } - case MON_DATA_LANGUAGE: - retVal = boxMon->language; - break; - case MON_DATA_SANITY_BIT1: - retVal = boxMon->isBadEgg; - break; - case MON_DATA_SANITY_BIT2: - retVal = boxMon->hasSpecies; - break; - case MON_DATA_SANITY_BIT3: - retVal = boxMon->isEgg; - break; - case MON_DATA_OT_NAME: + else if (boxMon->isEgg) + { + StringCopy(data, gEggNickname); + retVal = StringLength(data); + } + else { retVal = 0; - while (retVal < OT_NAME_LENGTH && boxMon->otName[retVal] != EOS) + while (retVal < POKEMON_NAME_LENGTH && boxMon->nickname[retVal] != EOS) { - data[retVal] = boxMon->otName[retVal]; + data[retVal] = boxMon->nickname[retVal]; retVal++; } data[retVal] = EOS; - break; + ConvertInternationalString(data, boxMon->language); + retVal = StringLength(data); } - case MON_DATA_MARKINGS: - retVal = boxMon->markings; - break; - case MON_DATA_CHECKSUM: - retVal = boxMon->checksum; - break; - case MON_DATA_10: - retVal = boxMon->unknown; - break; - case MON_DATA_SPECIES: - retVal = boxMon->isBadEgg ? 412 : substruct0->species; - break; - case MON_DATA_HELD_ITEM: - retVal = substruct0->heldItem; - break; - case MON_DATA_EXP: - retVal = substruct0->experience; - break; - case MON_DATA_PP_BONUSES: - retVal = substruct0->ppBonuses; - break; - case MON_DATA_FRIENDSHIP: - retVal = substruct0->friendship; - break; - case MON_DATA_MOVE1: - case MON_DATA_MOVE2: - case MON_DATA_MOVE3: - case MON_DATA_MOVE4: - retVal = substruct1->moves[field - MON_DATA_MOVE1]; - break; - case MON_DATA_PP1: - case MON_DATA_PP2: - case MON_DATA_PP3: - case MON_DATA_PP4: - retVal = substruct1->pp[field - MON_DATA_PP1]; - break; - case MON_DATA_HP_EV: - retVal = substruct2->hpEV; - break; - case MON_DATA_ATK_EV: - retVal = substruct2->attackEV; - break; - case MON_DATA_DEF_EV: - retVal = substruct2->defenseEV; - break; - case MON_DATA_SPD_EV: - retVal = substruct2->speedEV; - break; - case MON_DATA_SPATK_EV: - retVal = substruct2->spAttackEV; - break; - case MON_DATA_SPDEF_EV: - retVal = substruct2->spDefenseEV; - break; - case MON_DATA_COOL: - retVal = substruct2->cool; - break; - case MON_DATA_BEAUTY: - retVal = substruct2->beauty; - break; - case MON_DATA_CUTE: - retVal = substruct2->cute; - break; - case MON_DATA_SMART: - retVal = substruct2->smart; - break; - case MON_DATA_TOUGH: - retVal = substruct2->tough; - break; - case MON_DATA_SHEEN: - retVal = substruct2->sheen; - break; - case MON_DATA_POKERUS: - retVal = substruct3->pokerus; - break; - case MON_DATA_MET_LOCATION: - retVal = substruct3->metLocation; - break; - case MON_DATA_MET_LEVEL: - retVal = substruct3->metLevel; - break; - case MON_DATA_MET_GAME: - retVal = substruct3->metGame; - break; - case MON_DATA_POKEBALL: - retVal = substruct3->pokeball; - break; - case MON_DATA_OT_GENDER: - retVal = substruct3->otGender; - break; - case MON_DATA_HP_IV: - retVal = substruct3->hpIV; - break; - case MON_DATA_ATK_IV: - retVal = substruct3->attackIV; - break; - case MON_DATA_DEF_IV: - retVal = substruct3->defenseIV; - break; - case MON_DATA_SPD_IV: - retVal = substruct3->speedIV; - break; - case MON_DATA_SPATK_IV: - retVal = substruct3->spAttackIV; - break; - case MON_DATA_SPDEF_IV: - retVal = substruct3->spDefenseIV; - break; - case MON_DATA_IS_EGG: - retVal = substruct3->isEgg; - break; - case MON_DATA_ALT_ABILITY: - retVal = substruct3->altAbility; - break; - case MON_DATA_COOL_RIBBON: - retVal = substruct3->coolRibbon; - break; - case MON_DATA_BEAUTY_RIBBON: - retVal = substruct3->beautyRibbon; - break; - case MON_DATA_CUTE_RIBBON: - retVal = substruct3->cuteRibbon; - break; - case MON_DATA_SMART_RIBBON: - retVal = substruct3->smartRibbon; - break; - case MON_DATA_TOUGH_RIBBON: - retVal = substruct3->toughRibbon; - break; - case MON_DATA_CHAMPION_RIBBON: - retVal = substruct3->championRibbon; - break; - case MON_DATA_WINNING_RIBBON: - retVal = substruct3->winningRibbon; - break; - case MON_DATA_VICTORY_RIBBON: - retVal = substruct3->victoryRibbon; - break; - case MON_DATA_ARTIST_RIBBON: - retVal = substruct3->artistRibbon; - break; - case MON_DATA_EFFORT_RIBBON: - retVal = substruct3->effortRibbon; - break; - case MON_DATA_GIFT_RIBBON_1: - retVal = substruct3->giftRibbon1; - break; - case MON_DATA_GIFT_RIBBON_2: - retVal = substruct3->giftRibbon2; - break; - case MON_DATA_GIFT_RIBBON_3: - retVal = substruct3->giftRibbon3; - break; - case MON_DATA_GIFT_RIBBON_4: - retVal = substruct3->giftRibbon4; - break; - case MON_DATA_GIFT_RIBBON_5: - retVal = substruct3->giftRibbon5; - break; - case MON_DATA_GIFT_RIBBON_6: - retVal = substruct3->giftRibbon6; - break; - case MON_DATA_GIFT_RIBBON_7: - retVal = substruct3->giftRibbon7; - break; - case MON_DATA_FATEFUL_ENCOUNTER: - retVal = substruct3->fatefulEncounter; - break; - case MON_DATA_SPECIES2: - retVal = substruct0->species; - if (substruct0->species && (substruct3->isEgg || boxMon->isBadEgg)) - retVal = 412; - break; - case MON_DATA_IVS: - retVal = substruct3->hpIV | (substruct3->attackIV << 5) | (substruct3->defenseIV << 10) | (substruct3->speedIV << 15) | (substruct3->spAttackIV << 20) | (substruct3->spDefenseIV << 25); - break; - case MON_DATA_KNOWN_MOVES: - if (substruct0->species && !substruct3->isEgg) - { - u16 *moves = (u16 *)data; - s32 i = 0; - - while (moves[i] != 355) - { - u16 move = moves[i]; - if (substruct1->moves[0] == move - || substruct1->moves[1] == move - || substruct1->moves[2] == move - || substruct1->moves[3] == move) - retVal |= gBitTable[i]; - i++; - } - } - break; - case MON_DATA_RIBBON_COUNT: - retVal = 0; - if (substruct0->species && !substruct3->isEgg) - { - retVal += substruct3->coolRibbon; - retVal += substruct3->beautyRibbon; - retVal += substruct3->cuteRibbon; - retVal += substruct3->smartRibbon; - retVal += substruct3->toughRibbon; - retVal += substruct3->championRibbon; - retVal += substruct3->winningRibbon; - retVal += substruct3->victoryRibbon; - retVal += substruct3->artistRibbon; - retVal += substruct3->effortRibbon; - retVal += substruct3->giftRibbon1; - retVal += substruct3->giftRibbon2; - retVal += substruct3->giftRibbon3; - retVal += substruct3->giftRibbon4; - retVal += substruct3->giftRibbon5; - retVal += substruct3->giftRibbon6; - retVal += substruct3->giftRibbon7; - } - break; - case MON_DATA_RIBBONS: - retVal = 0; - if (substruct0->species && !substruct3->isEgg) + break; + } + case MON_DATA_LANGUAGE: + retVal = boxMon->language; + break; + case MON_DATA_SANITY_BIT1: + retVal = boxMon->isBadEgg; + break; + case MON_DATA_SANITY_BIT2: + retVal = boxMon->hasSpecies; + break; + case MON_DATA_SANITY_BIT3: + retVal = boxMon->isEgg; + break; + case MON_DATA_OT_NAME: + { + retVal = 0; + + while (retVal < OT_NAME_LENGTH && boxMon->otName[retVal] != EOS) + { + data[retVal] = boxMon->otName[retVal]; + retVal++; + } + + data[retVal] = EOS; + break; + } + case MON_DATA_MARKINGS: + retVal = boxMon->markings; + break; + case MON_DATA_CHECKSUM: + retVal = boxMon->checksum; + break; + case MON_DATA_10: + retVal = boxMon->unknown; + break; + case MON_DATA_SPECIES: + retVal = boxMon->isBadEgg ? SPECIES_EGG : substruct0->species; + break; + case MON_DATA_HELD_ITEM: + retVal = substruct0->heldItem; + break; + case MON_DATA_EXP: + retVal = substruct0->experience; + break; + case MON_DATA_PP_BONUSES: + retVal = substruct0->ppBonuses; + break; + case MON_DATA_FRIENDSHIP: + retVal = substruct0->friendship; + break; + case MON_DATA_MOVE1: + case MON_DATA_MOVE2: + case MON_DATA_MOVE3: + case MON_DATA_MOVE4: + retVal = substruct1->moves[field - MON_DATA_MOVE1]; + break; + case MON_DATA_PP1: + case MON_DATA_PP2: + case MON_DATA_PP3: + case MON_DATA_PP4: + retVal = substruct1->pp[field - MON_DATA_PP1]; + break; + case MON_DATA_HP_EV: + retVal = substruct2->hpEV; + break; + case MON_DATA_ATK_EV: + retVal = substruct2->attackEV; + break; + case MON_DATA_DEF_EV: + retVal = substruct2->defenseEV; + break; + case MON_DATA_SPD_EV: + retVal = substruct2->speedEV; + break; + case MON_DATA_SPATK_EV: + retVal = substruct2->spAttackEV; + break; + case MON_DATA_SPDEF_EV: + retVal = substruct2->spDefenseEV; + break; + case MON_DATA_COOL: + retVal = substruct2->cool; + break; + case MON_DATA_BEAUTY: + retVal = substruct2->beauty; + break; + case MON_DATA_CUTE: + retVal = substruct2->cute; + break; + case MON_DATA_SMART: + retVal = substruct2->smart; + break; + case MON_DATA_TOUGH: + retVal = substruct2->tough; + break; + case MON_DATA_SHEEN: + retVal = substruct2->sheen; + break; + case MON_DATA_POKERUS: + retVal = substruct3->pokerus; + break; + case MON_DATA_MET_LOCATION: + retVal = substruct3->metLocation; + break; + case MON_DATA_MET_LEVEL: + retVal = substruct3->metLevel; + break; + case MON_DATA_MET_GAME: + retVal = substruct3->metGame; + break; + case MON_DATA_POKEBALL: + retVal = substruct3->pokeball; + break; + case MON_DATA_OT_GENDER: + retVal = substruct3->otGender; + break; + case MON_DATA_HP_IV: + retVal = substruct3->hpIV; + break; + case MON_DATA_ATK_IV: + retVal = substruct3->attackIV; + break; + case MON_DATA_DEF_IV: + retVal = substruct3->defenseIV; + break; + case MON_DATA_SPD_IV: + retVal = substruct3->speedIV; + break; + case MON_DATA_SPATK_IV: + retVal = substruct3->spAttackIV; + break; + case MON_DATA_SPDEF_IV: + retVal = substruct3->spDefenseIV; + break; + case MON_DATA_IS_EGG: + retVal = substruct3->isEgg; + break; + case MON_DATA_ALT_ABILITY: + retVal = substruct3->altAbility; + break; + case MON_DATA_COOL_RIBBON: + retVal = substruct3->coolRibbon; + break; + case MON_DATA_BEAUTY_RIBBON: + retVal = substruct3->beautyRibbon; + break; + case MON_DATA_CUTE_RIBBON: + retVal = substruct3->cuteRibbon; + break; + case MON_DATA_SMART_RIBBON: + retVal = substruct3->smartRibbon; + break; + case MON_DATA_TOUGH_RIBBON: + retVal = substruct3->toughRibbon; + break; + case MON_DATA_CHAMPION_RIBBON: + retVal = substruct3->championRibbon; + break; + case MON_DATA_WINNING_RIBBON: + retVal = substruct3->winningRibbon; + break; + case MON_DATA_VICTORY_RIBBON: + retVal = substruct3->victoryRibbon; + break; + case MON_DATA_ARTIST_RIBBON: + retVal = substruct3->artistRibbon; + break; + case MON_DATA_EFFORT_RIBBON: + retVal = substruct3->effortRibbon; + break; + case MON_DATA_GIFT_RIBBON_1: + retVal = substruct3->giftRibbon1; + break; + case MON_DATA_GIFT_RIBBON_2: + retVal = substruct3->giftRibbon2; + break; + case MON_DATA_GIFT_RIBBON_3: + retVal = substruct3->giftRibbon3; + break; + case MON_DATA_GIFT_RIBBON_4: + retVal = substruct3->giftRibbon4; + break; + case MON_DATA_GIFT_RIBBON_5: + retVal = substruct3->giftRibbon5; + break; + case MON_DATA_GIFT_RIBBON_6: + retVal = substruct3->giftRibbon6; + break; + case MON_DATA_GIFT_RIBBON_7: + retVal = substruct3->giftRibbon7; + break; + case MON_DATA_FATEFUL_ENCOUNTER: + retVal = substruct3->fatefulEncounter; + break; + case MON_DATA_SPECIES2: + retVal = substruct0->species; + if (substruct0->species && (substruct3->isEgg || boxMon->isBadEgg)) + retVal = SPECIES_EGG; + break; + case MON_DATA_IVS: + retVal = substruct3->hpIV | (substruct3->attackIV << 5) | (substruct3->defenseIV << 10) | (substruct3->speedIV << 15) | (substruct3->spAttackIV << 20) | (substruct3->spDefenseIV << 25); + break; + case MON_DATA_KNOWN_MOVES: + if (substruct0->species && !substruct3->isEgg) + { + u16 *moves = (u16 *)data; + s32 i = 0; + + while (moves[i] != 355) { - retVal = substruct3->championRibbon - | (substruct3->coolRibbon << 1) - | (substruct3->beautyRibbon << 4) - | (substruct3->cuteRibbon << 7) - | (substruct3->smartRibbon << 10) - | (substruct3->toughRibbon << 13) - | (substruct3->winningRibbon << 16) - | (substruct3->victoryRibbon << 17) - | (substruct3->artistRibbon << 18) - | (substruct3->effortRibbon << 19) - | (substruct3->giftRibbon1 << 20) - | (substruct3->giftRibbon2 << 21) - | (substruct3->giftRibbon3 << 22) - | (substruct3->giftRibbon4 << 23) - | (substruct3->giftRibbon5 << 24) - | (substruct3->giftRibbon6 << 25) - | (substruct3->giftRibbon7 << 26); + u16 move = moves[i]; + if (substruct1->moves[0] == move + || substruct1->moves[1] == move + || substruct1->moves[2] == move + || substruct1->moves[3] == move) + retVal |= gBitTable[i]; + i++; } - break; - default: - break; + } + break; + case MON_DATA_RIBBON_COUNT: + retVal = 0; + if (substruct0->species && !substruct3->isEgg) + { + retVal += substruct3->coolRibbon; + retVal += substruct3->beautyRibbon; + retVal += substruct3->cuteRibbon; + retVal += substruct3->smartRibbon; + retVal += substruct3->toughRibbon; + retVal += substruct3->championRibbon; + retVal += substruct3->winningRibbon; + retVal += substruct3->victoryRibbon; + retVal += substruct3->artistRibbon; + retVal += substruct3->effortRibbon; + retVal += substruct3->giftRibbon1; + retVal += substruct3->giftRibbon2; + retVal += substruct3->giftRibbon3; + retVal += substruct3->giftRibbon4; + retVal += substruct3->giftRibbon5; + retVal += substruct3->giftRibbon6; + retVal += substruct3->giftRibbon7; + } + break; + case MON_DATA_RIBBONS: + retVal = 0; + if (substruct0->species && !substruct3->isEgg) + { + retVal = substruct3->championRibbon + | (substruct3->coolRibbon << 1) + | (substruct3->beautyRibbon << 4) + | (substruct3->cuteRibbon << 7) + | (substruct3->smartRibbon << 10) + | (substruct3->toughRibbon << 13) + | (substruct3->winningRibbon << 16) + | (substruct3->victoryRibbon << 17) + | (substruct3->artistRibbon << 18) + | (substruct3->effortRibbon << 19) + | (substruct3->giftRibbon1 << 20) + | (substruct3->giftRibbon2 << 21) + | (substruct3->giftRibbon3 << 22) + | (substruct3->giftRibbon4 << 23) + | (substruct3->giftRibbon5 << 24) + | (substruct3->giftRibbon6 << 25) + | (substruct3->giftRibbon7 << 26); + } + break; + default: + break; } if (field > MON_DATA_10) @@ -759,8 +750,8 @@ void SetMonData(struct Pokemon *mon, s32 field, const u8 *data) case MON_DATA_SPDEF: SET16(mon->spDefense); break; - case MON_DATA_64: - SET8(mon->pokerus); + case MON_DATA_MAIL: + SET8(mon->mail); break; case MON_DATA_SPECIES2: break; @@ -798,235 +789,239 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const u8 *data) switch (field) { - case MON_DATA_PERSONALITY: - SET32(boxMon->personality); - break; - case MON_DATA_OT_ID: - SET32(boxMon->otId); - break; - case MON_DATA_NICKNAME: - { - s32 i; - for (i = 0; i < POKEMON_NAME_LENGTH; i++) - boxMon->nickname[i] = data[i]; - break; - } - case MON_DATA_LANGUAGE: - SET8(boxMon->language); - break; - case MON_DATA_SANITY_BIT1: - SET8(boxMon->isBadEgg); - break; - case MON_DATA_SANITY_BIT2: - SET8(boxMon->hasSpecies); - break; - case MON_DATA_SANITY_BIT3: - SET8(boxMon->isEgg); - break; - case MON_DATA_OT_NAME: - { - s32 i; - for (i = 0; i < OT_NAME_LENGTH; i++) - boxMon->otName[i] = data[i]; - break; - } - case MON_DATA_MARKINGS: - SET8(boxMon->markings); - break; - case MON_DATA_CHECKSUM: - SET16(boxMon->checksum); - break; - case MON_DATA_10: - SET16(boxMon->unknown); - break; - case MON_DATA_SPECIES: - { - SET16(substruct0->species); - if (substruct0->species) - boxMon->hasSpecies = 1; - else - boxMon->hasSpecies = 0; - break; - } - case MON_DATA_HELD_ITEM: - SET16(substruct0->heldItem); - break; - case MON_DATA_EXP: - SET32(substruct0->experience); - break; - case MON_DATA_PP_BONUSES: - SET8(substruct0->ppBonuses); - break; - case MON_DATA_FRIENDSHIP: - SET8(substruct0->friendship); - break; - case MON_DATA_MOVE1: - case MON_DATA_MOVE2: - case MON_DATA_MOVE3: - case MON_DATA_MOVE4: - SET16(substruct1->moves[field - MON_DATA_MOVE1]); - break; - case MON_DATA_PP1: - case MON_DATA_PP2: - case MON_DATA_PP3: - case MON_DATA_PP4: - SET8(substruct1->pp[field - MON_DATA_PP1]); - break; - case MON_DATA_HP_EV: - SET8(substruct2->hpEV); - break; - case MON_DATA_ATK_EV: - SET8(substruct2->attackEV); - break; - case MON_DATA_DEF_EV: - SET8(substruct2->defenseEV); - break; - case MON_DATA_SPD_EV: - SET8(substruct2->speedEV); - break; - case MON_DATA_SPATK_EV: - SET8(substruct2->spAttackEV); - break; - case MON_DATA_SPDEF_EV: - SET8(substruct2->spDefenseEV); - break; - case MON_DATA_COOL: - SET8(substruct2->cool); - break; - case MON_DATA_BEAUTY: - SET8(substruct2->beauty); - break; - case MON_DATA_CUTE: - SET8(substruct2->cute); - break; - case MON_DATA_SMART: - SET8(substruct2->smart); - break; - case MON_DATA_TOUGH: - SET8(substruct2->tough); - break; - case MON_DATA_SHEEN: - SET8(substruct2->sheen); - break; - case MON_DATA_POKERUS: - SET8(substruct3->pokerus); - break; - case MON_DATA_MET_LOCATION: - SET8(substruct3->metLocation); - break; - case MON_DATA_MET_LEVEL: - { - u8 metLevel = *data; - substruct3->metLevel = metLevel; - break; - } - case MON_DATA_MET_GAME: - SET8(substruct3->metGame); - break; - case MON_DATA_POKEBALL: - { - u8 pokeball = *data; - substruct3->pokeball = pokeball; - break; - } - case MON_DATA_OT_GENDER: - SET8(substruct3->otGender); - break; - case MON_DATA_HP_IV: - SET8(substruct3->hpIV); - break; - case MON_DATA_ATK_IV: - SET8(substruct3->attackIV); - break; - case MON_DATA_DEF_IV: - SET8(substruct3->defenseIV); - break; - case MON_DATA_SPD_IV: - SET8(substruct3->speedIV); - break; - case MON_DATA_SPATK_IV: - SET8(substruct3->spAttackIV); - break; - case MON_DATA_SPDEF_IV: - SET8(substruct3->spDefenseIV); - break; - case MON_DATA_IS_EGG: - SET8(substruct3->isEgg); - if (substruct3->isEgg) - boxMon->isEgg = 1; - else - boxMon->isEgg = 0; - break; - case MON_DATA_ALT_ABILITY: - SET8(substruct3->altAbility); - break; - case MON_DATA_COOL_RIBBON: - SET8(substruct3->coolRibbon); - break; - case MON_DATA_BEAUTY_RIBBON: - SET8(substruct3->beautyRibbon); - break; - case MON_DATA_CUTE_RIBBON: - SET8(substruct3->cuteRibbon); - break; - case MON_DATA_SMART_RIBBON: - SET8(substruct3->smartRibbon); - break; - case MON_DATA_TOUGH_RIBBON: - SET8(substruct3->toughRibbon); - break; - case MON_DATA_CHAMPION_RIBBON: - SET8(substruct3->championRibbon); - break; - case MON_DATA_WINNING_RIBBON: - SET8(substruct3->winningRibbon); - break; - case MON_DATA_VICTORY_RIBBON: - SET8(substruct3->victoryRibbon); - break; - case MON_DATA_ARTIST_RIBBON: - SET8(substruct3->artistRibbon); - break; - case MON_DATA_EFFORT_RIBBON: - SET8(substruct3->effortRibbon); - break; - case MON_DATA_GIFT_RIBBON_1: - SET8(substruct3->giftRibbon1); - break; - case MON_DATA_GIFT_RIBBON_2: - SET8(substruct3->giftRibbon2); - break; - case MON_DATA_GIFT_RIBBON_3: - SET8(substruct3->giftRibbon3); - break; - case MON_DATA_GIFT_RIBBON_4: - SET8(substruct3->giftRibbon4); - break; - case MON_DATA_GIFT_RIBBON_5: - SET8(substruct3->giftRibbon5); - break; - case MON_DATA_GIFT_RIBBON_6: - SET8(substruct3->giftRibbon6); - break; - case MON_DATA_GIFT_RIBBON_7: - SET8(substruct3->giftRibbon7); - break; - case MON_DATA_FATEFUL_ENCOUNTER: - SET8(substruct3->fatefulEncounter); - break; - case MON_DATA_IVS: - { - u32 ivs = *data; // Bug: Only the HP IV and the lower 3 bits of the Attack IV are read. The rest become 0. - substruct3->hpIV = ivs & 0x1F; - substruct3->attackIV = (ivs >> 5) & 0x1F; - substruct3->defenseIV = (ivs >> 10) & 0x1F; - substruct3->speedIV = (ivs >> 15) & 0x1F; - substruct3->spAttackIV = (ivs >> 20) & 0x1F; - substruct3->spDefenseIV = (ivs >> 25) & 0x1F; - break; - } - default: - break; + case MON_DATA_PERSONALITY: + SET32(boxMon->personality); + break; + case MON_DATA_OT_ID: + SET32(boxMon->otId); + break; + case MON_DATA_NICKNAME: + { + s32 i; + for (i = 0; i < POKEMON_NAME_LENGTH; i++) + boxMon->nickname[i] = data[i]; + break; + } + case MON_DATA_LANGUAGE: + SET8(boxMon->language); + break; + case MON_DATA_SANITY_BIT1: + SET8(boxMon->isBadEgg); + break; + case MON_DATA_SANITY_BIT2: + SET8(boxMon->hasSpecies); + break; + case MON_DATA_SANITY_BIT3: + SET8(boxMon->isEgg); + break; + case MON_DATA_OT_NAME: + { + s32 i; + for (i = 0; i < OT_NAME_LENGTH; i++) + boxMon->otName[i] = data[i]; + break; + } + case MON_DATA_MARKINGS: + SET8(boxMon->markings); + break; + case MON_DATA_CHECKSUM: + SET16(boxMon->checksum); + break; + case MON_DATA_10: + SET16(boxMon->unknown); + break; + case MON_DATA_SPECIES: + { + SET16(substruct0->species); + if (substruct0->species) + boxMon->hasSpecies = 1; + else + boxMon->hasSpecies = 0; + break; + } + case MON_DATA_HELD_ITEM: + SET16(substruct0->heldItem); + break; + case MON_DATA_EXP: + SET32(substruct0->experience); + break; + case MON_DATA_PP_BONUSES: + SET8(substruct0->ppBonuses); + break; + case MON_DATA_FRIENDSHIP: + SET8(substruct0->friendship); + break; + case MON_DATA_MOVE1: + case MON_DATA_MOVE2: + case MON_DATA_MOVE3: + case MON_DATA_MOVE4: + SET16(substruct1->moves[field - MON_DATA_MOVE1]); + break; + case MON_DATA_PP1: + case MON_DATA_PP2: + case MON_DATA_PP3: + case MON_DATA_PP4: + SET8(substruct1->pp[field - MON_DATA_PP1]); + break; + case MON_DATA_HP_EV: + SET8(substruct2->hpEV); + break; + case MON_DATA_ATK_EV: + SET8(substruct2->attackEV); + break; + case MON_DATA_DEF_EV: + SET8(substruct2->defenseEV); + break; + case MON_DATA_SPD_EV: + SET8(substruct2->speedEV); + break; + case MON_DATA_SPATK_EV: + SET8(substruct2->spAttackEV); + break; + case MON_DATA_SPDEF_EV: + SET8(substruct2->spDefenseEV); + break; + case MON_DATA_COOL: + SET8(substruct2->cool); + break; + case MON_DATA_BEAUTY: + SET8(substruct2->beauty); + break; + case MON_DATA_CUTE: + SET8(substruct2->cute); + break; + case MON_DATA_SMART: + SET8(substruct2->smart); + break; + case MON_DATA_TOUGH: + SET8(substruct2->tough); + break; + case MON_DATA_SHEEN: + SET8(substruct2->sheen); + break; + case MON_DATA_POKERUS: + SET8(substruct3->pokerus); + break; + case MON_DATA_MET_LOCATION: + SET8(substruct3->metLocation); + break; + case MON_DATA_MET_LEVEL: + { + u8 metLevel = *data; + substruct3->metLevel = metLevel; + break; + } + case MON_DATA_MET_GAME: + SET8(substruct3->metGame); + break; + case MON_DATA_POKEBALL: + { + u8 pokeball = *data; + substruct3->pokeball = pokeball; + break; + } + case MON_DATA_OT_GENDER: + SET8(substruct3->otGender); + break; + case MON_DATA_HP_IV: + SET8(substruct3->hpIV); + break; + case MON_DATA_ATK_IV: + SET8(substruct3->attackIV); + break; + case MON_DATA_DEF_IV: + SET8(substruct3->defenseIV); + break; + case MON_DATA_SPD_IV: + SET8(substruct3->speedIV); + break; + case MON_DATA_SPATK_IV: + SET8(substruct3->spAttackIV); + break; + case MON_DATA_SPDEF_IV: + SET8(substruct3->spDefenseIV); + break; + case MON_DATA_IS_EGG: + SET8(substruct3->isEgg); + if (substruct3->isEgg) + boxMon->isEgg = 1; + else + boxMon->isEgg = 0; + break; + case MON_DATA_ALT_ABILITY: + SET8(substruct3->altAbility); + break; + case MON_DATA_COOL_RIBBON: + SET8(substruct3->coolRibbon); + break; + case MON_DATA_BEAUTY_RIBBON: + SET8(substruct3->beautyRibbon); + break; + case MON_DATA_CUTE_RIBBON: + SET8(substruct3->cuteRibbon); + break; + case MON_DATA_SMART_RIBBON: + SET8(substruct3->smartRibbon); + break; + case MON_DATA_TOUGH_RIBBON: + SET8(substruct3->toughRibbon); + break; + case MON_DATA_CHAMPION_RIBBON: + SET8(substruct3->championRibbon); + break; + case MON_DATA_WINNING_RIBBON: + SET8(substruct3->winningRibbon); + break; + case MON_DATA_VICTORY_RIBBON: + SET8(substruct3->victoryRibbon); + break; + case MON_DATA_ARTIST_RIBBON: + SET8(substruct3->artistRibbon); + break; + case MON_DATA_EFFORT_RIBBON: + SET8(substruct3->effortRibbon); + break; + case MON_DATA_GIFT_RIBBON_1: + SET8(substruct3->giftRibbon1); + break; + case MON_DATA_GIFT_RIBBON_2: + SET8(substruct3->giftRibbon2); + break; + case MON_DATA_GIFT_RIBBON_3: + SET8(substruct3->giftRibbon3); + break; + case MON_DATA_GIFT_RIBBON_4: + SET8(substruct3->giftRibbon4); + break; + case MON_DATA_GIFT_RIBBON_5: + SET8(substruct3->giftRibbon5); + break; + case MON_DATA_GIFT_RIBBON_6: + SET8(substruct3->giftRibbon6); + break; + case MON_DATA_GIFT_RIBBON_7: + SET8(substruct3->giftRibbon7); + break; + case MON_DATA_FATEFUL_ENCOUNTER: + SET8(substruct3->fatefulEncounter); + break; + case MON_DATA_IVS: + { +#ifdef BUGFIX_SETMONIVS + u32 ivs = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); +#else + u32 ivs = *data; // Bug: Only the HP IV and the lower 3 bits of the Attack IV are read. The rest become 0. +#endif + substruct3->hpIV = ivs & 0x1F; + substruct3->attackIV = (ivs >> 5) & 0x1F; + substruct3->defenseIV = (ivs >> 10) & 0x1F; + substruct3->speedIV = (ivs >> 15) & 0x1F; + substruct3->spAttackIV = (ivs >> 20) & 0x1F; + substruct3->spDefenseIV = (ivs >> 25) & 0x1F; + break; + } + default: + break; } if (field > MON_DATA_10) @@ -1073,7 +1068,7 @@ u8 SendMonToPC(struct Pokemon *mon) { if (GetBoxMonData(&gPokemonStorage.boxes[i][j], MON_DATA_SPECIES, NULL) == SPECIES_NONE) { - sub_8040B1C(mon); + MonRestorePP(mon); CopyMon(&gPokemonStorage.boxes[i][j], &mon->box, sizeof(mon->box)); return 1; } @@ -1126,7 +1121,7 @@ u8 sub_803DAA0(void) { if (GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) != 0 && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_NONE - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != 412) + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_EGG) aliveCount++; } @@ -1136,11 +1131,11 @@ u8 sub_803DAA0(void) u8 GetAbilityBySpecies(u16 species, bool8 altAbility) { if (altAbility) - byte_2024C06 = gBaseStats[species].ability2; + gLastUsedAbility = gBaseStats[species].ability2; else - byte_2024C06 = gBaseStats[species].ability1; + gLastUsedAbility = gBaseStats[species].ability1; - return byte_2024C06; + return gLastUsedAbility; } u8 GetMonAbility(struct Pokemon *mon) @@ -1183,7 +1178,7 @@ void CreateSecretBaseEnemyParty(struct SecretBaseRecord *secretBaseRecord) } } - gUnknown_020239F8 = 8; + gBattleTypeFlags = 8; gTrainerBattleOpponent = 1024; } @@ -1228,7 +1223,7 @@ void GetSpeciesName(u8 *name, u16 species) for (i = 0; i <= POKEMON_NAME_LENGTH; i++) { - if (species > 412) + if (species > NUM_SPECIES) name[i] = gSpeciesNames[0][i]; else name[i] = gSpeciesNames[species][i]; @@ -1300,7 +1295,7 @@ void CopyPlayerPartyMonToBattleData(u8 battleIndex, u8 partyIndex) GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, nickname); StringCopy10(gBattleMons[battleIndex].nickname, nickname); GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_NAME, gBattleMons[battleIndex].otName); - *(unk_20160BC + battle_side_get_owner(battleIndex)) = gBattleMons[battleIndex].hp; + *(unk_20160BC + GetBankSide(battleIndex)) = gBattleMons[battleIndex].hp; for (i = 0; i < 8; i++) gBattleMons[battleIndex].statStages[i] = 6; diff --git a/src/pokemon_3.c b/src/pokemon_3.c new file mode 100644 index 000000000..cb8eb2a46 --- /dev/null +++ b/src/pokemon_3.c @@ -0,0 +1,1402 @@ +#include "global.h" +#include "battle.h" +#include "battle_message.h" +#include "data2.h" +#include "event_data.h" +#include "hold_effects.h" +#include "item.h" +#include "items.h" +#include "link.h" +#include "m4a.h" +#include "main.h" +#include "pokemon.h" +#include "rng.h" +#include "rom4.h" +#include "rom_8077ABC.h" +#include "rom_8094928.h" +#include "rtc.h" +#include "songs.h" +#include "sound.h" +#include "species.h" +#include "sprite.h" +#include "string_util.h" +#include "text.h" +#include "util.h" + +#define EVO_FRIENDSHIP 0x0001 // Pokémon levels up with friendship ≥ 220 +#define EVO_FRIENDSHIP_DAY 0x0002 // Pokémon levels up during the day with friendship ≥ 220 +#define EVO_FRIENDSHIP_NIGHT 0x0003 // Pokémon levels up at night with friendship ≥ 220 +#define EVO_LEVEL 0x0004 // Pokémon reaches the specified level +#define EVO_TRADE 0x0005 // Pokémon is traded +#define EVO_TRADE_ITEM 0x0006 // Pokémon is traded while it's holding the specified item +#define EVO_ITEM 0x0007 // specified item is used on Pokémon +#define EVO_LEVEL_ATK_GT_DEF 0x0008 // Pokémon reaches the specified level with attack > defense +#define EVO_LEVEL_ATK_EQ_DEF 0x0009 // Pokémon reaches the specified level with attack = defense +#define EVO_LEVEL_ATK_LT_DEF 0x000a // Pokémon reaches the specified level with attack < defense +#define EVO_LEVEL_SILCOON 0x000b // Pokémon reaches the specified level with a Silcoon personality value +#define EVO_LEVEL_CASCOON 0x000c // Pokémon reaches the specified level with a Cascoon personality value +#define EVO_LEVEL_NINJASK 0x000d // Pokémon reaches the specified level (special value for Ninjask) +#define EVO_LEVEL_SHEDINJA 0x000e // Pokémon reaches the specified level (special value for Shedinja) +#define EVO_BEAUTY 0x000f // Pokémon levels up with beauty ≥ specified value + +struct SpindaSpot +{ + u8 x, y; + u16 image[16]; +}; + +extern u8 gPlayerPartyCount; +extern u8 gEnemyPartyCount; +extern struct BattlePokemon gBattleMons[4]; +extern u8 gActiveBank; +extern struct BattleEnigmaBerry gEnigmaBerries[]; +extern u16 gSpeciesToHoennPokedexNum[]; +extern u16 gSpeciesToNationalPokedexNum[]; +extern u16 gHoennToNationalOrder[]; +extern u16 gSpeciesIdToCryId[]; +extern u8 gBattleTextBuff1[]; +extern u8 gBattleTextBuff2[]; +extern u8 gDisplayedStringBattle[]; +extern u8 gBankAttacker; +extern u8 gBankTarget; +extern u8 gStringBank; +extern u8 gBankInMenu; +extern struct SpindaSpot gSpindaSpotGraphics[]; +extern s8 gNatureStatTable[][5]; +extern s8 gUnknown_082082FE[][3]; +extern u16 gTrainerBattleOpponent; +extern u16 gBattleTypeFlags; +extern u32 gTMHMLearnsets[][2]; +extern u8 gBattleMonForms[]; +extern const u8 BattleText_Wally[]; +extern const u16 gHMMoves[]; +extern s8 gUnknown_083F7E28[]; +extern u8 gLastUsedAbility; +extern const u8 BattleText_PreventedSwitch[]; +extern u16 gBattlePartyID[]; +extern u8 gJapaneseNidoranNames[][11]; + +extern u8 gUnknown_082082F8[]; +extern u8 gUnknown_083FFDB3[]; +extern u8 gUnknown_083FFDD3[]; +extern u8 gUnknown_083FEE5D[]; +extern u8 gUnknown_083FEE92[]; +extern u8 *gUnknown_08400F58[]; + +bool8 HealStatusConditions(struct Pokemon *mon, u32 unused, u32 healMask, u8 battleId) +{ + u32 status = GetMonData(mon, MON_DATA_STATUS, 0); + + if (status & healMask) + { + status &= ~healMask; + SetMonData(mon, MON_DATA_STATUS, (u8 *)&status); + if (gMain.inBattle && battleId != 4) + gBattleMons[battleId].status1 &= ~healMask; + return FALSE; + } + else + { + return TRUE; + } +} + +u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit) +{ + u8 *temp; + u8 *itemEffect; + u8 offset; + int i; + u8 j; + u8 val; + + offset = 6; + + temp = (u8 *) gItemEffectTable[itemId - 13]; + + if (!temp && itemId != ITEM_ENIGMA_BERRY) + return 0; + + if (itemId == ITEM_ENIGMA_BERRY) + { + temp = gEnigmaBerries[gActiveBank].itemEffect; + } + + itemEffect = temp; + + for (i = 0; i < 6; i++) + { + switch (i) + { + case 0: + case 1: + case 2: + case 3: + if (i == effectByte) + return 0; + break; + case 4: + val = itemEffect[4]; + if (val & 0x20) + val &= 0xDF; + j = 0; + while (val) + { + if (val & 1) + { + switch (j) + { + case 2: + if (val & 0x10) + val &= 0xEF; + case 0: + if (i == effectByte && (val & effectBit)) + return offset; + offset++; + break; + case 1: + if (i == effectByte && (val & effectBit)) + return offset; + offset++; + break; + case 3: + if (i == effectByte && (val & effectBit)) + return offset; + offset++; + break; + case 7: + if (i == effectByte) + return 0; + break; + } + } + j++; + val >>= 1; + if (i == effectByte) + effectBit >>= 1; + } + break; + case 5: + val = itemEffect[5]; + j = 0; + while (val) + { + if (val & 1) + { + switch (j) + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + if (i == effectByte && (val & effectBit)) + return offset; + offset++; + break; + case 7: + if (i == effectByte) + return 0; + break; + } + } + j++; + val >>= 1; + if (i == effectByte) + effectBit >>= 1; + } + break; + } + } + + return offset; +} + +void sub_803F324(int stat) +{ + gBankTarget = gBankInMenu; + StringCopy(gBattleTextBuff1, gUnknown_08400F58[gUnknown_082082F8[stat]]); + StringCopy(gBattleTextBuff2, gUnknown_083FFDB3); + StrCpyDecodeToDisplayedStringBattle(gUnknown_083FFDD3); +} + +u8 *sub_803F378(u16 itemId) +{ + int i; + u8 *itemEffect; + + if (itemId == ITEM_ENIGMA_BERRY) + { + if (gMain.inBattle) + { + itemEffect = gEnigmaBerries[gBankInMenu].itemEffect; + } + else + { + itemEffect = gSaveBlock1.enigmaBerry.itemEffect; + } + } + else + { + itemEffect = (u8 *) gItemEffectTable[itemId - 13]; + } + + gStringBank = gBankInMenu; + + for (i = 0; i < 3; i++) + { + if (itemEffect[i] & 0xF) + sub_803F324(i * 2); + if (itemEffect[i] & 0xF0) + { + if (i) + { + sub_803F324(i * 2 + 1); + } + else + { + gBankAttacker = gBankInMenu; + StrCpyDecodeToDisplayedStringBattle(gUnknown_083FEE92); + } + } + } + + if (itemEffect[3] & 0x80) + { + gBankAttacker = gBankInMenu; + StrCpyDecodeToDisplayedStringBattle(gUnknown_083FEE5D); + } + + return gDisplayedStringBattle; +} + +u8 GetNature(struct Pokemon *mon) +{ + return GetMonData(mon, MON_DATA_PERSONALITY, 0) % 25; +} + +u8 GetNatureFromPersonality(u32 personality) +{ + return personality % 25; +} + +u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem) +{ + int i; + u16 targetSpecies = 0; + u16 species = GetMonData(mon, MON_DATA_SPECIES, 0); + u16 heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, 0); + u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 0); + u8 level; + u16 friendship; + u8 beauty = GetMonData(mon, MON_DATA_BEAUTY, 0); + u16 upperPersonality = personality >> 16; + u8 holdEffect; + + if (heldItem == ITEM_ENIGMA_BERRY) + holdEffect = gSaveBlock1.enigmaBerry.holdEffect; + else + holdEffect = ItemId_GetHoldEffect(heldItem); + + if (holdEffect == 38 && type != 3) + return 0; + + switch (type) + { + case 0: + level = GetMonData(mon, MON_DATA_LEVEL, 0); + friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, 0); + + for (i = 0; i < 5; i++) + { + switch (gEvolutionTable[species].evolutions[i].method) + { + case EVO_FRIENDSHIP: + if (friendship >= 220) + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + case EVO_FRIENDSHIP_DAY: + RtcCalcLocalTime(); + if (gLocalTime.hours >= 12 && gLocalTime.hours < 24 && friendship >= 220) + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + case EVO_FRIENDSHIP_NIGHT: + RtcCalcLocalTime(); + if (gLocalTime.hours >= 0 && gLocalTime.hours < 12 && friendship >= 220) + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + case EVO_LEVEL: + if (gEvolutionTable[species].evolutions[i].param <= level) + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + case EVO_LEVEL_ATK_GT_DEF: + if (gEvolutionTable[species].evolutions[i].param <= level) + if (GetMonData(mon, MON_DATA_ATK, 0) > GetMonData(mon, MON_DATA_DEF, 0)) + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + case EVO_LEVEL_ATK_EQ_DEF: + if (gEvolutionTable[species].evolutions[i].param <= level) + if (GetMonData(mon, MON_DATA_ATK, 0) == GetMonData(mon, MON_DATA_DEF, 0)) + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + case EVO_LEVEL_ATK_LT_DEF: + if (gEvolutionTable[species].evolutions[i].param <= level) + if (GetMonData(mon, MON_DATA_ATK, 0) < GetMonData(mon, MON_DATA_DEF, 0)) + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + case EVO_LEVEL_SILCOON: + if (gEvolutionTable[species].evolutions[i].param <= level && (upperPersonality % 10) <= 4) + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + case EVO_LEVEL_CASCOON: + if (gEvolutionTable[species].evolutions[i].param <= level && (upperPersonality % 10) > 4) + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + case EVO_LEVEL_NINJASK: + if (gEvolutionTable[species].evolutions[i].param <= level) + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + case EVO_BEAUTY: + if (gEvolutionTable[species].evolutions[i].param <= beauty) + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + } + } + break; + case 1: + for (i = 0; i < 5; i++) + { + switch (gEvolutionTable[species].evolutions[i].method) + { + case EVO_TRADE: + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + case EVO_TRADE_ITEM: + if (gEvolutionTable[species].evolutions[i].param == heldItem) + { + heldItem = 0; + SetMonData(mon, MON_DATA_HELD_ITEM, (u8 *)&heldItem); + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + } + break; + } + } + break; + case 2: + case 3: + for (i = 0; i < 5; i++) + { + if (gEvolutionTable[species].evolutions[i].method == EVO_ITEM + && gEvolutionTable[species].evolutions[i].param == evolutionItem) + { + targetSpecies = gEvolutionTable[species].evolutions[i].targetSpecies; + break; + } + } + break; + } + + return targetSpecies; +} + +u16 HoennPokedexNumToSpecies(u16 hoennNum) +{ + u16 species; + + if (!hoennNum) + return 0; + + species = 0; + + while (species < 411 && gSpeciesToHoennPokedexNum[species] != hoennNum) + species++; + + if (species == 411) + return 0; + + return species + 1; +} + +u16 NationalPokedexNumToSpecies(u16 nationalNum) +{ + u16 species; + + if (!nationalNum) + return 0; + + species = 0; + + while (species < 411 && gSpeciesToNationalPokedexNum[species] != nationalNum) + species++; + + if (species == 411) + return 0; + + return species + 1; +} + +u16 NationalToHoennOrder(u16 nationalNum) +{ + u16 hoennNum; + + if (!nationalNum) + return 0; + + hoennNum = 0; + + while (hoennNum < 411 && gHoennToNationalOrder[hoennNum] != nationalNum) + hoennNum++; + + if (hoennNum == 411) + return 0; + + return hoennNum + 1; +} + +u16 SpeciesToNationalPokedexNum(u16 species) +{ + if (!species) + return 0; + + return gSpeciesToNationalPokedexNum[species - 1]; +} + +u16 SpeciesToHoennPokedexNum(u16 species) +{ + if (!species) + return 0; + + return gSpeciesToHoennPokedexNum[species - 1]; +} + +u16 HoennToNationalOrder(u16 hoennNum) +{ + if (!hoennNum) + return 0; + + return gHoennToNationalOrder[hoennNum - 1]; +} + +u32 SpeciesToCryId(u16 species) +{ + if (species <= 250) + return species; + + if (species < 276) + return 200; + + return gSpeciesIdToCryId[species - 276]; +} + +void unref_sub_803F938(u16 species, u32 personality, u8 *dest) +{ + if (species == SPECIES_SPINDA && dest != gUnknown_081FAF4C[0] && dest != gUnknown_081FAF4C[2]) + { + int i; + for (i = 0; i < 4; i++) + { + int j; + u8 x = gSpindaSpotGraphics[i].x + ((personality & 0x0F) - 8); + u8 y = gSpindaSpotGraphics[i].y + (((personality & 0xF0) >> 4) - 8); + + for (j = 0; j < 16; j++) + { + int k; + s32 row = gSpindaSpotGraphics[i].image[j]; + + for (k = x; k < x + 16; k++) + { + u8 *val = dest + ((k / 8) * 32) + ((k % 8) / 2) + ((y >> 3) << 8) + ((y & 7) << 2); + + if (row & 1) + { + if (k & 1) + { + if ((u8)((*val & 0xF0) - 0x10) <= 0x20) + *val += 0x40; + } + else + { + if ((u8)((*val & 0xF) - 0x01) <= 0x02) + *val += 0x04; + } + } + + row >>= 1; + } + + y++; + } + + personality >>= 8; + } + } +} + +void DrawSpindaSpots(u16 species, u32 personality, u8 *dest, u8 a4) +{ + if (species == SPECIES_SPINDA && a4) + { + int i; + for (i = 0; i < 4; i++) + { + int j; + u8 x = gSpindaSpotGraphics[i].x + ((personality & 0x0F) - 8); + u8 y = gSpindaSpotGraphics[i].y + (((personality & 0xF0) >> 4) - 8); + + for (j = 0; j < 16; j++) + { + int k; + s32 row = gSpindaSpotGraphics[i].image[j]; + + for (k = x; k < x + 16; k++) + { + u8 *val = dest + ((k / 8) * 32) + ((k % 8) / 2) + ((y >> 3) << 8) + ((y & 7) << 2); + + if (row & 1) + { + if (k & 1) + { + if ((u8)((*val & 0xF0) - 0x10) <= 0x20) + *val += 0x40; + } + else + { + if ((u8)((*val & 0xF) - 0x01) <= 0x02) + *val += 0x04; + } + } + + row >>= 1; + } + + y++; + } + + personality >>= 8; + } + } +} + +void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies) +{ +#ifdef BUGFIX_EVO_NAME + u8 language; + GetMonData(mon, MON_DATA_NICKNAME, gStringVar1); + language = GetMonData(mon, MON_DATA_LANGUAGE, &language); + if (language == GAME_LANGUAGE && !StringCompareWithoutExtCtrlCodes(gSpeciesNames[oldSpecies], gStringVar1)) + SetMonData(mon, MON_DATA_NICKNAME, gSpeciesNames[newSpecies]); +#else + GetMonData(mon, MON_DATA_NICKNAME, gStringVar1); + if (!StringCompareWithoutExtCtrlCodes(gSpeciesNames[oldSpecies], gStringVar1)) + SetMonData(mon, MON_DATA_NICKNAME, gSpeciesNames[newSpecies]); +#endif +} + +bool8 sub_803FBBC(void) +{ + bool8 retVal = FALSE; + switch (gLinkPlayers[GetMultiplayerId()].lp_field_18) + { + case 0: + case 3: + retVal = FALSE; + break; + case 1: + case 2: + retVal = TRUE; + break; + } + return retVal; +} + +bool8 sub_803FBFC(u8 id) +{ + bool8 retVal = FALSE; + switch (gLinkPlayers[id].lp_field_18) + { + case 0: + case 3: + retVal = FALSE; + break; + case 1: + case 2: + retVal = TRUE; + break; + } + return retVal; +} + +s32 sub_803FC34(u16 a1) +{ + s32 id; + for (id = 0; id < MAX_LINK_PLAYERS; id++) + if (gLinkPlayers[id].lp_field_18 == a1) + break; + return id; +} + +u8 sub_803FC58(u16 trainer) +{ + return gTrainers[trainer].encounterMusic_gender & 0x7F; +} + +u16 nature_stat_mod(u8 nature, u16 n, u8 statIndex) +{ + if (statIndex < 1 || statIndex > 5) + { + // should just be "return n", but it wouldn't match without this + u16 retVal = n; + retVal++; + retVal--; + return retVal; + } + + switch (gNatureStatTable[nature][statIndex - 1]) + { + case 1: + return (u16)(n * 110) / 100; + case -1: + return (u16)(n * 90) / 100; + } + + return n; +} + +void AdjustFriendship(struct Pokemon *mon, u8 event) +{ + u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + u16 heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, 0); + u8 holdEffect; + + if (heldItem == ITEM_ENIGMA_BERRY) + { + if (gMain.inBattle) + { + holdEffect = gEnigmaBerries[0].holdEffect; + } + else + { + holdEffect = gSaveBlock1.enigmaBerry.holdEffect; + } + } + else + { + holdEffect = ItemId_GetHoldEffect(heldItem); + } + + if (species && species != SPECIES_EGG) + { + u8 friendshipLevel = 0; + s16 friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, 0); + if (friendship > 99) + friendshipLevel++; + if (friendship > 199) + friendshipLevel++; + if ((event != 5 || !(Random() & 1)) + && (event != 3 + || ((gBattleTypeFlags & BATTLE_TYPE_TRAINER) + && (gTrainers[gTrainerBattleOpponent].trainerClass == 24 + || gTrainers[gTrainerBattleOpponent].trainerClass == 25 + || gTrainers[gTrainerBattleOpponent].trainerClass == 32)))) + { + s8 mod = gUnknown_082082FE[event][friendshipLevel]; + if (mod > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP) + mod = (150 * mod) / 100; + friendship += mod; + if (mod > 0) + { + if (GetMonData(mon, MON_DATA_POKEBALL, 0) == ITEM_LUXURY_BALL) + friendship++; + if (GetMonData(mon, MON_DATA_MET_LOCATION, 0) == sav1_map_get_name()) + friendship++; + } + if (friendship < 0) + friendship = 0; + if (friendship > 255) + friendship = 255; + SetMonData(mon, MON_DATA_FRIENDSHIP, (u8 *)&friendship); + } + } +} + +void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies) +{ + u8 evs[NUM_STATS]; + u16 evIncrease = 0; + u16 totalEVs = 0; + u16 heldItem; + u8 holdEffect; + int i; + + for (i = 0; i < NUM_STATS; i++) + { + evs[i] = GetMonData(mon, MON_DATA_HP_EV + i, 0); + totalEVs += evs[i]; + } + + for (i = 0; i < NUM_STATS; i++) + { + u8 hasHadPokerus; + int multiplier; + + if (totalEVs >= MAX_TOTAL_EVS) + break; + + hasHadPokerus = CheckPartyHasHadPokerus(mon, 0); + + if (hasHadPokerus) + multiplier = 2; + else + multiplier = 1; + + switch (i) + { + case 0: + evIncrease = gBaseStats[defeatedSpecies].evYield_HP * multiplier; + break; + case 1: + evIncrease = gBaseStats[defeatedSpecies].evYield_Attack * multiplier; + break; + case 2: + evIncrease = gBaseStats[defeatedSpecies].evYield_Defense * multiplier; + break; + case 3: + evIncrease = gBaseStats[defeatedSpecies].evYield_Speed * multiplier; + break; + case 4: + evIncrease = gBaseStats[defeatedSpecies].evYield_SpAttack * multiplier; + break; + case 5: + evIncrease = gBaseStats[defeatedSpecies].evYield_SpDefense * multiplier; + break; + } + + heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, 0); + + if (heldItem == ITEM_ENIGMA_BERRY) + { + if (gMain.inBattle) + { + holdEffect = gEnigmaBerries[0].holdEffect; + } + else + { + holdEffect = gSaveBlock1.enigmaBerry.holdEffect; + } + } + else + { + holdEffect = ItemId_GetHoldEffect(heldItem); + } + + if (holdEffect == HOLD_EFFECT_MACHO_BRACE) + evIncrease *= 2; + + if (totalEVs + (s16)evIncrease > MAX_TOTAL_EVS) + evIncrease = ((s16)evIncrease + MAX_TOTAL_EVS) - (totalEVs + evIncrease); + + if (evs[i] + (s16)evIncrease > 255) + { + int val1 = (s16)evIncrease + 255; + int val2 = evs[i] + evIncrease; + evIncrease = val1 - val2; + } + + evs[i] += evIncrease; + totalEVs += evIncrease; + SetMonData(mon, MON_DATA_HP_EV + i, &evs[i]); + } +} + +u16 GetMonEVCount(struct Pokemon *mon) +{ + int i; + u16 count = 0; + + for (i = 0; i < NUM_STATS; i++) + count += GetMonData(mon, MON_DATA_HP_EV + i, 0); + + return count; +} + +void RandomlyGivePartyPokerus(struct Pokemon *party) +{ + u16 rnd = Random(); + if (rnd == 0x4000 || rnd == 0x8000 || rnd == 0xC000) + { + struct Pokemon *mon; + + do + { + do + { + rnd = Random() % PARTY_SIZE; + mon = &party[rnd]; + } + while (!GetMonData(mon, MON_DATA_SPECIES, 0)); + } + while (GetMonData(mon, MON_DATA_IS_EGG, 0)); + + if (!(CheckPartyHasHadPokerus(party, gBitTable[rnd]))) + { + u8 rnd2; + + do + { + rnd2 = Random(); + } + while (rnd2 == 0); + + if (rnd2 & 0xF0) + rnd2 &= 0x07; + + rnd2 |= (rnd2 << 4); + rnd2 &= 0xF3; + rnd2++; + + SetMonData(&party[rnd], MON_DATA_POKERUS, &rnd2); + } + } +} + +u8 CheckPartyPokerus(struct Pokemon *party, u8 selection) +{ + u8 retVal; + + int partyIndex = 0; + unsigned curBit = 1; + retVal = 0; + + if (selection) + { + do + { + if ((selection & 1) && (GetMonData(&party[partyIndex], MON_DATA_POKERUS, 0) & 0xF)) + retVal |= curBit; + partyIndex++; + curBit <<= 1; + selection >>= 1; + } + while (selection); + } + else if (GetMonData(&party[0], MON_DATA_POKERUS, 0) & 0xF) + { + retVal = 1; + } + + return retVal; +} + +u8 CheckPartyHasHadPokerus(struct Pokemon *party, u8 selection) +{ + u8 retVal; + + int partyIndex = 0; + unsigned curBit = 1; + retVal = 0; + + if (selection) + { + do + { + if ((selection & 1) && GetMonData(&party[partyIndex], MON_DATA_POKERUS, 0)) + retVal |= curBit; + partyIndex++; + curBit <<= 1; + selection >>= 1; + } + while (selection); + } + else if (GetMonData(&party[0], MON_DATA_POKERUS, 0)) + { + retVal = 1; + } + + return retVal; +} + +void UpdatePartyPokerusTime(u16 days) +{ + int i; + for (i = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, 0)) + { + u8 pokerus = GetMonData(&gPlayerParty[i], MON_DATA_POKERUS, 0); + if (pokerus & 0xF) + { + if ((pokerus & 0xF) < days || days > 4) + pokerus &= 0xF0; + else + pokerus -= days; + + SetMonData(&gPlayerParty[i], MON_DATA_POKERUS, &pokerus); + } + } + } +} + +void PartySpreadPokerus(struct Pokemon *party) +{ + if ((Random() % 3) == 0) + { + int i; + for (i = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&party[i], MON_DATA_SPECIES, 0)) + { + u8 pokerus = GetMonData(&party[i], MON_DATA_POKERUS, 0); + u8 curPokerus = pokerus; + if (pokerus) + { + if (pokerus & 0xF) + { + // spread to adjacent party members + if (i != 0 && !(GetMonData(&party[i - 1], MON_DATA_POKERUS, 0) & 0xF0)) + SetMonData(&party[i - 1], MON_DATA_POKERUS, &curPokerus); + if (i != (PARTY_SIZE - 1) && !(GetMonData(&party[i + 1], MON_DATA_POKERUS, 0) & 0xF0)) + { + SetMonData(&party[i + 1], MON_DATA_POKERUS, &curPokerus); + i++; + } + } + } + } + } + } +} + +bool8 TryIncrementMonLevel(struct Pokemon *mon) +{ + u16 species = GetMonData(mon, MON_DATA_SPECIES, 0); + u8 nextLevel = GetMonData(mon, MON_DATA_LEVEL, 0) + 1; + if (GetMonData(mon, MON_DATA_EXP, 0) > gExperienceTables[gBaseStats[species].growthRate][nextLevel]) + { + SetMonData(mon, MON_DATA_LEVEL, &nextLevel); + return TRUE; + } + else + { + return FALSE; + } +} + +u32 CanMonLearnTMHM(struct Pokemon *mon, u8 tm) +{ + u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + if (species == SPECIES_EGG) + { + return 0; + } + else if (tm < 32) + { + u32 mask = 1 << tm; + return gTMHMLearnsets[species][0] & mask; + } + else + { + u32 mask = 1 << (tm - 32); + return gTMHMLearnsets[species][1] & mask; + } +} + +u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves) +{ + u16 learnedMoves[4]; + u8 numMoves = 0; + u16 species = GetMonData(mon, MON_DATA_SPECIES, 0); + u8 level = GetMonData(mon, MON_DATA_LEVEL, 0); + int i, j, k; + + for (i = 0; i < 4; i++) + learnedMoves[i] = GetMonData(mon, MON_DATA_MOVE1 + i, 0); + + for (i = 0; i < 20; i++) + { + u16 moveLevel; + + if (gLevelUpLearnsets[species][i] == 0xFFFF) + break; + + moveLevel = gLevelUpLearnsets[species][i] & 0xFE00; + + if (moveLevel <= (level << 9)) + { + for (j = 0; j < 4 && learnedMoves[j] != (gLevelUpLearnsets[species][i] & 0x1FF); j++) + ; + + if (j == 4) + { + for (k = 0; k < numMoves && moves[k] != (gLevelUpLearnsets[species][i] & 0x1FF); k++) + ; + + if (k == numMoves) + moves[numMoves++] = gLevelUpLearnsets[species][i] & 0x1FF; + } + } + } + + return numMoves; +} + +u8 GetLevelUpMovesBySpecies(u16 species, u16 *moves) +{ + u8 numMoves = 0; + int i; + + for (i = 0; i < 20 && gLevelUpLearnsets[species][i] != 0xFFFF; i++) + moves[numMoves++] = gLevelUpLearnsets[species][i] & 0x1FF; + + return numMoves; +} + +u8 sub_8040574(struct Pokemon *mon) +{ + u16 learnedMoves[4]; + u16 moves[20]; + u8 numMoves = 0; + u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + u8 level = GetMonData(mon, MON_DATA_LEVEL, 0); + int i, j, k; + + if (species == SPECIES_EGG) + return 0; + + for (i = 0; i < 4; i++) + learnedMoves[i] = GetMonData(mon, MON_DATA_MOVE1 + i, 0); + + for (i = 0; i < 20; i++) + { + u16 moveLevel; + + if (gLevelUpLearnsets[species][i] == 0xFFFF) + break; + + moveLevel = gLevelUpLearnsets[species][i] & 0xFE00; + + if (moveLevel <= (level << 9)) + { + for (j = 0; j < 4 && learnedMoves[j] != (gLevelUpLearnsets[species][i] & 0x1FF); j++) + ; + + if (j == 4) + { + for (k = 0; k < numMoves && moves[k] != (gLevelUpLearnsets[species][i] & 0x1FF); k++) + ; + + if (k == numMoves) + moves[numMoves++] = gLevelUpLearnsets[species][i] & 0x1FF; + } + } + } + + return numMoves; +} + +u16 SpeciesToPokedexNum(u16 species) +{ + if (IsNationalPokedexEnabled()) + { + return SpeciesToNationalPokedexNum(species); + } + else + { + species = SpeciesToHoennPokedexNum(species); + if (species <= 202) + return species; + return 0xFFFF; + } +} + +void ClearBattleMonForms(void) +{ + int i; + for (i = 0; i < 4; i++) + gBattleMonForms[i] = 0; +} + +u16 sub_8040728(void) +{ + if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE_GROUDON) + return BGM_BATTLE34; + if (gBattleTypeFlags & BATTLE_TYPE_REGI) + return BGM_BATTLE36; + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + return BGM_BATTLE20; + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) + { + switch (gTrainers[gTrainerBattleOpponent].trainerClass) + { + case 2: + case 0x31: + return BGM_BATTLE30; + case 3: + case 4: + case 0x32: + case 0x33: + return BGM_BATTLE31; + case 0x19: + return BGM_BATTLE32; + case 0x20: + return BGM_BATTLE33; + case 0x2E: + if (!StringCompare(gTrainers[gTrainerBattleOpponent].trainerName, BattleText_Wally)) + return BGM_BATTLE20; + return BGM_BATTLE35; + case 0x18: + return BGM_BATTLE38; + default: + return BGM_BATTLE20; + } + } + return BGM_BATTLE27; +} + +void sub_80408BC(void) +{ + ResetMapMusic(); + m4aMPlayAllStop(); + PlayBGM(sub_8040728()); +} + +void current_map_music_set__default_for_battle(u16 song) +{ + ResetMapMusic(); + m4aMPlayAllStop(); + if (song) + PlayNewMapMusic(song); + else + PlayNewMapMusic(sub_8040728()); +} + +const u8 *pokemon_get_pal(struct Pokemon *mon) +{ + u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); + u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 0); + return species_and_otid_get_pal(species, otId, personality); +} + +//Extracts the upper 16 bits of a 32-bit number +#define HIHALF(n) (((n) & 0xFFFF0000) >> 16) + +//Extracts the lower 16 bits of a 32-bit number +#define LOHALF(n) ((n) & 0xFFFF) + +const u8 *species_and_otid_get_pal(u16 species, u32 otId, u32 personality) +{ + u32 shinyValue; + + if (species > SPECIES_EGG) + return gMonPaletteTable[0].data; + + shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); + if (shinyValue < 8) + return gMonShinyPaletteTable[species].data; + else + return gMonPaletteTable[species].data; +} + +const struct CompressedSpritePalette *sub_8040990(struct Pokemon *mon) +{ + u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); + u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 0); + return sub_80409C8(species, otId, personality); +} + +const struct CompressedSpritePalette *sub_80409C8(u16 species, u32 otId , u32 personality) +{ + u32 shinyValue; + + shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); + if (shinyValue < 8) + return &gMonShinyPaletteTable[species]; + else + return &gMonPaletteTable[species]; +} + +bool8 IsHMMove2(u16 move) +{ + int i = 0; + while (gHMMoves[i] != 0xFFFF) + { + if (gHMMoves[i++] == move) + return TRUE; + } + return FALSE; +} + +bool8 sub_8040A3C(u16 species) +{ + return gBaseStats[species].unk19_7; +} + +s8 sub_8040A54(struct Pokemon *mon, u8 a2) +{ + u8 nature = GetNature(mon); + return gUnknown_083F7E28[nature * 5 + a2]; +} + +s8 sub_8040A7C(u32 personality, u8 a2) +{ + u8 nature = GetNatureFromPersonality(personality); + return gUnknown_083F7E28[nature * 5 + a2]; +} + +bool8 IsTradedMon(struct Pokemon *mon) +{ + u8 otName[8]; + u32 otId; + GetMonData(mon, MON_DATA_OT_NAME, otName); + otId = GetMonData(mon, MON_DATA_OT_ID, 0); + return IsOtherTrainer(otId, otName); +} + +bool8 IsOtherTrainer(u32 otId, u8 *otName) +{ + if (otId == (gSaveBlock2.playerTrainerId[0] | (gSaveBlock2.playerTrainerId[1] << 8) | (gSaveBlock2.playerTrainerId[2] << 16) | (gSaveBlock2.playerTrainerId[3] << 24))) + { + int i; + + for (i = 0; otName[i] != EOS; i++) + if (otName[i] != gSaveBlock2.playerName[i]) + return TRUE; + return FALSE; + } + + return TRUE; +} + +void BoxMonRestorePP(struct BoxPokemon *); + +void MonRestorePP(struct Pokemon *mon) +{ + BoxMonRestorePP(&mon->box); +} + +void BoxMonRestorePP(struct BoxPokemon *boxMon) +{ + int i; + + for (i = 0; i < 4; i++) + { + if (GetBoxMonData(boxMon, MON_DATA_MOVE1 + i, 0)) + { + u16 move = GetBoxMonData(boxMon, MON_DATA_MOVE1 + i, 0); + u16 bonus = GetBoxMonData(boxMon, MON_DATA_PP_BONUSES, 0); + u8 pp = CalculatePPWithBonus(move, bonus, i); + SetBoxMonData(boxMon, MON_DATA_PP1 + i, &pp); + } + } +} + +void sub_8040B8C(void) +{ + gLastUsedAbility = BATTLE_STRUCT->filler1_2[0x37]; + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 4; + gBattleTextBuff1[2] = BATTLE_STRUCT->filler1[0x34]; + gBattleTextBuff1[4] = EOS; + if (!GetBankSide(BATTLE_STRUCT->filler1[0x34])) + gBattleTextBuff1[3] = pokemon_order_func(gBattlePartyID[BATTLE_STRUCT->filler1[0x34]]); + else + gBattleTextBuff1[3] = gBattlePartyID[BATTLE_STRUCT->filler1[0x34]]; + gBattleTextBuff2[0] = 0xFD; + gBattleTextBuff2[1] = 4; + gBattleTextBuff2[2] = gBankInMenu; + gBattleTextBuff2[3] = pokemon_order_func(gBattlePartyID[gBankInMenu]); + gBattleTextBuff2[4] = EOS; + StrCpyDecodeBattle(BattleText_PreventedSwitch, gStringVar4); +} + +void SetWildMonHeldItem(void) +{ + if (!(gBattleTypeFlags & (BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_TRAINER))) + { + u16 rnd = Random() % 100; + u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, 0); + if (gBaseStats[species].item1 == gBaseStats[species].item2) + { + SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, (u8 *)&gBaseStats[species].item1); + return; + } + + if (rnd > 44) + { + if (rnd <= 94) + SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, (u8 *)&gBaseStats[species].item1); + else + SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, (u8 *)&gBaseStats[species].item2); + } + } +} + +bool8 IsShinyOtIdPersonality(u32, u32); + +bool8 IsShiny(struct Pokemon *mon) +{ + u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); + u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 0); + return IsShinyOtIdPersonality(otId, personality); +} + +bool8 IsShinyOtIdPersonality(u32 otId, u32 personality) +{ + bool8 retVal = FALSE; + u32 shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); + if (shinyValue < 8) + retVal = TRUE; + return retVal; +} + +u8 *sub_8040D08(void) +{ + u8 id = GetMultiplayerId(); + return gLinkPlayers[sub_803FC34(gLinkPlayers[id].lp_field_18 ^ 2)].name; +} + +bool32 sub_8040D3C(u16 species, u8 *name, u8 language) +{ + bool32 retVal = FALSE; + if (species == SPECIES_NIDORAN_M || species == SPECIES_NIDORAN_F) + { + u8 *speciesName; + if (language == GAME_LANGUAGE) + { + speciesName = gSpeciesNames[species]; + } + else + { + if (species == SPECIES_NIDORAN_M) + speciesName = gJapaneseNidoranNames[0]; + else + speciesName = gJapaneseNidoranNames[1]; + } + if (!StringCompareWithoutExtCtrlCodes(name, speciesName)) + retVal = TRUE; + else + retVal = FALSE; + } + return retVal; +} + +bool32 sub_8040D8C(u16 species, u8 *name) +{ + u8 language = GAME_LANGUAGE; + if (name[0] == 0xFC && name[1] == 21) + language = LANGUAGE_JAPANESE; + return sub_8040D3C(species, name, language); +} + +bool32 unref_sub_8040DAC(struct Pokemon *mon) +{ + u8 name[12]; + u16 species = GetMonData(mon, MON_DATA_SPECIES, 0); + u8 language = GetMonData(mon, MON_DATA_LANGUAGE, 0); + GetMonData(mon, MON_DATA_NICKNAME, name); + return sub_8040D3C(species, name, language); +} diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c index 21f386f2d..f2222bd3b 100644 --- a/src/pokemon_size_record.c +++ b/src/pokemon_size_record.c @@ -1,12 +1,12 @@ #include "global.h" #include "pokemon_size_record.h" -#include "string_util.h" +#include "data2.h" +#include "event_data.h" +#include "pokedex.h" #include "species.h" -#include "flag.h" -#include "var.h" - -extern u16 SpeciesToNationalPokedexNum(u16); -extern u16 sub_8090D54(u16, u8); +#include "string_util.h" +#include "strings2.h" +#include "text.h" struct UnknownStruct { @@ -15,15 +15,28 @@ struct UnknownStruct u16 unk4; }; -extern struct UnknownStruct gUnknown_083D180C[]; -extern u8 gOtherText_DecimalPoint[]; -extern u8 gOtherText_Marco[]; extern u16 gScriptResult; -extern u8 gSpeciesNames[][11]; -extern u8 gUnknown_083D188E[]; -#define VAR_SHROOMISH_SIZE_RECORD 0x4047 -#define VAR_BARBOACH_SIZE_RECORD 0x404F +static const struct UnknownStruct sBigMonSizeTable[] = +{ + { 290, 1, 0 }, + { 300, 1, 10 }, + { 400, 2, 110 }, + { 500, 4, 310 }, + { 600, 20, 710 }, + { 700, 50, 2710 }, + { 800, 100, 7710 }, + { 900, 150, 17710 }, + { 1000, 150, 32710 }, + { 1100, 100, -17826 }, + { 1200, 50, -7826 }, + { 1300, 20, -2826 }, + { 1400, 5, -826 }, + { 1500, 2, -326 }, + { 1600, 1, -126 }, + { 1700, 1, -26 }, +}; + #define CM_PER_INCH 2.54 static u32 GetMonSizeHash(struct Pokemon *pkmn) @@ -38,17 +51,17 @@ static u32 GetMonSizeHash(struct Pokemon *pkmn) u16 spDefIV = GetMonData(pkmn, MON_DATA_SPDEF_IV) & 0xF; u32 hibyte = ((attackIV ^ defenseIV) * hpIV) ^ (personality & 0xFF); u32 lobyte = ((spAtkIV ^ spDefIV) * speedIV) ^ (personality >> 8); - + return (hibyte << 8) + lobyte; } static u8 TranslateBigMonSizeTableIndex(u16 a) { u8 i; - - for(i = 1; i < 15; i++) + + for (i = 1; i < 15; i++) { - if(a < gUnknown_083D180C[i].unk4) + if (a < sBigMonSizeTable[i].unk4) return i - 1; } return i; @@ -59,54 +72,65 @@ static u32 GetMonSize(u16 species, u16 b) u64 unk2; u64 unk4; u64 unk0; - u32 r7; + u32 height; u32 var; - - r7 = sub_8090D54(SpeciesToNationalPokedexNum(species), 0); + + height = GetPokedexHeightWeight(SpeciesToNationalPokedexNum(species), 0); var = TranslateBigMonSizeTableIndex(b); - unk0 = gUnknown_083D180C[var].unk0; - unk2 = gUnknown_083D180C[var].unk2; - unk4 = gUnknown_083D180C[var].unk4; + unk0 = sBigMonSizeTable[var].unk0; + unk2 = sBigMonSizeTable[var].unk2; + unk4 = sBigMonSizeTable[var].unk4; unk0 += (b - unk4) / unk2; - return r7 * unk0 / 10; + return height * unk0 / 10; } static void FormatMonSizeRecord(u8 *string, u32 size) { - u8 decimalPoint[2]; - - memcpy(decimalPoint, gOtherText_DecimalPoint, 2); +#if ENGLISH + u8 decimalPoint[] = _("."); +#elif GERMAN + u8 decimalPoint[] = _(","); +#endif + +#ifdef UNITS_IMPERIAL //Convert size from centimeters to inches size = (double)(size * 10) / (CM_PER_INCH * 10); +#endif + string = ConvertIntToDecimalStringN(string, size / 10, 0, 8); string = StringAppend(string, decimalPoint); ConvertIntToDecimalStringN(string, size % 10, 0, 1); } static u8 CompareMonSize(u16 species, u16 *sizeRecord) -{ - if(gScriptResult == 0xFF) +{ + if (gScriptResult == 0xFF) + { return 0; + } else { struct Pokemon *pkmn = &gPlayerParty[gScriptResult]; - + // UB: Too few arguments for function 'GetMonData' - if(GetMonData(pkmn, MON_DATA_IS_EGG) == TRUE || GetMonData(pkmn, MON_DATA_SPECIES) != species) + if (GetMonData(pkmn, MON_DATA_IS_EGG) == TRUE || GetMonData(pkmn, MON_DATA_SPECIES) != species) + { return 1; + } else { u32 oldSize; u32 newSize; u16 sizeParams; - u16 *ptr = &sizeParams; //Why the pointer? - - *ptr = GetMonSizeHash(pkmn); + + *(&sizeParams) = GetMonSizeHash(pkmn); newSize = GetMonSize(species, sizeParams); oldSize = GetMonSize(species, *sizeRecord); FormatMonSizeRecord(gStringVar2, newSize); - if(newSize <= oldSize) + if (newSize <= oldSize) + { return 2; + } else { *sizeRecord = sizeParams; @@ -120,10 +144,10 @@ static u8 CompareMonSize(u16 species, u16 *sizeRecord) static void GetMonSizeRecordInfo(u16 species, u16 *sizeRecord) { u32 size = GetMonSize(species, *sizeRecord); - + FormatMonSizeRecord(gStringVar3, size); StringCopy(gStringVar1, gSpeciesNames[species]); - if(*sizeRecord == 0x8100) + if (*sizeRecord == 0x8100) StringCopy(gStringVar2, gOtherText_Marco); else StringCopy(gStringVar2, gSaveBlock2.playerName); @@ -137,14 +161,14 @@ void InitShroomishSizeRecord(void) void GetShroomishSizeRecordInfo(void) { u16 *sizeRecord = GetVarPointer(VAR_SHROOMISH_SIZE_RECORD); - + GetMonSizeRecordInfo(SPECIES_SHROOMISH, sizeRecord); } void CompareShroomishSize(void) { u16 *sizeRecord = GetVarPointer(VAR_SHROOMISH_SIZE_RECORD); - + gScriptResult = CompareMonSize(SPECIES_SHROOMISH, sizeRecord); } @@ -156,39 +180,38 @@ void InitBarboachSizeRecord(void) void GetBarboachSizeRecordInfo(void) { u16 *sizeRecord = GetVarPointer(VAR_BARBOACH_SIZE_RECORD); - + GetMonSizeRecordInfo(SPECIES_BARBOACH, sizeRecord); } void CompareBarboachSize(void) { u16 *sizeRecord = GetVarPointer(VAR_BARBOACH_SIZE_RECORD); - + gScriptResult = CompareMonSize(SPECIES_BARBOACH, sizeRecord); } void GiveGiftRibbonToParty(u8 index, u8 ribbonId) { s32 i; - u8 arr[7]; bool32 gotRibbon = FALSE; u8 data = 1; - - memcpy(arr, gUnknown_083D188E, 7); - if(index < 11 && ribbonId < 65) + u8 arr[] = { 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E }; + + if (index < 11 && ribbonId < 65) { gSaveBlock1.giftRibbons[index] = ribbonId; - for(i = 0; i < 6; i++) + for (i = 0; i < 6; i++) { struct Pokemon *pkmn = &gPlayerParty[i]; - - if(GetMonData(pkmn, MON_DATA_SPECIES) != 0 && GetMonData(pkmn, MON_DATA_SANITY_BIT3) == 0) + + if (GetMonData(pkmn, MON_DATA_SPECIES) != 0 && GetMonData(pkmn, MON_DATA_SANITY_BIT3) == 0) { SetMonData(pkmn, arr[index], &data); gotRibbon = TRUE; } } - if(gotRibbon) + if (gotRibbon) FlagSet(SYS_RIBBON_GET); } } diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c new file mode 100644 index 000000000..0cab07fc1 --- /dev/null +++ b/src/pokemon_storage_system.c @@ -0,0 +1,97 @@ +#include "global.h" +#include "pokemon_storage_system.h" +#include "menu.h" +#include "string_util.h" + +struct StorageAction { + u8 *text; + u8 format; +}; + +extern const struct StorageAction gUnknown_083B6DF4[]; + +extern const u8 unk_2000000[]; + +#define gUnk2002694 (u8 *)(&unk_2000000[0x2694]) +#define gUnk20026A6 (u8 *)(&unk_2000000[0x26a6]) +#define gUnk20011fa (u8 *)(&unk_2000000[0x11fa]) +#define gUnk20026e4 (u8 *)(&unk_2000000[0x26e4]) + +void sub_8098898(u8 index) { + u8 *ptr; + + MenuDrawTextWindow(10, 16, 29, 19); + + switch (gUnknown_083B6DF4[index].format) + { + + case 2: + ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); + ptr = StringCopy(ptr, gUnk20011fa); + break; + + case 5: + ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); + ptr = StringCopy(ptr, gUnk20026e4); + break; + + case 1: + // {var} + " is selected." + ptr = StringCopy(gUnk2002694, gUnk20011fa); + ptr = StringCopy(ptr, gUnknown_083B6DF4[index].text); + break; + + case 4: + // {var} + " was released." + ptr = StringCopy(gUnk2002694, gUnk20026e4); +#if ENGLISH + ptr = StringCopy(ptr, gUnknown_083B6DF4[index].text); +#elif GERMAN + ptr = de_sub_8073174(gUnk2002694, gUnknown_083B6DF4[index].text); +#endif + break; + + case 3: + { + u8 *stringLength; + u8 *text; + + text = gUnknown_083B6DF4[index].text; + stringLength = &text[StringLength(text)] + 1; + + ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); + ptr = StringCopy(ptr, gUnk20011fa); + ptr = StringCopy(ptr, stringLength); + } + break; + + case 6: + // "Bye-bye, ".substr(0, -1) + {var} + "Bye-bye, !".substr(-1, 1) + { + u8 *stringLength; + u8 *text; + + text = gUnknown_083B6DF4[index].text; + stringLength = &text[StringLength(text)] - 1; + + ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); + ptr = StringCopy(ptr - 1, gUnk20026e4); + ptr = StringCopy(ptr, stringLength); + } + break; + + case 0: + default: + ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); + break; + } + + while (ptr < gUnk20026A6) + { + ptr[0] = CHAR_SPACE; + ptr++; + } + + ptr[0] = EOS; + MenuPrint(gUnk2002694, 11, 17); +} diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c new file mode 100644 index 000000000..00a0bea29 --- /dev/null +++ b/src/pokemon_summary_screen.c @@ -0,0 +1,180 @@ +#include "global.h" +#include "pokemon_summary_screen.h" +#include "link.h" +#include "menu.h" +#include "pokemon.h" +#include "region_map.h" +#include "string_util.h" +#include "strings2.h" +#include "tv.h" + +extern struct Pokemon *unk_2018000; + +bool8 PokemonSummaryScreen_CheckOT(struct Pokemon *mon) +{ + u32 trainerId; + + if (unk_2018000 == gEnemyParty) + { + u8 enemyId = GetMultiplayerId() ^ 1; + trainerId = gLinkPlayers[enemyId].trainerId & 0xFFFF; + StringCopy(gStringVar1, gLinkPlayers[enemyId].name); + StripExtCtrlCodes(gStringVar1); + } + else + { + trainerId = GetPlayerTrainerId() & 0xFFFF; + StringCopy(gStringVar1, gSaveBlock2.playerName); + } + + if (trainerId != (GetMonData(mon, MON_DATA_OT_ID) & 0xFFFF)) + return FALSE; + + GetMonData(mon, MON_DATA_OT_NAME, gStringVar2); + + if (!StringCompareWithoutExtCtrlCodes(gStringVar1, gStringVar2)) + return TRUE; + + return FALSE; +} + +void PokemonSummaryScreen_PrintEggTrainerMemo(struct Pokemon *mon, u8 left, u8 top) +{ + u8 locationMet; + u8 gameMet = GetMonData(mon, MON_DATA_MET_GAME); + + if (!(gameMet == VERSION_RUBY || gameMet == VERSION_SAPPHIRE || gameMet == VERSION_EMERALD)) + { + MenuPrint(gOtherText_EggObtainedInTrade, left, top); + return; + } + + locationMet = GetMonData(mon, MON_DATA_MET_LOCATION); + + if (locationMet == 255) + { + MenuPrint(gOtherText_EggNicePlace, left, top); + return; + } + + if (!PokemonSummaryScreen_CheckOT(mon)) + { + MenuPrint(gOtherText_EggObtainedInTrade, left, top); + return; + } + + asm(""); // needed to match for some reason + + if (locationMet == 253) + { + MenuPrint(gOtherText_EggHotSprings, left, top); + return; + } + + MenuPrint(gOtherText_EggDayCare, left, top); +} + +void PokemonSummaryScreen_PrintTrainerMemo(struct Pokemon *pokemon, u8 left, u8 top) +{ + u8 locationMet; + u8 gameMet; + u8 *ptr = gStringVar4; + u8 nature = GetNature(pokemon); + +#if ENGLISH + ptr = sub_80A1E9C(ptr, gNatureNames[nature], 14); + + if (nature != NATURE_BOLD && nature != NATURE_GENTLE) + { + ptr = StringCopy(ptr, gOtherText_Terminator4); + } + + ptr = StringCopy(ptr, gOtherText_Nature); +#elif GERMAN + ptr = StringCopy(gStringVar4, gOtherText_Nature); + ptr = sub_80A1E9C(ptr, gNatureNames[nature], 14); + ptr = StringCopy(ptr, gOtherText_Terminator4); +#endif + + if (PokemonSummaryScreen_CheckOT(pokemon) == TRUE) + { + locationMet = GetMonData(pokemon, MON_DATA_MET_LOCATION); + + if (GetMonData(pokemon, MON_DATA_MET_LEVEL) == 0) + { + ptr = PokemonSummaryScreen_CopyPokemonLevel(ptr, 5); + *ptr = CHAR_NEWLINE; + ptr++; + + CopyLocationName(gStringVar1, locationMet); + ptr = sub_80A1E9C(ptr, gStringVar1, 14); + StringCopy(ptr, gOtherText_Egg2); + } + else if (locationMet >= 88) + { + *ptr = CHAR_NEWLINE; + ptr++; + + StringCopy(ptr, gOtherText_ObtainedInTrade); + } + else + { + u8 levelMet = GetMonData(pokemon, MON_DATA_MET_LEVEL); + + ptr = PokemonSummaryScreen_CopyPokemonLevel(ptr, levelMet); + *ptr = CHAR_NEWLINE; + ptr++; + + CopyLocationName(gStringVar1, locationMet); + ptr = sub_80A1E9C(ptr, gStringVar1, 14); + StringCopy(ptr, gOtherText_Met); + } + } + else + { + gameMet = GetMonData(pokemon, MON_DATA_MET_GAME); + + if (!(gameMet == VERSION_RUBY || gameMet == VERSION_SAPPHIRE || gameMet == VERSION_EMERALD)) + { + *ptr = CHAR_NEWLINE; + ptr++; + + StringCopy(ptr, gOtherText_ObtainedInTrade); + } + else + { + locationMet = GetMonData(pokemon, MON_DATA_MET_LOCATION); + if (locationMet == 0xFF) + { + u8 levelMet = GetMonData(pokemon, MON_DATA_MET_LEVEL); + + ptr = PokemonSummaryScreen_CopyPokemonLevel(ptr, levelMet); + *ptr = CHAR_NEWLINE; + ptr++; + + StringCopy(ptr, gOtherText_FatefulEncounter); + } + else if (locationMet >= 88) + { + *ptr = CHAR_NEWLINE; + ptr++; + + StringCopy(ptr, gOtherText_ObtainedInTrade); + } + else + { + u8 levelMet = GetMonData(pokemon, MON_DATA_MET_LEVEL); + + ptr = PokemonSummaryScreen_CopyPokemonLevel(ptr, levelMet); + *ptr = CHAR_NEWLINE; + ptr++; + + CopyLocationName(gStringVar1, locationMet); + ptr = sub_80A1E9C(ptr, gStringVar1, 14); + StringCopy(ptr, gOtherText_Met2); + } + } + } + + MenuPrint(gStringVar4, left++, top++); +} diff --git a/src/pokenav.c b/src/pokenav.c new file mode 100644 index 000000000..3a386d865 --- /dev/null +++ b/src/pokenav.c @@ -0,0 +1,39 @@ +#include "global.h" +#include "pokenav.h" +#include "battle.h" +#include "data2.h" +#include "de_rom_8040FE0.h" +#include "string_util.h" + +void sub_80F700C(u8 *arg0, u16 arg1) { + struct Trainer *trainer; + u8 *ptr; + +#if ENGLISH + trainer = (struct Trainer *) &gTrainers[gUnknown_083DFEC4->unkCEE8[arg1].unk0]; +#elif GERMAN + const u16 trainerIndex = gUnknown_083DFEC4->unkCEE8[arg1].unk0; + trainer = (struct Trainer *) &gTrainers[trainerIndex]; +#endif + + ptr = arg0; + if (arg1 < gUnknown_083DFEC4->unkD158) + { +#if ENGLISH + ptr = StringCopy(ptr, gTrainerClassNames[trainer->trainerClass]); +#elif GERMAN + ptr = StringCopy(ptr, de_sub_8041024(0, trainerIndex)); +#endif + + ptr[0] = 0xFC; + ptr[1] = 0x13; + ptr[2] = 0x4B; + ptr += 3; + ptr = StringCopy(ptr, trainer->trainerName); + } + + ptr[0] = 0xFC; + ptr[1] = 0x13; + ptr[2] = 0x80; + ptr[3] = 0xFF; +} diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c new file mode 100644 index 000000000..8d85705c8 --- /dev/null +++ b/src/post_battle_event_funcs.c @@ -0,0 +1,69 @@ +#include "global.h" +#include "event_data.h" +#include "hall_of_fame.h" +#include "load_save.h" +#include "main.h" +#include "pokemon.h" +#include "rom4.h" +#include "script_pokemon_80C4.h" + +extern u8 gUnknown_02039324; + +int GameClear(void) +{ + int i; + bool32 ribbonGet; + + HealPlayerParty(); + + if (FlagGet(SYS_GAME_CLEAR) == TRUE) + { + gUnknown_02039324 = 1; + } + else + { + gUnknown_02039324 = 0; + FlagSet(SYS_GAME_CLEAR); + } + + if (!GetGameStat(1)) + SetGameStat(1, (gSaveBlock2.playTimeHours << 16) | (gSaveBlock2.playTimeMinutes << 8) | gSaveBlock2.playTimeSeconds); + + SetSecretBase2Field_9(); + + if (gSaveBlock2.playerGender == MALE) + sub_80537CC(1); + else + sub_80537CC(2); + + ribbonGet = FALSE; + + for (i = 0; i < 6; i++) + { + u8 val; + u8 *ptr = &val; + if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT2) + && !GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT3) + && !GetMonData(&gPlayerParty[i], MON_DATA_CHAMPION_RIBBON)) + { + *ptr = 1; + SetMonData(&gPlayerParty[i], MON_DATA_CHAMPION_RIBBON, ptr); + ribbonGet = TRUE; + } + } + + if (ribbonGet == TRUE) + { + IncrementGameStat(42); + FlagSet(SYS_RIBBON_GET); + } + + SetMainCallback2(sub_8141F90); + return 0; +} + +int sp0C8_whiteout_maybe(void) +{ + SetMainCallback2(CB2_WhiteOut); + return 0; +} diff --git a/src/record_mixing.c b/src/record_mixing.c index 281ab2803..e1a72cf2e 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -1,53 +1,58 @@ #include "global.h" #include "record_mixing.h" -#include "asm.h" +#include "battle_tower.h" +#include "cable_club.h" +#include "daycare.h" +#include "dewford_trend.h" +#include "event_data.h" +#include "fldeff_80C5CD4.h" #include "link.h" +#include "mauville_old_man.h" #include "menu.h" +#include "mystery_event_script.h" #include "rom4.h" #include "script.h" +#include "secret_base.h" #include "songs.h" #include "sound.h" #include "string_util.h" +#include "strings2.h" #include "task.h" -#include "flag.h" -#include "var.h" +#include "tv.h" + extern void *recordMixingSecretBases; extern void *recordMixingTvShows; extern void *gUnknown_083D0274; extern void *gUnknown_083D0278; extern void *recordMixingEasyChatPairs; -extern void *gUnknown_083D0280; extern void *gUnknown_083D0284; extern u8 gUnknown_083D0288[2]; extern u8 gUnknown_083D028A[2][3]; extern u8 gUnknown_083D0290[9][4]; -extern u8 gUnknown_02038738[]; //Don't know what type this points to +extern struct RecordMixing_UnknownStruct gUnknown_02038738; //Don't know what type this points to +extern struct RecordMixing_UnknownStruct *gUnknown_083D0280; extern u16 gSpecialVar_0x8005; extern u32 gUnknown_03005D2C; extern u8 gUnknown_03000718; extern u8 gUnknown_0300071C[]; -extern u8 gOtherText_MixingComplete[]; -extern u8 gOtherText_MixingRecordsWithFriend[]; extern bool8 gReceivedRemoteLinkPlayers; -extern u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE]; -extern u16 gBlockRecvBuffer[MAX_LINK_PLAYERS][BLOCK_BUFFER_SIZE / 2]; #define BUFFER_CHUNK_SIZE 200 void sub_80B929C(void) { - sub_8083A84(sub_80B9484); + sub_8083A84(Task_RecordMixing_Main); } struct PlayerRecords { struct SecretBaseRecord secretBases[20]; - u8 tvShows[25][36]; + TVShow tvShows[25]; u8 filler1004[0x40]; u8 filler1044[0x40]; struct EasyChatPair easyChatPairs[5]; - u8 filler10AC[0x78]; + struct RecordMixing_UnknownStruct filler10AC; u8 filler1124[0xA4]; u16 filler11C8[0x34]; }; @@ -55,152 +60,43 @@ struct PlayerRecords { extern struct PlayerRecords unk_2008000; extern struct PlayerRecords unk_2018000; -#ifdef NONMATCHING -void sub_80B92AC(void) +void RecordMixing_PrepareExchangePacket(void) { sub_80BC300(); sub_80C045C(); - + memcpy(unk_2018000.secretBases, recordMixingSecretBases, sizeof(unk_2018000.secretBases)); memcpy(unk_2018000.tvShows, recordMixingTvShows, sizeof(unk_2018000.tvShows)); memcpy(unk_2018000.filler1004, gUnknown_083D0274, 0x40); memcpy(unk_2018000.filler1044, gUnknown_083D0278, 0x40); memcpy(unk_2018000.easyChatPairs, recordMixingEasyChatPairs, 0x28); - memcpy(gUnknown_02038738, gSaveBlock1.filler_303C, 0x38); - memcpy(gUnknown_02038738 + 0x38, gSaveBlock1.filler_3074, 0x38); - sub_8041324(gSaveBlock1.filler_2F9C, gUnknown_02038738); - memcpy(unk_2018000.filler10AC, gUnknown_083D0280, 0x78); + gUnknown_02038738.data[0] = gSaveBlock1.filler_303C.data[0]; + gUnknown_02038738.data[1] = gSaveBlock1.filler_303C.data[1]; + sub_8041324(gSaveBlock1.daycareData, &gUnknown_02038738); + memcpy(&unk_2018000.filler10AC, gUnknown_083D0280, sizeof(struct RecordMixing_UnknownStruct)); memcpy(unk_2018000.filler1124, gUnknown_083D0284, 0xA4); - - if(GetMultiplayerId() == 0) + + if (GetMultiplayerId() == 0) unk_2018000.filler11C8[0] = sub_8126338(); } -#else -__attribute__((naked)) -void sub_80B92AC(void) -{ - asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - bl sub_80BC300\n\ - bl sub_80C045C\n\ - ldr r6, _080B9364 @ =0x02018000\n\ - ldr r0, _080B9368 @ =recordMixingSecretBases\n\ - ldr r1, [r0]\n\ - movs r2, 0xC8\n\ - lsls r2, 4\n\ - adds r0, r6, 0\n\ - bl memcpy\n\ - movs r1, 0xC8\n\ - lsls r1, 4\n\ - adds r0, r6, r1\n\ - ldr r1, _080B936C @ =recordMixingTvShows\n\ - ldr r1, [r1]\n\ - movs r2, 0xE1\n\ - lsls r2, 2\n\ - bl memcpy\n\ - ldr r2, _080B9370 @ =0x00001004\n\ - adds r0, r6, r2\n\ - ldr r1, _080B9374 @ =gUnknown_083D0274\n\ - ldr r1, [r1]\n\ - movs r2, 0x40\n\ - bl memcpy\n\ - ldr r1, _080B9378 @ =0x00001044\n\ - adds r0, r6, r1\n\ - ldr r1, _080B937C @ =gUnknown_083D0278\n\ - ldr r1, [r1]\n\ - movs r2, 0x40\n\ - bl memcpy\n\ - ldr r2, _080B9380 @ =0x00001084\n\ - adds r0, r6, r2\n\ - ldr r1, _080B9384 @ =recordMixingEasyChatPairs\n\ - ldr r1, [r1]\n\ - movs r2, 0x28\n\ - bl memcpy\n\ - ldr r5, _080B9388 @ =gUnknown_02038738\n\ - ldr r4, _080B938C @ =gSaveBlock1\n\ - ldr r0, _080B9390 @ =0x0000303c\n\ - adds r1, r4, r0\n\ - adds r0, r5, 0\n\ - movs r2, 0x38\n\ - bl memcpy\n\ - ldr r2, _080B9394 @ =0x00003074\n\ - adds r1, r4, r2\n\ - adds r0, r5, 0\n\ - adds r0, 0x38\n\ - movs r2, 0x38\n\ - bl memcpy\n\ - ldr r0, _080B9398 @ =0x00002f9c\n\ - adds r4, r0\n\ - adds r0, r4, 0\n\ - adds r1, r5, 0\n\ - bl sub_8041324\n\ - ldr r1, _080B939C @ =0x000010ac\n\ - adds r0, r6, r1\n\ - ldr r1, _080B93A0 @ =gUnknown_083D0280\n\ - ldr r1, [r1]\n\ - movs r2, 0x78\n\ - bl memcpy\n\ - ldr r2, _080B93A4 @ =0x00001124\n\ - adds r0, r6, r2\n\ - ldr r1, _080B93A8 @ =gUnknown_083D0284\n\ - ldr r1, [r1]\n\ - movs r2, 0xA4\n\ - bl memcpy\n\ - bl GetMultiplayerId\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - bne _080B935C\n\ - bl sub_8126338\n\ - ldr r2, _080B93AC @ =0x000011c8\n\ - adds r1, r6, r2\n\ - strh r0, [r1]\n\ -_080B935C:\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_080B9364: .4byte 0x02018000\n\ -_080B9368: .4byte recordMixingSecretBases\n\ -_080B936C: .4byte recordMixingTvShows\n\ -_080B9370: .4byte 0x00001004\n\ -_080B9374: .4byte gUnknown_083D0274\n\ -_080B9378: .4byte 0x00001044\n\ -_080B937C: .4byte gUnknown_083D0278\n\ -_080B9380: .4byte 0x00001084\n\ -_080B9384: .4byte recordMixingEasyChatPairs\n\ -_080B9388: .4byte gUnknown_02038738\n\ -_080B938C: .4byte gSaveBlock1\n\ -_080B9390: .4byte 0x0000303c\n\ -_080B9394: .4byte 0x00003074\n\ -_080B9398: .4byte 0x00002f9c\n\ -_080B939C: .4byte 0x000010ac\n\ -_080B93A0: .4byte gUnknown_083D0280\n\ -_080B93A4: .4byte 0x00001124\n\ -_080B93A8: .4byte gUnknown_083D0284\n\ -_080B93AC: .4byte 0x000011c8\n\ - .syntax divided\n"); -} -#endif - -#undef NONMATCHING -void sub_80B93B0(u32 a) +void RecordMixing_ReceiveExchangePacket(u32 a) { sub_80BD674(unk_2008000.secretBases, sizeof(struct PlayerRecords), a); - sub_80BFD44(unk_2008000.tvShows, sizeof(struct PlayerRecords), a); + sub_80BFD44((u8 *)unk_2008000.tvShows, sizeof(struct PlayerRecords), a); sub_80C0514(unk_2008000.filler1004, sizeof(struct PlayerRecords), a); sub_80B9B1C(unk_2008000.filler1044, sizeof(struct PlayerRecords), a); //UB: Too many arguments for function "sub_80FA4E4" sub_80FA4E4(unk_2008000.easyChatPairs, sizeof(struct PlayerRecords), a); - sub_80B9C6C(unk_2008000.filler10AC, sizeof(struct PlayerRecords), a, unk_2008000.tvShows); + sub_80B9C6C(&unk_2008000.filler10AC, sizeof(struct PlayerRecords), a, unk_2008000.tvShows); sub_80B9B70(unk_2008000.filler1124, sizeof(struct PlayerRecords), a); sub_80B9F3C(unk_2008000.filler11C8, a); } -void sub_80B9450(u8 taskId) +void Task_RecordMixing_SoundEffect(u8 taskId) { gTasks[taskId].data[0]++; - if(gTasks[taskId].data[0] == 50) + if (gTasks[taskId].data[0] == 50) { PlaySE(SE_W213); gTasks[taskId].data[0] = 0; @@ -208,25 +104,24 @@ void sub_80B9450(u8 taskId) } #define TD_STATE 0 - -void sub_80B9484(u8 taskId) +void Task_RecordMixing_Main(u8 taskId) { s16 *taskData = gTasks[taskId].data; - - switch(taskData[TD_STATE]) + + switch (taskData[TD_STATE]) { - case 0: + case 0: // init sub_8007270(gSpecialVar_0x8005); VarSet(0x4000, 1); gUnknown_03000718 = 0; - sub_80B92AC(); + RecordMixing_PrepareExchangePacket(); CreateRecordMixingSprite(); taskData[TD_STATE] = 1; taskData[10] = CreateTask(sub_80B95F0, 0x50); - taskData[15] = CreateTask(sub_80B9450, 0x51); + taskData[15] = CreateTask(Task_RecordMixing_SoundEffect, 0x51); break; - case 1: - if(!gTasks[taskData[10]].isActive) + case 1: // wait for sub_80B95F0 + if (!gTasks[taskData[10]].isActive) { taskData[TD_STATE] = 2; FlagSet(SYS_MIX_RECORD); @@ -239,8 +134,8 @@ void sub_80B9484(u8 taskId) taskData[TD_STATE] = 3; PlaySE(SE_W226); break; - case 3: - if(!gTasks[taskData[10]].isActive) + case 3: // wait for sub_80BA00C + if (!gTasks[taskData[10]].isActive) { taskData[TD_STATE] = 4; taskData[10] = sub_8083664(); @@ -249,13 +144,13 @@ void sub_80B9484(u8 taskId) taskData[8] = 0; } break; - case 4: + case 4: // wait 60 frames taskData[8]++; - if(taskData[8] > 60) + if (taskData[8] > 60) taskData[TD_STATE] = 5; break; case 5: - if(!gTasks[taskData[10]].isActive) + if (!gTasks[taskData[10]].isActive) { sub_8055588(); MenuZeroFillScreen(); @@ -269,20 +164,20 @@ void sub_80B9484(u8 taskId) void sub_80B95F0(u8 taskId) { struct Task *task = &gTasks[taskId]; - - switch(task->data[TD_STATE]) + + switch (task->data[TD_STATE]) { case 0: sub_80B9A78(); MenuDisplayMessageBox(); MenuPrint(gOtherText_MixingRecordsWithFriend, 2, 15); task->data[8] = 0x708; - task->data[TD_STATE] = 0x190; + task->data[TD_STATE] = 400; ClearLinkCallback_2(); break; - case 100: + case 100: // wait 20 frames task->data[12]++; - if(task->data[12] > 20) + if (task->data[12] > 20) { task->data[12] = 0; task->data[TD_STATE] = 101; @@ -291,10 +186,10 @@ void sub_80B95F0(u8 taskId) case 101: { u8 players = GetLinkPlayerCount_2(); - - if(IsLinkMaster() == 1) + + if (IsLinkMaster() == 1) { - if(players == sub_800820C()) + if (players == sub_800820C()) { PlaySE(0x15); task->data[TD_STATE] = 201; @@ -309,9 +204,9 @@ void sub_80B95F0(u8 taskId) break; } case 201: - if(sub_800820C() == GetLinkPlayerCount_2()) + if (sub_800820C() == GetLinkPlayerCount_2()) { - if(++task->data[12] > GetLinkPlayerCount_2() * 30) + if (++task->data[12] > GetLinkPlayerCount_2() * 30) { sub_8007F4C(); task->data[TD_STATE] = 1; @@ -319,19 +214,19 @@ void sub_80B95F0(u8 taskId) } break; case 301: - if(sub_800820C() == GetLinkPlayerCount_2()) + if (sub_800820C() == GetLinkPlayerCount_2()) task->data[TD_STATE] = 1; break; - case 400: + case 400: // wait 20 frames task->data[12]++; - if(task->data[12] > 20) + if (task->data[12] > 20) { task->data[TD_STATE] = 1; task->data[12] = 0; } break; - case 1: - if(gReceivedRemoteLinkPlayers) + case 1: // wait for handshake + if (gReceivedRemoteLinkPlayers) { ConvertIntToDecimalStringN(gStringVar1, GetMultiplayerId_(), 2, 2); task->data[TD_STATE] = 5; @@ -340,22 +235,22 @@ void sub_80B95F0(u8 taskId) case 2: { u8 subTaskId; - + task->data[6] = GetLinkPlayerCount_2(); task->data[TD_STATE] = 0; task->data[5] = GetMultiplayerId_(); - task->func = sub_80B97DC; + task->func = Task_RecordMixing_SendPacket; StorePtrInTaskData(&unk_2018000, &task->data[2]); - subTaskId = CreateTask(Task_CopyRecvBuffer, 0x50); + subTaskId = CreateTask(Task_RecordMixing_CopyReceiveBuffer, 0x50); task->data[10] = subTaskId; gTasks[subTaskId].data[0] = taskId; //StorePtrInTaskData((void*)0x2008000, &gTasks[subTaskId].data[5]); StorePtrInTaskData((u8 *)&unk_2018000 - 0x10000, &gTasks[subTaskId].data[5]); break; } - case 5: + case 5: // wait 60 frames task->data[10]++; - if(task->data[10] > 60) + if (task->data[10] > 60) { task->data[10] = 0; task->data[TD_STATE] = 2; @@ -364,101 +259,97 @@ void sub_80B95F0(u8 taskId) } } -void sub_80B97DC(u8 taskId) +void Task_RecordMixing_SendPacket(u8 taskId) { struct Task *task = &gTasks[taskId]; - - switch(task->data[TD_STATE]) + // does this send the data 24 times? + + switch (task->data[TD_STATE]) { - case 0: //Copy record data to send buffer - { - void *recordData = (u8 *)LoadPtrFromTaskData(&task->data[2]) + BUFFER_CHUNK_SIZE * task->data[4]; - - memcpy(gBlockSendBuffer, recordData, BUFFER_CHUNK_SIZE); - task->data[TD_STATE]++; - break; - } - case 1: - if(GetMultiplayerId() == 0) - sub_8007E9C(1); + case 0: //Copy record data to send buffer + { + void *recordData = (u8 *)LoadPtrFromTaskData(&task->data[2]) + BUFFER_CHUNK_SIZE * task->data[4]; + + memcpy(gBlockSendBuffer, recordData, BUFFER_CHUNK_SIZE); + task->data[TD_STATE]++; + break; + } + case 1: + if (GetMultiplayerId() == 0) + sub_8007E9C(1); + task->data[TD_STATE]++; + break; + case 2: + break; + case 3: + task->data[4]++; + if ((u16)task->data[4] == 24) task->data[TD_STATE]++; - break; - case 2: - break; - case 3: - task->data[4]++; - if((u16)task->data[4] == 24) - task->data[TD_STATE]++; - else - task->data[TD_STATE] = 0; - break; - case 4: - if(!gTasks[task->data[10]].isActive) - task->func = sub_80B9A1C; + else + task->data[TD_STATE] = 0; + break; + case 4: + if (!gTasks[task->data[10]].isActive) + task->func = Task_RecordMixing_SendPacket_SwitchToReceive; } } -void Task_CopyRecvBuffer(u8 taskId) +void Task_RecordMixing_CopyReceiveBuffer(u8 taskId) { struct Task *task = &gTasks[taskId]; s32 recvStatus = GetBlockReceivedStatus(); - u32 sp8 = 0; - - if(recvStatus == sub_8008198()) + u8 handledPlayers = 0; + + if (recvStatus == sub_8008198()) { u8 player; - - for(player = 0; player < GetLinkPlayerCount(); player++) + + for (player = 0; player < GetLinkPlayerCount(); player++) { - //_080B98D4 - u8 *ptr; void *src; u8 *dst; - - if((recvStatus >> player) & 1) + + if ((recvStatus >> player) & 1) { - ptr = LoadPtrFromTaskData(&task->data[5]); - dst = ptr + task->data[player + 1] * BUFFER_CHUNK_SIZE + player * sizeof(struct PlayerRecords); + dst = LoadPtrFromTaskData(&task->data[5]) + task->data[player + 1] * BUFFER_CHUNK_SIZE + player * sizeof(struct PlayerRecords); src = GetPlayerRecvBuffer(player); - if((u32)(task->data[player + 1] + 1) * BUFFER_CHUNK_SIZE > sizeof(struct PlayerRecords)) + if ((task->data[player + 1] + 1) * BUFFER_CHUNK_SIZE > sizeof(struct PlayerRecords)) memcpy(dst, src, sizeof(struct PlayerRecords) - task->data[player + 1] * BUFFER_CHUNK_SIZE); else memcpy(dst, src, BUFFER_CHUNK_SIZE); - //_080B993C ResetBlockReceivedFlag(player); task->data[player + 1]++; - if((u16)task->data[player + 1] == 0x18) - sp8 = (u8)(sp8 + 1); + if ((u16)task->data[player + 1] == 0x18) + handledPlayers++; } } - //line 828 gTasks[task->data[0]].data[0]++; } //_080B998A - if(sp8 == GetLinkPlayerCount()) + if (handledPlayers == GetLinkPlayerCount()) DestroyTask(taskId); } void sub_80B99B4(u8 taskId) { struct Task *task = &gTasks[taskId]; - - if(!gTasks[task->data[10]].isActive) + + if (!gTasks[task->data[10]].isActive) DestroyTask(taskId); } -void sub_80B99E8(u8 taskId) +void Task_RecordMixing_ReceivePacket(u8 taskId) { struct Task *task = &gTasks[taskId]; - + task->func = sub_80B99B4; - if(gUnknown_03000718 == 1) - sub_80B93B0(task->data[5]); + if (gUnknown_03000718 == 1) + RecordMixing_ReceiveExchangePacket(task->data[5]); } -void sub_80B9A1C(u8 taskId) +void Task_RecordMixing_SendPacket_SwitchToReceive(u8 taskId) { - gTasks[taskId].func = sub_80B99E8; + gTasks[taskId].func = Task_RecordMixing_ReceivePacket; gUnknown_03000718 = 1; } @@ -493,21 +384,21 @@ void sub_80B9A88(u8 *a) u32 i; u32 id; u32 players = GetLinkPlayerCount(); - - switch(players) + + switch (players) { case 2: - for(i = 0; i < 2; i++) + for (i = 0; i < 2; i++) a[i] = gUnknown_083D0288[i]; break; case 3: id = GetLinkPlayerTrainerId(0) % 2; - for(i = 0; i < 3; i++) + for (i = 0; i < 3; i++) a[i] = gUnknown_083D028A[id][i]; break; case 4: id = GetLinkPlayerTrainerId(0) % 9; - for(i = 0; i < 4; i++) + for (i = 0; i < 4; i++) a[i] = gUnknown_083D0290[id][i]; break; default: @@ -519,7 +410,7 @@ void sub_80B9B1C(u8 *a, size_t size, u8 index) { u8 arr[4]; u8 *ptr; - + sub_80B9A88(arr); //Probably not how it was originally written, but this matches. memcpy(a + index * size, (ptr = gUnknown_083D0278), 0x40); @@ -539,83 +430,90 @@ u8 sub_80B9BBC(u16 *a) return a[16]; } +#undef NONMATCHING #ifdef NONMATCHING -void sub_80B9BC4(u32 a, u32 b, u32 c, u32 d) +void sub_80B9BC4(struct RecordMixing_UnknownStruct *a, size_t b, u8 c[][2], u8 d, u8 e) { + struct RecordMixing_UnknownStructSub *offA; + struct RecordMixing_UnknownStructSub *offB; + struct RecordMixing_UnknownStructSub v0; + v0 = (offA = ((struct RecordMixing_UnknownStruct *)(b * c[d][0] + (u32)&a))->data)[c[d][1]]; + offA[c[d][1]] = (offB = ((struct RecordMixing_UnknownStruct *)(b * c[e][0] + (u32)&a))->data)[c[e][1]]; + offB[c[e][1]] = v0; //ToDo: Figure out what this strange stack usage is } #else __attribute__((naked)) -void sub_80B9BC4(u32 a, u32 b, u32 c, u32 d) +void sub_80B9BC4(struct RecordMixing_UnknownStruct *a, size_t b, u8 c[][2], u8 d, u8 e) { asm(".syntax unified\n\ push {r4-r6,lr}\n\ - mov r6, r10\n\ - mov r5, r9\n\ - mov r4, r8\n\ - push {r4-r6}\n\ - sub sp, 0x38\n\ - mov r8, r0\n\ - mov r10, r1\n\ - mov r9, r2\n\ - adds r4, r3, 0\n\ - ldr r5, [sp, 0x54]\n\ - lsls r4, 24\n\ - lsls r5, 24\n\ - lsrs r5, 24\n\ - lsrs r4, 23\n\ - add r4, r9\n\ - ldrb r0, [r4]\n\ - mov r6, r10\n\ - muls r6, r0\n\ - add r6, r8\n\ - ldrb r0, [r4, 0x1]\n\ - lsls r1, r0, 3\n\ - subs r1, r0\n\ - lsls r1, 3\n\ - adds r1, r6, r1\n\ - mov r0, sp\n\ - movs r2, 0x38\n\ - bl memcpy\n\ - lsls r5, 1\n\ - add r5, r9\n\ - ldrb r0, [r5]\n\ - mov r1, r10\n\ - muls r1, r0\n\ - adds r0, r1, 0\n\ - add r8, r0\n\ - ldrb r1, [r4, 0x1]\n\ - lsls r0, r1, 3\n\ - subs r0, r1\n\ - lsls r0, 3\n\ - adds r6, r0\n\ - ldrb r0, [r5, 0x1]\n\ - lsls r1, r0, 3\n\ - subs r1, r0\n\ - lsls r1, 3\n\ - add r1, r8\n\ - adds r0, r6, 0\n\ - movs r2, 0x38\n\ - bl memcpy\n\ - ldrb r1, [r5, 0x1]\n\ - lsls r0, r1, 3\n\ - subs r0, r1\n\ - lsls r0, 3\n\ - add r8, r0\n\ - mov r0, r8\n\ - mov r1, sp\n\ - movs r2, 0x38\n\ - bl memcpy\n\ - add sp, 0x38\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ + mov r6, r10\n\ + mov r5, r9\n\ + mov r4, r8\n\ + push {r4-r6}\n\ + sub sp, 0x38\n\ + mov r8, r0\n\ + mov r10, r1\n\ + mov r9, r2\n\ + adds r4, r3, 0\n\ + ldr r5, [sp, 0x54]\n\ + lsls r4, 24\n\ + lsls r5, 24\n\ + lsrs r5, 24\n\ + lsrs r4, 23\n\ + add r4, r9\n\ + ldrb r0, [r4]\n\ + mov r6, r10\n\ + muls r6, r0\n\ + add r6, r8\n\ + ldrb r0, [r4, 0x1]\n\ + lsls r1, r0, 3\n\ + subs r1, r0\n\ + lsls r1, 3\n\ + adds r1, r6, r1\n\ + mov r0, sp\n\ + movs r2, 0x38\n\ + bl memcpy\n\ + lsls r5, 1\n\ + add r5, r9\n\ + ldrb r0, [r5]\n\ + mov r1, r10\n\ + muls r1, r0\n\ + adds r0, r1, 0\n\ + add r8, r0\n\ + ldrb r1, [r4, 0x1]\n\ + lsls r0, r1, 3\n\ + subs r0, r1\n\ + lsls r0, 3\n\ + adds r6, r0\n\ + ldrb r0, [r5, 0x1]\n\ + lsls r1, r0, 3\n\ + subs r1, r0\n\ + lsls r1, 3\n\ + add r1, r8\n\ + adds r0, r6, 0\n\ + movs r2, 0x38\n\ + bl memcpy\n\ + ldrb r1, [r5, 0x1]\n\ + lsls r0, r1, 3\n\ + subs r0, r1\n\ + lsls r0, 3\n\ + add r8, r0\n\ + mov r0, r8\n\ + mov r1, sp\n\ + movs r2, 0x38\n\ + bl memcpy\n\ + add sp, 0x38\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ .syntax divided\n"); } #endif @@ -624,81 +522,9 @@ u8 sub_80B9C4C(u8 *a) { int i; u8 r2 = 0; - - for(i = 0; i < 0x100; i++) + + for (i = 0; i < 0x100; i++) r2 += a[i]; return r2; } -struct UnkStruct1 -{ - u8 unk0[4]; - u8 unk4[4]; - u8 unk8[4]; - u8 fillerC[0x10]; - u8 unk1C[4][2]; - u8 filler24[8]; - void *unk2C; - u32 unk30; - u32 unk34; - void *unk38; - u32 unk3C; - u32 unk40; - u8 filler44[4]; - u32 unk48; - u32 unk4C; - u32 unk50; - -}; - -/* -//Not finished -extern void sub_80B9C6C(void *a, u32 b, u8 c, void *d) -{ - struct UnkStruct1 s; - u16 r8; - u16 r3; - - s.unk2C = a; - s.unk30 = b; - s.unk38 = d; - s.unk34 = c; - s.unk40 = Random(); - SeedRng(gLinkPlayers[0].trainerId); - r8 = GetLinkPlayerCount(); - r3 = 0; - - s.unk4C = 12; - - while(r3 < 4) - { - - s.unk4[r3] |= 0xFF; - s.unk8[r3] = 0; - - s.unk1C[r3][0] = 0; - s.unk1C[r3][1] = 0; - r3++; - } - s.unk3C = 0; - r3 = 0; - s.unk50 = r8 << 16; - s.unk48 = s.unk30 * s.unk34; - - if(s.unk3C < r8) - { - do //_080B9D00 - { - u32 *r6 = (u32 *)(s.unk2C + s.unk30 * r3); - if(r6[0x1C] != 0 && r6[0x1C] > 0) - { - - } - //_080B9D3C - } - while(r3 < r8); - } - //_080B9D46 -} -*/ - diff --git a/src/roamer.c b/src/roamer.c new file mode 100644 index 000000000..948828d5e --- /dev/null +++ b/src/roamer.c @@ -0,0 +1,226 @@ +#include "global.h" +#include "roamer.h" +#include "pokemon.h" +#include "rng.h" +#include "species.h" + +#ifdef SAPPHIRE +#define ROAMER_SPECIES SPECIES_LATIAS +#else +#define ROAMER_SPECIES SPECIES_LATIOS +#endif + +enum +{ + MAP_GRP = 0, // map group + MAP_NUM = 1, // map number +}; + +EWRAM_DATA static u8 sLocationHistory[3][2] = {0}; +EWRAM_DATA static u8 sRoamerLocation[2] = {0}; + +static const u8 sRoamerLocations[][6] = +{ + { 0x19, 0x1A, 0x20, 0x21, 0x31, 0xFF }, + { 0x1A, 0x19, 0x20, 0x21, 0xFF, 0xFF }, + { 0x20, 0x1A, 0x19, 0x21, 0xFF, 0xFF }, + { 0x21, 0x20, 0x19, 0x1A, 0x22, 0x26 }, + { 0x22, 0x21, 0x23, 0xFF, 0xFF, 0xFF }, + { 0x23, 0x22, 0x24, 0xFF, 0xFF, 0xFF }, + { 0x24, 0x23, 0x25, 0x26, 0xFF, 0xFF }, + { 0x25, 0x24, 0x26, 0xFF, 0xFF, 0xFF }, + { 0x26, 0x25, 0x21, 0xFF, 0xFF, 0xFF }, + { 0x27, 0x24, 0x28, 0x29, 0xFF, 0xFF }, + { 0x28, 0x27, 0x2A, 0xFF, 0xFF, 0xFF }, + { 0x29, 0x27, 0x2A, 0xFF, 0xFF, 0xFF }, + { 0x2A, 0x28, 0x29, 0x2B, 0xFF, 0xFF }, + { 0x2B, 0x2A, 0x2C, 0xFF, 0xFF, 0xFF }, + { 0x2C, 0x2B, 0x2D, 0xFF, 0xFF, 0xFF }, + { 0x2D, 0x2C, 0x2E, 0xFF, 0xFF, 0xFF }, + { 0x2E, 0x2D, 0x2F, 0xFF, 0xFF, 0xFF }, + { 0x2F, 0x2E, 0x30, 0xFF, 0xFF, 0xFF }, + { 0x30, 0x2F, 0x31, 0xFF, 0xFF, 0xFF }, + { 0x31, 0x30, 0x19, 0xFF, 0xFF, 0xFF }, + { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, +}; + +void ClearRoamerData(void) +{ + memset(&gSaveBlock1.roamer, 0, sizeof(gSaveBlock1.roamer)); +} + +void ClearRoamerLocationData(void) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + sLocationHistory[i][MAP_GRP] = 0; + sLocationHistory[i][MAP_NUM] = 0; + } + + sRoamerLocation[MAP_GRP] = 0; + sRoamerLocation[MAP_NUM] = 0; +} + +void CreateInitialRoamerMon(void) +{ + struct Roamer *roamer; + CreateMon(&gEnemyParty[0], ROAMER_SPECIES, 40, 0x20, 0, 0, 0, 0); + roamer = &gSaveBlock1.roamer; + roamer->species = ROAMER_SPECIES; + roamer->level = 40; + roamer->status = 0; + roamer->active = TRUE; + roamer->ivs = GetMonData(&gEnemyParty[0], MON_DATA_IVS); + roamer->personality = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY); + roamer->hp = GetMonData(&gEnemyParty[0], MON_DATA_MAX_HP); + roamer->cool = GetMonData(&gEnemyParty[0], MON_DATA_COOL); + roamer->beauty = GetMonData(&gEnemyParty[0], MON_DATA_BEAUTY); + roamer->cute = GetMonData(&gEnemyParty[0], MON_DATA_CUTE); + roamer->smart = GetMonData(&gEnemyParty[0], MON_DATA_SMART); + roamer->tough = GetMonData(&gEnemyParty[0], MON_DATA_TOUGH); + sRoamerLocation[MAP_GRP] = 0; + sRoamerLocation[MAP_NUM] = sRoamerLocations[Random() % 20][0]; +} + +void InitRoamer(void) +{ + ClearRoamerData(); + ClearRoamerLocationData(); + CreateInitialRoamerMon(); +} + +void UpdateLocationHistoryForRoamer(void) +{ + sLocationHistory[2][MAP_GRP] = sLocationHistory[1][MAP_GRP]; + sLocationHistory[2][MAP_NUM] = sLocationHistory[1][MAP_NUM]; + + sLocationHistory[1][MAP_GRP] = sLocationHistory[0][MAP_GRP]; + sLocationHistory[1][MAP_NUM] = sLocationHistory[0][MAP_NUM]; + + sLocationHistory[0][MAP_GRP] = gSaveBlock1.location.mapGroup; + sLocationHistory[0][MAP_NUM] = gSaveBlock1.location.mapNum; +} + +void RoamerMoveToOtherLocationSet(void) +{ + u8 val = 0; + struct Roamer *roamer = &gSaveBlock1.roamer; + + if (!roamer->active) + return; + + sRoamerLocation[MAP_GRP] = val; + + while (1) + { + val = sRoamerLocations[Random() % 20][0]; + if (sRoamerLocation[MAP_NUM] != val) + { + sRoamerLocation[MAP_NUM] = val; + return; + } + } +} + +void RoamerMove(void) +{ + u8 locSet = 0; + + if ((Random() % 16) == 0) + { + RoamerMoveToOtherLocationSet(); + } + else + { + struct Roamer *roamer = &gSaveBlock1.roamer; + + if (!roamer->active) + return; + + while (locSet < 20) + { + if (sRoamerLocation[MAP_NUM] == sRoamerLocations[locSet][0]) + { + u8 mapNum; + while (1) + { + mapNum = sRoamerLocations[locSet][(Random() % 5) + 1]; + if (!(sLocationHistory[2][MAP_GRP] == 0 && sLocationHistory[2][MAP_NUM] == mapNum) && mapNum != 0xFF) + break; + } + sRoamerLocation[MAP_NUM] = mapNum; + return; + } + locSet++; + } + } +} + +bool8 IsRoamerAt(u8 mapGroup, u8 mapNum) +{ + struct Roamer *roamer = &gSaveBlock1.roamer; + + if (roamer->active && mapGroup == sRoamerLocation[MAP_GRP] && mapNum == sRoamerLocation[MAP_NUM]) + return TRUE; + else + return FALSE; +} + +void CreateRoamerMonInstance(void) +{ + struct Pokemon *mon = &gEnemyParty[0]; + struct Roamer *roamer = &gSaveBlock1.roamer; + CreateMonWithIVsPersonality(mon, roamer->species, roamer->level, roamer->ivs, roamer->personality); + SetMonData(mon, MON_DATA_STATUS, (u8 *)&roamer->status); + SetMonData(mon, MON_DATA_HP, (u8 *)&roamer->hp); + SetMonData(mon, MON_DATA_COOL, (u8 *)&roamer->cool); + SetMonData(mon, MON_DATA_BEAUTY, (u8 *)&roamer->beauty); + SetMonData(mon, MON_DATA_CUTE, (u8 *)&roamer->cute); + SetMonData(mon, MON_DATA_SMART, (u8 *)&roamer->smart); + SetMonData(mon, MON_DATA_TOUGH, (u8 *)&roamer->tough); +} + +bool8 TryStartRoamerEncounter(void) +{ + if (IsRoamerAt(gSaveBlock1.location.mapGroup, gSaveBlock1.location.mapNum) == TRUE && (Random() % 4) == 0) + { + CreateRoamerMonInstance(); + return TRUE; + } + else + { + return FALSE; + } +} + +void UpdateRoamerHPStatus(struct Pokemon *mon) +{ + struct Roamer *roamer; + u16 hp; + u8 status; + + hp = GetMonData(mon, MON_DATA_HP); + + roamer = &gSaveBlock1.roamer; + roamer->hp = hp; + + status = GetMonData(mon, MON_DATA_STATUS); + + roamer->status = status; + + RoamerMoveToOtherLocationSet(); +} + +void SetRoamerInactive(void) +{ + struct Roamer *roamer = &gSaveBlock1.roamer; + roamer->active = FALSE; +} + +void GetRoamerLocation(u8 *mapGroup, u8 *mapNum) +{ + *mapGroup = sRoamerLocation[MAP_GRP]; + *mapNum = sRoamerLocation[MAP_NUM]; +} diff --git a/src/rom3.c b/src/rom3.c new file mode 100644 index 000000000..9d8d39f91 --- /dev/null +++ b/src/rom3.c @@ -0,0 +1,1387 @@ +#include "global.h" +#include "rom3.h" +#include "battle.h" +#include "battle_811DA74.h" +#include "battle_ai.h" +#include "battle_anim.h" +#include "battle_anim_81258BC.h" +#include "battle_anim_8137220.h" +#include "cable_club.h" +#include "items.h" +#include "link.h" +#include "pokemon.h" +#include "rom_8094928.h" +#include "species.h" +#include "task.h" +#include "util.h" + +extern u8 unk_2000000[]; + +#define EWRAM_14000 ((u8 *)(unk_2000000 + 0x14000)) +#define EWRAM_15000 ((u8 *)(unk_2000000 + 0x15000)) + +extern u16 gBattleTypeFlags; +extern u16 gBattleWeather; +extern struct BattlePokemon gBattleMons[]; + +extern u8 gUnknown_020238C4; +extern u8 gUnknown_020238C5; +extern u8 gUnknown_020238C6; +extern u32 gUnknown_020239FC; +extern u8 gBattleBufferA[][0x200]; +extern u8 gBattleBufferB[][0x200]; +extern u8 gActiveBank; +extern u32 gBattleExecBuffer; +extern u8 gNoOfAllBanks; +extern u16 gBattlePartyID[]; +extern u8 gBanksBySide[]; +extern u16 gCurrentMove; +extern u16 gUnknown_02024BE8; +extern u16 gLastUsedItem; +extern u8 gLastUsedAbility; +extern u8 gBankAttacker; +extern u8 gBankTarget; +extern u8 gEffectBank; +extern u8 gStringBank; +extern u8 gAbsentBankFlags; +extern u8 gMultiHitCounter; +extern u8 gUnknown_02024C78; +extern u8 gBattleOutcome; +extern u8 gActionSelectionCursor[]; +extern u8 gMoveSelectionCursor[]; +extern u8 gBattleBuffersTransferData[]; +extern u8 gBattleTextBuff1[]; +extern u8 gBattleTextBuff2[]; +extern u8 gBattleTextBuff3[]; +extern void (*gBattleMainFunc)(void); +extern void (*gBattleBankFunc[])(void); + +void sub_800B858(void) +{ + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + OpenLink(); + CreateTask(sub_8083C50, 0); + sub_800BF28(); + } +} + +void setup_poochyena_battle(void) +{ + s32 i; + + gBattleMainFunc = nullsub_41; + for (i = 0; i < 4; i++) + { + gBattleBankFunc[i] = nullsub_91; + gBanksBySide[i] = 0xFF; + gActionSelectionCursor[i] = 0; + gMoveSelectionCursor[i] = 0; + } + sub_800B858(); + gBattleExecBuffer = 0; + battle_anim_clear_some_data(); + ClearBattleMonForms(); + BattleAI_HandleItemUseBeforeAISetup(); + if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE) + { + ZeroEnemyPartyMons(); + CreateMon(&gEnemyParty[0], SPECIES_POOCHYENA, 2, 32, 0, 0, 0, 0); + i = ITEM_NONE; + SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, (u8 *)&i); + } + gUnknown_020239FC = 0; + gUnknown_02024C78 = 0; +} + +void sub_800B950(void) +{ + s32 i; + + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + sub_800BA78(); + else + sub_800B9A8(); + sub_800BD54(); + if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) + { + for (i = 0; i < gNoOfAllBanks; i++) + sub_8094978(i, 0); + } +} + +void sub_800B9A8(void) +{ + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) + { + gBattleMainFunc = sub_8010800; + if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) + gBattleBankFunc[0] = SetBankFuncToSafariBufferRunCommand; + else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) + gBattleBankFunc[0] = SetBankFuncToWallyBufferRunCommand; + else + gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBanksBySide[0] = 0; + gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBanksBySide[1] = 1; + gNoOfAllBanks = 2; + } + else + { + gBattleMainFunc = sub_8010800; + gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBanksBySide[0] = 0; + gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBanksBySide[1] = 1; + gBattleBankFunc[2] = SetBankFuncToPlayerBufferRunCommand; + gBanksBySide[2] = 2; + gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBanksBySide[3] = 3; + gNoOfAllBanks = 4; + } +} + +void sub_800BA78(void) +{ + u8 multiplayerId; + int i; + + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) + { + if (gBattleTypeFlags & BATTLE_TYPE_WILD) + { + gBattleMainFunc = sub_8010800; + gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBanksBySide[0] = 0; + gBattleBankFunc[1] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksBySide[1] = 1; + gNoOfAllBanks = 2; + } + else + { + gBattleBankFunc[1] = SetBankFuncToPlayerBufferRunCommand; + gBanksBySide[1] = 0; + gBattleBankFunc[0] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksBySide[0] = 1; + gNoOfAllBanks = 2; + } + return; + } + if ((gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_DOUBLE)) == BATTLE_TYPE_DOUBLE) + { + if (gBattleTypeFlags & BATTLE_TYPE_WILD) + { + gBattleMainFunc = sub_8010800; + gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBanksBySide[0] = 0; + gBattleBankFunc[1] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksBySide[1] = 1; + gBattleBankFunc[2] = SetBankFuncToPlayerBufferRunCommand; + gBanksBySide[2] = 2; + gBattleBankFunc[3] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksBySide[3] = 3; + gNoOfAllBanks = 4; + } + else + { + gBattleBankFunc[1] = SetBankFuncToPlayerBufferRunCommand; + gBanksBySide[1] = 0; + gBattleBankFunc[0] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksBySide[0] = 1; + gBattleBankFunc[3] = SetBankFuncToPlayerBufferRunCommand; + gBanksBySide[3] = 2; + gBattleBankFunc[2] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksBySide[2] = 3; + gNoOfAllBanks = 4; + + } + return; + } + multiplayerId = GetMultiplayerId(); + if (gBattleTypeFlags & BATTLE_TYPE_WILD) + gBattleMainFunc = sub_8010800; + for (i = 0; i < 4; i++) + { + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + sub_8094978(gLinkPlayers[i].lp_field_18, 0); + break; + case 1: + case 2: + sub_8094978(gLinkPlayers[i].lp_field_18, 1); + break; + } + + if (i == multiplayerId) + { + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToPlayerBufferRunCommand; + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + gBanksBySide[gLinkPlayers[i].lp_field_18] = 0; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; + break; + case 1: + case 2: + gBanksBySide[gLinkPlayers[i].lp_field_18] = 2; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; + break; + } + } + else + { + if ((!(gLinkPlayers[i].lp_field_18 & 1) && !(gLinkPlayers[multiplayerId].lp_field_18 & 1)) + || ((gLinkPlayers[i].lp_field_18 & 1) && (gLinkPlayers[multiplayerId].lp_field_18 & 1))) + { + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToLinkPartnerBufferRunCommand; + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + gBanksBySide[gLinkPlayers[i].lp_field_18] = 0; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; + break; + case 1: + case 2: + gBanksBySide[gLinkPlayers[i].lp_field_18] = 2; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; + break; + } + } + else + { + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToLinkOpponentBufferRunCommand; + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + gBanksBySide[gLinkPlayers[i].lp_field_18] = 1; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; + break; + case 1: + case 2: + gBanksBySide[gLinkPlayers[i].lp_field_18] = 3; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; + break; + } + } + } + } + gNoOfAllBanks = 4; +} + +void sub_800BD54(void) +{ + int i; + int j; + + if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) + { + for (i = 0; i < gNoOfAllBanks; i++) + { + for (j = 0; j < 6; j++) + { + if (i < 2) + { + if (!(gBanksBySide[i] & 1)) + { + if (GetMonData(&gPlayerParty[j], MON_DATA_HP) != 0 + && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != 0 + && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gPlayerParty[j], MON_DATA_IS_EGG) == 0) + { + gBattlePartyID[i] = j; + break; + } + } + else + { + if (GetMonData(&gEnemyParty[j], MON_DATA_HP) != 0 + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != 0 + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gEnemyParty[j], MON_DATA_IS_EGG) == 0) + { + gBattlePartyID[i] = j; + break; + } + } + } + else + { + if (!(gBanksBySide[i] & 1)) + { + if (GetMonData(&gPlayerParty[j], MON_DATA_HP) != 0 + && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES) != 0 //Probably a typo by Game Freak. The rest use SPECIES2 + && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gPlayerParty[j], MON_DATA_IS_EGG) == 0 + && gBattlePartyID[i - 2] != j) + { + gBattlePartyID[i] = j; + break; + } + } + else + { + if (GetMonData(&gEnemyParty[j], MON_DATA_HP) != 0 + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != 0 + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gEnemyParty[j], MON_DATA_IS_EGG) == 0 + && gBattlePartyID[i - 2] != j) + { + gBattlePartyID[i] = j; + break; + } + } + } + } + } + } +} + +void dp01_prepare_buffer(u8 a, u8 *b, u16 c) +{ + int i; + + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + dp01_prepare_buffer_wireless_probably(a, c, b); + } + else + { + switch (a) + { + case 0: + for (i = 0; i < c; i++) + { + gBattleBufferA[gActiveBank][i] = *b; + b++; + } + break; + case 1: + for (i = 0; i < c; i++) + { + gBattleBufferB[gActiveBank][i] = *b; + b++; + } + break; + } + } +} + +void sub_800BF28(void) +{ + gUnknown_020238C4 = CreateTask(sub_800C1A8, 0); + gTasks[gUnknown_020238C4].data[11] = 0; + gTasks[gUnknown_020238C4].data[12] = 0; + gTasks[gUnknown_020238C4].data[13] = 0; + gTasks[gUnknown_020238C4].data[14] = 0; + gTasks[gUnknown_020238C4].data[15] = 0; + gUnknown_020238C5 = CreateTask(sub_800C47C, 0); + gTasks[gUnknown_020238C5].data[12] = 0; + gTasks[gUnknown_020238C5].data[13] = 0; + gTasks[gUnknown_020238C5].data[14] = 0; + gTasks[gUnknown_020238C5].data[15] = 0; + gUnknown_020238C6 = 0; + CpuFill16(0, EWRAM_14000, 0x2000); +} + +void dp01_prepare_buffer_wireless_probably(u8 a, u16 b, u8 *c) +{ + s32 r9; + int i; + + r9 = b - b % 4 + 4; + if (gTasks[gUnknown_020238C4].data[14] + r9 + 9 > 0x1000) + { + gTasks[gUnknown_020238C4].data[12] = gTasks[gUnknown_020238C4].data[14]; + gTasks[gUnknown_020238C4].data[14] = 0; + } + unk_2000000[gTasks[gUnknown_020238C4].data[14] + 0x14000] = a; + unk_2000000[gTasks[gUnknown_020238C4].data[14] + 0x14001] = gActiveBank; + unk_2000000[gTasks[gUnknown_020238C4].data[14] + 0x14002] = gBankAttacker; + unk_2000000[gTasks[gUnknown_020238C4].data[14] + 0x14003] = gBankTarget; + unk_2000000[gTasks[gUnknown_020238C4].data[14] + 0x14004] = r9; + unk_2000000[gTasks[gUnknown_020238C4].data[14] + 0x14005] = (r9 & 0x0000FF00) >> 8; + unk_2000000[gTasks[gUnknown_020238C4].data[14] + 0x14006] = gAbsentBankFlags; + unk_2000000[gTasks[gUnknown_020238C4].data[14] + 0x14007] = gEffectBank; + for (i = 0; i < b; i++) + unk_2000000[gTasks[gUnknown_020238C4].data[14] + 0x14008 + i] = c[i]; + gTasks[gUnknown_020238C4].data[14] = gTasks[gUnknown_020238C4].data[14] + r9 + 8; +} + +void sub_800C1A8(u8 taskId) +{ + u16 var; + + switch (gTasks[taskId].data[11]) + { + case 0: + gTasks[taskId].data[10] = 100; + gTasks[taskId].data[11]++; + break; + case 1: + gTasks[taskId].data[10]--; + if (gTasks[taskId].data[10] == 0) + gTasks[taskId].data[11]++; + break; + case 2: + GetLinkPlayerCount_2(); + if (IsLinkMaster()) + { + sub_8007F4C(); + gTasks[taskId].data[11]++; + break; + } + gTasks[taskId].data[11]++; + break; + case 3: + if (gTasks[taskId].data[15] != gTasks[taskId].data[14]) + { + if (gTasks[taskId].data[13] == 0) + { + if (gTasks[taskId].data[15] > gTasks[taskId].data[14] + && gTasks[taskId].data[15] == gTasks[taskId].data[12]) + { + gTasks[taskId].data[12] = 0; + gTasks[taskId].data[15] = 0; + } + var = (unk_2000000[gTasks[taskId].data[15] + 0x14004] | (unk_2000000[gTasks[taskId].data[15] + 0x14005] << 8)) + 8; + SendBlock(bitmask_all_link_players_but_self(), &unk_2000000[gTasks[taskId].data[15] + 0x14000], var); + gTasks[taskId].data[11]++; + } + else + { + gTasks[taskId].data[13]--; + break; + } + } + break; + case 4: + if (sub_8007ECC()) + { + var = unk_2000000[gTasks[taskId].data[15] + 0x14004] | (unk_2000000[gTasks[taskId].data[15] + 0x14005] << 8); + gTasks[taskId].data[13] = 1; + gTasks[taskId].data[15] = gTasks[taskId].data[15] + var + 8; + gTasks[taskId].data[11] = 3; + } + break; + case 5: + gTasks[taskId].data[13]--; + if (gTasks[taskId].data[13] == 0) + { + gTasks[taskId].data[13] = 1; + gTasks[taskId].data[11] = 3; + } + break; + } +} + +//fix me +void sub_800C35C(void) +{ + u8 i; //r4 + s32 j; //r2 + u16 r6; //r6 + u8 *recvBuffer; //r3 + u8 *dest; //r5 + u8 *src; //r4 + + if (gReceivedRemoteLinkPlayers != 0 && (gBattleTypeFlags & 0x20) && gLinkPlayers[0].linkType == 0x2211) + { + for (i = 0; i < GetLinkPlayerCount(); i++) + { + if (GetBlockReceivedStatus() & gBitTable[i]) + { + ResetBlockReceivedFlag(i); + recvBuffer = (u8 *)&gBlockRecvBuffer[i]; +#ifndef NONMATCHING + asm(""); + recvBuffer = (u8 *)&gBlockRecvBuffer[i]; +#endif + r6 = gBlockRecvBuffer[i][2]; + if (gTasks[gUnknown_020238C5].data[14] + 9 + r6 > 0x1000) + { + gTasks[gUnknown_020238C5].data[12] = gTasks[gUnknown_020238C5].data[14]; + gTasks[gUnknown_020238C5].data[14] = 0; + } + //_0800C402 + dest = EWRAM_15000 + gTasks[gUnknown_020238C5].data[14]; + src = recvBuffer; + for (j = 0; j < r6 + 8; j++) + dest[j] = src[j]; + gTasks[gUnknown_020238C5].data[14] = gTasks[gUnknown_020238C5].data[14] + r6 + 8; + } + //_0800C446 + } + } +} + +void sub_800C47C(u8 taskId) +{ + u16 r7; + u8 r4; + u8 r2; + + if (gTasks[taskId].data[15] != gTasks[taskId].data[14]) + { + if (gTasks[taskId].data[15] > gTasks[taskId].data[14] + && gTasks[taskId].data[15] == gTasks[taskId].data[12]) + { + gTasks[taskId].data[12] = 0; + gTasks[taskId].data[15] = 0; + } + r4 = unk_2000000[0x15000 + gTasks[taskId].data[15] + 1]; + r7 = unk_2000000[0x15000 + gTasks[taskId].data[15] + 4] | (unk_2000000[0x15000 + gTasks[taskId].data[15] + 5] << 8); + switch (unk_2000000[0x15000 + gTasks[taskId].data[15] + 0]) + { + case 0: + if (gBattleExecBuffer & gBitTable[r4]) + return; + memcpy(gBattleBufferA[r4], &unk_2000000[0x15000 + gTasks[taskId].data[15] + 8], r7); + sub_80155A4(r4); + if (!(gBattleTypeFlags & BATTLE_TYPE_WILD)) + { + gBankAttacker = unk_2000000[0x15000 + gTasks[taskId].data[15] + 2]; + gBankTarget = unk_2000000[0x15000 + gTasks[taskId].data[15] + 3]; + gAbsentBankFlags = unk_2000000[0x15000 + gTasks[taskId].data[15] + 6]; + gEffectBank = unk_2000000[0x15000 + gTasks[taskId].data[15] + 7]; + } + break; + case 1: + memcpy(gBattleBufferB[r4], &unk_2000000[0x15000 + gTasks[taskId].data[15] + 8], r7); + break; + case 2: + r2 = unk_2000000[0x15000 + gTasks[taskId].data[15] + 8]; + gBattleExecBuffer &= ~(gBitTable[r4] << (r2 * 4)); + break; + } + gTasks[taskId].data[15] = gTasks[taskId].data[15] + r7 + 8; + } +} + +void EmitGetAttributes(u8 a, u8 b, u8 c) +{ + gBattleBuffersTransferData[0] = 0; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + gBattleBuffersTransferData[3] = 0; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x01_a_b_0(u8 a, u8 b, u8 c) +{ + gBattleBuffersTransferData[0] = 1; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + gBattleBuffersTransferData[3] = 0; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitSetAttributes(u8 a, u8 b, u8 c, u8 d, u8 *e) +{ + int i; + + gBattleBuffersTransferData[0] = 2; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + for (i = 0; i < d; i++) + gBattleBuffersTransferData[3 + i] = *(e++); + dp01_prepare_buffer(a, gBattleBuffersTransferData, d + 3); +} + +void unref_sub_800C6A4(u8 a, u8 b, u8 c, u8 *d) +{ + int i; + + gBattleBuffersTransferData[0] = 3; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + for (i = 0; i < c; i++) + gBattleBuffersTransferData[3 + i] = *(d++); + dp01_prepare_buffer(a, gBattleBuffersTransferData, c + 3); +} + +void dp01_build_cmdbuf_x04_4_4_4(u8 a) +{ + gBattleBuffersTransferData[0] = 4; + gBattleBuffersTransferData[1] = 4; + gBattleBuffersTransferData[2] = 4; + gBattleBuffersTransferData[3] = 4; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void sub_800C704(u8 a, u8 b, u8 c) +{ + gBattleBuffersTransferData[0] = 5; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + gBattleBuffersTransferData[3] = 5; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x06_a(u8 a, u8 b) +{ + gBattleBuffersTransferData[0] = 6; + gBattleBuffersTransferData[1] = b; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 2); +} + +void dp01_build_cmdbuf_x07_7_7_7(u8 a) +{ + gBattleBuffersTransferData[0] = 7; + gBattleBuffersTransferData[1] = 7; + gBattleBuffersTransferData[2] = 7; + gBattleBuffersTransferData[3] = 7; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x08_8_8_8(u8 a) +{ + gBattleBuffersTransferData[0] = 8; + gBattleBuffersTransferData[1] = 8; + gBattleBuffersTransferData[2] = 8; + gBattleBuffersTransferData[3] = 8; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x09_9_9_9(u8 a) +{ + gBattleBuffersTransferData[0] = 9; + gBattleBuffersTransferData[1] = 9; + gBattleBuffersTransferData[2] = 9; + gBattleBuffersTransferData[3] = 9; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitFaintAnimation(u8 a) +{ + gBattleBuffersTransferData[0] = 10; + gBattleBuffersTransferData[1] = 10; + gBattleBuffersTransferData[2] = 10; + gBattleBuffersTransferData[3] = 10; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x0B_B_B_B(u8 a) +{ + gBattleBuffersTransferData[0] = 11; + gBattleBuffersTransferData[1] = 11; + gBattleBuffersTransferData[2] = 11; + gBattleBuffersTransferData[3] = 11; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x0C_C_C_C(u8 a) +{ + gBattleBuffersTransferData[0] = 12; + gBattleBuffersTransferData[1] = 12; + gBattleBuffersTransferData[2] = 12; + gBattleBuffersTransferData[3] = 12; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x0D_a(u8 a, u8 b) +{ + gBattleBuffersTransferData[0] = 13; + gBattleBuffersTransferData[1] = b; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 2); +} + +void unref_sub_800C828(u8 a, u8 b, u8 *c) +{ + int i; + + gBattleBuffersTransferData[0] = 14; + gBattleBuffersTransferData[1] = b; + for (i = 0; i < b * 3; i++) + gBattleBuffersTransferData[2 + i] = *(c++); + dp01_prepare_buffer(a, gBattleBuffersTransferData, b * 3 + 2); +} + +void EmitMoveAnimation(u8 a, u16 b, u8 c, u16 d, s32 e, u8 f, u8 *g) +{ + gBattleBuffersTransferData[0] = 15; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = (b & 0xFF00) >> 8; + gBattleBuffersTransferData[3] = c; + gBattleBuffersTransferData[4] = d; + gBattleBuffersTransferData[5] = (d & 0xFF00) >> 8; + gBattleBuffersTransferData[6] = e; + gBattleBuffersTransferData[7] = (e & 0x0000FF00) >> 8; + gBattleBuffersTransferData[8] = (e & 0x00FF0000) >> 16; + gBattleBuffersTransferData[9] = (e & 0xFF000000) >> 24; + gBattleBuffersTransferData[10] = f; + gBattleBuffersTransferData[11] = gMultiHitCounter; + if (AbilityBattleEffects(14, 0, 13, 0, 0) == 0 && AbilityBattleEffects(14, 0, 0x4D, 0, 0) == 0) + { + gBattleBuffersTransferData[12] = gBattleWeather; + gBattleBuffersTransferData[13] = (gBattleWeather & 0xFF00) >> 8; + } + else + { + gBattleBuffersTransferData[12] = 0; + gBattleBuffersTransferData[13] = 0; + } + gBattleBuffersTransferData[14] = 0; + gBattleBuffersTransferData[15] = 0; + memcpy(&gBattleBuffersTransferData[16], g, 0x1C); + dp01_prepare_buffer(a, gBattleBuffersTransferData, 0x2C); +} + +#ifdef NONMATCHING +void EmitPrintString(u8 a, u16 b) +{ + int i; + //u16 *r12; + + gBattleBuffersTransferData[0] = 16; + gBattleBuffersTransferData[1] = gBattleOutcome; + gBattleBuffersTransferData[2] = b; + gBattleBuffersTransferData[3] = (b & 0xFF00) >> 8; + + *((u16 *)&gBattleBuffersTransferData[4]) = gCurrentMove; + *((u16 *)&gBattleBuffersTransferData[6]) = gUnknown_02024BE8; + *((u16 *)&gBattleBuffersTransferData[8]) = gLastUsedItem; + + gBattleBuffersTransferData[10] = gLastUsedAbility; + gBattleBuffersTransferData[11] = unk_2000000[0x16000 + 3]; + gBattleBuffersTransferData[12] = unk_2000000[0x16000 + 0x5E]; + gBattleBuffersTransferData[13] = unk_2000000[0x16000 + 0xC1]; + gBattleBuffersTransferData[14] = gStringBank; + gBattleBuffersTransferData[15] = gBattleMoves[gCurrentMove].type; + for (i = 0; i < 4; i++) + { + gBattleBuffersTransferData[16 + i] = gBattleMons[i].ability; + } + for (i = 0; i < 16; i++) + { + gBattleBuffersTransferData[20 + i] = gBattleTextBuff1[i]; + gBattleBuffersTransferData[36 + i] = gBattleTextBuff2[i]; + gBattleBuffersTransferData[52 + i] = gBattleTextBuff3[i]; + } + dp01_prepare_buffer(a, gBattleBuffersTransferData, 0x44); +} +#else +__attribute__((naked)) +void EmitPrintString(u8 a, u16 b) +{ + 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\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r10, r0\n\ + lsls r1, 16\n\ + lsrs r1, 16\n\ + ldr r2, _0800CA2C @ =gBattleBuffersTransferData\n\ + movs r0, 0x10\n\ + strb r0, [r2]\n\ + ldr r0, _0800CA30 @ =gBattleOutcome\n\ + ldrb r0, [r0]\n\ + strb r0, [r2, 0x1]\n\ + strb r1, [r2, 0x2]\n\ + lsrs r1, 8\n\ + strb r1, [r2, 0x3]\n\ + adds r0, r2, 0x4\n\ + mov r12, r0\n\ + ldr r4, _0800CA34 @ =gCurrentMove\n\ + ldrh r0, [r4]\n\ + strh r0, [r2, 0x4]\n\ + ldr r0, _0800CA38 @ =gUnknown_02024BE8\n\ + ldrh r0, [r0]\n\ + mov r1, r12\n\ + strh r0, [r1, 0x2]\n\ + ldr r0, _0800CA3C @ =gLastUsedItem\n\ + ldrh r0, [r0]\n\ + strh r0, [r1, 0x4]\n\ + ldr r0, _0800CA40 @ =gLastUsedAbility\n\ + ldrb r0, [r0]\n\ + strb r0, [r1, 0x6]\n\ + ldr r1, _0800CA44 @ =0x02000000\n\ + ldr r3, _0800CA48 @ =0x00016003\n\ + adds r0, r1, r3\n\ + ldrb r0, [r0]\n\ + mov r7, r12\n\ + strb r0, [r7, 0x7]\n\ + adds r3, 0x5B\n\ + adds r0, r1, r3\n\ + ldrb r0, [r0]\n\ + strb r0, [r7, 0x8]\n\ + ldr r7, _0800CA4C @ =0x000160c1\n\ + adds r1, r7\n\ + ldrb r0, [r1]\n\ + mov r1, r12\n\ + strb r0, [r1, 0x9]\n\ + ldr r0, _0800CA50 @ =gStringBank\n\ + ldrb r0, [r0]\n\ + strb r0, [r1, 0xA]\n\ + ldr r3, _0800CA54 @ =gBattleMoves\n\ + ldrh r1, [r4]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r3\n\ + ldrb r0, [r0, 0x2]\n\ + mov r3, r12\n\ + strb r0, [r3, 0xB]\n\ + movs r3, 0\n\ + mov r9, r2\n\ + ldr r7, _0800CA58 @ =gBattleTextBuff3\n\ + mov r8, r7\n\ + adds r2, 0x10\n\ + ldr r0, _0800CA5C @ =gBattleMons\n\ + adds r4, r0, 0\n\ + adds r4, 0x20\n\ +_0800C9D2:\n\ + adds r1, r2, r3\n\ + ldrb r0, [r4]\n\ + strb r0, [r1]\n\ + adds r4, 0x58\n\ + adds r3, 0x1\n\ + cmp r3, 0x3\n\ + ble _0800C9D2\n\ + movs r3, 0\n\ + mov r5, r12\n\ + adds r5, 0x10\n\ + mov r4, r12\n\ + adds r4, 0x20\n\ + ldr r6, _0800CA60 @ =gBattleTextBuff2\n\ + mov r2, r12\n\ + adds r2, 0x30\n\ +_0800C9F0:\n\ + adds r1, r5, r3\n\ + ldr r7, _0800CA64 @ =gBattleTextBuff1\n\ + adds r0, r3, r7\n\ + ldrb r0, [r0]\n\ + strb r0, [r1]\n\ + adds r1, r4, r3\n\ + adds r0, r3, r6\n\ + ldrb r0, [r0]\n\ + strb r0, [r1]\n\ + adds r1, r2, r3\n\ + mov r7, r8\n\ + adds r0, r3, r7\n\ + ldrb r0, [r0]\n\ + strb r0, [r1]\n\ + adds r3, 0x1\n\ + cmp r3, 0xF\n\ + ble _0800C9F0\n\ + mov r0, r10\n\ + mov r1, r9\n\ + movs r2, 0x44\n\ + bl dp01_prepare_buffer\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\ + .align 2, 0\n\ +_0800CA2C: .4byte gBattleBuffersTransferData\n\ +_0800CA30: .4byte gBattleOutcome\n\ +_0800CA34: .4byte gCurrentMove\n\ +_0800CA38: .4byte gUnknown_02024BE8\n\ +_0800CA3C: .4byte gLastUsedItem\n\ +_0800CA40: .4byte gLastUsedAbility\n\ +_0800CA44: .4byte 0x02000000\n\ +_0800CA48: .4byte 0x00016003\n\ +_0800CA4C: .4byte 0x000160c1\n\ +_0800CA50: .4byte gStringBank\n\ +_0800CA54: .4byte gBattleMoves\n\ +_0800CA58: .4byte gBattleTextBuff3\n\ +_0800CA5C: .4byte gBattleMons\n\ +_0800CA60: .4byte gBattleTextBuff2\n\ +_0800CA64: .4byte gBattleTextBuff1\n\ + .syntax divided\n"); +} +#endif + +__attribute__((naked)) +void EmitPrintStringPlayerOnly() +{ + 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\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r10, r0\n\ + lsls r1, 16\n\ + lsrs r1, 16\n\ + ldr r2, _0800CB28 @ =gBattleBuffersTransferData\n\ + movs r0, 0x11\n\ + strb r0, [r2]\n\ + strb r0, [r2, 0x1]\n\ + strb r1, [r2, 0x2]\n\ + lsrs r1, 8\n\ + strb r1, [r2, 0x3]\n\ + adds r0, r2, 0x4\n\ + mov r12, r0\n\ + ldr r0, _0800CB2C @ =gCurrentMove\n\ + ldrh r0, [r0]\n\ + strh r0, [r2, 0x4]\n\ + ldr r0, _0800CB30 @ =gUnknown_02024BE8\n\ + ldrh r0, [r0]\n\ + mov r1, r12\n\ + strh r0, [r1, 0x2]\n\ + ldr r0, _0800CB34 @ =gLastUsedItem\n\ + ldrh r0, [r0]\n\ + strh r0, [r1, 0x4]\n\ + ldr r0, _0800CB38 @ =gLastUsedAbility\n\ + ldrb r0, [r0]\n\ + strb r0, [r1, 0x6]\n\ + ldr r0, _0800CB3C @ =0x02000000\n\ + ldr r3, _0800CB40 @ =0x00016003\n\ + adds r1, r0, r3\n\ + ldrb r1, [r1]\n\ + mov r7, r12\n\ + strb r1, [r7, 0x7]\n\ + ldr r1, _0800CB44 @ =0x0001605e\n\ + adds r0, r1\n\ + ldrb r0, [r0]\n\ + strb r0, [r7, 0x8]\n\ + movs r3, 0\n\ + mov r9, r2\n\ + ldr r7, _0800CB48 @ =gBattleTextBuff3\n\ + mov r8, r7\n\ + mov r4, r9\n\ + adds r4, 0x10\n\ + ldr r0, _0800CB4C @ =gBattleMons\n\ + adds r2, r0, 0\n\ + adds r2, 0x20\n\ +_0800CACE:\n\ + adds r1, r4, r3\n\ + ldrb r0, [r2]\n\ + strb r0, [r1]\n\ + adds r2, 0x58\n\ + adds r3, 0x1\n\ + cmp r3, 0x3\n\ + ble _0800CACE\n\ + movs r3, 0\n\ + mov r5, r12\n\ + adds r5, 0x10\n\ + mov r4, r12\n\ + adds r4, 0x20\n\ + ldr r6, _0800CB50 @ =gBattleTextBuff2\n\ + mov r2, r12\n\ + adds r2, 0x30\n\ +_0800CAEC:\n\ + adds r1, r5, r3\n\ + ldr r7, _0800CB54 @ =gBattleTextBuff1\n\ + adds r0, r3, r7\n\ + ldrb r0, [r0]\n\ + strb r0, [r1]\n\ + adds r1, r4, r3\n\ + adds r0, r3, r6\n\ + ldrb r0, [r0]\n\ + strb r0, [r1]\n\ + adds r1, r2, r3\n\ + mov r7, r8\n\ + adds r0, r3, r7\n\ + ldrb r0, [r0]\n\ + strb r0, [r1]\n\ + adds r3, 0x1\n\ + cmp r3, 0xF\n\ + ble _0800CAEC\n\ + mov r0, r10\n\ + mov r1, r9\n\ + movs r2, 0x44\n\ + bl dp01_prepare_buffer\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\ + .align 2, 0\n\ +_0800CB28: .4byte gBattleBuffersTransferData\n\ +_0800CB2C: .4byte gCurrentMove\n\ +_0800CB30: .4byte gUnknown_02024BE8\n\ +_0800CB34: .4byte gLastUsedItem\n\ +_0800CB38: .4byte gLastUsedAbility\n\ +_0800CB3C: .4byte 0x02000000\n\ +_0800CB40: .4byte 0x00016003\n\ +_0800CB44: .4byte 0x0001605e\n\ +_0800CB48: .4byte gBattleTextBuff3\n\ +_0800CB4C: .4byte gBattleMons\n\ +_0800CB50: .4byte gBattleTextBuff2\n\ +_0800CB54: .4byte gBattleTextBuff1\n\ + .syntax divided\n"); +} + +void dp01_build_cmdbuf_x12_a_bb(u8 a, u8 b, u16 c) +{ + gBattleBuffersTransferData[0] = 18; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + gBattleBuffersTransferData[3] = (c & 0xFF00) >> 8; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void unref_sub_800CB84(u8 a, u8 b) +{ + gBattleBuffersTransferData[0] = 19; + gBattleBuffersTransferData[1] = b; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 2); +} + +void sub_800CBA4(u8 a, u8 b, u8 c, u8 *d) +{ + u32 i; + + gBattleBuffersTransferData[0] = 20; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + gBattleBuffersTransferData[3] = 0; + for (i = 0; i < 20; i++) + gBattleBuffersTransferData[4 + i] = d[i]; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 24); +} + +void sub_800CBE0(u8 a, u8 *b) +{ + int i; + + gBattleBuffersTransferData[0] = 21; + for (i = 0; i < 3; i++) + gBattleBuffersTransferData[1 + i] = b[i]; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x16_a_b_c_ptr_d_e_f(u8 a, u8 b, u8 c, u8 d, u8 *e) +{ + int i; + + gBattleBuffersTransferData[0] = 22; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + gBattleBuffersTransferData[3] = d; + for (i = 0; i < 3; i++) + gBattleBuffersTransferData[4 + i] = e[i]; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 8); //but only 7 bytes were written +} + +void dp01_build_cmdbuf_x17_17_17_17(u8 a) +{ + gBattleBuffersTransferData[0] = 23; + gBattleBuffersTransferData[1] = 23; + gBattleBuffersTransferData[2] = 23; + gBattleBuffersTransferData[3] = 23; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitHealthBarUpdate(u8 a, s16 b) +{ + gBattleBuffersTransferData[0] = 24; + gBattleBuffersTransferData[1] = 0; + gBattleBuffersTransferData[2] = b; + gBattleBuffersTransferData[3] = (b & 0xFF00) >> 8; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitExpBarUpdate(u8 a, u8 b, s16 c) +{ + gBattleBuffersTransferData[0] = 25; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + gBattleBuffersTransferData[3] = (c & 0xFF00) >> 8; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitStatusIconUpdate(u8 a, u32 b, u32 c) +{ + gBattleBuffersTransferData[0] = 26; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = (b & 0x0000FF00) >> 8; + gBattleBuffersTransferData[3] = (b & 0x00FF0000) >> 16; + gBattleBuffersTransferData[4] = (b & 0xFF000000) >> 24; + gBattleBuffersTransferData[5] = c; + gBattleBuffersTransferData[6] = (c & 0x0000FF00) >> 8; + gBattleBuffersTransferData[7] = (c & 0x00FF0000) >> 16; + gBattleBuffersTransferData[8] = (c & 0xFF000000) >> 24; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 9); +} + +void EmitStatusAnimation(u8 a, u8 b, u32 c) +{ + gBattleBuffersTransferData[0] = 27; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + gBattleBuffersTransferData[3] = (c & 0x0000FF00) >> 8; + gBattleBuffersTransferData[4] = (c & 0x00FF0000) >> 16; + gBattleBuffersTransferData[5] = (c & 0xFF000000) >> 24; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 6); +} + +void EmitStatusXor(u8 a, u8 b) +{ + gBattleBuffersTransferData[0] = 28; + gBattleBuffersTransferData[1] = b; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 2); +} + +void dp01_build_cmdbuf_x1D_1D_numargs_varargs(u8 a, u16 b, u8 *c) +{ + int i; + + gBattleBuffersTransferData[0] = 29; + gBattleBuffersTransferData[1] = 29; + gBattleBuffersTransferData[2] = b; + gBattleBuffersTransferData[3] = (b & 0xFF00) >> 8; + for (i = 0; i < b; i++) + gBattleBuffersTransferData[4 + i] = *(c++); + dp01_prepare_buffer(a, gBattleBuffersTransferData, b + 4); +} + +void unref_sub_800CDD4(u8 a, u32 b, u16 c, u8 *d) +{ + int i; + + gBattleBuffersTransferData[0] = 30; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = (b & 0x0000FF00) >> 8; + gBattleBuffersTransferData[3] = (b & 0x00FF0000) >> 16; + gBattleBuffersTransferData[4] = (b & 0xFF000000) >> 24; + gBattleBuffersTransferData[5] = c; + gBattleBuffersTransferData[6] = (c & 0xFF00) >> 8; + for (i = 0; i < c; i++) + gBattleBuffersTransferData[7 + i] = *(d++); + dp01_prepare_buffer(a, gBattleBuffersTransferData, c + 7); +} + +void unref_sub_800CE3C(u8 a, u16 b, u8 *c) +{ + int i; + + gBattleBuffersTransferData[0] = 31; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = (b & 0xFF00) >> 8; + for (i = 0; i < b; i++) + gBattleBuffersTransferData[3 + i] = *(c++); + dp01_prepare_buffer(a, gBattleBuffersTransferData, b + 3); +} + +void unref_sub_800CE84(u8 a, u16 b, u8 *c) +{ + int i; + + gBattleBuffersTransferData[0] = 32; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = (b & 0xFF00) >> 8; + for (i = 0; i < b; i++) + gBattleBuffersTransferData[3 + i] = *(c++); + dp01_prepare_buffer(a, gBattleBuffersTransferData, b + 3); +} + +void dp01_build_cmdbuf_x21_a_bb(u8 a, u8 b, u16 c) +{ + gBattleBuffersTransferData[0] = 33; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + gBattleBuffersTransferData[3] = (c & 0xFF00) >> 8; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x22_a_three_bytes(u8 a, u8 b, u8 *c) +{ + int i; + + gBattleBuffersTransferData[0] = 34; + gBattleBuffersTransferData[1] = b; + for (i = 0; i < 3; i++) + gBattleBuffersTransferData[2 + i] = c[i]; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 5); +} + +void dp01_build_cmdbuf_x23_aa_0(u8 a, u16 b) +{ + gBattleBuffersTransferData[0] = 35; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = (b & 0xFF00) >> 8; + gBattleBuffersTransferData[3] = 0; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x24_aa_0(u8 a, u16 b) +{ + gBattleBuffersTransferData[0] = 36; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = (b & 0xFF00) >> 8; + gBattleBuffersTransferData[3] = 0; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x25_25_25_25(u8 a) +{ + gBattleBuffersTransferData[0] = 37; + gBattleBuffersTransferData[1] = 37; + gBattleBuffersTransferData[2] = 37; + gBattleBuffersTransferData[3] = 37; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x26_a(u8 a, u8 b) +{ + gBattleBuffersTransferData[0] = 38; + gBattleBuffersTransferData[1] = b; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 2); +} + +void dp01_build_cmdbuf_x27_27_27_27(u8 a) +{ + gBattleBuffersTransferData[0] = 39; + gBattleBuffersTransferData[1] = 39; + gBattleBuffersTransferData[2] = 39; + gBattleBuffersTransferData[3] = 39; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x28_28_28_28(u8 a) +{ + gBattleBuffersTransferData[0] = 40; + gBattleBuffersTransferData[1] = 40; + gBattleBuffersTransferData[2] = 40; + gBattleBuffersTransferData[3] = 40; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitHitAnimation(u8 a) +{ + gBattleBuffersTransferData[0] = 41; + gBattleBuffersTransferData[1] = 41; + gBattleBuffersTransferData[2] = 41; + gBattleBuffersTransferData[3] = 41; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x2A_2A_2A_2A(u8 a) +{ + gBattleBuffersTransferData[0] = 42; + gBattleBuffersTransferData[1] = 42; + gBattleBuffersTransferData[2] = 42; + gBattleBuffersTransferData[3] = 42; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitEffectivenessSound(u8 a, u16 b) +{ + gBattleBuffersTransferData[0] = 43; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = (b & 0xFF00) >> 8; + gBattleBuffersTransferData[3] = 0; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void sub_800D074(u8 a, u16 b) +{ + gBattleBuffersTransferData[0] = 44; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = (b & 0xFF00) >> 8; + gBattleBuffersTransferData[3] = 0; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitFaintingCry(u8 a) +{ + gBattleBuffersTransferData[0] = 45; + gBattleBuffersTransferData[1] = 45; + gBattleBuffersTransferData[2] = 45; + gBattleBuffersTransferData[3] = 45; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitBattleIntroSlide(u8 a, u8 b) +{ + gBattleBuffersTransferData[0] = 46; + gBattleBuffersTransferData[1] = b; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 2); +} + +void dp01_build_cmdbuf_x2F_2F_2F_2F(u8 a) +{ + gBattleBuffersTransferData[0] = 47; + gBattleBuffersTransferData[1] = 47; + gBattleBuffersTransferData[2] = 47; + gBattleBuffersTransferData[3] = 47; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x30_TODO(u8 a, u8 *b, u8 c) +{ + int i; + + gBattleBuffersTransferData[0] = 48; + gBattleBuffersTransferData[1] = c & 0x7F; + gBattleBuffersTransferData[2] = (c & 0x80) >> 7; + gBattleBuffersTransferData[3] = 48; + for (i = 0; i < 48; i++) + gBattleBuffersTransferData[4 + i] = b[i]; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 52); +} + +void dp01_build_cmdbuf_x31_31_31_31(u8 a) +{ + gBattleBuffersTransferData[0] = 49; + gBattleBuffersTransferData[1] = 49; + gBattleBuffersTransferData[2] = 49; + gBattleBuffersTransferData[3] = 49; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void dp01_build_cmdbuf_x32_32_32_32(u8 a) +{ + gBattleBuffersTransferData[0] = 50; + gBattleBuffersTransferData[1] = 50; + gBattleBuffersTransferData[2] = 50; + gBattleBuffersTransferData[3] = 50; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitSpriteInvisibility(u8 a, u8 b) +{ + gBattleBuffersTransferData[0] = 51; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = 51; + gBattleBuffersTransferData[3] = 51; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitBattleAnimation(u8 a, u8 b, u16 c) +{ + gBattleBuffersTransferData[0] = 52; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = c; + gBattleBuffersTransferData[3] = (c & 0xFF00) >> 8; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 4); +} + +void EmitLinkStandbyMsg(u8 a, u8 b) +{ + gBattleBuffersTransferData[0] = 53; + gBattleBuffersTransferData[1] = b; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 2); +} + +void EmitResetActionMoveSelection(u8 a, u8 b) +{ + gBattleBuffersTransferData[0] = 54; + gBattleBuffersTransferData[1] = b; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 2); +} + +void dp01_build_cmdbuf_x37_a(u8 a, u8 b) +{ + gBattleBuffersTransferData[0] = 55; + gBattleBuffersTransferData[1] = b; + dp01_prepare_buffer(a, gBattleBuffersTransferData, 2); +} diff --git a/src/rom4.c b/src/rom4.c index b81007fd5..2ddd5ed9f 100644 --- a/src/rom4.c +++ b/src/rom4.c @@ -1,34 +1,51 @@ #include "global.h" #include "rom4.h" -#include "asm.h" -#include "asm_fieldmap.h" #include "battle_setup.h" #include "berry.h" +#include "cable_club.h" +#include "clock.h" +#include "event_data.h" #include "field_camera.h" +#include "field_control_avatar.h" #include "field_effect.h" +#include "field_fadetransition.h" +#include "field_ground_effect.h" #include "field_map_obj.h" +#include "field_map_obj_helpers.h" #include "field_message_box.h" #include "field_player_avatar.h" -#include "flag.h" +#include "field_screen_effect.h" +#include "field_special_scene.h" +#include "field_specials.h" +#include "field_tasks.h" +#include "field_weather.h" +#include "fieldmap.h" +#include "fldeff_flash.h" #include "heal_location.h" #include "link.h" #include "load_save.h" #include "main.h" +#include "map_name_popup.h" #include "menu.h" +#include "metatile_behavior.h" #include "new_game.h" #include "palette.h" #include "play_time.h" #include "rng.h" +#include "roamer.h" +#include "rotating_gate.h" #include "safari_zone.h" #include "script.h" +#include "script_pokemon_80C4.h" +#include "secret_base.h" #include "songs.h" #include "sound.h" #include "start_menu.h" #include "task.h" #include "tileset_anim.h" -#include "truck_scene.h" -#include "var.h" -#include "weather.h" +#include "time_events.h" +#include "tv.h" +#include "unknown_task.h" #include "wild_encounter.h" #ifdef SAPPHIRE @@ -43,11 +60,6 @@ struct UnkTVStruct u32 tv_field_4; }; -struct UCoords32 -{ - u32 x, y; -}; - extern struct WarpData gUnknown_020297F0; extern struct WarpData gUnknown_020297F8; extern struct WarpData gUnknown_02029800; @@ -55,48 +67,41 @@ extern struct WarpData gUnknown_02029808; extern struct UnkPlayerStruct gUnknown_02029810; extern u16 gUnknown_02029814; extern bool8 gUnknown_02029816; -extern struct LinkPlayerMapObject gLinkPlayerMapObjects[]; - -extern u8 gUnknown_0202E85C; -extern u8 gUnknown_0202E85D; +extern struct LinkPlayerMapObject gLinkPlayerMapObjects[4]; extern u8 gUnknown_03000580[]; extern u16 (*gUnknown_03000584)(u32); extern u8 gUnknown_03000588; extern u16 word_3004858; -extern void (*gUnknown_0300485C)(void); +extern void (*gFieldCallback)(void); extern u8 gUnknown_03004860; extern u8 gFieldLinkPlayerCount; -extern struct UnkTVStruct gUnknown_03004870; - extern u16 gUnknown_03004898; extern u16 gUnknown_0300489C; -extern u8 gUnknown_0819FC74[]; +extern u8 EventScript_LeagueWhiteOut[]; extern u8 gUnknown_0819FC9F[]; -extern u8 gUnknown_081A436F[]; -extern u8 gUnknown_081A4379[]; -extern u8 gUnknown_081A4383[]; -extern u8 gUnknown_081A439E[]; -extern u8 gUnknown_081A43B9[]; -extern u8 gUnknown_081A43D4[]; -extern u8 gUnknown_081A43F0[]; -extern u8 gUnknown_081A43FA[]; -extern u8 gUnknown_081A4418[]; -extern u8 gUnknown_081A442D[]; -extern u8 gUnknown_081A4442[]; -extern u8 gUnknown_081A4457[]; -extern u8 gUnknown_081A4479[]; -extern u8 gUnknown_081A4487[]; -extern u8 gUnknown_081A4495[]; -extern u8 gUnknown_081A44E5[]; -extern u8 gUnknown_081A44FE[]; +extern u8 SingleBattleColosseum_EventScript_1A436F[]; +extern u8 SingleBattleColosseum_EventScript_1A4379[]; +extern u8 DoubleBattleColosseum_EventScript_1A4383[]; +extern u8 DoubleBattleColosseum_EventScript_1A439E[]; +extern u8 DoubleBattleColosseum_EventScript_1A43B9[]; +extern u8 DoubleBattleColosseum_EventScript_1A43D4[]; +extern u8 TradeCenter_EventScript_1A43F0[]; +extern u8 TradeCenter_EventScript_1A43FA[]; +extern u8 RecordCorner_EventScript_1A4418[]; +extern u8 RecordCorner_EventScript_1A442D[]; +extern u8 RecordCorner_EventScript_1A4442[]; +extern u8 RecordCorner_EventScript_1A4457[]; +extern u8 TradeRoom_ReadTrainerCard1[]; +extern u8 TradeRoom_ReadTrainerCard2[]; +extern u8 TradeRoom_TooBusyToNotice[]; +extern u8 TradeRoom_PromptToCancelLink[]; +extern u8 TradeRoom_TerminateLink[]; extern u8 gUnknown_081A4508[]; -extern struct UCoords32 gUnknown_0821664C[]; - extern u8 (*gUnknown_082166A0[])(struct LinkPlayerMapObject *, struct MapObject *, u8); extern u8 (*gUnknown_082166AC[])(struct LinkPlayerMapObject *, struct MapObject *, u8); extern void (*gUnknown_082166D8[])(struct LinkPlayerMapObject *, struct MapObject *); @@ -107,10 +112,9 @@ extern const struct WarpData gDummyWarpData; extern s32 gUnknown_0839ACE8; extern u32 gUnknown_08216694[]; - -void sub_8052F5C(void) +void DoWhiteOut(void) { - ScriptContext2_RunNewScript(gUnknown_0819FC74); + ScriptContext2_RunNewScript(EventScript_LeagueWhiteOut); gSaveBlock1.money /= 2; HealPlayerParty(); sub_8053050(); @@ -164,18 +168,19 @@ void sub_805308C(void) FlagReset(SYS_SAFARI_MODE); sub_8054164(); ResetCyclingRoadChallengeData(); - mapnumbers_history_shift_sav1_0_2_4_out(); - sub_8134348(); + UpdateLocationHistoryForRoamer(); + RoamerMoveToOtherLocationSet(); } -void sub_80530AC(void) +void ResetGameStats(void) { s32 i; + for (i = 0; i < NUM_GAME_STATS; i++) gSaveBlock1.gameStats[i] = 0; } -void sav12_xor_increment(u8 index) +void IncrementGameStat(u8 index) { if (index < NUM_GAME_STATS) { @@ -186,7 +191,7 @@ void sav12_xor_increment(u8 index) } } -u32 sub_8053108(u8 index) +u32 GetGameStat(u8 index) { if (index >= NUM_GAME_STATS) return 0; @@ -194,7 +199,7 @@ u32 sub_8053108(u8 index) return gSaveBlock1.gameStats[index]; } -void sav12_xor_set(u8 index, u32 value) +void SetGameStat(u8 index, u32 value) { if (index < NUM_GAME_STATS) gSaveBlock1.gameStats[index] = value; @@ -369,7 +374,7 @@ void saved_warp2_set_2(int unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y warp_set(&gSaveBlock1.warp2, mapGroup, mapNum, warpId, x, y); } -void copy_saved_warp2_bank_and_enter_x_to_warp1(void) +void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused) { gUnknown_020297F8 = gSaveBlock1.warp2; } @@ -393,7 +398,7 @@ void sub_8053588(u8 a1) warp_set(&gSaveBlock1.warp3, warp->group, warp->map, -1, warp->x, warp->y); } -void sub_80535C4(u16 a1, u16 a2) +void sub_80535C4(s16 a1, s16 a2) { u8 v4 = sav1_map_get_light_level(); u8 v5 = get_map_light_level_by_bank_and_number(gUnknown_020297F8.mapGroup, gUnknown_020297F8.mapNum); @@ -469,15 +474,9 @@ struct MapConnection *sub_8053818(u8 dir) if (connection == NULL) return NULL; - i = 0; - - while (i < count) - { + for(i = 0; i < count; i++, connection++) if (connection->direction == dir) return connection; - i++; - connection++; - } return NULL; } @@ -512,12 +511,13 @@ bool8 sub_80538D0(u16 x, u16 y) void sub_80538F0(u8 mapGroup, u8 mapNum) { s32 i; + warp1_set(mapGroup, mapNum, -1, -1, -1); sub_8053F0C(); warp_shift(); set_current_map_header_from_sav1_save_old_name(); sub_8053154(); - sub_806906C(); + ClearTempFieldEventData(); ResetCyclingRoadChallengeData(); prev_quest_postbuffer_cursor_backup_reset(); sub_8082BD0(mapGroup, mapNum); @@ -530,15 +530,17 @@ void sub_80538F0(u8 mapGroup, u8 mapNum) not_trainer_hill_battle_pyramid(); sub_8056D38(gMapHeader.mapData); apply_map_tileset2_palette(gMapHeader.mapData); + for (i = 6; i < 12; i++) sub_807D874(i); + sub_8072ED0(); - mapnumbers_history_shift_sav1_0_2_4_out(); - sub_8134394(); - sub_808073C(); - wild_encounter_reset_coro_args(); + UpdateLocationHistoryForRoamer(); + RoamerMove(); + DoCurrentWeather(); + ResetFieldTasksArgs(); mapheader_run_script_with_tag_x5(); - AddMapNamePopUpWindowTask(); + ShowMapNamePopup(); } void sub_8053994(u32 a1) @@ -548,9 +550,9 @@ void sub_8053994(u32 a1) set_current_map_header_from_sav1_save_old_name(); sub_8053154(); - v2 = is_light_level_1_2_3_5_or_6(gMapHeader.light); - v3 = is_light_level_8_or_9(gMapHeader.light); - sub_806906C(); + v2 = is_light_level_1_2_3_5_or_6(gMapHeader.mapType); + v3 = is_light_level_8_or_9(gMapHeader.mapType); + ClearTempFieldEventData(); ResetCyclingRoadChallengeData(); prev_quest_postbuffer_cursor_backup_reset(); sub_8082BD0(gSaveBlock1.location.mapGroup, gSaveBlock1.location.mapNum); @@ -563,12 +565,12 @@ void sub_8053994(u32 a1) sub_8053C98(); sav1_reset_battle_music_maybe(); mapheader_run_script_with_tag_x3(); - mapnumbers_history_shift_sav1_0_2_4_out(); - sub_8134348(); + UpdateLocationHistoryForRoamer(); + RoamerMoveToOtherLocationSet(); not_trainer_hill_battle_pyramid(); if (a1 != 1 && v3) { - UpdateTVScreensOnMap(gUnknown_03004870.tv_field_0, gUnknown_03004870.tv_field_4); + UpdateTVScreensOnMap(gUnknown_03004870.width, gUnknown_03004870.height); sub_80BBCCC(1); } } @@ -615,7 +617,7 @@ u8 sub_8053B00(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3) return 16; if (MetatileBehavior_IsSurfableWaterOrUnderwater(a2) == 1) return 8; - if (sub_8053C44() != 1) + if (IsBikingAllowedByMap() != TRUE) return 1; if (playerStruct->player_field_0 == 2) return 2; @@ -628,9 +630,9 @@ u8 sub_8053B60(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4) { if (FlagGet(SYS_CRUISE_MODE) && a4 == 6) return 4; - if (sub_8056F24(a3) == TRUE) + if (MetatileBehavior_IsDeepSouthWarp(a3) == TRUE) return 2; - if (sub_8056F08(a3) == TRUE || MetatileBehavior_IsDoor(a3) == TRUE) + if (MetatileBehavior_IsNonAnimDoor(a3) == TRUE || MetatileBehavior_IsDoor(a3) == TRUE) return 1; if (MetatileBehavior_IsSouthArrowWarp(a3) == TRUE) return 2; @@ -653,20 +655,28 @@ u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void) return MapGridGetMetatileBehaviorAt(gSaveBlock1.pos.x + 7, gSaveBlock1.pos.y + 7); } -bool32 sub_8053C44(void) +bool32 IsBikingAllowedByMap(void) { + // is player in cycling road entrance? if (gSaveBlock1.location.mapGroup == 29 && (gSaveBlock1.location.mapNum == 11 || gSaveBlock1.location.mapNum == 12)) return TRUE; - if (gMapHeader.light == 8) + + // is player indoor, in a secret base, or underwater? + if (gMapHeader.mapType == MAP_TYPE_INDOOR) return FALSE; - if (gMapHeader.light == 9) + if (gMapHeader.mapType == MAP_TYPE_SECRET_BASE) return FALSE; - if (gMapHeader.light == 5) + if (gMapHeader.mapType == MAP_TYPE_UNDERWATER) return FALSE; + + // is player in SeafloorCavern_Room9? if (gSaveBlock1.location.mapGroup == 24 && gSaveBlock1.location.mapNum == 36) return FALSE; + + // is player in CaveOfOrigin_B4F? if (gSaveBlock1.location.mapGroup == 24 && gSaveBlock1.location.mapNum == 42) return FALSE; + return TRUE; } @@ -723,7 +733,7 @@ bool16 sub_8053D30(struct WarpData *warp) bool16 sub_8053D6C(struct WarpData *warp) { - if (VarGet(16563)) + if (VarGet(0x40B3)) return FALSE; if (warp->mapGroup != 32) return FALSE; @@ -854,7 +864,7 @@ void sub_8053FB0(u16 music) u8 is_warp1_light_level_8_or_9(void) { struct MapHeader *mapHeader = warp1_get_mapheader(); - if (is_light_level_8_or_9(mapHeader->light) == TRUE) + if (is_light_level_8_or_9(mapHeader->mapType) == TRUE) return 2; else return 4; @@ -926,7 +936,7 @@ void sub_80540D0(s16 *a1, u16 *a2) void sub_8054164(void) { - if ((gSaveBlock1.location.mapGroup == 0 && gSaveBlock1.location.mapNum == 45) && !sub_810D32C()) + if ((gSaveBlock1.location.mapGroup == 0 && gSaveBlock1.location.mapNum == 45) && !IsMirageIslandPresent()) { gUnknown_02029816 = TRUE; gUnknown_02029814 = GetMirageIslandMon(); @@ -939,7 +949,7 @@ void sub_8054164(void) u8 get_map_light_level_by_bank_and_number(s8 mapGroup, s8 mapNum) { - return get_mapheader_by_bank_and_number(mapGroup, mapNum)->light; + return get_mapheader_by_bank_and_number(mapGroup, mapNum)->mapType; } u8 get_map_light_level_from_warp(struct WarpData *warp) @@ -1011,20 +1021,21 @@ bool32 is_c1_link_related_active(void) void c1_overworld_normal(u16 newKeys, u16 heldKeys) { - struct UnkInputStruct inputStruct; + struct FieldInput inputStruct; + sub_8059204(); - sub_8067EEC(&inputStruct); - process_overworld_input(&inputStruct, newKeys, heldKeys); + FieldClearPlayerInput(&inputStruct); + FieldGetPlayerInput(&inputStruct, newKeys, heldKeys); if (!ScriptContext2_IsEnabled()) { if (sub_8068024(&inputStruct) == 1) { ScriptContext2_Enable(); - HideMapNamePopUpWindow(); + HideMapNamePopup(); } else { - player_step(inputStruct.input_field_2, newKeys, heldKeys); + player_step(inputStruct.dpadDirection, newKeys, heldKeys); } } } @@ -1074,11 +1085,11 @@ void sub_80543DC(u16 (*a1)(u32)) void sub_80543E8(void) { - if (gUnknown_0300485C) - gUnknown_0300485C(); + if (gFieldCallback) + gFieldCallback(); else mapldr_default(); - gUnknown_0300485C = NULL; + gFieldCallback = NULL; } void CB2_NewGame(void) @@ -1091,14 +1102,14 @@ void CB2_NewGame(void) PlayTimeCounter_Start(); ScriptContext1_Init(); ScriptContext2_Disable(); - gUnknown_0300485C = ExecuteTruckSequence; + gFieldCallback = ExecuteTruckSequence; do_load_map_stuff_loop(&gMain.state); SetFieldVBlankCallback(); set_callback1(c1_overworld); SetMainCallback2(c2_overworld); } -void c2_whiteout(void) +void CB2_WhiteOut(void) { u8 val; gMain.state++; @@ -1107,11 +1118,11 @@ void c2_whiteout(void) FieldClearVBlankHBlankCallbacks(); StopMapMusic(); ResetSafariZoneFlag_(); - sub_8052F5C(); + DoWhiteOut(); player_avatar_init_params_reset(); ScriptContext1_Init(); ScriptContext2_Disable(); - gUnknown_0300485C = sub_8080B60; + gFieldCallback = sub_8080B60; val = 0; do_load_map_stuff_loop(&val); SetFieldVBlankCallback(); @@ -1127,7 +1138,7 @@ void CB2_LoadMap(void) ScriptContext2_Disable(); set_callback1(NULL); SetMainCallback2(sub_810CC80); - gMain.field_8 = CB2_LoadMap2; + gMain.savedCallback = CB2_LoadMap2; } void CB2_LoadMap2(void) @@ -1158,7 +1169,7 @@ void sub_8054534(void) void sub_8054588(void) { FieldClearVBlankHBlankCallbacks(); - gUnknown_0300485C = sub_8080AC4; + gFieldCallback = sub_8080AC4; SetMainCallback2(c2_80567AC); } @@ -1208,7 +1219,7 @@ void sub_805465C(void) sub_8054F70(); set_callback1(sub_8055354); sub_80543DC(sub_8055390); - gUnknown_0300485C = sub_8080A3C; + gFieldCallback = sub_8080A3C; ScriptContext1_Init(); ScriptContext2_Disable(); c2_exit_to_overworld_2_switch(); @@ -1217,35 +1228,35 @@ void sub_805465C(void) void sub_805469C(void) { FieldClearVBlankHBlankCallbacks(); - gUnknown_0300485C = atk17_seteffectuser; + gFieldCallback = atk17_seteffectuser; c2_exit_to_overworld_2_switch(); } void sub_80546B8(void) { FieldClearVBlankHBlankCallbacks(); - gUnknown_0300485C = sub_80809B0; + gFieldCallback = sub_80809B0; c2_exit_to_overworld_2_switch(); } void c2_exit_to_overworld_1_continue_scripts_restart_music(void) { FieldClearVBlankHBlankCallbacks(); - gUnknown_0300485C = sub_8080990; + gFieldCallback = sub_8080990; c2_exit_to_overworld_2_switch(); } void sub_80546F0(void) { FieldClearVBlankHBlankCallbacks(); - gUnknown_0300485C = sub_8080B60; + gFieldCallback = sub_8080B60; c2_exit_to_overworld_2_switch(); } void sub_805470C(void) { if (gMapHeader.flags == 1 && sub_80BBB24() == 1) - AddMapNamePopUpWindowTask(); + ShowMapNamePopup(); sub_8080B60(); } @@ -1256,7 +1267,7 @@ void CB2_ContinueSavedGame(void) ResetSafariZoneFlag_(); sub_805338C(); sub_8053198(); - sub_806451C(); + UnfreezeMapObjects(); DoTimeBasedEvents(); sub_805308C(); sub_8055FC0(); @@ -1272,7 +1283,7 @@ void CB2_ContinueSavedGame(void) } else { - gUnknown_0300485C = sub_805470C; + gFieldCallback = sub_805470C; set_callback1(c1_overworld); c2_exit_to_overworld_2_switch(); } @@ -1440,7 +1451,7 @@ bool32 sub_805493C(u8 *a1, u32 a2) break; case 11: if (gMapHeader.flags == 1 && sub_80BBB24() == 1) - AddMapNamePopUpWindowTask(); + ShowMapNamePopup(); (*a1)++; break; case 12: @@ -1563,12 +1574,12 @@ void sub_8054BA8(void) addr = (void *)VRAM; size = 0x18000; - while(1) + while (1) { DmaFill16(3, 0, addr, 0x1000); addr += 0x1000; size -= 0x1000; - if(size <= 0x1000) + if (size <= 0x1000) { DmaFill16(3, 0, addr, size); break; @@ -1628,7 +1639,7 @@ void sub_8054D4C(u32 a1) sub_807C828(); sub_8080750(); if (!a1) - overworld_ensure_per_step_coros_running(); + SetUpFieldTasks(); mapheader_run_script_with_tag_x5(); } @@ -2090,7 +2101,7 @@ void sub_80555B0(int linkPlayerId, int a2, struct UnkStruct_8054FF8 *a3) sub_8055B08(linkPlayerId, &x, &y); a3->sub.x = x; a3->sub.y = y; - a3->sub.field_8 = sub_8055B50(linkPlayerId); + a3->sub.height = sub_8055B50(linkPlayerId); a3->field_C = MapGridGetMetatileBehaviorAt(x, y); } @@ -2132,7 +2143,7 @@ bool32 sub_8055660(struct UnkStruct_8054FF8 *a1) u8 *sub_805568C(struct UnkStruct_8054FF8 *a1) { - struct UnkStruct_8054FF8_Substruct unkStruct; + struct MapPosition unkStruct; u8 linkPlayerId; if (a1->c && a1->c != 2) @@ -2141,18 +2152,19 @@ u8 *sub_805568C(struct UnkStruct_8054FF8 *a1) unkStruct = a1->sub; unkStruct.x += gUnknown_0821664C[a1->d].x; unkStruct.y += gUnknown_0821664C[a1->d].y; - unkStruct.field_8 = 0; + unkStruct.height = 0; linkPlayerId = GetLinkPlayerIdAt(unkStruct.x, unkStruct.y); if (linkPlayerId != 4) { if (!a1->b) - return gUnknown_081A4495; + return TradeRoom_TooBusyToNotice; if (gUnknown_03000580[linkPlayerId] != 0x80) - return gUnknown_081A4495; + return TradeRoom_TooBusyToNotice; if (!sub_8083BF4(linkPlayerId)) - return gUnknown_081A4479; - return gUnknown_081A4487; + return TradeRoom_ReadTrainerCard1; + else + return TradeRoom_ReadTrainerCard2; } return sub_80682A8(&unkStruct, a1->field_C, a1->d); @@ -2160,29 +2172,29 @@ u8 *sub_805568C(struct UnkStruct_8054FF8 *a1) u16 sub_8055758(u8 *script) { - if (script == gUnknown_081A4383) + if (script == DoubleBattleColosseum_EventScript_1A4383) return 10; - if (script == gUnknown_081A439E) + if (script == DoubleBattleColosseum_EventScript_1A439E) return 9; - if (script == gUnknown_081A43B9) + if (script == DoubleBattleColosseum_EventScript_1A43B9) return 10; - if (script == gUnknown_081A43D4) + if (script == DoubleBattleColosseum_EventScript_1A43D4) return 9; - if (script == gUnknown_081A4418) + if (script == RecordCorner_EventScript_1A4418) return 10; - if (script == gUnknown_081A442D) + if (script == RecordCorner_EventScript_1A442D) return 9; - if (script == gUnknown_081A4442) + if (script == RecordCorner_EventScript_1A4442) return 10; - if (script == gUnknown_081A4457) + if (script == RecordCorner_EventScript_1A4457) return 9; - if (script == gUnknown_081A436F) + if (script == SingleBattleColosseum_EventScript_1A436F) return 10; - if (script == gUnknown_081A4379) + if (script == SingleBattleColosseum_EventScript_1A4379) return 9; - if (script == gUnknown_081A43F0) + if (script == TradeCenter_EventScript_1A43F0) return 10; - if (script == gUnknown_081A43FA) + if (script == TradeCenter_EventScript_1A43FA) return 9; return 0; } @@ -2209,7 +2221,7 @@ void sub_8055808(u8 *script) void sub_8055824(void) { PlaySE(SE_WIN_OPEN); - ScriptContext1_SetupScript(gUnknown_081A44E5); + ScriptContext1_SetupScript(TradeRoom_PromptToCancelLink); ScriptContext2_Enable(); } @@ -2222,7 +2234,7 @@ void sub_8055840(u8 *script) void sub_805585C(void) { - ScriptContext1_SetupScript(gUnknown_081A44FE); + ScriptContext1_SetupScript(TradeRoom_TerminateLink); ScriptContext2_Enable(); } @@ -2293,7 +2305,7 @@ void ZeroLinkPlayerMapObject(struct LinkPlayerMapObject *linkPlayerMapObj) void strange_npc_table_clear(void) { - memset(gLinkPlayerMapObjects, 0, 16); + memset(gLinkPlayerMapObjects, 0, sizeof(gLinkPlayerMapObjects)); } void ZeroMapObject(struct MapObject *mapObj) @@ -2531,7 +2543,7 @@ void CreateLinkPlayerSprite(u8 linkPlayerId) if (linkPlayerMapObj->active) { - u8 val = sub_805983C(0, mapObj->mapobj_bit_1); + u8 val = GetRivalAvatarGraphicsIdByStateIdAndGender(0, mapObj->mapobj_bit_1); mapObj->spriteId = AddPseudoFieldObject(val, SpriteCB_LinkPlayer, 0, 0, 0); sprite = &gSprites[mapObj->spriteId]; sprite->coordOffsetEnabled = TRUE; diff --git a/src/rom6.c b/src/rom6.c new file mode 100644 index 000000000..759aed93f --- /dev/null +++ b/src/rom6.c @@ -0,0 +1,202 @@ +#include "global.h" +#include "rom6.h" +#include "braille_puzzles.h" +#include "field_effect.h" +#include "field_map_obj.h" +#include "field_player_avatar.h" +#include "item_use.h" +#include "pokemon_menu.h" +#include "rom4.h" +#include "script.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" + +extern u16 gScriptLastTalked; +extern u32 gUnknown_0202FF84[]; +extern struct MapPosition gUnknown_0203923C; +extern void (*gFieldCallback)(void); +extern u8 gLastFieldPokeMenuOpened; +extern void (*gUnknown_03005CE4)(void); +extern u8 UseRockSmashScript[]; + +static void task08_080C9820(u8); +static void sub_810B3DC(u8); +static void sub_810B428(u8); +static void sub_810B4CC(u8); +static void sub_810B53C(void); +static void sub_810B58C(void); +static void sub_810B5D8(void); +static void sub_810B634(void); + +bool8 npc_before_player_of_type(u8 a) +{ + u8 mapObjId; + + GetXYCoordsOneStepInFrontOfPlayer(&gUnknown_0203923C.x, &gUnknown_0203923C.y); + gUnknown_0203923C.height = PlayerGetZCoord(); + mapObjId = GetFieldObjectIdByXYZ(gUnknown_0203923C.x, gUnknown_0203923C.y, gUnknown_0203923C.height); + if (gMapObjects[mapObjId].graphicsId != a) + { + return FALSE; + } + else + { + gScriptLastTalked = gMapObjects[mapObjId].localId; + return TRUE; + } +} + +u8 oei_task_add(void) +{ + GetXYCoordsOneStepInFrontOfPlayer(&gUnknown_0203923C.x, &gUnknown_0203923C.y); + return CreateTask(task08_080C9820, 8); +} + +static void task08_080C9820(u8 taskId) +{ + u8 mapObjId; + + ScriptContext2_Enable(); + gPlayerAvatar.unk6 = 1; + mapObjId = gPlayerAvatar.mapObjectId; + if (!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(&gMapObjects[mapObjId]) + || FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[mapObjId])) + { + if (gMapHeader.mapType == 5) + { + FieldEffectStart(0x3B); + gTasks[taskId].func = sub_810B428; + } + else + { + sub_8059BF4(); + FieldObjectSetSpecialAnim(&gMapObjects[mapObjId], 0x39); + gTasks[taskId].func = sub_810B3DC; + } + } +} + +static void sub_810B3DC(u8 taskId) +{ + if (FieldObjectCheckIfSpecialAnimFinishedOrInactive(&gMapObjects[gPlayerAvatar.mapObjectId]) == TRUE) + { + FieldEffectStart(0x3B); + gTasks[taskId].func = sub_810B428; + } +} + +static void sub_810B428(u8 taskId) +{ + if (!FieldEffectActiveListContains(6)) + { + gUnknown_0202FF84[1] = player_get_direction_lower_nybble(); + if (gUnknown_0202FF84[1] == 1) + gUnknown_0202FF84[2] = 0; + if (gUnknown_0202FF84[1] == 2) + gUnknown_0202FF84[2] = 1; + if (gUnknown_0202FF84[1] == 3) + gUnknown_0202FF84[2] = 2; + if (gUnknown_0202FF84[1] == 4) + gUnknown_0202FF84[2] = 3; + sub_805B980(&gMapObjects[gPlayerAvatar.mapObjectId], GetPlayerAvatarGraphicsIdByCurrentState()); + StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], gUnknown_0202FF84[2]); + FieldEffectActiveListRemove(6); + gTasks[taskId].func = sub_810B4CC; + } +} + +static void sub_810B4CC(u8 taskId) +{ + void (*func)(void) = (void (*)(void))(((u16)gTasks[taskId].data[8] << 16) | (u16)gTasks[taskId].data[9]); + + func(); + gPlayerAvatar.unk6 = 0; + DestroyTask(taskId); +} + +bool8 SetUpFieldMove_RockSmash(void) +{ + if (npc_before_player_of_type(0x56) == TRUE) + { + gFieldCallback = sub_808AB90; + gUnknown_03005CE4 = sub_810B53C; + return TRUE; + } + else + { + return FALSE; + } +} + +static void sub_810B53C(void) +{ + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; + ScriptContext1_SetupScript(UseRockSmashScript); +} + +int FldEff_RockSmash(void) +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)sub_810B58C >> 16; + gTasks[taskId].data[9] = (u32)sub_810B58C; + IncrementGameStat(0x13); + return 0; +} + +static void sub_810B58C(void) +{ + PlaySE(SE_W088); + FieldEffectActiveListRemove(0x25); + EnableBothScriptContexts(); +} + +int SetUpFieldMove_Dig(void) +{ + if (sub_80CA1C8() == TRUE) + { + gFieldCallback = sub_808AB90; + gUnknown_03005CE4 = sub_810B5D8; + return TRUE; + } + else + { + return FALSE; + } +} + +static void sub_810B5D8(void) +{ + sub_8053014(); + FieldEffectStart(0x26); + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; +} + +int FldEff_UseDig(void) +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)sub_810B634 >> 16; + gTasks[taskId].data[9] = (u32)sub_810B634; + if (!ShouldDoBrailleDigEffect()) + SetPlayerAvatarTransitionFlags(1); + return 0; +} + +static void sub_810B634(void) +{ + u8 taskId; + + FieldEffectActiveListRemove(0x26); + if (ShouldDoBrailleDigEffect()) + { + DoBrailleDigEffect(); + } + else + { + taskId = CreateTask(task08_080A1C44, 8); + gTasks[taskId].data[0] = 0; + } +} diff --git a/src/rom_800D42C.c b/src/rom_800D42C.c new file mode 100644 index 000000000..f51779e65 --- /dev/null +++ b/src/rom_800D42C.c @@ -0,0 +1,118 @@ +#include "global.h" +#include "battle.h" +#include "link.h" +#include "text.h" + +extern u16 gBattleTypeFlags; +extern u8 gBattleOutcome; + +extern struct Window gUnknown_03004210; + +extern u8 BattleText_Win[]; +extern u8 BattleText_Loss[]; +extern u8 BattleText_Tie[]; + +#if ENGLISH +#define LEFT_MESSAGE_X 6 +#define RIGHT_MESSAGE_X 21 +#define TILE_OFFSET_LOSS 168 +#elif GERMAN +#define LEFT_MESSAGE_X 5 +#define RIGHT_MESSAGE_X 20 +#define TILE_OFFSET_LOSS 172 +#endif +#define TILE_OFFSET_WIN 160 +#define CENTER_MESSAGE_X 13 +#define MESSAGE_Y 2 + +#define PRINT_MESSAGE(text, tileDataStartOffset, x) \ +{ \ + InitWindow(&gUnknown_03004210, text, tileDataStartOffset, x, MESSAGE_Y); \ + sub_8002F44(&gUnknown_03004210); \ +} + +#define PRINT_MESSAGE_LEFT(text, tileDataStartOffset) PRINT_MESSAGE(text, tileDataStartOffset, LEFT_MESSAGE_X) +#define PRINT_MESSAGE_RIGHT(text, tileDataStartOffset) PRINT_MESSAGE(text, tileDataStartOffset, RIGHT_MESSAGE_X) + +void PrintLinkBattleWinLossTie(void) +{ + + if (gBattleOutcome == 3) + { + PRINT_MESSAGE(BattleText_Tie, TILE_OFFSET_WIN, CENTER_MESSAGE_X); + return; + } + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + // Double battle? + + if (gBattleOutcome == 1) + { + + // lp_field_18 = player position? + switch (gLinkPlayers[BATTLE_STRUCT->linkPlayerIndex].lp_field_18) + { + case 0: + case 2: + PRINT_MESSAGE_LEFT(BattleText_Win, TILE_OFFSET_WIN); + PRINT_MESSAGE_RIGHT(BattleText_Loss, TILE_OFFSET_LOSS); + return; + + case 1: + case 3: + PRINT_MESSAGE_RIGHT(BattleText_Win, TILE_OFFSET_WIN) + PRINT_MESSAGE_LEFT(BattleText_Loss, TILE_OFFSET_LOSS) + return; + } + } + else + { + + switch (gLinkPlayers[BATTLE_STRUCT->linkPlayerIndex].lp_field_18) + { + case 1: + case 3: + PRINT_MESSAGE_LEFT(BattleText_Win, TILE_OFFSET_WIN); + PRINT_MESSAGE_RIGHT(BattleText_Loss, TILE_OFFSET_LOSS); + return; + + case 0: + case 2: + PRINT_MESSAGE_RIGHT(BattleText_Win, TILE_OFFSET_WIN); + PRINT_MESSAGE_LEFT(BattleText_Loss, TILE_OFFSET_LOSS); + return; + } + } + + return; + } + + + if (gBattleOutcome == 1) + { + if (gLinkPlayers[BATTLE_STRUCT->linkPlayerIndex].lp_field_18 != 0) + { + PRINT_MESSAGE_RIGHT(BattleText_Win, TILE_OFFSET_WIN); + PRINT_MESSAGE_LEFT(BattleText_Loss, TILE_OFFSET_LOSS); + } + else + { + PRINT_MESSAGE_LEFT(BattleText_Win, TILE_OFFSET_WIN); + PRINT_MESSAGE_RIGHT(BattleText_Loss, TILE_OFFSET_LOSS); + } + } + else + { + if (gLinkPlayers[BATTLE_STRUCT->linkPlayerIndex].lp_field_18 != 0) + { + PRINT_MESSAGE_LEFT(BattleText_Win, TILE_OFFSET_WIN); + PRINT_MESSAGE_RIGHT(BattleText_Loss, TILE_OFFSET_LOSS); + } + else + { + PRINT_MESSAGE_RIGHT(BattleText_Win, TILE_OFFSET_WIN); + PRINT_MESSAGE_LEFT(BattleText_Loss, TILE_OFFSET_LOSS); + } + } +} diff --git a/src/rom_8077ABC.c b/src/rom_8077ABC.c new file mode 100644 index 000000000..249146b37 --- /dev/null +++ b/src/rom_8077ABC.c @@ -0,0 +1,2055 @@ +#include "global.h" +#include "rom_8077ABC.h" +#include "battle.h" +#include "battle_anim.h" +#include "blend_palette.h" +#include "data2.h" +#include "decompress.h" +#include "palette.h" +#include "pokemon_icon.h" +#include "species.h" +#include "sprite.h" +#include "task.h" +#include "trig.h" +#include "util.h" + +#define GET_UNOWN_LETTER(personality) ((\ + (((personality & 0x03000000) >> 24) << 6) \ + | (((personality & 0x00030000) >> 16) << 4) \ + | (((personality & 0x00000300) >> 8) << 2) \ + | (((personality & 0x00000003) >> 0) << 0) \ +) % 28) + +#define IS_DOUBLE_BATTLE() ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) ? TRUE : FALSE) + +#define NUM_BATTLE_SLOTS 4 + +#define gBattleMonPartyPositions gBattlePartyID +#define gCastformElevations gUnknownCastformData_0837F5A8 +#define gCastformBackSpriteYCoords gUnknown_0837F5AC +#define gTransformPersonalities gPID_perBank +#define gBattleMonSprites gObjectBankIDs + + +struct Struct_unk_2019348 { + u16 field_0; + u16 field_2; + u8 field_4; + u32 field_8; + u32 field_c; + u32 field_10; +}; + +struct TransformStatus { + u16 unknown; + u16 species; +}; + +struct Struct_gUnknown_0837F578 { + u8 field_0; + u8 field_1; +}; + +struct OamMatrix { + s16 a; + s16 b; + s16 c; + s16 d; +}; + +struct Struct_2017810 { + u8 filler_0[6]; + u8 field_6; + u8 filler_7[5]; +}; + +struct Color { + u16 r:5; + u16 g:5; + u16 b:5; +}; + +struct Struct_sub_8078914 { + u8 *field_0; + u8 *field_4; + u8 field_8; +}; + +struct BGCnt { + u16 priority:2; + u16 charBase:2; + u16 unused:2; + u16 mosaic:1; + u16 colorMode:1; + u16 screenBase:5; + u16 overflow:1; + u16 size:2; +}; + +#define BG1CNT (*(volatile struct BGCnt*)REG_ADDR_BG1CNT) +#define BG2CNT (*(volatile struct BGCnt*)REG_ADDR_BG2CNT) +#define BG3CNT (*(volatile struct BGCnt*)REG_ADDR_BG3CNT) + +extern struct OamData gOamData_837DF9C[]; +extern const union AnimCmd *const gDummySpriteAnimTable[]; +extern const union AffineAnimCmd *const gDummySpriteAffineAnimTable[]; + +extern struct Struct_unk_2019348 unk_2019348; +extern struct TransformStatus gTransformStatuses[]; +extern u16 gBattleMonPartyPositions[]; +extern u16 gBattleTypeFlags; +extern u32 gTransformPersonalities[NUM_BATTLE_SLOTS]; +extern u8 gBattleMonForms[NUM_BATTLE_SLOTS]; +extern u16 gUnknown_0202F7CA[]; +extern u8 gBattleMonSprites[NUM_BATTLE_SLOTS]; +extern u8 gBattleAnimPlayerMonIndex; +extern u8 gBattleAnimEnemyMonIndex; +extern s16 gBattleAnimArgs[8]; +extern u8 gBanksBySide[NUM_BATTLE_SLOTS]; +extern u8 gNoOfAllBanks; // gNumBattleMons? +extern struct OamMatrix gOamMatrices[]; +extern struct Struct_2017810 unk_2017810[]; +extern u8 gHappinessMoveAnim; + +EWRAM_DATA union AffineAnimCmd *gUnknown_0202F7D4 = NULL; +EWRAM_DATA u32 filler_0202F7D8[3] = {0}; + +const struct Struct_gUnknown_0837F578 gUnknown_0837F578[][4] = { + { + { 72, 80 }, + { 176, 40 }, + { 48, 40 }, + { 112, 80 }, + }, + { + { 32, 80 }, + { 200, 40 }, + { 90, 88 }, + { 152, 32 }, + }, +}; + +// One entry for each of the four Castform forms. +// Coords are probably front pic coords or back pic coords, but this data does not seem to be +// used during battle, party summary, or pokedex screens. +const struct MonCoords gCastformFrontSpriteCoords[] = { + { 0x44, 17 }, // NORMAL + { 0x66, 9 }, // SUN + { 0x46, 9 }, // RAIN + { 0x86, 8 }, // HAIL +}; + +const u8 gCastformElevations[] = { + 13, // NORMAL + 14, // SUN + 13, // RAIN + 13, // HAIL +}; + +// Y position of the backsprite for each of the four Castform forms. +const u8 gCastformBackSpriteYCoords[] = { + 0, // NORMAL + 0, // SUN + 0, // RAIN + 0, // HAIL +}; + +const struct SpriteTemplate gSpriteTemplate_837F5B0[] = { + { + .tileTag = 55125, + .paletteTag = 55125, + .oam = gOamData_837DF9C, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, { + .tileTag = 55126, + .paletteTag = 55126, + .oam = gOamData_837DF9C, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + } +}; + +const struct SpriteSheet gUnknown_0837F5E0[] = { + { gMiscBlank_Gfx, 0x800, 55125, }, + { gMiscBlank_Gfx, 0x800, 55126, }, +}; + + +u8 sub_8077ABC(u8 slot, u8 a2) { + u8 var; + u16 species; + struct TransformStatus *transform; + + if (IsContest()) { + if (a2 == 3 && slot == 3) { + a2 = 1; + } + } + switch (a2) { + case 0: + case 2: + var = gUnknown_0837F578[IS_DOUBLE_BATTLE()][GetBankIdentity(slot)].field_0; + break; + case 1: + var = gUnknown_0837F578[IS_DOUBLE_BATTLE()][GetBankIdentity(slot)].field_1; + break; + case 3: + case 4: + default: + if (IsContest()) { + if (unk_2019348.field_4 & 1) { + species = unk_2019348.field_2; + } else { + species = unk_2019348.field_0; + } + } else { + if (GetBankSide(slot)) { + transform = &gTransformStatuses[slot]; + if (!transform->species) { + species = GetMonData(&gEnemyParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); + } else { + species = transform->species; + } + } else { + transform = &gTransformStatuses[slot]; + if (!transform->species) { + species = GetMonData(&gPlayerParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); + } else { + species = transform->species; + } + } + } + if (a2 == 3) { + var = sub_8077E44(slot, species, 1); + } else { + var = sub_8077E44(slot, species, 0); + } + break; + } + return var; +} + +u8 sub_8077BFC(u8 slot, u16 species) { + u16 letter; + u32 personality; + struct TransformStatus *transform; + u8 ret; + u16 var; + + if (!GetBankSide(slot) || IsContest()) { + if (species == SPECIES_UNOWN) { + if (IsContest()) { + if (unk_2019348.field_4 & 1) { + personality = unk_2019348.field_10; + } else { + personality = unk_2019348.field_8; + } + } else { + transform = &gTransformStatuses[slot]; + if (!transform->species) { + personality = GetMonData(&gPlayerParty[gBattleMonPartyPositions[slot]], MON_DATA_PERSONALITY); + } else { + personality = gTransformPersonalities[slot]; + } + } + letter = GET_UNOWN_LETTER(personality); + if (!letter) { + var = species; + } else { + var = letter + SPECIES_UNOWN_B - 1; + } + ret = gMonBackPicCoords[var].y_offset; + } else if (species == SPECIES_CASTFORM) { + ret = gCastformBackSpriteYCoords[gBattleMonForms[slot]]; + } else if (species > NUM_SPECIES) { + ret = gMonBackPicCoords[0].y_offset; + } else { + ret = gMonBackPicCoords[species].y_offset; + } + } else { + if (species == SPECIES_UNOWN) { + transform = &gTransformStatuses[slot]; + if (!transform->species) { + personality = GetMonData(&gEnemyParty[gBattleMonPartyPositions[slot]], MON_DATA_PERSONALITY); + } else { + personality = gTransformPersonalities[slot]; + } + letter = GET_UNOWN_LETTER(personality); + if (!letter) { + var = species; + } else { + var = letter + SPECIES_UNOWN_B - 1; + } + ret = gMonFrontPicCoords[var].y_offset; + } else if (species == SPECIES_CASTFORM) { + ret = gCastformFrontSpriteCoords[gBattleMonForms[slot]].y_offset; + } else if (species > NUM_SPECIES) { + ret = gMonFrontPicCoords[0].y_offset; + } else { + ret = gMonFrontPicCoords[species].y_offset; + } + } + return ret; +} + +u8 sub_8077DD8(u8 slot, u16 species) { + u8 ret = 0; + if (GetBankSide(slot) == 1) { + if (!IsContest()) { + if (species == SPECIES_CASTFORM) { + ret = gCastformElevations[gBattleMonForms[slot]]; + } else if (species > NUM_SPECIES) { + ret = gEnemyMonElevation[0]; + } else { + ret = gEnemyMonElevation[species]; + } + } + } + return ret; +} + +u8 sub_8077E44(u8 slot, u16 species, u8 a3) { + u16 offset; + u8 y; + if (GetBankSide(slot) == 0 || IsContest()) { + offset = sub_8077BFC(slot, species); + } else { + offset = sub_8077BFC(slot, species); + offset -= sub_8077DD8(slot, species); + } + y = offset + gUnknown_0837F578[IS_DOUBLE_BATTLE()][GetBankIdentity(slot)].field_1; + if (a3) { + if (GetBankSide(slot) == 0) { + y += 8; + } + if (y > 104) y = 104; + } + return y; +} + +u8 sub_8077EE4(u8 slot, u8 a2) { + u16 species; + struct TransformStatus *transform; + if (a2 == 3 || a2 == 4) { + if (IsContest()) { + if (unk_2019348.field_4 & 1) { + species = unk_2019348.field_2; + } else { + species = unk_2019348.field_0; + } + } else { + transform = &gTransformStatuses[slot]; + if (!transform->species) { + species = gUnknown_0202F7CA[slot]; + } else { + species = transform->species; + } + } + if (a2 == 3) { + return sub_8077E44(slot, species, 1); + } else { + return sub_8077E44(slot, species, 0); + } + } else { + return sub_8077ABC(slot, a2); + } +} + +u8 sub_8077F68(u8 slot) { + return sub_8077ABC(slot, 4); +} + +u8 sub_8077F7C(u8 slot) { + u16 var; + if (GetBankSide(slot)) { + var = sub_8077ABC(slot, 1) + 16; + } else { + var = sub_8077ABC(slot, 1) + 17; + } + return var; +} + +u8 sub_8077FC0(u8 slot) { + u16 var; + u8 r6; + struct TransformStatus *transform; + r6 = sub_8077ABC(slot, 1); + if (!IsContest()) { + if (GetBankSide(slot)) { + transform = &gTransformStatuses[slot]; + if (!transform->species) { + var = GetMonData(&gEnemyParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); + } else { + var = transform->species; + } + } else { + transform = &gTransformStatuses[slot]; + if (!transform->species) { + var = GetMonData(&gPlayerParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); + } else { + var = transform->species; + } + } + if (GetBankSide(slot)) { + r6 -= sub_8077DD8(slot, var); + } + } + return r6; +} + +u8 obj_id_for_side_relative_to_move(u8 a1) { + u8 *sprites; + if (a1 == 0) { + if (sub_8078874(gBattleAnimPlayerMonIndex)) { + sprites = gBattleMonSprites; + return sprites[gBattleAnimPlayerMonIndex]; + } else { + return 0xff; + } + } else if (a1 == 1) { + if (sub_8078874(gBattleAnimEnemyMonIndex)) { + sprites = gBattleMonSprites; + return sprites[gBattleAnimEnemyMonIndex]; + } else { + return 0xff; + } + } else if (a1 == 2) { + if (!b_side_obj__get_some_boolean(gBattleAnimPlayerMonIndex ^ 2)) { + return 0xff; + } else { + return gBattleMonSprites[gBattleAnimPlayerMonIndex ^ 2]; + } + } else { + if (b_side_obj__get_some_boolean(gBattleAnimEnemyMonIndex ^ 2)) { + return gBattleMonSprites[gBattleAnimEnemyMonIndex ^ 2]; + } else { + return 0xff; + } + } +} + +void oamt_set_x3A_32(struct Sprite *sprite, void (*callback)(struct Sprite*)) { + sprite->data6 = (u32)(callback) & 0xffff; + sprite->data7 = (u32)(callback) >> 16; +} + +void sub_8078104(struct Sprite *sprite) { + u32 callback = (u16)sprite->data6 | (sprite->data7 << 16); + sprite->callback = (void (*)(struct Sprite *))callback; +} + +void sub_8078114(struct Sprite *sprite) { + if (sprite->data3) { + sprite->pos2.x = Sin(sprite->data0, sprite->data1); + sprite->pos2.y = Cos(sprite->data0, sprite->data1); + sprite->data0 += sprite->data2; + if (sprite->data0 >= 0x100) { + sprite->data0 -= 0x100; + } else if (sprite->data0 < 0) { + sprite->data0 += 0x100; + } + sprite->data3--; + } else { + sub_8078104(sprite); + } +} + +void sub_8078174(struct Sprite *sprite) { + if (sprite->data3) { + sprite->pos2.x = Sin(sprite->data0, (sprite->data5 >> 8) + sprite->data1); + sprite->pos2.y = Cos(sprite->data0, (sprite->data5 >> 8) + sprite->data1); + sprite->data0 += sprite->data2; + sprite->data5 += sprite->data4; + if (sprite->data0 >= 0x100) { + sprite->data0 -= 0x100; + } else if (sprite->data0 < 0) { + sprite->data0 += 0x100; + } + sprite->data3--; + } else { + sub_8078104(sprite); + } +} + +void unref_sub_80781F0(struct Sprite *sprite) { + if (sprite->data3) { + sprite->pos2.x = Sin(sprite->data0, sprite->data1); + sprite->pos2.y = Cos(sprite->data4, sprite->data1); + sprite->data0 += sprite->data2; + sprite->data4 += sprite->data5; + if (sprite->data0 >= 0x100) { + sprite->data0 -= 0x100; + } else if (sprite->data0 < 0) { + sprite->data0 += 0x100; + } + if (sprite->data4 >= 0x100) { + sprite->data4 -= 0x100; + } else if (sprite->data4 < 0) { + sprite->data4 += 0x100; + } + sprite->data3--; + } else { + sub_8078104(sprite); + } +} + +void sub_8078278(struct Sprite *sprite) { + if (sprite->data3) { + sprite->pos2.x = Sin(sprite->data0, sprite->data1); + sprite->pos2.y = Cos(sprite->data0, sprite->data4); + sprite->data0 += sprite->data2; + if (sprite->data0 >= 0x100) { + sprite->data0 -= 0x100; + } else if (sprite->data0 < 0) { + sprite->data0 += 0x100; + } + sprite->data3--; + } else { + sub_8078104(sprite); + } +} + +void sub_80782D8(struct Sprite *sprite) { + if (sprite->data0 > 0) { + sprite->data0--; + } else { + sub_8078104(sprite); + } +} + +void sub_80782F8(struct Sprite *sprite) { + sub_8078314(sprite); + sprite->callback = sub_8078364; + sprite->callback(sprite); +} + +void sub_8078314(struct Sprite *sprite) { + s16 old; + int v1; + if (sprite->data1 > sprite->data2) { + sprite->data0 = -sprite->data0; + } + v1 = sprite->data2 - sprite->data1; + old = sprite->data0; + sprite->data0 = abs(v1 / sprite->data0); + sprite->data2 = (sprite->data4 - sprite->data3) / sprite->data0; + sprite->data1 = old; +} + +void sub_8078364(struct Sprite *sprite) { + if (sprite->data0 > 0) { + sprite->data0--; + sprite->pos2.x += sprite->data1; + sprite->pos2.y += sprite->data2; + } else { + sub_8078104(sprite); + } +} + +void sub_8078394(struct Sprite *sprite) { + if (sprite->data0 > 0) { + sprite->data0--; + sprite->data3 += sprite->data1; + sprite->data4 += sprite->data2; + sprite->pos2.x = sprite->data3 >> 8; + sprite->pos2.y = sprite->data4 >> 8; + } else { + sub_8078104(sprite); + } +} + +void sub_80783D0(struct Sprite *sprite) { + if (sprite->data0 > 0) { + sprite->data0--; + sprite->data3 += sprite->data1; + sprite->data4 += sprite->data2; + sprite->pos2.x = sprite->data3 >> 8; + sprite->pos2.y = sprite->data4 >> 8; + } else { + sub_8078104(sprite); + } + UpdateMonIconFrame(sprite); +} + +void unref_sub_8078414(struct Sprite *sprite) { + sprite->data1 = sprite->pos1.x + sprite->pos2.x; + sprite->data3 = sprite->pos1.y + sprite->pos2.y; + sprite->data2 = sub_8077ABC(gBattleAnimEnemyMonIndex, 2); + sprite->data4 = sub_8077ABC(gBattleAnimEnemyMonIndex, 3); + sprite->callback = sub_80782F8; +} + +void sub_8078458(struct Sprite *sprite) { + if (sprite->data0 > 0) { + sprite->data0--; + gSprites[sprite->data3].pos2.x += sprite->data1; + gSprites[sprite->data3].pos2.y += sprite->data2; + } else { + sub_8078104(sprite); + } +} + +void sub_80784A8(struct Sprite *sprite) { + if (sprite->data0 > 0) { + sprite->data0--; + sprite->data3 += sprite->data1; + sprite->data4 += sprite->data2; + gSprites[sprite->data5].pos2.x = sprite->data3 >> 8; + gSprites[sprite->data5].pos2.y = sprite->data4 >> 8; + } else { + sub_8078104(sprite); + } +} + +void sub_8078504(struct Sprite *sprite) { + if (sprite->data0 > 0) { + sprite->data0--; + sprite->pos2.x = sprite->data2 >> 8; + sprite->data2 += sprite->data1; + sprite->pos2.y = sprite->data4 >> 8; + sprite->data4 += sprite->data3; + if (sprite->data0 % sprite->data5 == 0) { + if (sprite->data5) { + sprite->invisible ^= 1; + } + } + } else { + sub_8078104(sprite); + } +} + +void move_anim_8074EE0(struct Sprite *sprite) { + FreeSpriteOamMatrix(sprite); + move_anim_8072740(sprite); +} + +void unref_sub_8078588(struct Sprite *sprite) { + sprite->data1 = sprite->pos1.x + sprite->pos2.x; + sprite->data3 = sprite->pos1.y + sprite->pos2.y; + sprite->data2 = sub_8077ABC(gBattleAnimPlayerMonIndex, 2); + sprite->data4 = sub_8077ABC(gBattleAnimPlayerMonIndex, 3); + sprite->callback = sub_80782F8; +} + +void unref_sub_80785CC(struct Sprite *sprite) { + ResetPaletteStructByUid(sprite->data5); + move_anim_8074EE0(sprite); +} + +void sub_80785E4(struct Sprite *sprite) { + if (sprite->affineAnimEnded) { + sub_8078104(sprite); + } +} + +void sub_8078600(struct Sprite *sprite) { + if (sprite->animEnded) { + sub_8078104(sprite); + } +} + +void sub_807861C(struct Sprite *sprite) { + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + move_anim_8072740(sprite); +} + +void sub_8078634(u8 task) { + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + DestroyAnimVisualTask(task); +} + +void sub_8078650(struct Sprite *sprite) { + sprite->pos1.x = sub_8077ABC(gBattleAnimPlayerMonIndex, 2); + sprite->pos1.y = sub_8077ABC(gBattleAnimPlayerMonIndex, 3); +} + +void sub_807867C(struct Sprite *sprite, s16 a2) { + u16 v1 = sub_8077ABC(gBattleAnimPlayerMonIndex, 0); + u16 v2 = sub_8077ABC(gBattleAnimEnemyMonIndex, 0); + if (v1 > v2) { + sprite->pos1.x -= a2; + } else if (v1 < v2) { + sprite->pos1.x += a2; + } else { + if (GetBankSide(gBattleAnimPlayerMonIndex)) { + sprite->pos1.x -= a2; + } else { + sprite->pos1.x += a2; + } + } +} + +void sub_80786EC(struct Sprite *sprite) { + sprite->data1 = sprite->pos1.x; + sprite->data3 = sprite->pos1.y; + obj_translate_based_on_private_1_2_3_4(sprite); + sprite->data6 = 0x8000 / sprite->data0; + sprite->data7 = 0; +} + +bool8 sub_8078718(struct Sprite *sprite) { + if (sub_8078B5C(sprite)) { + return TRUE; + } + sprite->data7 += sprite->data6; + sprite->pos2.y += Sin((u8)(sprite->data7 >> 8), sprite->data5); + return FALSE; +} + +void oamt_add_pos2_onto_pos1(struct Sprite *sprite) { + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.x = 0; + sprite->pos2.y = 0; +} + +void sub_8078764(struct Sprite *sprite, u8 a2) { + if (!a2) { + sprite->pos1.x = sub_8077EE4(gBattleAnimEnemyMonIndex, 0); + sprite->pos1.y = sub_8077EE4(gBattleAnimEnemyMonIndex, 1); + } + sub_807867C(sprite, gBattleAnimArgs[0]); + sprite->pos1.y += gBattleAnimArgs[1]; +} + +void sub_80787B0(struct Sprite *sprite, u8 a2) { + if (!a2) { + sprite->pos1.x = sub_8077EE4(gBattleAnimPlayerMonIndex, 0); + sprite->pos1.y = sub_8077EE4(gBattleAnimPlayerMonIndex, 1); + } else { + sprite->pos1.x = sub_8077EE4(gBattleAnimPlayerMonIndex, 2); + sprite->pos1.y = sub_8077EE4(gBattleAnimPlayerMonIndex, 3); + } + sub_807867C(sprite, gBattleAnimArgs[0]); + sprite->pos1.y += gBattleAnimArgs[1]; +} + +u8 GetBankSide(u8 slot) { + return gBanksBySide[slot] & 1; +} + +u8 GetBankIdentity(u8 slot) { + return gBanksBySide[slot]; +} + +u8 GetBankByPlayerAI(u8 slot) { + u8 i; + for (i = 0; i < gNoOfAllBanks; i++) { + if (gBanksBySide[i] == slot) { + break; + } + } + return i; +} + +bool8 sub_8078874(u8 slot) { + if (IsContest()) { + if (gBattleAnimPlayerMonIndex == slot) { + return TRUE; + } + if (gBattleAnimEnemyMonIndex == slot) { + return TRUE; + } + return FALSE; + } else { + if (gBanksBySide[slot] == 0xff) { + return FALSE; + } + if (GetBankSide(slot)) { + if (GetMonData(&gEnemyParty[gBattleMonPartyPositions[slot]], MON_DATA_HP) != 0) { + return TRUE; + } + } else { + if (GetMonData(&gPlayerParty[gBattleMonPartyPositions[slot]], MON_DATA_HP) != 0) { + return TRUE; + } + } + return FALSE; + } +} + +bool8 IsDoubleBattle() { + return IS_DOUBLE_BATTLE(); +} + +void sub_8078914(struct Struct_sub_8078914 *unk) { + if (IsContest()) { + unk->field_0 = (u8 *)0x6008000; + unk->field_4 = (u8 *)0x600f000; + unk->field_8 = 0xe; + } else { + unk->field_0 = (u8 *)0x6004000; + unk->field_4 = (u8 *)0x600e000; + unk->field_8 = 0x8; + } +} + +void sub_8078954(struct Struct_sub_8078914 *unk) { + if (IsContest()) { + unk->field_0 = (u8 *)0x6008000; + unk->field_4 = (u8 *)0x600f000; + unk->field_8 = 0xe; + } else if (GetBankIdentity_permutated(gBattleAnimPlayerMonIndex) == 1) { + unk->field_0 = (u8 *)0x6004000; + unk->field_4 = (u8 *)0x600e000; + unk->field_8 = 0x8; + } else { + unk->field_0 = (u8 *)0x6006000; + unk->field_4 = (u8 *)0x600f000; + unk->field_8 = 0x9; + } +} + +u8 sub_80789BC() { + if (IsContest()) { + return 1; + } + return 2; +} + +void sub_80789D4(bool8 a1) { + if (!a1) { + BG3CNT.size = 0; + BG3CNT.overflow = 1; + } else if (IsContest()) { + BG3CNT.size = 0; + BG3CNT.overflow = 1; + } else { + BG3CNT.size = 1; + BG3CNT.overflow = 0; + } +} + +void sub_8078A34(struct Sprite *sprite) { + sprite->data1 = sprite->pos1.x; + sprite->data3 = sprite->pos1.y; + sub_8078A5C(sprite); + sprite->callback = sub_80783D0; + sprite->callback(sprite); +} + +void sub_8078A5C(struct Sprite *sprite) { + s16 x = (sprite->data2 - sprite->data1) << 8; + s16 y = (sprite->data4 - sprite->data3) << 8; + sprite->data1 = x / sprite->data0; + sprite->data2 = y / sprite->data0; + sprite->data4 = 0; + sprite->data3 = 0; +} + +void obj_translate_based_on_private_1_2_3_4(struct Sprite *sprite) { + int x = sprite->data2 - sprite->data1; + int y = sprite->data4 - sprite->data3; + bool8 r8 = x < 0; + bool8 r9 = y < 0; + u16 x2 = abs(x) << 8; + u16 y2 = abs(y) << 8; + x2 = x2 / sprite->data0; + y2 = y2 / sprite->data0; + if (r8) { + x2 |= 1; + } else { + x2 &= ~1; + } + if (r9) { + y2 |= 1; + } else { + y2 &= ~1; + } + sprite->data1 = x2; + sprite->data2 = y2; + sprite->data4 = 0; + sprite->data3 = 0; +} + +void sub_8078B34(struct Sprite *sprite) { + sprite->data1 = sprite->pos1.x; + sprite->data3 = sprite->pos1.y; + obj_translate_based_on_private_1_2_3_4(sprite); + sprite->callback = sub_8078BB8; + sprite->callback(sprite); +} + +bool8 sub_8078B5C(struct Sprite *sprite) { + u16 v1, v2, x, y; + if (!sprite->data0) { + return TRUE; + } + v1 = sprite->data1; + v2 = sprite->data2; + x = sprite->data3; + y = sprite->data4; + x += v1; + y += v2; + if (v1 & 1) { + sprite->pos2.x = -(x >> 8); + } else { + sprite->pos2.x = x >> 8; + } + if (v2 & 1) { + sprite->pos2.y = -(y >> 8); + } else { + sprite->pos2.y = y >> 8; + } + sprite->data3 = x; + sprite->data4 = y; + sprite->data0--; + return FALSE; +} + +void sub_8078BB8(struct Sprite *sprite) { + if (sub_8078B5C(sprite)) { + sub_8078104(sprite); + } +} + +void sub_8078BD4(struct Sprite *sprite) { + int v1 = abs(sprite->data2 - sprite->data1) << 8; + sprite->data0 = v1 / sprite->data0; + obj_translate_based_on_private_1_2_3_4(sprite); +} + +void sub_8078C00(struct Sprite *sprite) { + sprite->data1 = sprite->pos1.x; + sprite->data3 = sprite->pos1.y; + sub_8078BD4(sprite); + sprite->callback = sub_8078BB8; + sprite->callback(sprite); +} + +void sub_8078C28(struct Sprite *sprite) { + int x = sprite->data2 - sprite->data1; + int y = sprite->data4 - sprite->data3; + bool8 x_sign = x < 0; + bool8 y_sign = y < 0; + u16 x2 = abs(x) << 4; + u16 y2 = abs(y) << 4; + x2 /= sprite->data0; + y2 /= sprite->data0; + if (x_sign) { + x2 |= 1; + } else { + x2 &= ~1; + } + if (y_sign) { + y2 |= 1; + } else { + y2 &= ~1; + } + sprite->data1 = x2; + sprite->data2 = y2; + sprite->data4 = 0; + sprite->data3 = 0; +} + +void sub_8078CC0(struct Sprite *sprite) { + sprite->data1 = sprite->pos1.x; + sprite->data3 = sprite->pos1.y; + sub_8078C28(sprite); + sprite->callback = sub_8078D44; + sprite->callback(sprite); +} + +bool8 sub_8078CE8(struct Sprite *sprite) { + u16 v1, v2, x, y; + if (!sprite->data0) { + return TRUE; + } + v1 = sprite->data1; + v2 = sprite->data2; + x = sprite->data3; + y = sprite->data4; + x += v1; + y += v2; + if (v1 & 1) { + sprite->pos2.x = -(x >> 4); + } else { + sprite->pos2.x = x >> 4; + } + if (v2 & 1) { + sprite->pos2.y = -(y >> 4); + } else { + sprite->pos2.y = y >> 4; + } + sprite->data3 = x; + sprite->data4 = y; + sprite->data0--; + return FALSE; +} + +void sub_8078D44(struct Sprite *sprite) { + if (sub_8078CE8(sprite)) { + sub_8078104(sprite); + } +} + +void sub_8078D60(struct Sprite *sprite) { + int v1 = abs(sprite->data2 - sprite->data1) << 4; + sprite->data0 = v1 / sprite->data0; + sub_8078C28(sprite); +} + +void sub_8078D8C(struct Sprite *sprite) { + sprite->data1 = sprite->pos1.x; + sprite->data3 = sprite->pos1.y; + sub_8078D60(sprite); + sprite->callback = sub_8078D44; + sprite->callback(sprite); +} + +void obj_id_set_rotscale(u8 sprite, s16 xScale, s16 yScale, u16 rotation) { + int i; + struct ObjAffineSrcData src; + struct OamMatrix matrix; + src.xScale = xScale; + src.yScale = yScale; + src.rotation = rotation; + if (sub_8078E38()) { + src.xScale = -src.xScale; + } + i = gSprites[sprite].oam.matrixNum; + ObjAffineSet(&src, &matrix, 1, 2); + gOamMatrices[i].a = matrix.a; + gOamMatrices[i].b = matrix.b; + gOamMatrices[i].c = matrix.c; + gOamMatrices[i].d = matrix.d; +} + +bool8 sub_8078E38() { + if (IsContest()) { + if (gSprites[obj_id_for_side_relative_to_move(0)].data2 == 0xc9 /* XXX SPECIES_UNOWN? */) { + return FALSE; + } + return TRUE; + } + return FALSE; +} + +void sub_8078E70(u8 sprite, u8 a2) { + struct Struct_2017810 *unk; + u8 r7 = gSprites[sprite].data0; + if (IsContest() || b_side_obj__get_some_boolean(r7)) { + gSprites[sprite].invisible = FALSE; + } + gSprites[sprite].oam.objMode = a2; + gSprites[sprite].affineAnimPaused = TRUE; + if (!IsContest() && !gSprites[sprite].oam.affineMode) { + unk = &unk_2017810[r7]; + gSprites[sprite].oam.matrixNum = unk->field_6; + } + gSprites[sprite].oam.affineMode = 3; + CalcCenterToCornerVec(&gSprites[sprite], gSprites[sprite].oam.shape, gSprites[sprite].oam.size, gSprites[sprite].oam.affineMode); +} + +void sub_8078F40(u8 sprite) { + obj_id_set_rotscale(sprite, 0x100, 0x100, 0); + gSprites[sprite].oam.affineMode = 1; + gSprites[sprite].oam.objMode = 0; + gSprites[sprite].affineAnimPaused = FALSE; + CalcCenterToCornerVec(&gSprites[sprite], gSprites[sprite].oam.shape, gSprites[sprite].oam.size, gSprites[sprite].oam.affineMode); +} + +void sub_8078F9C(u8 sprite) { + u16 matrix = gSprites[sprite].oam.matrixNum; + s16 c = gOamMatrices[matrix].c; + if (c < 0) { + c = -c; + } + gSprites[sprite].pos2.y = c >> 3; +} + +// related to obj_id_set_rotscale +void sub_8078FDC(struct Sprite *sprite, bool8 a2, s16 xScale, s16 yScale, u16 rotation) { + int i; + struct ObjAffineSrcData src; + struct OamMatrix matrix; + if (sprite->oam.affineMode & 1) { + sprite->affineAnimPaused = TRUE; + if (a2) { + CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode); + } + src.xScale = xScale; + src.yScale = yScale; + src.rotation = rotation; + if (sub_8078E38()) { + src.xScale = -src.xScale; + } + i = sprite->oam.matrixNum; + ObjAffineSet(&src, &matrix, 1, 2); + gOamMatrices[i].a = matrix.a; + gOamMatrices[i].b = matrix.b; + gOamMatrices[i].c = matrix.c; + gOamMatrices[i].d = matrix.d; + } +} + +void sub_8079098(struct Sprite *sprite) { + sub_8078FDC(sprite, TRUE, 0x100, 0x100, 0); + sprite->affineAnimPaused = FALSE; + CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode); +} + +u16 sub_80790D8(s16 a, s16 b) { + return ArcTan2(a, b); +} + +u16 sub_80790F0(s16 a, s16 b) { + u16 var = sub_80790D8(a, b); + return -var; +} + +void sub_8079108(u16 a1, bool8 a2) { + int i; + struct Color *c; + struct Color *c2; + u16 average; + + a1 *= 0x10; + + if (!a2) { + for (i = 0; i < 0x10; i++) { + c = (struct Color *)&gPlttBufferUnfaded[a1 + i]; + average = c->r + c->g + c->b; + average /= 3; + + c2 = (struct Color *)&gPlttBufferFaded[a1 + i]; + c2->r = average; + c2->g = average; + c2->b = average; + } + } else { + CpuCopy32(&gPlttBufferUnfaded[a1], &gPlttBufferFaded[a1], 0x20); + } +} + +u32 sub_80791A8(u8 a1, u8 a2, u8 a3, u8 a4, u8 a5, u8 a6, u8 a7) { + u32 var = 0; + u32 shift; + if (a1) { + if (!IsContest()) { + var = 0xe; + } else { + var = 1 << sub_80789BC(); + } + } + if (a2) { + shift = gBattleAnimPlayerMonIndex + 16; + var |= 1 << shift; + } + if (a3) { + shift = gBattleAnimEnemyMonIndex + 16; + var |= 1 << shift; + } + if (a4) { + if (b_side_obj__get_some_boolean(gBattleAnimPlayerMonIndex ^ 2)) { + shift = (gBattleAnimPlayerMonIndex ^ 2) + 16; + var |= 1 << shift; + } + } + if (a5) { + if (b_side_obj__get_some_boolean(gBattleAnimEnemyMonIndex ^ 2)) { + shift = (gBattleAnimEnemyMonIndex ^ 2) + 16; + var |= 1 << shift; + } + } + if (a6) { + if (!IsContest()) { + var |= 0x100; + } else { + var |= 0x4000; + } + } + if (a7) { + if (!IsContest()) { + var |= 0x200; + } + } + return var; +} + +u32 sub_80792C0(u8 a1, u8 a2, u8 a3, u8 a4) { + u32 var = 0; + u32 shift; + if (IsContest()) { + if (a1) { + var |= 1 << 18; + return var; + } + } else { + if (a1) { + if (b_side_obj__get_some_boolean(GetBankByPlayerAI(0))) { + var |= 1 << (GetBankByPlayerAI(0) + 16); + } + } + if (a2) { + if (b_side_obj__get_some_boolean(GetBankByPlayerAI(2))) { + shift = GetBankByPlayerAI(2) + 16; + var |= 1 << shift; + } + } + if (a3) { + if (b_side_obj__get_some_boolean(GetBankByPlayerAI(1))) { + shift = GetBankByPlayerAI(1) + 16; + var |= 1 << shift; + } + } + if (a4) { + if (b_side_obj__get_some_boolean(GetBankByPlayerAI(3))) { + shift = GetBankByPlayerAI(3) + 16; + var |= 1 << shift; + } + } + } + return var; +} + +u8 sub_80793A8(u8 a1) { + return a1; +} + +u8 unref_sub_80793B0(u8 a1) { + return GetBankByPlayerAI(a1); +} + +void sub_80793C4(struct Sprite *sprite) { + bool8 var; + if (!sprite->data0) { + if (!gBattleAnimArgs[3]) { + var = TRUE; + } else { + var = FALSE; + } + if (!gBattleAnimArgs[2]) { + sub_80787B0(sprite, var); + } else { + sub_8078764(sprite, var); + } + sprite->data0++; + + } else if (sprite->animEnded || sprite->affineAnimEnded) { + move_anim_8074EE0(sprite); + } +} + +void sub_807941C(struct Sprite *sprite) { + bool8 v1; + u8 v2; + if (!(gBattleAnimArgs[5] & 0xff00)) { + v1 = TRUE; + } else { + v1 = FALSE; + } + if (!(gBattleAnimArgs[5] & 0xff)) { + v2 = 3; + } else { + v2 = 1; + } + sub_80787B0(sprite, v1); + if (GetBankSide(gBattleAnimPlayerMonIndex)) { + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + } + sprite->data0 = gBattleAnimArgs[4]; + sprite->data2 = sub_8077ABC(gBattleAnimEnemyMonIndex, 2) + gBattleAnimArgs[2]; + sprite->data4 = sub_8077ABC(gBattleAnimEnemyMonIndex, v2) + gBattleAnimArgs[3]; + sprite->callback = sub_8078B34; + oamt_set_x3A_32(sprite, move_anim_8072740); +} + +void sub_80794A8(struct Sprite *sprite) { + sub_80787B0(sprite, 1); + if (GetBankSide(gBattleAnimPlayerMonIndex)) { + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + } + sprite->data0 = gBattleAnimArgs[4]; + sprite->data2 = sub_8077ABC(gBattleAnimEnemyMonIndex, 2) + gBattleAnimArgs[2]; + sprite->data4 = sub_8077ABC(gBattleAnimEnemyMonIndex, 3) + gBattleAnimArgs[3]; + sprite->data5 = gBattleAnimArgs[5]; + sub_80786EC(sprite); + sprite->callback = sub_8079518; +} + +void sub_8079518(struct Sprite *sprite) { + if (sub_8078718(sprite)) { + move_anim_8072740(sprite); + } +} + +void sub_8079534(struct Sprite *sprite) { + u8 r4, slot, r7; + if (!gBattleAnimArgs[6]) { + r4 = 1; + r7 = 3; + } else { + r4 = 0; + r7 = 1; + } + if (!gBattleAnimArgs[5]) { + sub_80787B0(sprite, r4); + slot = gBattleAnimPlayerMonIndex; + } else { + sub_8078764(sprite, r4); + slot = gBattleAnimEnemyMonIndex; + } + if (GetBankSide(gBattleAnimPlayerMonIndex)) { + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + } + sub_8078764(sprite, r4); + sprite->data0 = gBattleAnimArgs[4]; + sprite->data2 = sub_8077ABC(slot, 2) + gBattleAnimArgs[2]; + sprite->data4 = sub_8077ABC(slot, r7) + gBattleAnimArgs[3]; + sprite->callback = sub_8078B34; + oamt_set_x3A_32(sprite, move_anim_8072740); +} + +s16 duplicate_obj_of_side_rel2move_in_transparent_mode(u8 a1) { + u16 i; + u8 sprite = obj_id_for_side_relative_to_move(a1); + if (sprite != 0xff) { + for (i = 0; i < 0x40; i++) { + if (gSprites[i].inUse) { + continue; + } + gSprites[i] = gSprites[sprite]; + gSprites[i].oam.objMode = 1; + gSprites[i].invisible = FALSE; + return i; + } + } + return -1; +} + +void obj_delete_but_dont_free_vram(struct Sprite *sprite) { + sprite->usingSheet = TRUE; + DestroySprite(sprite); +} + +void sub_8079670(u8 task) { + s16 v1 = 0; + s16 v2 = 0; + if (gBattleAnimArgs[2] > gBattleAnimArgs[0]) { + v2 = 1; + } + if (gBattleAnimArgs[2] < gBattleAnimArgs[0]) { + v2 = -1; + } + if (gBattleAnimArgs[3] > gBattleAnimArgs[1]) { + v1 = 1; + } + if (gBattleAnimArgs[3] < gBattleAnimArgs[1]) { + v1 = -1; + } + gTasks[task].data[0] = 0; + gTasks[task].data[1] = gBattleAnimArgs[4]; + gTasks[task].data[2] = 0; + gTasks[task].data[3] = gBattleAnimArgs[0]; + gTasks[task].data[4] = gBattleAnimArgs[1]; + gTasks[task].data[5] = v2; + gTasks[task].data[6] = v1; + gTasks[task].data[7] = gBattleAnimArgs[2]; + gTasks[task].data[8] = gBattleAnimArgs[3]; + REG_BLDALPHA = (gBattleAnimArgs[1] << 8) | gBattleAnimArgs[0]; + gTasks[task].func = sub_80796F8; +} + +void sub_80796F8(u8 taskId) { + struct Task *task = &gTasks[taskId]; + if (++task->data[0] > task->data[1]) { + task->data[0] = 0; + if (++task->data[2] & 1) { + if (task->data[3] != task->data[7]) { + task->data[3] += task->data[5]; + } + } else { + if (task->data[4] != task->data[8]) { + task->data[4] += task->data[6]; + } + } + REG_BLDALPHA = (task->data[4] << 8) | task->data[3]; + if (task->data[3] == task->data[7] && task->data[4] == task->data[8]) { + DestroyAnimVisualTask(taskId); + return; + } + } +} + +void sub_8079790(u8 task) { + u8 sprite = obj_id_for_side_relative_to_move(gBattleAnimArgs[0]); + if (sprite == 0xff) { + DestroyAnimVisualTask(task); + return; + } + gTasks[task].data[0] = (gSprites[sprite].oam.paletteNum * 0x10) + 0x101; + sub_80797EC(&gTasks[task]); +} + +void sub_80797EC(struct Task *task) { + task->data[1] = gBattleAnimArgs[1]; + task->data[2] = 0; + task->data[3] = gBattleAnimArgs[2]; + task->data[4] = 0; + task->data[5] = gBattleAnimArgs[3]; + task->data[6] = 0; + task->data[7] = gBattleAnimArgs[4]; + task->func = sub_8079814; +} + +void sub_8079814(u8 taskId) { + struct Task *task = &gTasks[taskId]; + if (++task->data[4] >= task->data[5]) { + task->data[4] = 0; + if (!task->data[6]) { + task->data[2]++; + BlendPalette(task->data[0], 0xf, task->data[2], task->data[1]); + if (task->data[2] == task->data[3]) { + task->data[6] = 1; + } + } else { + task->data[2]--; + BlendPalette(task->data[0], 0xf, task->data[2], task->data[1]); + if (!task->data[2]) { + if (--task->data[7]) { + task->data[4] = 0; + task->data[6] = 0; + } else { + DestroyAnimVisualTask(taskId); + return; + } + } + } + } +} + +void sub_80798AC(u8 task) { + u8 palette = IndexOfSpritePaletteTag(gBattleAnimArgs[0]); + if (palette == 0xff) { + DestroyAnimVisualTask(task); + return; + } + gTasks[task].data[0] = (palette * 0x10) + 0x101; + sub_80797EC(&gTasks[task]); +} + +void sub_80798F4(struct Task *task, u8 a2, void *a3) { + task->data[7] = 0; + task->data[8] = 0; + task->data[9] = 0; + task->data[15] = a2; + task->data[10] = 0x100; + task->data[11] = 0x100; + task->data[12] = 0; + sub_8079BF4(&task->data[13], &task->data[14], a3); + sub_8078E70(a2, 0); +} + +bool8 sub_807992C(struct Task *task) { + gUnknown_0202F7D4 = sub_8079BFC(task->data[13], task->data[14]) + (task->data[7] << 3); + switch (gUnknown_0202F7D4->type) { + default: + if (!gUnknown_0202F7D4->frame.duration) { + task->data[10] = gUnknown_0202F7D4->frame.xScale; + task->data[11] = gUnknown_0202F7D4->frame.yScale; + task->data[12] = gUnknown_0202F7D4->frame.rotation; + task->data[7]++; + gUnknown_0202F7D4++; + } + task->data[10] += gUnknown_0202F7D4->frame.xScale; + task->data[11] += gUnknown_0202F7D4->frame.yScale; + task->data[12] += gUnknown_0202F7D4->frame.rotation; + obj_id_set_rotscale(task->data[15], task->data[10], task->data[11], task->data[12]); + sub_8079A64(task->data[15]); + if (++task->data[8] >= gUnknown_0202F7D4->frame.duration) { + task->data[8] = 0; + task->data[7]++; + } + break; + + case AFFINEANIMCMDTYPE_JUMP: + task->data[7] = gUnknown_0202F7D4->jump.target; + break; + + case AFFINEANIMCMDTYPE_LOOP: + if (gUnknown_0202F7D4->loop.count) { + if (task->data[9]) { + if (!--task->data[9]) { + task->data[7]++; + break; + } + } else { + task->data[9] = gUnknown_0202F7D4->loop.count; + } + if (!task->data[7]) { + break; + } + for (;;) { + task->data[7]--; + gUnknown_0202F7D4--; + if (gUnknown_0202F7D4->type == AFFINEANIMCMDTYPE_LOOP) { + task->data[7]++; + return TRUE; + } + if (!task->data[7]) { + return TRUE; + } + } + } + task->data[7]++; + break; + + case 0x7fff: + gSprites[task->data[15]].pos2.y = 0; + sub_8078F40(task->data[15]); + return FALSE; + } + + return TRUE; +} + +void sub_8079A64(u8 sprite) { + int var = 0x40 - sub_8079B10(sprite) * 2; + u16 matrix = gSprites[sprite].oam.matrixNum; + int var2 = (var << 8) / gOamMatrices[matrix].d; + if (var2 > 0x80) { + var2 = 0x80; + } + gSprites[sprite].pos2.y = (var - var2) / 2; +} + +void sub_8079AB8(u8 sprite, u8 sprite2) { + int var = 0x40 - sub_8079B10(sprite2) * 2; + u16 matrix = gSprites[sprite].oam.matrixNum; + int var2 = (var << 8) / gOamMatrices[matrix].d; + if (var2 > 0x80) { + var2 = 0x80; + } + gSprites[sprite].pos2.y = (var - var2) / 2; +} + +u16 sub_8079B10(u8 sprite) { + struct TransformStatus *transform; + u8 slot = gSprites[sprite].data0; + u16 species; + u16 i; + for (i = 0; i < (sizeof(gBattleMonSprites) / sizeof(u8)); i++) { + if (gBattleMonSprites[i] == sprite) { + if (IsContest()) { + species = unk_2019348.field_0; + return gMonBackPicCoords[species].y_offset; + } else { + if (!GetBankSide(i)) { + transform = &gTransformStatuses[slot]; + if (!transform->species) { + species = GetMonData(&gPlayerParty[gBattleMonPartyPositions[i]], MON_DATA_SPECIES); + } else { + species = transform->species; + } + return gMonBackPicCoords[species].y_offset; + } else { + transform = &gTransformStatuses[slot]; + if (!transform->species) { + species = GetMonData(&gEnemyParty[gBattleMonPartyPositions[i]], MON_DATA_SPECIES); + } else { + species = transform->species; + } + return gMonFrontPicCoords[species].y_offset; + } + } + } + } + return 0x40; +} + +void sub_8079BF4(s16 *bottom, s16 *top, void *ptr) { + *bottom = ((intptr_t) ptr) & 0xffff; + *top = (((intptr_t) ptr) >> 16) & 0xffff; +} + +void *sub_8079BFC(s16 bottom, s16 top) { + return (void *)((u16)bottom | ((u16)top << 16)); +} + + +// possible new file + +void sub_8079C08(struct Task *task, u8 a2, s16 a3, s16 a4, s16 a5, s16 a6, u16 a7) { + task->data[8] = a7; + task->data[15] = a2; + task->data[9] = a3; + task->data[10] = a4; + task->data[13] = a5; + task->data[14] = a6; + task->data[11] = (a5 - a3) / a7; + task->data[12] = (a6 - a4) / a7; +} + +u8 sub_8079C74(struct Task *task) { + if (!task->data[8]) { + return 0; + } + if (--task->data[8]) { + task->data[9] += task->data[11]; + task->data[10] += task->data[12]; + } else { + task->data[9] = task->data[13]; + task->data[10] = task->data[14]; + } + obj_id_set_rotscale(task->data[15], task->data[9], task->data[10], 0); + if (task->data[8]) { + sub_8079A64(task->data[15]); + } else { + gSprites[task->data[15]].pos2.y = 0; + } + return task->data[8]; +} + +void sub_8079CEC(u8 task) { + u16 v1; + if (gHappinessMoveAnim <= 30) { + v1 = 0; + } else if (gHappinessMoveAnim <= 100) { + v1 = 1; + } else if (gHappinessMoveAnim <= 200) { + v1 = 2; + } else { + v1 = 3; + } + gBattleAnimArgs[7] = v1; + DestroyAnimVisualTask(task); +} + +void unref_sub_8079D20(u8 priority) { + if (b_side_obj__get_some_boolean(gBattleAnimEnemyMonIndex)) { + gSprites[gBattleMonSprites[gBattleAnimEnemyMonIndex]].oam.priority = priority; + } + if (b_side_obj__get_some_boolean(gBattleAnimPlayerMonIndex)) { + gSprites[gBattleMonSprites[gBattleAnimPlayerMonIndex]].oam.priority = priority; + } + if (b_side_obj__get_some_boolean(gBattleAnimEnemyMonIndex ^ 2)) { + gSprites[gBattleMonSprites[gBattleAnimEnemyMonIndex ^ 2]].oam.priority = priority; + } + if (b_side_obj__get_some_boolean(gBattleAnimPlayerMonIndex ^ 2)) { + gSprites[gBattleMonSprites[gBattleAnimPlayerMonIndex ^ 2]].oam.priority = priority; + } +} + +void sub_8079E24() { + int i; + for (i = 0; i < gNoOfAllBanks; i++) { + if (b_side_obj__get_some_boolean(i)) { + gSprites[gBattleMonSprites[i]].subpriority = sub_8079E90(i); + gSprites[gBattleMonSprites[i]].oam.priority = 2; + } + } +} + +u8 sub_8079E90(u8 slot) { + u8 status; + u8 ret; + if (IsContest()) { + if (slot == 2) { + return 30; + } else { + return 40; + } + } else { + status = GetBankIdentity(slot); + if (status == 0) { + ret = 30; + } else if (status == 2) { + ret = 20; + } else if (status == 1) { + ret = 40; + } else { + ret = 50; + } + } + return ret; +} + +u8 sub_8079ED4(u8 slot) { + u8 status = GetBankIdentity(slot); + if (IsContest()) { + return 2; + } + if (status == 0 || status == 3) { + return BG2CNT.priority; + } else { + return BG1CNT.priority; + } +} + +u8 GetBankIdentity_permutated(u8 slot) { + u8 status; + if (!IsContest()) { + status = GetBankIdentity(slot); + if (status == 0 || status == 3) { + return 2; + } else { + return 1; + } + } + return 1; +} + +u8 sub_8079F44(u16 species, u8 isBackpic, u8 a3, s16 a4, s16 a5, u8 a6, u32 a7, u32 a8) { + void *src; + void *dest; + int size; + + u8 sprite; + u16 sheet = LoadSpriteSheet(&gUnknown_0837F5E0[a3]); + u16 palette = AllocSpritePalette(gSpriteTemplate_837F5B0[a3].paletteTag); + if (!isBackpic) { + LoadCompressedPalette(species_and_otid_get_pal(species, a8, a7), (palette * 0x10) + 0x100, 0x20); + LoadSpecialPokePic( + &gMonFrontPicTable[species], + gMonFrontPicCoords[species].coords, + gMonFrontPicCoords[species].y_offset, + 0x2000000, + (void *)0x2000000, + species, + a7, + 1 + ); + } else { + LoadCompressedPalette( + species_and_otid_get_pal(species, a8, a7), (palette * 0x10) + 0x100, 0x20); + LoadSpecialPokePic( + &gMonBackPicTable[species], + gMonBackPicCoords[species].coords, + gMonBackPicCoords[species].y_offset, + 0x2000000, + (void *)0x2000000, + species, + a7, + 0 + ); + } + + src = (void *)0x2000000; + dest = (void *)(0x6010000 + (sheet * 0x20)); + size = 0x800; + DmaCopy32(3, src, dest, size); + + if (!isBackpic) { + sprite = CreateSprite(&gSpriteTemplate_837F5B0[a3], a4, a5 + gMonFrontPicCoords[species].y_offset, a6); + } else { + sprite = CreateSprite(&gSpriteTemplate_837F5B0[a3], a4, a5 + gMonBackPicCoords[species].y_offset, a6); + } + if (IsContest()) { + gSprites[sprite].affineAnims = &gSpriteAffineAnimTable_81E7C18; + StartSpriteAffineAnim(&gSprites[sprite], 0); + } + return sprite; +} + +void sub_807A0F4(struct Sprite *sprite) { + DestroySpriteAndFreeResources(sprite); +} + +int sub_807A100(u8 slot, u8 a2) { + u16 species; + u32 personality; + u16 letter; + u16 var; + int ret; + const struct MonCoords *coords; + struct TransformStatus *transform; + if (IsContest()) { + if (unk_2019348.field_4 & 1) { + species = unk_2019348.field_2; + personality = unk_2019348.field_10; + } else { + species = unk_2019348.field_0; + personality = unk_2019348.field_8; + } + if (species == SPECIES_UNOWN) { + letter = GET_UNOWN_LETTER(personality); + if (!letter) { + var = SPECIES_UNOWN; + } else { + var = letter + SPECIES_UNOWN_B - 1; + } + coords = &gMonBackPicCoords[var]; + } else if (species == SPECIES_CASTFORM) { + coords = &gCastformFrontSpriteCoords[gBattleMonForms[slot]]; + } else if (species <= SPECIES_EGG) { + coords = &gMonBackPicCoords[species]; + } else { + coords = &gMonBackPicCoords[0]; + } + } else { + if (!GetBankSide(slot)) { + transform = &gTransformStatuses[slot]; + if (!transform->species) { + species = GetMonData(&gPlayerParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); + personality = GetMonData(&gPlayerParty[gBattleMonPartyPositions[slot]], MON_DATA_PERSONALITY); + } else { + species = transform->species; + personality = gTransformPersonalities[slot]; + } + if (species == SPECIES_UNOWN) { + letter = GET_UNOWN_LETTER(personality); + if (!letter) { + var = SPECIES_UNOWN; + } else { + var = letter + SPECIES_UNOWN_B - 1; + } + coords = &gMonBackPicCoords[var]; + } else if (species > SPECIES_EGG) { + coords = &gMonBackPicCoords[0]; + } else { + coords = &gMonBackPicCoords[species]; + } + } else { + transform = &gTransformStatuses[slot]; + if (!transform->species) { + species = GetMonData(&gEnemyParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); + personality = GetMonData(&gEnemyParty[gBattleMonPartyPositions[slot]], MON_DATA_PERSONALITY); + } else { + species = transform->species; + personality = gTransformPersonalities[slot]; + } + if (species == SPECIES_UNOWN) { + letter = GET_UNOWN_LETTER(personality); + if (!letter) { + var = SPECIES_UNOWN; + } else { + var = letter + SPECIES_UNOWN_B - 1; + } + coords = &gMonFrontPicCoords[var]; + } else if (species == SPECIES_CASTFORM) { + coords = &gCastformFrontSpriteCoords[gBattleMonForms[slot]]; + } else if (species > SPECIES_EGG) { + coords = &gMonFrontPicCoords[0]; + } else { + coords = &gMonFrontPicCoords[species]; + } + } + } + + switch (a2) { + case 0: + return (coords->coords & 0xf) * 8; + case 1: + return (coords->coords >> 4) * 8; + case 4: + return sub_8077ABC(slot, 2) - ((coords->coords >> 4) * 4); + case 5: + return sub_8077ABC(slot, 2) + ((coords->coords >> 4) * 4); + case 2: + return sub_8077ABC(slot, 3) - ((coords->coords & 0xf) * 4); + case 3: + return sub_8077ABC(slot, 3) + ((coords->coords & 0xf) * 4); + case 6: + ret = sub_8077ABC(slot, 1) + 0x1f; + return ret - coords->y_offset; + default: + return 0; + } +} + +void sub_807A3FC(u8 slot, u8 a2, s16 *a3, s16 *a4) { + u8 v1, v2; + s16 v3, v4; + s16 v5, v6; + if (!a2) { + v1 = 0; + v2 = 1; + } else { + v1 = 2; + v2 = 3; + } + v3 = sub_8077ABC(slot, v1); + v4 = sub_8077ABC(slot, v2); + if (IsDoubleBattle() && !IsContest()) { + v5 = sub_8077ABC(slot ^ 2, v1); + v6 = sub_8077ABC(slot ^ 2, v2); + } else { + v5 = v3; + v6 = v4; + } + *a3 = (v3 + v5) / 2; + *a4 = (v4 + v6) / 2; +} + +u8 sub_807A4A0(int a1, u8 sprite, int a3) { + u8 new_sprite = CreateInvisibleSpriteWithCallback(SpriteCallbackDummy); + gSprites[new_sprite] = gSprites[sprite]; + gSprites[new_sprite].usingSheet = TRUE; + gSprites[new_sprite].oam.priority = 0; + gSprites[new_sprite].oam.objMode = 2; + gSprites[new_sprite].oam.tileNum = gSprites[sprite].oam.tileNum; + gSprites[new_sprite].callback = SpriteCallbackDummy; + return new_sprite; +} + +void sub_807A544(struct Sprite *sprite) { + sub_8078650(sprite); + if (GetBankSide(gBattleAnimPlayerMonIndex)) { + sprite->pos1.x -= gBattleAnimArgs[0]; + gBattleAnimArgs[3] = -gBattleAnimArgs[3]; + sprite->hFlip = TRUE; + } else { + sprite->pos1.x += gBattleAnimArgs[0]; + } + sprite->pos1.y += gBattleAnimArgs[1]; + sprite->data0 = gBattleAnimArgs[2]; + sprite->data1 = gBattleAnimArgs[3]; + sprite->data3 = gBattleAnimArgs[4]; + sprite->data5 = gBattleAnimArgs[5]; + oamt_set_x3A_32(sprite, move_anim_8074EE0); + sprite->callback = sub_8078504; +} + +void sub_807A5C4(struct Sprite *sprite) { + if (GetBankSide(gBattleAnimPlayerMonIndex)) { + sprite->pos1.x -= gBattleAnimArgs[0]; + gBattleAnimArgs[3] *= -1; + } else { + sprite->pos1.x += gBattleAnimArgs[0]; + } + sprite->pos1.y += gBattleAnimArgs[1]; + sprite->data0 = gBattleAnimArgs[2]; + sprite->data1 = gBattleAnimArgs[3]; + sprite->data3 = gBattleAnimArgs[4]; + sprite->data5 = gBattleAnimArgs[5]; + StartSpriteAnim(sprite, gBattleAnimArgs[6]); + oamt_set_x3A_32(sprite, move_anim_8074EE0); + sprite->callback = sub_8078504; +} + +void sub_807A63C(struct Sprite *sprite) { + sub_8078650(sprite); + if (GetBankSide(gBattleAnimPlayerMonIndex)) { + sprite->pos1.x -= gBattleAnimArgs[0]; + } else { + sprite->pos1.x += gBattleAnimArgs[0]; + } + sprite->pos1.y += gBattleAnimArgs[1]; + sprite->callback = sub_8078600; + oamt_set_x3A_32(sprite, move_anim_8072740); +} + +void sub_807A69C(u8 taskId) { + u16 src; + u16 dest; + struct Task *task = &gTasks[taskId]; + task->data[0] = obj_id_for_side_relative_to_move(0); + task->data[1] = (GetBankSide(gBattleAnimPlayerMonIndex)) ? -8 : 8; + task->data[2] = 0; + task->data[3] = 0; + gSprites[task->data[0]].pos2.x -= task->data[0]; + task->data[4] = AllocSpritePalette(10097); + task->data[5] = 0; + + dest = (task->data[4] + 0x10) * 0x10; + src = (gSprites[task->data[0]].oam.paletteNum + 0x10) * 0x10; + task->data[6] = sub_8079E90(gBattleAnimPlayerMonIndex); + if (task->data[6] == 20 || task->data[6] == 40) { + task->data[6] = 2; + } else { + task->data[6] = 3; + } + CpuCopy32(&gPlttBufferUnfaded[src], &gPlttBufferFaded[dest], 0x20); + BlendPalette(dest, 0x10, gBattleAnimArgs[1], gBattleAnimArgs[0]); + task->func = sub_807A784; +} + +void sub_807A784(u8 taskId) { + struct Task *task = &gTasks[taskId]; + switch (task->data[2]) { + case 0: + sub_807A850(task, taskId); + gSprites[task->data[0]].pos2.x += task->data[1]; + if (++task->data[3] == 5) { + task->data[3]--; + task->data[2]++; + } + break; + case 1: + sub_807A850(task, taskId); + gSprites[task->data[0]].pos2.x -= task->data[1]; + if (--task->data[3] == 0) { + gSprites[task->data[0]].pos2.x = 0; + task->data[2]++; + } + break; + case 2: + if (!task->data[5]) { + FreeSpritePaletteByTag(10097); + DestroyAnimVisualTask(taskId); + } + break; + } +} + +void sub_807A850(struct Task *task, u8 taskId) { + s16 sprite = duplicate_obj_of_side_rel2move_in_transparent_mode(0); + if (sprite >= 0) { + gSprites[sprite].oam.priority = task->data[6]; + gSprites[sprite].oam.paletteNum = task->data[4]; + gSprites[sprite].data0 = 8; + gSprites[sprite].data1 = taskId; + gSprites[sprite].data2 = sprite; + gSprites[sprite].pos2.x = gSprites[task->data[0]].pos2.x; + gSprites[sprite].callback = sub_807A8D4; + task->data[5]++; + } +} + +void sub_807A8D4(struct Sprite *sprite) { + if (--sprite->data0 == 0) { + gTasks[sprite->data1].data[5]--; + obj_delete_but_dont_free_vram(sprite); + } +} + +void sub_807A908(struct Sprite *sprite) { + sprite->pos1.x = sub_8077ABC(gBattleAnimPlayerMonIndex, 2); + sprite->pos1.y = sub_8077ABC(gBattleAnimPlayerMonIndex, 3); + if (!GetBankSide(gBattleAnimPlayerMonIndex)) { + sprite->data0 = 5; + } else { + sprite->data0 = -10; + } + sprite->data1 = -40; + sprite->callback = sub_807A960; +} + +void sub_807A960(struct Sprite *sprite) { + sprite->data2 += sprite->data0; + sprite->data3 += sprite->data1; + sprite->pos2.x = sprite->data2 / 10; + sprite->pos2.y = sprite->data3 / 10; + if (sprite->data1 < -20) { + sprite->data1++; + } + if ((sprite->pos1.y + sprite->pos2.y) < -32) { + move_anim_8072740(sprite); + } +} + +void sub_807A9BC(struct Sprite *sprite) { + int x; + sprite->data0 = gBattleAnimArgs[2]; + sprite->data2 = sprite->pos1.x + gBattleAnimArgs[4]; + sprite->data4 = sprite->pos1.y + gBattleAnimArgs[5]; + if (!GetBankSide(gBattleAnimEnemyMonIndex)) { + x = (u16)gBattleAnimArgs[4] + 30; + sprite->pos1.x += x; + sprite->pos1.y = gBattleAnimArgs[5] - 20; + } else { + x = (u16)gBattleAnimArgs[4] - 30; + sprite->pos1.x += x; + sprite->pos1.y = gBattleAnimArgs[5] - 80; + } + sprite->callback = sub_8078B34; + oamt_set_x3A_32(sprite, move_anim_8072740); +} @@ -63,9 +63,8 @@ u16 ConvertDateToDayCount(u8 year, u8 month, u8 day) s32 i; u16 dayCount = 0; -#if (REVISION < 2) - // Revisions 0 and 1 don't add days for the year 2000, - // causing the berry glitch. +#ifndef BUGFIX_BERRY + // The berry glitch was caused by not adding days for the year 2000. for (i = year - 1; i > 0; i--) { dayCount += 365; @@ -74,8 +73,7 @@ u16 ConvertDateToDayCount(u8 year, u8 month, u8 day) dayCount++; } #else - // Revision 2 has "i >= 0" as the condition instead of "i > 0", - // which fixes the issue. + // The fix was to use "i >= 0" as the condition instead of "i > 0". for (i = year - 1; i >= 0; i--) { dayCount += 365; @@ -83,7 +81,7 @@ u16 ConvertDateToDayCount(u8 year, u8 month, u8 day) if (IsLeapYear(i) == TRUE) dayCount++; } -#endif +#endif // BUGFIX_BERRY for (i = 0; i < month - 1; i++) dayCount += sNumDaysInMonths[i]; diff --git a/src/safari_zone.c b/src/safari_zone.c index 118797136..a47c8e951 100644 --- a/src/safari_zone.c +++ b/src/safari_zone.c @@ -1,12 +1,13 @@ #include "global.h" #include "safari_zone.h" -#include "asm.h" +#include "event_data.h" +#include "field_fadetransition.h" #include "field_player_avatar.h" -#include "flag.h" #include "main.h" +#include "rom4.h" #include "script.h" #include "string_util.h" -#include "rom4.h" +#include "text.h" struct PokeblockFeeder { @@ -22,13 +23,13 @@ struct PokeblockFeeder static void ClearAllPokeblockFeeders(void); static void DecrementFeederStepCounters(void); -extern u8 gUnknown_02024D26; +extern u8 gBattleOutcome; EWRAM_DATA u8 gNumSafariBalls = 0; EWRAM_DATA static u16 gSafariZoneStepCounter = 0; EWRAM_DATA static struct PokeblockFeeder gPokeblockFeeders[NUM_POKEBLOCK_FEEDERS] = {0}; -extern void (*gUnknown_0300485C)(void); +extern void (*gFieldCallback)(void); extern u8 gUnknown_081C340A; extern u8 gUnknown_081C342D; @@ -55,7 +56,7 @@ void ResetSafariZoneFlag(void) void EnterSafariMode(void) { - sav12_xor_increment(0x11); + IncrementGameStat(0x11); SetSafariZoneFlag(); ClearAllPokeblockFeeders(); gNumSafariBalls = 30; @@ -98,14 +99,14 @@ void sub_80C824C(void) { SetMainCallback2(c2_exit_to_overworld_2_switch); } - else if (gUnknown_02024D26 == 8) + else if (gBattleOutcome == 8) { ScriptContext2_RunNewScript(&gUnknown_081C340A); warp_in(); - gUnknown_0300485C = sub_8080E44; + gFieldCallback = sub_8080E44; SetMainCallback2(CB2_LoadMap); } - else if (gUnknown_02024D26 == 7) + else if (gBattleOutcome == 7) { ScriptContext1_SetupScript(&gUnknown_081C3459); ScriptContext1_Stop(); diff --git a/src/save.c b/src/save.c index 1f527bbc0..570210fb0 100644 --- a/src/save.c +++ b/src/save.c @@ -1,59 +1,86 @@ #include "global.h" -#include "save.h" -#include "asm.h" #include "gba/gba.h" +#include "gba/flash_internal.h" +#include "save.h" #include "load_save.h" #include "rom4.h" -#include "gba/flash_internal.h" - -extern struct SaveSection unk_2000000; +#include "save_failed_screen.h" + +#define GETVALIDSTATUSBITFIELD ((1 << ARRAY_COUNT(gSaveSectionLocations)) - 1) +#define GETCHUNKSIZE(chunk, n) ((sizeof(chunk) - (0xF80 * (n - 1))) >= 0xF80 ? 0xF80 : (sizeof(chunk) - (0xF80 * (n - 1)))) +#define GETBLOCKOFFSET(n) (0xF80 * (n - 1)) +#define TOTALNUMSECTORS ((ARRAY_COUNT(gSaveSectionLocations) * 2) + (ARRAY_COUNT(gHallOfFameSaveSectionLocations) * 2)) // there are 2 slots, so double each array count and get the sum. + +extern u32 gLastSaveSectorStatus; // used but in an unferenced function, so unused +extern u16 gLastWrittenSector; +extern u32 gLastSaveCounter; +extern u16 gLastKnownGoodSector; +extern u32 gDamagedSaveSectors; +extern u32 gSaveCounter; +extern struct SaveSection unk_2000000; // slow save RAM +extern struct SaveSection *gFastSaveSection; // the pointer is in fast IWRAM but may sometimes point to the slower EWRAM. +extern u16 gUnknown_03005EB4; +extern u16 gSaveFileStatus; +extern u32 gGameContinueCallback; -extern u32 gUnknown_02039284; +extern struct PokemonStorage gPokemonStorage; +extern struct HallOfFame gHallOfFame; -extern u32 gUnknown_3004820; +const struct SaveSectionLocation gSaveSectionLocations[] = +{ + {((u8 *) &gSaveBlock2) + GETBLOCKOFFSET(1), GETCHUNKSIZE(gSaveBlock2, 1)}, + {((u8 *) &gSaveBlock1) + GETBLOCKOFFSET(1), GETCHUNKSIZE(gSaveBlock1, 1)}, + {((u8 *) &gSaveBlock1) + GETBLOCKOFFSET(2), GETCHUNKSIZE(gSaveBlock1, 2)}, + {((u8 *) &gSaveBlock1) + GETBLOCKOFFSET(3), GETCHUNKSIZE(gSaveBlock1, 3)}, + {((u8 *) &gSaveBlock1) + GETBLOCKOFFSET(4), GETCHUNKSIZE(gSaveBlock1, 4)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(1), GETCHUNKSIZE(gPokemonStorage, 1)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(2), GETCHUNKSIZE(gPokemonStorage, 2)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(3), GETCHUNKSIZE(gPokemonStorage, 3)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(4), GETCHUNKSIZE(gPokemonStorage, 4)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(5), GETCHUNKSIZE(gPokemonStorage, 5)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(6), GETCHUNKSIZE(gPokemonStorage, 6)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(7), GETCHUNKSIZE(gPokemonStorage, 7)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(8), GETCHUNKSIZE(gPokemonStorage, 8)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(9), GETCHUNKSIZE(gPokemonStorage, 9)} +}; -extern u16 gUnknown_03005E9C; -extern u32 gUnknown_03005EA0; -extern u16 gUnknown_03005EA4; -extern u32 gUnknown_03005EA8; -extern u32 gUnknown_03005EAC; -extern struct SaveSection *gUnknown_03005EB0; -extern u16 gUnknown_03005EB4; -extern u16 gSaveFileStatus; -extern u32 gUnknown_03005EBC; +const struct SaveSectionLocation gHallOfFameSaveSectionLocations[] = +{ + {((u8 *) &gHallOfFame) + GETBLOCKOFFSET(1), GETCHUNKSIZE(struct HallOfFame, 1)}, // gHallOfFame is not a proper sym, so the struct must be used. + {((u8 *) &gHallOfFame) + GETBLOCKOFFSET(2), GETCHUNKSIZE(struct HallOfFame, 2)} +}; -extern struct SaveSectionLocation gSaveSectionLocations[]; -extern struct SaveSectionLocation gHallOfFameSaveSectionLocations[]; -extern u8 gUnknown_08401E24[]; +const u8 gFlashSectors[] = { 0x1E, 0x1F }; void ClearSaveData(void) { u16 i; - for (i = 0; i < 32; i++) + + for (i = 0; i < NUM_SECTORS; i++) EraseFlashSector(i); } -void sub_81251B8(void) +void ResetSaveCounters(void) { - gUnknown_03005EAC = 0; - gUnknown_03005E9C = 0; - gUnknown_03005EA8 = 0; + gSaveCounter = 0; + gLastWrittenSector = 0; + gDamagedSaveSectors = 0; } -bool32 sub_81251D4(u8 op, u8 bit) +bool32 SetDamagedSectorBits(u8 op, u8 bit) { bool32 retVal = FALSE; switch (op) { - case 0: - gUnknown_03005EA8 |= 1 << bit; + case ENABLE: + gDamagedSaveSectors |= (1 << bit); break; - case 1: - gUnknown_03005EA8 &= ~(1 << bit); + case DISABLE: + gDamagedSaveSectors &= ~(1 << bit); break; - case 2: - if (gUnknown_03005EA8 & (1 << bit)) + case CHECK: // unused + if (gDamagedSaveSectors & (1 << bit)) retVal = TRUE; break; } @@ -61,67 +88,70 @@ bool32 sub_81251D4(u8 op, u8 bit) return retVal; } -u8 save_write_to_flash(u16 a1, struct SaveSectionLocation *a2) +u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *location) { u32 retVal; u16 i; - gUnknown_03005EB0 = &unk_2000000; + gFastSaveSection = &unk_2000000; - if (a1 != 0xFFFF) + if (a1 != 0xFFFF) // for link { - retVal = sub_81252D8(a1, a2); + retVal = HandleWriteSector(a1, location); } else { - gUnknown_03005EA4 = gUnknown_03005E9C; - gUnknown_03005EA0 = gUnknown_03005EAC; - gUnknown_03005E9C++; - gUnknown_03005E9C = gUnknown_03005E9C % 14; - gUnknown_03005EAC++; + gLastKnownGoodSector = gLastWrittenSector; // backup the current written sector before attempting to write. + gLastSaveCounter = gSaveCounter; + gLastWrittenSector++; + gLastWrittenSector = gLastWrittenSector % ARRAY_COUNT(gSaveSectionLocations); + gSaveCounter++; retVal = 1; - for (i = 0; i < 14; i++) - sub_81252D8(i, a2); - if (gUnknown_03005EA8) + + for (i = 0; i < ARRAY_COUNT(gSaveSectionLocations); i++) + HandleWriteSector(i, location); + + if (gDamagedSaveSectors != 0) // skip the damaged sector. { retVal = 0xFF; - gUnknown_03005E9C = gUnknown_03005EA4; - gUnknown_03005EAC = gUnknown_03005EA0; + gLastWrittenSector = gLastKnownGoodSector; + gSaveCounter = gLastSaveCounter; } } return retVal; } -u8 sub_81252D8(u16 a1, struct SaveSectionLocation *a2) +u8 HandleWriteSector(u16 a1, const struct SaveSectionLocation *location) { u16 i; u16 sector; u8 *data; u16 size; - sector = a1 + gUnknown_03005E9C; - sector %= 14; - sector += 14 * (gUnknown_03005EAC % 2); + sector = a1 + gLastWrittenSector; + sector %= ARRAY_COUNT(gSaveSectionLocations); + sector += ARRAY_COUNT(gSaveSectionLocations) * (gSaveCounter % 2); - data = a2[a1].data; - size = a2[a1].size; + data = location[a1].data; + size = location[a1].size; + // clear save section. for (i = 0; i < sizeof(struct SaveSection); i++) - ((char *)gUnknown_03005EB0)[i] = 0; + ((char *)gFastSaveSection)[i] = 0; - gUnknown_03005EB0->id = a1; - gUnknown_03005EB0->unknown = 0x8012025; - gUnknown_03005EB0->counter = gUnknown_03005EAC; + gFastSaveSection->id = a1; + gFastSaveSection->security = UNKNOWN_CHECK_VALUE; + gFastSaveSection->counter = gSaveCounter; for (i = 0; i < size; i++) - gUnknown_03005EB0->data[i] = data[i]; + gFastSaveSection->data[i] = data[i]; - gUnknown_03005EB0->checksum = sub_8125C10(data, size); - return sub_8125440(sector, gUnknown_03005EB0->data); + gFastSaveSection->checksum = CalculateChecksum(data, size); + return TryWriteSector(sector, gFastSaveSection->data); } -u8 sub_81253C8(u8 sector, u8 *data, u16 size) +u8 HandleWriteSectorNBytes(u8 sector, u8 *data, u16 size) { u16 i; struct SaveSection *section = &unk_2000000; @@ -129,66 +159,66 @@ u8 sub_81253C8(u8 sector, u8 *data, u16 size) for (i = 0; i < sizeof(struct SaveSection); i++) ((char *)section)[i] = 0; - section->unknown = 0x8012025; + section->security = UNKNOWN_CHECK_VALUE; for (i = 0; i < size; i++) section->data[i] = data[i]; - section->id = sub_8125C10(data, size); // id instead of checksum? - return sub_8125440(sector, section->data); + section->id = CalculateChecksum(data, size); // though this appears to be incorrect, it might be some sector checksum instead of a whole save checksum and only appears to be relevent to HOF data, if used. + return TryWriteSector(sector, section->data); } -u8 sub_8125440(u8 sector, u8 *data) +u8 TryWriteSector(u8 sector, u8 *data) { - if (ProgramFlashSectorAndVerify(sector, data)) + if (ProgramFlashSectorAndVerify(sector, data) != 0) // is damaged? { - sub_81251D4(0, sector); + SetDamagedSectorBits(ENABLE, sector); // set damaged sector bits. return 0xFF; } else { - sub_81251D4(1, sector); + SetDamagedSectorBits(DISABLE, sector); // unset damaged sector bits. it's safe now. return 1; } } -u32 sub_812546C(struct SaveSectionLocation *a1) +u32 RestoreSaveBackupVarsAndIncrement(const struct SaveSectionLocation *location) // location is unused { - gUnknown_03005EB0 = &unk_2000000; - gUnknown_03005EA4 = gUnknown_03005E9C; - gUnknown_03005EA0 = gUnknown_03005EAC; - gUnknown_03005E9C++; - gUnknown_03005E9C = gUnknown_03005E9C % 14; - gUnknown_03005EAC++; + gFastSaveSection = &unk_2000000; + gLastKnownGoodSector = gLastWrittenSector; + gLastSaveCounter = gSaveCounter; + gLastWrittenSector++; + gLastWrittenSector = gLastWrittenSector % ARRAY_COUNT(gSaveSectionLocations); + gSaveCounter++; gUnknown_03005EB4 = 0; - gUnknown_03005EA8 = 0; + gDamagedSaveSectors = 0; return 0; } -u32 sub_81254C8(struct SaveSectionLocation *a1) +u32 RestoreSaveBackupVars(const struct SaveSectionLocation *location) // only ever called once, and gSaveBlock2 is passed to this function. location is unused { - gUnknown_03005EB0 = &unk_2000000; - gUnknown_03005EA4 = gUnknown_03005E9C; - gUnknown_03005EA0 = gUnknown_03005EAC; + gFastSaveSection = &unk_2000000; + gLastKnownGoodSector = gLastWrittenSector; + gLastSaveCounter = gSaveCounter; gUnknown_03005EB4 = 0; - gUnknown_03005EA8 = 0; + gDamagedSaveSectors = 0; return 0; } -u8 sub_812550C(u16 a1, struct SaveSectionLocation *a2) +u8 sub_812550C(u16 a1, const struct SaveSectionLocation *location) { u8 retVal; if (gUnknown_03005EB4 < a1 - 1) { retVal = 1; - sub_81252D8(gUnknown_03005EB4, a2); + HandleWriteSector(gUnknown_03005EB4, location); gUnknown_03005EB4++; - if (gUnknown_03005EA8) + if (gDamagedSaveSectors) { retVal = 0xFF; - gUnknown_03005E9C = gUnknown_03005EA4; - gUnknown_03005EAC = gUnknown_03005EA0; + gLastWrittenSector = gLastKnownGoodSector; + gSaveCounter = gLastSaveCounter; } } else @@ -199,20 +229,22 @@ u8 sub_812550C(u16 a1, struct SaveSectionLocation *a2) return retVal; } -u8 sub_812556C(u16 a1, struct SaveSectionLocation *a2) +u8 sub_812556C(u16 a1, const struct SaveSectionLocation *location) { u8 retVal = 1; - sub_81255B8(a1 - 1, a2); - if (gUnknown_03005EA8) + + sub_81255B8(a1 - 1, location); + + if (gDamagedSaveSectors) { retVal = 0xFF; - gUnknown_03005E9C = gUnknown_03005EA4; - gUnknown_03005EAC = gUnknown_03005EA0; + gLastWrittenSector = gLastKnownGoodSector; + gSaveCounter = gLastSaveCounter; } return retVal; } -u8 sub_81255B8(u16 a1, struct SaveSectionLocation *a2) +u8 sub_81255B8(u16 a1, const struct SaveSectionLocation *location) { u16 i; u16 sector; @@ -220,32 +252,35 @@ u8 sub_81255B8(u16 a1, struct SaveSectionLocation *a2) u16 size; u8 status; - sector = a1 + gUnknown_03005E9C; - sector %= 14; - sector += 14 * (gUnknown_03005EAC % 2); + sector = a1 + gLastWrittenSector; + sector %= ARRAY_COUNT(gSaveSectionLocations); + sector += ARRAY_COUNT(gSaveSectionLocations) * (gSaveCounter % 2); - data = a2[a1].data; - size = a2[a1].size; + data = location[a1].data; + size = location[a1].size; + // clear temp save section. for (i = 0; i < sizeof(struct SaveSection); i++) - ((char *)gUnknown_03005EB0)[i] = 0; + ((char *)gFastSaveSection)[i] = 0; - gUnknown_03005EB0->id = a1; - gUnknown_03005EB0->unknown = 0x8012025; - gUnknown_03005EB0->counter = gUnknown_03005EAC; + gFastSaveSection->id = a1; + gFastSaveSection->security = UNKNOWN_CHECK_VALUE; + gFastSaveSection->counter = gSaveCounter; + // set temp section's data. for (i = 0; i < size; i++) - gUnknown_03005EB0->data[i] = data[i]; + gFastSaveSection->data[i] = data[i]; - gUnknown_03005EB0->checksum = sub_8125C10(data, size); + // calculate checksum. + gFastSaveSection->checksum = CalculateChecksum(data, size); EraseFlashSector(sector); status = 1; - for (i = 0; i < 0xFF8; i++) + for (i = 0; i < sizeof(struct UnkSaveSection); i++) { - if (ProgramFlashByte(sector, i, ((u8 *)gUnknown_03005EB0)[i])) + if (ProgramFlashByte(sector, i, ((u8 *)gFastSaveSection)[i])) { status = 0xFF; break; @@ -254,7 +289,7 @@ u8 sub_81255B8(u16 a1, struct SaveSectionLocation *a2) if (status == 0xFF) { - sub_81251D4(0, sector); + SetDamagedSectorBits(ENABLE, sector); return 0xFF; } else @@ -263,7 +298,7 @@ u8 sub_81255B8(u16 a1, struct SaveSectionLocation *a2) for (i = 0; i < 7; i++) { - if (ProgramFlashByte(sector, 0xFF9 + i, ((u8 *)gUnknown_03005EB0)[0xFF9 + i])) + if (ProgramFlashByte(sector, 0xFF9 + i, ((u8 *)gFastSaveSection)[0xFF9 + i])) { status = 0xFF; break; @@ -272,227 +307,228 @@ u8 sub_81255B8(u16 a1, struct SaveSectionLocation *a2) if (status == 0xFF) { - sub_81251D4(0, sector); + SetDamagedSectorBits(ENABLE, sector); return 0xFF; } else { - sub_81251D4(1, sector); + SetDamagedSectorBits(DISABLE, sector); return 1; } } } -u8 sub_8125758(u16 a1, struct SaveSectionLocation *a2) +u8 sub_8125758(u16 a1, const struct SaveSectionLocation *location) { u16 sector; - sector = a1 + gUnknown_03005E9C - 1; - sector %= 14; - sector += 14 * (gUnknown_03005EAC % 2); + sector = a1 + gLastWrittenSector - 1; + sector %= ARRAY_COUNT(gSaveSectionLocations); + sector += ARRAY_COUNT(gSaveSectionLocations) * (gSaveCounter % 2); - if (ProgramFlashByte(sector, 0xFF8, ((u8 *)gUnknown_03005EB0)[0xFF8])) + if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), ((u8 *)gFastSaveSection)[sizeof(struct UnkSaveSection)])) { - sub_81251D4(0, sector); - gUnknown_03005E9C = gUnknown_03005EA4; - gUnknown_03005EAC = gUnknown_03005EA0; + // sector is damaged, so enable the bit in gDamagedSaveSectors and restore the last written sector and save counter. + SetDamagedSectorBits(ENABLE, sector); + gLastWrittenSector = gLastKnownGoodSector; + gSaveCounter = gLastSaveCounter; return 0xFF; } else { - sub_81251D4(1u, sector); + SetDamagedSectorBits(DISABLE, sector); return 1; } } -u8 sub_81257F0(u16 a1, struct SaveSectionLocation *a2) +u8 sub_81257F0(u16 a1, const struct SaveSectionLocation *location) { u16 sector; - sector = a1 + gUnknown_03005E9C - 1; - sector %= 14; - sector += 14 * (gUnknown_03005EAC % 2); + sector = a1 + gLastWrittenSector - 1; + sector %= ARRAY_COUNT(gSaveSectionLocations); + sector += ARRAY_COUNT(gSaveSectionLocations) * (gSaveCounter % 2); - if (ProgramFlashByte(sector, 0xFF8, 0x25)) + if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), 0x25)) { - sub_81251D4(0, sector); - gUnknown_03005E9C = gUnknown_03005EA4; - gUnknown_03005EAC = gUnknown_03005EA0; + // sector is damaged, so enable the bit in gDamagedSaveSectors and restore the last written sector and save counter. + SetDamagedSectorBits(ENABLE, sector); + gLastWrittenSector = gLastKnownGoodSector; + gSaveCounter = gLastSaveCounter; return 0xFF; } else { - sub_81251D4(1u, sector); + SetDamagedSectorBits(DISABLE, sector); return 1; } } -u8 sub_812587C(u16 a1, struct SaveSectionLocation *a2) +u8 sub_812587C(u16 a1, const struct SaveSectionLocation *location) { u8 retVal; - gUnknown_03005EB0 = &unk_2000000; + gFastSaveSection = &unk_2000000; if (a1 != 0xFFFF) { retVal = 0xFF; } else { - retVal = sub_8125974(a2); - sub_81258BC(0xFFFF, a2); + retVal = GetSaveValidStatus(location); + sub_81258BC(0xFFFF, location); } return retVal; } -u8 sub_81258BC(u16 a1, struct SaveSectionLocation *a2) +u8 sub_81258BC(u16 a1, const struct SaveSectionLocation *location) { u16 i; u16 checksum; - u16 v3 = 14 * (gUnknown_03005EAC % 2); + u16 v3 = ARRAY_COUNT(gSaveSectionLocations) * (gSaveCounter % 2); u16 id; - for (i = 0; i < 14; i++) + for (i = 0; i < ARRAY_COUNT(gSaveSectionLocations); i++) { - sub_8125BF8(i + v3, gUnknown_03005EB0); - id = gUnknown_03005EB0->id; + DoReadFlashWholeSection(i + v3, gFastSaveSection); + id = gFastSaveSection->id; if (id == 0) - gUnknown_03005E9C = i; - checksum = sub_8125C10(gUnknown_03005EB0->data, a2[id].size); - if (gUnknown_03005EB0->unknown == 0x8012025 - && gUnknown_03005EB0->checksum == checksum) + gLastWrittenSector = i; + checksum = CalculateChecksum(gFastSaveSection->data, location[id].size); + if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE + && gFastSaveSection->checksum == checksum) { u16 j; - for (j = 0; j < a2[id].size; j++) - ((u8 *)a2[id].data)[j] = gUnknown_03005EB0->data[j]; + for (j = 0; j < location[id].size; j++) + ((u8 *)location[id].data)[j] = gFastSaveSection->data[j]; } } return 1; } -u8 sub_8125974(struct SaveSectionLocation *a1) +u8 GetSaveValidStatus(const struct SaveSectionLocation *location) { u16 i; u16 checksum; - u32 v2 = 0; - u32 v3 = 0; - u32 v4; - bool8 v5; - u8 v14; - u8 v10; - - v4 = 0; - v5 = FALSE; - - for (i = 0; i < 14; i++) - { - sub_8125BF8(i, gUnknown_03005EB0); - if (gUnknown_03005EB0->unknown == 0x8012025) + u32 saveSlot1Counter = 0; + u32 saveSlot2Counter = 0; + u32 slotCheckField = 0; + bool8 securityPassed = FALSE; + u8 saveSlot1Status; + u8 saveSlot2Status; + + // check save slot 1. + for (i = 0; i < ARRAY_COUNT(gSaveSectionLocations); i++) + { + DoReadFlashWholeSection(i, gFastSaveSection); + if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE) { - v5 = TRUE; - checksum = sub_8125C10(gUnknown_03005EB0->data, a1[gUnknown_03005EB0->id].size); - if (gUnknown_03005EB0->checksum == checksum) + securityPassed = TRUE; + checksum = CalculateChecksum(gFastSaveSection->data, location[gFastSaveSection->id].size); + if (gFastSaveSection->checksum == checksum) { - v2 = gUnknown_03005EB0->counter; - v4 |= 1 << gUnknown_03005EB0->id; + saveSlot1Counter = gFastSaveSection->counter; + slotCheckField |= 1 << gFastSaveSection->id; } } } - if (v5) + if (securityPassed) { - if (v4 == 0x3FFF) - v14 = 1; + if (slotCheckField == GETVALIDSTATUSBITFIELD) + saveSlot1Status = 1; else - v14 = 255; + saveSlot1Status = 255; } else { - v14 = 0; + saveSlot1Status = 0; } - v4 = 0; - v5 = FALSE; + slotCheckField = 0; + securityPassed = FALSE; - for (i = 0; i < 14; i++) + // check save slot 2. + for (i = 0; i < ARRAY_COUNT(gSaveSectionLocations); i++) { - sub_8125BF8(i + 14, gUnknown_03005EB0); - if (gUnknown_03005EB0->unknown == 0x8012025) + DoReadFlashWholeSection(i + ARRAY_COUNT(gSaveSectionLocations), gFastSaveSection); + if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE) { - v5 = TRUE; - checksum = sub_8125C10(gUnknown_03005EB0->data, a1[gUnknown_03005EB0->id].size); - if (gUnknown_03005EB0->checksum == checksum) + securityPassed = TRUE; + checksum = CalculateChecksum(gFastSaveSection->data, location[gFastSaveSection->id].size); + if (gFastSaveSection->checksum == checksum) { - v3 = gUnknown_03005EB0->counter; - v4 |= 1 << gUnknown_03005EB0->id; + saveSlot2Counter = gFastSaveSection->counter; + slotCheckField |= 1 << gFastSaveSection->id; } } } - if (v5) + if (securityPassed) { - if (v4 == 0x3FFF) - v10 = 1; + if (slotCheckField == GETVALIDSTATUSBITFIELD) + saveSlot2Status = 1; else - v10 = 255; + saveSlot2Status = 255; } else { - v10 = 0; + saveSlot2Status = 0; } - if (v14 == 1 && v10 == 1) + if (saveSlot1Status == 1 && saveSlot2Status == 1) { - if ((v2 == -1 && v3 == 0) || (v2 == 0 && v3 == -1)) + if ((saveSlot1Counter == -1 && saveSlot2Counter == 0) || (saveSlot1Counter == 0 && saveSlot2Counter == -1)) { - if ((unsigned)(v2 + 1) < (unsigned)(v3 + 1)) + if ((unsigned)(saveSlot1Counter + 1) < (unsigned)(saveSlot2Counter + 1)) { - gUnknown_03005EAC = v3; + gSaveCounter = saveSlot2Counter; } else { - gUnknown_03005EAC = v2; + gSaveCounter = saveSlot1Counter; } } else { - if (v2 < v3) + if (saveSlot1Counter < saveSlot2Counter) { - gUnknown_03005EAC = v3; + gSaveCounter = saveSlot2Counter; } else { - gUnknown_03005EAC = v2; + gSaveCounter = saveSlot1Counter; } } return 1; } - if (v14 == 1) + if (saveSlot1Status == 1) { - gUnknown_03005EAC = v2; - if (v10 == 255) + gSaveCounter = saveSlot1Counter; + if (saveSlot2Status == 255) return 255; return 1; } - if (v10 == 1) + if (saveSlot2Status == 1) { - gUnknown_03005EAC = v3; - if (v14 == 255) + gSaveCounter = saveSlot2Counter; + if (saveSlot1Status == 255) return 255; return 1; } - if (v14 == 0 && v10 == 0) + if (saveSlot1Status == 0 && saveSlot2Status == 0) { - gUnknown_03005EAC = 0; - gUnknown_03005E9C = 0; + gSaveCounter = 0; + gLastWrittenSector = 0; return 0; } - gUnknown_03005EAC = 0; - gUnknown_03005E9C = 0; + gSaveCounter = 0; + gLastWrittenSector = 0; return 2; } @@ -500,10 +536,10 @@ u8 sub_8125B88(u8 a1, u8 *data, u16 size) { u16 i; struct SaveSection *section = &unk_2000000; - sub_8125BF8(a1, section); - if (section->unknown == 0x8012025) + DoReadFlashWholeSection(a1, section); + if (section->security == UNKNOWN_CHECK_VALUE) { - u16 checksum = sub_8125C10(section->data, size); + u16 checksum = CalculateChecksum(section->data, size); if (section->id == checksum) { for (i = 0; i < size; i++) @@ -521,13 +557,13 @@ u8 sub_8125B88(u8 a1, u8 *data, u16 size) } } -u8 sub_8125BF8(u8 sector, struct SaveSection *section) +u8 DoReadFlashWholeSection(u8 sector, struct SaveSection *section) { - ReadFlash(sector, 0, section->data, 0x1000); + ReadFlash(sector, 0, section->data, sizeof(struct SaveSection)); return 1; } -u16 sub_8125C10(void *data, u16 size) +u16 CalculateChecksum(void *data, u16 size) { u16 i; u32 checksum = 0; @@ -538,39 +574,39 @@ u16 sub_8125C10(void *data, u16 size) return ((checksum >> 16) + checksum); } -u8 sub_8125C3C(u8 a1) +u8 HandleSavingData(u8 saveType) { u8 i; - switch (a1) + switch (saveType) { - case 5: - for (i = 28; i < 32; i++) + case HOF_DELETE_SAVE: // deletes HOF before overwriting HOF completely. unused + for (i = (ARRAY_COUNT(gSaveSectionLocations) * 2 + 0); i < TOTALNUMSECTORS; i++) EraseFlashSector(i); - case 3: - if (sub_8053108(10) < 999) - sav12_xor_increment(10); - for (i = 0; i < 2; i++) - sub_81253C8(28 + i, gHallOfFameSaveSectionLocations[i].data, gHallOfFameSaveSectionLocations[i].size); + case HOF_SAVE: // hall of fame. + if (GetGameStat(10) < 999) + IncrementGameStat(10); + for (i = 0; i < ARRAY_COUNT(gHallOfFameSaveSectionLocations); i++) + HandleWriteSectorNBytes((ARRAY_COUNT(gSaveSectionLocations) * 2 + 0) + i, gHallOfFameSaveSectionLocations[i].data, gHallOfFameSaveSectionLocations[i].size); SaveSerializedGame(); save_write_to_flash(0xFFFF, gSaveSectionLocations); break; - case 0: + case NORMAL_SAVE: // normal save. also called by overwriting your own save. default: SaveSerializedGame(); save_write_to_flash(0xFFFF, gSaveSectionLocations); break; - case 1: + case LINK_SAVE: // link save. updates only gSaveBlock1 and gSaveBlock2. SaveSerializedGame(); for (i = 0; i < 5; i++) save_write_to_flash(i, gSaveSectionLocations); break; - case 2: + case EREADER_SAVE: // used in mossdeep "game corner" before/after battling old man e-reader trainer SaveSerializedGame(); save_write_to_flash(0, gSaveSectionLocations); break; - case 4: - for (i = 28; i < 32; i++) - EraseFlashSector(i); + case DIFFERENT_FILE_SAVE: // there is a different file, so erase the file and overwrite it completely. + for (i = (ARRAY_COUNT(gSaveSectionLocations) * 2 + 0); i < TOTALNUMSECTORS; i++) + EraseFlashSector(i); // erase HOF. SaveSerializedGame(); save_write_to_flash(0xFFFF, gSaveSectionLocations); break; @@ -578,60 +614,60 @@ u8 sub_8125C3C(u8 a1) return 0; } -u8 sub_8125D44(u8 a1) +u8 TrySavingData(u8 saveType) // TrySave { - if (gUnknown_3004820 != 1) + if (gFlashMemoryPresent != TRUE) return 0xFF; - sub_8125C3C(a1); - if (!gUnknown_03005EA8) + HandleSavingData(saveType); + if (!gDamagedSaveSectors) return 1; - fullscreen_save_activate(a1); + DoSaveFailedScreen(saveType); return 0xFF; } -u8 sub_8125D80(void) +u8 sub_8125D80(void) // trade.s save { - if (gUnknown_3004820 != 1) + if (gFlashMemoryPresent != TRUE) return 1; SaveSerializedGame(); - sub_812546C(gSaveSectionLocations); + RestoreSaveBackupVarsAndIncrement(gSaveSectionLocations); return 0; } -bool8 sub_8125DA8(void) +bool8 sub_8125DA8(void) // trade.s save { - u8 v0 = sub_812550C(14, gSaveSectionLocations); - if (gUnknown_03005EA8) - fullscreen_save_activate(0); - if (v0 == 0xFF) + u8 retVal = sub_812550C(ARRAY_COUNT(gSaveSectionLocations), gSaveSectionLocations); + if (gDamagedSaveSectors) + DoSaveFailedScreen(0); + if (retVal == 0xFF) return 1; else return 0; } -u8 sub_8125DDC(void) +u8 sub_8125DDC(void) // trade.s save { - sub_812556C(14, gSaveSectionLocations); - if (gUnknown_03005EA8) - fullscreen_save_activate(0); + sub_812556C(ARRAY_COUNT(gSaveSectionLocations), gSaveSectionLocations); + if (gDamagedSaveSectors) + DoSaveFailedScreen(0); return 0; } -u8 sub_8125E04(void) +u8 sub_8125E04(void) // trade.s save { - sub_8125758(14, gSaveSectionLocations); - if (gUnknown_03005EA8) - fullscreen_save_activate(0); + sub_8125758(ARRAY_COUNT(gSaveSectionLocations), gSaveSectionLocations); + if (gDamagedSaveSectors) + DoSaveFailedScreen(0); return 0; } u8 sub_8125E2C(void) { - if (gUnknown_3004820 != 1) + if (gFlashMemoryPresent != TRUE) return 1; SaveSerializedGame(); - sub_81254C8(gSaveSectionLocations); + RestoreSaveBackupVars(gSaveSectionLocations); sub_812556C(gUnknown_03005EB4 + 1, gSaveSectionLocations); return 0; } @@ -650,8 +686,8 @@ u8 sub_8125E6C(void) sub_81257F0(val, gSaveSectionLocations); retVal = 1; } - if (gUnknown_03005EA8) - fullscreen_save_activate(1); + if (gDamagedSaveSectors) + DoSaveFailedScreen(1); return retVal; } @@ -659,7 +695,7 @@ u8 sub_8125EC8(u8 a1) { u8 result; - if (gUnknown_3004820 != 1) + if (gFlashMemoryPresent != TRUE) { gSaveFileStatus = 4; return 0xFF; @@ -672,12 +708,12 @@ u8 sub_8125EC8(u8 a1) result = sub_812587C(0xFFFF, gSaveSectionLocations); LoadSerializedGame(); gSaveFileStatus = result; - gUnknown_03005EBC = 0; + gGameContinueCallback = 0; break; case 3: - result = sub_8125B88(28, gHallOfFameSaveSectionLocations[0].data, gHallOfFameSaveSectionLocations[0].size); + result = sub_8125B88((ARRAY_COUNT(gSaveSectionLocations) * 2 + 0), gHallOfFameSaveSectionLocations[0].data, gHallOfFameSaveSectionLocations[0].size); if (result == 1) - result = sub_8125B88(29, gHallOfFameSaveSectionLocations[1].data, gHallOfFameSaveSectionLocations[1].size); + result = sub_8125B88((ARRAY_COUNT(gSaveSectionLocations) * 2 + 1), gHallOfFameSaveSectionLocations[1].data, gHallOfFameSaveSectionLocations[1].size); break; } @@ -689,12 +725,12 @@ bool8 unref_sub_8125F4C(struct UnkSaveSection *a1) u16 i; char *raw = (char *)a1; - for (i = 0; i < 0x1000; i++) + for (i = 0; i < sizeof(struct SaveSection); i++) raw[i] = 0; - ReadFlash(gUnknown_08401E24[0], 0, a1->data, 4096); + ReadFlash(gFlashSectors[0], 0, a1->data, 4096); - if (a1->unknown != 0x8012025) + if (a1->security != UNKNOWN_CHECK_VALUE) return FALSE; return TRUE; @@ -703,10 +739,10 @@ bool8 unref_sub_8125F4C(struct UnkSaveSection *a1) u8 unref_sub_8125FA0(void) { u16 i; - u8 v0 = sub_8125D44(0); + u8 v0 = TrySavingData(0); for (i = 0; i < 2; i++) - EraseFlashSector(gUnknown_08401E24[i]); + EraseFlashSector(gFlashSectors[i]); if (v0 == 255) { @@ -728,25 +764,25 @@ u8 unref_sub_8125FF0(u8 *data, u16 size) u16 i; struct UnkSaveSection *section = (struct UnkSaveSection *)&unk_2000000; - for (i = 0; i < 0x1000; i++) + for (i = 0; i < sizeof(struct SaveSection); i++) ((char *)section)[i] = 0; - section->unknown = 0x8012025; + section->security = UNKNOWN_CHECK_VALUE; for (i = 0; i < size; i++) section->data[i] = data[i]; - gUnknown_02039284 = ProgramFlashSectorAndVerifyNBytes(gUnknown_08401E24[0], (u8 *)section, 0x1000); + gLastSaveSectorStatus = ProgramFlashSectorAndVerifyNBytes(gFlashSectors[0], (u8 *)section, sizeof(struct SaveSection)); - if (gUnknown_02039284) - return 255; + if (gLastSaveSectorStatus) + return 0xFF; else return 1; } u8 unref_sub_8126068(u8 sector, u8 *data, u32 size) { - if (ProgramFlashSectorAndVerify(sector, data, size)) + if (ProgramFlashSectorAndVerify(sector, data)) return 255; else return 1; @@ -754,6 +790,6 @@ u8 unref_sub_8126068(u8 sector, u8 *data, u32 size) u8 unref_sub_8126080(u8 sector, u8 *data) { - ReadFlash(sector, 0, data, 0x1000); + ReadFlash(sector, 0, data, sizeof(struct SaveSection)); return 1; } diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 8c724e1c5..a64b3eb5f 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -1,475 +1,316 @@ #include "global.h" +#include "gba/flash_internal.h" +#include "save_failed_screen.h" +#include "m4a.h" #include "main.h" -#include "sprite.h" +#include "menu.h" #include "palette.h" +#include "save.h" +#include "sprite.h" +#include "starter_choose.h" +#include "strings.h" #include "task.h" #include "text.h" -#include "menu.h" -#include "save.h" -#include "m4a.h" -#include "gba/flash_internal.h" -#include "asm.h" - -extern u8 unk_2000000[]; -extern u16 gUnknown_0203933C; -extern u16 gUnknown_0203933E; -extern u32 gUnknown_03005EA8; -extern u32 gUnknown_03005EBC; +// In English 1.0, the text window is too small, causing text to overflow. -extern u8 gBirchHelpGfx[]; +#ifdef BUGFIX_SAVEFAILEDSCREEN1 +#define MSG_WIN_TOP 10 +#else +#define MSG_WIN_TOP 12 +#endif -extern u8 gSystemText_SaveFailedBackupCheck[]; -extern u8 gSystemText_CheckCompleteSaveAttempt[]; -extern u8 gSystemText_BackupDamagedGameContinue[]; -extern u8 gSystemText_SaveCompletedPressA[]; -extern u8 gSystemText_SaveCompletedGameEnd[]; -extern u8 gSystemText_GameplayEnded[]; +#define CLOCK_WIN_TOP (MSG_WIN_TOP - 4) -extern u8 gBirchGrassTilemap[]; -extern u8 gBirchBagTilemap[]; +struct SaveFailedClockStruct +{ + bool16 clockRunning; + u16 timer; // appears to be unused, the only case its "used" cannot be reached normally + u8 unused[0xE]; // appears to be unused space. alternatively, there could have been multiple clock structs. however, neither of these cases are fulfilled, so the purpose of this space is unknown. one theory is that there is room for 3 more clock structs (2 16-bit values), so its possible GF intended there to be support for link-based save failed screens in case the synchronization failed, or it in fact was present in an earlier build but taken out for reasons. +}; -extern const u8 gSaveFailedClockGfx[]; -extern const u8 gSaveFailedClockPal[]; -extern u8 gBirchBagGrassPal[]; +extern u8 unk_2000000[]; -void sub_8146E50(void); -void sub_8147048(void); -void sub_8147154(void); -void sub_81471A4(void); -void sub_81471EC(void); -void sub_8147218(void); -bool8 sub_814737C(u32); +extern u16 gSaveFailedType; +extern struct SaveFailedClockStruct gSaveFailedClockInfo; +extern u32 gDamagedSaveSectors; +extern u32 gGameContinueCallback; -void fullscreen_save_activate(u8 var) +static const struct OamData sClockOamData = +{ + 160, // Y + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0 +}; + +static const u8 sClockFrames[8][3] = { - SetMainCallback2(sub_8146E50); - gUnknown_0203933C = var; - gUnknown_0203933E = 0; + { 1, 0, 0 }, + { 5, 0, 0 }, + { 9, 0, 0 }, + { 5, 0, 1 }, + { 1, 0, 1 }, + { 5, 1, 1 }, + { 9, 1, 0 }, + { 5, 1, 0 }, +}; + +static const u8 gSaveFailedClockPal[] = INCBIN_U8("graphics/misc/clock_small.gbapal"); +static const u8 gSaveFailedClockGfx[] = INCBIN_U8("graphics/misc/clock_small.4bpp.lz"); + +static void VBlankCB(void); +static void CB2_SaveFailedScreen(void); +static void CB2_WipeSave(void); +static void CB2_GameplayCannotBeContinued(void); +static void CB2_FadeAndReturnToTitleScreen(void); +static void CB2_ReturnToTitleScreen(void); +static void VBlankCB_UpdateClockGraphics(void); +static bool8 VerifySectorWipe(u16 sector); +static bool8 WipeSector(u16 sector); +static bool8 WipeSectors(u32 sectorBits); + +void DoSaveFailedScreen(u8 saveType) +{ + SetMainCallback2(CB2_SaveFailedScreen); + gSaveFailedType = saveType; + gSaveFailedClockInfo.clockRunning = FALSE; } -void sub_8146E3C(void) +static void VBlankCB(void) { - LoadOam(); - ProcessSpriteCopyRequests(); - TransferPlttBuffer(); + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); } -void sub_8146E50(void) +static void CB2_SaveFailedScreen(void) { - u16 ime; - - switch(gMain.state) - { - case 0: - default: - SetVBlankCallback(0); - REG_DISPCNT = 0; - REG_BG3CNT = 0; - REG_BG2CNT = 0; - REG_BG1CNT = 0; - REG_BG0CNT = 0; - REG_BG3HOFS = 0; - REG_BG3VOFS = 0; - REG_BG2HOFS = 0; - REG_BG2VOFS = 0; - REG_BG1HOFS = 0; - REG_BG1VOFS = 0; - REG_BG0HOFS = 0; - REG_BG0VOFS = 0; - DmaFill16(3, 0, VRAM, VRAM_SIZE); - DmaFill32(3, 0, OAM, OAM_SIZE); - DmaFill16(3, 0, PLTT, PLTT_SIZE); - LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM); - LZ77UnCompVram(&gBirchBagTilemap, (void *)(VRAM + 0x3000)); - LZ77UnCompVram(&gBirchGrassTilemap, (void *)(VRAM + 0x3800)); - LZ77UnCompVram(&gSaveFailedClockGfx, (void *)(VRAM + 0x10020)); - ResetSpriteData(); - ResetTasks(); - ResetPaletteFade(); - LoadPalette(&gBirchBagGrassPal, 0, 0x40); - LoadPalette(&gSaveFailedClockPal, 0x100, 0x20); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); - // in revision 1.0, the text window is too small, causing text to overflow and create garbage. this is fixed in later revisions. -#if (REVISION >= 1) - MenuDrawTextWindow(13, 6, 16, 9); - MenuDrawTextWindow(1, 10, 28, 19); - MenuPrint(gSystemText_SaveFailedBackupCheck, 2, 11); -#else - MenuDrawTextWindow(13, 8, 16, 11); - MenuDrawTextWindow(1, 12, 28, 19); - MenuPrint(gSystemText_SaveFailedBackupCheck, 2, 13); -#endif - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); - ime = REG_IME; - REG_IME = 0; - REG_IE |= INTR_FLAG_VBLANK; - REG_IME = ime; - REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; - SetVBlankCallback(sub_8146E3C); - REG_BG3CNT = 0x703; - REG_BG2CNT = 0x602; - REG_BG0CNT = 0x1f08; - REG_DISPCNT = DISPCNT_OBJ_ON | DISPCNT_BG3_ON | DISPCNT_BG2_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_MODE_0; - gMain.state++; - break; - case 1: - if(!UpdatePaletteFade()) - { - SetMainCallback2(sub_8147048); - SetVBlankCallback(sub_8147218); - } - break; - } + u16 ime; + + switch (gMain.state) + { + case 0: + default: + SetVBlankCallback(0); + REG_DISPCNT = 0; + REG_BG3CNT = 0; + REG_BG2CNT = 0; + REG_BG1CNT = 0; + REG_BG0CNT = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; + REG_BG2HOFS = 0; + REG_BG2VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + DmaFill16(3, 0, VRAM, VRAM_SIZE); + DmaFill32(3, 0, OAM, OAM_SIZE); + DmaFill16(3, 0, PLTT, PLTT_SIZE); + LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM); + LZ77UnCompVram(&gBirchBagTilemap, (void *)(VRAM + 0x3000)); + LZ77UnCompVram(&gBirchGrassTilemap, (void *)(VRAM + 0x3800)); + LZ77UnCompVram(&gSaveFailedClockGfx, (void *)(VRAM + 0x10020)); + ResetSpriteData(); + ResetTasks(); + ResetPaletteFade(); + LoadPalette(&gBirchBagGrassPal, 0, sizeof(gBirchBagGrassPal)); + LoadPalette(&gSaveFailedClockPal, 0x100, sizeof(gSaveFailedClockPal)); + SetUpWindowConfig(&gWindowConfig_81E6C3C); + InitMenuWindow(&gWindowConfig_81E6CE4); + MenuDrawTextWindow(13, CLOCK_WIN_TOP, 16, CLOCK_WIN_TOP + 3); // clock window + MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); // message window + MenuPrint(gSystemText_SaveFailedBackupCheck, 2, MSG_WIN_TOP + 1); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + ime = REG_IME; + REG_IME = 0; + REG_IE |= INTR_FLAG_VBLANK; + REG_IME = ime; + REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; + SetVBlankCallback(VBlankCB); + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(6) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_OBJ_ON | DISPCNT_BG3_ON | DISPCNT_BG2_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_MODE_0; + gMain.state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + SetMainCallback2(CB2_WipeSave); + SetVBlankCallback(VBlankCB_UpdateClockGraphics); + } + break; + } } -void sub_8147048(void) +static void CB2_WipeSave(void) { - u8 clockVal = 0; - - gUnknown_0203933E = 1; - - if(gUnknown_03005EA8) - { - while(1) // _0814705C - { - if(!sub_814737C(gUnknown_03005EA8)) - { - #if (REVISION >= 1) - MenuDrawTextWindow(1, 10, 28, 19); - MenuPrint(gSystemText_CheckCompleteSaveAttempt, 2, 11); - #else - MenuDrawTextWindow(1, 12, 28, 19); - MenuPrint(gSystemText_CheckCompleteSaveAttempt, 2, 13); - #endif - sub_8125C3C(gUnknown_0203933C); - - if(gUnknown_03005EA8) - #if (REVISION >= 1) - MenuPrint(gSystemText_SaveFailedBackupCheck, 2, 11); - #else - MenuPrint(gSystemText_SaveFailedBackupCheck, 2, 13); - #endif - - clockVal++; - - if(!gUnknown_03005EA8 || clockVal > 2) - break; // go to _081470A6 - - continue; - } - goto gotoLabel2; - } - } - if(clockVal == 3) // _081470A6 - { - #if (REVISION >= 1) - MenuDrawTextWindow(1, 10, 28, 19); - MenuPrint(gSystemText_BackupDamagedGameContinue, 2, 11); - #else - MenuDrawTextWindow(1, 12, 28, 19); - MenuPrint(gSystemText_BackupDamagedGameContinue, 2, 13); - #endif - SetMainCallback2(sub_81471A4); - goto gotoLabel; // this calls sub_81471A4 for some reason. - } - else // _081470E4 - { - #if (REVISION >= 1) - MenuDrawTextWindow(1, 10, 28, 19); - #else - MenuDrawTextWindow(1, 12, 28, 19); - #endif - - if(!gUnknown_03005EBC) // cant continue game. - { - #if (REVISION >= 1) - MenuPrint(gSystemText_SaveCompletedGameEnd, 2, 11); - #else - MenuPrint(gSystemText_SaveCompletedGameEnd, 2, 13); - #endif - goto gotoLabel; - } - else // can continue game. - goto gotoLabel3; - } - // no matter what I do, i can't get rid of these gotos. They were seemingly labeled at the end by the developer and jumped to manually depending on the result. -gotoLabel2: // _0814710C -#if (REVISION >= 1) - MenuDrawTextWindow(1, 10, 28, 19); - MenuPrint(gSystemText_BackupDamagedGameContinue, 2, 11); -#else - MenuDrawTextWindow(1, 12, 28, 19); - MenuPrint(gSystemText_BackupDamagedGameContinue, 2, 13); -#endif - SetMainCallback2(sub_8147154); - return; + u8 wipeTries = 0; + + gSaveFailedClockInfo.clockRunning = TRUE; + + while (gDamagedSaveSectors != 0 && wipeTries < 3) // while there are still attempts left, keep trying to fix the save sectors. + { + if (WipeSectors(gDamagedSaveSectors) != FALSE) + { + MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); + MenuPrint(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1); + SetMainCallback2(CB2_GameplayCannotBeContinued); + return; + } -gotoLabel3: -#if (REVISION >= 1) - MenuPrint(gSystemText_SaveCompletedPressA, 2, 11); -#else - MenuPrint(gSystemText_SaveCompletedPressA, 2, 13); + MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); + MenuPrint(gSystemText_CheckCompleteSaveAttempt, 2, MSG_WIN_TOP + 1); + HandleSavingData(gSaveFailedType); + + if (gDamagedSaveSectors != 0) + { +#ifdef BUGFIX_SAVEFAILEDSCREEN2 + MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); #endif + MenuPrint(gSystemText_SaveFailedBackupCheck, 2, MSG_WIN_TOP + 1); + } -gotoLabel: // _0814713E - SetMainCallback2(sub_81471A4); // seemingly called twice? -} + wipeTries++; + } -void sub_8147154(void) -{ - gUnknown_0203933E = 0; - - if(gMain.newKeys & A_BUTTON) - { - #if (REVISION >= 1) - MenuDrawTextWindow(1, 10, 28, 19); - MenuPrint(gSystemText_GameplayEnded, 2, 11); - #else - MenuDrawTextWindow(1, 12, 28, 19); - MenuPrint(gSystemText_GameplayEnded, 2, 13); - #endif - SetVBlankCallback(sub_8146E3C); - SetMainCallback2(sub_81471A4); - } + if (wipeTries == 3) + { + MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); + MenuPrint(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1); + SetMainCallback2(CB2_FadeAndReturnToTitleScreen); // called again below + } + else + { + MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); + + // no callback exists, so the game cannot continue. + if (gGameContinueCallback == 0) + MenuPrint(gSystemText_SaveCompletedGameEnd, 2, MSG_WIN_TOP + 1); + else // callback exists, so continue + MenuPrint(gSystemText_SaveCompletedPressA, 2, MSG_WIN_TOP + 1); + } + + SetMainCallback2(CB2_FadeAndReturnToTitleScreen); } -void sub_81471A4(void) +static void CB2_GameplayCannotBeContinued(void) { - u8 zero; - - gUnknown_0203933E = zero = 0; - - if(gMain.newKeys & A_BUTTON) - { - BeginNormalPaletteFade(0xFFFFFFFF, 0, zero, 16, 0); - SetVBlankCallback(sub_8146E3C); - SetMainCallback2(sub_81471EC); - } + gSaveFailedClockInfo.clockRunning = FALSE; + + if (gMain.newKeys & A_BUTTON) + { + MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); + MenuPrint(gSystemText_GameplayEnded, 2, MSG_WIN_TOP + 1); + SetVBlankCallback(VBlankCB); + SetMainCallback2(CB2_FadeAndReturnToTitleScreen); + } } -void sub_81471EC(void) +static void CB2_FadeAndReturnToTitleScreen(void) { - if(!UpdatePaletteFade()) - { - if(!gUnknown_03005EBC) - DoSoftReset(); - else - { - SetMainCallback2((MainCallback)gUnknown_03005EBC); - gUnknown_03005EBC = 0; - } - } + gSaveFailedClockInfo.clockRunning = FALSE; + + if (gMain.newKeys & A_BUTTON) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + SetVBlankCallback(VBlankCB); + SetMainCallback2(CB2_ReturnToTitleScreen); + } } -// do later -__attribute__((naked)) -void sub_8147218(void) +static void CB2_ReturnToTitleScreen(void) { - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - ldr r0, _08147290 @ =gMain\n\ - mov r12, r0\n\ - ldr r0, [r0, 0x24]\n\ - lsrs r4, r0, 3\n\ - movs r0, 0x7\n\ - ands r4, r0\n\ - ldr r0, _08147294 @ =gUnknown_08411940\n\ - ldr r1, [r0, 0x4]\n\ - ldr r0, [r0]\n\ - mov r2, r12\n\ - str r0, [r2, 0x3C]\n\ - str r1, [r2, 0x40]\n\ - ldrh r1, [r2, 0x3E]\n\ - ldr r0, _08147298 @ =0xfffffe00\n\ - ands r0, r1\n\ - movs r1, 0x70\n\ - orrs r0, r1\n\ - strh r0, [r2, 0x3E]\n\ - mov r1, r12\n\ - adds r1, 0x3C\n\ - @.if REVISION >= 1\n\ - @movs r0, 0x38\n\ - @.else\n\ - movs r0, 0x48\n\ - @.endif\n\ - strb r0, [r1]\n\ - ldr r0, _0814729C @ =gUnknown_0203933E\n\ - ldrh r0, [r0]\n\ - cmp r0, 0\n\ - beq _081472A8\n\ - ldr r3, _081472A0 @ =gUnknown_08411948\n\ - lsls r2, r4, 1\n\ - adds r2, r4\n\ - adds r0, r2, r3\n\ - mov r4, r12\n\ - adds r4, 0x40\n\ - ldrb r5, [r0]\n\ - ldrh r1, [r4]\n\ - ldr r0, _081472A4 @ =0xfffffc00\n\ - ands r0, r1\n\ - orrs r0, r5\n\ - strh r0, [r4]\n\ - adds r0, r3, 0x2\n\ - adds r0, r2, r0\n\ - ldrb r1, [r0]\n\ - lsls r1, 4\n\ - adds r3, 0x1\n\ - adds r2, r3\n\ - ldrb r0, [r2]\n\ - lsls r0, 3\n\ - orrs r1, r0\n\ - mov r3, r12\n\ - adds r3, 0x3F\n\ - movs r0, 0x1F\n\ - ands r1, r0\n\ - lsls r1, 1\n\ - ldrb r2, [r3]\n\ - movs r0, 0x3F\n\ - negs r0, r0\n\ - ands r0, r2\n\ - orrs r0, r1\n\ - strb r0, [r3]\n\ - b _081472B8\n\ - .align 2, 0\n\ -_08147290: .4byte gMain\n\ -_08147294: .4byte gUnknown_08411940\n\ -_08147298: .4byte 0xfffffe00\n\ -_0814729C: .4byte gUnknown_0203933E\n\ -_081472A0: .4byte gUnknown_08411948\n\ -_081472A4: .4byte 0xfffffc00\n\ -_081472A8:\n\ - mov r2, r12\n\ - adds r2, 0x40\n\ - ldrh r1, [r2]\n\ - ldr r0, _081472D8 @ =0xfffffc00\n\ - ands r0, r1\n\ - movs r1, 0x1\n\ - orrs r0, r1\n\ - strh r0, [r2]\n\ -_081472B8:\n\ - ldr r0, _081472DC @ =gMain + 0x3C\n\ - movs r1, 0xE0\n\ - lsls r1, 19\n\ - movs r2, 0x1\n\ - bl CpuFastSet\n\ - ldr r1, _081472E0 @ =gUnknown_0203933E\n\ - ldrh r0, [r1, 0x2]\n\ - cmp r0, 0\n\ - beq _081472D0\n\ - subs r0, 0x1\n\ - strh r0, [r1, 0x2]\n\ -_081472D0:\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_081472D8: .4byte 0xfffffc00\n\ -_081472DC: .4byte gMain + 0x3C\n\ -_081472E0: .4byte gUnknown_0203933E\n\ - .syntax divided"); + if (!UpdatePaletteFade()) + { + if (gGameContinueCallback == 0) // no callback exists, so do a soft reset. + { + DoSoftReset(); + } + else + { + SetMainCallback2((MainCallback)gGameContinueCallback); + gGameContinueCallback = 0; + } + } } -bool8 sub_81472E4(u16 var) +static void VBlankCB_UpdateClockGraphics(void) { - u32 * ptr = (u32 *) unk_2000000; - u16 i; - - ReadFlash(var, 0, (u8 *) ptr, 4096); + unsigned int n = (gMain.vblankCounter2 >> 3) & 7; + + gMain.oamBuffer[0] = sClockOamData; + gMain.oamBuffer[0].x = 112; + gMain.oamBuffer[0].y = (CLOCK_WIN_TOP + 1) * 8; + + if (gSaveFailedClockInfo.clockRunning != FALSE) + { + gMain.oamBuffer[0].tileNum = sClockFrames[n][0]; + gMain.oamBuffer[0].matrixNum = (sClockFrames[n][2] << 4) | (sClockFrames[n][1] << 3); + } + else + { + gMain.oamBuffer[0].tileNum = 1; + } - for(i = 0; i < 0x400; i++, ptr++) - if(*ptr) - return TRUE; + CpuFastCopy(gMain.oamBuffer, (void *)OAM, 4); - return FALSE; + if (gSaveFailedClockInfo.timer) // maybe was used for debugging? + gSaveFailedClockInfo.timer--; } -#ifdef NONMATCHING -bool8 sub_8147324(u16 arg0) { - u16 i2; +static bool8 VerifySectorWipe(u16 sector) +{ + u32 *ptr = (u32 *)unk_2000000; u16 i; - bool8 success; - i = 0; - while (TRUE) { - u32 next; + ReadFlash(sector, 0, (u8 *)ptr, 4096); - i2 = 0; - next = i + 1; + for (i = 0; i < 0x400; i++, ptr++) + if (*ptr) + return TRUE; - for (; i2 < 0x1000; i2++) { - ProgramFlashByte(arg0, i2, 0); - } + return FALSE; +} + +static bool8 WipeSector(u16 sector) +{ + u16 i, j; + bool8 failed = TRUE; + + for (i = 0; failed && i < 130; i++) + { + for (j = 0; j < 0x1000; j++) + ProgramFlashByte(sector, j, 0); - if (!(success = sub_81472E4(arg0), (i = next)) || i >= 130) // matches except it checks r0 instead of r1. both are the same value, but the compiler prefers r1 for some reason. - break; + failed = VerifySectorWipe(sector); } - return success; + return failed; } -#else -__attribute__((naked)) -bool8 sub_8147324(u16 arg0) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ - movs r0, 0\n\ - ldr r1, _08147374 @ =0x00000fff\n\ - mov r8, r1\n\ - ldr r7, _08147378 @ =ProgramFlashByte\n\ -_08147336:\n\ - movs r4, 0\n\ - adds r5, r0, 0x1\n\ -_0814733A:\n\ - ldr r3, [r7]\n\ - adds r0, r6, 0\n\ - adds r1, r4, 0\n\ - movs r2, 0\n\ - bl _call_via_r3\n\ - adds r0, r4, 0x1\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - cmp r4, r8 @ compare i to var.\n\ - bls _0814733A\n\ - adds r0, r6, 0\n\ - bl sub_81472E4\n\ - lsls r0, 24\n\ - lsrs r1, r0, 24\n\ - lsls r0, r5, 16\n\ - lsrs r0, 16\n\ - cmp r1, 0\n\ - beq _08147366\n\ - cmp r0, 0x81\n\ - bls _08147336\n\ -_08147366:\n\ - adds r0, r1, 0 @ add var64 to the result from sub_81472E4(var)?\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n\ - .align 2, 0\n\ -_08147374: .4byte 0x00000fff\n\ -_08147378: .4byte ProgramFlashByte\n\ - .syntax divided"); -} -#endif -bool8 sub_814737C(u32 var) +static bool8 WipeSectors(u32 sectorBits) { - u16 i; - - for(i = 0; i < 0x20; i++) - if(var & (1 << i) && !sub_8147324(i)) - var &= ~(1 << i); - - if(var == 0) - return FALSE; - else - return TRUE; + u16 i; + + for (i = 0; i < 0x20; i++) + if ((sectorBits & (1 << i)) && !WipeSector(i)) + sectorBits &= ~(1 << i); + + if (sectorBits == 0) + return FALSE; + else + return TRUE; } diff --git a/src/save_menu_util.c b/src/save_menu_util.c index ff42d66ea..b2dd662d6 100644 --- a/src/save_menu_util.c +++ b/src/save_menu_util.c @@ -1,21 +1,18 @@ #include "global.h" #include "save_menu_util.h" -#include "asm.h" +#include "event_data.h" #include "menu.h" -#include "flag.h" -#include "string_util.h" #include "pokedex.h" - -extern u8 gOtherText_Player[]; -extern u8 gOtherText_Badges[]; -extern u8 gOtherText_Pokedex[]; -extern u8 gOtherText_PlayTime[]; +#include "region_map.h" +#include "string_util.h" +#include "strings2.h" void HandleDrawSaveWindowInfo(s16 left, s16 top) { u32 width = 12; - if (sub_809473C()) + // old handle for setting window width? + if (IsResizeSaveWindowEnabled()) width = 13; if (FlagGet(SYS_POKEDEX_GET)) @@ -39,11 +36,12 @@ void HandleDrawSaveWindowInfo(s16 left, s16 top) } } -void sub_80946C8(u16 left, u16 top) +void HandleCloseSaveWindow(u16 left, u16 top) { u32 width = 12; - if (sub_809473C()) + // old handle for setting window width? + if (IsResizeSaveWindowEnabled()) width = 13; if (FlagGet(SYS_POKEDEX_GET)) @@ -52,9 +50,14 @@ void sub_80946C8(u16 left, u16 top) MenuZeroFillWindowRect(left, top, left + width, top + 9); } -u8 sub_809473C() +/* +theory: This function was used to handle the save menu window's width being auto sized from +either 12 or 13 in an older source. Whatever was here might have either been optimized out by +GF's compiler or was dummied out to always return a TRUE at some point. +*/ +u8 IsResizeSaveWindowEnabled(void) // i don't know what else to name it.. { - return 1; + return TRUE; } void PrintSavePlayerName(s16 x, s16 y) @@ -74,22 +77,18 @@ void PrintSaveMapName(s16 x, s16 y) void PrintSaveBadges(s16 x, s16 y) { char badges[16]; - u8 badgeCount; MenuPrint(gOtherText_Badges, x, y); - badgeCount = GetBadgeCount(); - ConvertIntToDecimalString(badges, badgeCount); + ConvertIntToDecimalString(badges, GetBadgeCount()); MenuPrint_RightAligned(badges, x + 12, y); } void PrintSavePokedexCount(s16 x, s16 y) { char pokedex[16]; - u16 pokedexCount; MenuPrint(gOtherText_Pokedex, x, y); - pokedexCount = GetPokedexSeenCount(); - ConvertIntToDecimalStringN(pokedex, pokedexCount, 1, 3); + ConvertIntToDecimalStringN(pokedex, GetPokedexSeenCount(), 1, 3); MenuPrint_RightAligned(pokedex, x + 12, y); } @@ -118,7 +117,7 @@ u16 GetPokedexSeenCount() { u16 pokedexSeenCount; - if (IsNationalPokedex()) + if (IsNationalPokedexEnabled()) pokedexSeenCount = GetNationalPokedexCount(1); else pokedexSeenCount = GetHoennPokedexCount(1); diff --git a/src/scrcmd.c b/src/scrcmd.c index a8567a2bb..a394f2a55 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1,36 +1,52 @@ #include "global.h" -#include "asm.h" #include "battle_setup.h" #include "berry.h" +#include "clock.h" +#include "coins.h" +#include "contest_link_80C2020.h" +#include "contest_painting.h" +#include "data2.h" +#include "decoration.h" +#include "decoration_inventory.h" +#include "event_data.h" +#include "field_door.h" +#include "field_effect.h" +#include "field_fadetransition.h" +#include "field_map_obj.h" +#include "field_map_obj_helpers.h" +#include "field_message_box.h" #include "field_player_avatar.h" +#include "field_screen_effect.h" +#include "field_specials.h" +#include "field_tasks.h" +#include "field_weather.h" +#include "fieldmap.h" #include "item.h" -#include "script.h" -#include "rng.h" -#include "palette.h" -#include "rtc.h" -#include "pokemon.h" -#include "asm_fieldmap.h" #include "main.h" +#include "map_obj_lock.h" #include "menu.h" #include "money.h" -#include "decoration.h" -#include "field_message_box.h" +#include "mystery_event_script.h" +#include "palette.h" +#include "party_menu.h" +#include "pokemon.h" +#include "rng.h" +#include "rom4.h" +#include "rtc.h" +#include "script.h" +#include "script_menu.h" +#include "script_movement.h" +#include "script_pokemon_80C4.h" +#include "script_pokemon_80F9.h" +#include "shop.h" +#include "slot_machine.h" #include "sound.h" #include "string_util.h" -#include "flag.h" -#include "var.h" -#include "rom4.h" -#include "weather.h" -#include "map_obj_lock.h" -#include "coins.h" -#include "field_effect.h" +#include "tv.h" typedef u16 (*SpecialFunc)(void); typedef void (*NativeFunc)(void); -extern struct Pokemon gPlayerParty[6]; // 0x3004360 -extern struct Pokemon gEnemyParty[6]; // 0x30045C0 - extern u32 gUnknown_0202E8AC; extern u32 gUnknown_0202E8B0; extern u16 gUnknown_0202E8B4; @@ -53,13 +69,27 @@ extern SpecialFunc gSpecials[]; extern u8 *gStdScripts[]; extern u8 *gStdScripts_End[]; -extern u8 gSpeciesNames[][11]; -extern u8 gMoveNames[][13]; +// This is defined in here so the optimizer can't see its value when compiling +// script.c. +void * const gNullScriptPtr = NULL; -extern u8 gScriptConditionTable[6][3]; -extern u8 * const gUnknown_083762F0[]; -extern u8 * const gUnknown_083CE048[]; -extern struct Decoration gDecorations[]; +static const u8 sScriptConditionTable[6][3] = +{ +// < = > + 1, 0, 0, // < + 0, 1, 0, // = + 0, 0, 1, // > + 1, 1, 0, // <= + 0, 1, 1, // >= + 1, 0, 1, // != +}; + +static u8 * const sScriptStringVars[] = +{ + gStringVar1, + gStringVar2, + gStringVar3, +}; bool8 ScrCmd_snop(struct ScriptContext *ctx) { @@ -136,7 +166,7 @@ bool8 ScrCmd_jumpif(struct ScriptContext *ctx) { u8 condition = ScriptReadByte(ctx); u8 *ptr = (u8 *)ScriptReadWord(ctx); - if (gScriptConditionTable[condition][ctx->comparisonResult] == 1) + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) ScriptJump(ctx, ptr); return FALSE; } @@ -145,7 +175,7 @@ bool8 ScrCmd_callif(struct ScriptContext *ctx) { u8 condition = ScriptReadByte(ctx); u8 *ptr = (u8 *)ScriptReadWord(ctx); - if (gScriptConditionTable[condition][ctx->comparisonResult] == 1) + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) ScriptCall(ctx, ptr); return FALSE; } @@ -176,7 +206,7 @@ bool8 ScrCmd_if5(struct ScriptContext *ctx) { u8 condition = ScriptReadByte(ctx); u8 *ptr = (u8 *)(ScriptReadWord(ctx) - gUnknown_0202E8B0); - if (gScriptConditionTable[condition][ctx->comparisonResult] == 1) + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) ScriptJump(ctx, ptr); return FALSE; } @@ -185,7 +215,7 @@ bool8 ScrCmd_if6(struct ScriptContext *ctx) { u8 condition = ScriptReadByte(ctx); u8 *ptr = (u8 *)(ScriptReadWord(ctx) - gUnknown_0202E8B0); - if (gScriptConditionTable[condition][ctx->comparisonResult] == 1) + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) ScriptCall(ctx, ptr); return FALSE; } @@ -212,7 +242,7 @@ bool8 ScrCmd_jumpstdif(struct ScriptContext *ctx) { u8 condition = ScriptReadByte(ctx); u8 index = ScriptReadByte(ctx); - if (gScriptConditionTable[condition][ctx->comparisonResult] == 1) + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) { u8 **ptr = &gStdScripts[index]; if (ptr < gStdScripts_End) @@ -225,7 +255,7 @@ bool8 ScrCmd_callstdif(struct ScriptContext *ctx) { u8 condition = ScriptReadByte(ctx); u8 index = ScriptReadByte(ctx); - if (gScriptConditionTable[condition][ctx->comparisonResult] == 1) + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) { u8 **ptr = &gStdScripts[index]; if (ptr < gStdScripts_End) @@ -524,7 +554,7 @@ bool8 ScrCmd_checkflag(struct ScriptContext *ctx) bool8 ScrCmd_inccounter(struct ScriptContext *ctx) { - sav12_xor_increment(ScriptReadByte(ctx)); + IncrementGameStat(ScriptReadByte(ctx)); return FALSE; } @@ -542,7 +572,7 @@ bool8 ScrCmd_darken(struct ScriptContext *ctx) return FALSE; } -bool8 sub_8066248(void) +bool8 IsPaletteNotActive(void) { if (!gPaletteFade.active) return TRUE; @@ -553,16 +583,16 @@ bool8 sub_8066248(void) bool8 ScrCmd_fadescreen(struct ScriptContext *ctx) { fade_screen(ScriptReadByte(ctx), 0); - SetupNativeScript(ctx, sub_8066248); + SetupNativeScript(ctx, IsPaletteNotActive); return TRUE; } bool8 ScrCmd_fadescreendelay(struct ScriptContext *ctx) { - u8 val1 = ScriptReadByte(ctx); - u8 val2 = ScriptReadByte(ctx); - fade_screen(val1, val2); - SetupNativeScript(ctx, sub_8066248); + u8 duration = ScriptReadByte(ctx); + u8 delay = ScriptReadByte(ctx); + fade_screen(duration, delay); + SetupNativeScript(ctx, IsPaletteNotActive); return TRUE; } @@ -621,13 +651,13 @@ bool8 ScrCmd_resetweather(struct ScriptContext *ctx) bool8 ScrCmd_doweather(struct ScriptContext *ctx) { - sub_808073C(); + DoCurrentWeather(); return FALSE; } bool8 ScrCmd_tileeffect(struct ScriptContext *ctx) { - activate_per_step_callback(ScriptReadByte(ctx)); + ActivatePerStepCallback(ScriptReadByte(ctx)); return FALSE; } @@ -1066,7 +1096,7 @@ bool8 ScrCmd_lockall(struct ScriptContext *ctx) } else { - sub_8064D20(); + ScriptFreezeMapObjects(); SetupNativeScript(ctx, sub_8064CFC); return TRUE; } @@ -1087,7 +1117,7 @@ bool8 ScrCmd_lock(struct ScriptContext *ctx) } else { - sub_8064D20(); + ScriptFreezeMapObjects(); SetupNativeScript(ctx, sub_8064CFC); } @@ -1103,7 +1133,7 @@ bool8 ScrCmd_releaseall(struct ScriptContext *ctx) objectId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[objectId]); sub_80A2178(); - sub_806451C(); + UnfreezeMapObjects(); return FALSE; } @@ -1117,7 +1147,7 @@ bool8 ScrCmd_release(struct ScriptContext *ctx) objectId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[objectId]); sub_80A2178(); - sub_806451C(); + UnfreezeMapObjects(); return FALSE; } @@ -1151,7 +1181,7 @@ bool8 ScrCmd_closebutton(struct ScriptContext *ctx) return FALSE; } -bool8 sub_80670C0() +bool8 WaitForAorBPress(void) { if (gMain.newKeys & A_BUTTON) return TRUE; @@ -1162,7 +1192,7 @@ bool8 sub_80670C0() bool8 ScrCmd_waitbutton(struct ScriptContext *ctx) { - SetupNativeScript(ctx, sub_80670C0); + SetupNativeScript(ctx, WaitForAorBPress); return TRUE; } @@ -1326,14 +1356,14 @@ bool8 ScrCmd_bufferpoke(struct ScriptContext *ctx) { u8 stringVarIndex = ScriptReadByte(ctx); u16 species = VarGet(ScriptReadHalfword(ctx)); - StringCopy(gUnknown_083762F0[stringVarIndex], gSpeciesNames[species]); + StringCopy(sScriptStringVars[stringVarIndex], gSpeciesNames[species]); return FALSE; } bool8 ScrCmd_bufferfirstpoke(struct ScriptContext *ctx) { u8 stringVarIndex = ScriptReadByte(ctx); - u8 *dest = gUnknown_083762F0[stringVarIndex]; + u8 *dest = sScriptStringVars[stringVarIndex]; u8 partyIndex = GetLeadMonIndex(); u32 species = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPECIES, NULL); StringCopy(dest, gSpeciesNames[species]); @@ -1344,8 +1374,8 @@ bool8 ScrCmd_bufferpartypoke(struct ScriptContext *ctx) { u8 stringVarIndex = ScriptReadByte(ctx); u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); - GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, gUnknown_083762F0[stringVarIndex]); - StringGetEnd10(gUnknown_083762F0[stringVarIndex]); + GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, sScriptStringVars[stringVarIndex]); + StringGetEnd10(sScriptStringVars[stringVarIndex]); return FALSE; } @@ -1353,7 +1383,7 @@ bool8 ScrCmd_bufferitem(struct ScriptContext *ctx) { u8 stringVarIndex = ScriptReadByte(ctx); u16 itemId = VarGet(ScriptReadHalfword(ctx)); - CopyItemName(itemId, gUnknown_083762F0[stringVarIndex]); + CopyItemName(itemId, sScriptStringVars[stringVarIndex]); return FALSE; } @@ -1361,7 +1391,7 @@ bool8 ScrCmd_bufferdecor(struct ScriptContext *ctx) { u8 stringVarIndex = ScriptReadByte(ctx); u16 decorId = VarGet(ScriptReadHalfword(ctx)); - StringCopy(gUnknown_083762F0[stringVarIndex], gDecorations[decorId].name); + StringCopy(sScriptStringVars[stringVarIndex], gDecorations[decorId].name); return FALSE; } @@ -1369,7 +1399,7 @@ bool8 ScrCmd_bufferattack(struct ScriptContext *ctx) { u8 stringVarIndex = ScriptReadByte(ctx); u16 moveId = VarGet(ScriptReadHalfword(ctx)); - StringCopy(gUnknown_083762F0[stringVarIndex], gMoveNames[moveId]); + StringCopy(sScriptStringVars[stringVarIndex], gMoveNames[moveId]); return FALSE; } @@ -1378,7 +1408,7 @@ bool8 ScrCmd_buffernum(struct ScriptContext *ctx) u8 stringVarIndex = ScriptReadByte(ctx); u16 v1 = VarGet(ScriptReadHalfword(ctx)); u8 v2 = sub_80BF0B8(v1); - ConvertIntToDecimalStringN(gUnknown_083762F0[stringVarIndex], v1, 0, v2); + ConvertIntToDecimalStringN(sScriptStringVars[stringVarIndex], v1, 0, v2); return FALSE; } @@ -1386,7 +1416,7 @@ bool8 ScrCmd_bufferstd(struct ScriptContext *ctx) { u8 stringVarIndex = ScriptReadByte(ctx); u16 index = VarGet(ScriptReadHalfword(ctx)); - StringCopy(gUnknown_083762F0[stringVarIndex], gUnknown_083CE048[index]); + StringCopy(sScriptStringVars[stringVarIndex], gUnknown_083CE048[index].text); return FALSE; } @@ -1394,7 +1424,7 @@ bool8 ScrCmd_buffertext(struct ScriptContext *ctx) { u8 stringVarIndex = ScriptReadByte(ctx); u8 *text = (u8 *)ScriptReadWord(ctx); - StringCopy(gUnknown_083762F0[stringVarIndex], text); + StringCopy(sScriptStringVars[stringVarIndex], text); return FALSE; } @@ -1410,7 +1440,7 @@ bool8 ScrCmd_vbuffer(struct ScriptContext *ctx) u8 stringVarIndex = ScriptReadByte(ctx); u32 addr = ScriptReadWord(ctx); u8 *src = (u8 *)(addr - gUnknown_0202E8B0); - u8 *dest = gUnknown_083762F0[stringVarIndex]; + u8 *dest = sScriptStringVars[stringVarIndex]; StringCopy(dest, src); return FALSE; } @@ -1599,7 +1629,7 @@ bool8 ScrCmd_setwildbattle(struct ScriptContext *ctx) bool8 ScrCmd_dowildbattle(struct ScriptContext *ctx) { - sub_8081B3C(); + StartBattle_ScriptedWild(); ScriptContext1_Stop(); return TRUE; } @@ -1836,8 +1866,8 @@ bool8 ScrCmd_checkcoins(struct ScriptContext *ctx) bool8 ScrCmd_givecoins(struct ScriptContext *ctx) { - u16 v2 = VarGet(ScriptReadHalfword(ctx)); - if (GiveCoins(v2) == TRUE) + u16 coins = VarGet(ScriptReadHalfword(ctx)); + if (GiveCoins(coins) == TRUE) gScriptResult = 0; else gScriptResult = 1; @@ -1847,8 +1877,8 @@ bool8 ScrCmd_givecoins(struct ScriptContext *ctx) bool8 ScrCmd_removecoins(struct ScriptContext *ctx) { - u16 v2 = VarGet(ScriptReadHalfword(ctx)); - if (TakeCoins(v2) == TRUE) + u16 coins = VarGet(ScriptReadHalfword(ctx)); + if (TakeCoins(coins) == TRUE) gScriptResult = 0; else gScriptResult = 1; diff --git a/src/script.c b/src/script.c index a7aa9c809..488a67de1 100644 --- a/src/script.c +++ b/src/script.c @@ -1,7 +1,6 @@ #include "global.h" #include "script.h" -#include "asm_fieldmap.h" -#include "var.h" +#include "event_data.h" #define RAM_SCRIPT_MAGIC 51 @@ -15,7 +14,7 @@ static bool8 sScriptContext2Enabled; extern ScrCmdFunc gScriptCmdTable[]; extern ScrCmdFunc gScriptCmdTableEnd[]; -extern void *gUnknown_083762D8; +extern void *gNullScriptPtr; void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTableEnd) { @@ -83,7 +82,7 @@ u8 RunScript(struct ScriptContext *ctx) return 0; } - if (ctx->scriptPtr == gUnknown_083762D8) + if (ctx->scriptPtr == gNullScriptPtr) { while (1) asm("svc 2"); // HALT diff --git a/src/script_menu.c b/src/script_menu.c new file mode 100644 index 000000000..e1ad3f467 --- /dev/null +++ b/src/script_menu.c @@ -0,0 +1,1134 @@ +#include "global.h" +#include "script_menu.h" +#include "event_data.h" +#include "field_effect.h" +#include "menu.h" +#include "palette.h" +#include "script.h" +#include "sound.h" +#include "sprite.h" +#include "strings.h" +#include "task.h" + +// multichoice lists +const struct MenuAction MultichoiceList_00[] = +{ + {(u8 *)OtherText_Petalburg, 0}, + {(u8 *)OtherText_Slateport, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_02[] = +{ + {(u8 *)OtherText_Enter, 0}, + {(u8 *)OtherText_Info3, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_03[] = +{ + {(u8 *)OtherText_WhatsAContest, 0}, + {(u8 *)OtherText_TypesOfContest, 0}, + {(u8 *)OtherText_Ranks, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_04[] = +{ + {(u8 *)OtherText_CoolContest, 0}, + {(u8 *)OtherText_BeautyContest, 0}, + {(u8 *)OtherText_CuteContest, 0}, + {(u8 *)OtherText_SmartContest, 0}, + {(u8 *)OtherText_ToughContest, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_06[] = +{ + {(u8 *)OtherText_Decoration, 0}, + {(u8 *)OtherText_PackUp, 0}, + {(u8 *)OtherText_Registry, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_05[] = +{ + {(u8 *)OtherText_Decoration, 0}, + {(u8 *)OtherText_PackUp, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_07[] = +{ + {(u8 *)OtherText_Register, 0}, + {(u8 *)OtherText_Registry, 0}, + {(u8 *)OtherText_Information, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_12[] = +{ + {(u8 *)OtherText_Mach, 0}, + {(u8 *)OtherText_Acro, 0}, +}; + +const struct MenuAction MultichoiceList_13[] = +{ + {(u8 *)OtherText_Poison, 0}, + {(u8 *)OtherText_Paralysis, 0}, + {(u8 *)OtherText_Sleep, 0}, + {(u8 *)OtherText_Burn, 0}, + {(u8 *)OtherText_Frozen, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_14[] = +{ + {(u8 *)OtherText_Dewford, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_16[] = +{ + {(u8 *)OtherText_SawIt, 0}, + {(u8 *)OtherText_NotYet, 0}, +}; + +const struct MenuAction MultichoiceList_17[] = +{ + {(u8 *)OtherText_Yes, 0}, + {(u8 *)OtherText_No, 0}, + {(u8 *)OtherText_Info3, 0}, +}; + +const struct MenuAction MultichoiceList_18[] = +{ + {(u8 *)OtherText_SingleBattle, 0}, + {(u8 *)OtherText_DoubleBattle, 0}, + {(u8 *)OtherText_MultiBattle, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_19[] = +{ + {(u8 *)OtherText_Littleroot, 0}, + {(u8 *)OtherText_Slateport, 0}, + {(u8 *)OtherText_Lilycove, 0}, +}; + +const struct MenuAction MultichoiceList_20[] = +{ + {(u8 *)OtherText_Yes, 0}, + {(u8 *)OtherText_No, 0}, + {(u8 *)OtherText_Info3, 0}, +}; + +const struct MenuAction MultichoiceList_23[] = +{ + {(u8 *)OtherText_MakeAChallenge, 0}, + {(u8 *)OtherText_ObtainInformation, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_24[] = +{ + {(u8 *)OtherText_Lv50_2, 0}, + {(u8 *)OtherText_Lv100_2, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_25[] = +{ + {(u8 *)OtherText_Zigzagoon, 0}, + {(u8 *)OtherText_Nincada, 0}, + {(u8 *)OtherText_Poochyena, 0}, +}; + +const struct MenuAction MultichoiceList_26[] = +{ + {(u8 *)OtherText_Nincada2, 0}, + {(u8 *)OtherText_Lotad, 0}, + {(u8 *)OtherText_Roselia, 0}, +}; + +const struct MenuAction MultichoiceList_27[] = +{ + {(u8 *)OtherText_Shroomish, 0}, + {(u8 *)OtherText_Nincada3, 0}, + {(u8 *)OtherText_Surskit, 0}, +}; + +const struct MenuAction MultichoiceList_28[] = +{ + {(u8 *)OtherText_Treecko, 0}, + {(u8 *)OtherText_Torchic, 0}, + {(u8 *)OtherText_Mudkip, 0}, +}; + +const struct MenuAction MultichoiceList_29[] = +{ + {(u8 *)OtherText_Seedot, 0}, + {(u8 *)OtherText_Shroomish2, 0}, + {(u8 *)OtherText_Spinda, 0}, +}; + +const struct MenuAction MultichoiceList_30[] = +{ + {(u8 *)OtherText_Shroomish3, 0}, + {(u8 *)OtherText_Zigzagoon2, 0}, + {(u8 *)OtherText_Wurmple, 0}, +}; + +const struct MenuAction MultichoiceList_31[] = +{ + {(u8 *)OtherText_PokeBall, 0}, + {(u8 *)OtherText_SuperPotion, 0}, + {(u8 *)OtherText_SamePrice, 0}, +}; + +const struct MenuAction MultichoiceList_32[] = +{ + {(u8 *)OtherText_Yen135, 0}, + {(u8 *)OtherText_Yen155, 0}, + {(u8 *)OtherText_Yen175, 0}, +}; + +const struct MenuAction MultichoiceList_33[] = +{ + {(u8 *)OtherText_CostMore, 0}, + {(u8 *)OtherText_CostLess, 0}, + {(u8 *)OtherText_SamePrice2, 0}, +}; + +const struct MenuAction MultichoiceList_34[] = +{ + {(u8 *)OtherText_MaleSymbol, 0}, + {(u8 *)OtherText_FemaleSymbol, 0}, + {(u8 *)OtherText_Neither, 0}, +}; + +const struct MenuAction MultichoiceList_35[] = +{ + {(u8 *)OtherText_Males, 0}, + {(u8 *)OtherText_Females, 0}, + {(u8 *)OtherText_SameNumber, 0}, +}; + +const struct MenuAction MultichoiceList_36[] = +{ + {(u8 *)OtherText_Male, 0}, + {(u8 *)OtherText_Female, 0}, + {(u8 *)OtherText_ItDepends, 0}, +}; + +const struct MenuAction MultichoiceList_37[] = +{ + {(u8 *)OtherText_Six2, 0}, + {(u8 *)OtherText_Eight2, 0}, + {(u8 *)OtherText_Ten, 0}, +}; + +const struct MenuAction MultichoiceList_38[] = +{ + {(u8 *)OtherText_One, 0}, + {(u8 *)OtherText_Two, 0}, + {(u8 *)OtherText_Three, 0}, +}; + +const struct MenuAction MultichoiceList_39[] = +{ + {(u8 *)OtherText_Six, 0}, + {(u8 *)OtherText_Seven, 0}, + {(u8 *)OtherText_Eight, 0}, +}; + +const struct MenuAction MultichoiceList_42[] = +{ + {(u8 *)OtherText_FreshWater, 0}, + {(u8 *)OtherText_SodaPop, 0}, + {(u8 *)OtherText_Lemonade, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_43[] = +{ + {(u8 *)OtherText_HowToRide, 0}, + {(u8 *)OtherText_HowToTurn, 0}, + {(u8 *)OtherText_SandySlopes, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_44[] = +{ + {(u8 *)OtherText_Wheelies, 0}, + {(u8 *)OtherText_BunnyHops, 0}, + {(u8 *)OtherText_Jumping, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_45[] = +{ + {(u8 *)OtherText_Satisfied, 0}, + {(u8 *)OtherText_Dissatisfied, 0}, +}; + +const struct MenuAction MultichoiceList_46[] = +{ + {(u8 *)OtherText_Deepseatooth, 0}, + {(u8 *)OtherText_Deepseascale, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_47[] = +{ + {(u8 *)OtherText_BlueFlute2, 0}, + {(u8 *)OtherText_YellowFlute2, 0}, + {(u8 *)OtherText_RedFlute2, 0}, + {(u8 *)OtherText_WhiteFlute2, 0}, + {(u8 *)OtherText_BlackFlute2, 0}, + {(u8 *)OtherText_GlassChair, 0}, + {(u8 *)OtherText_GlassDesk, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_48[] = +{ + {(u8 *)OtherText_TreeckoDoll, 0}, + {(u8 *)OtherText_TorchicDoll, 0}, + {(u8 *)OtherText_MudkipDoll, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_55[] = +{ + {(u8 *)OtherText_TM32, 0}, + {(u8 *)OtherText_TM29, 0}, + {(u8 *)OtherText_TM35, 0}, + {(u8 *)OtherText_TM24, 0}, + {(u8 *)OtherText_TM13, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_49[] = +{ + {(u8 *)OtherText_50Coins, 0}, + {(u8 *)OtherText_500Coins, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_50[] = +{ + {(u8 *)OtherText_Excellent, 0}, + {(u8 *)OtherText_NotSoHot, 0}, +}; + +const struct MenuAction MultichoiceList_52[] = +{ + {(u8 *)OtherText_Lilycove, 0}, + {(u8 *)OtherText_BattleTower, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_53[] = +{ + {(u8 *)OtherText_Slateport, 0}, + {(u8 *)OtherText_Lilycove, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_54[] = +{ + {(u8 *)OtherText_Right, 0}, + {(u8 *)OtherText_Left, 0}, +}; + +const struct MenuAction MultichoiceList_56[] = +{ + {(u8 *)OtherText_Slateport, 0}, + {(u8 *)OtherText_BattleTower, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_57[] = +{ + {(u8 *)OtherText_1F_2, 0}, + {(u8 *)OtherText_2F_2, 0}, + {(u8 *)OtherText_3F_2, 0}, + {(u8 *)OtherText_4F_2, 0}, + {(u8 *)OtherText_5F_2, 0}, +}; + +const struct MenuAction MultichoiceList_58[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_59[] = +{ + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_60[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_61[] = +{ + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_62[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_63[] = +{ + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_64[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_65[] = +{ + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_66[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_67[] = +{ + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_68[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_69[] = +{ + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_70[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_71[] = +{ + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_72[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_01[] = +{ + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MultichoiceListStruct gMultichoiceLists[] = +{ + {(struct MenuAction *)MultichoiceList_00, 3}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_02, 3}, + {(struct MenuAction *)MultichoiceList_03, 4}, + {(struct MenuAction *)MultichoiceList_04, 6}, + {(struct MenuAction *)MultichoiceList_05, 3}, + {(struct MenuAction *)MultichoiceList_06, 4}, + {(struct MenuAction *)MultichoiceList_07, 4}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_12, 2}, + {(struct MenuAction *)MultichoiceList_13, 6}, + {(struct MenuAction *)MultichoiceList_14, 2}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_16, 2}, + {(struct MenuAction *)MultichoiceList_17, 3}, + {(struct MenuAction *)MultichoiceList_18, 4}, + {(struct MenuAction *)MultichoiceList_19, 3}, + {(struct MenuAction *)MultichoiceList_20, 3}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_23, 3}, + {(struct MenuAction *)MultichoiceList_24, 3}, + {(struct MenuAction *)MultichoiceList_25, 3}, + {(struct MenuAction *)MultichoiceList_26, 3}, + {(struct MenuAction *)MultichoiceList_27, 3}, + {(struct MenuAction *)MultichoiceList_28, 3}, + {(struct MenuAction *)MultichoiceList_29, 3}, + {(struct MenuAction *)MultichoiceList_30, 3}, + {(struct MenuAction *)MultichoiceList_31, 3}, + {(struct MenuAction *)MultichoiceList_32, 3}, + {(struct MenuAction *)MultichoiceList_33, 3}, + {(struct MenuAction *)MultichoiceList_34, 3}, + {(struct MenuAction *)MultichoiceList_35, 3}, + {(struct MenuAction *)MultichoiceList_36, 3}, + {(struct MenuAction *)MultichoiceList_37, 3}, + {(struct MenuAction *)MultichoiceList_38, 3}, + {(struct MenuAction *)MultichoiceList_39, 3}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_42, 4}, + {(struct MenuAction *)MultichoiceList_43, 4}, + {(struct MenuAction *)MultichoiceList_44, 4}, + {(struct MenuAction *)MultichoiceList_45, 2}, + {(struct MenuAction *)MultichoiceList_46, 3}, + {(struct MenuAction *)MultichoiceList_47, 8}, + {(struct MenuAction *)MultichoiceList_48, 4}, + {(struct MenuAction *)MultichoiceList_49, 3}, + {(struct MenuAction *)MultichoiceList_50, 2}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_52, 3}, + {(struct MenuAction *)MultichoiceList_53, 3}, + {(struct MenuAction *)MultichoiceList_54, 2}, + {(struct MenuAction *)MultichoiceList_55, 6}, + {(struct MenuAction *)MultichoiceList_56, 3}, + {(struct MenuAction *)MultichoiceList_57, 5}, + {(struct MenuAction *)MultichoiceList_58, 2}, + {(struct MenuAction *)MultichoiceList_59, 2}, + {(struct MenuAction *)MultichoiceList_60, 3}, + {(struct MenuAction *)MultichoiceList_61, 2}, + {(struct MenuAction *)MultichoiceList_62, 3}, + {(struct MenuAction *)MultichoiceList_63, 3}, + {(struct MenuAction *)MultichoiceList_64, 4}, + {(struct MenuAction *)MultichoiceList_65, 2}, + {(struct MenuAction *)MultichoiceList_66, 3}, + {(struct MenuAction *)MultichoiceList_67, 3}, + {(struct MenuAction *)MultichoiceList_68, 4}, + {(struct MenuAction *)MultichoiceList_69, 3}, + {(struct MenuAction *)MultichoiceList_70, 4}, + {(struct MenuAction *)MultichoiceList_71, 4}, + {(struct MenuAction *)MultichoiceList_72, 5} +}; + +const struct TextStruct gUnknown_083CE048[] = +{ + OtherText_Cool2, + OtherText_Beauty3, + OtherText_Cute2, + OtherText_Smart2, + OtherText_Tough2, + OtherText_Normal, + OtherText_Super, + OtherText_Hyper, + OtherText_Master, + OtherText_Cool3, + OtherText_Beauty4, + OtherText_Cute3, + OtherText_Smart3, + OtherText_Tough3, + OtherText_Items, + OtherText_KeyItems, + OtherText_Balls, + OtherText_TMsHMs, + OtherText_Berries, +}; + +extern u8 gPCText_WhichPCShouldBeAccessed[]; + +extern u16 gScriptResult; + +bool8 sub_80B5054(u8 left, u8 top, u8 var3, u8 var4) +{ + if (FuncIsActiveTask(sub_80B52B4) == 1) + return FALSE; + else + { + gScriptResult = 0xFF; + DrawMultichoiceMenu(left, top, gMultichoiceLists[var3].count, gMultichoiceLists[var3].list, var4, 0); + return TRUE; + } +} + +bool8 sub_80B50B0(u8 left, u8 top, u8 var3, u8 var4, u8 var5) +{ + if (FuncIsActiveTask(sub_80B52B4) == 1) + return FALSE; + else + { + gScriptResult = 0xFF; + DrawMultichoiceMenu(left, top, gMultichoiceLists[var3].count, gMultichoiceLists[var3].list, var4, var5); + return TRUE; + } +} + +u16 GetStringWidthInTilesForScriptMenu(const u8 *str) +{ + // each tile on screen is 8x8, so it needs the number of tiles and not pixels, hence the division by 8. + return (GetStringWidthGivenWindowConfig((struct WindowConfig *)&gWindowConfig_81E6CE4, str) + 7) / 8; +} + +void DrawMultichoiceMenu(u8 left, u8 top, u8 count, struct MenuAction *list, u8 var4, u8 cursorPos) +{ + u16 width = GetStringWidthInTilesForScriptMenu(list[0].text); + u16 newWidth; + u8 i; + u8 right; + u8 bottom; + + for (i = 1; i < count; i++) + { + newWidth = GetStringWidthInTilesForScriptMenu(list[i].text); + if (width < newWidth) + width = newWidth; + } + + right = width; + right = (right + left) + 1; + + if (right > 29) + { + left = left + (29 - right); + right = 29; + } + + bottom = top + (2 * count + 1); + + MenuDrawTextWindow(left, top, right, bottom); + PrintMenuItems(left + 1, top + 1, count, list); + InitMenu(0, left + 1, top + 1, count, cursorPos, right - left - 1); + sub_80B5230(left, top, right, bottom, var4, count); +} + +void sub_80B5230(u8 left, u8 top, u8 right, u8 bottom, u8 unkVar, u8 count) +{ + u8 taskId = CreateTask(sub_80B52B4, 80); + + gTasks[taskId].data[0] = left; + gTasks[taskId].data[1] = top; + gTasks[taskId].data[2] = right; + gTasks[taskId].data[3] = bottom; + gTasks[taskId].data[4] = unkVar; + + if (count > 3) + gTasks[taskId].data[5] = TRUE; + else + gTasks[taskId].data[5] = FALSE; +} + +void sub_80B52B4(u8 taskId) +{ + s8 var; + + if (!gPaletteFade.active) + { + if (!gTasks[taskId].data[5]) + var = ProcessMenuInputNoWrap(); + else + var = ProcessMenuInput(); + + if (var != -2) + { + if (var == -1) + { + if (!gTasks[taskId].data[4]) + { + PlaySE(5); + gScriptResult = 127; + } + else + { + return; + } + } + else + { + gScriptResult = var; + } + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(gTasks[taskId].data[0], gTasks[taskId].data[1], gTasks[taskId].data[2], gTasks[taskId].data[3]); + DestroyTask(taskId); + EnableBothScriptContexts(); + } + } +} + +bool8 Multichoice(u8 var1, u8 var2, u8 var3, u8 var4) +{ + if (FuncIsActiveTask(sub_80B52B4) == 1) + return FALSE; + else + { + gScriptResult = 0xFF; + sub_80B53B4(var1, var2, gMultichoiceLists[var3].count, gMultichoiceLists[var3].list, var4); + return TRUE; + } +} + +void sub_80B53B4(u8 left, u8 top, u8 count, struct MenuAction *list, u8 var4) +{ + u16 width = GetStringWidthInTilesForScriptMenu(list[0].text); + u16 newWidth; + u8 i; + u8 right; + u8 bottom; + + for (i = 1; i < count; i++) + { + newWidth = GetStringWidthInTilesForScriptMenu(list[i].text); + if (width < newWidth) + width = newWidth; + } + + right = width; + right = (right + left) + 2; + bottom = top + (2 * count + 1); + + PrintMenuItems(left, top, count, list); + InitMenu(0, left, top, count, 0, right - left - 1); + sub_80B5230(left, top, right, bottom, var4, count); +} + +bool8 yes_no_box(u8 var1, u8 var2) +{ + u8 taskId; + + if (FuncIsActiveTask(task_yes_no_maybe) == 1) + return FALSE; + else + { + gScriptResult = 0xFF; + DisplayYesNoMenu(var1, var2, 1); + taskId = CreateTask(task_yes_no_maybe, 0x50); + gTasks[taskId].data[0] = var1; + gTasks[taskId].data[1] = var2; + return TRUE; + } +} + +// unused +bool8 IsScriptActive(void) +{ + if (gScriptResult == 0xFF) + return FALSE; + else + return TRUE; +} + +void task_yes_no_maybe(u8 taskId) +{ + u8 left, top; + + if (gTasks[taskId].data[2] < 5) + { + gTasks[taskId].data[2]++; + return; + } + + switch (ProcessMenuInputNoWrap()) + { + case -2: + return; + case -1: + case 1: + PlaySE(5); + gScriptResult = 0; + break; + case 0: + gScriptResult = 1; + break; + } + + left = gTasks[taskId].data[0]; + top = gTasks[taskId].data[1]; + + MenuZeroFillWindowRect(left, top, left + 6, top + 5); + DestroyTask(taskId); + EnableBothScriptContexts(); +} + +bool8 sub_80B5578(u8 left, u8 top, u8 multichoiceId, u8 a4, u8 columnCount) +{ + u8 bottom = 0; + + if (FuncIsActiveTask(sub_80B5684) == TRUE) + { + return FALSE; + } + else + { + u8 taskId; + u8 width; + + gScriptResult = 0xFF; + + sub_807274C(left, top, gMultichoiceLists[multichoiceId].count, 0, gMultichoiceLists[multichoiceId].list, columnCount, 0); + + taskId = CreateTask(sub_80B5684, 80); + + if (!((gMultichoiceLists[multichoiceId].count >> 1) < columnCount || (gMultichoiceLists[multichoiceId].count & 1)) + || columnCount == 1 || gMultichoiceLists[multichoiceId].count == columnCount) + { + bottom = (2 * (gMultichoiceLists[multichoiceId].count / columnCount)) + 1 + top; + } + else + { + bottom = (2 * (gMultichoiceLists[multichoiceId].count / columnCount)) + 3 + top; + } + + width = sub_807288C(columnCount); + gTasks[taskId].data[0] = left; + gTasks[taskId].data[1] = top; + gTasks[taskId].data[2] = width + left + 2; + gTasks[taskId].data[3] = bottom; + gTasks[taskId].data[4] = a4; + return TRUE; + } +} + +void sub_80B5684(u8 taskId) +{ + s8 var = sub_80727CC(); + + if (var != -2) + { + if (var == -1) + { + if (!gTasks[taskId].data[4]) + { + PlaySE(5); + gScriptResult = 127; + } + else + { + return; + } + } + else + { + gScriptResult = var; + } + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(gTasks[taskId].data[0], gTasks[taskId].data[1], gTasks[taskId].data[2], gTasks[taskId].data[3]); + DestroyTask(taskId); + EnableBothScriptContexts(); + } +} + +bool8 TryCreatePCMenu(void) +{ + if (FuncIsActiveTask(sub_80B52B4) == 1) + return FALSE; + else + { + gScriptResult = 0xFF; + CreatePCMenu(); + return TRUE; + } +} + +#if ENGLISH +void CreatePCMenu(void) +{ + u16 playersPCWidth = GetStringWidthInTilesForScriptMenu(gPCText_PlayersPC); + u8 width; + u8 numChoices; + + if (playersPCWidth > GetStringWidthInTilesForScriptMenu(gPCText_SomeonesPC)) + width = playersPCWidth; + else + width = 8; + + if (FlagGet(SYS_GAME_CLEAR)) // player has cleared game? + { + numChoices = 4; + MenuDrawTextWindow(0, 0, width + 2, 9); + MenuPrint(gPCText_HallOfFame, 1, 5); + MenuPrint(gPCText_LogOff, 1, 7); + } + else + { + numChoices = 3; + MenuDrawTextWindow(0, 0, width + 2, 7); + MenuPrint(gPCText_LogOff, 1, 5); + } + + if (FlagGet(SYS_PC_LANETTE)) // player met lanette? + MenuPrint(gPCText_LanettesPC, 1, 1); + else + MenuPrint(gPCText_SomeonesPC, 1, 1); + + MenuPrint(gPCText_PlayersPC, 1, 3); + InitMenu(0, 1, 1, numChoices, 0, width + 1); + sub_80B5230(0, 0, width + 2, 2 * numChoices + 1, 0, numChoices); +} +#elif GERMAN +__attribute__((naked)) +void CreatePCMenu(void) { + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + sub sp, 0x18\n\ + ldr r0, _080B5748 @ =0x0000084b\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080B5750\n\ + ldr r0, _080B574C @ =gPCText_LanettesPC\n\ + b _080B5752\n\ + .align 2, 0\n\ +_080B5748: .4byte 0x0000084b\n\ +_080B574C: .4byte gPCText_LanettesPC\n\ +_080B5750:\n\ + ldr r0, _080B57E8 @ =gPCText_SomeonesPC\n\ +_080B5752:\n\ + bl GetStringWidthInTilesForScriptMenu\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x8]\n\ + movs r4, 0x1\n\ + ldr r0, _080B57EC @ =gPCText_PlayersPC\n\ + bl GetStringWidthInTilesForScriptMenu\n\ + lsls r1, r4, 2\n\ + add r1, sp\n\ + adds r1, 0x8\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [r1]\n\ + ldr r0, _080B57F0 @ =gPCText_LogOff\n\ + bl GetStringWidthInTilesForScriptMenu\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x10]\n\ + movs r4, 0x3\n\ + ldr r0, _080B57F4 @ =0x00000804\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080B5798\n\ + ldr r0, _080B57F8 @ =gPCText_HallOfFame\n\ + bl GetStringWidthInTilesForScriptMenu\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x14]\n\ + movs r4, 0x4\n\ +_080B5798:\n\ + movs r5, 0\n\ + cmp r5, r4\n\ + bge _080B57B4\n\ + add r2, sp, 0x8\n\ + adds r1, r4, 0\n\ +_080B57A2:\n\ + ldr r0, [r2]\n\ + cmp r5, r0\n\ + bge _080B57AC\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ +_080B57AC:\n\ + adds r2, 0x4\n\ + subs r1, 0x1\n\ + cmp r1, 0\n\ + bne _080B57A2\n\ +_080B57B4:\n\ + ldr r0, _080B57F4 @ =0x00000804\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080B57FC\n\ + movs r7, 0x4\n\ + adds r4, r5, 0x2\n\ + lsls r2, r4, 24\n\ + lsrs r2, 24\n\ + movs r0, 0\n\ + movs r1, 0\n\ + movs r3, 0x9\n\ + bl MenuDrawTextWindow\n\ + ldr r0, _080B57F8 @ =gPCText_HallOfFame\n\ + movs r1, 0x1\n\ + movs r2, 0x5\n\ + bl MenuPrint\n\ + ldr r0, _080B57F0 @ =gPCText_LogOff\n\ + movs r1, 0x1\n\ + movs r2, 0x7\n\ + bl MenuPrint\n\ + b _080B5818\n\ + .align 2, 0\n\ +_080B57E8: .4byte gPCText_SomeonesPC\n\ +_080B57EC: .4byte gPCText_PlayersPC\n\ +_080B57F0: .4byte gPCText_LogOff\n\ +_080B57F4: .4byte 0x00000804\n\ +_080B57F8: .4byte gPCText_HallOfFame\n\ +_080B57FC:\n\ + movs r7, 0x3\n\ + adds r4, r5, 0x2\n\ + lsls r2, r4, 24\n\ + lsrs r2, 24\n\ + movs r0, 0\n\ + movs r1, 0\n\ + movs r3, 0x7\n\ + bl MenuDrawTextWindow\n\ + ldr r0, _080B5834 @ =gPCText_LogOff\n\ + movs r1, 0x1\n\ + movs r2, 0x5\n\ + bl MenuPrint\n\ +_080B5818:\n\ + adds r6, r4, 0\n\ + ldr r0, _080B5838 @ =0x0000084b\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080B5840\n\ + ldr r0, _080B583C @ =gPCText_LanettesPC\n\ + movs r1, 0x1\n\ + movs r2, 0x1\n\ + bl MenuPrint\n\ + b _080B584A\n\ + .align 2, 0\n\ +_080B5834: .4byte gPCText_LogOff\n\ +_080B5838: .4byte 0x0000084b\n\ +_080B583C: .4byte gPCText_LanettesPC\n\ +_080B5840:\n\ + ldr r0, _080B5888 @ =gPCText_SomeonesPC\n\ + movs r1, 0x1\n\ + movs r2, 0x1\n\ + bl MenuPrint\n\ +_080B584A:\n\ + ldr r0, _080B588C @ =gPCText_PlayersPC\n\ + movs r1, 0x1\n\ + movs r2, 0x3\n\ + bl MenuPrint\n\ + movs r4, 0\n\ + str r4, [sp]\n\ + adds r0, r5, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x4]\n\ + movs r0, 0\n\ + movs r1, 0x1\n\ + movs r2, 0x1\n\ + adds r3, r7, 0\n\ + bl InitMenu\n\ + lsls r2, r6, 24\n\ + lsrs r2, 24\n\ + lsls r3, r7, 1\n\ + adds r3, 0x1\n\ + str r4, [sp]\n\ + str r7, [sp, 0x4]\n\ + movs r0, 0\n\ + movs r1, 0\n\ + bl sub_80B5230\n\ + add sp, 0x18\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_080B5888: .4byte gPCText_SomeonesPC\n\ +_080B588C: .4byte gPCText_PlayersPC\n\ + .syntax divided\n"); +} +#endif + +void sub_80B5838(void) +{ + MenuDisplayMessageBox(); + MenuPrint(gPCText_WhichPCShouldBeAccessed, 2, 15); +} + +void task_picbox(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + task->data[0]++; + break; + case 1: + break; + case 2: + FreeResourcesAndDestroySprite(&gSprites[task->data[2]]); + task->data[0]++; + break; + case 3: + MenuZeroFillWindowRect(task->data[3], task->data[4], task->data[3] + 9, task->data[4] + 10); + DestroyTask(taskId); + break; + } +} + +bool8 sub_80B58C4(u16 var1, u8 var2, u8 var3) +{ + u8 taskId; + u8 var; + + if (FindTaskIdByFunc(task_picbox) != 0xFF) + return FALSE; + else + { + MenuDrawTextWindow(var2, var3, var2 + 9, var3 + 10); + taskId = CreateTask(task_picbox, 0x50); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = var1; + var = CreateMonSprite_PicBox(var1, var2 * 8 + 40, var3 * 8 + 40, 0); + gTasks[taskId].data[2] = var; + gTasks[taskId].data[3] = var2; + gTasks[taskId].data[4] = var3; + gSprites[var].callback = SpriteCallbackDummy; + gSprites[var].oam.priority = 0; + return TRUE; + } +} + +void *picbox_close(void) +{ + u8 taskId = FindTaskIdByFunc(task_picbox); + + if (taskId == 0xFF) + return NULL; + + gTasks[taskId].data[0]++; + return (void *)sub_80B59AC; +} + +bool8 sub_80B59AC(void) +{ + if (FindTaskIdByFunc(task_picbox) == 0xFF) + return TRUE; + else + return FALSE; +} diff --git a/src/script_movement.c b/src/script_movement.c new file mode 100644 index 000000000..31143ed6f --- /dev/null +++ b/src/script_movement.c @@ -0,0 +1,224 @@ +#include "global.h" +#include "script_movement.h" +#include "field_map_obj.h" +#include "field_map_obj_helpers.h" +#include "task.h" +#include "util.h" + +extern u8 *gUnknown_020384F8[]; + +static void sub_80A2198(u8); +static u8 sub_80A21E0(void); +static bool8 sub_80A21F4(u8, u8, u8 *); +static u8 sub_80A2260(u8, u8); +static bool8 sub_80A2370(u8, u8); +static void sub_80A23C8(u8, u8, u8, u8 *); +static void sub_80A2408(u8); +static void Task_80A244C(u8); +static void sub_80A2490(u8, u8, u8, u8 *); + +bool8 exec_movement(u8 a, u8 b, u8 c, u8 *d) +{ + u8 mapObjId; + + if (TryGetFieldObjectIdByLocalIdAndMap(a, b, c, &mapObjId)) + return TRUE; + if (!FuncIsActiveTask(Task_80A244C)) + sub_80A2198(50); + return sub_80A21F4(sub_80A21E0(), mapObjId, d); +} + +bool8 sub_80A212C(u8 a, u8 b, u8 c) +{ + u8 mapObjId; + u8 r4; + u8 r1; + + if (TryGetFieldObjectIdByLocalIdAndMap(a, b, c, &mapObjId)) + return 1; + r4 = sub_80A21E0(); + r1 = sub_80A2260(r4, mapObjId); + if (r1 == 16) + return 1; + return sub_80A2370(r4, r1); +} + +void sub_80A2178(void) +{ + u8 taskId; + + taskId = sub_80A21E0(); + if (taskId != 0xFF) + { + sub_80A2408(taskId); + DestroyTask(taskId); + } +} + +static void sub_80A2198(u8 priority) +{ + u8 taskId; + u8 i; + + taskId = CreateTask(Task_80A244C, priority); + for (i = 1; i < 16; i++) + gTasks[taskId].data[i] = 0xFFFF; +} + +static u8 sub_80A21E0(void) +{ + return FindTaskIdByFunc(Task_80A244C); +} + +static bool8 sub_80A21F4(u8 taskId, u8 b, u8 *c) +{ + u8 r4; + + r4 = sub_80A2260(taskId, b); + if (r4 != 16) + { + if (sub_80A2370(taskId, r4) == 0) + return TRUE; + else + { + sub_80A23C8(taskId, r4, b, c); + return FALSE; + } + } + r4 = sub_80A2260(taskId, 0xFF); + if (r4 == 16) + return TRUE; + else + { + sub_80A23C8(taskId, r4, b, c); + return FALSE; + } +} + +static u8 sub_80A2260(u8 taskId, u8 b) +{ + u8 *ptr; + u8 i; + + ptr = (u8 *)&gTasks[taskId].data[1]; + for (i = 0; i < 16; i++, ptr++) + { + if (*ptr == b) + return i; + } + return 16; +} + +static void sub_80A229C(u8 taskId, u8 b, u8 **c) +{ + u8 i; + + *c = (u8 *)&gTasks[taskId].data[1]; + for (i = 0; i < b; i++, (*c)++) + ; +} + +static void sub_80A22D0(u8 taskId, u8 b, u8 c) +{ + u8 *ptr; + + sub_80A229C(taskId, b, &ptr); + *ptr = c; //what is this supposed to do? +} + +static void sub_80A22F4(u8 taskId, u8 b, u8 *c) +{ + u8 *ptr; + + sub_80A229C(taskId, b, &ptr); + *c = *ptr; +} + +static void sub_80A2318(u8 a, u8 b) +{ + u16 var = ~gBitTable[b]; + + gTasks[a].data[0] &= var; +} + +static void sub_80A2348(u8 taskId, u8 b) +{ + gTasks[taskId].data[0] |= gBitTable[b]; +} + +static bool8 sub_80A2370(u8 taskId, u8 b) +{ + u16 var = (u16)gTasks[taskId].data[0] & gBitTable[b]; + + if (var != 0) + return TRUE; + else + return FALSE; +} + +static void npc_obj_offscreen_culling_and_flag_update(u8 a, u8 *b) +{ + gUnknown_020384F8[a] = b; +} + +static u8 *sub_80A23B8(u8 a) +{ + return gUnknown_020384F8[a]; +} + +static void sub_80A23C8(u8 taskId, u8 b, u8 c, u8 *d) +{ + sub_80A2318(taskId, b); + npc_obj_offscreen_culling_and_flag_update(b, d); + sub_80A22D0(taskId, b, c); +} + +static void sub_80A2408(u8 a) +{ + u8 *ptr; + u8 i; + + ptr = (u8 *)&gTasks[a].data[1]; + for (i = 0; i < 16; i++, ptr++) + { + if (*ptr != 0xFF) + UnfreezeMapObject(&gMapObjects[*ptr]); + } +} + +static void Task_80A244C(u8 taskId) +{ + u8 i; + u8 var; + + for (i = 0; i < 16; i++) + { + sub_80A22F4(taskId, i, &var); + if (var != 0xFF) + sub_80A2490(taskId, i, var, sub_80A23B8(i)); + } +} + +static void sub_80A2490(u8 taskId, u8 b, u8 c, u8 *d) +{ + u8 var; + + if (FieldObjectIsSpecialAnimActive(&gMapObjects[c]) + && !FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[c])) + return; + + var = *d; + if (var == 0xFE) + { + sub_80A2348(taskId, b); + FreezeMapObject(&gMapObjects[c]); + } + else + { + if (!FieldObjectSetSpecialAnim(&gMapObjects[c], var)) + { + d++; + npc_obj_offscreen_culling_and_flag_update(b, d); + } + } +} diff --git a/src/script_pokemon_util_80C4BF0.c b/src/script_pokemon_util_80C4BF0.c new file mode 100644 index 000000000..cbca07011 --- /dev/null +++ b/src/script_pokemon_util_80C4BF0.c @@ -0,0 +1,716 @@ +#include "global.h" +#include "battle.h" +#include "berry.h" +#include "choose_party.h" +#include "contest.h" +#include "contest_link_80C2020.h" +#include "contest_painting.h" +#include "data2.h" +#include "daycare.h" +#include "debug.h" +#include "decompress.h" +#include "event_data.h" +#include "items.h" +#include "link.h" +#include "load_save.h" +#include "main.h" +#include "menu.h" +#include "pokedex.h" +#include "pokemon.h" +#include "rng.h" +#include "rom4.h" +#include "script_pokemon_80C4.h" +#include "species.h" +#include "task.h" + +#define CONTEST_ENTRY_PIC_LEFT 10 +#define CONTEST_ENTRY_PIC_TOP 3 + +extern struct SpriteTemplate gUnknown_02024E8C; + +extern u8 gContestPlayerMonIndex; +extern u8 gIsLinkContest; +extern u8 gPlayerPartyCount; +extern u8 gSelectedOrderFromParty[]; + +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u16 gSpecialVar_0x8006; + +extern u16 gScriptContestCategory; +extern u16 gScriptContestRank; +extern u16 gScriptResult; + +extern u32 gUnknown_03005D28; + +extern u8 gUnknown_02038694; +extern u8 gUnknown_0203856C; +extern u8 gUnknown_02038690[]; +extern u16 gUnknown_02038678[]; + +void sub_80C4BF0(void) +{ + gSaveBlock1.vars[0x10] = gContestMons[0].unk16; + gSaveBlock1.vars[0x11] = gContestMons[1].unk16; + gSaveBlock1.vars[0x12] = gContestMons[2].unk16; +} + +void sub_80C4C28(void) +{ + u16 var; + u8 specialVar = gSpecialVar_0x8005; + + switch(specialVar) + { + case 0: + var = 3; + break; + case 1: + var = 4; + break; + case 2: + var = 5; + break; + default: + var = 100; + break; + } + gSpecialVar_0x8004 = var; +} + +void sub_80C4C64(void) +{ + sub_80C46EC(); + sub_80C4740(); + sub_80C48F4(); +} + +void sub_80C4C78(void) +{ + u16 var; + u16 returnVar; + + switch(gScriptContestCategory) + { + case 0: + var = 8; + break; + case 1: + var = 9; + break; + case 2: + var = 10; + break; + case 3: + var = 11; + break; + case 4: + default: + var = 12; + break; + } + + returnVar = gSaveBlock1.sbStruct.unkSB2.sb1_2EFC_struct2[var].var; + + if(returnVar == 0) + gSpecialVar_0x8004 = returnVar; + else + gSpecialVar_0x8004 = 1; +} + +void sub_80C4CEC(void) +{ + sub_80B2A7C(0xFF); +} + +void sub_80C4CF8(void) +{ + if(!gUnknown_02038690[gContestPlayerMonIndex] + && gScriptContestRank == 3 + && (s16)gUnknown_02038678[gContestPlayerMonIndex] >= 800) + { + gSpecialVar_0x8004 = 1; + } + else + { + gSpecialVar_0x8004 = 0; + } +} + +u8 sub_80C4D50(void) +{ + u8 retVar = 0; + int i; + + for (i = 0; i < 5; i++) + if (gSaveBlock1.sbStruct.unkSB2.sb1_2EFC_struct2[i + 8].var) + retVar++; + + return retVar; +} + +// nope. too hard +__attribute__((naked)) +void sub_80C4D80(void) +{ + 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, 0x8\n\ + ldr r0, _080C4EA0 @ =gUnknown_02038670\n\ + mov r12, r0\n\ + ldr r1, _080C4EA4 @ =gSpecialVar_0x8006\n\ + mov r8, r1\n\ + ldr r2, _080C4EA8 @ =gStringVar1\n\ + mov r9, r2\n\ + mov r2, r12\n\ + mov r1, sp\n\ + movs r6, 0x3\n\ +_080C4D9E:\n\ + ldrh r0, [r2]\n\ + strh r0, [r1]\n\ + adds r2, 0x2\n\ + adds r1, 0x2\n\ + subs r6, 0x1\n\ + cmp r6, 0\n\ + bge _080C4D9E\n\ + movs r6, 0\n\ +_080C4DAE:\n\ + movs r1, 0x3\n\ + cmp r1, r6\n\ + ble _080C4DD8\n\ +_080C4DB4:\n\ + subs r4, r1, 0x1\n\ + lsls r0, r4, 1\n\ + mov r5, sp\n\ + adds r3, r5, r0\n\ + lsls r0, r1, 1\n\ + adds r2, r5, r0\n\ + ldrh r5, [r3]\n\ + movs r7, 0\n\ + ldrsh r1, [r3, r7]\n\ + movs r7, 0\n\ + ldrsh r0, [r2, r7]\n\ + cmp r1, r0\n\ + bge _080C4DD2\n\ + strh r5, [r2]\n\ + strh r0, [r3]\n\ +_080C4DD2:\n\ + adds r1, r4, 0\n\ + cmp r1, r6\n\ + bgt _080C4DB4\n\ +_080C4DD8:\n\ + adds r6, 0x1\n\ + cmp r6, 0x2\n\ + ble _080C4DAE\n\ + mov r2, r8\n\ + ldrh r0, [r2]\n\ + lsls r0, 1\n\ + add r0, sp\n\ + ldrh r0, [r0]\n\ + movs r2, 0\n\ + movs r7, 0\n\ + movs r6, 0\n\ + lsls r0, 16\n\ + asrs r4, r0, 16\n\ + adds r3, r0, 0\n\ + mov r1, sp\n\ +_080C4DF6:\n\ + movs r5, 0\n\ + ldrsh r0, [r1, r5]\n\ + cmp r0, r4\n\ + bne _080C4E12\n\ + lsls r0, r2, 24\n\ + movs r2, 0x80\n\ + lsls r2, 17\n\ + adds r0, r2\n\ + lsrs r2, r0, 24\n\ + mov r5, r8\n\ + ldrh r5, [r5]\n\ + cmp r6, r5\n\ + bne _080C4E12\n\ + adds r7, r2, 0\n\ +_080C4E12:\n\ + adds r1, 0x2\n\ + adds r6, 0x1\n\ + cmp r6, 0x3\n\ + ble _080C4DF6\n\ + movs r6, 0\n\ + mov r0, sp\n\ + movs r1, 0\n\ + ldrsh r0, [r0, r1]\n\ + asrs r1, r3, 16\n\ + lsls r2, 24\n\ + mov r10, r2\n\ + cmp r0, r1\n\ + beq _080C4E40\n\ + adds r2, r1, 0\n\ + mov r1, sp\n\ +_080C4E30:\n\ + adds r1, 0x2\n\ + adds r6, 0x1\n\ + cmp r6, 0x3\n\ + bgt _080C4E40\n\ + movs r4, 0\n\ + ldrsh r0, [r1, r4]\n\ + cmp r0, r2\n\ + bne _080C4E30\n\ +_080C4E40:\n\ + lsls r0, r6, 24\n\ + lsrs r4, r0, 24\n\ + adds r2, r7, 0\n\ + movs r6, 0\n\ + asrs r5, r3, 16\n\ + mov r8, r5\n\ + mov r1, r12\n\ + movs r5, 0\n\ + ldrsh r0, [r1, r5]\n\ + cmp r8, r0\n\ + bne _080C4E60\n\ + cmp r7, 0x1\n\ + beq _080C4E78\n\ +_080C4E5A:\n\ + subs r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ +_080C4E60:\n\ + adds r6, 0x1\n\ + cmp r6, 0x3\n\ + bgt _080C4E78\n\ + lsls r0, r6, 1\n\ + add r0, r12\n\ + asrs r1, r3, 16\n\ + movs r5, 0\n\ + ldrsh r0, [r0, r5]\n\ + cmp r1, r0\n\ + bne _080C4E60\n\ + cmp r2, 0x1\n\ + bne _080C4E5A\n\ +_080C4E78:\n\ + lsls r1, r6, 24\n\ + lsrs r1, 24\n\ + mov r0, r9\n\ + bl sub_80C4698\n\ + ldr r0, _080C4EAC @ =gIsLinkContest\n\ + ldrb r1, [r0]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080C4EB8\n\ + ldr r0, _080C4EB0 @ =gStringVar2\n\ + lsls r1, r6, 3\n\ + subs r1, r6\n\ + lsls r1, 2\n\ + ldr r2, _080C4EB4 @ =gLinkPlayers + 0x8\n\ + adds r1, r2\n\ + bl sub_80C4674\n\ + b _080C4EC4\n\ + .align 2, 0\n\ +_080C4EA0: .4byte gUnknown_02038670\n\ +_080C4EA4: .4byte gSpecialVar_0x8006\n\ +_080C4EA8: .4byte gStringVar1\n\ +_080C4EAC: .4byte gIsLinkContest\n\ +_080C4EB0: .4byte gStringVar2\n\ +_080C4EB4: .4byte gLinkPlayers + 0x8\n\ +_080C4EB8:\n\ + ldr r0, _080C4ED8 @ =gStringVar2\n\ + lsls r1, r6, 6\n\ + ldr r2, _080C4EDC @ =gUnknown_0203857D\n\ + adds r1, r2\n\ + bl sub_80C4674\n\ +_080C4EC4:\n\ + mov r1, r10\n\ + asrs r0, r1, 24\n\ + cmp r0, 0x1\n\ + beq _080C4ED0\n\ + cmp r7, r0\n\ + bne _080C4EE4\n\ +_080C4ED0:\n\ + ldr r0, _080C4EE0 @ =gSpecialVar_0x8006\n\ + strh r4, [r0]\n\ + b _080C4EEA\n\ + .align 2, 0\n\ +_080C4ED8: .4byte gStringVar2\n\ +_080C4EDC: .4byte gUnknown_0203857D\n\ +_080C4EE0: .4byte gSpecialVar_0x8006\n\ +_080C4EE4:\n\ + ldr r1, _080C4EFC @ =gSpecialVar_0x8006\n\ + adds r0, r4, 0x4\n\ + strh r0, [r1]\n\ +_080C4EEA:\n\ + add sp, 0x8\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\ + .align 2, 0\n\ +_080C4EFC: .4byte gSpecialVar_0x8006\n\ + .syntax divided"); +} + +void ShowContestWinnerCleanup(void) +{ + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); +} + +void ShowContestWinner(void) +{ + if(gUnknown_0203856C) + { + sub_80AAF30(); + BATTLE_STRUCT->unk15DDF = 1; + BATTLE_STRUCT->unk15DDE = sub_80B2C4C(254, 0); + sub_80B2A7C(3); + gUnknown_0203856C = 0; + } + SetMainCallback2(CB2_ContestPainting); + gMain.savedCallback = ShowContestWinnerCleanup; +} + +void sub_80C4F70(void) +{ + VarSet(0x4010, gContestMons[0].unk16); + VarSet(0x4011, gContestMons[1].unk16); + VarSet(0x4012, gContestMons[2].unk16); + VarSet(0x4013, gContestMons[3].unk16); +} + +bool8 GiveMonArtistRibbon(void) +{ + u8 ribbon = GetMonData(&gPlayerParty[gUnknown_02038694], MON_DATA_ARTIST_RIBBON); + + if(ribbon == FALSE + && gUnknown_02038690[gContestPlayerMonIndex] == 0 + && gScriptContestRank == 3 + && (s16)gUnknown_02038678[gContestPlayerMonIndex] >= 800) + { + ribbon = TRUE; + SetMonData(&gPlayerParty[gUnknown_02038694], MON_DATA_ARTIST_RIBBON, &ribbon); + return TRUE; + } + else + { + return FALSE; + } +} + +u8 sub_80C5044(void) +{ + return gUnknown_0203856C; +} + +void ShowContestEntryMonPic(void) +{ + const struct CompressedSpritePalette *palette; + u32 var1, var2; + u16 species; + u8 spriteId; + u8 taskId; + + if(FindTaskIdByFunc(sub_80C5190) == 0xFF) + { + u8 left = CONTEST_ENTRY_PIC_LEFT; + u8 top = CONTEST_ENTRY_PIC_TOP; + + MenuDrawTextWindow(left, top, 19, 13); + species = gContestMons[gSpecialVar_0x8006].species; + var1 = gContestMons[gSpecialVar_0x8006].unk38; // v2 + var2 = gContestMons[gSpecialVar_0x8006].unk3C; // v3 + taskId = CreateTask(sub_80C5190, 0x50); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = species; + HandleLoadSpecialPokePic( + &gMonFrontPicTable[species], + gMonFrontPicCoords[species].coords, + gMonFrontPicCoords[species].y_offset, + (u32)gUnknown_081FAF4C[0], + gUnknown_081FAF4C[1], + species, + var1); + palette = sub_80409C8(species, var2, var1); + LoadCompressedObjectPalette(palette); + GetMonSpriteTemplate_803C56C(species, 1); + gUnknown_02024E8C.paletteTag = palette->tag; + spriteId = CreateSprite(&gUnknown_02024E8C, 0x78, 0x40, 0); + gTasks[taskId].data[2] = spriteId; + gTasks[taskId].data[3] = left; + gTasks[taskId].data[4] = top; + gSprites[spriteId].callback = SpriteCallbackDummy; + gSprites[spriteId].oam.priority = 0; + } +} + +void sub_80C5164(void) +{ + u8 taskId = FindTaskIdByFunc(sub_80C5190); + + if(taskId != 0xFF) + gTasks[taskId].data[0]++; +} + +void sub_80C5190(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + struct Sprite *sprite; + + switch(task->data[0]) + { + case 2: + sprite = &gSprites[task->data[2]]; + FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum)); + + if(sprite->oam.affineMode) + FreeOamMatrix(sprite->oam.matrixNum); + + DestroySprite(sprite); + task->data[0]++; + break; + case 0: + task->data[0]++; + break; + case 3: + MenuZeroFillWindowRect(task->data[3], task->data[4], task->data[3] + 9, task->data[4] + 10); + DestroyTask(taskId); + break; + case 1: + default: + break; + } +} + +void ScriptGetMultiplayerId(void) +{ + if(gIsLinkContest & 1) + gScriptResult = GetMultiplayerId(); + else + gScriptResult = 4; +} + +void ScriptRandom(void) +{ + u16 random; + u16 *scriptPtr; + + if(gIsLinkContest & 1) + { + gUnknown_03005D28 = 1103515245 * gUnknown_03005D28 + 24691; + random = gUnknown_03005D28 >> 16; + scriptPtr = &gScriptResult; + } + else + { + scriptPtr = &gScriptResult; + random = Random(); + } + *scriptPtr = random % *scriptPtr; +} + +void HealPlayerParty(void) +{ + u8 i, j; + u8 ppBonuses; + u8 arg[4]; + + // restore HP. + for(i = 0; i < gPlayerPartyCount; i++) + { + u16 maxHP = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP); + arg[0] = maxHP; + arg[1] = maxHP >> 8; + SetMonData(&gPlayerParty[i], MON_DATA_HP, arg); + ppBonuses = GetMonData(&gPlayerParty[i], MON_DATA_PP_BONUSES); + + // restore PP. + for(j = 0; j < 4; j++) + { + arg[0] = CalculatePPWithBonus(GetMonData(&gPlayerParty[i], MON_DATA_MOVE1 + j), ppBonuses, j); + SetMonData(&gPlayerParty[i], MON_DATA_PP1 + j, arg); + } + + // since status is u32, the four 0 assignments here are probably for safety to prevent undefined data from reaching SetMonData. + arg[0] = 0; + arg[1] = 0; + arg[2] = 0; + arg[3] = 0; + SetMonData(&gPlayerParty[i], MON_DATA_STATUS, arg); + } +} + +u8 ScriptGiveMon(u16 species, u8 var, u16 item, u32 var3, u32 var4, u8 var5) +{ + u16 nationalSpecies; + int sentToPc; + u8 array[2]; + struct Pokemon mon; + + CreateMon(&mon, species, var, 32, 0, 0, 0, 0); + array[0] = item; + array[1] = item >> 8; + SetMonData(&mon, MON_DATA_HELD_ITEM, array); + sentToPc = GiveMonToPlayer(&mon); + nationalSpecies = SpeciesToNationalPokedexNum(species); + + // nested if check to fool compiler + switch(sentToPc) + { + case 0: + case 1: + GetNationalPokedexFlag(nationalSpecies, 2); + GetNationalPokedexFlag(nationalSpecies, 3); + return sentToPc; + default: + return sentToPc; + } +} + +u8 ScriptGiveEgg(u16 value) +{ + struct Pokemon mon; + u8 data; + + sub_8042044(&mon, value, 1); + data = 1; + SetMonData(&mon, MON_DATA_IS_EGG, &data); + + return GiveMonToPlayer(&mon); +} + +void CheckForAlivePartyMons(void) +{ + u8 var = sub_803DAA0(); + + switch(var) + { + case 1: + gScriptResult = var; + break; + case 0: + gScriptResult = var; + break; + case 2: + gScriptResult = var; + break; + } +} + +bool8 CheckPartyMonHasHeldItem(u16 item) +{ + int i; + + for(i = 0; i < 6; i++) + { + u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + if(species != SPECIES_NONE && species != SPECIES_EGG && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == item) + return TRUE; + } + return FALSE; +} + +bool8 GetNameOfEnigmaBerryInPlayerParty(void) +{ + bool8 hasItem = CheckPartyMonHasHeldItem(ITEM_ENIGMA_BERRY); + + if(hasItem == TRUE) + GetBerryNameByBerryType(ItemIdToBerryType(ITEM_ENIGMA_BERRY), gStringVar1); + + return hasItem; +} + +void ScriptWildBattle(u16 species, u8 level, u16 item) +{ + u8 data[2]; + + ZeroEnemyPartyMons(); + CreateMon(&gEnemyParty[0], species, level, 0x20, 0, 0, 0, 0); + + if(item) + { + data[0] = item; + data[1] = item >> 8; + SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, data); + } +} + +void ScriptSetMonMoveSlot(u8 monIndex, u16 move, u8 slot) +{ + if(monIndex > 6) + monIndex = gPlayerPartyCount - 1; + + SetMonMoveSlot(&gPlayerParty[monIndex], move, slot); +} + +void sub_80C5568(void) +{ + gMain.savedCallback = sub_80C5580; + sub_8121E10(); +} + +void sub_80C5580(void) +{ + u8 var = gSelectedOrderFromParty[0]; + + switch(var) + { + case 0: + gScriptResult = 0; + break; + default: + gScriptResult = 1; + break; + } + + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); +} + +void ChooseBattleTowerPlayerParty(void) +{ + gMain.savedCallback = SetBattleTowerPlayerParty; + sub_8121E34(); +} + +void SetBattleTowerPlayerParty(void) +{ + u8 var = gSelectedOrderFromParty[0]; + + switch(var) + { + case 0: // player quit battle tower? + LoadPlayerParty(); + gScriptResult = 0; + break; + default: // load battle tower. + ReducePlayerPartyToThree(); + gScriptResult = 1; + break; + } + + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); +} + +void ReducePlayerPartyToThree(void) +{ + struct Pokemon party[3]; + int i; + + CpuFill32(0, party, sizeof party); + + // copy the selected pokemon according to the order. + for(i = 0; i < 3; i++) + if(gSelectedOrderFromParty[i]) // as long as the order keeps going (did the player select 1 mon? 2? 3?), do not stop + party[i] = gPlayerParty[gSelectedOrderFromParty[i] - 1]; // index is 0 based, not literal + + // delete the last 3 pokemon + CpuFill32(0, gPlayerParty, sizeof gPlayerParty); + + // overwrite the first 3 with the order copied to. + for(i = 0; i < 3; i++) + gPlayerParty[i] = party[i]; + + CalculatePlayerPartyCount(); +} diff --git a/src/script_pokemon_util_80F99CC.c b/src/script_pokemon_util_80F99CC.c new file mode 100644 index 000000000..2b48cc0d8 --- /dev/null +++ b/src/script_pokemon_util_80F99CC.c @@ -0,0 +1,445 @@ +#include "global.h" +#include "battle_party_menu.h" +#include "choose_party.h" +#include "contest.h" +#include "data2.h" +#include "party_menu.h" +#include "field_fadetransition.h" +#include "palette.h" +#include "party_menu.h" +#include "pokemon.h" +#include "pokemon_summary_screen.h" +#include "rom4.h" +#include "script.h" +#include "script_pokemon_80F9.h" +#include "sound.h" +#include "string_util.h" +#include "task.h" +#include "text.h" + + + +extern u8 gPlayerPartyCount; +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u8 gUnknown_02038694; +extern u16 gScriptResult; + +extern void (*gFieldCallback)(void); + +void sub_80F99CC(void) +{ + u8 taskId; + + ScriptContext2_Enable(); + taskId = CreateTask((void *)sub_80F9A8C, 0xA); + gTasks[taskId].data[0] = 2; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); +} + +void sub_80F9A0C(void) +{ + u8 taskId; + + ScriptContext2_Enable(); + taskId = CreateTask((void *)sub_80F9A8C, 0xA); + gTasks[taskId].data[0] = 3; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); +} + +void sub_80F9A4C(void) +{ + u8 taskId; + + ScriptContext2_Enable(); + taskId = CreateTask((void *)sub_80F9A8C, 0xA); + gTasks[taskId].data[0] = 7; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); +} + +void sub_80F9A8C(u8 taskId) +{ + if(!gPaletteFade.active) + { + gPaletteFade.bufferTransferDisabled = 1; + OpenPartyMenu((u8) gTasks[taskId].data[0], 0); + DestroyTask(taskId); + } +} + +bool8 sub_80F9ACC(void) +{ + switch(EWRAM_1B000.unk264) + { + case 0: + if(EWRAM_1B000.unk266 < gPlayerPartyCount) + { + TryCreatePartyMenuMonIcon(EWRAM_1B000.unk260, EWRAM_1B000.unk266, &gPlayerParty[EWRAM_1B000.unk266]); + EWRAM_1B000.unk266++; + } + else + { + EWRAM_1B000.unk266 = 0; + EWRAM_1B000.unk264++; + } + break; + case 1: + LoadHeldItemIconGraphics(); + EWRAM_1B000.unk264++; + break; + case 2: + CreateHeldItemIcons_806DC34(EWRAM_1B000.unk260); + EWRAM_1B000.unk264++; + break; + case 3: + if(sub_806BD58(EWRAM_1B000.unk260, EWRAM_1B000.unk266) != 1) + { + EWRAM_1B000.unk266++; + break; + } + else + { + EWRAM_1B000.unk266 = 0; + EWRAM_1B000.unk264++; + break; + } + case 4: + PartyMenuPrintMonsLevelOrStatus(); + EWRAM_1B000.unk264++; + break; + case 5: + PrintPartyMenuMonNicknames(); + EWRAM_1B000.unk264++; + break; + case 6: + sub_80F9C00(); + EWRAM_1B000.unk264++; + break; + case 7: // the only case that can return true. + if(sub_806B58C(EWRAM_1B000.unk266) != 1) + { + EWRAM_1B000.unk266++; + break; + } + else + { + EWRAM_1B000.unk266 = 0; + EWRAM_1B000.unk264 = 0; + return TRUE; + } + } + return FALSE; +} + +void sub_80F9C00(void) +{ + u8 i; + + for(i = 0; i < gPlayerPartyCount; i++) + { + switch(sub_80AE47C(&gPlayerParty[i])) + { + case 0: + case 3: + case 4: + sub_806BC3C(i, 0x7E); + break; + case 1: + case 2: + sub_806BC3C(i, 0x70); + break; + } + } +} + +void sub_80F9C6C(u8 var) +{ + if(!gPaletteFade.active) + { + switch(sub_806BD80(var)) + { + case 1: + PlaySE(5); + gUnknown_02038694 = sub_806CA38(var); + gSpecialVar_0x8004 = gUnknown_02038694; + sub_8123138(var); + break; + case 2: + PlaySE(5); + gUnknown_02038694 = 0xFF; + gSpecialVar_0x8004 = 0xFF; + sub_8123138(var); + break; + } + } +} + +bool8 sub_80F9CE8(void) // this is the same function as sub_80F9ACC except case 6 calls a different function. why +{ + switch(EWRAM_1B000.unk264) + { + case 0: + if(EWRAM_1B000.unk266 < gPlayerPartyCount) + { + TryCreatePartyMenuMonIcon(EWRAM_1B000.unk260, EWRAM_1B000.unk266, &gPlayerParty[EWRAM_1B000.unk266]); + EWRAM_1B000.unk266++; + } + else + { + EWRAM_1B000.unk266 = 0; + EWRAM_1B000.unk264++; + } + break; + case 1: + LoadHeldItemIconGraphics(); + EWRAM_1B000.unk264++; + break; + case 2: + CreateHeldItemIcons_806DC34(EWRAM_1B000.unk260); + EWRAM_1B000.unk264++; + break; + case 3: + if(sub_806BD58(EWRAM_1B000.unk260, EWRAM_1B000.unk266) != 1) + { + EWRAM_1B000.unk266++; + break; + } + else + { + EWRAM_1B000.unk266 = 0; + EWRAM_1B000.unk264++; + break; + } + case 4: + PartyMenuPrintMonsLevelOrStatus(); + EWRAM_1B000.unk264++; + break; + case 5: + PrintPartyMenuMonNicknames(); + EWRAM_1B000.unk264++; + break; + case 6: + sub_80F9E1C(); + EWRAM_1B000.unk264++; + break; + case 7: // the only case that can return true. + if(sub_806B58C(EWRAM_1B000.unk266) != 1) + { + EWRAM_1B000.unk266++; + break; + } + else + { + EWRAM_1B000.unk266 = 0; + EWRAM_1B000.unk264 = 0; + return TRUE; + } + } + return FALSE; +} + +void sub_80F9E1C(void) +{ + u8 i; + + for(i = 0; i < gPlayerPartyCount; i++) + { + if(!sub_8040574(&gPlayerParty[i])) + sub_806BC3C(i, 0x9A); + else + sub_806BC3C(i, 0x8C); + } +} + +void sub_80F9E64(u8 var) +{ + if(!gPaletteFade.active) + { + switch(sub_806BD80(var)) + { + case 1: + PlaySE(5); + gSpecialVar_0x8004 = sub_806CA38(var); + gSpecialVar_0x8005 = sub_8040574(&gPlayerParty[gSpecialVar_0x8004]); + sub_8123138(var); + break; + case 2: + PlaySE(5); + gSpecialVar_0x8004 = 0xFF; + sub_8123138(var); + } + } +} + +void sub_80F9EEC(void) +{ + sub_809D9F0(&gPlayerParty[0], gSpecialVar_0x8004, gPlayerPartyCount - 1, c2_exit_to_overworld_2_switch, 0); + unk_2018000.unk8 = 3; + gFieldCallback = sub_8080990; +} + +void sub_80F9F3C(void) // count pokemon moves +{ + u8 i; + + gScriptResult = 0; + + for(i = 0; i < 4; i++) // checks MOVE1-MOVE4 + if(GetMonData(&gPlayerParty[gSpecialVar_0x8004], i + 13)) + gScriptResult++; +} + +void sub_80F9F84(void) +{ + struct Pokemon *party = &gPlayerParty[gSpecialVar_0x8004]; + u16 data = GetMonData(party, gSpecialVar_0x8005 + 13); + + GetMonNickname(party, gStringVar1); + StringCopy(gStringVar2, gMoveNames[data]); +} + +// no. hard +__attribute__((naked)) +void sub_80F9FDC(struct Pokemon *party, u8 var, u8 var2) +{ + 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, 0x20\n\ + mov r8, r0\n\ + adds r5, r1, 0\n\ + adds r4, r2, 0\n\ + lsls r5, 24\n\ + lsrs r5, 24\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + adds r0, r5, 0\n\ + adds r0, 0xD\n\ + str r0, [sp, 0x8]\n\ + mov r0, r8\n\ + ldr r1, [sp, 0x8]\n\ + bl GetMonData\n\ + mov r1, sp\n\ + adds r1, 0x2\n\ + str r1, [sp, 0x14]\n\ + strh r0, [r1]\n\ + adds r3, r4, 0\n\ + adds r3, 0xD\n\ + str r3, [sp, 0xC]\n\ + mov r0, r8\n\ + adds r1, r3, 0\n\ + bl GetMonData\n\ + mov r1, sp\n\ + strh r0, [r1]\n\ + adds r7, r5, 0\n\ + adds r7, 0x11\n\ + str r7, [sp, 0x10]\n\ + mov r0, r8\n\ + adds r1, r7, 0\n\ + bl GetMonData\n\ + mov r1, sp\n\ + adds r1, 0x5\n\ + str r1, [sp, 0x18]\n\ + strb r0, [r1]\n\ + adds r3, r4, 0\n\ + adds r3, 0x11\n\ + str r3, [sp, 0x1C]\n\ + mov r0, r8\n\ + adds r1, r3, 0\n\ + bl GetMonData\n\ + add r7, sp, 0x4\n\ + mov r10, r7\n\ + strb r0, [r7]\n\ + mov r0, r8\n\ + movs r1, 0x15\n\ + bl GetMonData\n\ + mov r6, sp\n\ + adds r6, 0x6\n\ + strb r0, [r6]\n\ + ldr r1, _080FA0D8 @ =gUnknown_08208238\n\ + adds r0, r5, r1\n\ + ldrb r0, [r0]\n\ + mov r9, r0\n\ + ldrb r0, [r6]\n\ + adds r2, r0, 0\n\ + mov r3, r9\n\ + ands r2, r3\n\ + lsls r5, 1\n\ + asrs r2, r5\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + adds r1, r4, r1\n\ + ldrb r3, [r1]\n\ + adds r1, r0, 0\n\ + ands r1, r3\n\ + lsls r4, 1\n\ + asrs r1, r4\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + mov r7, r9\n\ + bics r0, r7\n\ + strb r0, [r6]\n\ + ldrb r0, [r6]\n\ + bics r0, r3\n\ + strb r0, [r6]\n\ + lsls r2, r4\n\ + lsls r1, r5\n\ + adds r2, r1\n\ + ldrb r0, [r6]\n\ + orrs r0, r2\n\ + strb r0, [r6]\n\ + mov r0, r8\n\ + ldr r1, [sp, 0x8]\n\ + mov r2, sp\n\ + bl SetMonData\n\ + mov r0, r8\n\ + ldr r1, [sp, 0xC]\n\ + ldr r2, [sp, 0x14]\n\ + bl SetMonData\n\ + mov r0, r8\n\ + ldr r1, [sp, 0x10]\n\ + mov r2, r10\n\ + bl SetMonData\n\ + mov r0, r8\n\ + ldr r1, [sp, 0x1C]\n\ + ldr r2, [sp, 0x18]\n\ + bl SetMonData\n\ + mov r0, r8\n\ + movs r1, 0x15\n\ + adds r2, r6, 0\n\ + bl SetMonData\n\ + add sp, 0x20\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\ + .align 2, 0\n\ +_080FA0D8: .4byte gUnknown_08208238\n\ + .syntax divided"); +} + +void sub_80FA0DC(void) +{ + u16 i; + + SetMonMoveSlot(&gPlayerParty[gSpecialVar_0x8004], 0, gSpecialVar_0x8005); + RemoveMonPPBonus(&gPlayerParty[gSpecialVar_0x8004], gSpecialVar_0x8005); + + for(i = gSpecialVar_0x8005; i < 3; i++) + sub_80F9FDC(&gPlayerParty[gSpecialVar_0x8004], i, i + 1); +} + +void sub_80FA148(void) +{ + struct Pokemon *party = &gPlayerParty[gSpecialVar_0x8004]; + gScriptResult = 0; + + if(GetMonData(party, MON_DATA_IS_EGG)) + gScriptResult = 1; +} diff --git a/src/secret_base.c b/src/secret_base.c new file mode 100644 index 000000000..d88d2c66a --- /dev/null +++ b/src/secret_base.c @@ -0,0 +1,1075 @@ +#include "global.h" +#include "secret_base.h" +#include "decoration.h" +#include "event_data.h" +#include "field_camera.h" +#include "field_fadetransition.h" +#include "field_player_avatar.h" +#include "field_weather.h" +#include "fieldmap.h" +#include "main.h" +#include "map_constants.h" +#include "map_name_popup.h" +#include "menu.h" +#include "metatile_behavior.h" +#include "palette.h" +#include "pokemon.h" +#include "rom4.h" +#include "script.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "text.h" +#include "vars.h" + +extern u8 gUnknown_020387DC; +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u16 gSpecialVar_0x8006; +extern u16 gSpecialVar_0x8007; +extern u16 gScriptResult; +extern const struct +{ + u16 unk_083D1358_0; + u16 unk_083D1358_1; +} gUnknown_083D1358[7]; +extern const u8 gUnknown_083D1374[4 * 16]; +extern void *gUnknown_0300485C; +extern const u8 gUnknown_083D13EC[12]; +extern u8 gUnknown_081A2E14[]; + + +void sub_80BB4AC(struct SecretBaseRecord *record) // 080bb4ac +{ + u16 i; + u16 j; + record->sbr_field_0 = 0; + for (i=0; i<7; i++) + record->sbr_field_2[i] = 0xff; + for (i=0; i<4; i++) + record->trainerId[i] = 0x00; + record->sbr_field_e = 0; + record->sbr_field_10 = 0; + record->sbr_field_11 = 0; + record->sbr_field_1_0 = 0; + record->gender = 0; + record->sbr_field_1_5 = 0; + record->sbr_field_1_6 = 0; + for (i=0; i<16; i++) { + record->decorations[i] = 0; + record->decorationPos[i] = 0; + } + for (i=0; i<6; i++) { + for (j=0; j<4; j++) { + record->partyMoves[i * 4 + j] = 0; + } + record->partyPersonality[i] = 0; + record->partyEVs[i] = 0; + record->partySpecies[i] = 0; + record->partyHeldItems[i] = 0; + record->partyLevels[i] = 0; + } +} + +void ResetSecretBase(u8 idx) // 80bb594 +{ + sub_80BB4AC(&(gSaveBlock1.secretBases[idx])); +} + +void ResetSecretBases(void) // 080bb5b4 +{ + u16 i; + for (i=0; i<20; i++) + ResetSecretBase(i); +} + +void sub_80BB5D0(void) // 080bb5d0 +{ + gUnknown_020387DC = gSpecialVar_0x8004; +} + +void sub_80BB5E4(void) // 80bb5e4 +{ + u16 idx; + gScriptResult = 0; + for (idx=0; idx<20; idx++) { + if (gUnknown_020387DC != gSaveBlock1.secretBases[idx].sbr_field_0) + continue; + gScriptResult = 1; + VarSet(VAR_0x4054, idx); + break; + } +} + +void sub_80BB63C(void) // 80bb63c +{ + if (gSaveBlock1.secretBases[0].sbr_field_0) + gScriptResult = 1; + else + gScriptResult = 0; +} + +u8 sub_80BB66C(void) // 80bb66c +{ + s16 x, y; + s16 v0; + GetXYCoordsOneStepInFrontOfPlayer(&x, &y); + v0 = MapGridGetMetatileBehaviorAt(x, y) & 0xFFF; + if (v0 == 0x90 || v0 == 0x91) + return 1; + else if (v0 == 0x92 || v0 == 0x93) + return 2; + else if (v0 == 0x9a || v0 == 0x9b) + return 3; + else if (v0 == 0x94 || v0 == 0x95) + return 4; + else if (v0 == 0x96 || v0 == 0x97 || v0 == 0x9c || v0 == 0x9d) + return 5; + else if (v0 == 0x98 || v0 == 0x99) + return 6; + return 0; +} + +void sub_80BB70C(void) // 80bb70c +{ + gSpecialVar_0x8007 = sub_80BB66C(); +} + +s16 unref_sub_80BB724(u16 *a0, u8 a1) +{ + u16 v2; + for (v2=0; v2<0x200; v2++) { + if ((a0[v2] & 0xFFF) == a1) + return (s16)v2; + } + return -1; +} + +void sub_80BB764(s16 *arg1, s16 *arg2, u16 arg3) +{ + s16 x, y; + for (y=0; y<gMapHeader.mapData->height; y++) { + for (x=0; x<gMapHeader.mapData->width; x++) { + if ((gMapHeader.mapData->map[y * gMapHeader.mapData->width + x] & 0x3ff) == arg3) { + *arg1 = x; + *arg2 = y; + return; + } + } + } +} + +void sub_80BB800(void) +{ + s16 x, y; + s16 tile_id; + u16 idx; + GetXYCoordsOneStepInFrontOfPlayer(&x, &y); + tile_id = MapGridGetMetatileIdAt(x, y); + for (idx=0; idx<7; idx++) { + if (gUnknown_083D1358[idx].unk_083D1358_0 == tile_id) { + MapGridSetMetatileIdAt(x, y, gUnknown_083D1358[idx].unk_083D1358_1 | 0xc00); + CurrentMapDrawMetatileAt(x, y); + return; + } + } + for (idx=0; idx<7; idx++) { + if (gUnknown_083D1358[idx].unk_083D1358_1 == tile_id) { + MapGridSetMetatileIdAt(x, y, gUnknown_083D1358[idx].unk_083D1358_0 | 0xc00); + CurrentMapDrawMetatileAt(x, y); + return; + } + } +} + +u8 sub_80BB8A8(u8 *arg1) +{ + u8 idx; + for (idx=0; idx<7; idx++) { + if (arg1[idx] == EOS) + return idx; + } + return 7; +} + +void sub_80BB8CC(void) +{ + u8 nameLength; + u16 idx; + gSaveBlock1.secretBases[0].sbr_field_0 = gUnknown_020387DC; + for (idx=0; idx<4; idx++) { + gSaveBlock1.secretBases[0].trainerId[idx] = gSaveBlock2.playerTrainerId[idx]; + } + VarSet(VAR_0x4054, 0); + nameLength = sub_80BB8A8(gSaveBlock2.playerName); + memset(gSaveBlock1.secretBases[0].sbr_field_2, 0xFF, 7); + StringCopyN(gSaveBlock1.secretBases[0].sbr_field_2, gSaveBlock2.playerName, nameLength); + gSaveBlock1.secretBases[0].gender = gSaveBlock2.playerGender; + VarSet(VAR_SECRET_BASE_MAP, gMapHeader.name); +} + +void sub_80BB970(struct MapEvents *events) +{ + u16 bgevidx, idx, jdx; + s16 tile_id; + for (bgevidx=0; bgevidx<events->bgEventCount; bgevidx++) { + if (events->bgEvents[bgevidx].kind == 8) { + for (jdx=0; jdx<20; jdx++) { + if (gSaveBlock1.secretBases[jdx].sbr_field_0 == events->bgEvents[bgevidx].bgUnion.secretBaseId) { + tile_id = MapGridGetMetatileIdAt(events->bgEvents[bgevidx].x + 7, events->bgEvents[bgevidx].y + 7); + for (idx=0; idx<7; idx++) { + if (gUnknown_083D1358[idx].unk_083D1358_0 == tile_id) { + MapGridSetMetatileIdAt(events->bgEvents[bgevidx].x + 7, events->bgEvents[bgevidx].y + 7, gUnknown_083D1358[idx].unk_083D1358_1 | 0xc00); + break; + } + } + break; + } + } + } + } +} + +void sub_80BBA14(void) +{ + s8 idx = 4 * (gUnknown_020387DC / 10); + warp1_set_2(MAP_GROUP_SECRET_BASE_RED_CAVE1, gUnknown_083D1374[idx], gUnknown_083D1374[idx + 1]); +} + +void sub_80BBA48(u8 taskid) +{ + u16 curbaseid; + switch (gTasks[taskid].data[0]) { + case 0: + gTasks[taskid].data[0] = 1; + break; + case 1: + if (!gPaletteFade.active) { + gTasks[taskid].data[0] = 2; + } + break; + case 2: + curbaseid = VarGet(VAR_0x4054); + if (gSaveBlock1.secretBases[curbaseid].sbr_field_10 < 0xff) + gSaveBlock1.secretBases[curbaseid].sbr_field_10 ++; + sub_80BBA14(); + warp_in(); + gFieldCallback = sub_8080990; + SetMainCallback2(CB2_LoadMap); + DestroyTask(taskid); + break; + } +} + +void sub_80BBAF0(void) +{ + CreateTask(sub_80BBA48, 0); + fade_screen(1, 0); + saved_warp2_set(0, gSaveBlock1.location.mapGroup, gSaveBlock1.location.mapNum, -1); +} + +bool8 sub_80BBB24(void) +{ + if (gMapHeader.mapType == 9 && VarGet(VAR_0x4097) == 0) + return FALSE; + return TRUE; +} + +void sub_80BBB50(u8 taskid) +{ + FieldObjectTurn(&(gMapObjects[gPlayerAvatar.mapObjectId]), 2); + if (sub_807D770() == 1) { + EnableBothScriptContexts(); + DestroyTask(taskid); + } +} + +void sub_80BBB90(void) +{ + s16 x, y; + ScriptContext2_Enable(); + HideMapNamePopup(); + sub_80BB764(&x, &y, 0x220); + MapGridSetMetatileIdAt(x + 7, y + 7, 0xe20); + CurrentMapDrawMetatileAt(x + 7, y + 7); + pal_fill_black(); + CreateTask(sub_80BBB50, 0); +} + +void sub_80BBBEC(u8 taskid) +{ + s8 idx; + if (!gPaletteFade.active) { + idx = 4 * (gUnknown_020387DC / 10); + warp1_set(gSaveBlock1.location.mapGroup, gSaveBlock1.location.mapNum, -1, gUnknown_083D1374[idx + 2], gUnknown_083D1374[idx + 3]); + warp_in(); + gFieldCallback = sub_80BBB90; + SetMainCallback2(CB2_LoadMap); + DestroyTask(taskid); + } +} + +void sub_80BBC78(void) +{ + u8 taskid = CreateTask(sub_80BBBEC, 0); + gTasks[taskid].data[0] = 0; + fade_screen(1, 0); +} + +bool8 CurrentMapIsSecretBase(void) +{ + if (gSaveBlock1.location.mapGroup == MAP_GROUP_SECRET_BASE_SHRUB4 && (u8)(gSaveBlock1.location.mapNum) <= MAP_ID_SECRET_BASE_SHRUB4) + return TRUE; + return FALSE; +} + +#ifdef NONMATCHING +void sub_80BBCCC(u8 flagIn) +{ + u16 curBaseId; + u16 x, y; + if (CurrentMapIsSecretBase()) { + curBaseId = VarGet(VAR_0x4054); + for (x=0; x<16; x++) { + if ((u8)(gSaveBlock1.secretBases[curBaseId].decorations[x] - 1) <= 0x77 && gDecorations[gSaveBlock1.secretBases[curBaseId].decorations[x]].decor_field_11 != 4) { + sub_80FF394((gSaveBlock1.secretBases[0].decorationPos[x] >> 4) + 7, (gSaveBlock1.secretBases[0].decorationPos[x] & 0xF) + 7, gSaveBlock1.secretBases[curBaseId].decorations[x]); + } + } + if (curBaseId != 0) { + sub_80BB764(&x, &y, 0x220); + MapGridSetMetatileIdAt(x + 7, y + 7, 0xe21); + } else if (flagIn == 1 && VarGet(VAR_0x4089) == 1) { + sub_80BB764(&x, &y, 0x220); + MapGridSetMetatileIdAt(x + 7, y + 7, 0xe0a); + } + } +} + +void sub_80BBDD0(void) +{ + u8 *roomdecor; + u8 *roomdecorpos; + u8 ndecor; + u8 decidx; + u8 objid = 0; + u8 metatile; + u16 curBase = VarGet(VAR_0x4054); + if (!CurrentMapIsSecretBase()) { + roomdecor = gSaveBlock1.playerRoomDecor; + roomdecorpos = gSaveBlock1.playerRoomDecorPos; + ndecor = 12; + } else { + roomdecor = gSaveBlock1.secretBases[curBase].decorations; + roomdecorpos = gSaveBlock1.secretBases[curBase].decorationPos; + ndecor = 16; + } + for (decidx=0; decidx<ndecor; decidx++) { + if (roomdecor[decidx] == 0) + continue; + if (gDecorations[roomdecor[decidx]].decor_field_11 != 4) + continue; + for (objid=0; objid<gMapHeader.events->mapObjectCount; objid++) { + if (gMapHeader.events->mapObjects[objid].flagId == gSpecialVar_0x8004 + 0xAE) + break; + } + if (objid != gMapHeader.events->mapObjectCount) { + gSpecialVar_0x8006 = roomdecorpos[decidx] >> 4; + gSpecialVar_0x8007 = roomdecorpos[decidx] & 0xF; + metatile = MapGridGetMetatileBehaviorAt(gSpecialVar_0x8006 + 7, gSpecialVar_0x8007 + 7); + if (sub_80572D8(metatile) == 1 || sub_80572EC(metatile) == 1) { + gScriptResult = gMapHeader.events->mapObjects[objid].graphicsId + 0x3f20; + VarSet(gScriptResult, gDecorations[roomdecor[decidx]].tiles[0]); + gScriptResult = gMapHeader.events->mapObjects[objid].localId; + FlagReset(gSpecialVar_0x8004 + 0xAE); + show_sprite(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup); + sub_805C0F8(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, gSpecialVar_0x8006, gSpecialVar_0x8007); + sub_805C78C(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup); + gSpecialVar_0x8004 ++; + } + } + } +} + +#else +__attribute__((naked)) +void sub_80BBCCC(u8 flagIn) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + sub sp, 0x4\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ + bl CurrentMapIsSecretBase\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080BBDBC\n\ + ldr r0, _080BBD70 @ =0x00004054\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + movs r1, 0\n\ + mov r0, sp\n\ + strh r1, [r0]\n\ + ldr r6, _080BBD74 @ =gSaveBlock1\n\ + mov r4, sp\n\ + ldr r0, _080BBD78 @ =0x00001a2a\n\ + adds r7, r6, r0\n\ +_080BBCFC:\n\ + lsls r0, r5, 2\n\ + adds r0, r5\n\ + lsls r0, 5\n\ + ldrh r1, [r4]\n\ + adds r2, r0, r1\n\ + ldr r1, _080BBD7C @ =0x00001a1a\n\ + adds r0, r6, r1\n\ + adds r1, r2, r0\n\ + ldrb r0, [r1]\n\ + subs r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x77\n\ + bhi _080BBD3A\n\ + ldr r0, _080BBD80 @ =gDecorations\n\ + ldrb r3, [r1]\n\ + lsls r1, r3, 5\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x11]\n\ + cmp r0, 0x4\n\ + beq _080BBD3A\n\ + adds r0, r2, r7\n\ + ldrb r2, [r0]\n\ + lsrs r0, r2, 4\n\ + adds r0, 0x7\n\ + movs r1, 0xF\n\ + ands r1, r2\n\ + adds r1, 0x7\n\ + adds r2, r3, 0\n\ + bl sub_80FF394\n\ +_080BBD3A:\n\ + ldrh r0, [r4]\n\ + adds r0, 0x1\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + strh r0, [r4]\n\ + cmp r0, 0xF\n\ + bls _080BBCFC\n\ + cmp r5, 0\n\ + beq _080BBD88\n\ + mov r4, sp\n\ + adds r4, 0x2\n\ + movs r2, 0x88\n\ + lsls r2, 2\n\ + mov r0, sp\n\ + adds r1, r4, 0\n\ + bl sub_80BB764\n\ + mov r0, sp\n\ + ldrh r0, [r0]\n\ + adds r0, 0x7\n\ + ldrh r1, [r4]\n\ + adds r1, 0x7\n\ + ldr r2, _080BBD84 @ =0x00000e21\n\ + bl MapGridSetMetatileIdAt\n\ + b _080BBDBC\n\ + .align 2, 0\n\ +_080BBD70: .4byte 0x00004054\n\ +_080BBD74: .4byte gSaveBlock1\n\ +_080BBD78: .4byte 0x00001a2a\n\ +_080BBD7C: .4byte 0x00001a1a\n\ +_080BBD80: .4byte gDecorations\n\ +_080BBD84: .4byte 0x00000e21\n\ +_080BBD88:\n\ + mov r0, r8\n\ + cmp r0, 0x1\n\ + bne _080BBDBC\n\ + ldr r0, _080BBDC8 @ =0x00004089\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r0, 0x1\n\ + bne _080BBDBC\n\ + mov r4, sp\n\ + adds r4, 0x2\n\ + movs r2, 0x88\n\ + lsls r2, 2\n\ + mov r0, sp\n\ + adds r1, r4, 0\n\ + bl sub_80BB764\n\ + mov r0, sp\n\ + ldrh r0, [r0]\n\ + adds r0, 0x7\n\ + ldrh r1, [r4]\n\ + adds r1, 0x7\n\ + ldr r2, _080BBDCC @ =0x00000e0a\n\ + bl MapGridSetMetatileIdAt\n\ +_080BBDBC:\n\ + add sp, 0x4\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_080BBDC8: .4byte 0x00004089\n\ +_080BBDCC: .4byte 0x00000e0a\n\ +.syntax divided\n"); +} + +__attribute__((naked)) +void sub_80BBDD0(void) +{ + 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, 0x14\n\ + ldr r0, _080BBE00 @ =0x00004054\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + bl CurrentMapIsSecretBase\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _080BBE08\n\ + ldr r0, _080BBE04 @ =gSaveBlock1 + 0x2688\n\ + str r0, [sp, 0x4]\n\ + adds r0, 0xC\n\ + str r0, [sp, 0x8]\n\ + movs r1, 0xC\n\ + str r1, [sp, 0xC]\n\ + b _080BBE1E\n\ + .align 2, 0\n\ +_080BBE00: .4byte 0x00004054\n\ +_080BBE04: .4byte gSaveBlock1 + 0x2688\n\ +_080BBE08:\n\ + lsls r1, r4, 2\n\ + adds r1, r4\n\ + lsls r1, 5\n\ + ldr r0, _080BBF7C @ =gSaveBlock1 + 0x1A1A\n\ + adds r2, r1, r0\n\ + str r2, [sp, 0x4]\n\ + adds r0, 0x10\n\ + adds r1, r0\n\ + str r1, [sp, 0x8]\n\ + movs r3, 0x10\n\ + str r3, [sp, 0xC]\n\ +_080BBE1E:\n\ + movs r6, 0\n\ + ldr r4, [sp, 0xC]\n\ + cmp r6, r4\n\ + bcc _080BBE28\n\ + b _080BBF6C\n\ +_080BBE28:\n\ + ldr r5, _080BBF80 @ =gSaveBlock1\n\ + mov r10, r5\n\ +_080BBE2C:\n\ + ldr r1, [sp, 0x4]\n\ + adds r0, r1, r6\n\ + ldrb r1, [r0]\n\ + mov r9, r0\n\ + adds r2, r6, 0x1\n\ + str r2, [sp, 0x10]\n\ + cmp r1, 0\n\ + bne _080BBE3E\n\ + b _080BBF5E\n\ +_080BBE3E:\n\ + ldrb r0, [r0]\n\ + lsls r0, 5\n\ + ldr r3, _080BBF84 @ =gDecorations\n\ + adds r0, r3\n\ + ldrb r0, [r0, 0x11]\n\ + cmp r0, 0x4\n\ + beq _080BBE4E\n\ + b _080BBF5E\n\ +_080BBE4E:\n\ + movs r5, 0\n\ + ldr r0, _080BBF88 @ =gMapHeader\n\ + ldr r2, [r0, 0x4]\n\ + ldrb r3, [r2]\n\ + mov r8, r0\n\ + cmp r5, r3\n\ + bcs _080BBE8E\n\ + ldr r0, [r2, 0x4]\n\ + ldrh r1, [r0, 0x14]\n\ + ldr r4, _080BBF8C @ =gSpecialVar_0x8004\n\ + ldrh r0, [r4]\n\ + adds r0, 0xAE\n\ + adds r7, r4, 0\n\ + cmp r1, r0\n\ + beq _080BBE8E\n\ + adds r4, r2, 0\n\ + adds r2, r3, 0\n\ +_080BBE70:\n\ + adds r0, r5, 0x1\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + cmp r5, r2\n\ + bcs _080BBE8E\n\ + ldr r1, [r4, 0x4]\n\ + lsls r0, r5, 1\n\ + adds r0, r5\n\ + lsls r0, 3\n\ + adds r0, r1\n\ + ldrh r1, [r0, 0x14]\n\ + ldrh r0, [r7]\n\ + adds r0, 0xAE\n\ + cmp r1, r0\n\ + bne _080BBE70\n\ +_080BBE8E:\n\ + mov r1, r8\n\ + ldr r0, [r1, 0x4]\n\ + ldrb r0, [r0]\n\ + cmp r5, r0\n\ + beq _080BBF5E\n\ + ldr r7, _080BBF90 @ =gSpecialVar_0x8006\n\ + ldr r2, [sp, 0x8]\n\ + adds r1, r2, r6\n\ + ldrb r0, [r1]\n\ + lsrs r0, 4\n\ + strh r0, [r7]\n\ + ldr r6, _080BBF94 @ =gSpecialVar_0x8007\n\ + ldrb r1, [r1]\n\ + movs r0, 0xF\n\ + ands r0, r1\n\ + strh r0, [r6]\n\ + ldrh r0, [r7]\n\ + adds r0, 0x7\n\ + ldrh r1, [r6]\n\ + adds r1, 0x7\n\ + bl MapGridGetMetatileBehaviorAt\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + adds r0, r4, 0\n\ + bl sub_80572D8\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + beq _080BBEDA\n\ + adds r0, r4, 0\n\ + bl sub_80572EC\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + bne _080BBF5E\n\ +_080BBEDA:\n\ + mov r3, r8\n\ + ldr r0, [r3, 0x4]\n\ + ldr r1, [r0, 0x4]\n\ + lsls r4, r5, 1\n\ + adds r4, r5\n\ + lsls r4, 3\n\ + adds r1, r4, r1\n\ + ldr r5, _080BBF98 @ =0x00003f20\n\ + adds r0, r5, 0\n\ + ldrb r1, [r1, 0x1]\n\ + adds r0, r1\n\ + ldr r1, _080BBF9C @ =gScriptResult\n\ + strh r0, [r1]\n\ + ldrh r0, [r1]\n\ + mov r2, r9\n\ + ldrb r1, [r2]\n\ + lsls r1, 5\n\ + ldr r3, _080BBFA0 @ =gDecorations + 0x1C\n\ + adds r1, r3\n\ + ldr r1, [r1]\n\ + ldrh r1, [r1]\n\ + bl VarSet\n\ + mov r5, r8\n\ + ldr r0, [r5, 0x4]\n\ + ldr r0, [r0, 0x4]\n\ + adds r4, r0\n\ + ldrb r0, [r4]\n\ + ldr r1, _080BBF9C @ =gScriptResult\n\ + strh r0, [r1]\n\ + ldr r2, _080BBF8C @ =gSpecialVar_0x8004\n\ + ldrh r0, [r2]\n\ + adds r0, 0xAE\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + bl FlagReset\n\ + ldr r3, _080BBF9C @ =gScriptResult\n\ + ldrb r0, [r3]\n\ + mov r4, r10\n\ + ldrb r1, [r4, 0x5]\n\ + ldrb r2, [r4, 0x4]\n\ + bl show_sprite\n\ + ldr r5, _080BBF9C @ =gScriptResult\n\ + ldrb r0, [r5]\n\ + ldrb r1, [r4, 0x5]\n\ + ldrb r2, [r4, 0x4]\n\ + movs r4, 0\n\ + ldrsh r3, [r7, r4]\n\ + movs r5, 0\n\ + ldrsh r4, [r6, r5]\n\ + str r4, [sp]\n\ + bl sub_805C0F8\n\ + ldr r1, _080BBF9C @ =gScriptResult\n\ + ldrb r0, [r1]\n\ + mov r2, r10\n\ + ldrb r1, [r2, 0x5]\n\ + ldrb r2, [r2, 0x4]\n\ + bl sub_805C78C\n\ + ldr r3, _080BBF8C @ =gSpecialVar_0x8004\n\ + ldrh r0, [r3]\n\ + adds r0, 0x1\n\ + strh r0, [r3]\n\ +_080BBF5E:\n\ + ldr r4, [sp, 0x10]\n\ + lsls r0, r4, 24\n\ + lsrs r6, r0, 24\n\ + ldr r5, [sp, 0xC]\n\ + cmp r6, r5\n\ + bcs _080BBF6C\n\ + b _080BBE2C\n\ +_080BBF6C:\n\ + add sp, 0x14\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\ + .align 2, 0\n\ +_080BBF7C: .4byte gSaveBlock1 + 0x1A1A\n\ +_080BBF80: .4byte gSaveBlock1\n\ +_080BBF84: .4byte gDecorations\n\ +_080BBF88: .4byte gMapHeader\n\ +_080BBF8C: .4byte gSpecialVar_0x8004\n\ +_080BBF90: .4byte gSpecialVar_0x8006\n\ +_080BBF94: .4byte gSpecialVar_0x8007\n\ +_080BBF98: .4byte 0x00003f20\n\ +_080BBF9C: .4byte gScriptResult\n\ +_080BBFA0: .4byte gDecorations + 0x1C\n\ +.syntax divided\n"); +} +#endif + +void sub_80BBFA4(void) +{ + int curBase = VarGet(VAR_0x4054); + VarSet(VAR_0x401F, gUnknown_083D13EC[sub_80BCCA4(curBase)]); +} + +void sub_80BBFD8(s16 *position, struct MapEvents *events) +{ + s16 bgevtidx; + for (bgevtidx=0; bgevtidx<events->bgEventCount; bgevtidx++) { + if (events->bgEvents[bgevtidx].kind == 8 && position[0] == events->bgEvents[bgevtidx].x + 7 && position[1] == events->bgEvents[bgevtidx].y + 7) { + gUnknown_020387DC = events->bgEvents[bgevtidx].bgUnion.secretBaseId; + break; + } + } +} + +void sub_80BC038(s16 *position, struct MapEvents *events) +{ + sub_80BBFD8(position, events); + sub_80BB5E4(); + ScriptContext1_SetupScript(gUnknown_081A2E14); +} + +bool8 sub_80BC050(void) +{ + sub_80BB5D0(); + sub_80BB5E4(); + if (gScriptResult == 1) + return FALSE; + return TRUE; +} + +void sub_80BC074(u8 taskid) +{ + switch (gTasks[taskid].data[0]) { + case 0: + ScriptContext2_Enable(); + gTasks[taskid].data[0] = 1; + break; + case 1: + if (!gPaletteFade.active) { + gTasks[taskid].data[0] = 2; + } + break; + case 2: + copy_saved_warp2_bank_and_enter_x_to_warp1(0x7E); + warp_in(); + gFieldCallback = mapldr_default; + SetMainCallback2(CB2_LoadMap); + ScriptContext2_Disable(); + DestroyTask(taskid); + break; + } +} + +void sub_80BC0F8(void) { + CreateTask(sub_80BC074, 0); + fade_screen(1, 0); +} + +void sub_80BC114(void) { + if (gSaveBlock1.secretBases[0].sbr_field_0 != gUnknown_020387DC) + gScriptResult = 1; + else + gScriptResult = 0; +} + +u8 sub_80BC14C(u8 sbid) +{ + s16 idx; + for (idx=0; idx<20; idx++) { + if (gSaveBlock1.secretBases[idx].sbr_field_0 == sbid) + return idx; + } + return 0; +} + +u8 *sub_80BC190(u8 *dest, u8 arg1) { // 80bc190 + u8 local1; + u8 *str; + + local1 = sub_80BB8A8(gSaveBlock1.secretBases[arg1].sbr_field_2); + + str = StringCopyN(dest, gSaveBlock1.secretBases[arg1].sbr_field_2, local1); + str[0] = EOS; + +#if ENGLISH + return StringAppend(dest, gOtherText_PlayersBase); +#elif GERMAN + return de_sub_8073174(dest, gOtherText_PlayersBase); +#endif +} + +u8 *GetSecretBaseMapName(u8 *dest) { + gUnknown_020387DC = gSaveBlock1.secretBases[VarGet(VAR_0x4054)].sbr_field_0; + return sub_80BC190(dest, VarGet(VAR_0x4054)); +} + +void sub_80BC224(void) { + u8 *var0 = gSaveBlock1.secretBases[(u8)VarGet(VAR_0x4054)].sbr_field_2; + u8 *var1 = gStringVar1; + u8 var2 = sub_80BB8A8(var0); + u8 *var3 = StringCopyN(var1, var0, var2); + *var3 = EOS; +} + +u8 sub_80BC268(u8 foo) { // 80bc268 + if (gSaveBlock1.secretBases[foo].sbr_field_1_6) + return 1; + return 0; +} + +u8 sub_80BC298(struct Pokemon *mon) { // 80bc298 + u16 evsum = GetMonData(mon, MON_DATA_HP_EV); + evsum += GetMonData(mon, MON_DATA_ATK_EV); + evsum += GetMonData(mon, MON_DATA_DEF_EV); + evsum += GetMonData(mon, MON_DATA_SPD_EV); + evsum += GetMonData(mon, MON_DATA_SPATK_EV); + evsum += GetMonData(mon, MON_DATA_SPDEF_EV); + return (u8)(evsum / 6); +} + +#ifdef NONMATCHING +void sub_80BC300(void) +{ + u16 moveidx; + u16 sbpartyidx = 0; + int resetVal = 0; + u16 partyidx = 0; + while (partyidx < 6) { + partyidx ++; + for (moveidx=0; moveidx<4; moveidx++) { + gSaveBlock1.secretBases[0].partyMoves[(partyidx - 1) * 6 + moveidx] = resetVal; + } + gSaveBlock1.secretBases[0].partySpecies[partyidx - 1] = resetVal; + gSaveBlock1.secretBases[0].partyHeldItems[partyidx - 1] = resetVal; + gSaveBlock1.secretBases[0].partyLevels[partyidx - 1] = resetVal; + gSaveBlock1.secretBases[0].partyPersonality[partyidx - 1] = resetVal; + gSaveBlock1.secretBases[0].partyEVs[partyidx - 1] = resetVal; + if (GetMonData(&(gPlayerParty[partyidx - 1]), MON_DATA_SPECIES) != 0 && !GetMonData(&(gPlayerParty[partyidx - 1]), MON_DATA_IS_EGG)) { + sbpartyidx ++; + for (moveidx=0; moveidx<4; moveidx++) { + gSaveBlock1.secretBases[0].partyMoves[(sbpartyidx - 1) * 6 + moveidx] = GetMonData(&(gPlayerParty[partyidx - 1]), MON_DATA_MOVE1 + moveidx); + } + gSaveBlock1.secretBases[0].partySpecies[sbpartyidx - 1] = GetMonData(&(gPlayerParty[partyidx - 1]), MON_DATA_SPECIES); + gSaveBlock1.secretBases[0].partyHeldItems[sbpartyidx - 1] = GetMonData(&(gPlayerParty[partyidx - 1]), MON_DATA_HELD_ITEM); + gSaveBlock1.secretBases[0].partyLevels[sbpartyidx - 1] = GetMonData(&(gPlayerParty[partyidx - 1]), MON_DATA_LEVEL); + gSaveBlock1.secretBases[0].partyPersonality[sbpartyidx - 1] = GetMonData(&(gPlayerParty[partyidx - 1]), MON_DATA_PERSONALITY); + gSaveBlock1.secretBases[0].partyEVs[sbpartyidx - 1] = sub_80BC298(&(gPlayerParty[partyidx - 1])); + } + } +} +#else +__attribute__((naked)) +void sub_80BC300(void) +{ + 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, 0xC\n\ + movs r0, 0\n\ + mov r10, r0\n\ + movs r6, 0\n\ + mov r9, r6\n\ +_080BC314:\n\ + movs r4, 0\n\ + lsls r3, r6, 2\n\ + lsls r2, r6, 1\n\ + ldr r7, _080BC424 @ =gPlayerParty\n\ + adds r1, r6, 0x1\n\ + str r1, [sp]\n\ + adds r1, r3, 0\n\ +_080BC322:\n\ + adds r0, r1, r4\n\ + lsls r0, 1\n\ + ldr r5, _080BC428 @ =gSaveBlock1 + 0x1A54\n\ + adds r0, r5, r0\n\ + mov r5, r9\n\ + strh r5, [r0]\n\ + adds r0, r4, 0x1\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + cmp r4, 0x3\n\ + bls _080BC322\n\ + ldr r1, _080BC42C @ =gSaveBlock1 + 0x1A84\n\ + adds r0, r1, r2\n\ + strh r5, [r0]\n\ + ldr r5, _080BC430 @ =gSaveBlock1 + 0x1A90\n\ + adds r0, r5, r2\n\ + mov r1, r9\n\ + strh r1, [r0]\n\ + ldr r2, _080BC434 @ =gSaveBlock1 + 0x1A9C\n\ + adds r0, r2, r6\n\ + mov r5, r9\n\ + strb r5, [r0]\n\ + ldr r1, _080BC438 @ =gSaveBlock1 + 0x1A3C\n\ + adds r0, r1, r3\n\ + mov r2, r9\n\ + str r2, [r0]\n\ + ldr r3, _080BC43C @ =gSaveBlock1 + 0x1AA2\n\ + adds r0, r3, r6\n\ + strb r2, [r0]\n\ + movs r0, 0x64\n\ + adds r5, r6, 0\n\ + muls r5, r0\n\ + adds r4, r5, r7\n\ + adds r0, r4, 0\n\ + movs r1, 0xB\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + beq _080BC408\n\ + adds r0, r4, 0\n\ + movs r1, 0x2D\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + bne _080BC408\n\ + movs r4, 0\n\ + mov r0, r10\n\ + lsls r0, 2\n\ + mov r8, r0\n\ + mov r1, r10\n\ + lsls r7, r1, 1\n\ + adds r1, 0x1\n\ + str r1, [sp, 0x4]\n\ + ldr r2, _080BC424 @ =gPlayerParty\n\ +_080BC38E:\n\ + adds r1, r4, 0\n\ + adds r1, 0xD\n\ + adds r0, r5, r2\n\ + str r2, [sp, 0x8]\n\ + bl GetMonData\n\ + mov r3, r8\n\ + adds r1, r3, r4\n\ + lsls r1, 1\n\ + ldr r3, _080BC428 @ =gSaveBlock1 + 0x1A54\n\ + adds r1, r3, r1\n\ + strh r0, [r1]\n\ + adds r0, r4, 0x1\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + ldr r2, [sp, 0x8]\n\ + cmp r4, 0x3\n\ + bls _080BC38E\n\ + movs r0, 0x64\n\ + adds r4, r6, 0\n\ + muls r4, r0\n\ + ldr r0, _080BC424 @ =gPlayerParty\n\ + adds r4, r0\n\ + adds r0, r4, 0\n\ + movs r1, 0xB\n\ + bl GetMonData\n\ + ldr r5, _080BC42C @ =gSaveBlock1 + 0x1A84\n\ + adds r1, r5, r7\n\ + strh r0, [r1]\n\ + adds r0, r4, 0\n\ + movs r1, 0xC\n\ + bl GetMonData\n\ + ldr r2, _080BC430 @ =gSaveBlock1 + 0x1A90\n\ + adds r1, r2, r7\n\ + strh r0, [r1]\n\ + adds r0, r4, 0\n\ + movs r1, 0x38\n\ + bl GetMonData\n\ + ldr r1, _080BC434 @ =gSaveBlock1 + 0x1A9C\n\ + add r1, r10\n\ + strb r0, [r1]\n\ + adds r0, r4, 0\n\ + movs r1, 0\n\ + bl GetMonData\n\ + ldr r1, _080BC438 @ =gSaveBlock1 + 0x1A3C\n\ + add r1, r8\n\ + str r0, [r1]\n\ + adds r0, r4, 0\n\ + bl sub_80BC298\n\ + ldr r1, _080BC43C @ =gSaveBlock1 + 0x1AA2\n\ + add r1, r10\n\ + strb r0, [r1]\n\ + ldr r3, [sp, 0x4]\n\ + lsls r0, r3, 16\n\ + lsrs r0, 16\n\ + mov r10, r0\n\ +_080BC408:\n\ + ldr r5, [sp]\n\ + lsls r0, r5, 16\n\ + lsrs r6, r0, 16\n\ + cmp r6, 0x5\n\ + bls _080BC314\n\ + add sp, 0xC\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\ + .align 2, 0\n\ +_080BC424: .4byte gPlayerParty\n\ +_080BC428: .4byte gSaveBlock1 + 0x1A54\n\ +_080BC42C: .4byte gSaveBlock1 + 0x1A84\n\ +_080BC430: .4byte gSaveBlock1 + 0x1A90\n\ +_080BC434: .4byte gSaveBlock1 + 0x1A9C\n\ +_080BC438: .4byte gSaveBlock1 + 0x1A3C\n\ +_080BC43C: .4byte gSaveBlock1 + 0x1AA2\n\ +.syntax divided\n"); +} +#endif + +void sub_80BC440(void) +{ + u16 backupValue = gSaveBlock1.secretBases[0].sbr_field_e; + ResetSecretBase(0); + gSaveBlock1.secretBases[0].sbr_field_e = backupValue; + sub_80BC0F8(); +} + +void SecretBasePC_PackUp(void) +{ + IncrementGameStat(20); + sub_80BC440(); +} diff --git a/src/shop.c b/src/shop.c new file mode 100644 index 000000000..d53646a88 --- /dev/null +++ b/src/shop.c @@ -0,0 +1,342 @@ +#include "global.h" +#include "shop.h" +#include "decompress.h" +#include "field_fadetransition.h" +#include "field_weather.h" +#include "item_menu.h" +#include "main.h" +#include "menu.h" +#include "menu_helpers.h" +#include "money.h" +#include "palette.h" +#include "script.h" +#include "sound.h" +#include "sprite.h" +#include "strings.h" +#include "task.h" +#include "tv.h" +#include "unknown_task.h" + +struct UnknownShopStruct +{ + /* 0x0 */ void (* callback) (void); + /* 0x4 */ u16 *itemList; + /* 0x8 */ u8 itemCount; + /* 0x9 */ u8 unk9; + /* 0xA */ u8 unkA; + /* 0xB */ u8 unkB; + /* 0xC */ bool8 unkC; + // unknown size +}; + +extern struct UnknownShopStruct gUnknown_03000708; +extern struct MenuAction gUnknown_083CC6D0[]; + +extern u8 gUnknown_083CC6E8[]; +extern u8 gUnknown_083CC6EB[]; +extern u8 gBuyMenuFrame_Gfx[]; + +extern u16 gBuyMenuFrame_Tilemap[]; +extern u16 gMenuMoneyPal[16]; +extern u16 gUnknown_083CC710[2]; + +u8 CreateShopMenu(bool8 var) +{ + ScriptContext2_Enable(); + gUnknown_03000708.unkC = var; + gUnknown_03000708.unk9 = 0; + + if(var == FALSE) + { + gUnknown_03000708.unkA = 2; + MenuDrawTextWindow(0, 0, 10, 7); + PrintMenuItemsReordered(1, 1, 3, gUnknown_083CC6D0, (u8 *)gUnknown_083CC6E8); + } + else + { + gUnknown_03000708.unkA = 1; + MenuDrawTextWindow(0, 0, 10, 5); + PrintMenuItemsReordered(1, 1, 2, gUnknown_083CC6D0, (u8 *)gUnknown_083CC6EB); + } + InitMenu(0, 1, 1, gUnknown_03000708.unkA + 1, 0, 9); + + return CreateTask(sub_80B2E38, 8); +} + +void SetShopMenuCallback(void *callbackPtr) +{ + gUnknown_03000708.callback = callbackPtr; +} + +void SetShopItemsForSale(u16 *items) +{ + u16 i = 0; + + gUnknown_03000708.itemList = items; + gUnknown_03000708.itemCount = 0; + + while (gUnknown_03000708.itemList[i]) + { + gUnknown_03000708.itemCount++; + i++; + } +} + +void sub_80B2E38(u8 var) +{ + const u8 local = var; + + if(gMain.newAndRepeatedKeys & 0x40) + { + if(gUnknown_03000708.unk9) + { + PlaySE(0x5); + gUnknown_03000708.unk9 = MoveMenuCursor(-1); + } + } + else if(gMain.newAndRepeatedKeys & 0x80) + { + if(gUnknown_03000708.unk9 != gUnknown_03000708.unkA) + { + PlaySE(0x5); + gUnknown_03000708.unk9 = MoveMenuCursor(1); + } + } + else if (gMain.newKeys & 1) + { + PlaySE(0x5); + if(!gUnknown_03000708.unkC) + { + gUnknown_083CC6D0[gUnknown_083CC6E8[gUnknown_03000708.unk9]].func(local); + } + else + { + gUnknown_083CC6D0[gUnknown_083CC6EB[gUnknown_03000708.unk9]].func(local); + } + } + else if(gMain.newKeys & 2) + { + PlaySE(0x5); + HandleShopMenuQuit(local); + } +} + +void sub_80B2EFC(u8 taskId) +{ + gTasks[taskId].data[8] = (u32)BuyMenuDrawGraphics >> 16; + gTasks[taskId].data[9] = (u32)BuyMenuDrawGraphics; + gTasks[taskId].func = sub_80B2FA0; + fade_screen(1, 0); +} + +void sub_80B2F30(u8 taskId) +{ + gTasks[taskId].data[8] = (u32)sub_80A6300 >> 16; + gTasks[taskId].data[9] = (u32)sub_80A6300; + gTasks[taskId].func = sub_80B2FA0; + fade_screen(1, 0); +} + +void HandleShopMenuQuit(u8 taskId) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 11, 8); + sub_80BE3BC(); // in tv.s? + ScriptContext2_Disable(); + DestroyTask(taskId); + + if(gUnknown_03000708.callback) + gUnknown_03000708.callback(); // run the callback if it exists. +} + +void sub_80B2FA0(u8 taskId) +{ + if(!gPaletteFade.active) + { + SetMainCallback2((void *)((u16)gTasks[taskId].data[8] << 16 | (u16)gTasks[taskId].data[9])); + DestroyTask(taskId); + } +} + +void ReturnToShopMenuAfterExitingSellMenu(u8 taskId) +{ + CreateShopMenu(gUnknown_03000708.unkC); + DestroyTask(taskId); +} + +void Task_ExitSellMenu(u8 taskId) +{ + if(sub_807D770() == 1) + { + if(gUnknown_03000708.unkC == 2) + DisplayItemMessageOnField(taskId, gOtherText_CanIHelpYou, ReturnToShopMenuAfterExitingSellMenu, 0); + else + DisplayItemMessageOnField(taskId, gOtherText_AnythingElse, ReturnToShopMenuAfterExitingSellMenu, 0); + } +} + +void sub_80B3050(void) +{ + pal_fill_black(); + CreateTask(Task_ExitSellMenu, 0x8); +} + +void sub_80B3068(u8 taskId) +{ + Task_ExitSellMenu(taskId); +} + +void unref_sub_80B3078(u8 taskId) +{ + gTasks[taskId].func = Task_ExitSellMenu; +} + +void sub_80B3094(void) +{ + AnimateSprites(); + BuildOamBuffer(); + RunTasks(); + UpdatePaletteFade(); +} + +void sub_80B30AC(void) +{ + void *addr; + void *addr2; + void *addr3; + u16 *tempArr; + u16 *tempArr2; + u16 *tempArr3; + + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); + + // temp vars needed to match for some dumb reason + tempArr = gBGTilemapBuffers[1]; + addr = (void *)(VRAM + 0xE800); + DmaCopy16(3, tempArr, addr, 0x800); + tempArr2 = gBGTilemapBuffers[2]; + addr2 = (void *)(VRAM + 0xE000); + DmaCopy16(3, tempArr2, addr2, 0x800); + tempArr3 = gBGTilemapBuffers[3]; + addr3 = (void *)(VRAM + 0xF000); + DmaCopy16(3, tempArr3, addr3, 0x800); +} + +// this function is fugly. pls fix +void BuyMenuDrawGraphics(void) +{ + void *addr; + register u16 zero2 asm("r5"); + + sub_80F9438(); + remove_some_task(); + REG_BG1HOFS = (zero2 = 0); + REG_BG1VOFS = zero2; + REG_BG2HOFS = zero2; + REG_BG2VOFS = zero2; + REG_BG3HOFS = zero2; + REG_BG3VOFS = zero2; + gPaletteFade.bufferTransferDisabled = 1; + addr = (void*)OAM; + { + register const u32 zero asm("r6") = 0; + DmaFill32(3, zero, addr, OAM_SIZE); + LZDecompressVram(gBuyMenuFrame_Gfx, (void*)(VRAM + 0x7C00)); + sub_800D238(gBuyMenuFrame_Tilemap, (void *)0x02018000); + LoadCompressedPalette(gMenuMoneyPal, 0xC0, sizeof(gMenuMoneyPal)); + FreeAllSpritePalettes(); + ResetPaletteFade(); + ResetSpriteData(); + ResetTasks(); + SetUpWindowConfig(&gWindowConfig_81E6DFC); + InitMenuWindow(&gWindowConfig_81E6DFC); + BuyMenuDrawMapGraphics(); + gUnknown_03000708.unk9 = zero; + gUnknown_03000708.unkB = zero2; + MenuZeroFillWindowRect(0, 0, 0x20, 0x20); + sub_80B7C14(gSaveBlock1.money, 0, 0); + sub_80B3764(0, 7); + sub_80B37EC(); + sub_80B3270(); + CreateTask(sub_80B40E8, 0x8); + sub_80B3240(); + asm("":::"r4"); // what?? + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, zero); + gPaletteFade.bufferTransferDisabled = 0; + SetVBlankCallback(sub_80B30AC); + SetMainCallback2(sub_80B3094); + } +} + +void sub_80B3240(void) +{ + u16 tempArr[2]; + + memcpy(tempArr, gUnknown_083CC710, sizeof(tempArr)); + LoadPalette(&tempArr[1], 0xD1, 2); + LoadPalette(&tempArr[0], 0xD8, 2); +} + +void sub_80B3270(void) +{ + sub_80F944C(); + + if(gUnknown_03000708.itemCount > 7) + { + CreateVerticalScrollIndicators(0, 172, 12); + CreateVerticalScrollIndicators(1, 172, 148); + sub_80F979C(0, 1); + } +} + +void sub_80B32A4(void) +{ + if(gUnknown_03000708.unkB == 0) + sub_80F979C(0, 1); + else + sub_80F979C(0, 0); + + if(gUnknown_03000708.unkB + 7 >= gUnknown_03000708.itemCount) + sub_80F979C(1, 1); + else + sub_80F979C(1, 0); +} + +void sub_80B32EC(u16 *array, s16 offset1, s16 offset2) +{ + array[offset1 + offset2] = 0xC3E1; + array[offset1 + offset2 + 1] = 0xC3E1; +} + +void BuyMenuDrawMapMetatileLayer(u16 *array, s16 offset1, s16 offset2, u16 *array2) +{ + array[offset1 + offset2] = array2[0]; + array[offset1 + offset2 + 1] = array2[1]; + array[offset1 + offset2 + 32] = array2[2]; + array[offset1 + offset2 + 33] = array2[3]; +} + +void BuyMenuDrawMapMetatile(int var1, int var2, u16 *var3, s8 var4) +{ + u8 tempVar4 = var4; + s16 offset1 = var1 * 2; + s16 offset2 = (var2 * 0x40) + 0x40; + + switch(tempVar4) + { + case 0: // _080B335C + BuyMenuDrawMapMetatileLayer(gBGTilemapBuffers[2], offset1, offset2, var3); + BuyMenuDrawMapMetatileLayer(gBGTilemapBuffers[1], offset1, offset2, var3 + 4); + break; + case 1: // _080B3364 + BuyMenuDrawMapMetatileLayer(gBGTilemapBuffers[3], offset1, offset2, var3); + BuyMenuDrawMapMetatileLayer(gBGTilemapBuffers[2], offset1, offset2, var3 + 4); + break; + case 2: // _080B3398 + BuyMenuDrawMapMetatileLayer(gBGTilemapBuffers[3], offset1, offset2, var3); + BuyMenuDrawMapMetatileLayer(gBGTilemapBuffers[1], offset1, offset2, var3 + 4); + break; + } +} diff --git a/src/slot_machine.c b/src/slot_machine.c new file mode 100644 index 000000000..c9a06a758 --- /dev/null +++ b/src/slot_machine.c @@ -0,0 +1,150 @@ +#include "global.h" +#include "slot_machine.h" +#include "decompress.h" +#include "palette.h" +#include "task.h" + +struct UnkStruct2000000 { + /*0x00*/ u8 filler00[61]; + /*0x3D*/ u8 unk3D; +}; + +struct UnkStruct1 { + /*0x00*/ u8 unk00; + /*0x01*/ u8 unk01; + /*0x02*/ s16 unk02; +}; + +extern struct UnkStruct2000000 unk_2000000; + +extern struct UnkStruct1 *gUnknown_083ED048[]; +extern const u16 gPalette_83EDE24[]; + +extern const u8 gSlotMachine_Gfx[]; +#if ENGLISH +#define SLOTMACHINE_GFX_TILES 233 +#elif GERMAN +#define SLOTMACHINE_GFX_TILES 236 +#endif + +extern const u16 gUnknown_08E95A18[]; + +extern u16 gUnknown_08E95AB8[]; +extern u16 gUnknown_08E95FB8[]; + +static void LoadSlotMachineWheelOverlay(void); + +void sub_8104CAC(u8 arg0) { + u8 i; + struct Task *task; + + sub_8104DA4(); + + task = &gTasks[unk_2000000.unk3D]; + task->data[1] = arg0; + + i = 0; + while (gUnknown_083ED048[arg0][i].unk00 != 0xFF) + { + u8 spriteId; + spriteId = sub_8105BB4( + gUnknown_083ED048[arg0][i].unk00, + gUnknown_083ED048[arg0][i].unk01, + gUnknown_083ED048[arg0][i].unk02 + ); + task->data[4 + i] = spriteId; + +#ifdef GERMAN + if (arg0 == 5 && i <= 2) + { + gSprites[spriteId].invisible = TRUE; + } +#endif + + i += 1; + } +} + +asm(".section .text_b"); + +void sub_8106448(void) { + u32 offsetRead, offsetWrite; + u32 size; + + sub_800D238(gSlotMachine_Gfx, (void *) 0x02010000); + + offsetRead = 0x02010000; + offsetWrite = BG_VRAM; + size = SLOTMACHINE_GFX_TILES * 32; + while (TRUE) + { + DmaCopy16(3, offsetRead, (void *) (offsetWrite), 0x1000); + offsetRead += 0x1000; + offsetWrite += 0x1000; + size -= 0x1000; + if (size <= 0x1000) + { + DmaCopy16(3, offsetRead, (void *) (offsetWrite), size); + break; + } + } + + LoadPalette(gUnknown_08E95A18, 0, 160); + LoadPalette(gPalette_83EDE24, 208, 32); +} + +void sub_81064B8(void) { + CpuCopy16(gUnknown_08E95AB8, (void *) BG_SCREEN_ADDR(29), 20 * 32 * 2); + LoadSlotMachineWheelOverlay(); +} + +static void LoadSlotMachineWheelOverlay(void) { + s16 x, y, dx; + u16 *screen; + + screen = (u16 *) BG_SCREEN_ADDR(30); + + for (x = 4; x < 18; x += 5) + { + for (dx = 0; dx < 4; dx++) + { + screen[5 * 32 + dx + x] = 0x2051; + screen[13 * 32 + dx + x] = 0x2851; + screen[6 * 32 + dx + x] = 0x2061; + screen[12 * 32 + dx + x] = 0x2861; + } + + screen[6 * 32 + x] = 0x20BE; + screen[12 * 32 + x] = 0x28BE; + + for (y = 7; y <= 11; y++) + { + screen[y * 32 + x] = 0x20BF; + } + } +} + +void sub_81065A8(s16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { + u16 *vram = (u16 *) BG_SCREEN_ADDR(29); + + vram[15 * 32 + arg0] = arg1; + vram[15 * 32 + 1 + arg0] = arg2; + vram[16 * 32 + arg0] = arg3; + vram[16 * 32 + 1 + arg0] = arg4; +} + +void sub_81065DC(void) { + s16 y, x; + u16 *screen; + + CpuCopy16(gUnknown_08E95FB8, (void *) BG_SCREEN_ADDR(29), 20 * 32 * 2); + + screen = (u16 *) BG_SCREEN_ADDR(30); + for (y = 0; y < 20; y++) + { + for (x = 0; x < 30; x++) + { + screen[x + y * 32] = 0; + } + } +} diff --git a/src/smokescreen.c b/src/smokescreen.c new file mode 100644 index 000000000..8345cb6ad --- /dev/null +++ b/src/smokescreen.c @@ -0,0 +1,73 @@ +#include "global.h" +#include "data2.h" +#include "decompress.h" +#include "sprite.h" +#include "util.h" + + +static void sub_8046388(struct Sprite *); + + +u8 sub_8046234(s16 x, s16 y, u8 a3) +{ + u8 mainSpriteId; + u8 spriteId1, spriteId2, spriteId3, spriteId4; + struct Sprite *mainSprite; + + if (GetSpriteTileStartByTag(gUnknown_081FAEA4.tag) == 0xFFFF) + { + LoadCompressedObjectPic(&gUnknown_081FAEA4); + LoadCompressedObjectPalette(&gUnknown_081FAEAC); + } + + mainSpriteId = CreateInvisibleSpriteWithCallback(sub_8046388); + mainSprite = &gSprites[mainSpriteId]; + mainSprite->data1 = a3; + + spriteId1 = CreateSprite(&gSpriteTemplate_81FAF0C, x - 16, y - 16, 2); + gSprites[spriteId1].data0 = mainSpriteId; + mainSprite->data0++; + AnimateSprite(&gSprites[spriteId1]); + + spriteId2 = CreateSprite(&gSpriteTemplate_81FAF0C, x, y - 16, 2); + gSprites[spriteId2].data0 = mainSpriteId; + mainSprite->data0++; + StartSpriteAnim(&gSprites[spriteId2], 1); + AnimateSprite(&gSprites[spriteId2]); + + spriteId3 = CreateSprite(&gSpriteTemplate_81FAF0C, x - 16, y, 2); + gSprites[spriteId3].data0 = mainSpriteId; + mainSprite->data0++; + StartSpriteAnim(&gSprites[spriteId3], 2); + AnimateSprite(&gSprites[spriteId3]); + + spriteId4 = CreateSprite(&gSpriteTemplate_81FAF0C, x, y, 2); + gSprites[spriteId4].data0 = mainSpriteId; + mainSprite->data0++; + StartSpriteAnim(&gSprites[spriteId4], 3); + AnimateSprite(&gSprites[spriteId4]); + + return mainSpriteId; +} + +static void sub_8046388(struct Sprite *sprite) +{ + if (!sprite->data0) + { + FreeSpriteTilesByTag(gUnknown_081FAEA4.tag); + FreeSpritePaletteByTag(gUnknown_081FAEAC.tag); + if (!sprite->data1) + DestroySprite(sprite); + else + sprite->callback = SpriteCallbackDummy; + } +} + +void sub_80463CC(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + gSprites[sprite->data0].data0--; + DestroySprite(sprite); + } +} diff --git a/src/sound.c b/src/sound.c index 56719aa08..c9c4916b0 100644 --- a/src/sound.c +++ b/src/sound.c @@ -1,10 +1,11 @@ #include "global.h" -#include "sound.h" -#include "asm.h" #include "gba/m4a_internal.h" -#include "task.h" -#include "songs.h" +#include "sound.h" +#include "battle.h" #include "m4a.h" +#include "main.h" +#include "songs.h" +#include "task.h" struct Fanfare { @@ -12,7 +13,10 @@ struct Fanfare u16 duration; }; -extern u16 gUnknown_020239F8; +// FIXME: different prototype than definition +u32 SpeciesToCryId(u32); + +extern u16 gBattleTypeFlags; extern struct MusicPlayerInfo *gMPlay_PokemonCry; extern u8 gPokemonCryBGMDuckingCounter; @@ -28,8 +32,6 @@ extern struct MusicPlayerInfo gMPlay_SE1; extern struct MusicPlayerInfo gMPlay_SE2; extern struct MusicPlayerInfo gMPlay_SE3; -extern struct Fanfare gFanfares[]; - extern struct ToneData voicegroup_8452590[]; extern struct ToneData voicegroup_8452B90[]; extern struct ToneData voicegroup_8453190[]; @@ -40,6 +42,22 @@ extern struct ToneData voicegroup_8453DC0[]; extern struct ToneData voicegroup_84543C0[]; extern struct ToneData voicegroup_84549C0[]; +static const struct Fanfare sFanfares[] = +{ + { BGM_FANFA1, 80 }, + { BGM_FANFA4, 160 }, + { BGM_FANFA5, 220 }, + { BGM_ME_WAZA, 220 }, + { BGM_ME_ASA, 160 }, + { BGM_ME_BACHI, 340 }, + { BGM_ME_WASURE, 180 }, + { BGM_ME_KINOMI, 120 }, + { BGM_ME_TAMA, 710 }, + { BGM_ME_B_BIG, 250 }, + { BGM_ME_B_SMALL, 150 }, + { BGM_ME_ZANNEN, 160 }, +}; + static void Task_Fanfare(u8 taskId); static void CreateFanfareTask(void); static void PlayCryInternal(u16 species, s8 pan, s8 volume, u8 priority, u8 mode); @@ -170,14 +188,10 @@ bool8 IsNotWaitingForBGMStop(void) void PlayFanfareByFanfareNum(u8 fanfareNum) { - struct Fanfare *fanfares; - struct Fanfare *fanfare; u16 songNum; m4aMPlayStop(&gMPlay_BGM); - fanfares = gFanfares; - fanfare = &fanfares[fanfareNum]; - songNum = fanfare->songNum; - sFanfareCounter = fanfare->duration; + songNum = sFanfares[fanfareNum].songNum; + sFanfareCounter = sFanfares[fanfareNum].duration; m4aSongNumStart(songNum); } @@ -201,7 +215,7 @@ bool8 WaitFanfare(bool8 stop) void StopFanfareByFanfareNum(u8 fanfareNum) { - m4aSongNumStop(gFanfares[fanfareNum].songNum); + m4aSongNumStop(sFanfares[fanfareNum].songNum); } void PlayFanfare(u16 songNum) @@ -209,8 +223,7 @@ void PlayFanfare(u16 songNum) s32 i; for (i = 0; (u32)i < 12; i++) { - struct Fanfare *fanfare = &gFanfares[i]; - if (fanfare->songNum == songNum) + if (sFanfares[i].songNum == songNum) { PlayFanfareByFanfareNum(i); CreateFanfareTask(); @@ -326,7 +339,7 @@ void PlayCry4(u16 species, s8 pan, u8 mode) } else { - if (!(gUnknown_020239F8 & 0x40)) + if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 85); PlayCryInternal(species, pan, 125, 10, mode); } @@ -513,7 +526,7 @@ void PlaySE(u16 songNum) m4aSongNumStart(songNum); } -void PlaySE12WithPanning(u16 songNum, u8 pan) +void PlaySE12WithPanning(u16 songNum, s8 pan) { m4aSongNumStart(songNum); m4aMPlayImmInit(&gMPlay_SE1); @@ -522,21 +535,21 @@ void PlaySE12WithPanning(u16 songNum, u8 pan) m4aMPlayPanpotControl(&gMPlay_SE2, 0xFFFF, pan); } -void PlaySE1WithPanning(u16 songNum, u8 pan) +void PlaySE1WithPanning(u16 songNum, s8 pan) { m4aSongNumStart(songNum); m4aMPlayImmInit(&gMPlay_SE1); m4aMPlayPanpotControl(&gMPlay_SE1, 0xFFFF, pan); } -void PlaySE2WithPanning(u16 songNum, u8 pan) +void PlaySE2WithPanning(u16 songNum, s8 pan) { m4aSongNumStart(songNum); m4aMPlayImmInit(&gMPlay_SE2); m4aMPlayPanpotControl(&gMPlay_SE2, 0xFFFF, pan); } -void SE12PanpotControl(u8 pan) +void SE12PanpotControl(s8 pan) { m4aMPlayPanpotControl(&gMPlay_SE1, 0xFFFF, pan); m4aMPlayPanpotControl(&gMPlay_SE2, 0xFFFF, pan); diff --git a/src/sprite.c b/src/sprite.c index b468b3f0a..fb8c2b648 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -1,8 +1,8 @@ #include "global.h" #include "sprite.h" #include "main.h" -#include "palette.h" #include "menu_cursor.h" +#include "palette.h" #define MAX_SPRITE_COPY_REQUESTS 64 @@ -10,12 +10,8 @@ #define SET_SPRITE_TILE_RANGE(index, start, count) \ { \ - u16 *rangeStarts; \ - u16 *rangeCounts; \ - rangeStarts = sSpriteTileRanges; \ - rangeStarts[index * 2] = start; \ - rangeCounts = sSpriteTileRanges + 1; \ - rangeCounts[index * 2] = count; \ + sSpriteTileRanges[index * 2] = start; \ + (sSpriteTileRanges + 1)[index * 2] = count; \ } #define ALLOC_SPRITE_TILE(n) \ @@ -40,7 +36,7 @@ struct OamMatrix struct SpriteCopyRequest { - u8 *src; + const u8 *src; u8 *dest; u16 size; }; @@ -61,8 +57,7 @@ static void ClearSpriteCopyRequests(void); static void ResetOamMatrices(void); static void ResetSprite(struct Sprite *sprite); static s16 AllocSpriteTiles(u16 tileCount); -u8 SpriteTileAllocBitmapOp(u16 bit, u8 op); -static void RequestSpriteFrameImageCopy(u16 index, u16 tileNum, struct SpriteFrameImage *images); +static void RequestSpriteFrameImageCopy(u16 index, u16 tileNum, const struct SpriteFrameImage *images); static void ResetAllSprites(void); static void BeginAnim(struct Sprite *sprite); static void ContinueAnim(struct Sprite *sprite); @@ -99,7 +94,7 @@ static void ApplyAffineAnimFrame(u8 matrixNum, struct AffineAnimFrameCmd *frameC static void ResetAffineAnimData(void); static u8 IndexOfSpriteTileTag(u16 tag); static void AllocSpriteTileRange(u16 tag, u16 start, u16 count); -static void DoLoadSpritePalette(u16 *src, u16 paletteOffset); +static void DoLoadSpritePalette(const u16 *src, u16 paletteOffset); typedef void (*AnimFunc)(struct Sprite *); typedef void (*AnimCmdFunc)(struct Sprite *); @@ -133,10 +128,12 @@ const struct SpriteTemplate gDummySpriteTemplate; // Unreferenced error message. // It means "The DMA transfer request table has exceeded its limit." static const u8 sDmaOverErrorMsg[] = - _"DMA OVER\n" - "DMAてんそう\n" - "リクエストテーブルが\n" - "オーバーしました"; + _( + "DMA OVER\n" + "DMAてんそう\n" + "リクエストテーブルが\n" + "オーバーしました" + ); // Unreferenced data. static const u8 sUnknownData[24] = @@ -173,51 +170,51 @@ static const u8 sCenterToCornerVecTable[3][4][2] = static const struct Sprite sDummySprite = { - DUMMY_OAM_DATA, - (union AnimCmd **)gDummySpriteAnimTable, - NULL, - (union AffineAnimCmd **)gDummySpriteAffineAnimTable, - (struct SpriteTemplate *)&gDummySpriteTemplate, - NULL, - SpriteCallbackDummy, - { 304, 160 }, - { 0, 0 }, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0xFF + .oam = DUMMY_OAM_DATA, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .template = &gDummySpriteTemplate, + .subspriteTables = NULL, + .callback = SpriteCallbackDummy, + .pos1 = { 304, 160 }, + .pos2 = { 0, 0 }, + .centerToCornerVecX = 0, + .centerToCornerVecY = 0, + .animNum = 0, + .animCmdIndex = 0, + .animDelayCounter = 0, + .animPaused = 0, + .affineAnimPaused = 0, + .animLoopCounter = 0, + .data0 = 0, + .data1 = 0, + .data2 = 0, + .data3 = 0, + .data4 = 0, + .data5 = 0, + .data6 = 0, + .data7 = 0, + .inUse = 0, + .coordOffsetEnabled = 0, + .invisible = 0, + .flags_3 = 0, + .flags_4 = 0, + .flags_5 = 0, + .flags_6 = 0, + .flags_7 = 0, + .hFlip = 0, + .vFlip = 0, + .animBeginning = 0, + .affineAnimBeginning = 0, + .animEnded = 0, + .affineAnimEnded = 0, + .usingSheet = 0, + .flags_f = 0, + .sheetTileStart = 0, + .subspriteTableNum = 0, + .subspriteMode = 0, + .subpriority = 0xFF }; const struct OamData gDummyOamData = DUMMY_OAM_DATA; @@ -232,13 +229,13 @@ const union AffineAnimCmd * const gDummySpriteAffineAnimTable[] = { &sDummyAffin const struct SpriteTemplate gDummySpriteTemplate = { - 0, - 0xFFFF, - (struct OamData *)&gDummyOamData, - (union AnimCmd **)gDummySpriteAnimTable, - NULL, - (union AffineAnimCmd **)gDummySpriteAffineAnimTable, - SpriteCallbackDummy + .tileTag = 0, + .paletteTag = 0xFFFF, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy }; // TODO: Find out what these are used for. @@ -538,7 +535,7 @@ u8 CreateSprite(const struct SpriteTemplate *template, s16 x, s16 y, u8 subprior return MAX_SPRITES; } -u8 CreateSpriteAtEnd(const struct SpriteTemplate *template, u16 x, u16 y, u8 subpriority) +u8 CreateSpriteAtEnd(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority) { s16 i; @@ -831,7 +828,7 @@ void ProcessSpriteCopyRequests(void) } } -static void RequestSpriteFrameImageCopy(u16 index, u16 tileNum, struct SpriteFrameImage *images) +static void RequestSpriteFrameImageCopy(u16 index, u16 tileNum, const struct SpriteFrameImage *images) { if (gSpriteCopyRequestCount < MAX_SPRITE_COPY_REQUESTS) { @@ -842,7 +839,7 @@ static void RequestSpriteFrameImageCopy(u16 index, u16 tileNum, struct SpriteFra } } -void RequestSpriteCopy(u8 *src, u8 *dest, u16 size) +void RequestSpriteCopy(const u8 *src, u8 *dest, u16 size) { if (gSpriteCopyRequestCount < MAX_SPRITE_COPY_REQUESTS) { @@ -1470,7 +1467,7 @@ void SetOamMatrixRotationScaling(u8 matrixNum, s16 xScale, s16 yScale, u16 rotat CopyOamMatrix(matrixNum, &matrix); } -u16 LoadSpriteSheet(struct SpriteSheet *sheet) +u16 LoadSpriteSheet(const struct SpriteSheet *sheet) { s16 tileStart = AllocSpriteTiles(sheet->size / TILE_SIZE_4BPP); @@ -1486,7 +1483,7 @@ u16 LoadSpriteSheet(struct SpriteSheet *sheet) } } -void LoadSpriteSheets(struct SpriteSheet *sheets) +void LoadSpriteSheets(const struct SpriteSheet *sheets) { u8 i; for (i = 0; sheets[i].data != NULL; i++) @@ -1515,9 +1512,9 @@ void AllocTilesForSpriteSheets(struct SpriteSheet *sheets) AllocTilesForSpriteSheet(&sheets[i]); } -void LoadTilesForSpriteSheet(struct SpriteSheet *sheet) +void LoadTilesForSpriteSheet(const struct SpriteSheet *sheet) { - u8 *data = sheet->data; + const u8 *data = sheet->data; u16 tileStart = GetSpriteTileStartByTag(sheet->tag); CpuCopy16(data, (u8 *)OBJ_VRAM0 + TILE_SIZE_4BPP * tileStart, sheet->size); } @@ -1601,14 +1598,14 @@ static void AllocSpriteTileRange(u16 tag, u16 start, u16 count) SET_SPRITE_TILE_RANGE(freeIndex, start, count); } -void RequestSpriteSheetCopy(struct SpriteSheet *sheet) +void RequestSpriteSheetCopy(const struct SpriteSheet *sheet) { - u8 *data = sheet->data; + const u8 *data = sheet->data; u16 tileStart = GetSpriteTileStartByTag(sheet->tag); RequestSpriteCopy(data, (u8 *)OBJ_VRAM0 + tileStart * TILE_SIZE_4BPP, sheet->size); } -u16 LoadSpriteSheetDeferred(struct SpriteSheet *sheet) +u16 LoadSpriteSheetDeferred(const struct SpriteSheet *sheet) { s16 tileStart = AllocSpriteTiles(sheet->size / TILE_SIZE_4BPP); @@ -1661,7 +1658,7 @@ void LoadSpritePalettes(const struct SpritePalette *palettes) break; } -static void DoLoadSpritePalette(u16 *src, u16 paletteOffset) +static void DoLoadSpritePalette(const u16 *src, u16 paletteOffset) { LoadPalette(src, paletteOffset + 0x100, 32); } @@ -1702,7 +1699,7 @@ void FreeSpritePaletteByTag(u16 tag) sSpritePaletteTags[index] = 0xFFFF; } -void SetSubspriteTables(struct Sprite *sprite, struct SubspriteTable *subspriteTables) +void SetSubspriteTables(struct Sprite *sprite, const struct SubspriteTable *subspriteTables) { sprite->subspriteTables = subspriteTables; sprite->subspriteTableNum = 0; @@ -1728,7 +1725,7 @@ bool8 AddSpriteToOamBuffer(struct Sprite *sprite, u8 *oamIndex) bool8 AddSubspritesToOamBuffer(struct Sprite *sprite, struct OamData *destOam, u8 *oamIndex) { - struct SubspriteTable *subspriteTable; + const struct SubspriteTable *subspriteTable; struct OamData *oam; if (*oamIndex >= gOamLimit) diff --git a/src/start_menu.c b/src/start_menu.c index f02665ad1..e05f3a999 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -1,8 +1,11 @@ #include "global.h" #include "start_menu.h" -#include "asm.h" +#include "event_data.h" +#include "field_map_obj_helpers.h" #include "field_player_avatar.h" -#include "flag.h" +#include "field_weather.h" +#include "fieldmap.h" +#include "item_menu.h" #include "load_save.h" #include "main.h" #include "map_obj_lock.h" @@ -10,6 +13,8 @@ #include "option_menu.h" #include "palette.h" #include "pokedex.h" +#include "pokemon_menu.h" +#include "pokenav.h" #include "rom4.h" #include "safari_zone.h" #include "save.h" @@ -19,9 +24,11 @@ #include "sound.h" #include "sprite.h" #include "string_util.h" +#include "strings.h" +#include "strings2.h" #include "task.h" #include "trainer_card.h" -#include "weather.h" +#include "unknown_task.h" //Menu actions enum { @@ -37,36 +44,51 @@ enum { MENU_ACTION_PLAYER_LINK }; -struct MenuItem { - u8 *text; - u8 (*callback)(void); -}; - static u8 (*saveDialogCallback)(void); static u8 saveDialogTimer; //Number of frames to keep the window on screen after save was completed static bool8 savingComplete; -extern bool8 gUnknown_020297EC; +extern bool8 gDifferentSaveFile; extern u16 gSaveFileStatus; extern u16 gScriptResult; extern u8 (*gCallback_03004AE8)(void); extern u8 gUnknown_03004860; -extern struct MenuItem gStartMenuItems[]; -extern u8 gNumSafariBalls; EWRAM_DATA static u8 sStartMenuCursorPos = 0; EWRAM_DATA static u8 sNumStartMenuActions = 0; EWRAM_DATA static u8 sCurrentStartMenuActions[10] = {0}; //Text strings -extern u8 gSystemText_Saving[]; extern u8 gSaveText_PlayerSavedTheGame[]; extern u8 gSaveText_DontTurnOff[]; -extern u8 gSystemText_SaveErrorExchangeBackup[]; extern u8 gSaveText_ThereIsAlreadyAFile[]; extern u8 gSaveText_ThereIsADifferentFile[]; extern u8 gSaveText_WouldYouLikeToSave[]; -extern u8 gOtherText_SafariStock[]; + +static u8 StartMenu_PokedexCallback(void); +static u8 StartMenu_PokemonCallback(void); +static u8 StartMenu_BagCallback(void); +static u8 StartMenu_PokenavCallback(void); +static u8 StartMenu_PlayerCallback(void); +static u8 StartMenu_SaveCallback(void); +static u8 StartMenu_OptionCallback(void); +static u8 StartMenu_ExitCallback(void); +static u8 StartMenu_RetireCallback(void); +static u8 StartMenu_PlayerLinkCallback(void); + +static const struct MenuAction sStartMenuItems[] = +{ + { SystemText_Pokedex, StartMenu_PokedexCallback }, + { SystemText_Pokemon, StartMenu_PokemonCallback }, + { SystemText_BAG, StartMenu_BagCallback }, + { SystemText_Pokenav, StartMenu_PokenavCallback }, + { SystemText_Player, StartMenu_PlayerCallback }, + { SystemText_Save, StartMenu_SaveCallback }, + { SystemText_Option, StartMenu_OptionCallback }, + { SystemText_Exit, StartMenu_ExitCallback }, + { SystemText_Retire, StartMenu_RetireCallback }, + { SystemText_Player, StartMenu_PlayerLinkCallback }, +}; //Private functions static void BuildStartMenuActions(void); @@ -83,7 +105,7 @@ static u8 SaveCallback1(void); static u8 SaveCallback2(void); static void sub_807160C(void); static u8 RunSaveDialogCallback(void); -static void DisplaySaveMessageWithCallback(u8 *ptr, u8 (*func)(void)); +static void DisplaySaveMessageWithCallback(const u8 *ptr, u8 (*func)(void)); static void Task_SaveDialog(u8 taskId); static void sub_8071700(void); static void HideSaveDialog(void); @@ -112,11 +134,11 @@ static void Task_8071B64(u8 taskId); static void BuildStartMenuActions(void) { sNumStartMenuActions = 0; - if(is_c1_link_related_active() == TRUE) + if (is_c1_link_related_active() == TRUE) BuildStartMenuActions_Link(); else { - if(GetSafariZoneFlag() == TRUE) + if (GetSafariZoneFlag() == TRUE) BuildStartMenuActions_SafariZone(); else BuildStartMenuActions_Normal(); @@ -130,12 +152,12 @@ static void AddStartMenuAction(u8 action) static void BuildStartMenuActions_Normal(void) { - if(FlagGet(SYS_POKEDEX_GET) == TRUE) + if (FlagGet(SYS_POKEDEX_GET) == TRUE) AddStartMenuAction(MENU_ACTION_POKEDEX); - if(FlagGet(SYS_POKEMON_GET) == TRUE) + if (FlagGet(SYS_POKEMON_GET) == TRUE) AddStartMenuAction(MENU_ACTION_POKEMON); AddStartMenuAction(MENU_ACTION_BAG); - if(FlagGet(SYS_POKENAV_GET) == TRUE) + if (FlagGet(SYS_POKENAV_GET) == TRUE) AddStartMenuAction(MENU_ACTION_POKENAV); AddStartMenuAction(MENU_ACTION_PLAYER); AddStartMenuAction(MENU_ACTION_SAVE); @@ -158,11 +180,11 @@ static void BuildStartMenuActions_Link(void) { AddStartMenuAction(MENU_ACTION_POKEMON); AddStartMenuAction(MENU_ACTION_BAG); - if(FlagGet(SYS_POKENAV_GET) == TRUE) + if (FlagGet(SYS_POKENAV_GET) == TRUE) AddStartMenuAction(MENU_ACTION_POKENAV); AddStartMenuAction(MENU_ACTION_PLAYER_LINK); AddStartMenuAction(MENU_ACTION_OPTION); - AddStartMenuAction(MENU_ACTION_EXIT); + AddStartMenuAction(MENU_ACTION_EXIT); } //Show number of safari balls left @@ -177,50 +199,50 @@ static void DisplaySafariBallsWindow(void) static bool32 PrintStartMenuItemsMultistep(s16 *index, u32 n) { int _index = *index; - + do { - MenuPrint(gStartMenuItems[sCurrentStartMenuActions[_index]].text, 23, 2 + _index * 2); + MenuPrint(sStartMenuItems[sCurrentStartMenuActions[_index]].text, 23, 2 + _index * 2); _index++; - if(_index >= sNumStartMenuActions) + if (_index >= sNumStartMenuActions) { *index = _index; return TRUE; } } - while(--n != 0); + while (--n != 0); *index = _index; return FALSE; } static bool32 InitStartMenuMultistep(s16 *step, s16 *index) { - switch(*step) - { - case 1: - BuildStartMenuActions(); - (*step)++; - break; - case 2: - MenuDrawTextWindow(22, 0, 29, sNumStartMenuActions * 2 + 3); - *index = 0; + switch (*step) + { + case 1: + BuildStartMenuActions(); + (*step)++; + break; + case 2: + MenuDrawTextWindow(22, 0, 29, sNumStartMenuActions * 2 + 3); + *index = 0; + (*step)++; + break; + case 3: + if (GetSafariZoneFlag()) + DisplaySafariBallsWindow(); + (*step)++; + break; + case 4: + if (PrintStartMenuItemsMultistep(index, 2)) (*step)++; - break; - case 3: - if(GetSafariZoneFlag()) - DisplaySafariBallsWindow(); - (*step)++; - break; - case 4: - if(PrintStartMenuItemsMultistep(index, 2)) - (*step)++; - break; - case 0: - (*step)++; - break; - case 5: - sStartMenuCursorPos = InitMenu(0, 0x17, 2, sNumStartMenuActions, sStartMenuCursorPos, 6); - return TRUE; + break; + case 0: + (*step)++; + break; + case 5: + sStartMenuCursorPos = InitMenu(0, 0x17, 2, sNumStartMenuActions, sStartMenuCursorPos, 6); + return TRUE; } return FALSE; } @@ -229,14 +251,14 @@ static void InitStartMenu(void) { s16 step = 0; s16 index = 0; - - while(InitStartMenuMultistep(&step, &index) == FALSE) + + while (InitStartMenuMultistep(&step, &index) == FALSE) ; } static void Task_StartMenu(u8 taskId) { - if(InitStartMenuMultistep(gTasks[taskId].data, gTasks[taskId].data + 1) == TRUE) + if (InitStartMenuMultistep(gTasks[taskId].data, gTasks[taskId].data + 1) == TRUE) { *gTasks[taskId].data = 0; SwitchTaskToFollowupFunc(taskId); @@ -246,41 +268,34 @@ static void Task_StartMenu(u8 taskId) void CreateStartMenuTask(void (*func)(u8)) { u8 taskId; - + InitMenuWindow(&gWindowConfig_81E6CE4); taskId = CreateTask(Task_StartMenu, 0x50); SetTaskFuncWithFollowupFunc(taskId, Task_StartMenu, func); } -struct MyTask { - TaskFunc func; - bool8 isActive; - u8 prev; - u8 next; - u8 priority; - s16 var1; -}; - void sub_80712B4(u8 taskId) { - switch(((struct MyTask *)&gTasks[taskId])->var1) + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) { - case 0: - gCallback_03004AE8 = StartMenu_InputProcessCallback; - ((struct MyTask *)&gTasks[taskId])->var1++; - break; - case 1: - if(gCallback_03004AE8() == 1) - DestroyTask(taskId); - break; + case 0: + gCallback_03004AE8 = StartMenu_InputProcessCallback; + task->data[0]++; + break; + case 1: + if (gCallback_03004AE8() == 1) + DestroyTask(taskId); + break; } } void sub_8071310(void) { - if(!is_c1_link_related_active()) + if (!is_c1_link_related_active()) { - player_bitmagic(); + FreezeMapObjects(); sub_80594C0(); sub_80597F4(); } @@ -290,45 +305,45 @@ void sub_8071310(void) static u8 StartMenu_InputProcessCallback(void) { - if(gMain.newKeys & DPAD_UP) + if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); sStartMenuCursorPos = MoveMenuCursor(-1); } - if(gMain.newKeys & DPAD_DOWN) + if (gMain.newKeys & DPAD_DOWN) { PlaySE(SE_SELECT); sStartMenuCursorPos = MoveMenuCursor(1); } - if(gMain.newKeys & A_BUTTON) + if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - if(gStartMenuItems[sCurrentStartMenuActions[sStartMenuCursorPos]].callback == StartMenu_PokedexCallback) + if (sStartMenuItems[sCurrentStartMenuActions[sStartMenuCursorPos]].func == StartMenu_PokedexCallback) { - if(GetNationalPokedexCount(0) == 0) + if (GetNationalPokedexCount(0) == 0) return 0; } - gCallback_03004AE8 = gStartMenuItems[sCurrentStartMenuActions[sStartMenuCursorPos]].callback; - if(gCallback_03004AE8 != StartMenu_SaveCallback && + gCallback_03004AE8 = sStartMenuItems[sCurrentStartMenuActions[sStartMenuCursorPos]].func; + if (gCallback_03004AE8 != StartMenu_SaveCallback && gCallback_03004AE8 != StartMenu_ExitCallback && gCallback_03004AE8 != StartMenu_RetireCallback) fade_screen(1, 0); return 0; } - if(gMain.newKeys & (START_BUTTON | B_BUTTON)) + if (gMain.newKeys & (START_BUTTON | B_BUTTON)) { - sub_8071C20(); + CloseMenu(); return 1; } return 0; } //When player selects POKEDEX -u8 StartMenu_PokedexCallback(void) +static u8 StartMenu_PokedexCallback(void) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { - sav12_xor_increment(0x29); + IncrementGameStat(0x29); PlayRainSoundEffect(); SetMainCallback2(CB2_InitPokedex); return 1; @@ -337,9 +352,9 @@ u8 StartMenu_PokedexCallback(void) } //When player selects POKEMON -u8 StartMenu_PokemonCallback(void) +static u8 StartMenu_PokemonCallback(void) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { PlayRainSoundEffect(); SetMainCallback2(sub_8089A70); @@ -349,9 +364,9 @@ u8 StartMenu_PokemonCallback(void) } //When player selects BAG -u8 StartMenu_BagCallback(void) +static u8 StartMenu_BagCallback(void) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { PlayRainSoundEffect(); SetMainCallback2(sub_80A53F8); @@ -361,9 +376,9 @@ u8 StartMenu_BagCallback(void) } //When player selects POKENAV -u8 StartMenu_PokenavCallback(void) +static u8 StartMenu_PokenavCallback(void) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { PlayRainSoundEffect(); SetMainCallback2(sub_80EBA5C); @@ -373,9 +388,9 @@ u8 StartMenu_PokenavCallback(void) } //When player selects his/her name -u8 StartMenu_PlayerCallback(void) +static u8 StartMenu_PlayerCallback(void) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { PlayRainSoundEffect(); sub_8093110(sub_805469C); @@ -385,45 +400,45 @@ u8 StartMenu_PlayerCallback(void) } //When player selects SAVE -u8 StartMenu_SaveCallback(void) +static u8 StartMenu_SaveCallback(void) { - sub_8072DEC(); + HandleDestroyMenuCursors(); gCallback_03004AE8 = SaveCallback1; return 0; } //When player selects OPTION -u8 StartMenu_OptionCallback(void) +static u8 StartMenu_OptionCallback(void) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { PlayRainSoundEffect(); SetMainCallback2(CB2_InitOptionMenu); - gMain.field_8 = sub_805469C; + gMain.savedCallback = sub_805469C; return 1; } return 0; } //When player selects EXIT -u8 StartMenu_ExitCallback(void) +static u8 StartMenu_ExitCallback(void) { - sub_8071C20(); + CloseMenu(); return 1; } //When player selects RETIRE -u8 StartMenu_RetireCallback(void) +static u8 StartMenu_RetireCallback(void) { - sub_8071C20(); + CloseMenu(); SafariZoneRetirePrompt(); return 1; } //When player selects their name in multiplayer mode -u8 StartMenu_PlayerLinkCallback(void) +static u8 StartMenu_PlayerLinkCallback(void) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) { PlayRainSoundEffect(); sub_8093130(gUnknown_03004860, sub_805469C); @@ -450,25 +465,25 @@ static u8 SaveCallback1(void) static u8 SaveCallback2(void) { - switch(RunSaveDialogCallback()) - { - case SAVE_IN_PROGRESS: - return FALSE; - case SAVE_CANCELED: - //Go back to start menu - MenuZeroFillScreen(); - InitStartMenu(); - gCallback_03004AE8 = StartMenu_InputProcessCallback; - return FALSE; - case SAVE_SUCCESS: - case SAVE_ERROR: - MenuZeroFillScreen(); - sub_8064E2C(); - ScriptContext2_Disable(); - return TRUE; + switch (RunSaveDialogCallback()) + { + case SAVE_IN_PROGRESS: + return FALSE; + case SAVE_CANCELED: + //Go back to start menu + MenuZeroFillScreen(); + InitStartMenu(); + gCallback_03004AE8 = StartMenu_InputProcessCallback; + return FALSE; + case SAVE_SUCCESS: + case SAVE_ERROR: + MenuZeroFillScreen(); + sub_8064E2C(); + ScriptContext2_Disable(); + return TRUE; } return FALSE; -} +} static void sub_807160C(void) { @@ -479,9 +494,9 @@ static void sub_807160C(void) static u8 RunSaveDialogCallback(void) { - if(savingComplete) + if (savingComplete) { - if(!MenuUpdateWindowText()) + if (!MenuUpdateWindowText()) return 0; } savingComplete = FALSE; @@ -494,7 +509,7 @@ void InitSaveDialog(void) CreateTask(Task_SaveDialog, 0x50); } -static void DisplaySaveMessageWithCallback(u8 *ptr, u8 (*func)(void)) +static void DisplaySaveMessageWithCallback(const u8 *ptr, u8 (*func)(void)) { StringExpandPlaceholders(gStringVar4, ptr); MenuDisplayMessageBox(); @@ -506,18 +521,18 @@ static void DisplaySaveMessageWithCallback(u8 *ptr, u8 (*func)(void)) static void Task_SaveDialog(u8 taskId) { u8 status = RunSaveDialogCallback(); - - switch(status) - { - case SAVE_CANCELED: - case SAVE_ERROR: - gScriptResult = 0; - break; - case SAVE_SUCCESS: - gScriptResult = status; - break; - case SAVE_IN_PROGRESS: - return; + + switch (status) + { + case SAVE_CANCELED: + case SAVE_ERROR: + gScriptResult = 0; + break; + case SAVE_SUCCESS: + gScriptResult = status; + break; + case SAVE_IN_PROGRESS: + return; } DestroyTask(taskId); EnableBothScriptContexts(); @@ -525,7 +540,7 @@ static void Task_SaveDialog(u8 taskId) static void sub_8071700(void) { - sub_80946C8(0, 0); + HandleCloseSaveWindow(0, 0); } static void HideSaveDialog(void) @@ -541,21 +556,21 @@ static void SaveDialogStartTimeout(void) static bool8 SaveDialogCheckForTimeoutOrKeypress(void) { saveDialogTimer--; - if(gMain.heldKeys & A_BUTTON) + if (gMain.heldKeys & A_BUTTON) { PlaySE(SE_SELECT); return TRUE; } - else if(saveDialogTimer == 0) + else if (saveDialogTimer == 0) return TRUE; return FALSE; } static bool8 SaveDialogCheckForTimeoutAndKeypress(void) { - if(saveDialogTimer != 0) + if (saveDialogTimer != 0) saveDialogTimer--; - else if(gMain.heldKeys & A_BUTTON) + else if (gMain.heldKeys & A_BUTTON) return TRUE; return FALSE; } @@ -564,7 +579,6 @@ static u8 SaveDialogCB_DisplayConfirmMessage(void) { MenuZeroFillScreen(); HandleDrawSaveWindowInfo(0, 0); - //"Would you like to save the game?" DisplaySaveMessageWithCallback(gSaveText_WouldYouLikeToSave, SaveDialogCB_DisplayConfirmYesNoMenu); return SAVE_IN_PROGRESS; } @@ -578,31 +592,31 @@ static u8 SaveDialogCB_DisplayConfirmYesNoMenu(void) static u8 SaveDialogCB_ProcessConfirmYesNoMenu(void) { - switch(ProcessMenuInputNoWrap_()) + switch (ProcessMenuInputNoWrap_()) { - case 0: //YES - HideSaveDialog(); - switch(gSaveFileStatus) + case 0: //YES + HideSaveDialog(); + switch (gSaveFileStatus) + { + case 0: + case 2: + if (gDifferentSaveFile == FALSE) { - case 0: - case 2: - if(gUnknown_020297EC == FALSE) - { - saveDialogCallback = SaveDialogCB_SaveFileExists; - return SAVE_IN_PROGRESS; - } - saveDialogCallback = SaveDialogCB_DisplaySavingMessage; - return SAVE_IN_PROGRESS; - default: - saveDialogCallback = SaveDialogCB_SaveFileExists; - return SAVE_IN_PROGRESS; + saveDialogCallback = SaveDialogCB_SaveFileExists; + return SAVE_IN_PROGRESS; } - break; - case -1: //B button - case 1: //NO - HideSaveDialog(); - sub_8071700(); - return SAVE_CANCELED; + saveDialogCallback = SaveDialogCB_DisplaySavingMessage; + return SAVE_IN_PROGRESS; + default: + saveDialogCallback = SaveDialogCB_SaveFileExists; + return SAVE_IN_PROGRESS; + } + break; + case -1: //B button + case 1: //NO + HideSaveDialog(); + sub_8071700(); + return SAVE_CANCELED; } return SAVE_IN_PROGRESS; } @@ -610,7 +624,7 @@ static u8 SaveDialogCB_ProcessConfirmYesNoMenu(void) static u8 SaveDialogCB_SaveFileExists(void) { DisplaySaveMessageWithCallback( - gUnknown_020297EC == TRUE ? gSaveText_ThereIsADifferentFile : gSaveText_ThereIsAlreadyAFile, + gDifferentSaveFile == TRUE ? gSaveText_ThereIsADifferentFile : gSaveText_ThereIsAlreadyAFile, SaveDialogCB_DisplayOverwriteYesNoMenu); return SAVE_IN_PROGRESS; } @@ -624,17 +638,17 @@ static u8 SaveDialogCB_DisplayOverwriteYesNoMenu(void) static u8 SaveDialogCB_ProcessOverwriteYesNoMenu(void) { - switch(ProcessMenuInputNoWrap_()) + switch (ProcessMenuInputNoWrap_()) { - case 0: //YES - HideSaveDialog(); - saveDialogCallback = SaveDialogCB_DisplaySavingMessage; - break; - case -1: //B button - case 1: //NO - HideSaveDialog(); - sub_8071700(); - return SAVE_CANCELED; + case 0: //YES + HideSaveDialog(); + saveDialogCallback = SaveDialogCB_DisplaySavingMessage; + break; + case -1: //B button + case 1: //NO + HideSaveDialog(); + sub_8071700(); + return SAVE_CANCELED; } return SAVE_IN_PROGRESS; } @@ -648,20 +662,20 @@ static u8 SaveDialogCB_DisplaySavingMessage(void) static u8 SaveDialogCB_DoSave(void) { - u8 a; - - sav12_xor_increment(0); - if(gUnknown_020297EC == TRUE) + bool8 saveSucceeded; + + IncrementGameStat(0); + if (gDifferentSaveFile == TRUE) { - a = sub_8125D44(4); - gUnknown_020297EC = FALSE; + saveSucceeded = TrySavingData(DIFFERENT_FILE_SAVE); + gDifferentSaveFile = FALSE; } else { - a = sub_8125D44(0); + saveSucceeded = TrySavingData(NORMAL_SAVE); } - - if(a == 1) + + if (saveSucceeded == TRUE) { //"(Player) saved the game." DisplaySaveMessageWithCallback(gSaveText_PlayerSavedTheGame, SaveDialogCB_SaveSuccess); @@ -671,14 +685,14 @@ static u8 SaveDialogCB_DoSave(void) //"Save error. Please exchange the backup memory." DisplaySaveMessageWithCallback(gSystemText_SaveErrorExchangeBackup, SaveDialogCB_SaveError); } - + SaveDialogStartTimeout(); return SAVE_IN_PROGRESS; } static u8 SaveDialogCB_SaveSuccess(void) { - if(MenuUpdateWindowText()) + if (MenuUpdateWindowText()) { PlaySE(SE_SAVE); saveDialogCallback = SaveDialogCB_ReturnSuccess; @@ -688,7 +702,7 @@ static u8 SaveDialogCB_SaveSuccess(void) static u8 SaveDialogCB_ReturnSuccess(void) { - if(!IsSEPlaying() && SaveDialogCheckForTimeoutOrKeypress()) + if (!IsSEPlaying() && SaveDialogCheckForTimeoutOrKeypress()) { sub_8071700(); return SAVE_SUCCESS; @@ -699,7 +713,7 @@ static u8 SaveDialogCB_ReturnSuccess(void) static u8 SaveDialogCB_SaveError(void) { - if(MenuUpdateWindowText()) + if (MenuUpdateWindowText()) { PlaySE(SE_BOO); saveDialogCallback = SaveDialogCB_ReturnError; @@ -709,7 +723,7 @@ static u8 SaveDialogCB_SaveError(void) static u8 SaveDialogCB_ReturnError(void) { - if(!SaveDialogCheckForTimeoutAndKeypress()) + if (!SaveDialogCheckForTimeoutAndKeypress()) return SAVE_IN_PROGRESS; else { @@ -725,57 +739,57 @@ static void sub_80719F0(void) static bool32 sub_80719FC(u8 *step) { - switch(*step) + switch (*step) { - case 0: + case 0: + { + u8 *addr; + u32 size; + + REG_DISPCNT = 0; + SetVBlankCallback(NULL); + remove_some_task(); + DmaClear16(3, PLTT, PLTT_SIZE); + addr = (void *)VRAM; + size = 0x18000; + while (1) { - u8 *addr; - u32 size; - - REG_DISPCNT = 0; - SetVBlankCallback(NULL); - remove_some_task(); - DmaClear16(3, PLTT, PLTT_SIZE); - addr = (void *)VRAM; - size = 0x18000; - while(1) + DmaFill16(3, 0, addr, 0x1000); + addr += 0x1000; + size -= 0x1000; + if (size <= 0x1000) { - DmaFill16(3, 0, addr, 0x1000); - addr += 0x1000; - size -= 0x1000; - if(size <= 0x1000) - { - DmaFill16(3, 0, addr, size); - break; - } + DmaFill16(3, 0, addr, size); + break; } - break; } - case 1: - ResetSpriteData(); - ResetTasks(); - ResetPaletteFade(); - dp12_8087EA4(); - break; - case 2: - SetUpWindowConfig(&gWindowConfig_81E6CE4); - InitMenuWindow(&gWindowConfig_81E6CE4); - REG_DISPCNT = 0x100; - break; - case 3: - { - u32 savedIme; - - BlendPalettes(-1, 0x10, 0); - SetVBlankCallback(sub_80719F0); - savedIme = REG_IME; - REG_IME = 0; - REG_IE |= 1; - REG_IME = savedIme; - break; - } - case 4: - return TRUE; + break; + } + case 1: + ResetSpriteData(); + ResetTasks(); + ResetPaletteFade(); + dp12_8087EA4(); + break; + case 2: + SetUpWindowConfig(&gWindowConfig_81E6CE4); + InitMenuWindow(&gWindowConfig_81E6CE4); + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_BG0_ON; + break; + case 3: + { + u32 savedIme; + + BlendPalettes(-1, 0x10, 0); + SetVBlankCallback(sub_80719F0); + savedIme = REG_IME; + REG_IME = 0; + REG_IE |= 1; + REG_IME = savedIme; + break; + } + case 4: + return TRUE; } (*step)++; return FALSE; @@ -783,7 +797,7 @@ static bool32 sub_80719FC(u8 *step) void sub_8071B28(void) { - if(sub_80719FC(&gMain.state)) + if (sub_80719FC(&gMain.state)) { CreateTask(Task_8071B64, 0x50); SetMainCallback2(sub_8071B54); @@ -799,51 +813,36 @@ static void sub_8071B54(void) static void Task_8071B64(u8 taskId) { s16 *step = gTasks[taskId].data; - - if(!gPaletteFade.active) + + if (!gPaletteFade.active) { - switch(*step) + switch (*step) { - case 0: - MenuDisplayMessageBox(); - MenuPrint(gSystemText_Saving, 2, 15); - BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - (*step)++; - break; - case 1: - SetSecretBase2Field_9_AndHideBG(); - sub_8125E2C(); - (*step)++; - break; - case 2: - if(!sub_8125E6C()) - break; - ClearSecretBase2Field_9_2(); - (*step)++; - break; - case 3: - BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - (*step)++; + case 0: + MenuDisplayMessageBox(); + MenuPrint(gSystemText_Saving, 2, 15); + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + (*step)++; + break; + case 1: + SetSecretBase2Field_9_AndHideBG(); + sub_8125E2C(); + (*step)++; + break; + case 2: + if (!sub_8125E6C()) break; - case 4: - SetMainCallback2(gMain.field_8); - DestroyTask(taskId); - break; + ClearSecretBase2Field_9_2(); + (*step)++; + break; + case 3: + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + (*step)++; + break; + case 4: + SetMainCallback2(gMain.savedCallback); + DestroyTask(taskId); + break; } } } - -void sub_8071C20(void) -{ - PlaySE(SE_SELECT); - MenuZeroFillScreen(); - sub_8064E2C(); - ScriptContext2_Disable(); - sub_8072DEC(); -} - -void AppendToList(u8 *list, u8 *pindex, u32 value) -{ - list[*pindex] = value; - (*pindex)++; -} diff --git a/src/starter_choose.c b/src/starter_choose.c index 2750705b8..2b28df4f0 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -1,50 +1,227 @@ #include "global.h" #include "starter_choose.h" -#include "asm.h" +#include "data2.h" +#include "decompress.h" #include "main.h" #include "menu.h" #include "palette.h" #include "pokedex.h" #include "songs.h" #include "sound.h" +#include "species.h" +#include "sprite.h" #include "string_util.h" +#include "strings.h" #include "task.h" #include "trig.h" -#include "decompress.h" -#include "sprite.h" - -struct MonCoords -{ - u8 x, y; -}; +#include "unknown_task.h" -extern void * const gUnknown_081FAF4C[]; -extern const u8 gStarterChoose_PokeballCoords[][2]; -extern u8 gBirchHelpGfx[]; -extern u8 gBirchBagTilemap[]; -extern u8 gBirchGrassTilemap[]; -extern struct SpriteSheet gUnknown_083F7794; -extern struct SpriteSheet gUnknown_083F77A4; -extern u8 gBirchBagGrassPal[]; -extern const u8 gStarterChoose_LabelCoords[][2]; -extern u16 gStarterMons[]; -extern union AffineAnimCmd *gUnknown_083F778C[]; -extern u8 gOtherText_DoYouChoosePoke[]; extern u16 gScriptResult; -extern u8 gSpeciesNames[][11]; -extern u8 gOtherText_Poke[]; -extern const struct SpriteSheet gMonFrontPicTable[]; -extern const struct MonCoords gMonFrontPicCoords[]; -extern const struct SpritePalette gMonPaletteTable[]; -extern u8 gUnknown_083F76E4[][2]; -extern u8 gOtherText_BirchInTrouble[]; - -extern struct SpriteTemplate gSpriteTemplate_83F77E4; -extern struct SpriteTemplate gSpriteTemplate_83F77CC; -extern struct SpritePalette gUnknown_083F77B4[]; -extern struct SpriteTemplate gSpriteTemplate_83F77FC; extern struct SpriteTemplate gUnknown_02024E8C; +//-------------------------------------------------- +// Graphics Data +//-------------------------------------------------- + +const u16 gBirchBagGrassPal[2][16] = +{ + INCBIN_U16("graphics/misc/birch_bag.gbapal"), + INCBIN_U16("graphics/misc/birch_grass.gbapal"), +}; +static const u16 gBirchBallarrow_Pal[] = INCBIN_U16("graphics/misc/birch_ballarrow.gbapal"); +static const u16 gBirchCircle_Pal[] = INCBIN_U16("graphics/misc/birch_circle.gbapal"); +const u8 gBirchBagTilemap[] = INCBIN_U8("graphics/misc/birch_bag_map.bin.lz"); +const u8 gBirchGrassTilemap[] = INCBIN_U8("graphics/misc/birch_grass_map.bin.lz"); +const u8 gBirchHelpGfx[] = INCBIN_U8("graphics/misc/birch_help.4bpp.lz"); +static const u8 gBirchBallarrow_Gfx[] = INCBIN_U8("graphics/misc/birch_ballarrow.4bpp.lz"); +static const u8 gBirchCircle_Gfx[] = INCBIN_U8("graphics/misc/birch_circle.4bpp.lz"); +static const u8 gStarterChoose_PokeballCoords[][2] = +{ + {60, 64}, + {120, 88}, + {180, 64}, +}; +static const u8 gStarterChoose_LabelCoords[][2] = +{ + {0, 9}, + {16, 10}, + {8, 4}, +}; +static const u16 sStarterMons[] = {SPECIES_TREECKO, SPECIES_TORCHIC, SPECIES_MUDKIP}; +static const struct OamData gOamData_83F76CC = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 2, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const struct OamData gOamData_83F76D4 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 2, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const struct OamData gOamData_83F76DC = +{ + .y = 160, + .affineMode = 3, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const u8 gUnknown_083F76E4[][2] = +{ + {60, 32}, + {120, 56}, + {180, 32}, + {0, 0}, +}; +static const union AnimCmd gSpriteAnim_83F76EC[] = +{ + ANIMCMD_FRAME(48, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83F76F4[] = +{ + ANIMCMD_FRAME(0, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83F76FC[] = +{ + ANIMCMD_FRAME(16, 4), + ANIMCMD_FRAME(0, 4), + ANIMCMD_FRAME(32, 4), + ANIMCMD_FRAME(0, 4), + ANIMCMD_FRAME(16, 4), + ANIMCMD_FRAME(0, 4), + ANIMCMD_FRAME(32, 4), + ANIMCMD_FRAME(0, 4), + ANIMCMD_FRAME(0, 32), + ANIMCMD_FRAME(16, 8), + ANIMCMD_FRAME(0, 8), + ANIMCMD_FRAME(32, 8), + ANIMCMD_FRAME(0, 8), + ANIMCMD_FRAME(16, 8), + ANIMCMD_FRAME(0, 8), + ANIMCMD_FRAME(32, 8), + ANIMCMD_FRAME(0, 8), + ANIMCMD_JUMP(0), +}; +static const union AnimCmd gSpriteAnim_83F7744[] = +{ + ANIMCMD_FRAME(0, 8), + ANIMCMD_END, +}; +static const union AnimCmd *const gSpriteAnimTable_83F774C[] = +{ + gSpriteAnim_83F76EC, +}; +static const union AnimCmd *const gSpriteAnimTable_83F7750[] = +{ + gSpriteAnim_83F76F4, + gSpriteAnim_83F76FC, +}; +static const union AnimCmd *const gSpriteAnimTable_83F7758[] = +{ + gSpriteAnim_83F7744, +}; +static const union AffineAnimCmd gSpriteAffineAnim_83F775C[] = +{ + AFFINEANIMCMD_FRAME(16, 16, 0, 0), + AFFINEANIMCMD_FRAME(16, 16, 0, 15), + AFFINEANIMCMD_END, +}; +static const union AffineAnimCmd gSpriteAffineAnim_83F7774[] = +{ + AFFINEANIMCMD_FRAME(20, 20, 0, 0), + AFFINEANIMCMD_FRAME(20, 20, 0, 15), + AFFINEANIMCMD_END, +}; +static const union AffineAnimCmd *const gSpriteAffineAnimTable_83F778C[] = +{ + gSpriteAffineAnim_83F775C, +}; +static const union AffineAnimCmd *const gSpriteAffineAnimTable_83F7790[] = +{ + gSpriteAffineAnim_83F7774, +}; +static const struct CompressedSpriteSheet gUnknown_083F7794[] = +{ + {gBirchBallarrow_Gfx, 0x0800, 0x1000}, + {NULL}, +}; +static const struct CompressedSpriteSheet gUnknown_083F77A4[] = +{ + {gBirchCircle_Gfx, 0x0800, 0x1001}, + {NULL}, +}; +const struct SpritePalette gUnknown_083F77B4[] = +{ + {gBirchBallarrow_Pal, 0x1000}, + {gBirchCircle_Pal, 0x1001}, + {NULL}, +}; +static void sub_810A62C(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_83F77CC = +{ + .tileTag = 4096, + .paletteTag = 4096, + .oam = &gOamData_83F76CC, + .anims = gSpriteAnimTable_83F774C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_810A62C, +}; +static void sub_810A68C(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_83F77E4 = +{ + .tileTag = 4096, + .paletteTag = 4096, + .oam = &gOamData_83F76D4, + .anims = gSpriteAnimTable_83F7750, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_810A68C, +}; +static void StarterPokemonSpriteAnimCallback(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_83F77FC = +{ + .tileTag = 4097, + .paletteTag = 4097, + .oam = &gOamData_83F76DC, + .anims = gSpriteAnimTable_83F7758, + .images = NULL, + .affineAnims = gSpriteAffineAnimTable_83F7790, + .callback = StarterPokemonSpriteAnimCallback, +}; + static void MainCallback2(void); static void Task_StarterChoose1(u8 taskId); static void Task_StarterChoose2(u8 taskId); @@ -60,19 +237,12 @@ static u8 CreatePokemonFrontSprite(u16, u8, u8); #define STARTER_PKMN_POS_X 120 #define STARTER_PKMN_POS_Y 64 -//Task data -enum { - TD_STARTERSELECTION, - TD_PKMN_SPRITE_ID, - TD_CIRCLE_SPRITE_ID, -}; - //Retrieves one of the available starter Pokemon u16 GetStarterPokemon(u16 n) { - if(n > 3) + if (n > 3) n = 0; - return gStarterMons[n]; + return sStarterMons[n]; } static void VblankCallback(void) @@ -82,14 +252,18 @@ static void VblankCallback(void) TransferPlttBuffer(); } +#define tStarterSelection data[0] +#define tPkmnSpriteId data[1] +#define tCircleSpriteId data[2] + void CB2_ChooseStarter(void) { u16 savedIme; u8 taskId; u8 spriteId; - + SetVBlankCallback(NULL); - + REG_DISPCNT = 0; REG_BG3CNT = 0; REG_BG2CNT = 0; @@ -103,11 +277,11 @@ void CB2_ChooseStarter(void) REG_BG1VOFS = 0; REG_BG0HOFS = 0; REG_BG0VOFS = 0; - + DmaFill16(3, 0, VRAM, VRAM_SIZE); DmaFill32(3, 0, OAM, OAM_SIZE); DmaFill16(3, 0, PLTT, PLTT_SIZE); - + LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM); LZ77UnCompVram(&gBirchBagTilemap, (void *)(VRAM + 0x3000)); LZ77UnCompVram(&gBirchGrassTilemap, (void *)(VRAM + 0x3800)); @@ -116,23 +290,23 @@ void CB2_ChooseStarter(void) ResetSpriteData(); ResetPaletteFade(); FreeAllSpritePalettes(); - LoadPalette(gBirchBagGrassPal, 0, 0x40); - LoadCompressedObjectPic(&gUnknown_083F7794); - LoadCompressedObjectPic(&gUnknown_083F77A4); + LoadPalette(gBirchBagGrassPal, 0, sizeof(gBirchBagGrassPal)); + LoadCompressedObjectPic(&gUnknown_083F7794[0]); + LoadCompressedObjectPic(&gUnknown_083F77A4[0]); LoadSpritePalettes(gUnknown_083F77B4); SetUpWindowConfig(&gWindowConfig_81E6C3C); InitMenuWindow(&gWindowConfig_81E6CE4); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - + savedIme = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; REG_IME = savedIme; REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; - + SetVBlankCallback(VblankCallback); SetMainCallback2(MainCallback2); - + REG_WININ = 0x3F; REG_WINOUT = 0x1F; REG_WIN0H = 0; @@ -140,18 +314,18 @@ void CB2_ChooseStarter(void) REG_BLDCNT = 0xFE; REG_BLDALPHA = 0; REG_BLDY = 0x7; - REG_BG3CNT = 0x703; - REG_BG2CNT = 0x602; - REG_BG0CNT = 0x1F08; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(6) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON; - + taskId = CreateTask(Task_StarterChoose1, 0); - gTasks[taskId].data[TD_STARTERSELECTION] = 1; - + gTasks[taskId].tStarterSelection = 1; + //Create hand sprite spriteId = CreateSprite(&gSpriteTemplate_83F77CC, 120, 56, 2); gSprites[spriteId].data0 = taskId; - + //Create three Pokeball sprites spriteId = CreateSprite( &gSpriteTemplate_83F77E4, @@ -180,7 +354,7 @@ static void MainCallback2(void) static void Task_StarterChoose1(u8 taskId) { - CreateStarterPokemonLabel(0xFF, gTasks[taskId].data[TD_STARTERSELECTION]); + CreateStarterPokemonLabel(0xFF, gTasks[taskId].tStarterSelection); MenuDrawTextWindow(2, 14, 27, 19); MenuPrint(gOtherText_BirchInTrouble, 3, 15); gTasks[taskId].func = Task_StarterChoose2; @@ -188,60 +362,60 @@ static void Task_StarterChoose1(u8 taskId) static void Task_StarterChoose2(u8 taskId) { - u8 selection = gTasks[taskId].data[TD_STARTERSELECTION]; - - if(gMain.newKeys & A_BUTTON) + u8 selection = gTasks[taskId].tStarterSelection; + + if (gMain.newKeys & A_BUTTON) { u8 spriteId; - + MenuZeroFillWindowRect( gStarterChoose_LabelCoords[selection][0], gStarterChoose_LabelCoords[selection][1], gStarterChoose_LabelCoords[selection][0] + 13, gStarterChoose_LabelCoords[selection][1] + 3); - + REG_WIN0H = 0; REG_WIN0V = 0; - + //Create white circle background spriteId = CreateSprite( &gSpriteTemplate_83F77FC, gStarterChoose_PokeballCoords[selection][0], gStarterChoose_PokeballCoords[selection][1], 1); - gTasks[taskId].data[TD_CIRCLE_SPRITE_ID] = spriteId; - + gTasks[taskId].tCircleSpriteId = spriteId; + //Create Pokemon sprite spriteId = CreatePokemonFrontSprite( - GetStarterPokemon(gTasks[taskId].data[TD_STARTERSELECTION]), + GetStarterPokemon(gTasks[taskId].tStarterSelection), gStarterChoose_PokeballCoords[selection][0], gStarterChoose_PokeballCoords[selection][1]); - gSprites[spriteId].affineAnims = gUnknown_083F778C; + gSprites[spriteId].affineAnims = gSpriteAffineAnimTable_83F778C; gSprites[spriteId].callback = StarterPokemonSpriteAnimCallback; - gTasks[taskId].data[TD_PKMN_SPRITE_ID] = spriteId; - + gTasks[taskId].tPkmnSpriteId = spriteId; + gTasks[taskId].func = Task_StarterChoose3; } else { - if((gMain.newKeys & DPAD_LEFT) && selection > 0) + if ((gMain.newKeys & DPAD_LEFT) && selection > 0) { - gTasks[taskId].data[TD_STARTERSELECTION]--; - CreateStarterPokemonLabel(selection, gTasks[taskId].data[TD_STARTERSELECTION]); + gTasks[taskId].tStarterSelection--; + CreateStarterPokemonLabel(selection, gTasks[taskId].tStarterSelection); } - else if((gMain.newKeys & DPAD_RIGHT) && selection < 2) + else if ((gMain.newKeys & DPAD_RIGHT) && selection < 2) { - gTasks[taskId].data[TD_STARTERSELECTION]++; - CreateStarterPokemonLabel(selection, gTasks[taskId].data[TD_STARTERSELECTION]); + gTasks[taskId].tStarterSelection++; + CreateStarterPokemonLabel(selection, gTasks[taskId].tStarterSelection); } } } static void Task_StarterChoose3(u8 taskId) { - if(gSprites[gTasks[taskId].data[TD_CIRCLE_SPRITE_ID]].affineAnimEnded && - gSprites[gTasks[taskId].data[TD_CIRCLE_SPRITE_ID]].pos1.x == STARTER_PKMN_POS_X && - gSprites[gTasks[taskId].data[TD_CIRCLE_SPRITE_ID]].pos1.y == STARTER_PKMN_POS_Y) + if (gSprites[gTasks[taskId].tCircleSpriteId].affineAnimEnded && + gSprites[gTasks[taskId].tCircleSpriteId].pos1.x == STARTER_PKMN_POS_X && + gSprites[gTasks[taskId].tCircleSpriteId].pos1.y == STARTER_PKMN_POS_Y) { gTasks[taskId].func = Task_StarterChoose4; } @@ -249,7 +423,7 @@ static void Task_StarterChoose3(u8 taskId) static void Task_StarterChoose4(u8 taskId) { - PlayCry1(GetStarterPokemon(gTasks[taskId].data[TD_STARTERSELECTION]), 0); + PlayCry1(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0); MenuDrawTextWindow(2, 14, 27, 19); //"Do you choose this POKEMON?" MenuPrint(gOtherText_DoYouChoosePoke, 3, 15); @@ -260,29 +434,29 @@ static void Task_StarterChoose4(u8 taskId) static void Task_StarterChoose5(u8 taskId) { u8 spriteId; - - switch(ProcessMenuInputNoWrap_()) + + switch (ProcessMenuInputNoWrap_()) { - case 0: //YES - //Return the starter choice and exit. - gScriptResult = gTasks[taskId].data[TD_STARTERSELECTION]; - SetMainCallback2(gMain.field_8); - break; - case 1: //NO - case -1: //B button - PlaySE(SE_SELECT); - MenuZeroFillWindowRect(21, 7, 27, 12); - - spriteId = gTasks[taskId].data[TD_PKMN_SPRITE_ID]; - FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(gSprites[spriteId].oam.paletteNum)); - FreeOamMatrix(gSprites[spriteId].oam.matrixNum); - DestroySprite(&gSprites[spriteId]); - - spriteId = gTasks[taskId].data[TD_CIRCLE_SPRITE_ID]; - FreeOamMatrix(gSprites[spriteId].oam.matrixNum); - DestroySprite(&gSprites[spriteId]); - gTasks[taskId].func = Task_StarterChoose6; - break; + case 0: // YES + //Return the starter choice and exit. + gScriptResult = gTasks[taskId].tStarterSelection; + SetMainCallback2(gMain.savedCallback); + break; + case 1: // NO + case -1: // B button + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(21, 7, 27, 12); + + spriteId = gTasks[taskId].tPkmnSpriteId; + FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(gSprites[spriteId].oam.paletteNum)); + FreeOamMatrix(gSprites[spriteId].oam.matrixNum); + DestroySprite(&gSprites[spriteId]); + + spriteId = gTasks[taskId].tCircleSpriteId; + FreeOamMatrix(gSprites[spriteId].oam.matrixNum); + DestroySprite(&gSprites[spriteId]); + gTasks[taskId].func = Task_StarterChoose6; + break; } } @@ -291,7 +465,7 @@ static void Task_StarterChoose6(u8 taskId) gTasks[taskId].func = Task_StarterChoose1; } -static void AddTextColorCtrlCode(u8 *string, u8 bgColor, u8 textColor, u8 shadowColor) +void AddTextColorCtrlCode(u8 *string, u8 bgColor, u8 textColor, u8 shadowColor) { *(string++) = EXT_CTRL_CODE_BEGIN; *(string++) = 4; @@ -306,20 +480,22 @@ static void AddTextColorCtrlCode(u8 *string, u8 bgColor, u8 textColor, u8 shadow *p = c; \ } + +#if ENGLISH static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) { u8 labelText[72]; - u8 *category; + const u8 *category; u8 srcIndex; u8 dstIndex; u16 species; - + u8 labelLeft; u8 labelRight; u8 labelTop; u8 labelBottom; - - if(prevSelection != 0xFF) + + if (prevSelection != 0xFF) { //Remove the old Pokemon label MenuZeroFillWindowRect( @@ -337,18 +513,18 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) SET_CHAR(labelText, 5, EXT_CTRL_CODE_BEGIN); SET_CHAR(labelText, 6, 0x11); SET_CHAR(labelText, 7, dstIndex); - + //Copy category string to label dstIndex = 8; srcIndex = 0; - while(category[srcIndex] != EOS && srcIndex <= 10) + while (category[srcIndex] != EOS && srcIndex <= 10) { labelText[dstIndex] = category[srcIndex]; srcIndex++; dstIndex++; } labelText[dstIndex++] = CHAR_SPACE; - + //Copy POKEMON string to label StringCopy(labelText + dstIndex, gOtherText_Poke); MenuPrint( @@ -356,14 +532,14 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) gStarterChoose_LabelCoords[selection][0], gStarterChoose_LabelCoords[selection][1]); AddTextColorCtrlCode(labelText, 0, 15, 8); - + //Copy Pokemon name to label sub_8072C74(labelText + 5, gSpeciesNames[species], 0x6B, 1); MenuPrint( labelText, gStarterChoose_LabelCoords[selection][0], gStarterChoose_LabelCoords[selection][1] + 2); - + labelLeft = gStarterChoose_LabelCoords[selection][0] * 8 + 4; labelRight = (gStarterChoose_LabelCoords[selection][0] + 13) * 8 + 4; labelTop = gStarterChoose_LabelCoords[selection][1] * 8; @@ -371,19 +547,173 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) REG_WIN0H = WIN_RANGE(labelLeft, labelRight); REG_WIN0V = WIN_RANGE(labelTop, labelBottom); } +#elif GERMAN +__attribute__((naked)) +static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + sub sp, 0x48\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + lsls r1, 24\n\ + lsrs r5, r1, 24\n\ + cmp r0, 0xFF\n\ + beq _0810A872\n\ + ldr r1, _0810A960 @ =gStarterChoose_LabelCoords\n\ + lsls r2, r0, 1\n\ + adds r0, r2, r1\n\ + ldrb r0, [r0]\n\ + adds r1, 0x1\n\ + adds r2, r1\n\ + ldrb r1, [r2]\n\ + adds r2, r0, 0\n\ + adds r2, 0xD\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + adds r3, r1, 0x3\n\ + lsls r3, 24\n\ + lsrs r3, 24\n\ + bl MenuZeroFillWindowRect\n\ + ldr r0, _0810A964 @ =0x04000040\n\ + movs r1, 0\n\ + strh r1, [r0]\n\ + adds r0, 0x4\n\ + strh r1, [r0]\n\ +_0810A872:\n\ + adds r0, r5, 0\n\ + bl GetStarterPokemon\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ + adds r0, r6, 0\n\ + bl SpeciesToNationalPokedexNum\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + bl GetPokemonCategory\n\ + adds r4, r0, 0\n\ + mov r0, sp\n\ + movs r1, 0\n\ + movs r2, 0xF\n\ + movs r3, 0x8\n\ + bl AddTextColorCtrlCode\n\ + movs r2, 0x8\n\ + movs r3, 0\n\ + ldrb r0, [r4]\n\ + lsls r5, 1\n\ + mov r7, sp\n\ + adds r7, 0x5\n\ + cmp r0, 0xFF\n\ + beq _0810A8CA\n\ +_0810A8A8:\n\ + mov r0, sp\n\ + adds r1, r0, r2\n\ + adds r0, r4, r3\n\ + ldrb r0, [r0]\n\ + strb r0, [r1]\n\ + adds r0, r3, 0x1\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + adds r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + adds r0, r4, r3\n\ + ldrb r0, [r0]\n\ + cmp r0, 0xFF\n\ + beq _0810A8CA\n\ + cmp r3, 0xA\n\ + bls _0810A8A8\n\ +_0810A8CA:\n\ + mov r0, sp\n\ + adds r1, r0, r2\n\ + movs r0, 0xFF\n\ + strb r0, [r1]\n\ + mov r1, sp\n\ + movs r0, 0xFC\n\ + strb r0, [r1, 0x5]\n\ + movs r0, 0x11\n\ + strb r0, [r1, 0x6]\n\ + mov r2, sp\n\ + lsls r1, r3, 1\n\ + adds r1, r3\n\ + lsls r1, 1\n\ + movs r0, 0x70\n\ + subs r0, r1\n\ + asrs r0, 1\n\ + strb r0, [r2, 0x7]\n\ + ldr r0, _0810A960 @ =gStarterChoose_LabelCoords\n\ + adds r1, r5, r0\n\ + ldrb r4, [r1]\n\ + adds r0, 0x1\n\ + adds r0, r5, r0\n\ + ldrb r5, [r0]\n\ + mov r0, sp\n\ + adds r1, r4, 0\n\ + adds r2, r5, 0\n\ + bl MenuPrint\n\ + mov r0, sp\n\ + movs r1, 0\n\ + movs r2, 0xF\n\ + movs r3, 0x8\n\ + bl AddTextColorCtrlCode\n\ + movs r0, 0xB\n\ + adds r1, r6, 0\n\ + muls r1, r0\n\ + ldr r0, _0810A968 @ =gSpeciesNames\n\ + adds r1, r0\n\ + adds r0, r7, 0\n\ + movs r2, 0x70\n\ + movs r3, 0x2\n\ + bl sub_8072C74\n\ + adds r2, r5, 0x2\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + mov r0, sp\n\ + adds r1, r4, 0\n\ + bl MenuPrint\n\ + lsls r0, r4, 3\n\ + adds r0, 0x4\n\ + lsls r0, 24\n\ + adds r4, 0xD\n\ + lsls r4, 3\n\ + adds r4, 0x4\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + lsls r1, r5, 27\n\ + adds r5, 0x4\n\ + lsls r5, 27\n\ + lsrs r5, 24\n\ + ldr r2, _0810A964 @ =0x04000040\n\ + lsrs r0, 16\n\ + orrs r0, r4\n\ + strh r0, [r2]\n\ + ldr r0, _0810A96C @ =0x04000044\n\ + lsrs r1, 16\n\ + orrs r1, r5\n\ + strh r1, [r0]\n\ + add sp, 0x48\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_0810A960: .4byte gStarterChoose_LabelCoords\n\ +_0810A964: .4byte 0x04000040\n\ +_0810A968: .4byte gSpeciesNames\n\ +_0810A96C: .4byte 0x04000044\n\ + .syntax divided\n"); +} +#endif -void nullsub_72(struct Sprite *sprite) +static void nullsub_72(struct Sprite *sprite) { - } static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y) { u8 spriteId; - + DecompressPicFromTable_2( &gMonFrontPicTable[species], - gMonFrontPicCoords[species].x, gMonFrontPicCoords[species].y, + gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, gUnknown_081FAF4C[0], gUnknown_081FAF4C[1], species); LoadCompressedObjectPalette(&gMonPaletteTable[species]); @@ -395,33 +725,33 @@ static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y) } //Sprite callback -void sub_810A62C(struct Sprite *sprite) +static void sub_810A62C(struct Sprite *sprite) { - sprite->pos1.x = gUnknown_083F76E4[gTasks[sprite->data0].data[TD_STARTERSELECTION]][0]; - sprite->pos1.y = gUnknown_083F76E4[gTasks[sprite->data0].data[TD_STARTERSELECTION]][1]; + sprite->pos1.x = gUnknown_083F76E4[gTasks[sprite->data0].tStarterSelection][0]; + sprite->pos1.y = gUnknown_083F76E4[gTasks[sprite->data0].tStarterSelection][1]; sprite->pos2.y = Sin(sprite->data1, 8); sprite->data1 = (u8)sprite->data1 + 4; } //Sprite callback -void sub_810A68C(struct Sprite *sprite) +static void sub_810A68C(struct Sprite *sprite) { - if(gTasks[sprite->data0].data[TD_STARTERSELECTION] == sprite->data1) + if (gTasks[sprite->data0].tStarterSelection == sprite->data1) StartSpriteAnimIfDifferent(sprite, 1); else StartSpriteAnimIfDifferent(sprite, 0); } //Sprite callback -void StarterPokemonSpriteAnimCallback(struct Sprite *sprite) +static void StarterPokemonSpriteAnimCallback(struct Sprite *sprite) { //Move sprite to upper center of screen - if(sprite->pos1.x > STARTER_PKMN_POS_X) + if (sprite->pos1.x > STARTER_PKMN_POS_X) sprite->pos1.x -= 4; - if(sprite->pos1.x < STARTER_PKMN_POS_X) + if (sprite->pos1.x < STARTER_PKMN_POS_X) sprite->pos1.x += 4; - if(sprite->pos1.y > STARTER_PKMN_POS_Y) + if (sprite->pos1.y > STARTER_PKMN_POS_Y) sprite->pos1.y -= 2; - if(sprite->pos1.y < STARTER_PKMN_POS_Y) + if (sprite->pos1.y < STARTER_PKMN_POS_Y) sprite->pos1.y += 2; } diff --git a/src/string_util.c b/src/string_util.c index a7f9c3d1f..9686256a1 100644 --- a/src/string_util.c +++ b/src/string_util.c @@ -1,30 +1,14 @@ #include "global.h" #include "string_util.h" +#include "strings.h" #include "text.h" -#define MAX_PLACEHOLDER_ID 0xD - -static u8 *ExpandPlaceholder_UnknownStringVar(void); -static u8 *ExpandPlaceholder_PlayerName(void); -static u8 *ExpandPlaceholder_StringVar1(void); -static u8 *ExpandPlaceholder_StringVar2(void); -static u8 *ExpandPlaceholder_StringVar3(void); -static u8 *ExpandPlaceholder_KunChan(void); -static u8 *ExpandPlaceholder_RivalName(void); -static u8 *ExpandPlaceholder_Version(void); -static u8 *ExpandPlaceholder_EvilTeam(void); -static u8 *ExpandPlaceholder_GoodTeam(void); -static u8 *ExpandPlaceholder_EvilLeader(void); -static u8 *ExpandPlaceholder_GoodLeader(void); -static u8 *ExpandPlaceholder_EvilLegendary(void); -static u8 *ExpandPlaceholder_GoodLegendary(void); - u8 gUnknownStringVar[16]; -const u8 gEmptyString_81E72B0[] = _""; -const u8 gRightPointingTriangleString[] = _"▶"; +const u8 gEmptyString_81E72B0[] = _(""); +const u8 gRightPointingTriangleString[] = _("▶"); -static const u8 sDigits[] = @"0123456789ABCDEF"; +static const u8 sDigits[] = __("0123456789ABCDEF"); static const s32 sPowersOfTen[] = { @@ -40,43 +24,6 @@ static const s32 sPowersOfTen[] = 1000000000, }; -static const u8 sSetBrailleFont[] = { 0xFC, 0x06, 0x06, 0xFF }; -static const u8 sGotoLine2[] = { 0xFE, 0xFC, 0x0E, 0x02, 0xFF }; - -typedef u8 *(*ExpandPlaceholderFunc)(void); - -static const ExpandPlaceholderFunc sExpandPlaceholderFuncs[] = -{ - ExpandPlaceholder_UnknownStringVar, - ExpandPlaceholder_PlayerName, - ExpandPlaceholder_StringVar1, - ExpandPlaceholder_StringVar2, - ExpandPlaceholder_StringVar3, - ExpandPlaceholder_KunChan, - ExpandPlaceholder_RivalName, - ExpandPlaceholder_Version, - ExpandPlaceholder_EvilTeam, - ExpandPlaceholder_GoodTeam, - ExpandPlaceholder_EvilLeader, - ExpandPlaceholder_GoodLeader, - ExpandPlaceholder_EvilLegendary, - ExpandPlaceholder_GoodLegendary, -}; - -extern u8 gExpandedPlaceholder_Empty[]; -extern u8 gExpandedPlaceholder_Kun[]; -extern u8 gExpandedPlaceholder_Chan[]; -extern u8 gExpandedPlaceholder_Sapphire[]; -extern u8 gExpandedPlaceholder_Ruby[]; -extern u8 gExpandedPlaceholder_Aqua[]; -extern u8 gExpandedPlaceholder_Magma[]; -extern u8 gExpandedPlaceholder_Archie[]; -extern u8 gExpandedPlaceholder_Maxie[]; -extern u8 gExpandedPlaceholder_Kyogre[]; -extern u8 gExpandedPlaceholder_Groudon[]; -extern u8 gExpandedPlaceholder_Brendan[]; -extern u8 gExpandedPlaceholder_May[]; - u8 *StringCopy10(u8 *dest, const u8 *src) { u8 i; @@ -177,6 +124,21 @@ u16 StringLength(const u8 *str) return length; } +#ifdef GERMAN +s32 StringLengthN(const u8 *str, s32 n) +{ + s32 i; + + for (i = 0; i < n && str[i] != EOS; i++) + ; + + if (i == n) + i = 0; + + return i; +} +#endif + s32 StringCompare(const u8 *str1, const u8 *str2) { while (*str1 == *str2) @@ -445,11 +407,8 @@ u8 *StringExpandPlaceholders(u8 *dest, const u8 *src) u8 *StringBraille(u8 *dest, const u8 *src) { - u8 setBrailleFont[4]; - u8 gotoLine2[5]; - - memcpy(setBrailleFont, sSetBrailleFont, 4); - memcpy(gotoLine2, sGotoLine2, 5); + u8 setBrailleFont[] = { 0xFC, 0x06, 0x06, 0xFF }; + u8 gotoLine2[] = { 0xFE, 0xFC, 0x0E, 0x02, 0xFF }; dest = StringCopy(dest, setBrailleFont); @@ -473,45 +432,45 @@ u8 *StringBraille(u8 *dest, const u8 *src) } } -u8 *ExpandPlaceholder_UnknownStringVar(void) +static u8 *ExpandPlaceholder_UnknownStringVar(void) { return gUnknownStringVar; } -u8 *ExpandPlaceholder_PlayerName(void) +static u8 *ExpandPlaceholder_PlayerName(void) { return gSaveBlock2.playerName; } -u8 *ExpandPlaceholder_StringVar1(void) +static u8 *ExpandPlaceholder_StringVar1(void) { return gStringVar1; } -u8 *ExpandPlaceholder_StringVar2(void) +static u8 *ExpandPlaceholder_StringVar2(void) { return gStringVar2; } -u8 *ExpandPlaceholder_StringVar3(void) +static u8 *ExpandPlaceholder_StringVar3(void) { return gStringVar3; } -u8 *ExpandPlaceholder_KunChan(void) +static u8 *ExpandPlaceholder_KunChan(void) { if (gSaveBlock2.playerGender == MALE) - return gExpandedPlaceholder_Kun; + return (u8 *) gExpandedPlaceholder_Kun; else - return gExpandedPlaceholder_Chan; + return (u8 *) gExpandedPlaceholder_Chan; } -u8 *ExpandPlaceholder_RivalName(void) +static u8 *ExpandPlaceholder_RivalName(void) { if (gSaveBlock2.playerGender == MALE) - return gExpandedPlaceholder_May; + return (u8 *) gExpandedPlaceholder_May; else - return gExpandedPlaceholder_Brendan; + return (u8 *) gExpandedPlaceholder_Brendan; } #define VERSION_DEPENDENT_PLACEHOLDER_LIST \ @@ -525,11 +484,11 @@ u8 *ExpandPlaceholder_RivalName(void) #ifdef SAPPHIRE #define X(ph, r, s) \ -static u8 *ExpandPlaceholder_##ph(void) { return gExpandedPlaceholder_##s; } +static u8 *ExpandPlaceholder_##ph(void) { return (u8 *) gExpandedPlaceholder_##s; } VERSION_DEPENDENT_PLACEHOLDER_LIST #else #define X(ph, r, s) \ -static u8 *ExpandPlaceholder_##ph(void) { return gExpandedPlaceholder_##r; } +static u8 *ExpandPlaceholder_##ph(void) { return (u8 *) gExpandedPlaceholder_##r; } VERSION_DEPENDENT_PLACEHOLDER_LIST #endif @@ -537,10 +496,30 @@ VERSION_DEPENDENT_PLACEHOLDER_LIST u8 *GetExpandedPlaceholder(u32 id) { - if (id > MAX_PLACEHOLDER_ID) - return gExpandedPlaceholder_Empty; + typedef u8 *(*ExpandPlaceholderFunc)(void); + + static const ExpandPlaceholderFunc funcs[] = + { + ExpandPlaceholder_UnknownStringVar, + ExpandPlaceholder_PlayerName, + ExpandPlaceholder_StringVar1, + ExpandPlaceholder_StringVar2, + ExpandPlaceholder_StringVar3, + ExpandPlaceholder_KunChan, + ExpandPlaceholder_RivalName, + ExpandPlaceholder_Version, + ExpandPlaceholder_EvilTeam, + ExpandPlaceholder_GoodTeam, + ExpandPlaceholder_EvilLeader, + ExpandPlaceholder_GoodLeader, + ExpandPlaceholder_EvilLegendary, + ExpandPlaceholder_GoodLegendary, + }; + + if (id >= ARRAY_COUNT(funcs)) + return (u8 *) gExpandedPlaceholder_Empty; else - return sExpandPlaceholderFuncs[id](); + return funcs[id](); } u8 *StringFill(u8 *dest, u8 c, u16 n) diff --git a/src/strings.c b/src/strings.c new file mode 100644 index 000000000..cc0641dce --- /dev/null +++ b/src/strings.c @@ -0,0 +1,1846 @@ +#include "global.h" +#include "strings.h" + +#if ENGLISH +// placeholder strings +const u8 gExpandedPlaceholder_Empty[] = _(""); +const u8 gExpandedPlaceholder_Kun[] = _(""); +const u8 gExpandedPlaceholder_Chan[] = _(""); +const u8 gExpandedPlaceholder_Sapphire[] = _("SAPPHIRE"); +const u8 gExpandedPlaceholder_Ruby[] = _("RUBY"); +const u8 gExpandedPlaceholder_Aqua[] = _("AQUA"); +const u8 gExpandedPlaceholder_Magma[] = _("MAGMA"); +const u8 gExpandedPlaceholder_Archie[] = _("ARCHIE"); +const u8 gExpandedPlaceholder_Maxie[] = _("MAXIE"); +const u8 gExpandedPlaceholder_Kyogre[] = _("KYOGRE"); +const u8 gExpandedPlaceholder_Groudon[] = _("GROUDON"); +const u8 gExpandedPlaceholder_Brendan[] = _("BRENDAN"); +const u8 gExpandedPlaceholder_May[] = _("MAY"); + +// system text +const u8 gSystemText_Egg[] = _("EGG"); +const u8 gSystemText_Pokemon2[] = _("POKéMON"); + +// main menu text +const u8 gMainMenuString_NewGame[] = _("NEW GAME"); +const u8 gMainMenuString_Continue[] = _("CONTINUE"); +const u8 gMainMenuString_Option[] = _("OPTION"); +const u8 gMainMenuString_MysteryEvents[] = _("MYSTERY EVENTS"); + +// system text 2 +const u8 SystemText_UpdatingSaveExternal[] = _("Updating save file using external\ndata. Please wait."); +const u8 SystemText_SaveUpdated[] = _("The save file has been updated."); +const u8 SystemText_SaveUpdatedExchangeBackup[] = _("The save file has been updated.\pFurther game data cannot be saved\nto the backup memory.\pPlease exchange the backup memory.\pFor details, please contact the\nNintendo Service Center."); +const u8 SystemText_SaveNotUpdated[] = _("The save file could not be updated.\pPlease exchange the backup\nmemory.\pFor details, please contact the\nNintendo Service Center."); + +// save file text +const u8 gSaveFileCorruptMessage[] = _("The save file is corrupt. The\nprevious save file will be loaded."); +const u8 gSaveFileDeletedMessage[] = _(" The save file has been deleted..."); + +// system text 3 +const u8 gBoardNotInstalledMessage[] = _("The 1M sub-circuit board is\nnot installed."); +const u8 gBatteryDryMessage[] = _("The internal battery has run dry.\nThe game can be played.\pHowever, clock-based events will\nno longer occur."); + +// main menu text 2 +const u8 gMainMenuString_Player[] = _("PLAYER"); +const u8 gMainMenuString_Pokedex[] = _("POKéDEX"); +const u8 gMainMenuString_Time[] = _("TIME"); +const u8 gMainMenuString_Badges[] = _("BADGES"); + +// birch text +const u8 gBirchText_Boy[] = _("BOY"); +const u8 gBirchText_Girl[] = _("GIRL"); +const u8 gBirchText_NewName[] = _("NEW NAME"); + +#ifdef SAPPHIRE +const u8 gDefaultBoyName1[] = _("SEAN"); +#else +const u8 gDefaultBoyName1[] = _("LANDON"); +#endif +const u8 gDefaultBoyName2[] = _("TERRY"); +const u8 gDefaultBoyName3[] = _("SETH"); +const u8 gDefaultBoyName4[] = _("TOM"); + +#ifdef SAPPHIRE +const u8 gDefaultGirlName1[] = _("MARINA"); +#else +const u8 gDefaultGirlName1[] = _("TERRA"); +#endif +const u8 gDefaultGirlName2[] = _("KIMMY"); +const u8 gDefaultGirlName3[] = _("NICOLA"); +const u8 gDefaultGirlName4[] = _("SARA"); + +const u8 gSystemText_IntroWeCall[] = _("This is what we call\na POKéMON."); +const u8 gSystemText_NewPara[] = _("\p"); + +const u8 gDexText_UnknownPoke[] = _(" ????? POKéMON"); +const u8 gDexText_UnknownHeight[] = _("{CLEAR_TO 0x0C}??’??”"); +const u8 gDexText_UnknownWeight[] = _("????.? lbs.$"); // extra terminator? +const u8 gDexText_CryOf[] = _("{CLEAR_TO 2}CRY OF$"); // extra terminator? +const u8 gDexText_SizeComparedTo[] = _("SIZE COMPARED TO "); +const u8 gDexText_RegisterComplete[] = _("POKéDEX registration completed."); +const u8 gDexText_Searching[] = _("Searching...\nPlease wait."); +const u8 gDexText_SearchComplete[] = _("Search completed."); +const u8 gDexText_NoMatching[] = _("No matching POKéMON were found."); + +const u8 DexText_SearchForPoke[] = _("Search for POKéMON based on\nselected parameters."); +const u8 DexText_SwitchDex[] = _("Switch POKéDEX listings."); +const u8 DexText_ReturnToDex[] = _("Return to the POKéDEX."); +const u8 DexText_SelectDexMode[] = _("Select the POKéDEX mode."); +const u8 DexText_SelectDexList[] = _("Select the POKéDEX listing mode."); +const u8 DexText_ListByABC[] = _("List by the first letter in the name.\n/Spotted POKéMON only."); +const u8 DexText_ListByColor[] = _("List by body color.\n/Spotted POKéMON only."); +const u8 DexText_ListByType[] = _("List by type.\n/Owned POKéMON only."); +const u8 DexText_ExecuteSearchSwitch[] = _("Execute search/switch."); +const u8 DexText_HoennDex[] = _("HOENN DEX"); +const u8 DexText_NationalDex[] = _("NATIONAL DEX"); +const u8 DexText_NumericalMode[] = _("NUMERICAL MODE"); +const u8 DexText_ABCMode[] = _("A TO Z MODE"); +const u8 DexText_HeaviestMode[] = _("HEAVIEST MODE"); +const u8 DexText_LightestMode[] = _("LIGHTEST MODE"); +const u8 DexText_TallestMode[] = _("TALLEST MODE"); +const u8 DexText_SmallestMode[] = _("SMALLEST MODE"); +const u8 DexText_ABC[] = _("ABC"); +const u8 DexText_DEF[] = _("DEF"); +const u8 DexText_GHI[] = _("GHI"); +const u8 DexText_JKL[] = _("JKL"); +const u8 DexText_MNO[] = _("MNO"); +const u8 DexText_PQR[] = _("PQR"); +const u8 DexText_STU[] = _("STU"); +const u8 DexText_VWX[] = _("VWX"); +const u8 DexText_YZ[] = _("YZ"); +const u8 DexText_Red[] = _("RED"); +const u8 DexText_Blue[] = _("BLUE"); +const u8 DexText_Yellow[] = _("YELLOW"); +const u8 DexText_Green[] = _("GREEN"); +const u8 DexText_Black[] = _("BLACK"); +const u8 DexText_Brown[] = _("BROWN"); +const u8 DexText_Purple[] = _("PURPLE"); +const u8 DexText_Gray[] = _("GRAY"); +const u8 DexText_White[] = _("WHITE"); +const u8 DexText_Pink[] = _("PINK"); +const u8 DexText_HoennDex2[] = _("HOENN region’s POKéDEX"); +const u8 DexText_NationalDex2[] = _("National edition POKéDEX"); +const u8 DexText_ListByNumber[] = _("POKéMON are listed according to their\nnumber."); +const u8 DexText_ListByABC2[] = _("Spotted and owned POKéMON are listed\nalphabetically."); +const u8 DexText_ListByHeavyToLightest[] = _("Owned POKéMON are listed from the\nheaviest to the lightest."); +const u8 DexText_ListByLightToHeaviest[] = _("Owned POKéMON are listed from the\nlightest to the heaviest."); +const u8 DexText_ListByTallToSmallest[] = _("Owned POKéMON are listed from the\ntallest to the smallest."); +const u8 DexText_ListBySmallToTallest[] = _("Owned POKéMON are listed from the\nsmallest to the tallest."); +const u8 DexText_Terminator5[] = _(""); +const u8 DexText_DontSpecify[] = _("DON’T SPECIFY."); +const u8 DexText_None[] = _("NONE"); +const u8 DexText_RightPointingTriangle[] = _("▶"); // right pointing triangle +const u8 DexText_Terminator6[] = _(" "); + +const u8 gMenuText_WelcomeToHOFAndDexRating[] = _("Welcome to the HALL OF FAME!$Spotted POKéMON: {STR_VAR_1}!\nOwned POKéMON: {STR_VAR_2}!\pPROF. BIRCH’s POKéDEX rating!\pPROF. BIRCH: Let’s see...\p"); +const u8 gMenuText_HOFSaving[] = _("SAVING...\nDON’T TURN OFF THE POWER."); +const u8 gMenuText_HOFCorrupt[] = _("The HALL OF FAME data is corrupt."); +const u8 gMenuText_HOFNumber[] = _("HALL OF FAME No. "); +const u8 gMenuText_HOFCongratulations[] = _("LEAGUE CHAMPION!\nCONGRATULATIONS!"); + +const u8 gOtherText_Number2[] = _("No. "); +const u8 gOtherText_Level3[] = _("Lv. "); +const u8 gOtherText_IDNumber[] = _("IDNo. /"); +const u8 gOtherText_Name[] = _("NAME /"); +const u8 gOtherText_IDNumber2[] = _("IDNo. /"); +const u8 gOtherText_BirchInTrouble[] = _("{HIGHLIGHT WHITE2}{COLOR DARK_GREY}PROF. BIRCH is in trouble!\nRelease a POKéMON and rescue him!"); +const u8 gOtherText_DoYouChoosePoke[] = _("{HIGHLIGHT WHITE2}{COLOR DARK_GREY}Do you choose this POKéMON?"); +const u8 gOtherText_Poke[] = _("POKéMON"); + +const u8 gSystemText_SaveErrorExchangeBackup[] = _("Save error.\pPlease exchange the\nbackup memory."); +const u8 gOtherText_FlyToWhere[] = _("FLY to where?"); + +const u8 OtherText_Use[] = _("USE"); +const u8 OtherText_Toss[] = _("TOSS"); +const u8 OtherText_Register[] = _("REGISTER"); +const u8 OtherText_Give2[] = _("GIVE"); +const u8 OtherText_CheckTag[] = _("CHECK TAG"); +const u8 OtherText_Confirm[] = _("CONFIRM"); +const u8 gOtherText_Walk[] = _("WALK"); + +const u8 gUnknownText_Exit[] = _("EXIT"); +const u8 gOtherText_CancelNoTerminator[] = _("CANCEL"); +const u8 gOtherText_CancelWithTerminator[] = _("$CANCEL"); // with terminator at beginning? + +const u8 OtherText_Item[] = _("ITEM"); +const u8 OtherText_Mail[] = _("MAIL"); +const u8 OtherText_Take2[] = _("TAKE"); +const u8 OtherText_Store[] = _("STORE"); + +const u8 gOtherText_Check[] = _("CHECK"); +const u8 gOtherText_None[] = _("NONE"); + +const u8 gOtherText_ThreeQuestions2[] = _("???"); + +const u8 gOtherText_FiveQuestionsAndSlash[] = _("?????$/"); + +const u8 gOtherText_OneDash[] = _("-"); +const u8 gOtherText_TwoDashes[] = _("--"); +const u8 gOtherText_ThreeDashes2[] = _("---"); +const u8 gOtherText_MaleSymbol2[] = _("♂"); +const u8 gOtherText_FemaleSymbolAndLv[] = _("♀$Lv."); +const u8 gOtherText_TallPlusAndRightArrow[] = _("{TALL_PLUS}${RIGHT_ARROW}"); +const u8 gMenuText_GoBackToPrev[] = _("Go back to the\nprevious menu."); +const u8 gOtherText_WhatWillYouDo[] = _("What would you like to do?"); + +const u8 gOtherText_xString1[] = _("×{STR_VAR_1}"); +const u8 gOtherText_Berry2[] = _(" BERRY"); +const u8 gOtherText_Coins2[] = _("{STR_VAR_1} COINS"); +const u8 gOtherText_CloseBag[] = _("CLOSE BAG"); + +const u8 OtherText_TheField3[] = _("the field."); +const u8 OtherText_TheBattle[] = _("the battle."); +const u8 OtherText_ThePokeList[] = _("the POKéMON LIST."); +const u8 OtherText_TheShop[] = _("the shop."); +const u8 OtherText_TheField[] = _("the field."); +const u8 OtherText_TheField2[] = _("the field."); +const u8 OtherText_ThePC[] = _("the PC."); + +const struct TextStruct gUnknown_0840E740[7] = +{ + OtherText_TheField3, + OtherText_TheBattle, + OtherText_ThePokeList, + OtherText_TheShop, + OtherText_TheField, + OtherText_TheField2, + OtherText_ThePC, +}; + +const u8 gOtherText_ReturnTo[] = _("Return to"); +const u8 gOtherText_WhatWillYouDo2[] = _("What would you\nlike to do?"); +const u8 gOtherText_CantWriteMail[] = _("You can’t write\nMAIL here."); +const u8 gOtherText_NoPokemon[] = _("There is no\nPOKéMON.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_SwitchWhichItem[] = _("Switch with which\nitem?"); +const u8 gOtherText_CantBeHeld[] = _("{STR_VAR_1} can’t be held."); +const u8 gOtherText_CantBeHeldHere[] = _("{STR_VAR_1} can’t be held here."); +const u8 gOtherText_HowManyToDeposit[] = _("How many do you\nwant to deposit?"); +const u8 gOtherText_DepositedItems[] = _("Deposited {STR_VAR_2}\n{STR_VAR_1}(s)."); +const u8 gOtherText_NoRoomForItems[] = _("There’s no room to\nstore items."); +const u8 gOtherText_CantStoreSomeoneItem[] = _("You can’t store\nsomeone else’s item\nin the PC."); +const u8 gOtherText_TooImportant[] = _("That’s much too\nimportant to toss\nout!"); +const u8 gOtherText_HowManyToToss[] = _("Toss out how many?"); +const u8 gOtherText_ThrewAwayItem[] = _("Threw away {STR_VAR_2}\n{STR_VAR_1}(s)."); +const u8 gOtherText_OkayToThrowAwayPrompt[] = _("Is it okay to\nthrow away {STR_VAR_2}\n{STR_VAR_1}(s)?"); +const u8 gOtherText_DadsAdvice[] = _("DAD’s advice...\n{PLAYER}, there’s a time and place for\leverything!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantGetOffBike[] = _("You can’t dismount your BIKE here.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ItemfinderResponding[] = _("Oh!\nThe machine’s responding!\pThere’s an item buried around here!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ItemfinderItemUnderfoot[] = _("The machine’s indicating something\nright underfoot!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoResponse[] = _("... ... ... ... Nope!\nThere’s no response.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_Coins3[] = _("Your COINS:\n{STR_VAR_1}{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BootedTM[] = _("Booted up a TM."); +const u8 gOtherText_BootedHM[] = _("Booted up an HM."); +const u8 gOtherText_ContainsMove[] = _("It contained\n{STR_VAR_1}.\pTeach {STR_VAR_1}\nto a POKéMON?"); +const u8 gOtherText_UsedItem[] = _("{PLAYER} used the\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_RepelLingers[] = _("But the effects of a REPEL lingered\nfrom earlier.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_UsedFlute[] = _("{PLAYER} used the\n{STR_VAR_2}.\pWild POKéMON will be lured.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_UsedRepel[] = _("{PLAYER} used the\n{STR_VAR_2}.\pWild POKéMON will be repelled.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BoxIsFull[] = _("The BOX is full.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_Size[] = _("SIZE /"); +const u8 gOtherText_Firm[] = _("FIRM /"); + +const u8 gContestStatsText_Unknown1[] = _("{STR_VAR_1}.{STR_VAR_2}”"); + +const u8 ContestStatsText_VerySoft[] = _("Very soft"); +const u8 ContestStatsText_Soft[] = _("Soft"); +const u8 ContestStatsText_Hard[] = _("Hard"); +const u8 ContestStatsText_VeryHard[] = _("Very hard"); +const u8 ContestStatsText_SuperHard[] = _("Super hard"); + +const u8 ContestStatsText_RedPokeBlock[] = _("RED {POKEBLOCK}"); +const u8 ContestStatsText_BluePokeBlock[] = _("BLUE {POKEBLOCK}"); +const u8 ContestStatsText_PinkPokeBlock[] = _("PINK {POKEBLOCK}"); +const u8 ContestStatsText_GreenPokeBlock[] = _("GREEN {POKEBLOCK}"); +const u8 ContestStatsText_YellowPokeBlock[] = _("YELLOW {POKEBLOCK}"); +const u8 ContestStatsText_PurplePokeBlock[] = _("PURPLE {POKEBLOCK}"); +const u8 ContestStatsText_IndigoPokeBlock[] = _("INDIGO {POKEBLOCK}"); +const u8 ContestStatsText_BrownPokeBlock[] = _("BROWN {POKEBLOCK}"); +const u8 ContestStatsText_LiteBluePokeBlock[] = _("LITEBLUE {POKEBLOCK}"); +const u8 ContestStatsText_OlivePokeBlock[] = _("OLIVE {POKEBLOCK}"); +const u8 ContestStatsText_GrayPokeBlock[] = _("GRAY {POKEBLOCK}"); +const u8 ContestStatsText_BlackPokeBlock[] = _("BLACK {POKEBLOCK}"); +const u8 ContestStatsText_WhitePokeBlock[] = _("WHITE {POKEBLOCK}"); +const u8 ContestStatsText_GoldPokeBlock[] = _("GOLD {POKEBLOCK}"); + +const u8 gContestStatsText_Spicy[] = _("SPICY"); +const u8 gContestStatsText_Dry[] = _("DRY"); +const u8 gContestStatsText_Sweet[] = _("SWEET"); +const u8 gContestStatsText_Bitter[] = _("BITTER"); +const u8 gContestStatsText_Sour[] = _("SOUR$TASTY$FEEL"); // tasty is unused, feel might not be + +const u8 gContestStatsText_StowCase[] = _("Stow CASE."); +const u8 gContestStatsText_ThrowAwayPrompt[] = _("Throw away this\n{STR_VAR_1}?"); +const u8 gContestStatsText_WasThrownAway[] = _("The {STR_VAR_1}\nwas thrown away."); +const u8 gContestStatsText_NormallyAte[] = _("{STR_VAR_1} ate the\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gContestStatsText_HappilyAte[] = _("{STR_VAR_1} happily ate the\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gContestStatsText_DisdainfullyAte[] = _("{STR_VAR_1} disdainfully ate the\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); + +const u8 MartText_Buy[] = _("BUY"); +const u8 MartText_Sell[] = _("SELL"); +const u8 MartText_Quit2[] = _("QUIT"); + +const u8 gOtherText_QuitShopping[] = _("Quit shopping."); + +const u8 gOtherText_HowManyYouWant[] = _("{STR_VAR_1}? Certainly.\nHow many would you like?"); +const u8 gOtherText_ThatWillBe[] = _("{STR_VAR_1}? And you wanted {STR_VAR_2}?\nThat will be ¥{STR_VAR_3}."); +const u8 gOtherText_ThatWillBe2[] = _("{STR_VAR_1}, is it?\nThat’ll be ¥{STR_VAR_2}. Do you want it?"); +const u8 gOtherText_ThatWillBe3[] = _("You wanted {STR_VAR_1}?\nThat’ll be ¥{STR_VAR_2}. Will that be okay?"); +const u8 gOtherText_HereYouGo[] = _("Here you go!\nThank you very much."); +const u8 gOtherText_HereYouGo2[] = _("Thank you!\nI’ll send it to your home PC."); +const u8 gOtherText_HereYouGo3[] = _("Thanks!\nI’ll send it to your PC at home."); +const u8 gOtherText_NotEnoughMoney[] = _("You don’t have enough money.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoRoomFor[] = _("You have no more room for items.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_SpaceForIsFull[] = _("The space for {STR_VAR_1} is full.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AnythingElse[] = _("Is there anything else I can help\nyou with?"); +const u8 gOtherText_CanIHelpYou[] = _("Can I help you with anything else?"); +const u8 gOtherText_FreePremierBall[] = _("I’ll throw in a PREMIER BALL, too.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantBuyThat[] = _("{STR_VAR_2}? Oh, no.\nI can’t buy that.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_HowManyToSell[] = _("{STR_VAR_2}?\nHow many would you like to sell?"); +const u8 gOtherText_CanPay[] = _("I can pay ¥{STR_VAR_1}.\nWould that be okay?"); +const u8 gOtherText_SoldItem[] = _("Turned over the {STR_VAR_2}\nand received ¥{STR_VAR_1}."); + +const u8 OtherText_Money[] = _("¥{STR_VAR_1}"); +const u8 OtherText_Shift[] = _("SHIFT"); +const u8 OtherText_SendOut[] = _("SEND OUT"); +const u8 OtherText_Switch2[] = _("SWITCH"); +const u8 OtherText_Summary[] = _("SUMMARY"); +const u8 OtherText_Moves[] = _("MOVES"); +const u8 OtherText_Enter2[] = _("ENTER"); +const u8 OtherText_NoEntry[] = _("NO ENTRY"); +const u8 OtherText_Take[] = _("TAKE"); +const u8 OtherText_Read2[] = _("READ"); + +const u8 gOtherText_Hp2[] = _("HP"); +const u8 gOtherText_SpAtk2[] = _("SP. ATK"); +const u8 gOtherText_SpDef2[] = _("SP. DEF"); +const u8 gOtherText_WontHaveAnyEffect[] = _("It won’t have any effect.{PAUSE_UNTIL_PRESS}"); + +#if REVISION >= 1 +const u8 gOtherText_CantUseOnPoke[] = _("This can’t be used on\nthat POKéMON.{PAUSE_UNTIL_PRESS}"); +#else +const u8 gOtherText_CantUseOnPoke[] = _("This item can’t be used on\nthat POKéMON.{PAUSE_UNTIL_PRESS}"); +#endif + +const u8 gOtherText_CantBeSwitched[] = _("{STR_VAR_1} can’t be switched\nout!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadyBattle[] = _("{STR_VAR_1} is already\nin battle!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadySelected[] = _("{STR_VAR_1} has already been\nselected.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoEnergyLeft[] = _("{STR_VAR_1} has no energy\nleft to battle!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantSwitchPokeWithYours[] = _("You can’t switch {STR_VAR_1}’s\nPOKéMON with one of yours!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_EGGCantBattle[] = _("An EGG can’t battle!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantBeUsedBadge[] = _("This can’t be used until a new\nBADGE is obtained."); +const u8 gOtherText_NoMoreThreePoke[] = _("No more than three POKéMON\nmay enter."); +const u8 gOtherText_SendRemovedMailPrompt[] = _("Send the removed MAIL to\nyour PC?"); +const u8 gOtherText_MailWasSent[] = _("The MAIL was sent to your PC.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailboxIsFull[] = _("Your PC’s MAILBOX is full.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailRemovedMessageLost[] = _("If the MAIL is removed, the\nmessage will be lost. Okay?"); +const u8 gOtherText_MailMustBeRemoved[] = _("MAIL must be removed before\nholding an item.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WasGivenToHold[] = _("{STR_VAR_1} was given the\n{STR_VAR_2} to hold.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadyHolding[] = _("{STR_VAR_1} is already holding\none {STR_VAR_2}.\pWould you like to switch the\ntwo items?"); +const u8 gOtherText_NotHoldingAnything[] = _("{STR_VAR_1} isn’t\nholding anything.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ReceivedTheThingFrom[] = _("Received the {STR_VAR_2}\nfrom {STR_VAR_1}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailTaken[] = _("MAIL was taken from the\nPOKéMON.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_TakenAndReplaced[] = _("The {STR_VAR_2} was taken and\nreplaced with the {STR_VAR_1}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_PokeHoldingItemCantMail[] = _("This POKéMON is holding an item.\nIt cannot hold MAIL.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailTransferredMailbox[] = _("MAIL was transferred from\nthe MAILBOX.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BagFullCannotRemoveItem[] = _("The BAG is full. The POKéMON’s\nitem could not be removed.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_LearnedMove[] = _("{STR_VAR_1} learned\n{STR_VAR_2}!"); +const u8 gOtherText_NotCompatible[] = _("{STR_VAR_1} and {STR_VAR_2}\nare not compatible.\p{STR_VAR_2} can’t be learned.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WantsToLearn[] = _("{STR_VAR_1} wants to learn the\nmove {STR_VAR_2}.\pHowever, {STR_VAR_1} already\nknows four moves.\pShould a move be deleted and\nreplaced with {STR_VAR_2}?"); +const u8 gOtherText_StopTryingTo[] = _("Stop trying to teach\n{STR_VAR_2}?"); +const u8 gOtherText_DidNotLearnMove2[] = _("{STR_VAR_1} did not learn the\nmove {STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WhichMoveToForget2[] = _("Which move should be forgotten?{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ForgetMove123_2[] = _("{PAUSE 32}1, {PAUSE 15}2, and{PAUSE 15}... {PAUSE 15}... {PAUSE 15}... {PAUSE 15}{PLAY_SE SE_KON}Poof!\p{STR_VAR_1} forgot how to\nuse {STR_VAR_2}.\pAnd...{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadyKnows[] = _("{STR_VAR_1} already knows\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_HPRestoredBy[] = _("{STR_VAR_1}’s HP was restored by\n{STR_VAR_2} points.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CuredPoisoning[] = _("{STR_VAR_1} was cured of its\npoisoning.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CuredParalysis[] = _("{STR_VAR_1} was cured of\nparalysis.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WokeUp[] = _("{STR_VAR_1} woke up.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BurnHealed[] = _("{STR_VAR_1}’s burn was healed.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ThawedOut[] = _("{STR_VAR_1} was thawed out.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_PPRestored[] = _("PP was restored.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_RegainedHealth[] = _("{STR_VAR_1} regained health.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BecameHealthy[] = _("{STR_VAR_1} became healthy.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_PPIncreased[] = _("{STR_VAR_1}’s PP increased.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ElevatedTo[] = _("{STR_VAR_1} was elevated to\nLv. {STR_VAR_2}."); +const u8 gOtherText_WasRaised[] = _("{STR_VAR_1}’s {STR_VAR_2} was\nraised.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_SnapConfusion[] = _("{STR_VAR_1} snapped out of its\nconfusion.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_GotOverLove[] = _("{STR_VAR_1} got over its\ninfatuation.{PAUSE_UNTIL_PRESS}"); +const u8 OtherText_ChoosePoke[] = _("Choose a POKéMON."); +const u8 OtherText_MovePokeTo[] = _("Move to where?"); +const u8 OtherText_TeachWhat[] = _("Teach which POKéMON?"); +const u8 OtherText_UseWhat[] = _("Use on which POKéMON?"); +const u8 OtherText_GiveWhat[] = _("Give to which POKéMON?"); +const u8 OtherText_DoWhat[] = _("Do what with {STR_VAR_1}?"); +const u8 OtherText_NothingToCut[] = _("There’s nothing to CUT."); +const u8 OtherText_CantSurf[] = _("You can’t SURF here."); +const u8 OtherText_AlreadySurfing[] = _("You’re already SURFING."); +const u8 OtherText_CantUseThatHere[] = _("Can’t use that here."); +const u8 OtherText_RestoreWhatMove[] = _("Restore which move?"); +const u8 OtherText_BoostPP[] = _("Boost PP of which move?"); +const u8 OtherText_DoWhatWithItem[] = _("Do what with an item?"); +const u8 OtherText_NoPokeForBattle[] = _("No POKéMON for battle!"); +const u8 OtherText_ChoosePoke2[] = _("Choose a POKéMON."); +const u8 OtherText_NotEnoughHP[] = _("Not enough HP..."); +const u8 OtherText_ThreePokeNeeded[] = _("Three POKéMON are needed."); +const u8 OtherText_PokeCantBeSame[] = _("POKéMON can’t be the same."); +const u8 OtherText_NoIdenticalHoldItems[] = _("No identical hold items."); +const u8 OtherText_TeachWhichPoke[] = _("Teach which POKéMON?"); +const u8 gOtherText_Attack[] = _("ATTACK"); +const u8 gOtherText_Defense[] = _("DEFENSE"); +const u8 gOtherText_SpAtk[] = _("SP. ATK"); +const u8 gOtherText_SpDef[] = _("SP. DEF"); +const u8 gOtherText_Speed[] = _("SPEED"); +const u8 gOtherText_HP[] = _("HP"); +const u8 gOtherText_Terminator18[] = _(""); +const u8 gOtherText_OriginalTrainer[] = _("OT/"); +const u8 gOtherText_Type2[] = _("TYPE/"); +const u8 gOtherText_Power2[] = _("POWER"); +const u8 gOtherText_Accuracy2[] = _("ACCURACY"); +const u8 gOtherText_Appeal2[] = _("APPEAL"); +const u8 gOtherText_Jam2[] = _("JAM"); +const u8 gOtherText_Status[] = _("STATUS"); +const u8 gOtherText_ExpPoints[] = _("EXP. POINTS"); +const u8 gOtherText_NextLv[] = _("NEXT LV."); +const u8 gOtherText_Ribbons00[] = _("RIBBONS: 00"); + +const u8 OtherText_Event[] = _("EVENT"); +const u8 OtherText_Switch[] = _("SWITCH"); +const u8 OtherText_PokeInfo[] = _("POKéMON INFO"); +const u8 OtherText_PokeSkills[] = _("POKéMON SKILLS"); +const u8 OtherText_BattleMoves[] = _("BATTLE MOVES"); +const u8 OtherText_ContestMoves[] = _("C0NTEST MOVES"); // why the l33t 0, that's stupid +const u8 OtherText_Info[] = _("INFO"); + +const u8 gOtherText_EggLongTime[] = _("It looks like this EGG will\ntake a long time to hatch."); +const u8 gOtherText_EggSomeTime[] = _("What will hatch from this?\nIt will take some time."); +const u8 gOtherText_EggSoon[] = _("It moves occasionally.\nIt should hatch soon."); +const u8 gOtherText_EggAbout[] = _("It’s making sounds.\nIt’s about to hatch!"); +const u8 gOtherText_CantForgetHMs[] = _("HM moves can’t be\nforgotten now."); +const u8 gOtherText_PlayersBase[] = _("’s BASE"); +const u8 gOtherText_OkayToDeleteFromRegistry[] = _("Is it okay to delete {STR_VAR_1}\nfrom the REGISTRY?"); +const u8 gOtherText_RegisteredDataDeleted[] = _("The registered data was deleted.{PAUSE_UNTIL_PRESS}"); + +const u8 gSecretBaseText_NoRegistry[] = _("There is no REGISTRY.{PAUSE_UNTIL_PRESS}"); +const u8 SecretBaseText_DelRegist[] = _("DEL REGIST."); +const u8 SecretBaseText_Decorate[] = _("DECORATE"); +const u8 SecretBaseText_PutAway[] = _("PUT AWAY"); +const u8 SecretBaseText_Toss[] = _("TOSS"); +const u8 SecretBaseText_PutOutDecor[] = _("Put out the selected decoration item."); +const u8 SecretBaseText_StoreChosenDecor[] = _("Store the chosen decoration in the PC."); +const u8 SecretBaseText_ThrowAwayDecor[] = _("Throw away unwanted decorations."); +const u8 gSecretBaseText_NoDecors[] = _("There are no decorations.{PAUSE_UNTIL_PRESS}"); +const u8 SecretBaseText_Desk[] = _("DESK"); +const u8 SecretBaseText_Chair[] = _("CHAIR"); +const u8 SecretBaseText_Plant[] = _("PLANT"); +const u8 SecretBaseText_Ornament[] = _("ORNAMENT"); +const u8 SecretBaseText_Mat[] = _("MAT"); +const u8 SecretBaseText_Poster[] = _("POSTER"); +const u8 SecretBaseText_Doll[] = _("DOLL"); +const u8 SecretBaseText_Cushion[] = _("CUSHION"); +const u8 gSecretBaseText_GoldRank[] = _("GOLD"); +const u8 gSecretBaseText_SilverRank[] = _("SILVER"); +const u8 gSecretBaseText_PlaceItHere[] = _("Place it here?"); +const u8 gSecretBaseText_CantBePlacedHere[] = _("It can’t be placed here."); +const u8 gSecretBaseText_CancelDecorating[] = _("Cancel decorating?"); +const u8 gSecretBaseText_InUseAlready[] = _("This is in use already."); +const u8 gSecretBaseText_NoMoreDecor[] = _("No more decorations can be placed.\nThe most that can be placed is {STR_VAR_1}."); +const u8 gSecretBaseText_NoMoreDecor2[] = _("No more decorations can be placed.\nThe most that can be placed is {STR_VAR_1}.$This can’t be placed here.\nIt must be on a DESK, etc."); +const u8 gSecretBaseText_DecorCantPlace[] = _("This decoration can’t be placed in\nyour own room."); +const u8 gSecretBaseText_DecorInUse[] = _("This decoration is in use.\nIt can’t be thrown away."); +const u8 gSecretBaseText_WillBeDiscarded[] = _("This {STR_VAR_1} will be discarded.\nIs that okay?"); +const u8 gSecretBaseText_DecorThrownAway[] = _("The decoration item was thrown away."); +const u8 gSecretBaseText_StopPuttingAwayDecor[] = _("Stop putting away decorations?"); +const u8 gSecretBaseText_NoDecor[] = _("There is no decoration item here."); +const u8 gSecretBaseText_ReturnDecor[] = _("Return this decoration to the PC?"); +const u8 gSecretBaseText_DecorReturned[] = _("The decoration was returned to the PC."); +const u8 gSecretBaseText_NoDecorInUse[] = _("There are no decorations in use.{PAUSE_UNTIL_PRESS}"); +const u8 SecretBaseText_Tristan[] = _("TRISTAN"); +const u8 SecretBaseText_Philip[] = _("PHILIP"); +const u8 SecretBaseText_Dennis[] = _("DENNIS"); +const u8 SecretBaseText_Roberto[] = _("ROBERTO"); +const u8 SecretBaseText_TurnOff[] = _("TURN OFF"); +const u8 SecretBaseText_Decoration[] = _("DECORATION"); +const u8 SecretBaseText_ItemStorage[] = _("ITEM STORAGE"); + +const u8 gPCText_Mailbox[] = _("MAILBOX"); +const u8 PCText_DepositItem[] = _("DEPOSIT ITEM"); +const u8 PCText_WithdrawItem[] = _("WITHDRAW ITEM"); +const u8 PCText_TossItem[] = _("TOSS ITEM"); +const u8 PCText_StoreItems[] = _("Store items in the PC."); +const u8 PCText_TakeOutItems[] = _("Take out items from the PC."); +const u8 PCText_ThrowAwayItems[] = _("Throw away items stored in the PC."); + +const u8 gOtherText_NoItems[] = _("There are no items.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoMoreRoom[] = _("There is no more\nroom in the BAG."); +const u8 gOtherText_HowManyToWithdraw[] = _("How many do you\nwant to withdraw?"); +const u8 gOtherText_WithdrewThing[] = _("Withdrew {STR_VAR_2}\n{STR_VAR_1}(s)."); +const u8 OtherText_Read[] = _("READ"); +const u8 gOtherText_MoveToBag[] = _("MOVE TO BAG"); +const u8 OtherText_Give[] = _("GIVE"); +const u8 gOtherText_NoMailHere[] = _("There’s no MAIL here.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WhatWillYouDoMail[] = _("What would you like to do with\n{STR_VAR_1}’s MAIL?"); +const u8 gOtherText_MessageWillBeLost[] = _("The message will be lost.\nIs that okay?"); +const u8 gOtherText_BagIsFull[] = _("The BAG is full.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailWasReturned[] = _("The MAIL was returned to the BAG\nwith its message erased.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_Dad[] = _("DAD"); +const u8 gOtherText_Mom[] = _("MOM"); +const u8 gOtherText_Wallace[] = _("WALLACE"); +const u8 gOtherText_Steven[] = _("STEVEN"); +const u8 gOtherText_Brawly[] = _("BRAWLY"); +const u8 gOtherText_Winona[] = _("WINONA"); +const u8 gOtherText_Phoebe[] = _("PHOEBE"); +const u8 gOtherText_Glacia[] = _("GLACIA"); +const u8 gContestText_ContestWinner[] = _("CONTEST WINNER\n"); +const u8 gOtherText_Unknown1[] = _("’s "); +const u8 OtherText_Cool[] = _("COOL "); +const u8 OtherText_Beauty2[] = _("BEAUTY "); +const u8 OtherText_Cute[] = _("CUTE "); +const u8 OtherText_Smart[] = _("SMART "); +const u8 OtherText_Tough[] = _("TOUGH "); +const u8 OtherText_NonstopSuperCool[] = _("Nonstop super-cool -\nthe inestimable "); +const u8 OtherText_Terminator6[] = _(""); +const u8 OtherText_GoodLookingPoke[] = _("Hey, there!\nThe good-looking POKéMON "); +const u8 OtherText_Terminator7[] = _(""); +const u8 OtherText_MarvelousGreat[] = _("The marvelous, wonderful, and\nvery great "); +const u8 OtherText_Terminator8[]= _(""); +const u8 OtherText_CenturyLastVenus[]= _("This century’s last Venus -\nthe beautiful "); +const u8 OtherText_Terminator9[]= _(""); +const u8 OtherText_Terminator10[]= _(""); +const u8 OtherText_DazzlingSmile[]= _("’s dazzling,\nglittering smile"); +const u8 OtherText_PokeCenterIdol[]= _("POKéMON CENTER’s super idol -\nthe incomparable "); +const u8 OtherText_Terminator11[]= _(""); +const u8 OtherText_LovelyAndSweet[]= _("The lovely and sweet "); +const u8 OtherText_Terminator12[]= _(""); +const u8 OtherText_ThePretty[]= _("The pretty "); +const u8 OtherText_WinningPortrait[] = _("’s\nwinning portrait"); +const u8 OtherText_GiveUsWink[] = _("Give us a wink!\nThe cutie POKéMON "); +const u8 OtherText_Terminator13[] = _(""); +const u8 OtherText_SmartnessMaestro[] = _("The smartness maestro -\nThe wise POKéMON "); +const u8 OtherText_Terminator14[] = _(""); +const u8 OtherText_ChosenPokeAmong[] = _("The chosen POKéMON -\nThe one among POKéMON "); +const u8 OtherText_Terminator15[] = _(""); +const u8 OtherText_TheExcellent[] = _("The excellent "); +const u8 OtherText_ItsMomentOfElegance[] = _("’s\nmoment of elegance"); +const u8 OtherText_PowerfullyMuscular[] = _("The powerfully muscular\nspeedster "); +const u8 OtherText_Terminator16[] = _(""); +const u8 OtherText_StrongErEst[] = _("The strong, stronger, and\nstrongest "); +const u8 OtherText_Terminator17[] = _(""); +const u8 OtherText_MightyTough[] = _("The mighty tough\nhyper POKéMON "); +const u8 OtherText_Exclamation[] = _("!"); +const u8 OtherText_Petalburg[] = _("PETALBURG"); +const u8 OtherText_Slateport[] = _("SLATEPORT"); +const u8 OtherText_Littleroot[] = _("LITTLEROOT"); // unused contest location? +const u8 OtherText_Lilycove[] = _("LILYCOVE"); +const u8 OtherText_Dewford[] = _("DEWFORD"); +const u8 OtherText_Enter[] = _("ENTER"); +const u8 OtherText_Info3[] = _("INFO"); +const u8 OtherText_WhatsAContest[] = _("What’s a CONTEST?"); +const u8 OtherText_TypesOfContest[] = _("Types of CONTESTS"); +const u8 OtherText_Ranks[] = _("Ranks"); +const u8 OtherText_Judging[] = _("Judging"); +const u8 OtherText_CoolContest[] = _("COOL CONTEST"); +const u8 OtherText_BeautyContest[] = _("BEAUTY CONTEST"); +const u8 OtherText_CuteContest[] = _("CUTE CONTEST"); +const u8 OtherText_SmartContest[] = _("SMART CONTEST"); +const u8 OtherText_ToughContest[] = _("TOUGH CONTEST"); +const u8 OtherText_Decoration[] = _("DECORATION"); +const u8 OtherText_PackUp[] = _("PACK UP"); +const u8 OtherText_Count[] = _("COUNT"); +const u8 OtherText_Registry[] = _("REGISTRY"); +const u8 OtherText_Information[] = _("INFORMATION"); +const u8 OtherText_Mach[] = _("MACH"); +const u8 OtherText_Acro[] = _("ACRO"); +const u8 OtherText_Poison[] = _("PSN"); +const u8 OtherText_Paralysis[] = _("PAR"); +const u8 OtherText_Sleep[] = _("SLP"); +const u8 OtherText_Burn[] = _("BRN"); +const u8 OtherText_Frozen[] = _("FRZ"); +const u8 OtherText_Quit[] = _("QUIT"); +const u8 OtherText_SawIt[] = _("Saw it"); +const u8 OtherText_NotYet[] = _("Not yet"); +const u8 OtherText_Yes[] = _("YES"); +const u8 OtherText_No[] = _("NO"); +const u8 OtherText_Info2[] = _("INFO"); +const u8 OtherText_SingleBattle[] = _("SINGLE BATTLE"); +const u8 OtherText_DoubleBattle[] = _("DOUBLE BATTLE"); +const u8 OtherText_MultiBattle[] = _("MULTI BATTLE"); +const u8 OtherText_MrBriney[] = _("MR. BRINEY"); +const u8 OtherText_MakeAChallenge[] = _("Make a challenge."); +const u8 OtherText_ObtainInformation[] = _("Obtain information."); +const u8 OtherText_Lv50_2[] = _("LV. 50"); +const u8 OtherText_Lv100_2[] = _("LV. 100"); +const u8 OtherText_Zigzagoon[] = _("ZIGZAGOON"); +const u8 OtherText_Nincada[] = _("NINCADA"); +const u8 OtherText_Poochyena[] = _("POOCHYENA"); +const u8 OtherText_Nincada2[] = _("NINCADA"); +const u8 OtherText_Lotad[] = _("LOTAD"); +const u8 OtherText_Roselia[] = _("ROSELIA"); +const u8 OtherText_Shroomish[] = _("SHROOMISH"); +const u8 OtherText_Nincada3[] = _("NINCADA"); +const u8 OtherText_Surskit[] = _("SURSKIT"); +const u8 OtherText_Treecko[] = _("TREECKO"); +const u8 OtherText_Torchic[] = _("TORCHIC"); +const u8 OtherText_Mudkip[] = _("MUDKIP"); +const u8 OtherText_Seedot[] = _("SEEDOT"); +const u8 OtherText_Shroomish2[] = _("SHROOMISH"); +const u8 OtherText_Spinda[] = _("SPINDA"); +const u8 OtherText_Shroomish3[] = _("SHROOMISH"); +const u8 OtherText_Zigzagoon2[] = _("ZIGZAGOON"); +const u8 OtherText_Wurmple[] = _("WURMPLE"); +const u8 OtherText_PokeBall[] = _("POKé BALL"); +const u8 OtherText_SuperPotion[] = _("SUPER POTION"); +const u8 OtherText_SamePrice[] = _("Same price"); +const u8 OtherText_Yen135[] = _("¥135"); +const u8 OtherText_Yen155[] = _("¥155"); +const u8 OtherText_Yen175[] = _("¥175"); +const u8 OtherText_CostMore[] = _("They will cost more."); +const u8 OtherText_CostLess[] = _("They will cost less."); +const u8 OtherText_SamePrice2[] = _("Same price"); +const u8 OtherText_MaleSymbol[] = _("♂"); +const u8 OtherText_FemaleSymbol[] = _("♀"); +const u8 OtherText_Neither[] = _("Neither"); +const u8 OtherText_Males[] = _("Males"); +const u8 OtherText_Females[] = _("Females"); +const u8 OtherText_SameNumber[] = _("Same number"); +const u8 OtherText_Male[] = _("Male"); +const u8 OtherText_Female[] = _("Female"); +const u8 OtherText_ItDepends[] = _("It depends"); +const u8 OtherText_Six2[] = _("6"); +const u8 OtherText_Eight2[] = _("8"); +const u8 OtherText_Ten[] = _("10"); +const u8 OtherText_One[] = _("1"); +const u8 OtherText_Two[] = _("2"); +const u8 OtherText_Three[] = _("3"); +const u8 OtherText_Six[] = _("6"); +const u8 OtherText_Seven[] = _("7"); +const u8 OtherText_Eight[] = _("8"); +const u8 OtherText_FreshWater[] = _("FRESH WATER{CLEAR_TO 0x48}¥200"); +const u8 OtherText_SodaPop[] = _("SODA POP{CLEAR_TO 0x48}¥300"); +const u8 OtherText_Lemonade[] = _("LEMONADE{CLEAR_TO 0x48}¥350"); +const u8 OtherText_HowToRide[] = _("HOW TO RIDE"); +const u8 OtherText_HowToTurn[] = _("HOW TO TURN"); +const u8 OtherText_SandySlopes[] = _("SANDY SLOPES"); +const u8 OtherText_Wheelies[] = _("WHEELIES"); +const u8 OtherText_BunnyHops[] = _("BUNNY-HOPS"); +const u8 OtherText_Jumping[] = _("JUMPING"); +const u8 OtherText_Satisfied[] = _("Satisfied"); +const u8 OtherText_Dissatisfied[] = _("Dissatisfied"); +const u8 OtherText_Deepseatooth[] = _("DEEPSEATOOTH"); +const u8 OtherText_Deepseascale[] = _("DEEPSEASCALE"); +const u8 OtherText_BlueFlute2[] = _("BLUE FLUTE"); +const u8 OtherText_YellowFlute2[] = _("YELLOW FLUTE"); +const u8 OtherText_RedFlute2[] = _("RED FLUTE"); +const u8 OtherText_WhiteFlute2[] = _("WHITE FLUTE"); +const u8 OtherText_BlackFlute2[] = _("BLACK FLUTE"); +const u8 OtherText_GlassChair[] = _("GLASS CHAIR"); +const u8 OtherText_GlassDesk[] = _("GLASS DESK"); +const u8 OtherText_TreeckoDoll[] = _("TREECKO DOLL 1,000 COINS"); +const u8 OtherText_TorchicDoll[] = _("TORCHIC DOLL 1,000 COINS"); +const u8 OtherText_MudkipDoll[] = _("MUDKIP DOLL 1,000 COINS"); +const u8 OtherText_50Coins[] = _(" 50 COINS ¥1,000"); +const u8 OtherText_500Coins[] = _("500 COINS ¥10,000"); +const u8 OtherText_Excellent[] = _("Excellent!"); +const u8 OtherText_NotSoHot[] = _("Not so hot"); +const u8 OtherText_RedShard[] = _("RED SHARD"); +const u8 OtherText_YellowShard[] = _("YELLOW SHARD"); +const u8 OtherText_BlueShard[] = _("BLUE SHARD"); +const u8 OtherText_GreenShard[] = _("GREEN SHARD"); +const u8 OtherText_BattleTower[] = _("BATTLE TOWER"); +const u8 OtherText_Right[] = _("Right"); +const u8 OtherText_Left[] = _("Left"); +const u8 OtherText_TM32[] = _("TM32 1,500 COINS"); +const u8 OtherText_TM29[] = _("TM29 3,500 COINS"); +const u8 OtherText_TM35[] = _("TM35 4,000 COINS"); +const u8 OtherText_TM24[] = _("TM24 4,000 COINS"); +const u8 OtherText_TM13[] = _("TM13 4,000 COINS"); +const u8 OtherText_1F_2[] = _("1F"); +const u8 OtherText_2F_2[] = _("2F"); +const u8 OtherText_3F_2[] = _("3F"); +const u8 OtherText_4F_2[] = _("4F"); +const u8 OtherText_5F_2[] = _("5F"); +const u8 OtherText_Cool2[] = _("COOL"); +const u8 OtherText_Beauty3[] = _("BEAUTY"); +const u8 OtherText_Cute2[] = _("CUTE"); +const u8 OtherText_Smart2[] = _("SMART"); +const u8 OtherText_Tough2[] = _("TOUGH"); +const u8 OtherText_Normal[] = _("NORMAL"); +const u8 OtherText_Super[] = _("SUPER"); +const u8 OtherText_Hyper[] = _("HYPER"); +const u8 OtherText_Master[] = _("MASTER"); +const u8 OtherText_Cool3[] = _("COOL"); +const u8 OtherText_Beauty4[] = _("BEAUTY"); +const u8 OtherText_Cute3[] = _("CUTE"); +const u8 OtherText_Smart3[] = _("SMART"); +const u8 OtherText_Tough3[] = _("TOUGH"); +const u8 OtherText_Items[] = _("ITEMS"); +const u8 OtherText_KeyItems[] = _("KEY ITEMS"); +const u8 OtherText_Balls[] = _("BALLS"); +const u8 OtherText_TMsHMs[] = _("TMs & HMs"); +const u8 OtherText_Berries[] = _("BERRIES"); + +const u8 gPCText_SomeonesPC[] = _("SOMEONE’S PC"); +const u8 gPCText_LanettesPC[] = _("LANETTE’S PC"); +const u8 gPCText_PlayersPC[] = _("{PLAYER}’s PC"); +const u8 gPCText_HallOfFame[] = _("HALL OF FAME"); +const u8 gPCText_LogOff[] = _("LOG OFF"); + +const u8 gOtherText_99Times[] = _("99 times +"); +const u8 gOtherText_1Minute[] = _("1 minute +"); +const u8 gOtherText_Seconds[] = _(" seconds"); +const u8 gOtherText_Times[] = _(" times$."); +const u8 gOtherText_BigGuy[] = _("Big guy"); +const u8 gOtherText_BigGirl[] = _("Big girl"); +const u8 gOtherText_Son[] = _("son"); +const u8 gOtherText_Daughter[] = _("daughter"); +const u8 OtherText_BlueFlute[] = _("BLUE FLUTE"); +const u8 OtherText_YellowFlute[] = _("YELLOW FLUTE"); +const u8 OtherText_RedFlute[] = _("RED FLUTE"); +const u8 OtherText_WhiteFlute[] = _("WHITE FLUTE"); +const u8 OtherText_BlackFlute[] = _("BLACK FLUTE"); +const u8 OtherText_PrettyChair[] = _("PRETTY CHAIR"); +const u8 OtherText_PrettyDesk[] = _("PRETTY DESK"); +const u8 OtherText_1F[] = _("1F"); +const u8 OtherText_2F[] = _("2F"); +const u8 OtherText_3F[] = _("3F"); +const u8 OtherText_4F[] = _("4F"); +const u8 OtherText_5F[] = _("5F"); +const u8 OtherText_6F[] = _("6F"); +const u8 OtherText_7F[] = _("7F"); +const u8 OtherText_8F[] = _("8F"); +const u8 OtherText_9F[] = _("9F"); +const u8 OtherText_10F[] = _("10F"); +const u8 OtherText_11F[] = _("11F"); +const u8 OtherText_B1F[] = _("B1F"); +const u8 OtherText_B2F[] = _("B2F"); +const u8 OtherText_B3F[] = _("B3F"); +const u8 OtherText_B4F[] = _("B4F"); +const u8 OtherText_Rooftop[] = _("ROOFTOP"); + +const u8 gOtherText_NowOn[] = _("Now on:"); + +const u8 gPCText_Cancel[] = _("CANCEL"); + +const u8 PCText_ExitBox[] = _("Exit from the BOX."); +const u8 PCText_WhatYouDo[] = _("What would you like to do?"); +const u8 PCText_PickATheme[] = _("Please pick a theme."); +const u8 PCText_PickAWallpaper[] = _("Please pick out wallpaper."); +const u8 PCText_IsSelected[] = _(" is selected."); +const u8 PCText_JumpToWhichBox[] = _("Jump to which BOX?"); +const u8 PCText_DepositInWhichBox[] = _("Deposit in which BOX?"); +const u8 PCText_WasDeposited[] = _(" was deposited."); +const u8 PCText_BoxIsFull[] = _("The BOX is full."); +const u8 PCText_ReleasePoke[] = _("Release this POKéMON?"); +const u8 PCText_WasReleased[] = _(" was released."); +const u8 PCText_ByeBye[] = _("Bye-bye, !"); +const u8 PCText_MarkPoke[] = _("Mark your POKéMON."); +const u8 PCText_LastPoke[] = _("That’s your last POKéMON!"); +const u8 PCText_PartyFull[] = _("Your party’s full!"); +const u8 PCText_HoldingPoke[] = _("You’re holding a POKéMON!"); +const u8 PCText_WhichOneWillTake[] = _("Which one will you take?"); +const u8 PCText_CantReleaseEgg[] = _("You can’t release an EGG."); +const u8 PCText_ContinueBox[] = _("Continue BOX operations?"); +const u8 PCText_CameBack[] = _(" came back!"); +const u8 PCText_Worried[] = _("Was it worried about you?"); +const u8 PCText_Surprise[] = _("... ... ... ... ...!"); +const u8 PCText_PleaseRemoveMail[] = _("Please remove the MAIL."); +const u8 PCText_Cancel2[] = _("CANCEL"); +const u8 PCText_Deposit[] = _("DEPOSIT"); +const u8 PCText_Withdraw[] = _("WITHDRAW"); +const u8 PCText_Switch[] = _("SWITCH"); +const u8 PCText_Move[] = _("MOVE"); +const u8 PCText_Place[] = _("PLACE"); +const u8 PCText_Summary[] = _("SUMMARY"); +const u8 PCText_Release[] = _("RELEASE"); +const u8 PCText_Mark[] = _("MARK"); +const u8 PCText_Name[] = _("NAME"); +const u8 PCText_Jump[] = _("JUMP"); +const u8 PCText_Wallpaper[] = _("WALLPAPER"); +const u8 PCText_Scenery1[] = _("SCENERY 1"); +const u8 PCText_Scenery2[] = _("SCENERY 2"); +const u8 PCText_Scenery3[] = _("SCENERY 3"); +const u8 PCText_Etc[] = _("ETCETERA"); +const u8 PCText_Forest[] = _("FOREST"); +const u8 PCText_City[] = _("CITY"); +const u8 PCText_Desert[] = _("DESERT"); +const u8 PCText_Savanna[] = _("SAVANNA"); +const u8 PCText_Crag[] = _("CRAG"); +const u8 PCText_Volcano[] = _("VOLCANO"); +const u8 PCText_Snow[] = _("SNOW"); +const u8 PCText_Cave[] = _("CAVE"); +const u8 PCText_Beach[] = _("BEACH"); +const u8 PCText_Seafloor[] = _("SEAFLOOR"); +const u8 PCText_River[] = _("RIVER"); +const u8 PCText_Sky[] = _("SKY"); +const u8 PCText_Polka[] = _("POLKA-DOT"); +const u8 PCText_PokeCenter[] = _("POKéCENTER"); +const u8 PCText_Machine[] = _("MACHINE"); +const u8 PCText_Plain[] = _("PLAIN"); +const u8 PCText_WhatDoYouWant[] = _("What do you want?"); +const u8 PCText_WithdrawPoke[] = _("WITHDRAW POKéMON"); +const u8 PCText_DepositPoke[] = _("DEPOSIT POKéMON"); +const u8 PCText_MovePoke[] = _("MOVE POKéMON"); +const u8 PCText_SeeYa[] = _("SEE YA!"); +const u8 PCText_MovePokeToParty[] = _("Move POKéMON stored in BOXES to\nyour party."); +const u8 PCText_StorePokeInBox[] = _("Store POKéMON in your party in BOXES."); +const u8 PCText_OrganizeBoxesParty[] = _("Organize the POKéMON in BOXES and\nin your party."); +const u8 PCText_ReturnToPrevMenu[] = _("Return to the previous menu."); + +const u8 gPCText_OnlyOne[] = _("There is just one POKéMON with you."); +const u8 gPCText_PartyFull2[] = _("Your party is full!"); +const u8 gPCText_BOX[] = _("BOX"); + +// pokenav +const u8 PCText_CheckMap[] = _("{CLEAR 0}Check the map of the HOENN region."); +const u8 PCText_CheckPoke[] = _("{CLEAR 0}Check POKéMON in detail."); +const u8 PCText_CheckTrainer[] = _("{CLEAR 0}Check TRAINER information."); +const u8 PCText_CheckRibbons[] = _("{CLEAR 0}Check obtained RIBBONS."); +const u8 PCText_PutAwayNav[] = _("{CLEAR 0}Put away the POKéNAV."); +const u8 PCText_NoRibbonWin[] = _("{CLEAR 0}There are no RIBBON winners."); +const u8 PCText_NoTrainers[] = _("{CLEAR 0}No TRAINERS are registered."); +const u8 PCText_CheckParty[] = _("{CLEAR 0}Check party POKéMON in detail."); +const u8 PCText_CheckPokeAll[] = _("{CLEAR 0}Check all POKéMON in detail."); +const u8 PCText_ReturnToNav[] = _("{CLEAR 0}Return to the POKéNAV menu."); +const u8 PCText_FindCool[] = _("{CLEAR 0}Find cool POKéMON."); +const u8 PCText_FindBeauty[] = _("{CLEAR 0}Find beautiful POKéMON."); +const u8 PCText_FindCute[] = _("{CLEAR 0}Find cute POKéMON."); +const u8 PCText_FindSmart[] = _("{CLEAR 0}Find smart POKéMON."); +const u8 PCText_FindTough[] = _("{CLEAR 0}Find tough POKéMON."); +const u8 PCText_ReturnToCondition[] = _("{CLEAR 0}Return to the CONDITION menu."); + +const u8 gOtherText_NumberRegistered[] = _("No. registered"); +const u8 gOtherText_NumberBattles[] = _("No. of battles"); +const u8 gOtherText_Strategy[] = _("{PALETTE 5}STRATEGY"); +const u8 gOtherText_TrainersPokemon[] = _("{PALETTE 5}TRAINER’S POKéMON"); +const u8 gOtherText_SelfIntroduction[] = _("{PALETTE 5}SELF-INTRODUCTION"); +const u8 gOtherText_Nature2[] = _("NATURE/"); +const u8 gOtherText_InParty[] = _("IN PARTY"); +const u8 gOtherText_Number[] = _("No. "); +const u8 gOtherText_Ribbons[] = _("RIBBONS"); +const u8 OtherText_MakeProfilePage1[] = _("Make your profile by combining"); +const u8 OtherText_MakeProfilePage2[] = _("four words or phrases."); +const u8 OtherText_MakeMessagePage1[] = _("Make a message with 6 phrases."); +const u8 OtherText_MakeMessagePage2[] = _("Max. two 12-letter phrases/line."); +const u8 OtherText_DescribeFeelingsPage1[] = _("Find words that describe your"); +const u8 OtherText_DescribeFeelingsPage2[] = _("feelings right now."); +const u8 OtherText_WithFourPhrases[] = _("With four phrases,"); +const u8 OtherText_CombineNinePhrasesPage1[] = _("Combine nine phrases and"); +const u8 OtherText_CombineNinePhrasesPage2[] = _("make a message."); +const u8 OtherText_ImproveBardSongPage1[] = _("Change just one word or phrase"); +const u8 OtherText_ImproveBardSongPage2[] = _("and improve the BARD’s song."); +const u8 OtherText_YourProfile[] = _("Your profile "); +const u8 OtherText_YourFeelingBattle[] = _("Your feeling at the battle’s start"); +const u8 OtherText_SetWinMessage[] = _("What you say if you win a battle"); +const u8 OtherText_SetLossMessage[] = _("What you say if you lose a battle"); +const u8 OtherText_TheAnswer[] = _("The answer"); +const u8 OtherText_MailMessage[] = _("The MAIL message"); +const u8 OtherText_MailSalutation[] = _("The MAIL salutation"); +const u8 OtherText_NewSong[] = _("The new song"); +const u8 OtherText_CombineTwoPhrasesPage1[] = _("Combine two phrases and"); +const u8 OtherText_CombineTwoPhrasesPage2[] = _("make a trendy saying."); +const u8 OtherText_ConfirmTrendyPage1[] = _("The trendy saying"); +const u8 OtherText_ConfirmTrendyPage2[] = _("is as shown. Okay?"); +const u8 OtherText_HipsterPage1[] = _("I’ll combine two phrases and"); +const u8 OtherText_HipsterPage2[] = _("teach you a good saying."); + +const u8 gOtherText_TextDeletedConfirmPage1[] = _("All the text being edited will"); +const u8 gOtherText_TextDeletedConfirmPage2[] = _("be deleted. Is that okay?"); +const u8 gOtherText_QuitEditing[] = _("Quit editing?"); +const u8 gOtherText_EditedTextNoSavePage1[] = _("The edited text will not be saved."); +const u8 gOtherText_EditedTextNoSavePage2[] = _("Is that okay?"); +const u8 gOtherText_EnterAPhraseOrWord[] = _("Please enter a phrase or word."); +const u8 gOtherText_TextNoDelete[] = _("The entire text can’t be deleted."); +const u8 gOtherText_OnlyOnePhrase[] = _("Only one phrase may be changed."); +const u8 gOtherText_OriginalSongRestored[] = _("The original song will be restored."); +const u8 gOtherText_TrendyAlready[] = _("That’s trendy already!"); +const u8 gOtherText_CombineTwoPhrases[] = _("Combine two words or phrases."); +const u8 gOtherText_QuitGivingInfo[] = _("Quit giving information?"); +const u8 gOtherText_StopGivingMail[] = _("Stop giving the POKéMON MAIL?"); +const u8 gOtherText_Profile[] = _("PROFILE"); +const u8 gOtherText_AtBattleStart[] = _("At the battle’s start."); +const u8 gOtherText_UponWinningBattle[] = _("Upon winning a battle."); +const u8 gOtherText_UponLosingBattle[] = _("Upon losing a battle."); + +// mauville_old_man? +const u8 gOtherText_TheBardsSong[] = _("The BARD’s Song"); +const u8 gOtherText_WhatsHipHappening[] = _("What’s hip and happening?"); +const u8 gOtherText_Interview[] = _("Interview"); +const u8 gOtherText_GoodSaying[] = _("Good saying"); +const u8 OtherText_SoPretty[] = _(" so pretty!"); +const u8 OtherText_SoDarling[] = _(" so darling!"); +const u8 OtherText_SoRelaxed[] = _(" so relaxed!"); +const u8 OtherText_SoSunny[] = _(" so sunny!"); +const u8 OtherText_SoDesirable[] = _(" so desirable!"); +const u8 OtherText_SoExciting[] = _(" so exciting!"); +const u8 OtherText_SoAmusing[] = _(" so amusing!"); +const u8 OtherText_SoMagical[] = _(" so magical!"); + +const u8 gOtherText_Is[] = _(" is"); +const u8 gOtherText_DontYouAgree[] = _("\nDon’t you agree?"); + +const u8 OtherText_WantVacationNicePlace[] = _("I so want to go on a vacation.\nWould you happen to know a nice place?"); +const u8 OtherText_BoughtCrayonsIsNice[] = _("I bought crayons with 120 colors!\nDon’t you think that’s nice?"); +const u8 OtherText_IfWeCouldFloat[] = _("Wouldn’t it be nice if we could float\naway on a cloud of bubbles?"); +const u8 OtherText_SandWashesAwayMakeSad[] = _("When you write on a sandy beach,\nthey wash away. It makes me sad."); +const u8 OtherText_WhatsBottomSeaLike[] = _("What’s the bottom of the sea like?\nJust once I would so love to go!"); +const u8 OtherText_SeeSettingSun[] = _("When you see the setting sun, does it\nmake you want to go home?"); +const u8 OtherText_LyingInGreenGrass[] = _("Lying back in the green grass...\nOh, it’s so, so nice!"); +const u8 OtherText_SecretBasesWonderful[] = _("SECRET BASES are so wonderful!\nCan’t you feel the excitement?"); + +const u8 OtherText_PokeLeague[] = _("POKéMON LEAGUE"); +const u8 OtherText_PokeCenter[] = _("POKéMON CENTER"); + +const u8 gOtherText_GetsAPokeBlock[] = _(" gets a {POKEBLOCK}?"); + +const u8 OtherText_Coolness[] = _("Coolness "); +const u8 OtherText_Beauty[] = _("Beauty "); +const u8 OtherText_Cuteness[] = _("Cuteness "); +const u8 OtherText_Smartness[] = _("Smartness "); +const u8 OtherText_Toughness[] = _("Toughness "); + +const u8 gOtherText_WasEnhanced[] = _("was enhanced!"); +const u8 gOtherText_NothingChanged[] = _("Nothing changed!"); +const u8 gOtherText_WontEat[] = _("It won’t eat anymore..."); + +const u8 gSystemText_SaveFailedBackupCheck[] = _("Save failed.\nChecking the backup memory...\nPlease wait.\n{COLOR RED}“Time required: 1 minute”"); +const u8 gSystemText_BackupDamagedGameContinue[] = _("The backup memory is damaged or\nthe internal battery has run dry.\nThe game can be played. However,\nprogress cannot be saved."); +const u8 gSystemText_GameplayEnded[] = _("{COLOR RED}“Gameplay cannot be continued.\nReturning to the title screen...”"); +const u8 gSystemText_CheckCompleteSaveAttempt[] = _("Check completed.\nAttempting to save again.\nPlease wait."); +const u8 gSystemText_SaveCompletedGameEnd[] = _("Save completed.\n{COLOR RED}“Gameplay cannot be continued.\nReturning to the title screen.”"); +const u8 gSystemText_SaveCompletedPressA[] = _("Save completed.\n{COLOR RED}“Please press the A Button.”"); + +const u8 gOtherText_Ferry[] = _("FERRY"); +const u8 gOtherText_SecretBase[] = _("SECRET BASE"); +const u8 gOtherText_Hideout[] = _("HIDEOUT"); + +const u8 gSystemText_ResetRTCPrompt[] = _("Reset RTC?\nA: Confirm, B: Cancel"); +const u8 gSystemText_PresentTime[] = _("Present time in game"); +const u8 gSystemText_PreviousTime[] = _("Previous time in game"); +const u8 gSystemText_PleaseResetTime[] = _("Please reset the time."); +const u8 gSystemText_ClockResetDataSave[] = _("The clock has been reset.\nData will be saved. Please wait."); +const u8 gSystemText_SaveCompleted[] = _("Save completed."); +const u8 gSystemText_SaveFailed[] = _("Save failed..."); +const u8 gSystemText_NoSaveFileNoTime[] = _("There is no save file, so the time\ncan’t be set."); +const u8 gSystemText_ClockAdjustmentUsable[] = _("The in-game clock adjustment system\nis now useable."); +const u8 gSystemText_Saving[] = _("SAVING...\nDON’T TURN OFF THE POWER."); +#elif GERMAN + +// placeholder strings +const u8 gExpandedPlaceholder_Empty[] = _(""); +const u8 gExpandedPlaceholder_Kun[] = _(""); +const u8 gExpandedPlaceholder_Chan[] = _(""); +const u8 gExpandedPlaceholder_Sapphire[] = _("SAPHIR"); +const u8 gExpandedPlaceholder_Ruby[] = _("RUBIN"); +const u8 gExpandedPlaceholder_Aqua[] = _("AQUA"); +const u8 gExpandedPlaceholder_Magma[] = _("MAGMA"); +const u8 gExpandedPlaceholder_Archie[] = _("ADRIAN"); +const u8 gExpandedPlaceholder_Maxie[] = _("MARC"); +const u8 gExpandedPlaceholder_Kyogre[] = _("KYOGRE"); +const u8 gExpandedPlaceholder_Groudon[] = _("GROUDON"); +const u8 gExpandedPlaceholder_Brendan[] = _("BRIX"); +const u8 gExpandedPlaceholder_May[] = _("MAIKE"); + +// system text +const u8 gSystemText_Egg[] = _("EI"); +const u8 gSystemText_Pokemon2[] = _("POKéMON"); + +// main menu text +const u8 gMainMenuString_NewGame[] = _("NEUES SPIEL"); +const u8 gMainMenuString_Continue[] = _("WEITER"); +const u8 gMainMenuString_Option[] = _("OPTIONEN"); +const u8 gMainMenuString_MysteryEvents[] = _("GEHEIMGESCHEHEN"); + +// system text 2 +const u8 SystemText_UpdatingSaveExternal[] = _("Neuer Spielstand mittels Übertra-\ngung externer Daten. Bitte warten."); +const u8 SystemText_SaveUpdated[] = _("Der Spielstand wurde erneuert."); +const u8 SystemText_SaveUpdatedExchangeBackup[] = _("Der Spielstand wurde gespeichert.\pDas Backup Memory kann keine \nweiteren Spieldaten sichern.\pBitte Backup Memory austauschen.\pBei Fragen bitte an die Nintendo\nKonsumentenberatung wenden."); +const u8 SystemText_SaveNotUpdated[] = _("Spielstand wurde nicht gesichert.\pBitte Backup Memory \naustauschen.\pBei Fragen bitte an die Nintendo\nKonsumentenberatung wenden."); + +// save file text +const u8 gSaveFileCorruptMessage[] = _("Der Spielstand ist beschädigt. Der\nvorherige Spielstand wird geladen."); +const u8 gSaveFileDeletedMessage[] = _("Der Spielstand wurde gelöscht."); + +// system text 3 +const u8 gBoardNotInstalledMessage[] = _("Das ‘1M Sub-circuit Board’\nist nicht installiert."); +const u8 gBatteryDryMessage[] = _("Interne Batterie ist verbraucht.\nSpiel kann fortgesetzt werden.\pAber zeitbasierende Spiel-Events\nwerden nicht mehr initiiert."); + +// main menu text 2 +const u8 gMainMenuString_Player[] = _("SPIELER"); +const u8 gMainMenuString_Pokedex[] = _("POKéDEX"); +const u8 gMainMenuString_Time[] = _("SPIELZEIT"); +const u8 gMainMenuString_Badges[] = _("ORDEN"); + +// birch text +const u8 gBirchText_Boy[] = _("JUNGE"); +const u8 gBirchText_Girl[] = _("MÄDEL"); +const u8 gBirchText_NewName[] = _("NEUER NAME"); + +#ifdef SAPPHIRE +const u8 gDefaultBoyName1[] = _("SEAN"); +#else +const u8 gDefaultBoyName1[] = _("ROLAND"); +#endif +const u8 gDefaultBoyName2[] = _("DANIEL"); +const u8 gDefaultBoyName3[] = _("HELGE"); +const u8 gDefaultBoyName4[] = _("JAN"); + +#ifdef SAPPHIRE +const u8 gDefaultGirlName1[] = _("MARINA"); +#else +const u8 gDefaultGirlName1[] = _("PETRA"); +#endif +const u8 gDefaultGirlName2[] = _("TANJA"); +const u8 gDefaultGirlName3[] = _("ANDREA"); +const u8 gDefaultGirlName4[] = _("SARA"); + +const u8 gSystemText_IntroWeCall[] = _("Dies ist ein so genanntes\n“POKéMON”."); +const u8 gSystemText_NewPara[] = _("\p"); + +const u8 gDexText_UnknownPoke[] = _("?????"); +const u8 gDexText_UnknownHeight[] = _("???,? m"); +const u8 gDexText_UnknownWeight[] = _("???,? kg$"); +const u8 gDexText_CryOf[] = _("{CLEAR_TO 2}RUF VON$"); +const u8 gDexText_SizeComparedTo[] = _("GRÖSSE IM VERGLEICH ZU "); +const u8 gDexText_RegisterComplete[] = _("Neuer Eintrag aufgenommen."); +const u8 gDexText_Searching[] = _("Suche läuft.\nBitte warten..."); +const u8 gDexText_SearchComplete[] = _("Suche beendet."); +const u8 gDexText_NoMatching[] = _("Es wurde keine Übereinstimmung ermittelt."); + +const u8 DexText_SearchForPoke[] = _("Suche nach POKéMON anhand\nausgewählter Parameter."); +const u8 DexText_SwitchDex[] = _("Ordnungssystem des POKéDEX ändern."); +const u8 DexText_ReturnToDex[] = _("Kehre zurück zum POKéDEX."); +const u8 DexText_SelectDexMode[] = _("Wähle einen POKéDEX."); +const u8 DexText_SelectDexList[] = _("Wähle ein Ordnungssystem des POKéDEX."); +const u8 DexText_ListByABC[] = _("Nach Anfangsbuchstaben suchen.\n(Alle gesehenen POKéMON.)"); +const u8 DexText_ListByColor[] = _("Nach Körperfarbe suchen.\n(Alle gesehenen POKéMON.)"); +const u8 DexText_ListByType[] = _("Nach Elementklasse suchen.\n(Nur gefangene POKéMON.)"); +const u8 DexText_ExecuteSearchSwitch[] = _("Suche/Ändern ausführen."); +const u8 DexText_HoennDex[] = _("HOENN DEX"); +const u8 DexText_NationalDex[] = _("NATIONALER DEX"); +const u8 DexText_NumericalMode[] = _("NUMERISCH"); +const u8 DexText_ABCMode[] = _("VON A BIS Z"); +const u8 DexText_HeaviestMode[] = _("NACH GEWICHT {0x86}"); +const u8 DexText_LightestMode[] = _("NACH GEWICHT {0x85}"); +const u8 DexText_TallestMode[] = _("NACH GRÖSSE {0x86}"); +const u8 DexText_SmallestMode[] = _("NACH GRÖSSE {0x85}"); +const u8 DexText_ABC[] = _("ABC"); +const u8 DexText_DEF[] = _("DEF"); +const u8 DexText_GHI[] = _("GHI"); +const u8 DexText_JKL[] = _("JKL"); +const u8 DexText_MNO[] = _("MNO"); +const u8 DexText_PQR[] = _("PQR"); +const u8 DexText_STU[] = _("STU"); +const u8 DexText_VWX[] = _("VWX"); +const u8 DexText_YZ[] = _("YZ"); +const u8 DexText_Red[] = _("ROT"); +const u8 DexText_Blue[] = _("BLAU"); +const u8 DexText_Yellow[] = _("GELB"); +const u8 DexText_Green[] = _("GRÜN"); +const u8 DexText_Black[] = _("SCHWARZ"); +const u8 DexText_Brown[] = _("BRAUN"); +const u8 DexText_Purple[] = _("LILA"); +const u8 DexText_Gray[] = _("GRAU"); +const u8 DexText_White[] = _("WEISS"); +const u8 DexText_Pink[] = _("ROSA"); +const u8 DexText_HoennDex2[] = _("POKéDEX von HOENN"); +const u8 DexText_NationalDex2[] = _("POKéDEX, erweiterte Edition"); +const u8 DexText_ListByNumber[] = _("POKéMON werden anhand ihrer\nNummer sortiert."); +const u8 DexText_ListByABC2[] = _("Gesehene und gefangene POKéMON\nwerden alphabetisch geordnet."); +const u8 DexText_ListByHeavyToLightest[] = _("Gefangene POKéMON werden nach Gewicht\nsortiert, beginnend mit dem schwersten."); +const u8 DexText_ListByLightToHeaviest[] = _("Gefangene POKéMON werden nach Gewicht\nsortiert, beginnend mit dem leichtesten."); +const u8 DexText_ListByTallToSmallest[] = _("Gefangene POKéMON werden nach Größe\nsortiert, beginnend mit dem größten."); +const u8 DexText_ListBySmallToTallest[] = _("Gefangene POKéMON werden nach Größe\nsortiert, beginnend mit dem kleinsten."); +const u8 DexText_Terminator5[] = _(""); +const u8 DexText_DontSpecify[] = _("KEINE ANGABE"); +const u8 DexText_None[] = _("KEINER"); +const u8 DexText_RightPointingTriangle[] = _("▶"); +const u8 DexText_Terminator6[] = _(" "); + +const u8 gMenuText_WelcomeToHOFAndDexRating[] = _("Willkommen in der RUHMESHALLE!$Gesehene POKéMON: {STR_VAR_1}!\nGefangene POKéMON: {STR_VAR_2}!\pPROF. BIRKs POKéDEX-Bewertung!\pPROF. BIRK: Sehen wir mal...\p"); +const u8 gMenuText_HOFSaving[] = _("SPEICHERVORGANG...\nDAS GERÄT NICHT AUSSCHALTEN!"); +const u8 gMenuText_HOFCorrupt[] = _("Die RH-Daten sind beschädigt."); +const u8 gMenuText_HOFNumber[] = _("RUHMESHALLE, Nr. "); +const u8 gMenuText_HOFCongratulations[] = _("CHAMP der POKéMON LIGA!\nHerzlichen Glückwunsch!"); + +const u8 gOtherText_Number2[] = _("Nr."); +const u8 gOtherText_Level3[] = _("Lv."); +const u8 gOtherText_IDNumber[] = _("ID.Nr. /"); +const u8 gOtherText_Name[] = _("NAME /"); +const u8 gOtherText_IDNumber2[] = _("ID.Nr. /"); +const u8 gOtherText_BirchInTrouble[] = _("{HIGHLIGHT WHITE2}{COLOR DARK_GREY}PROF. BIRK ist in Schwierigkeiten!\nSchnapp’ dir ein POKéMON und hilf ihm!"); +const u8 gOtherText_DoYouChoosePoke[] = _("{HIGHLIGHT WHITE2}{COLOR DARK_GREY}Wählst du dieses POKéMON?"); +const u8 gOtherText_Poke[] = _("POKéMON"); + +const u8 gSystemText_SaveErrorExchangeBackup[] = _("Fehler beim Speichern!\pBitte Backup Memory\naustauschen."); +const u8 gOtherText_FlyToWhere[] = _("Wohin willst du FLIEGEN?"); + +const u8 OtherText_Use[] = _("O.K."); +const u8 OtherText_Toss[] = _("MÜLL"); +const u8 OtherText_Register[] = _("WÄHLEN"); +const u8 OtherText_Give2[] = _("GEBEN"); +const u8 OtherText_CheckTag[] = _("PRÜFEN"); +const u8 OtherText_Confirm[] = _("O.K."); +const u8 gOtherText_Walk[] = _("LAUFEN"); + +const u8 gUnknownText_Exit[] = _("BEENDEN"); +const u8 gOtherText_CancelNoTerminator[] = _("ZURÜCK"); +const u8 gOtherText_CancelWithTerminator[] = _("$ZURÜCK"); + +const u8 OtherText_Item[] = _("ITEM"); +const u8 OtherText_Mail[] = _("BRIEF"); +const u8 OtherText_Take2[] = _("NEHMEN"); +const u8 OtherText_Store[] = _("GEBEN"); + +const u8 gOtherText_Check[] = _("PRÜFEN"); +const u8 gOtherText_None[] = _("KEINES"); + +const u8 gOtherText_ThreeQuestions2[] = _("???"); + +const u8 gOtherText_FiveQuestionsAndSlash[] = _("?????$/"); + +const u8 gOtherText_OneDash[] = _("-"); +const u8 gOtherText_TwoDashes[] = _("--"); +const u8 gOtherText_ThreeDashes2[] = _("---"); +const u8 gOtherText_MaleSymbol2[] = _("♂"); +const u8 gOtherText_FemaleSymbolAndLv[] = _("♀$Lv."); +const u8 gOtherText_TallPlusAndRightArrow[] = _("{TALL_PLUS}${RIGHT_ARROW}"); +const u8 gMenuText_GoBackToPrev[] = _("Kehre zurück zum\nvorherigen Menü."); +const u8 gOtherText_WhatWillYouDo[] = _("Was möchtest du tun?"); + +const u8 gOtherText_xString1[] = _("×{STR_VAR_1}"); +const u8 gOtherText_Berry2[] = _("BEERE"); +const u8 gOtherText_Coins2[] = _("{STR_VAR_1} MÜNZ."); +const u8 gOtherText_CloseBag[] = _("BEUTEL SCHLIESSEN"); + +const u8 OtherText_TheField3[] = _("zum Hauptmenü."); +const u8 OtherText_TheBattle[] = _("zum Kampf."); +const u8 OtherText_ThePokeList[] = _("zur POKéMON-LISTE."); +const u8 OtherText_TheShop[] = _("zum Geschäft."); +const u8 OtherText_TheField[] = _("zum Hauptmenü."); +const u8 OtherText_TheField2[] = _("zum Hauptmenü."); +const u8 OtherText_ThePC[] = _("zum PC."); + +const struct TextStruct gUnknown_0840E740[7] = +{ + OtherText_TheField3, + OtherText_TheBattle, + OtherText_ThePokeList, + OtherText_TheShop, + OtherText_TheField, + OtherText_TheField2, + OtherText_ThePC, +}; + +const u8 gOtherText_ReturnTo[] = _("Zurück "); +const u8 gOtherText_WhatWillYouDo2[] = _("Was möchtest\ndu tun?"); +const u8 gOtherText_CantWriteMail[] = _("Du kannst keinen\nBRIEF schreiben."); +const u8 gOtherText_NoPokemon[] = _("Hier ist kein\nPOKéMON.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_SwitchWhichItem[] = _("Gegen welches Item\naustauschen?"); +const u8 gOtherText_CantBeHeld[] = _("{STR_VAR_1} ist nicht zu geben."); +const u8 gOtherText_CantBeHeldHere[] = _("{STR_VAR_1} ist hier nicht zu geben."); +const u8 gOtherText_HowManyToDeposit[] = _("Wie viele möchtest\ndu ablegen?"); +const u8 gOtherText_DepositedItems[] = _("{STR_VAR_2}× {STR_VAR_1}\nwurde abgelegt."); +const u8 gOtherText_NoRoomForItems[] = _("Kein Platz für\nweitere Items."); +const u8 gOtherText_CantStoreSomeoneItem[] = _("Du kannst kein\nItem eines anderen\nauf dem PC lagern."); +const u8 gOtherText_TooImportant[] = _("Das ist viel zu\nwichtig, um es\nwegzuwerfen!"); +const u8 gOtherText_HowManyToToss[] = _("Wie viel in den Müll?"); +const u8 gOtherText_ThrewAwayItem[] = _("{STR_VAR_2} × {STR_VAR_1}\nweggeworfen."); +const u8 gOtherText_OkayToThrowAwayPrompt[] = _("Willst du wirklich\n{STR_VAR_2} × {STR_VAR_1}\nwegwerfen?"); +const u8 gOtherText_DadsAdvice[] = _("VATI sagt immer...\n{PLAYER}, dies ist weder der rechte\lOrt noch der rechte Zeitpunkt dafür!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantGetOffBike[] = _("Du kannst hier nicht vom RAD steigen.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ItemfinderResponding[] = _("Oh!\nDas Gerät zeigt etwas an!\pHier muss ein Item vergraben sein!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ItemfinderItemUnderfoot[] = _("Das Gerät macht direkt unter\ndeinen Füßen etwas aus!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoResponse[] = _("... ... ... ... Nichts!\nKeine Anzeige.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_Coins3[] = _("Deine MÜNZEN:\n{STR_VAR_1}{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BootedTM[] = _("Eine TM wurde aktiviert."); +const u8 gOtherText_BootedHM[] = _("Eine VM wurde aktiviert."); +const u8 gOtherText_ContainsMove[] = _("Sie enthält\n{STR_VAR_1}.\p{STR_VAR_1} einem\nPOKéMON beibringen?"); +const u8 gOtherText_UsedItem[] = _("{PLAYER} setzt\n{STR_VAR_2} ein.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_RepelLingers[] = _("Aber SCHUTZ wirkt doch\nnoch!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_UsedFlute[] = _("{PLAYER} setzt\n{STR_VAR_2} ein.\pWilde POKéMON werden angezogen.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_UsedRepel[] = _("{PLAYER} setzt\n{STR_VAR_2} ein.\pWilde POKéMON werden abgehalten.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BoxIsFull[] = _("Die BOXEN sind voll.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_Size[] = _("MASS:"); +const u8 gOtherText_Firm[] = _("GÜTE:"); + +const u8 gContestStatsText_Unknown1[] = _("{STR_VAR_1},{STR_VAR_2} cm"); + +const u8 ContestStatsText_VerySoft[] = _("Sehr weich"); +const u8 ContestStatsText_Soft[] = _("Weich"); +const u8 ContestStatsText_Hard[] = _("Hart"); +const u8 ContestStatsText_VeryHard[] = _("Sehr hart"); +const u8 ContestStatsText_SuperHard[] = _("Steinhart"); + +const u8 ContestStatsText_RedPokeBlock[] = _("{POKEBLOCK} ROT"); +const u8 ContestStatsText_BluePokeBlock[] = _("{POKEBLOCK} BLAU"); +const u8 ContestStatsText_PinkPokeBlock[] = _("{POKEBLOCK} ROSA"); +const u8 ContestStatsText_GreenPokeBlock[] = _("{POKEBLOCK} GRÜN"); +const u8 ContestStatsText_YellowPokeBlock[] = _("{POKEBLOCK} GELB"); +const u8 ContestStatsText_PurplePokeBlock[] = _("{POKEBLOCK} LILA"); +const u8 ContestStatsText_IndigoPokeBlock[] = _("{POKEBLOCK} INDIGO"); +const u8 ContestStatsText_BrownPokeBlock[] = _("{POKEBLOCK} BRAUN"); +const u8 ContestStatsText_LiteBluePokeBlock[] = _("{POKEBLOCK} CYAN"); +const u8 ContestStatsText_OlivePokeBlock[] = _("{POKEBLOCK} OLIV"); +const u8 ContestStatsText_GrayPokeBlock[] = _("{POKEBLOCK} GRAU"); +const u8 ContestStatsText_BlackPokeBlock[] = _("{POKEBLOCK} SCHWARZ"); +const u8 ContestStatsText_WhitePokeBlock[] = _("{POKEBLOCK} WEISS"); +const u8 ContestStatsText_GoldPokeBlock[] = _("{POKEBLOCK} GOLD"); + +const u8 gContestStatsText_Spicy[] = _("SCHARF"); +const u8 gContestStatsText_Dry[] = _("TROCKEN"); +const u8 gContestStatsText_Sweet[] = _("SÜSS"); +const u8 gContestStatsText_Bitter[] = _("BITTER"); +const u8 gContestStatsText_Sour[] = _("SAUER$LECKER$WÜRZE"); + +const u8 gContestStatsText_StowCase[] = _("BOX verstauen."); +const u8 gContestStatsText_ThrowAwayPrompt[] = _("{STR_VAR_1}\nwegwerfen?"); +const u8 gContestStatsText_WasThrownAway[] = _("{STR_VAR_1}\nwurde weggeworfen."); +const u8 gContestStatsText_NormallyAte[] = _("{STR_VAR_1} aß den\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gContestStatsText_HappilyAte[] = _("{STR_VAR_1} aß gerne den\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gContestStatsText_DisdainfullyAte[] = _("{STR_VAR_1} aß ungern den\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); + +const u8 MartText_Buy[] = _("KAUFEN"); +const u8 MartText_Sell[] = _("VERKAUFEN"); +const u8 MartText_Quit2[] = _("TSCHÜSS!"); + +const u8 gOtherText_QuitShopping[] = _("Einkauf beenden."); + +const u8 gOtherText_HowManyYouWant[] = _("{STR_VAR_1}? Aber gerne.\nWie viele möchtest du?"); +const u8 gOtherText_ThatWillBe[] = _("{STR_VAR_1}? Und du möchtest {STR_VAR_2}?\nDas macht dann ¥{STR_VAR_3}."); +const u8 gOtherText_ThatWillBe2[] = _("{STR_VAR_1} soll es sein?\nDas kostet ¥{STR_VAR_2}. Einverstanden?"); +const u8 gOtherText_ThatWillBe3[] = _("Du wolltest {STR_VAR_1}?\nDas kostet ¥{STR_VAR_2}. Einverstanden?"); +const u8 gOtherText_HereYouGo[] = _("Bitte sehr!\nUnd vielen Dank."); +const u8 gOtherText_HereYouGo2[] = _("Vielen Dank!\nEs wird auf deinen PC übertragen."); +const u8 gOtherText_HereYouGo3[] = _("Danke!\nEs wird auf deinen PC übertragen."); +const u8 gOtherText_NotEnoughMoney[] = _("Du hast nicht genug Geld.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoRoomFor[] = _("Du hast keinen Platz für weitere Items.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_SpaceForIsFull[] = _("Es ist kein Platz für {STR_VAR_1}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AnythingElse[] = _("Gibt es noch etwas, womit\nich dienen kann?"); +const u8 gOtherText_CanIHelpYou[] = _("Kann ich dir sonst noch dienlich sein?"); +const u8 gOtherText_FreePremierBall[] = _("Ich gebe dir noch einen PREMIERBALL.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantBuyThat[] = _("{STR_VAR_2}? Es tut mir Leid, aber\ndas kann ich nicht kaufen.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_HowManyToSell[] = _("{STR_VAR_2}?\nWie viele möchtest du verkaufen?"); +const u8 gOtherText_CanPay[] = _("Ich gebe dir ¥{STR_VAR_1}.\nBist du damit einverstanden?"); +const u8 gOtherText_SoldItem[] = _("{STR_VAR_2} wurde übergeben\nim Tausch gegen ¥{STR_VAR_1}."); + +const u8 OtherText_Money[] = _("¥{STR_VAR_1}"); +const u8 OtherText_Shift[] = _("TAUSCH"); +const u8 OtherText_SendOut[] = _("AUSSENDEN"); +const u8 OtherText_Switch2[] = _("TAUSCH"); +const u8 OtherText_Summary[] = _("BERICHT"); +const u8 OtherText_Moves[] = _("ATTACKEN"); +const u8 OtherText_Enter2[] = _("EINTRAGEN"); +const u8 OtherText_NoEntry[] = _("AUSTRAGEN"); +const u8 OtherText_Take[] = _("NEHMEN"); +const u8 OtherText_Read2[] = _("LESEN"); + +const u8 gOtherText_Hp2[] = _("KP"); +const u8 gOtherText_SpAtk2[] = _("SP. ANG."); +const u8 gOtherText_SpDef2[] = _("SP. VER."); +const u8 gOtherText_WontHaveAnyEffect[] = _("Es wird keine Wirkung haben.{PAUSE_UNTIL_PRESS}"); + +const u8 gOtherText_CantUseOnPoke[] = _("Das kann nicht bei diesem\nPOKéMON eingesetzt werden.{PAUSE_UNTIL_PRESS}"); + +const u8 gOtherText_CantBeSwitched[] = _("{STR_VAR_1} kann nicht ausge-\ntauscht werden!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadyBattle[] = _("{STR_VAR_1}\nkämpft bereits!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadySelected[] = _("{STR_VAR_1} ist\nbereits ausgewählt.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoEnergyLeft[] = _("{STR_VAR_1} kann\nnicht kämpfen!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantSwitchPokeWithYours[] = _("Ein POKéMON von {STR_VAR_1} ist\nnicht gegen deins eintauschbar!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_EGGCantBattle[] = _("Ein EI kann nicht kämpfen!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantBeUsedBadge[] = _("Das ist erst einsetzbar, wenn\nein neuer ORDEN errungen wurde."); +const u8 gOtherText_NoMoreThreePoke[] = _("Es können nicht mehr als\ndrei POKéMON teilnehmen."); +const u8 gOtherText_SendRemovedMailPrompt[] = _("Den abgenommenen BRIEF\nauf deinen PC übertragen?"); +const u8 gOtherText_MailWasSent[] = _("Der BRIEF wurde auf deinen\nPC übertragen.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailboxIsFull[] = _("Du kannst keine weiteren BRIEFE\nauf deinen PC übertragen.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailRemovedMessageLost[] = _("Wird der BRIEF entfernt, geht\nder Inhalt verloren, okay?"); +const u8 gOtherText_MailMustBeRemoved[] = _("Der BRIEF muss entfernt werden,\num ein Item tragen zu können.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WasGivenToHold[] = _("{STR_VAR_1} erhält\n{STR_VAR_2} zum Tragen.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadyHolding[] = _("{STR_VAR_1} trägt bereits\n{STR_VAR_2}.\pSollen die Items ausge-\ntauscht werden?"); +const u8 gOtherText_NotHoldingAnything[] = _("{STR_VAR_1} trägt\nkein Item.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ReceivedTheThingFrom[] = _("{STR_VAR_2} von\n{STR_VAR_1} erhalten.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailTaken[] = _("Der BRIEF wurde dem\nPOKéMON abgenommen.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_TakenAndReplaced[] = _("{STR_VAR_2} wurde gegen\n{STR_VAR_1} ausgetauscht.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_PokeHoldingItemCantMail[] = _("Dieses POKéMON trägt ein Item.\nEs kann keinen BRIEF tragen.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailTransferredMailbox[] = _("Der BRIEF wurde von deinem\nPC heruntergeladen.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BagFullCannotRemoveItem[] = _("Der BEUTEL ist voll. Das Item des\nPOKéMON wurde nicht entfernt.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_LearnedMove[] = _("{STR_VAR_1} erlernt\n{STR_VAR_2}!"); +const u8 gOtherText_NotCompatible[] = _("{STR_VAR_1} und {STR_VAR_2}\nsind nicht kompatibel.\p{STR_VAR_2} kann nicht \nerlernt werden.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WantsToLearn[] = _("{STR_VAR_1} versucht,\n{STR_VAR_2} zu erlernen.\pAber {STR_VAR_1} kann maximal\nvier Attacken erlernen.\pSoll eine andere Attacke durch\n{STR_VAR_2} ersetzt werden?"); +const u8 gOtherText_StopTryingTo[] = _("{STR_VAR_2} nicht\nerlernen?"); +const u8 gOtherText_DidNotLearnMove2[] = _("{STR_VAR_1} hat {STR_VAR_2}\nnicht erlernt.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WhichMoveToForget2[] = _("Welche Attacke soll vergessen\nwerden?{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ForgetMove123_2[] = _("{PAUSE 32}1, {PAUSE 15}2 und{PAUSE 15}... {PAUSE 15}... {PAUSE 15}... {PAUSE 15}{PLAY_SE 0x38 0x00} Schwupp!\p{STR_VAR_1} hat\n{STR_VAR_2} vergessen.\pUnd...{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadyKnows[] = _("{STR_VAR_1} kennt\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_HPRestoredBy[] = _("Die KP von {STR_VAR_1} wurden\num {STR_VAR_2} Punkte aufgefüllt.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CuredPoisoning[] = _("Die Vergiftung von {STR_VAR_1}\nwurde geheilt.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CuredParalysis[] = _("Die Paralyse von {STR_VAR_1}\nwurde aufgehoben.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WokeUp[] = _("{STR_VAR_1} ist aufgewacht.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BurnHealed[] = _("Verbrennung von {STR_VAR_1}\nwurde geheilt.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ThawedOut[] = _("{STR_VAR_1} wurde aufgetaut.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_PPRestored[] = _("AP wurden aufgefüllt.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_RegainedHealth[] = _("{STR_VAR_1} erholte sich.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BecameHealthy[] = _("{STR_VAR_1} erholte sich.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_PPIncreased[] = _("AP von {STR_VAR_1}\nwurden angehoben.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ElevatedTo[] = _("{STR_VAR_1} erreicht\nLv. {STR_VAR_2}."); +const u8 gOtherText_WasRaised[] = _("{STR_VAR_2} von\n{STR_VAR_1} wurde angehoben.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_SnapConfusion[] = _("{STR_VAR_1} ist nicht\nmehr verwirrt.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_GotOverLove[] = _("{STR_VAR_1} fühlt sich nicht\nmehr angezogen.{PAUSE_UNTIL_PRESS}"); +const u8 OtherText_ChoosePoke[] = _("Wähle ein POKéMON."); +const u8 OtherText_MovePokeTo[] = _("An wessen Stelle setzen?"); +const u8 OtherText_TeachWhat[] = _("Welches POKéMON lehren?"); +const u8 OtherText_UseWhat[] = _("Welches POKéMON?"); +const u8 OtherText_GiveWhat[] = _("Welchem POKéMON geben?"); +const u8 OtherText_DoWhat[] = _("Was tun mit {STR_VAR_1}?"); +const u8 OtherText_NothingToCut[] = _("Hier nicht einsetzbar."); +const u8 OtherText_CantSurf[] = _("SURFER nicht einsetzbar."); +const u8 OtherText_AlreadySurfing[] = _("SURFER ist eingesetzt."); +const u8 OtherText_CantUseThatHere[] = _("Hier nicht einsetzbar."); +const u8 OtherText_RestoreWhatMove[] = _("Welche Attacke auffüllen?"); +const u8 OtherText_BoostPP[] = _("AP welcher Attacke heben?"); +const u8 OtherText_DoWhatWithItem[] = _("Was willst du mit dem Item?"); +const u8 OtherText_NoPokeForBattle[] = _("Kein POKéMON kampfbereit!"); +const u8 OtherText_ChoosePoke2[] = _("Wähle ein POKéMON."); +const u8 OtherText_NotEnoughHP[] = _("Nicht genügend KP..."); +const u8 OtherText_ThreePokeNeeded[] = _("Drei POKéMON sind nötig."); +const u8 OtherText_PokeCantBeSame[] = _("Nicht dieselben POKéMON!"); +const u8 OtherText_NoIdenticalHoldItems[] = _("Nicht dieselben Items!"); +const u8 OtherText_TeachWhichPoke[] = _("Welches POKéMON lehren?"); +const u8 gOtherText_Attack[] = _("ANGRIFF"); +const u8 gOtherText_Defense[] = _("VERT."); +const u8 gOtherText_SpAtk[] = _("SP.ANG."); +const u8 gOtherText_SpDef[] = _("SP.VER."); +const u8 gOtherText_Speed[] = _("INIT."); +const u8 gOtherText_HP[] = _("KP"); +const u8 gOtherText_Terminator18[] = _(""); +const u8 gOtherText_OriginalTrainer[] = _("OT:"); +const u8 gOtherText_Type2[] = _("TYP:"); +const u8 gOtherText_Power2[] = _("STÄRKE"); +const u8 gOtherText_Accuracy2[] = _("GENAU."); +const u8 gOtherText_Appeal2[] = _("AUSDR."); +const u8 gOtherText_Jam2[] = _("EINDR."); +const u8 gOtherText_Status[] = _("STATUS"); +const u8 gOtherText_ExpPoints[] = _("E.-PUNKTE"); +const u8 gOtherText_NextLv[] = _("NÄCHST. Lv."); +const u8 gOtherText_Ribbons00[] = _("BÄNDER: 00"); + +const u8 OtherText_Event[] = _("GESCHEHEN"); +const u8 OtherText_Switch[] = _("TAUSCH"); +const u8 OtherText_PokeInfo[] = _("POKéMON-INFO"); +const u8 OtherText_PokeSkills[] = _("POKéMON-FÄHIG."); +const u8 OtherText_BattleMoves[] = _("ATTACKEN"); +const u8 OtherText_ContestMoves[] = _("WETT.-ATTACKEN"); +const u8 OtherText_Info[] = _("INFO"); + +const u8 gOtherText_EggLongTime[] = _("Dieses EI braucht sicher\nnoch lange, bis es schlüpft."); +const u8 gOtherText_EggSomeTime[] = _("Was da wohl schlüpfen wird?\nEs wird sicher lange dauern."); +const u8 gOtherText_EggSoon[] = _("Es bewegt sich manchmal.\nVielleicht schlüpft es bald?"); +const u8 gOtherText_EggAbout[] = _("Es macht Geräusche.\nSicher schlüpft es bald!"); +const u8 gOtherText_CantForgetHMs[] = _("VM-Attacken können jetzt\nnicht vergessen werden."); +const u8 gOtherText_PlayersBase[] = _("BASIS v. {PLAYER}"); +const u8 gOtherText_OkayToDeleteFromRegistry[] = _("Soll {STR_VAR_1} aus dem GRUNDBUCH\ngelöscht werden?"); +const u8 gOtherText_RegisteredDataDeleted[] = _("Eingetragene Daten wurden gelöscht.{PAUSE_UNTIL_PRESS}"); + +const u8 gSecretBaseText_NoRegistry[] = _("Es gibt kein GRUNDBUCH.{PAUSE_UNTIL_PRESS}"); +const u8 SecretBaseText_DelRegist[] = _("EINTR. LÖSCHEN"); +const u8 SecretBaseText_Decorate[] = _("DEKORIEREN"); +const u8 SecretBaseText_PutAway[] = _("WEGNEHMEN"); +const u8 SecretBaseText_Toss[] = _("WEGWERFEN"); +const u8 SecretBaseText_PutOutDecor[] = _("Wähle eine Dekoration \nund stelle sie auf."); +const u8 SecretBaseText_StoreChosenDecor[] = _("Wähle eine Dekoration und \nübertrage sie auf deinen PC."); +const u8 SecretBaseText_ThrowAwayDecor[] = _("Wähle eine Dekoration\nund wirf sie weg."); +const u8 gSecretBaseText_NoDecors[] = _("Es gibt keine Dekoration.{PAUSE_UNTIL_PRESS}"); +const u8 SecretBaseText_Desk[] = _("TISCH"); +const u8 SecretBaseText_Chair[] = _("STUHL"); +const u8 SecretBaseText_Plant[] = _("PFLANZE"); +const u8 SecretBaseText_Ornament[] = _("ORNAMENT"); +const u8 SecretBaseText_Mat[] = _("MATTE"); +const u8 SecretBaseText_Poster[] = _("POSTER"); +const u8 SecretBaseText_Doll[] = _("PUPPE"); +const u8 SecretBaseText_Cushion[] = _("KISSEN"); +const u8 gSecretBaseText_GoldRank[] = _("GOLD"); +const u8 gSecretBaseText_SilverRank[] = _("SILBER"); +const u8 gSecretBaseText_PlaceItHere[] = _("Hierhin platzieren?"); +const u8 gSecretBaseText_CantBePlacedHere[] = _("Kann hier nicht platziert werden."); +const u8 gSecretBaseText_CancelDecorating[] = _("Dekorieren beenden?"); +const u8 gSecretBaseText_InUseAlready[] = _("Das wurde bereits platziert."); +const u8 gSecretBaseText_NoMoreDecor[] = _("Mehr kann nicht dekoriert werden. Es\nist nur Platz für {STR_VAR_1} Dekorationen."); +const u8 gSecretBaseText_NoMoreDecor2[] = _("Mehr kann nicht dekoriert werden. Es\nist nur Platz für {STR_VAR_1} Dekorationen."); +const u8 gSecretBaseText_DecorMustPlaceOnTable[] = _("Das geht nicht. Es muss auf einem\nTISCH oder Ähnlichem stehen."); +const u8 gSecretBaseText_DecorCantPlace[] = _("Die Dekoration kann nicht in deinem\neigenen Zimmer aufgestellt werden."); +const u8 gSecretBaseText_DecorInUse[] = _("Diese Dekoration wurde platziert.\nDu kannst sie nicht wegwerfen."); +const u8 gSecretBaseText_WillBeDiscarded[] = _("{STR_VAR_1} wird weggeworfen.\nEinverstanden?"); +const u8 gSecretBaseText_DecorThrownAway[] = _("Die Dekoration wurde weggeworfen."); +const u8 gSecretBaseText_StopPuttingAwayDecor[] = _("Wegnehmen von Dekoration beenden?"); +const u8 gSecretBaseText_NoDecor[] = _("Hier ist keine Dekoration."); +const u8 gSecretBaseText_ReturnDecor[] = _("Diese Dekoration auf \nden PC übertragen?"); +const u8 gSecretBaseText_DecorReturned[] = _("Die Dekoration wurde auf\nden PC übertragen."); +const u8 gSecretBaseText_NoDecorInUse[] = _("Es sind keine Dekorationen platziert.{PAUSE_UNTIL_PRESS}"); +const u8 SecretBaseText_Tristan[] = _("TATIAN"); +const u8 SecretBaseText_Philip[] = _("LARS"); +const u8 SecretBaseText_Dennis[] = _("KLAAS"); +const u8 SecretBaseText_Roberto[] = _("HAINER"); +const u8 SecretBaseText_TurnOff[] = _("AUSSCHALTEN"); +const u8 SecretBaseText_Decoration[] = _("DEKORATION"); +const u8 SecretBaseText_ItemStorage[] = _("ITEM-LAGER"); + +const u8 gPCText_Mailbox[] = _("BRIEFBOX"); +const u8 PCText_DepositItem[] = _("ITEM ABLEGEN"); +const u8 PCText_WithdrawItem[] = _("ITEM NEHMEN"); +const u8 PCText_TossItem[] = _("ITEM IN MÜLL"); +const u8 PCText_StoreItems[] = _("Lagere Items auf deinem PC."); +const u8 PCText_TakeOutItems[] = _("Nimm Items von deinem PC."); +const u8 PCText_ThrowAwayItems[] = _("Wirf gelagerte Items weg."); + +const u8 gOtherText_NoItems[] = _("Es gibt keine Items.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoMoreRoom[] = _("In deinem BEUTEL\nist kein Platz mehr."); +const u8 gOtherText_HowManyToWithdraw[] = _("Wie viele möchtest\ndu aufnehmen?"); +const u8 gOtherText_WithdrewThing[] = _("{STR_VAR_2} × {STR_VAR_1}\naufgenommen."); +const u8 OtherText_Read[] = _("LESEN"); +const u8 gOtherText_MoveToBag[] = _("IN BEUTEL GEBEN"); +const u8 OtherText_Give[] = _("GEBEN"); +const u8 gOtherText_NoMailHere[] = _("Hier ist kein BRIEF.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WhatWillYouDoMail[] = _("Was soll mit dem BRIEF von\n{STR_VAR_1} geschehen?"); +const u8 gOtherText_MessageWillBeLost[] = _("Der Inhalt geht verloren.\nIst das in Ordnung für dich?"); +const u8 gOtherText_BagIsFull[] = _("Der BEUTEL ist voll.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailWasReturned[] = _("Der BRIEF, dessen Inhalt gelöscht\nist, wurde im BEUTEL gelagert.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_Dad[] = _("VATI"); +const u8 gOtherText_Mom[] = _("MUTTI"); +const u8 gOtherText_Wallace[] = _("WASSILI"); +const u8 gOtherText_Steven[] = _("TROY"); +const u8 gOtherText_Brawly[] = _("KAMILLO"); +const u8 gOtherText_Winona[] = _("WIBKE"); +const u8 gOtherText_Phoebe[] = _("ANTONIA"); +const u8 gOtherText_Glacia[] = _("FROSINA"); +const u8 gContestText_ContestWinner[] = _("-WETTBEWERBSSIEGER\n"); +const u8 gOtherText_Unknown1[] = _(" von "); +const u8 OtherText_Cool[] = _("COOL."); +const u8 OtherText_Beauty2[] = _("SCHÖN."); +const u8 OtherText_Cute[] = _("ANMUT"); +const u8 OtherText_Smart[] = _("KLUG."); +const u8 OtherText_Tough[] = _("STÄRKE"); +const u8 OtherText_NonstopSuperCool[] = _("Super-mega-cool ist\ndieses umwerfende "); +const u8 OtherText_Terminator6[] = _(""); +const u8 OtherText_GoodLookingPoke[] = _("Das anbetungswürdige\nPOKéMON: "); +const u8 OtherText_Terminator7[] = _(""); +const u8 OtherText_MarvelousGreat[] = _("Phantastisch, großartig -\nschlicht brillant: "); +const u8 OtherText_Terminator8[] = _(""); +const u8 OtherText_CenturyLastVenus[] = _("Ein Bild von einem POKéMON!\nDas wunderschöne "); +const u8 OtherText_Terminator9[] = _(""); +const u8 OtherText_Terminator10[] = _("Einfach umwerfend, das strahlende\nLächeln von "); +const u8 OtherText_DazzlingSmile[] = _(""); +const u8 OtherText_PokeCenterIdol[] = _("Superstar des POKéMON-CENTERs -\ndas unvergleichliche "); +const u8 OtherText_Terminator11[] = _(""); +const u8 OtherText_LovelyAndSweet[] = _("Das liebliche, zuckersüße "); +const u8 OtherText_Terminator12[] = _(""); +const u8 OtherText_ThePretty[] = _("Das Gewinner-Portrait\nvon dem hübschen "); +const u8 OtherText_WinningPortrait[] = _(""); +const u8 OtherText_GiveUsWink[] = _("Winke uns zu, du\ngoldiges "); +const u8 OtherText_Terminator13[] = _(""); +const u8 OtherText_SmartnessMaestro[] = _("Der Gelehrte unter den\nPOKéMON! Das weise "); +const u8 OtherText_Terminator14[] = _(""); +const u8 OtherText_ChosenPokeAmong[] = _("Das auserwählte und\neinzigartige POKéMON: "); +const u8 OtherText_Terminator15[] = _(""); +const u8 OtherText_TheExcellent[] = _("Das grandiose "); +const u8 OtherText_ItsMomentOfElegance[] = _(" -\nder Inbegriff von Eleganz und Stil"); +const u8 OtherText_PowerfullyMuscular[] = _("Der energische, kraftstrotzende\nÜberflieger: "); +const u8 OtherText_Terminator16[] = _(""); +const u8 OtherText_StrongErEst[] = _("Stark, stärker, am stärksten -\ndas allerstärkste "); +const u8 OtherText_Terminator17[] = _(""); +const u8 OtherText_MightyTough[] = _("Das mächtige, prächtige - das\nstärkste POKéMON: "); +const u8 OtherText_Exclamation[] = _(""); +const u8 OtherText_Petalburg[] = _("BLÜTENBURG CITY"); +const u8 OtherText_Slateport[] = _("GRAPHITPORT CITY"); +const u8 OtherText_Littleroot[] = _("WURZELHEIM"); +const u8 OtherText_Lilycove[] = _("SEEGRASULB CITY"); +const u8 OtherText_Dewford[] = _("FAUSTAUHAVEN"); +const u8 OtherText_Enter[] = _("JA"); +const u8 OtherText_Info3[] = _("INFO"); +const u8 OtherText_WhatsAContest[] = _("Der WETTBEWERB"); +const u8 OtherText_TypesOfContest[] = _("WETTBEWERB-Arten"); +const u8 OtherText_Ranks[] = _("Klassen"); +const u8 OtherText_Judging[] = _("Bewertung"); +const u8 OtherText_CoolContest[] = _("COOL.-WETTB."); +const u8 OtherText_BeautyContest[] = _("SCHÖN.-WETTB."); +const u8 OtherText_CuteContest[] = _("ANMUT-WETTB."); +const u8 OtherText_SmartContest[] = _("KLUG.-WETTB."); +const u8 OtherText_ToughContest[] = _("STÄRKE-WETTB."); +const u8 OtherText_Decoration[] = _("DEKORATION"); +const u8 OtherText_PackUp[] = _("EINPACKEN"); +const u8 OtherText_Count[] = _("ZÄHLEN"); +const u8 OtherText_Registry[] = _("GRUNDBUCH"); +const u8 OtherText_Information[] = _("INFORMATION"); +const u8 OtherText_Mach[] = _("EIL"); +const u8 OtherText_Acro[] = _("KUNST"); +const u8 OtherText_Poison[] = _("GIF"); +const u8 OtherText_Paralysis[] = _("PAR"); +const u8 OtherText_Sleep[] = _("SLF"); +const u8 OtherText_Burn[] = _("BRT"); +const u8 OtherText_Frozen[] = _("GFR"); +const u8 OtherText_Quit[] = _("ZURÜCK"); +const u8 OtherText_SawIt[] = _("Gesehen"); +const u8 OtherText_NotYet[] = _("Noch nicht"); +const u8 OtherText_Yes[] = _("JA"); +const u8 OtherText_No[] = _("NEIN"); +const u8 OtherText_Info2[] = _("INFO"); +const u8 OtherText_SingleBattle[] = _("EINZELKAMPF"); +const u8 OtherText_DoubleBattle[] = _("DOPPELKAMPF"); +const u8 OtherText_MultiBattle[] = _("MULTIKAMPF"); +const u8 OtherText_MrBriney[] = _("MR. BRACK"); +const u8 OtherText_MakeAChallenge[] = _("Zum Kampf fordern"); +const u8 OtherText_ObtainInformation[] = _("Information dazu"); +const u8 OtherText_Lv50_2[] = _("Lv. 50"); +const u8 OtherText_Lv100_2[] = _("Lv. 100"); +const u8 OtherText_Zigzagoon[] = _("ZIGZACHS"); +const u8 OtherText_Nincada[] = _("NINCADA"); +const u8 OtherText_Poochyena[] = _("FIFFYEN"); +const u8 OtherText_Nincada2[] = _("NINCADA"); +const u8 OtherText_Lotad[] = _("LOTURZEL"); +const u8 OtherText_Roselia[] = _("ROSELIA"); +const u8 OtherText_Shroomish[] = _("KNILZ"); +const u8 OtherText_Nincada3[] = _("NINCADA"); +const u8 OtherText_Surskit[] = _("GEHWEIHER"); +const u8 OtherText_Treecko[] = _("GECKARBOR"); +const u8 OtherText_Torchic[] = _("FLEMMLI"); +const u8 OtherText_Mudkip[] = _("HYDROPI"); +const u8 OtherText_Seedot[] = _("SAMURZEL"); +const u8 OtherText_Shroomish2[] = _("KNILZ"); +const u8 OtherText_Spinda[] = _("PANDIR"); +const u8 OtherText_Shroomish3[] = _("KNILZ"); +const u8 OtherText_Zigzagoon2[] = _("ZIGZACHS"); +const u8 OtherText_Wurmple[] = _("WAUMPEL"); +const u8 OtherText_PokeBall[] = _("POKéBALL"); +const u8 OtherText_SuperPotion[] = _("SUPERTRANK"); +const u8 OtherText_SamePrice[] = _("Zum selben Preis"); +const u8 OtherText_Yen135[] = _("¥135"); +const u8 OtherText_Yen155[] = _("¥155"); +const u8 OtherText_Yen175[] = _("¥175"); +const u8 OtherText_CostMore[] = _("Sie kosten mehr."); +const u8 OtherText_CostLess[] = _("Sie kosten weniger."); +const u8 OtherText_SamePrice2[] = _("Gleicher Preis"); +const u8 OtherText_MaleSymbol[] = _("♂"); +const u8 OtherText_FemaleSymbol[] = _("♀"); +const u8 OtherText_Neither[] = _("Weder noch"); +const u8 OtherText_Males[] = _("Männer"); +const u8 OtherText_Females[] = _("Frauen"); +const u8 OtherText_SameNumber[] = _("Gleich viele"); +const u8 OtherText_Male[] = _("Männlich"); +const u8 OtherText_Female[] = _("Weiblich"); +const u8 OtherText_ItDepends[] = _("Ansichtssache"); +const u8 OtherText_Six2[] = _("6"); +const u8 OtherText_Eight2[] = _("8"); +const u8 OtherText_Ten[] = _("10"); +const u8 OtherText_One[] = _("1"); +const u8 OtherText_Two[] = _("2"); +const u8 OtherText_Three[] = _("3"); +const u8 OtherText_Six[] = _("6"); +const u8 OtherText_Seven[] = _("7"); +const u8 OtherText_Eight[] = _("8"); +const u8 OtherText_FreshWater[] = _("TAFELWASSER{CLEAR_TO 72}¥200"); +const u8 OtherText_SodaPop[] = _("SPRUDEL{CLEAR_TO 72}¥300"); +const u8 OtherText_Lemonade[] = _("LIMONADE{CLEAR_TO 72}¥350"); +const u8 OtherText_HowToRide[] = _("RAD FAHREN"); +const u8 OtherText_HowToTurn[] = _("KURVEN FAHREN"); +const u8 OtherText_SandySlopes[] = _("SANDHÜGEL"); +const u8 OtherText_Wheelies[] = _("WHEELIES"); +const u8 OtherText_BunnyHops[] = _("HOPPELN"); +const u8 OtherText_Jumping[] = _("SPRINGEN"); +const u8 OtherText_Satisfied[] = _("Zufrieden"); +const u8 OtherText_Dissatisfied[] = _("Unzufrieden"); +const u8 OtherText_Deepseatooth[] = _("ABYSSZAHN"); +const u8 OtherText_Deepseascale[] = _("ABYSSPLATTE"); +const u8 OtherText_BlueFlute2[] = _("BLAUE FLÖTE"); +const u8 OtherText_YellowFlute2[] = _("GELBE FLÖTE"); +const u8 OtherText_RedFlute2[] = _("ROTE FLÖTE"); +const u8 OtherText_WhiteFlute2[] = _("WEISSE FLÖTE"); +const u8 OtherText_BlackFlute2[] = _("SCHWRZ. FLÖTE"); +const u8 OtherText_GlassChair[] = _("GLASSTUHL"); +const u8 OtherText_GlassDesk[] = _("GLASTISCH"); +const u8 OtherText_TreeckoDoll[] = _("GECKARBOR-PUPPE 1.000 M."); +const u8 OtherText_TorchicDoll[] = _("FLEMMLI-PUPPE 1.000 M."); +const u8 OtherText_MudkipDoll[] = _("HYDROPI-PUPPE 1.000 M."); +const u8 OtherText_50Coins[] = _(" 50 MÜNZEN ¥1.000"); +const u8 OtherText_500Coins[] = _("500 MÜNZEN ¥10.000"); +const u8 OtherText_Excellent[] = _("Klasse!"); +const u8 OtherText_NotSoHot[] = _("Naja..."); +const u8 OtherText_RedShard[] = _("PURPURSTÜCK"); +const u8 OtherText_YellowShard[] = _("GELBSTÜCK"); +const u8 OtherText_BlueShard[] = _("INDIGOSTÜCK"); +const u8 OtherText_GreenShard[] = _("GRÜNSTÜCK"); +const u8 OtherText_BattleTower[] = _("DUELLTURM"); +const u8 OtherText_Right[] = _("Rechts"); +const u8 OtherText_Left[] = _("Links"); +const u8 OtherText_TM32[] = _("TM32 1.500 MÜNZEN"); +const u8 OtherText_TM29[] = _("TM29 3.500 MÜNZEN"); +const u8 OtherText_TM35[] = _("TM35 4.000 MÜNZEN"); +const u8 OtherText_TM24[] = _("TM24 4.000 MÜNZEN"); +const u8 OtherText_TM13[] = _("TM13 4.000 MÜNZEN"); +const u8 OtherText_1F_2[] = _("EG"); +const u8 OtherText_2F_2[] = _("1S"); +const u8 OtherText_3F_2[] = _("2S"); +const u8 OtherText_4F_2[] = _("3S"); +const u8 OtherText_5F_2[] = _("4S"); +const u8 OtherText_Cool2[] = _("COOL."); +const u8 OtherText_Beauty3[] = _("SCHÖN."); +const u8 OtherText_Cute2[] = _("ANMUT"); +const u8 OtherText_Smart2[] = _("KLUG."); +const u8 OtherText_Tough2[] = _("STÄRKE"); +const u8 OtherText_Normal[] = _("NORMAL"); +const u8 OtherText_Super[] = _("SUPER"); +const u8 OtherText_Hyper[] = _("HYPER"); +const u8 OtherText_Master[] = _("MASTER"); +const u8 OtherText_Cool3[] = _("COOL."); +const u8 OtherText_Beauty4[] = _("SCHÖN."); +const u8 OtherText_Cute3[] = _("ANMUT"); +const u8 OtherText_Smart3[] = _("KLUG."); +const u8 OtherText_Tough3[] = _("STÄRKE"); +const u8 OtherText_Items[] = _("ITEM"); +const u8 OtherText_KeyItems[] = _("BASIS-ITEM"); +const u8 OtherText_Balls[] = _("BALL"); +const u8 OtherText_TMsHMs[] = _("TM/VM"); +const u8 OtherText_Berries[] = _("BEEREN"); + +const u8 gPCText_SomeonesPC[] = _("JEMANDES PC"); +const u8 gPCText_LanettesPC[] = _("LANETTES PC"); +const u8 gPCText_PlayersPC[] = _("PC von {PLAYER}"); +const u8 gPCText_HallOfFame[] = _("RUHMESHALLE"); +const u8 gPCText_LogOff[] = _("AUSLOGGEN"); + +const u8 gOtherText_99Times[] = _("99-mal +"); +const u8 gOtherText_1Minute[] = _("1 Minute +"); +const u8 gOtherText_Seconds[] = _(" Sekunden"); +const u8 gOtherText_Times[] = _("-mal$."); +const u8 gOtherText_BigGuy[] = _(""); +const u8 gOtherText_BigGirl[] = _(""); +const u8 gOtherText_Son[] = _("Sohn"); +const u8 gOtherText_Daughter[] = _("Tochter"); +const u8 OtherText_BlueFlute[] = _("BLAUE FLÖTE"); +const u8 OtherText_YellowFlute[] = _("GELBE FLÖTE"); +const u8 OtherText_RedFlute[] = _("ROTE FLÖTE"); +const u8 OtherText_WhiteFlute[] = _("WEISSE FLÖTE"); +const u8 OtherText_BlackFlute[] = _("SCHWRZ. FLÖTE"); +const u8 OtherText_PrettyChair[] = _("EDLER STUHL"); +const u8 OtherText_PrettyDesk[] = _("EDLER TISCH"); +const u8 OtherText_1F[] = _("EG"); +const u8 OtherText_2F[] = _("1S"); +const u8 OtherText_3F[] = _("2S"); +const u8 OtherText_4F[] = _("3S"); +const u8 OtherText_5F[] = _("4S"); +const u8 OtherText_6F[] = _("5S"); +const u8 OtherText_7F[] = _("6S"); +const u8 OtherText_8F[] = _("7S"); +const u8 OtherText_9F[] = _("8S"); +const u8 OtherText_10F[] = _("9S"); +const u8 OtherText_11F[] = _("10S"); +const u8 OtherText_B1F[] = _("U1S"); +const u8 OtherText_B2F[] = _("U2S"); +const u8 OtherText_B3F[] = _("U3S"); +const u8 OtherText_B4F[] = _("U4S"); +const u8 OtherText_Rooftop[] = _("DACH"); + +const u8 gOtherText_NowOn[] = _("Momentan im"); + +const u8 gPCText_Cancel[] = _("ZURÜCK"); + +const u8 PCText_ExitBox[] = _("Die BOX verlassen?"); +const u8 PCText_WhatYouDo[] = _("Was möchtest du tun?"); +const u8 PCText_PickATheme[] = _("Wähle eine Motivsammlung."); +const u8 PCText_PickAWallpaper[] = _("Wähle ein Hintergrundmotiv."); +const u8 PCText_IsSelected[] = _(" ist ausgewählt."); +const u8 PCText_JumpToWhichBox[] = _("Zu welcher BOX wechseln?"); +const u8 PCText_DepositInWhichBox[] = _("In welche BOX ablegen?"); +const u8 PCText_WasDeposited[] = _(" wurde abgelegt."); +const u8 PCText_BoxIsFull[] = _("Die BOX ist voll."); +const u8 PCText_ReleasePoke[] = _("Dieses POKéMON freilassen?"); +const u8 PCText_WasReleased[] = _("{STR_VAR_1} ist wieder frei."); +const u8 PCText_ByeBye[] = _("Tschüss, !"); +const u8 PCText_MarkPoke[] = _("Markiere dein POKéMON."); +const u8 PCText_LastPoke[] = _("Dein letztes POKéMON!"); +const u8 PCText_PartyFull[] = _("Dein Team ist voll!"); +const u8 PCText_HoldingPoke[] = _("Du hältst ein POKéMON!"); +const u8 PCText_WhichOneWillTake[] = _("Welches wählst du aus?"); +const u8 PCText_CantReleaseEgg[] = _("Du kannst kein EI freilass.!"); +const u8 PCText_ContinueBox[] = _("Die BOX weiter bearbeiten?"); +const u8 PCText_CameBack[] = _(" kam zurück!"); +const u8 PCText_Worried[] = _("War es in Sorge um dich?"); +const u8 PCText_Surprise[] = _("... ... ... ... ...!"); +const u8 PCText_PleaseRemoveMail[] = _("BRIEF bitte entfernen."); +const u8 PCText_Cancel2[] = _("ZURÜCK"); +const u8 PCText_Deposit[] = _("ABLEGEN"); +const u8 PCText_Withdraw[] = _("NEHMEN"); +const u8 PCText_Switch[] = _("TAUSCHEN"); +const u8 PCText_Move[] = _("BEWEGEN"); +const u8 PCText_Place[] = _("ABSETZEN"); +const u8 PCText_Summary[] = _("BERICHT"); +const u8 PCText_Release[] = _("ENTLASS."); +const u8 PCText_Mark[] = _("MARKIER."); +const u8 PCText_Name[] = _("BENENNEN"); +const u8 PCText_Jump[] = _("WECHSELN"); +const u8 PCText_Wallpaper[] = _("MOTIV"); +const u8 PCText_Scenery1[] = _("LISTE 1"); +const u8 PCText_Scenery2[] = _("LISTE 2"); +const u8 PCText_Scenery3[] = _("LISTE 3"); +const u8 PCText_Etc[] = _("SONSTIGES"); +const u8 PCText_Forest[] = _("WALD"); +const u8 PCText_City[] = _("MAUER"); +const u8 PCText_Desert[] = _("WÜSTE"); +const u8 PCText_Savanna[] = _("STEPPE"); +const u8 PCText_Crag[] = _("GERÖLL"); +const u8 PCText_Volcano[] = _("VULKAN"); +const u8 PCText_Snow[] = _("SCHNEE"); +const u8 PCText_Cave[] = _("HÖHLE"); +const u8 PCText_Beach[] = _("STRAND"); +const u8 PCText_Seafloor[] = _("TIEFSEE"); +const u8 PCText_River[] = _("FLUSS"); +const u8 PCText_Sky[] = _("HIMMEL"); +const u8 PCText_Polka[] = _("PUNKTE"); +const u8 PCText_PokeCenter[] = _("POKéCENTER"); +const u8 PCText_Machine[] = _("MASCHINE"); +const u8 PCText_Plain[] = _("WEISS"); +const u8 PCText_WhatDoYouWant[] = _("Was willst du tun?"); +const u8 PCText_WithdrawPoke[] = _("POKéMON NEHMEN"); +const u8 PCText_DepositPoke[] = _("POKéMON ABLEGEN"); +const u8 PCText_MovePoke[] = _("POKéMON BEWEGEN"); +const u8 PCText_SeeYa[] = _("TSCHÜSSI!"); +const u8 PCText_MovePokeToParty[] = _("Nimm POKéMON aus einer\nBOX in dein Team auf."); +const u8 PCText_StorePokeInBox[] = _("Lagere POKéMON aus deinem\nTeam in einer BOX."); +const u8 PCText_OrganizeBoxesParty[] = _("Ordne POKéMON in den BOXEN\nund/oder in deinem Team."); +const u8 PCText_ReturnToPrevMenu[] = _("Zurück zum vorherigen Menü."); + +const u8 gPCText_OnlyOne[] = _("Du führst nur ein POKéMON mit dir."); +const u8 gPCText_PartyFull2[] = _("Dein Team ist voll!"); +const u8 gPCText_BOX[] = _("BOX "); + +// pokenav +const u8 PCText_CheckMap[] = _("{CLEAR 0}Karte der HOENN-Region"); +const u8 PCText_CheckPoke[] = _("{CLEAR 0}POKéMON-Daten im Detail"); +const u8 PCText_CheckTrainer[] = _("{CLEAR 0}TRAINER-Daten im Detail"); +const u8 PCText_CheckRibbons[] = _("{CLEAR 0}Einsicht über BÄNDER"); +const u8 PCText_PutAwayNav[] = _("{CLEAR 0}POKéNAV schließen"); +const u8 PCText_NoRibbonWin[] = _("{CLEAR 0}Es gibt keine BÄNDER."); +const u8 PCText_NoTrainers[] = _("{CLEAR 0}Keine TRAINER-Daten aufgenommen"); +const u8 PCText_CheckParty[] = _("{CLEAR 0}Daten über POKéMON des Teams"); +const u8 PCText_CheckPokeAll[] = _("{CLEAR 0}Daten über alle POKéMON"); +const u8 PCText_ReturnToNav[] = _("{CLEAR 0}Zurück zum POKéNAV-Menü"); +const u8 PCText_FindCool[] = _("{CLEAR 0}Nach coolen POKéMON suchen."); +const u8 PCText_FindBeauty[] = _("{CLEAR 0}Nach schönen POKéMON suchen."); +const u8 PCText_FindCute[] = _("{CLEAR 0}Nach anmutigen POKéMON suchen."); +const u8 PCText_FindSmart[] = _("{CLEAR 0}Nach klugen POKéMON suchen."); +const u8 PCText_FindTough[] = _("{CLEAR 0}Nach starken POKéMON suchen."); +const u8 PCText_ReturnToCondition[] = _("{CLEAR 0}Zurück zum Menüpunkt ZUSTAND"); + +const u8 gOtherText_NumberRegistered[] = _("Registrierte:"); +const u8 gOtherText_NumberBattles[] = _("Kämpfe:"); +const u8 gOtherText_Strategy[] = _("{PALETTE 5}TAKTIK:"); +const u8 gOtherText_TrainersPokemon[] = _("{PALETTE 5}POKéMON:"); +const u8 gOtherText_SelfIntroduction[] = _("{PALETTE 5}MOTTO:"); +const u8 gOtherText_Nature2[] = _("NATUR/"); +const u8 gOtherText_InParty[] = _("IM TEAM"); +const u8 gOtherText_Number[] = _("Nr. "); +const u8 gOtherText_Ribbons[] = _("BÄNDER"); +const u8 OtherText_MakeProfilePage1[] = _("Erstelle dein eigenes Profil:"); +const u8 OtherText_MakeProfilePage2[] = _("Kombiniere 4 Wörter/Ausdrücke."); +const u8 OtherText_MakeMessagePage1[] = _("Verwende 6 Ausdrücke."); +const u8 OtherText_MakeMessagePage2[] = _("Max. pro Zeile 2-mal 12 Buchstaben"); +const u8 OtherText_DescribeFeelingsPage1[] = _("Finde Worte, die deine momentanen"); +const u8 OtherText_DescribeFeelingsPage2[] = _("Empfindungen beschreiben."); +const u8 OtherText_WithFourPhrases[] = _("Verwende 4 Ausdrücke und"); +const u8 OtherText_CombineNinePhrasesPage1[] = _("Kombiniere 9 Ausdrücke und"); +const u8 OtherText_CombineNinePhrasesPage2[] = _("erstelle eine Nachricht."); +const u8 OtherText_ImproveBardSongPage1[] = _("Ändere nur 1 Wort/Ausdruck"); +const u8 OtherText_ImproveBardSongPage2[] = _("und verbessere das BARDEN-Lied."); +const u8 OtherText_YourProfile[] = _("Dein Profil"); +const u8 OtherText_YourFeelingBattle[] = _("Deine Gefühle zum Kampfbeginn"); +const u8 OtherText_SetWinMessage[] = _("Deine Worte im Fall des Sieges"); +const u8 OtherText_SetLossMessage[] = _("Deine Worte im Fall der Niederlage"); +const u8 OtherText_TheAnswer[] = _("Die Antwort"); +const u8 OtherText_MailMessage[] = _("Der Inhalt des BRIEFES"); +const u8 OtherText_MailSalutation[] = _("Der Gruß des BRIEFES"); +const u8 OtherText_NewSong[] = _("Das neue Lied"); +const u8 OtherText_CombineTwoPhrasesPage1[] = _("Kombiniere 2 Ausdrücke und"); +const u8 OtherText_CombineTwoPhrasesPage2[] = _("schaffe einen hippen Spruch."); +const u8 OtherText_ConfirmTrendyPage1[] = _("Der hippe Spruch"); +const u8 OtherText_ConfirmTrendyPage2[] = _("lautet also so. O.K.?"); +const u8 OtherText_HipsterPage1[] = _("Kombiniere 2 Ausdrücke und"); +const u8 OtherText_HipsterPage2[] = _("bringe ihr einen guten Spruch bei."); + +const u8 gOtherText_TextDeletedConfirmPage1[] = _("Der gesamte verfasste Text wird"); +const u8 gOtherText_TextDeletedConfirmPage2[] = _("gelöscht. Einverstanden?"); +const u8 gOtherText_QuitEditing[] = _("Das Textverfassen beenden?"); +const u8 gOtherText_EditedTextNoSavePage1[] = _("Der Text wird nicht gespeichert."); +const u8 gOtherText_EditedTextNoSavePage2[] = _("Ist das in Ordnung?"); +const u8 gOtherText_EnterAPhraseOrWord[] = _("Bitte Wort/Ausdruck eingeben."); +const u8 gOtherText_TextNoDelete[] = _("Gesamter Text ist nicht löschbar."); +const u8 gOtherText_OnlyOnePhrase[] = _("Nur ein Ausdruck ist änderbar."); +const u8 gOtherText_OriginalSongRestored[] = _("Das Lied wird wiederhergestellt."); +const u8 gOtherText_TrendyAlready[] = _("Das ist bereits hip."); +const u8 gOtherText_CombineTwoPhrases[] = _("Kombiniere 2 Wörter/Ausdrücke."); +const u8 gOtherText_QuitGivingInfo[] = _("Keine weiteren Infos liefern?"); +const u8 gOtherText_StopGivingMail[] = _("POKéMON keinen BRIEF geben?"); +const u8 gOtherText_Profile[] = _("PROFIL"); +const u8 gOtherText_AtBattleStart[] = _("Zum Kampfbeginn"); +const u8 gOtherText_UponWinningBattle[] = _("Über den Sieg"); +const u8 gOtherText_UponLosingBattle[] = _("Über die Niederlage"); + +// mauville_old_man? +const u8 gOtherText_TheBardsSong[] = _("Das BARDEN-Lied"); +const u8 gOtherText_WhatsHipHappening[] = _("Was ist hip? Was ist top?"); +const u8 gOtherText_Interview[] = _("Interview"); +const u8 gOtherText_GoodSaying[] = _("Guter Spruch"); +const u8 OtherText_SoPretty[] = _(" so hübsch!"); +const u8 OtherText_SoDarling[] = _(" so reizend!"); +const u8 OtherText_SoRelaxed[] = _(" so lässig!"); +const u8 OtherText_SoSunny[] = _(" so überwältigend!"); +const u8 OtherText_SoDesirable[] = _(" so erstrebenswert!"); +const u8 OtherText_SoExciting[] = _(" so aufregend!"); +const u8 OtherText_SoAmusing[] = _(" so amüsant!"); +const u8 OtherText_SoMagical[] = _(" so zauberhaft!"); + +const u8 gOtherText_Is[] = _(" klingt"); +const u8 gOtherText_DontYouAgree[] = _("\nFindest du nicht auch?"); + +const u8 OtherText_WantVacationNicePlace[] = _("Ich will unbedingt verreisen!\nKennst du ein hübsches Reiseziel?"); +const u8 OtherText_BoughtCrayonsIsNice[] = _("Ich habe 120 verschiedene Farbstifte\ngekauft! Das ist doch toll, oder?"); +const u8 OtherText_IfWeCouldFloat[] = _("Wäre es nicht herrlich, wir könnten auf\neiner Luftblasenwolke davonschweben?"); +const u8 OtherText_SandWashesAwayMakeSad[] = _("Eine Botschaft in Sand geschrieben\nwird weggespült. Das ist traurig."); +const u8 OtherText_WhatsBottomSeaLike[] = _("Wie der Meeresgrund wohl ist? Ich\nwürde ihn so gerne einmal erleben!"); +const u8 OtherText_SeeSettingSun[] = _("Sehnst du dich beim Anblick der unter-\ngehenden Sonne nach deinem Zuhause?"); +const u8 OtherText_LyingInGreenGrass[] = _("Einfach so im grünen Gras liegen...\nOh, das ist so was von angenehm!"); +const u8 OtherText_SecretBasesWonderful[] = _("GEHEIMBASEN sind superklasse!\nFindest du das nicht auch aufregend?"); + +const u8 OtherText_PokeLeague[] = _("POKéMON LIGA"); +const u8 OtherText_PokeCenter[] = _("POKéMON-CENTER"); + +const u8 gOtherText_GetsAPokeBlock[] = _(" erhält einen {POKEBLOCK}?"); + +const u8 OtherText_Coolness[] = _("Coolness "); +const u8 OtherText_Beauty[] = _("Schönheit "); +const u8 OtherText_Cuteness[] = _("Anmut "); +const u8 OtherText_Smartness[] = _("Klugheit "); +const u8 OtherText_Toughness[] = _("Stärke "); + +const u8 gOtherText_WasEnhanced[] = _("wurde erhöht!"); +const u8 gOtherText_NothingChanged[] = _("Keine Veränderung eingetreten!"); +const u8 gOtherText_WontEat[] = _("Es will nicht mehr essen."); + +const u8 gSystemText_SaveFailedBackupCheck[] = _("Speicherfehler\nBackup Memory wird geprüft.\nBitte warten...\n{COLOR RED}“Benötigte Zeit: 1 Minute”"); +const u8 gSystemText_BackupDamagedGameContinue[] = _("Backup Memory defekt oder\ninterne Batterie verbraucht!\nSpiel kann fortgesetzt werden.\nWeiteres Speichern nicht möglich."); +const u8 gSystemText_GameplayEnded[] = _("{COLOR RED}“Spiel fortsetzen nicht möglich.\nZurück zum Titelbildschirm...”"); +const u8 gSystemText_CheckCompleteSaveAttempt[] = _("Überprüfung beendet.\nNeuer Speicherversuch erfolgt.\nBitte warten..."); +const u8 gSystemText_SaveCompletedGameEnd[] = _("Speichern beendet.\n{COLOR RED}“Spiel fortsetzen nicht möglich.\nZurück zum Titelbildschirm.”"); +const u8 gSystemText_SaveCompletedPressA[] = _("Speichern beendet.\n{COLOR RED}“Bitte A-Knopf drücken.”"); + +const u8 gOtherText_Ferry[] = _("FÄHRE"); +const u8 gOtherText_SecretBase[] = _("GEHEIMBASIS"); +const u8 gOtherText_Hideout[] = _("VERSTECK"); + +const u8 gSystemText_ResetRTCPrompt[] = _("Echtzeituhr zurücksetzen?\nA: Bestätigen, B: Zurück"); +const u8 gSystemText_PresentTime[] = _("Aktuelle Uhrzeit im Spiel"); +const u8 gSystemText_PreviousTime[] = _("Vorherige Uhrzeit im Spiel"); +const u8 gSystemText_PleaseResetTime[] = _("Bitte die Zeit zurückstellen."); +const u8 gSystemText_ClockResetDataSave[] = _("Die Uhr wurde zurückgestellt. Daten\nwerden gesichert. Bitte warten..."); +const u8 gSystemText_SaveCompleted[] = _("Speichern beendet."); +const u8 gSystemText_SaveFailed[] = _("Speichern fehlgeschlagen."); +const u8 gSystemText_NoSaveFileNoTime[] = _("Es existiert kein Speicherstand. Uhr-\nzeit kann nicht eingestellt werden."); +const u8 gSystemText_ClockAdjustmentUsable[] = _("Das spielinterne Zeiteingabe-\nSystem ist jetzt verfügbar."); +const u8 gSystemText_Saving[] = _("SPEICHERVORGANG...\nGERÄT NICHT AUSSCHALTEN!"); +#endif diff --git a/src/task.c b/src/task.c index e79929c63..3c28a66d9 100644 --- a/src/task.c +++ b/src/task.c @@ -1,48 +1,48 @@ #include "global.h" #include "task.h" -#define NUM_TASKS 16 - +#define ACTIVE_SENTINEL 0x10 #define HEAD_SENTINEL 0xFE #define TAIL_SENTINEL 0xFF -struct Task gTasks[NUM_TASKS]; +// gTasks is a queue of the active 16 tasks +struct Task gTasks[ACTIVE_SENTINEL]; static void InsertTask(u8 newTaskId); static u8 FindFirstActiveTask(); void ResetTasks() { - u8 i; + u8 taskId; - for (i = 0; i < NUM_TASKS; i++) + for (taskId = 0; taskId < ACTIVE_SENTINEL; taskId++) { - gTasks[i].isActive = FALSE; - gTasks[i].func = TaskDummy; - gTasks[i].prev = i; - gTasks[i].next = i + 1; - gTasks[i].priority = -1; - memset(gTasks[i].data, 0, sizeof(gTasks[i].data)); + gTasks[taskId].isActive = FALSE; + gTasks[taskId].func = TaskDummy; + gTasks[taskId].prev = taskId; + gTasks[taskId].next = taskId + 1; + gTasks[taskId].priority = -1; + memset(gTasks[taskId].data, 0, sizeof(gTasks[taskId].data)); } gTasks[0].prev = HEAD_SENTINEL; - gTasks[NUM_TASKS - 1].next = TAIL_SENTINEL; + gTasks[ACTIVE_SENTINEL - 1].next = TAIL_SENTINEL; } u8 CreateTask(TaskFunc func, u8 priority) { - u8 i; + u8 taskId; - for (i = 0; i < NUM_TASKS; i++) + for (taskId = 0; taskId < ACTIVE_SENTINEL; taskId++) { - if (!gTasks[i].isActive) + if (!gTasks[taskId].isActive) { - gTasks[i].func = func; - gTasks[i].priority = priority; - InsertTask(i); - memset(gTasks[i].data, 0, sizeof(gTasks[i].data)); - gTasks[i].isActive = TRUE; - return i; + gTasks[taskId].func = func; + gTasks[taskId].priority = priority; + InsertTask(taskId); + memset(gTasks[taskId].data, 0, sizeof(gTasks[taskId].data)); + gTasks[taskId].isActive = TRUE; + return taskId; } } @@ -53,9 +53,9 @@ static void InsertTask(u8 newTaskId) { u8 taskId = FindFirstActiveTask(); - if (taskId == NUM_TASKS) + if (taskId == ACTIVE_SENTINEL) { - // The new task is the only task. + // The task system inserts from the top downwards starting from the end (0xFF) to 0. If FindFirstActiveTask returned the value equivalent to ACTIVE_SENTINEL, it means it is the only task because it searched the entire queue. gTasks[newTaskId].prev = HEAD_SENTINEL; gTasks[newTaskId].next = TAIL_SENTINEL; return; @@ -69,12 +69,14 @@ static void InsertTask(u8 newTaskId) // so we insert the new task before it. gTasks[newTaskId].prev = gTasks[taskId].prev; gTasks[newTaskId].next = taskId; + if (gTasks[taskId].prev != HEAD_SENTINEL) - gTasks[gTasks[taskId].prev].next = newTaskId; + gTasks[gTasks[taskId].prev].next = newTaskId; // as long as we are not at the end, insert the newTask appropriately. + gTasks[taskId].prev = newTaskId; return; } - if (gTasks[taskId].next == TAIL_SENTINEL) + if (gTasks[taskId].next == TAIL_SENTINEL) // we did not find a space for the task, so overwrite the last task as it is the lowest priority. { // We've reached the end. gTasks[newTaskId].prev = taskId; @@ -82,7 +84,7 @@ static void InsertTask(u8 newTaskId) gTasks[taskId].next = newTaskId; return; } - taskId = gTasks[taskId].next; + taskId = gTasks[taskId].next; // neither the priority was lower, nor the end. check the next task. } } @@ -112,11 +114,11 @@ void DestroyTask(u8 taskId) } } -void RunTasks() +void RunTasks(void) { u8 taskId = FindFirstActiveTask(); - if (taskId != NUM_TASKS) + if (taskId != ACTIVE_SENTINEL) { do { @@ -126,11 +128,11 @@ void RunTasks() } } -static u8 FindFirstActiveTask() +static u8 FindFirstActiveTask(void) { u8 taskId; - for (taskId = 0; taskId < NUM_TASKS; taskId++) + for (taskId = 0; taskId < ACTIVE_SENTINEL; taskId++) if (gTasks[taskId].isActive == TRUE && gTasks[taskId].prev == HEAD_SENTINEL) break; @@ -173,7 +175,7 @@ bool8 FuncIsActiveTask(TaskFunc func) { u8 i; - for (i = 0; i < NUM_TASKS; i++) + for (i = 0; i < ACTIVE_SENTINEL; i++) if (gTasks[i].isActive == TRUE && gTasks[i].func == func) return TRUE; @@ -184,19 +186,19 @@ u8 FindTaskIdByFunc(TaskFunc func) { s32 i; - for (i = 0; i < NUM_TASKS; i++) + for (i = 0; i < ACTIVE_SENTINEL; i++) if (gTasks[i].isActive == TRUE && gTasks[i].func == func) return (u8)i; return -1; } -u8 GetTaskCount() +u8 GetTaskCount(void) { u8 i; u8 count = 0; - for (i = 0; i < NUM_TASKS; i++) + for (i = 0; i < ACTIVE_SENTINEL; i++) if (gTasks[i].isActive == TRUE) count++; diff --git a/src/text.c b/src/text.c index fb7c085a2..b27084b86 100644 --- a/src/text.c +++ b/src/text.c @@ -1,16 +1,11 @@ #include "global.h" #include "text.h" +#include "battle.h" #include "main.h" -#include "string_util.h" -#include "songs.h" #include "palette.h" +#include "songs.h" #include "sound.h" - -enum -{ - CHARSET_JAPANESE = 1, - CHARSET_LATIN -}; +#include "string_util.h" enum { @@ -184,8 +179,8 @@ EWRAM_DATA u8 gStringVar2[0x100] = {0}; EWRAM_DATA u8 gStringVar3[0x100] = {0}; EWRAM_DATA u8 gStringVar4[0x100] = {0}; -extern u16 gUnknown_020239F8; -extern u8 gUnknown_0203869A; +extern u16 gBattleTypeFlags; +extern u8 gIsLinkContest; extern u8 gTileBuffer[]; vu16 *const gBGControlRegs[] = @@ -216,20 +211,24 @@ const u16 gUnknown_081E29D8[] = { 0x100, 0x200, 0x400, 0x800 }; const u16 gUnknown_081E29E0[] = { 0x100, 0x200, 0x400, 0x800 }; const u16 gUnknown_081E29E8[] = { 1, 2, 4, 8 }; -#include "fonts/font0_lat_glyphs.h" -#include "fonts/font1_lat_glyphs.h" -#include "fonts/font0_jpn_glyphs.h" -#include "fonts/font1_jpn_glyphs.h" -#include "fonts/braille_glyphs.h" -#include "fonts/down_arrow_tiles.h" -#include "fonts/type1_map.h" -#include "fonts/type3_map.h" -#include "fonts/font1_widths.h" -#include "fonts/font4_widths.h" -#include "fonts/font0_widths.h" -#include "fonts/font3_widths.h" -#include "fonts/unknown_palette_81E6692.h" -#include "fonts/default_palette.h" +static const u8 sFont0LatinGlyphs[] = INCBIN_U8("graphics/fonts/font0_lat.1bpp"); +static const u8 sFont1LatinGlyphs[] = INCBIN_U8("graphics/fonts/font1_lat.1bpp"); +static const u8 sFont0JapaneseGlyphs[] = INCBIN_U8("graphics/fonts/font0_jpn.1bpp"); +static const u8 sFont1JapaneseGlyphs[] = INCBIN_U8("graphics/fonts/font1_jpn.1bpp"); +static const u8 sBrailleGlyphs[] = INCBIN_U8("graphics/fonts/font6_braille.1bpp"); +static const u32 sDownArrowTiles[] = INCBIN_U32("graphics/fonts/down_arrow.4bpp"); + +// clang-format off +#include "data/text/type1_map.h" +#include "data/text/type3_map.h" +#include "data/text/font1_widths.h" +#include "data/text/font4_widths.h" +#include "data/text/font0_widths.h" +#include "data/text/font3_widths.h" +// clang-format on + +const u16 gUnknownPalette_81E6692[] = INCBIN_U16("graphics/fonts/unknown_81E6692.gbapal"); +const u16 gFontDefaultPalette[] = INCBIN_U16("graphics/fonts/default.gbapal"); const u8 sBlankTile[8] = { 0, 0, 0, 0, 0, 0, 0, 0, }; @@ -361,7 +360,7 @@ static const WriteGlyphTilemapFunc sWriteGlyphTilemapFuncs[] = WriteGlyphTilemap_Font6, }; -static const struct Window sDefaultWindow = { .charset = CHARSET_LATIN }; +static const struct Window sDefaultWindow = { .language = GAME_LANGUAGE }; typedef u8 (*ExtCtrlCodeFunc)(struct Window *); @@ -1758,21 +1757,21 @@ u16 InitWindowTileData(struct Window *win, u16 startOffset) case 1: switch (win->config->fontNum) { - case 0: - case 3: - retVal = LoadFixedWidthFont(win, startOffset); - break; - case 1: - case 2: - retVal = LoadFixedWidthFont_Font1Latin(win, startOffset); - break; - case 4: - case 5: - retVal = LoadFixedWidthFont_Font4Latin(win, startOffset); - break; - case 6: - retVal = LoadFixedWidthFont_Braille(win, startOffset); - break; + case 0: + case 3: + retVal = LoadFixedWidthFont(win, startOffset); + break; + case 1: + case 2: + retVal = LoadFixedWidthFont_Font1Latin(win, startOffset); + break; + case 4: + case 5: + retVal = LoadFixedWidthFont_Font4Latin(win, startOffset); + break; + case 6: + retVal = LoadFixedWidthFont_Braille(win, startOffset); + break; } break; } @@ -1891,30 +1890,30 @@ static void MultistepLoadFont_LoadGlyph(struct Window *win, u16 startOffset, u8 switch (win->config->fontNum) { - case 0: - case 3: - buffer = win->tileData + 32 * startOffset + 64 * glyph; - LoadFixedWidthGlyph(win, glyph, buffer); - break; - case 1: - case 2: - buffer = win->tileData + 32 * (glyph + startOffset); - ApplyColors_UnshadowedFont( - &sFont1LatinGlyphs[8 * glyph], - (u32 *)buffer, - win->foregroundColor, - win->backgroundColor); - break; - case 4: - case 5: - buffer = win->tileData + 32 * (glyph + startOffset); - ApplyColors_ShadowedFont( - &gFont4LatinGlyphs[8 * glyph], - buffer, - win->foregroundColor, - win->shadowColor, - win->backgroundColor); - break; + case 0: + case 3: + buffer = win->tileData + 32 * startOffset + 64 * glyph; + LoadFixedWidthGlyph(win, glyph, buffer); + break; + case 1: + case 2: + buffer = win->tileData + 32 * (glyph + startOffset); + ApplyColors_UnshadowedFont( + &sFont1LatinGlyphs[8 * glyph], + (u32 *)buffer, + win->foregroundColor, + win->backgroundColor); + break; + case 4: + case 5: + buffer = win->tileData + 32 * (glyph + startOffset); + ApplyColors_ShadowedFont( + &gFont4LatinGlyphs[8 * glyph], + buffer, + win->foregroundColor, + win->shadowColor, + win->backgroundColor); + break; } } @@ -1947,7 +1946,7 @@ void InitWindow(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 struct WindowConfig *winConfig = win->config; win->textMode = winConfig->textMode; win->fontNum = winConfig->fontNum; - win->charset = CHARSET_LATIN; + win->language = GAME_LANGUAGE; win->paletteNum = winConfig->paletteNum; win->win_field_B = 0; win->win_field_C = 0; @@ -2045,7 +2044,7 @@ u8 sub_8002F44(struct Window *win) static u8 sub_8002FA0(struct Window *win, const u8 *text) { u8 retVal; - u8 savedCharset = win->charset; + u8 savedLanguage = win->language; const u8 *savedText = win->text; u16 savedTextIndex = win->textIndex; win->text = text; @@ -2055,7 +2054,7 @@ static u8 sub_8002FA0(struct Window *win, const u8 *text) win->text = savedText; win->textIndex = savedTextIndex; win->state = WIN_STATE_NORMAL; - win->charset = savedCharset; + win->language = savedLanguage; return retVal; } @@ -2291,13 +2290,13 @@ static u8 ExtCtrlCode_Spacing(struct Window *win) static u8 ExtCtrlCode_Japanese(struct Window *win) { - win->charset = CHARSET_JAPANESE; + win->language = LANGUAGE_JAPANESE; return 2; } static u8 ExtCtrlCode_Latin(struct Window *win) { - win->charset = CHARSET_LATIN; + win->language = GAME_LANGUAGE; return 2; } @@ -2341,7 +2340,7 @@ u8 sub_8003490(struct Window *win, u8 c, u16 tileDataStartOffset, u8 left, u8 to return retVal; } -void sub_80034D4(u8 *tileData, u8 *text) +void sub_80034D4(u8 *tileData, const u8 *text) { sub_8004E3C((struct WindowConfig *)&gWindowConfig_81E6C74, tileData, text); } @@ -2477,12 +2476,18 @@ static u8 UpdateWindowText(struct Window *win) return 0; } +#if defined(ENGLISH) +#define SUB_800374C_LINE_LENGTH 26 +#elif defined(GERMAN) +#define SUB_800374C_LINE_LENGTH 27 +#endif + u8 sub_800374C(struct Window *win) { u8 retVal; sWaitType = 1; - sLineLength = 26; + sLineLength = SUB_800374C_LINE_LENGTH; retVal = UpdateWindowText(win); sLineLength = 26; sWaitType = 0; @@ -2596,7 +2601,7 @@ static void LoadFixedWidthGlyph(struct Window *win, u32 glyph, u8 *dest) u8 *upperTile; u8 *lowerTile; - GetGlyphTilePointers(win->fontNum, win->charset, glyph, &upperTile, &lowerTile); + GetGlyphTilePointers(win->fontNum, win->language, glyph, &upperTile, &lowerTile); switch (win->fontNum) { @@ -2627,17 +2632,17 @@ static void WriteGlyphTilemap(struct Window *win, u16 upperTileNum, u16 lowerTil } } -static void GetGlyphTilePointers(u8 fontNum, u8 charset, u16 glyph, u8 **upperTilePtr, u8 **lowerTilePtr) +static void GetGlyphTilePointers(u8 fontNum, u8 language, u16 glyph, u8 **upperTilePtr, u8 **lowerTilePtr) { u16 index; const struct Font *font; - if (charset == CHARSET_JAPANESE) - charset = 0; + if (language == LANGUAGE_JAPANESE) + language = 0; else - charset = 7; + language = 7; - font = &sFonts[charset + fontNum]; + font = &sFonts[language + fontNum]; switch (font->type) { @@ -2912,12 +2917,10 @@ static bool8 PlayerCanInterruptWait(struct Window *win) retVal = FALSE; break; case 3: - retVal = FALSE; - if (!gUnknown_0203869A) - retVal = TRUE; + retVal = gIsLinkContest ? FALSE : TRUE; break; case 1: - retVal &= ~(gUnknown_020239F8 >> 1); + retVal = (gBattleTypeFlags & BATTLE_TYPE_LINK) ? FALSE : TRUE; break; } @@ -3137,7 +3140,7 @@ static void DrawDownArrow(struct Window *win) { u8 *upperTile; u8 *lowerTile; - GetGlyphTilePointers(win->fontNum, win->charset, 0, &upperTile, &lowerTile); + GetGlyphTilePointers(win->fontNum, win->language, 0, &upperTile, &lowerTile); glyphTileInfo.width = 8 - glyphTileInfo.startPixel; glyphTileInfo.src = upperTile; glyphTileInfo.dest = (u32 *)(win->tileData + 32 * GetCursorTileNum(win, 1, 0)); @@ -3340,10 +3343,10 @@ static u8 GetGlyphWidth(struct Window *win, u32 glyph) { u8 width = 8; -#if REVISION >= 1 - if (win->charset != CHARSET_JAPANESE) +#ifdef BUGFIX_GLYPHWIDTH + if (win->language != LANGUAGE_JAPANESE) #else - if (win->charset == CHARSET_LATIN) + if (win->language == LANGUAGE_ENGLISH) #endif { width = win->spacing; @@ -3539,7 +3542,7 @@ u8 GetStringWidth(struct Window *win, const u8 *s) { u8 width = 0; u8 savedFontNum = win->fontNum; - u8 savedCharset = win->charset; + u8 savedCharset = win->language; u8 savedSpacing = win->spacing; s32 i = 0; @@ -3552,9 +3555,9 @@ u8 GetStringWidth(struct Window *win, const u8 *s) { u8 temp; i++; - temp = win->charset; + temp = win->language; width += GetStringWidth(win, GetExpandedPlaceholder(s[i])); - win->charset = temp; + win->language = temp; i++; break; } @@ -3580,10 +3583,10 @@ u8 GetStringWidth(struct Window *win, const u8 *s) win->spacing = s[i + 1]; break; case 0x15: - win->charset = 1; + win->language = LANGUAGE_JAPANESE; break; case 0x16: - win->charset = 2; + win->language = GAME_LANGUAGE; break; } @@ -3596,7 +3599,7 @@ u8 GetStringWidth(struct Window *win, const u8 *s) } win->spacing = savedSpacing; - win->charset = savedCharset; + win->language = savedCharset; win->fontNum = savedFontNum; return width; @@ -3659,7 +3662,7 @@ u8 GetStringWidthGivenWindowConfig(struct WindowConfig *winConfig, const u8 *s) void ConvertInternationalString(u8 *s, u8 language) { - if (language == CHARSET_JAPANESE) + if (language == LANGUAGE_JAPANESE) { u8 i; @@ -4253,7 +4256,7 @@ static s32 DrawGlyphTiles(struct Window *win, u32 glyph, u32 glyphWidth) u8 *lowerTile; s32 retVal = 0; - GetGlyphTilePointers(win->fontNum, win->charset, glyph, &upperTile, &lowerTile); + GetGlyphTilePointers(win->fontNum, win->language, glyph, &upperTile, &lowerTile); glyphTileInfo.textMode = win->textMode; glyphTileInfo.startPixel = (win->left + win->cursorX) & 7; glyphTileInfo.width = glyphWidth; diff --git a/src/text_window.c b/src/text_window.c index 1ac624dd0..9a88789d1 100644 --- a/src/text_window.c +++ b/src/text_window.c @@ -1,8 +1,8 @@ #include "global.h" #include "text_window.h" #include "main.h" -#include "text.h" #include "palette.h" +#include "text.h" #define STD_MSG_BOX_LEFT 0 #define STD_MSG_BOX_TOP 14 diff --git a/src/tileset_anim.c b/src/tileset_anim.c index 415b69cfe..34685381d 100644 --- a/src/tileset_anim.c +++ b/src/tileset_anim.c @@ -30,10 +30,11 @@ extern u8 *gTilesetAnimTable_EliteFour_1[]; extern u8 *gTilesetAnimTable_MauvilleGym[]; extern u8 *gTilesetAnimTable_BikeShop[]; -struct Dma { - u8 *src; - u8 *dest; - u16 size; +struct Dma +{ + u8 *src; + u8 *dest; + u16 size; }; EWRAM_DATA static struct Dma gTilesetAnimDmas[20] = {0}; @@ -88,510 +89,542 @@ static void sub_807399C(u16); static void sub_8073974(u16); static void sub_80739EC(u16); -static void ClearTilesetAnimDmas(void) { - gNumTilesetAnimDmas = 0; - CpuFill32(0, &gTilesetAnimDmas, sizeof(gTilesetAnimDmas)); -} - -static void QueueTilesetAnimDma(u8 *src, u8 *dest, u16 size) { - if (gNumTilesetAnimDmas < 20) { - gTilesetAnimDmas[gNumTilesetAnimDmas].src = src; - gTilesetAnimDmas[gNumTilesetAnimDmas].dest = dest; - gTilesetAnimDmas[gNumTilesetAnimDmas].size = size; - gNumTilesetAnimDmas++; - } -} - -void sub_8072E74(void) { - int i; - for (i = 0; i < gNumTilesetAnimDmas; i++) { - DmaCopy16(3, - gTilesetAnimDmas[i].src, - gTilesetAnimDmas[i].dest, - gTilesetAnimDmas[i].size); - } - gNumTilesetAnimDmas = 0; -} - -void cur_mapheader_run_tileset_funcs_after_some_cpuset(void) { - ClearTilesetAnimDmas(); - StartTileset1Animation(); - StartTileset2Animation(); -} - -void sub_8072ED0(void) { - StartTileset2Animation(); -} - -void sub_8072EDC(void) { - ClearTilesetAnimDmas(); - if (++gTileset1AnimFrame >= gTileset1AnimLength) { - gTileset1AnimFrame = 0; - } - if (++gTileset2AnimFrame >= gTileset2AnimLength) { - gTileset2AnimFrame = 0; - } - if (gTileset1AnimCallback) { - gTileset1AnimCallback(gTileset1AnimFrame); - } - if (gTileset2AnimCallback) { - gTileset2AnimCallback(gTileset2AnimFrame); - } -} - -static void StartTileset1Animation(void) { - gTileset1AnimFrame = 0; - gTileset1AnimLength = 0; - gTileset1AnimCallback = 0; - if (gMapHeader.mapData->primaryTileset) { - if (gMapHeader.mapData->primaryTileset->callback) { - gMapHeader.mapData->primaryTileset->callback(); - } - } -} - -static void StartTileset2Animation(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = 0; - gTileset2AnimCallback = 0; - if (gMapHeader.mapData->secondaryTileset) { - if (gMapHeader.mapData->secondaryTileset->callback) { - gMapHeader.mapData->secondaryTileset->callback(); - } - } +static void ClearTilesetAnimDmas(void) +{ + gNumTilesetAnimDmas = 0; + CpuFill32(0, &gTilesetAnimDmas, sizeof(gTilesetAnimDmas)); +} + +static void QueueTilesetAnimDma(u8 *src, u8 *dest, u16 size) +{ + if (gNumTilesetAnimDmas < 20) + { + gTilesetAnimDmas[gNumTilesetAnimDmas].src = src; + gTilesetAnimDmas[gNumTilesetAnimDmas].dest = dest; + gTilesetAnimDmas[gNumTilesetAnimDmas].size = size; + gNumTilesetAnimDmas++; + } +} + +void sub_8072E74(void) +{ + int i; + for (i = 0; i < gNumTilesetAnimDmas; i++) + { + DmaCopy16(3, + gTilesetAnimDmas[i].src, + gTilesetAnimDmas[i].dest, + gTilesetAnimDmas[i].size); + } + gNumTilesetAnimDmas = 0; +} + +void cur_mapheader_run_tileset_funcs_after_some_cpuset(void) +{ + ClearTilesetAnimDmas(); + StartTileset1Animation(); + StartTileset2Animation(); +} + +void sub_8072ED0(void) +{ + StartTileset2Animation(); +} + +void sub_8072EDC(void) +{ + ClearTilesetAnimDmas(); + if (++gTileset1AnimFrame >= gTileset1AnimLength) + { + gTileset1AnimFrame = 0; + } + if (++gTileset2AnimFrame >= gTileset2AnimLength) + { + gTileset2AnimFrame = 0; + } + if (gTileset1AnimCallback) + { + gTileset1AnimCallback(gTileset1AnimFrame); + } + if (gTileset2AnimCallback) + { + gTileset2AnimCallback(gTileset2AnimFrame); + } +} + +static void StartTileset1Animation(void) +{ + gTileset1AnimFrame = 0; + gTileset1AnimLength = 0; + gTileset1AnimCallback = 0; + if (gMapHeader.mapData->primaryTileset) + { + if (gMapHeader.mapData->primaryTileset->callback) + { + gMapHeader.mapData->primaryTileset->callback(); + } + } +} + +static void StartTileset2Animation(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = 0; + gTileset2AnimCallback = 0; + if (gMapHeader.mapData->secondaryTileset) + { + if (gMapHeader.mapData->secondaryTileset->callback) + { + gMapHeader.mapData->secondaryTileset->callback(); + } + } +} + +void TilesetCB_General(void) +{ + gTileset1AnimFrame = 0; + gTileset1AnimLength = 0x100; + gTileset1AnimCallback = sub_8073014; +} + +void TilesetCB_Building(void) +{ + gTileset1AnimFrame = 0; + gTileset1AnimLength = 0x100; + gTileset1AnimCallback = sub_8073058; +} + +static void sub_8073014(u16 a1) +{ + int v1; + v1 = a1 % 0x10; + if (v1 == 0) sub_8073070(a1 / 0x10); + if (v1 == 1) sub_8073098(a1 / 0x10); + if (v1 == 2) sub_80730C0(a1 / 0x10); + if (v1 == 3) sub_80730E8(a1 / 0x10); + if (v1 == 4) sub_807361C(a1 / 0x10); +} + +static void sub_8073058(u16 a1) +{ + if (a1 % 8 == 0) + { + sub_8073904(a1 / 8); + } +} + +static void sub_8073070(u16 a1) +{ + int v1; + v1 = a1 % 4; + QueueTilesetAnimDma(gTilesetAnimTable_General_0[v1], (u8 *)(BG_VRAM + 0x3f80), 0x80); +} + +static void sub_8073098(u16 a1) +{ + u8 v1; + v1 = a1 % 8; + QueueTilesetAnimDma(gTilesetAnimTable_General_1[v1], (u8 *)(BG_VRAM + 0x3600), 0x3c0); +} + +static void sub_80730C0(u16 a1) +{ + int v1; + v1 = a1 % 8; + QueueTilesetAnimDma(gTilesetAnimTable_General_2[v1], (u8 *)(BG_VRAM + 0x3a00), 0x140); +} + +static void sub_80730E8(u16 a1) +{ + int v1; + v1 = a1 % 4; + QueueTilesetAnimDma(gTilesetAnimTable_General_3[v1], (u8 *)(BG_VRAM + 0x3e00), 0xc0); } -void TilesetCB_General(void) { - gTileset1AnimFrame = 0; - gTileset1AnimLength = 0x100; - gTileset1AnimCallback = sub_8073014; +void TilesetCB_Petalburg(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = 0; } -void TilesetCB_Building(void) { - gTileset1AnimFrame = 0; - gTileset1AnimLength = 0x100; - gTileset1AnimCallback = sub_8073058; +void TilesetCB_Rustboro(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = sub_8073424; } -static void sub_8073014(u16 a1) { - int v1; - v1 = a1 % 0x10; - if (v1 == 0) sub_8073070(a1 / 0x10); - if (v1 == 1) sub_8073098(a1 / 0x10); - if (v1 == 2) sub_80730C0(a1 / 0x10); - if (v1 == 3) sub_80730E8(a1 / 0x10); - if (v1 == 4) sub_807361C(a1 / 0x10); +void TilesetCB_Dewford(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = 0; } -static void sub_8073058(u16 a1) { - if (a1 % 8 == 0) { - sub_8073904(a1 / 8); - } +void TilesetCB_Slateport(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = 0; } -static void sub_8073070(u16 a1) { - int v1; - v1 = a1 % 4; - QueueTilesetAnimDma(gTilesetAnimTable_General_0[v1], - (u8 *)(BG_VRAM + 0x3f80), - 0x80); +void TilesetCB_Mauville(void) +{ + gTileset2AnimFrame = gTileset1AnimFrame; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = sub_80734A0; } -static void sub_8073098(u16 a1) { - u8 v1; - v1 = a1 % 8; - QueueTilesetAnimDma(gTilesetAnimTable_General_1[v1], - (u8 *)(BG_VRAM + 0x3600), - 0x3c0); +void TilesetCB_Lavaridge(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = sub_8073514; } -static void sub_80730C0(u16 a1) { - int v1; - v1 = a1 % 8; - QueueTilesetAnimDma(gTilesetAnimTable_General_2[v1], - (u8 *)(BG_VRAM + 0x3a00), - 0x140); +void TilesetCB_Fallarbor(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = 0; } -static void sub_80730E8(u16 a1) { - int v1; - v1 = a1 % 4; - QueueTilesetAnimDma(gTilesetAnimTable_General_3[v1], - (u8 *)(BG_VRAM + 0x3e00), - 0xc0); +void TilesetCB_Fortree(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = 0; } -void TilesetCB_Petalburg(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = 0; +void TilesetCB_Lilycove(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = 0; } -void TilesetCB_Rustboro(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = sub_8073424; +void TilesetCB_Mossdeep(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = 0; } -void TilesetCB_Dewford(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = 0; +void TilesetCB_EverGrande(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = sub_8073540; } -void TilesetCB_Slateport(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = 0; +void TilesetCB_Pacifidlog(void) +{ + gTileset2AnimFrame = gTileset1AnimFrame; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = sub_80735B4; } -void TilesetCB_Mauville(void) { - gTileset2AnimFrame = gTileset1AnimFrame; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = sub_80734A0; +void TilesetCB_Sootopolis(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = 0; } -void TilesetCB_Lavaridge(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = sub_8073514; +void TilesetCB_Underwater(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = 0x80; + gTileset2AnimCallback = sub_80735E4; } -void TilesetCB_Fallarbor(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = 0; +void TilesetCB_SootopolisGym(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = 0xf0; + gTileset2AnimCallback = sub_80738A8; } -void TilesetCB_Fortree(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = 0; +void TilesetCB_Cave(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = sub_8073600; } -void TilesetCB_Lilycove(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = 0; +void TilesetCB_EliteFour(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = 0x80; + gTileset2AnimCallback = sub_80738C0; } -void TilesetCB_Mossdeep(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = 0; +void TilesetCB_MauvilleGym(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = sub_8073890; } -void TilesetCB_EverGrande(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = sub_8073540; +void TilesetCB_BikeShop(void) +{ + gTileset2AnimFrame = 0; + gTileset2AnimLength = gTileset1AnimLength; + gTileset2AnimCallback = sub_80738EC; } -void TilesetCB_Pacifidlog(void) { - gTileset2AnimFrame = gTileset1AnimFrame; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = sub_80735B4; -} - -void TilesetCB_Sootopolis(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = 0; -} - -void TilesetCB_Underwater(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = 0x80; - gTileset2AnimCallback = sub_80735E4; -} +static void sub_8073424(u16 a1) +{ + int v1; + v1 = a1 % 8; + if (v1 == 0) + { + sub_80737A4(a1 / 8, 0); + sub_80737E0(a1 / 8); + } + if (v1 == 1) sub_80737A4(a1 / 8, 1); + if (v1 == 2) sub_80737A4(a1 / 8, 2); + if (v1 == 3) sub_80737A4(a1 / 8, 3); + if (v1 == 4) sub_80737A4(a1 / 8, 4); + if (v1 == 5) sub_80737A4(a1 / 8, 5); + if (v1 == 6) sub_80737A4(a1 / 8, 6); + if (v1 == 7) sub_80737A4(a1 / 8, 7); +} + +static void sub_80734A0(u16 a1) +{ + int v1; + v1 = a1 % 8; + if (v1 == 0) sub_8073704(a1 / 8, 0); + if (v1 == 1) sub_8073704(a1 / 8, 1); + if (v1 == 2) sub_8073704(a1 / 8, 2); + if (v1 == 3) sub_8073704(a1 / 8, 3); + if (v1 == 4) sub_8073704(a1 / 8, 4); + if (v1 == 5) sub_8073704(a1 / 8, 5); + if (v1 == 6) sub_8073704(a1 / 8, 6); + if (v1 == 7) sub_8073704(a1 / 8, 7); +} + +static void sub_8073514(u16 a1) +{ + int v1; + v1 = a1 % 0x10; + if (v1 == 0) sub_8073644(a1 / 0x10); + if (v1 == 1) sub_8073808(a1 / 0x10); +} + +static void sub_8073540(u16 a1) +{ + int v1; + v1 = a1 % 8; + if (v1 == 0) sub_8073830(a1 / 8, 0); + if (v1 == 1) sub_8073830(a1 / 8, 1); + if (v1 == 2) sub_8073830(a1 / 8, 2); + if (v1 == 3) sub_8073830(a1 / 8, 3); + if (v1 == 4) sub_8073830(a1 / 8, 4); + if (v1 == 5) sub_8073830(a1 / 8, 5); + if (v1 == 6) sub_8073830(a1 / 8, 6); + if (v1 == 7) sub_8073830(a1 / 8, 7); +} + +static void sub_80735B4(u16 a1) +{ + int v1; + v1 = a1 % 0x10; + if (v1 == 0) sub_807368C(a1 / 0x10); + if (v1 == 1) sub_80736DC(a1 / 0x10); +} + +static void sub_80735E4(u16 a1) +{ + int v1; + v1 = a1 % 0x10; + if (v1 == 0) sub_80736B4(a1 / 0x10); +} + +static void sub_8073600(u16 a1) +{ + int v1; + v1 = a1 % 0x10; + if (v1 == 1) sub_8073868(a1 / 0x10); +} + +static void sub_807361C(u16 a1) +{ + int v1; + v1 = a1 % 4; + QueueTilesetAnimDma(gTilesetAnimTable_General_4[v1], (u8 *)(BG_VRAM + 0x3c00), 0x140); +} + +static void sub_8073644(u8 a1) +{ + u8 v1; + v1 = a1 % 4; + QueueTilesetAnimDma(gTilesetAnimTable_Lavaridge[v1], (u8 *)(BG_VRAM + 0x6400), 0x80); + v1 = (a1 + 2) % 4; + QueueTilesetAnimDma(gTilesetAnimTable_Lavaridge[v1], (u8 *)(BG_VRAM + 0x6480), 0x80); +} + +static void sub_807368C(u8 a1) +{ + int v1; + v1 = a1 % 4; + QueueTilesetAnimDma(gTilesetAnimTable_Pacifidlog_0[v1], (u8 *)(BG_VRAM + 0x7a00), 0x3c0); +} + +static void sub_80736B4(u8 a1) +{ + int v1; + v1 = a1 % 4; + QueueTilesetAnimDma(gTilesetAnimTable_Underwater[v1], (u8 *)(BG_VRAM + 0x7e00), 0x80); +} + +static void sub_80736DC(u8 a1) +{ + int v1; + v1 = a1 % 8; + QueueTilesetAnimDma(gTilesetAnimTable_Pacifidlog_1[v1], (u8 *)(BG_VRAM + 0x7e00), 0x100); +} + +static void sub_8073704(u16 a1, u8 a2) +{ + int v1; + a1 -= a2; + if (a1 < 12) + { + v1 = a1 % 12; + QueueTilesetAnimDma(gTilesetAnimTable_Mauville_0A[v1], gUnknown_0837BAE4[a2], 0x80); + QueueTilesetAnimDma(gTilesetAnimTable_Mauville_1A[v1], gUnknown_0837BB04[a2], 0x80); + } + else + { + v1 = a1 % 4; + QueueTilesetAnimDma(gTilesetAnimTable_Mauville_0B[v1], gUnknown_0837BAE4[a2], 0x80); + QueueTilesetAnimDma(gTilesetAnimTable_Mauville_1B[v1], gUnknown_0837BB04[a2], 0x80); + } +} + +static void sub_80737A4(u16 a1, u8 a2) +{ + int v1; + a1 -= a2; + + v1 = a1 % 8; + if (gTilesetAnimTable_Rustboro_0[v1]) + { + QueueTilesetAnimDma(gTilesetAnimTable_Rustboro_0[v1], gUnknown_0837BFA4[a2], 0x80); + } +} + +static void sub_80737E0(u16 a1) +{ + int v1; + v1 = a1 % 2; + QueueTilesetAnimDma(gTilesetAnimTable_Rustboro_1[v1], (u8 *)(BG_VRAM + 0x7800), 0x80); +} + +static void sub_8073808(u16 a1) +{ + int v1; + v1 = a1 % 4; + QueueTilesetAnimDma(gTilesetAnimTable_Cave[v1], (u8 *)(BG_VRAM + 0x5400), 0x80); +} + +static void sub_8073830(u16 a1, u8 a2) +{ + int v1; + a1 -= a2; + v1 = a1 % 8; + QueueTilesetAnimDma(gTilesetAnimTable_EverGrande[v1], gUnknown_0837C93C[a2], 0x80); +} + +static void sub_8073868(u16 a1) +{ + int v1; + v1 = a1 % 4; + QueueTilesetAnimDma(gTilesetAnimTable_Cave[v1], (u8 *)(BG_VRAM + 0x7400), 0x80); +} + +static void sub_8073890(u16 a1) +{ + int v1; + v1 = a1 % 2; + if (!v1) + { + sub_80739C4(a1 / 2); + } +} + +static void sub_80738A8(u16 a1) +{ + int v1; + v1 = a1 % 8; + if (!v1) + { + sub_807392C(a1 / 8); + } +} + +static void sub_80738C0(u16 a1) +{ + if (a1 % 0x40 == 0) + { + sub_807399C(a1 / 0x40); + } + if (a1 % 8 == 1) + { + sub_8073974(a1 / 8); + } +} + +static void sub_80738EC(u16 a1) +{ + if (a1 % 4 == 0) + { + sub_80739EC(a1 / 4); + } +} + +static void sub_8073904(u16 a1) +{ + int v1; + v1 = a1 % 2; + QueueTilesetAnimDma(gTilesetAnimTable_Building[v1], (u8 *)(BG_VRAM + 0x3e00), 0x80); +} + +static void sub_807392C(u16 a1) +{ + int v1; + v1 = a1 % 3; + QueueTilesetAnimDma(gTilesetAnimTable_SootopolisGym_0[v1], (u8 *)(BG_VRAM + 0x7e00), 0x180); + QueueTilesetAnimDma(gTilesetAnimTable_SootopolisGym_1[v1], (u8 *)(BG_VRAM + 0x7a00), 0x280); +} -void TilesetCB_SootopolisGym(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = 0xf0; - gTileset2AnimCallback = sub_80738A8; +static void sub_8073974(u16 a1) +{ + int v1; + v1 = a1 % 4; + QueueTilesetAnimDma(gTilesetAnimTable_EliteFour_0[v1], (u8 *)(BG_VRAM + 0x7f00), 0x20); +} + +static void sub_807399C(u16 a1) +{ + int v1; + v1 = a1 % 2; + QueueTilesetAnimDma(gTilesetAnimTable_EliteFour_1[v1], (u8 *)(BG_VRAM + 0x7c00), 0x80); } -void TilesetCB_Cave(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = sub_8073600; -} - -void TilesetCB_EliteFour(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = 0x80; - gTileset2AnimCallback = sub_80738C0; -} - -void TilesetCB_MauvilleGym(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = sub_8073890; -} - -void TilesetCB_BikeShop(void) { - gTileset2AnimFrame = 0; - gTileset2AnimLength = gTileset1AnimLength; - gTileset2AnimCallback = sub_80738EC; -} - -static void sub_8073424(u16 a1) { - int v1; - v1 = a1 % 8; - if (v1 == 0) { - sub_80737A4(a1 / 8, 0); - sub_80737E0(a1 / 8); - } - if (v1 == 1) sub_80737A4(a1 / 8, 1); - if (v1 == 2) sub_80737A4(a1 / 8, 2); - if (v1 == 3) sub_80737A4(a1 / 8, 3); - if (v1 == 4) sub_80737A4(a1 / 8, 4); - if (v1 == 5) sub_80737A4(a1 / 8, 5); - if (v1 == 6) sub_80737A4(a1 / 8, 6); - if (v1 == 7) sub_80737A4(a1 / 8, 7); -} - -static void sub_80734A0(u16 a1) { - int v1; - v1 = a1 % 8; - if (v1 == 0) sub_8073704(a1 / 8, 0); - if (v1 == 1) sub_8073704(a1 / 8, 1); - if (v1 == 2) sub_8073704(a1 / 8, 2); - if (v1 == 3) sub_8073704(a1 / 8, 3); - if (v1 == 4) sub_8073704(a1 / 8, 4); - if (v1 == 5) sub_8073704(a1 / 8, 5); - if (v1 == 6) sub_8073704(a1 / 8, 6); - if (v1 == 7) sub_8073704(a1 / 8, 7); -} - -static void sub_8073514(u16 a1) { - int v1; - v1 = a1 % 0x10; - if (v1 == 0) sub_8073644(a1 / 0x10); - if (v1 == 1) sub_8073808(a1 / 0x10); -} - -static void sub_8073540(u16 a1) { - int v1; - v1 = a1 % 8; - if (v1 == 0) sub_8073830(a1 / 8, 0); - if (v1 == 1) sub_8073830(a1 / 8, 1); - if (v1 == 2) sub_8073830(a1 / 8, 2); - if (v1 == 3) sub_8073830(a1 / 8, 3); - if (v1 == 4) sub_8073830(a1 / 8, 4); - if (v1 == 5) sub_8073830(a1 / 8, 5); - if (v1 == 6) sub_8073830(a1 / 8, 6); - if (v1 == 7) sub_8073830(a1 / 8, 7); -} - -static void sub_80735B4(u16 a1) { - int v1; - v1 = a1 % 0x10; - if (v1 == 0) sub_807368C(a1 / 0x10); - if (v1 == 1) sub_80736DC(a1 / 0x10); -} - -static void sub_80735E4(u16 a1) { - int v1; - v1 = a1 % 0x10; - if (v1 == 0) sub_80736B4(a1 / 0x10); -} - -static void sub_8073600(u16 a1) { - int v1; - v1 = a1 % 0x10; - if (v1 == 1) sub_8073868(a1 / 0x10); -} - -static void sub_807361C(u16 a1) { - int v1; - v1 = a1 % 4; - QueueTilesetAnimDma(gTilesetAnimTable_General_4[v1], - (u8 *)(BG_VRAM + 0x3c00), - 0x140); -} - -static void sub_8073644(u8 a1) { - u8 v1; - v1 = a1 % 4; - QueueTilesetAnimDma(gTilesetAnimTable_Lavaridge[v1], - (u8 *)(BG_VRAM + 0x6400), - 0x80); - v1 = (a1 + 2) % 4; - QueueTilesetAnimDma(gTilesetAnimTable_Lavaridge[v1], - (u8 *)(BG_VRAM + 0x6480), - 0x80); -} - -static void sub_807368C(u8 a1) { - int v1; - v1 = a1 % 4; - QueueTilesetAnimDma(gTilesetAnimTable_Pacifidlog_0[v1], - (u8 *)(BG_VRAM + 0x7a00), - 0x3c0); -} - -static void sub_80736B4(u8 a1) { - int v1; - v1 = a1 % 4; - QueueTilesetAnimDma(gTilesetAnimTable_Underwater[v1], - (u8 *)(BG_VRAM + 0x7e00), - 0x80); -} - -static void sub_80736DC(u8 a1) { - int v1; - v1 = a1 % 8; - QueueTilesetAnimDma(gTilesetAnimTable_Pacifidlog_1[v1], - (u8 *)(BG_VRAM + 0x7e00), - 0x100); -} - -static void sub_8073704(u16 a1, u8 a2) { - int v1; - a1 -= a2; - if (a1 < 12) { - v1 = a1 % 12; - QueueTilesetAnimDma(gTilesetAnimTable_Mauville_0A[v1], - gUnknown_0837BAE4[a2], - 0x80); - QueueTilesetAnimDma(gTilesetAnimTable_Mauville_1A[v1], - gUnknown_0837BB04[a2], - 0x80); - } else { - v1 = a1 % 4; - QueueTilesetAnimDma(gTilesetAnimTable_Mauville_0B[v1], - gUnknown_0837BAE4[a2], - 0x80); - QueueTilesetAnimDma(gTilesetAnimTable_Mauville_1B[v1], - gUnknown_0837BB04[a2], - 0x80); - } -} - -static void sub_80737A4(u16 a1, u8 a2) { - int v1; - a1 -= a2; - - v1 = a1 % 8; - if (gTilesetAnimTable_Rustboro_0[v1]) { - QueueTilesetAnimDma(gTilesetAnimTable_Rustboro_0[v1], - gUnknown_0837BFA4[a2], - 0x80); - } -} - -static void sub_80737E0(u16 a1) { - int v1; - v1 = a1 % 2; - QueueTilesetAnimDma(gTilesetAnimTable_Rustboro_1[v1], - (u8 *)(BG_VRAM + 0x7800), - 0x80); -} - -static void sub_8073808(u16 a1) { - int v1; - v1 = a1 % 4; - QueueTilesetAnimDma(gTilesetAnimTable_Cave[v1], - (u8 *)(BG_VRAM + 0x5400), - 0x80); -} - -static void sub_8073830(u16 a1, u8 a2) { - int v1; - a1 -= a2; - v1 = a1 % 8; - QueueTilesetAnimDma(gTilesetAnimTable_EverGrande[v1], - gUnknown_0837C93C[a2], - 0x80); -} - -static void sub_8073868(u16 a1) { - int v1; - v1 = a1 % 4; - QueueTilesetAnimDma(gTilesetAnimTable_Cave[v1], - (u8 *)(BG_VRAM + 0x7400), - 0x80); -} - -static void sub_8073890(u16 a1) { - int v1; - v1 = a1 % 2; - if (!v1) { - sub_80739C4(a1 / 2); - } -} - -static void sub_80738A8(u16 a1) { - int v1; - v1 = a1 % 8; - if (!v1) { - sub_807392C(a1 / 8); - } -} - -static void sub_80738C0(u16 a1) { - if (a1 % 0x40 == 0) { - sub_807399C(a1 / 0x40); - } - if (a1 % 8 == 1) { - sub_8073974(a1 / 8); - } -} - -static void sub_80738EC(u16 a1) { - if (a1 % 4 == 0) { - sub_80739EC(a1 / 4); - } -} - -static void sub_8073904(u16 a1) { - int v1; - v1 = a1 % 2; - QueueTilesetAnimDma(gTilesetAnimTable_Building[v1], - (u8 *)(BG_VRAM + 0x3e00), - 0x80); -} - -static void sub_807392C(u16 a1) { - int v1; - v1 = a1 % 3; - QueueTilesetAnimDma(gTilesetAnimTable_SootopolisGym_0[v1], - (u8 *)(BG_VRAM + 0x7e00), - 0x180); - QueueTilesetAnimDma(gTilesetAnimTable_SootopolisGym_1[v1], - (u8 *)(BG_VRAM + 0x7a00), - 0x280); -} - -static void sub_8073974(u16 a1) { - int v1; - v1 = a1 % 4; - QueueTilesetAnimDma(gTilesetAnimTable_EliteFour_0[v1], - (u8 *)(BG_VRAM + 0x7f00), - 0x20); -} - -static void sub_807399C(u16 a1) { - int v1; - v1 = a1 % 2; - QueueTilesetAnimDma(gTilesetAnimTable_EliteFour_1[v1], - (u8 *)(BG_VRAM + 0x7c00), - 0x80); -} - -static void sub_80739C4(u16 a1) { - int v1; - v1 = a1 % 2; - QueueTilesetAnimDma(gTilesetAnimTable_MauvilleGym[v1], - (u8 *)(BG_VRAM + 0x5200), - 0x200); +static void sub_80739C4(u16 a1) +{ + int v1; + v1 = a1 % 2; + QueueTilesetAnimDma(gTilesetAnimTable_MauvilleGym[v1], (u8 *)(BG_VRAM + 0x5200), 0x200); } -static void sub_80739EC(u16 a1) { - int v1; - v1 = a1 % 2; - QueueTilesetAnimDma(gTilesetAnimTable_BikeShop[v1], - (u8 *)(BG_VRAM + 0x7e00), - 0x120); +static void sub_80739EC(u16 a1) +{ + int v1; + v1 = a1 % 2; + QueueTilesetAnimDma(gTilesetAnimTable_BikeShop[v1], (u8 *)(BG_VRAM + 0x7e00), 0x120); } diff --git a/src/time_events.c b/src/time_events.c new file mode 100644 index 000000000..e1b9a2e9e --- /dev/null +++ b/src/time_events.c @@ -0,0 +1,118 @@ +#include "global.h" +#include "time_events.h" +#include "event_data.h" +#include "field_weather.h" +#include "pokemon.h" +#include "rng.h" +#include "rom4.h" +#include "rtc.h" +#include "script.h" +#include "task.h" + +static u32 GetMirageRnd(void) +{ + u32 hi = VarGet(VAR_MIRAGE_RND_H); + u32 lo = VarGet(VAR_MIRAGE_RND_L); + return (hi << 16) | lo; +} + +static void SetMirageRnd(u32 rnd) +{ + VarSet(VAR_MIRAGE_RND_H, rnd >> 16); + VarSet(VAR_MIRAGE_RND_L, rnd); +} + +// unused +void InitMirageRnd(void) +{ + SetMirageRnd((Random() << 16) | Random()); +} + +void UpdateMirageRnd(u16 days) +{ + s32 rnd = GetMirageRnd(); + while (days) + { + rnd = 1103515245 * rnd + 12345; + days--; + } + SetMirageRnd(rnd); +} + +bool8 IsMirageIslandPresent(void) +{ + u16 rnd = GetMirageRnd() >> 16; + int i; + + for (i = 0; i < PARTY_SIZE; i++) + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && (GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY) & 0xFFFF) == rnd) + return TRUE; + + return FALSE; +} + +void UpdateShoalTideFlag(void) +{ + static const u8 tide[] = + { + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + }; + + if (is_light_level_1_2_3_5_or_6(get_map_light_from_warp0())) + { + RtcCalcLocalTime(); + if (tide[gLocalTime.hours]) + FlagSet(SYS_SHOAL_TIDE); + else + FlagReset(SYS_SHOAL_TIDE); + } +} + +static void Task_WaitWeather(u8 taskId) +{ + if (sub_807DDFC()) + { + EnableBothScriptContexts(); + DestroyTask(taskId); + } +} + +void WaitWeather(void) +{ + CreateTask(Task_WaitWeather, 80); +} + +void InitBirchState(void) +{ + *(u16 *)GetVarPointer(VAR_BIRCH_STATE) = 0; +} + +void UpdateBirchState(u16 days) +{ + u16 *state = GetVarPointer(VAR_BIRCH_STATE); + *state += days; + *state %= 7; +} diff --git a/src/title_screen.c b/src/title_screen.c index 9282978de..664e07978 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -1,49 +1,325 @@ #include "global.h" +#include "gba/m4a_internal.h" #include "title_screen.h" -#include "asm.h" #include "clear_save_data_menu.h" -#include "m4a.h" -#include "main_menu.h" +#include "decompress.h" +#include "event_data.h" #include "intro.h" -#include "gba/m4a_internal.h" +#include "m4a.h" #include "main.h" +#include "main_menu.h" #include "palette.h" +#include "reset_rtc_screen.h" #include "sound.h" #include "sprite.h" #include "task.h" -#include "decompress.h" +#include "unknown_task.h" + +#if ENGLISH +#define VERSION_BANNER_SHAPE 1 +#define VERSION_BANNER_RIGHT_TILEOFFSET 64 +#define VERSION_BANNER_BYTES 0x1000 +#define VERSION_BANNER_LEFT_X 98 +#define VERSION_BANNER_RIGHT_X 162 +#define VERSION_BANNER_Y 26 +#define VERSION_BANNER_Y_GOAL 66 +#define START_BANNER_X DISPLAY_WIDTH / 2 +#elif GERMAN +#define VERSION_BANNER_SHAPE 0 +#define VERSION_BANNER_RIGHT_TILEOFFSET 128 +#define VERSION_BANNER_BYTES 0x2000 +#define VERSION_BANNER_LEFT_X 108 +#define VERSION_BANNER_RIGHT_X 172 +#define VERSION_BANNER_Y 44 +#define VERSION_BANNER_Y_GOAL 84 +#define START_BANNER_X DISPLAY_WIDTH / 2 - 2 +#endif extern u8 gReservedSpritePaletteCount; extern struct MusicPlayerInfo gMPlay_BGM; extern u8 gUnknown_0202F7E4; extern u16 gUnknown_030041B4; extern u16 gUnknown_030042C0; -extern u8 gUnknown_08393210[]; -extern u8 gUnknown_08393250[]; -extern u8 gUnknown_083939EC[]; -extern u8 gUnknown_08393BF8[]; -extern u16 gUnknown_08393E64[]; -extern struct SpriteTemplate gSpriteTemplate_8393ECC; -extern struct SpriteTemplate gSpriteTemplate_8393EE4; -extern struct SpriteSheet gUnknown_08393EFC; -extern struct SpriteTemplate gSpriteTemplate_8393F74; -extern struct SpriteSheet gUnknown_08393F8C; -extern const struct SpritePalette gUnknown_08393F9C[]; -extern struct SpriteTemplate gSpriteTemplate_8393FC0; -extern struct SpriteSheet gUnknown_08393FD8; -extern u8 gUnknown_08E9D8CC[]; -extern u8 gUnknown_08E9F624[]; -extern u8 gUnknown_08E9F7E4[]; +extern const u8 gUnknown_08E9D8CC[]; +extern const u16 gUnknown_08E9F624[]; +extern const u8 gUnknown_08E9F7E4[]; +extern const u8 gVersionTiles[]; +extern const u8 gTitleScreenPressStart_Gfx[]; +extern const u16 gTitleScreenLogoShinePalette[]; -static void MainCB2(void); -static void Task_TitleScreenPhase1(u8); -static void Task_TitleScreenPhase2(u8); -static void Task_TitleScreenPhase3(u8); -static void CB2_GoToMainMenu(void); -static void CB2_GoToClearSaveDataScreen(void); -static void CB2_GoToResetRtcScreen(void); -static void CB2_GoToCopyrightScreen(void); -static void UpdateLegendaryMarkingColor(u8); +#ifdef SAPPHIRE +static const u16 sLegendaryMonPalettes[][16] = +{ + INCBIN_U16("graphics/title_screen/kyogre_dark.gbapal"), + INCBIN_U16("graphics/title_screen/kyogre_glow.gbapal"), +}; +static const u8 sLegendaryMonPixelData[] = INCBIN_U8("graphics/title_screen/kyogre.4bpp.lz"); +static const u8 sLegendaryMonTilemap[] = INCBIN_U8("graphics/title_screen/kyogre_map.bin.lz"); +static const u8 sBackdropTilemap[] = INCBIN_U8("graphics/title_screen/water_map.bin.lz"); +#else +static const u16 sLegendaryMonPalettes[][16] = +{ + INCBIN_U16("graphics/title_screen/groudon_dark.gbapal"), + INCBIN_U16("graphics/title_screen/groudon_glow.gbapal"), +}; +static const u8 sLegendaryMonPixelData[] = INCBIN_U8("graphics/title_screen/groudon.4bpp.lz"); +static const u8 sLegendaryMonTilemap[] = INCBIN_U8("graphics/title_screen/groudon_map.bin.lz"); +static const u8 sBackdropTilemap[] = INCBIN_U8("graphics/title_screen/lava_map.bin.lz"); +#endif +static const u8 sLogoShineTiles[] = INCBIN_U8("graphics/title_screen/logo_shine.4bpp.lz"); +const u16 gUnknown_08393E64[] = +{ + 0x10, + 0x110, + 0x210, + 0x310, + 0x410, + 0x510, + 0x610, + 0x710, + 0x810, + 0x910, + 0xA10, + 0xB10, + 0xC10, + 0xD10, + 0xE10, + 0xF10, + 0x100F, + 0x100E, + 0x100D, + 0x100C, + 0x100B, + 0x100A, + 0x1009, + 0x1008, + 0x1007, + 0x1006, + 0x1005, + 0x1004, + 0x1003, + 0x1002, + 0x1001, + 0x1000, +}; +static const struct OamData sVersionBannerLeftOamData = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 1, + .shape = VERSION_BANNER_SHAPE, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const struct OamData sVersionBannerRightOamData = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 1, + .shape = VERSION_BANNER_SHAPE, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd sVersionBannerLeftAnimSequence[] = +{ + ANIMCMD_FRAME(0, 30), + ANIMCMD_END, +}; +static const union AnimCmd sVersionBannerRightAnimSequence[] = +{ + ANIMCMD_FRAME(VERSION_BANNER_RIGHT_TILEOFFSET, 30), + ANIMCMD_END, +}; +static const union AnimCmd *const sVersionBannerLeftAnimTable[] = +{ + sVersionBannerLeftAnimSequence, +}; +static const union AnimCmd *const sVersionBannerRightAnimTable[] = +{ + sVersionBannerRightAnimSequence, +}; +static const struct SpriteTemplate sVersionBannerLeftSpriteTemplate = +{ + .tileTag = 1000, + .paletteTag = 1000, + .oam = &sVersionBannerLeftOamData, + .anims = sVersionBannerLeftAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallback_VersionBannerLeft, +}; +static const struct SpriteTemplate sVersionBannerRightSpriteTemplate = +{ + .tileTag = 1000, + .paletteTag = 1000, + .oam = &sVersionBannerRightOamData, + .anims = sVersionBannerRightAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallback_VersionBannerRight, +}; +static const struct CompressedSpriteSheet gUnknown_08393EFC[] = +{ + {gVersionTiles, VERSION_BANNER_BYTES, 1000}, + {NULL}, +}; +static const struct OamData gOamData_8393F0C = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_8393F14[] = +{ + ANIMCMD_FRAME(0, 4), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_8393F1C[] = +{ + ANIMCMD_FRAME(4, 4), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_8393F24[] = +{ + ANIMCMD_FRAME(8, 4), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_8393F2C[] = +{ + ANIMCMD_FRAME(12, 4), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_8393F34[] = +{ + ANIMCMD_FRAME(16, 4), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_8393F3C[] = +{ + ANIMCMD_FRAME(20, 4), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_8393F44[] = +{ + ANIMCMD_FRAME(24, 4), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_8393F4C[] = +{ + ANIMCMD_FRAME(28, 4), + ANIMCMD_END, +}; +#if GERMAN +static const union AnimCmd gSpriteAnim_839F73C[] = +{ + ANIMCMD_FRAME(32, 4), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_839F744[] = +{ + ANIMCMD_FRAME(36, 4), + ANIMCMD_END, +}; +#endif +static const union AnimCmd *const sStartCopyrightBannerAnimTable[] = +{ + gSpriteAnim_8393F14, + gSpriteAnim_8393F1C, + gSpriteAnim_8393F24, + gSpriteAnim_8393F2C, + gSpriteAnim_8393F34, + gSpriteAnim_8393F3C, + gSpriteAnim_8393F44, + gSpriteAnim_8393F4C, +#if GERMAN + gSpriteAnim_839F73C, + gSpriteAnim_839F744, +#endif +}; +static const struct SpriteTemplate sStartCopyrightBannerSpriteTemplate = +{ + .tileTag = 1001, + .paletteTag = 1001, + .oam = &gOamData_8393F0C, + .anims = sStartCopyrightBannerAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallback_PressStartCopyrightBanner, +}; +static const struct CompressedSpriteSheet gUnknown_08393F8C[] = +{ + {gTitleScreenPressStart_Gfx, 0x520, 1001}, + {NULL}, +}; +const struct SpritePalette sPokemonLogoShinePalette[] = +{ + {gTitleScreenLogoShinePalette, 1001}, + {NULL}, +}; +static const struct OamData sPokemonLogoShineOamData = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd sPokemonLogoShineAnimSequence[] = +{ + ANIMCMD_FRAME(0, 4), + ANIMCMD_END, +}; +static const union AnimCmd *const sPokemonLogoShineAnimTable[] = +{ + sPokemonLogoShineAnimSequence, +}; +static const struct SpriteTemplate sPokemonLogoShineSpriteTemplate = +{ + .tileTag = 1002, + .paletteTag = 1001, + .oam = &sPokemonLogoShineOamData, + .anims = sPokemonLogoShineAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallback_PokemonLogoShine, +}; +static const struct CompressedSpriteSheet sPokemonLogoShineSpriteSheet[] = +{ + {sLogoShineTiles, 0x800, 1002}, + {NULL}, +}; #define _RGB(r, g, b) ((((b) & 31) << 10) + (((g) & 31) << 5) + ((r) & 31)) @@ -65,14 +341,24 @@ static void UpdateLegendaryMarkingColor(u8); #define RESET_RTC_BUTTON_COMBO (B_BUTTON | SELECT_BUTTON | DPAD_LEFT) #define A_B_START_SELECT (A_BUTTON | B_BUTTON | START_BUTTON | SELECT_BUTTON) +static void MainCB2(void); +static void Task_TitleScreenPhase1(u8); +static void Task_TitleScreenPhase2(u8); +static void Task_TitleScreenPhase3(u8); +static void CB2_GoToMainMenu(void); +static void CB2_GoToClearSaveDataScreen(void); +static void CB2_GoToResetRtcScreen(void); +static void CB2_GoToCopyrightScreen(void); +static void UpdateLegendaryMarkingColor(u8); + void SpriteCallback_VersionBannerLeft(struct Sprite *sprite) { struct Task *task = &gTasks[sprite->data1]; - + if (task->data[1] != 0) { sprite->oam.objMode = 0; - sprite->pos1.y = 66; + sprite->pos1.y = VERSION_BANNER_Y_GOAL; sprite->invisible = FALSE; } else @@ -82,7 +368,7 @@ void SpriteCallback_VersionBannerLeft(struct Sprite *sprite) if (task->data[5] < 64) { sprite->invisible = FALSE; - if (sprite->pos1.y != 66) + if (sprite->pos1.y != VERSION_BANNER_Y_GOAL) sprite->pos1.y++; REG_BLDALPHA = gUnknown_08393E64[task->data[5] / 2]; } @@ -92,11 +378,11 @@ void SpriteCallback_VersionBannerLeft(struct Sprite *sprite) void SpriteCallback_VersionBannerRight(struct Sprite *sprite) { struct Task *task = &gTasks[sprite->data1]; - + if (task->data[1] != 0) { sprite->oam.objMode = 0; - sprite->pos1.y = 66; + sprite->pos1.y = VERSION_BANNER_Y_GOAL; sprite->invisible = FALSE; } else @@ -104,7 +390,7 @@ void SpriteCallback_VersionBannerRight(struct Sprite *sprite) if (task->data[5] < 64) { sprite->invisible = FALSE; - if (sprite->pos1.y != 66) + if (sprite->pos1.y != VERSION_BANNER_Y_GOAL) sprite->pos1.y++; } } @@ -125,29 +411,134 @@ void SpriteCallback_PressStartCopyrightBanner(struct Sprite *sprite) sprite->invisible = FALSE; } +#if ENGLISH static void CreatePressStartBanner(s16 x, s16 y) { u8 i; u8 spriteId; - + x -= 32; for (i = 0; i < 3; i++, x += 32) { - spriteId = CreateSprite(&gSpriteTemplate_8393F74, x, y, 0); + spriteId = CreateSprite(&sStartCopyrightBannerSpriteTemplate, x, y, 0); StartSpriteAnim(&gSprites[spriteId], i); gSprites[spriteId].data0 = 1; } } +#elif GERMAN +__attribute__((naked)) +static void CreatePressStartBanner(s16 x, s16 y) +{ + 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\ + lsls r0, 16\n\ + ldr r2, _0807C3AC @ =0xffe00000\n\ + adds r0, r2\n\ + lsrs r0, 16\n\ + movs r6, 0\n\ + lsls r1, 16\n\ + mov r10, r1\n\ + mov r8, r10\n\ +_0807C302:\n\ + lsls r5, r0, 16\n\ + asrs r5, 16\n\ + ldr r0, _0807C3B0 @ =sStartCopyrightBannerSpriteTemplate\n\ + adds r1, r5, 0\n\ + mov r3, r8\n\ + asrs r2, r3, 16\n\ + movs r3, 0\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + lsls r4, r0, 4\n\ + adds r4, r0\n\ + lsls r4, 2\n\ + ldr r0, _0807C3B4 @ =gSprites\n\ + mov r9, r0\n\ + add r4, r9\n\ + adds r0, r4, 0\n\ + adds r1, r6, 0\n\ + bl StartSpriteAnim\n\ + movs r7, 0x1\n\ + strh r7, [r4, 0x2E]\n\ + adds r0, r6, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + adds r5, 0x20\n\ + lsls r5, 16\n\ + lsrs r0, r5, 16\n\ + cmp r6, 0x2\n\ + bls _0807C302\n\ + ldr r1, _0807C3B0 @ =sStartCopyrightBannerSpriteTemplate\n\ + mov r8, r1\n\ + lsls r5, r0, 16\n\ + asrs r5, 16\n\ + mov r2, r10\n\ + asrs r6, r2, 16\n\ + mov r0, r8\n\ + adds r1, r5, 0\n\ + adds r2, r6, 0\n\ + movs r3, 0\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + lsls r4, r0, 4\n\ + adds r4, r0\n\ + lsls r4, 2\n\ + add r4, r9\n\ + adds r0, r4, 0\n\ + movs r1, 0x8\n\ + bl StartSpriteAnim\n\ + strh r7, [r4, 0x2E]\n\ + subs r5, 0x60\n\ + lsls r5, 16\n\ + asrs r5, 16\n\ + subs r6, 0x8\n\ + lsls r6, 16\n\ + asrs r6, 16\n\ + mov r0, r8\n\ + adds r1, r5, 0\n\ + adds r2, r6, 0\n\ + movs r3, 0\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + lsls r4, r0, 4\n\ + adds r4, r0\n\ + lsls r4, 2\n\ + add r4, r9\n\ + adds r0, r4, 0\n\ + movs r1, 0x9\n\ + bl StartSpriteAnim\n\ + strh r7, [r4, 0x2E]\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\ + .align 2, 0\n\ +_0807C3AC: .4byte 0xffe00000\n\ +_0807C3B0: .4byte sStartCopyrightBannerSpriteTemplate\n\ +_0807C3B4: .4byte gSprites\n\ + .syntax divided\n"); +} +#endif static void CreateCopyrightBanner(s16 x, s16 y) { u8 i; u8 spriteId; - + x -= 64; for (i = 0; i < 5; i++, x += 32) { - spriteId = CreateSprite(&gSpriteTemplate_8393F74, x, y, 0); + spriteId = CreateSprite(&sStartCopyrightBannerSpriteTemplate, x, y, 0); StartSpriteAnim(&gSprites[spriteId], i + 3); } } @@ -159,7 +550,7 @@ void SpriteCallback_PokemonLogoShine(struct Sprite *sprite) if (sprite->data0) //Flash background { u16 backgroundColor; - + if (sprite->pos1.x < DISPLAY_WIDTH / 2) { //Brighten background color @@ -192,8 +583,8 @@ void SpriteCallback_PokemonLogoShine(struct Sprite *sprite) static void StartPokemonLogoShine(bool8 flashBackground) { - u8 spriteId = CreateSprite(&gSpriteTemplate_8393FC0, 0, 68, 0); - + u8 spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, 0, 68, 0); + gSprites[spriteId].oam.objMode = 2; gSprites[spriteId].data0 = flashBackground; } @@ -207,11 +598,9 @@ static void VBlankCB(void) REG_BG1VOFS = gUnknown_030041B4; } -enum -{ - TD_COUNTER, - TD_SKIP, -}; + +#define tCounter data[0] +#define tSkipToNext data[1] void CB2_InitTitleScreen(void) { @@ -244,28 +633,28 @@ void CB2_InitTitleScreen(void) LZ77UnCompVram(gUnknown_08E9D8CC, (void *)VRAM); LZ77UnCompVram(gUnknown_08E9F7E4, (void *)(VRAM + 0x4800)); LoadPalette(gUnknown_08E9F624, 0, 0x1C0); - LZ77UnCompVram(gUnknown_08393250, (void *)(VRAM + 0x8000)); - LZ77UnCompVram(gUnknown_083939EC, (void *)(VRAM + 0xC000)); - LZ77UnCompVram(gUnknown_08393BF8, (void *)(VRAM + 0xC800)); - LoadPalette(gUnknown_08393210, 0xE0, 0x40); + LZ77UnCompVram(sLegendaryMonPixelData, (void *)(VRAM + 0x8000)); + LZ77UnCompVram(sLegendaryMonTilemap, (void *)(VRAM + 0xC000)); + LZ77UnCompVram(sBackdropTilemap, (void *)(VRAM + 0xC800)); + LoadPalette(sLegendaryMonPalettes, 0xE0, sizeof(sLegendaryMonPalettes)); remove_some_task(); ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); gReservedSpritePaletteCount = 14; - LoadCompressedObjectPic(&gUnknown_08393EFC); - LoadCompressedObjectPic(&gUnknown_08393F8C); - LoadCompressedObjectPic(&gUnknown_08393FD8); + LoadCompressedObjectPic(&gUnknown_08393EFC[0]); + LoadCompressedObjectPic(&gUnknown_08393F8C[0]); + LoadCompressedObjectPic(&sPokemonLogoShineSpriteSheet[0]); LoadPalette(gUnknown_08E9F624, 0x100, 0x1C0); - LoadSpritePalette(&gUnknown_08393F9C[0]); + LoadSpritePalette(&sPokemonLogoShinePalette[0]); gMain.state = 2; break; case 2: { u8 taskId = CreateTask(Task_TitleScreenPhase1, 0); - - gTasks[taskId].data[TD_COUNTER] = 0x100; - gTasks[taskId].data[TD_SKIP] = FALSE; + + gTasks[taskId].tCounter = 256; + gTasks[taskId].tSkipToNext = FALSE; gTasks[taskId].data[2] = -16; gTasks[taskId].data[3] = -32; gUnknown_0202F7E4 = taskId; @@ -280,7 +669,7 @@ void CB2_InitTitleScreen(void) case 4: { u16 savedIme; - + sub_813CE30(0x78, 0x50, 0x100, 0); REG_BG2X = -29 * 256; REG_BG2Y = -33 * 256; @@ -293,9 +682,9 @@ void CB2_InitTitleScreen(void) REG_BLDCNT = 0x84; REG_BLDALPHA = 0; REG_BLDY = 0x8; - REG_BG0CNT = 0x180B; - REG_BG1CNT = 0x190A; - REG_BG2CNT = 0x4981; + REG_BG0CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(24) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(25) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(9) | BGCNT_256COLOR | BGCNT_AFF256x256; savedIme = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; @@ -336,41 +725,41 @@ static void Task_TitleScreenPhase1(u8 taskId) //Skip to next phase when A, B, Start, or Select is pressed if ((gMain.newKeys & A_B_START_SELECT) || gTasks[taskId].data[1] != 0) { - gTasks[taskId].data[TD_SKIP] = TRUE; - gTasks[taskId].data[TD_COUNTER] = 0; + gTasks[taskId].tSkipToNext = TRUE; + gTasks[taskId].tCounter = 0; } - - if (gTasks[taskId].data[TD_COUNTER] != 0) + + if (gTasks[taskId].tCounter != 0) { - u16 frameNum = gTasks[taskId].data[TD_COUNTER]; - + u16 frameNum = gTasks[taskId].tCounter; + if (frameNum == 160 || frameNum == 64) StartPokemonLogoShine(TRUE); - gTasks[taskId].data[TD_COUNTER]--; + gTasks[taskId].tCounter--; } else { u8 spriteId; - + REG_DISPCNT = DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; REG_WININ = 0; REG_WINOUT = 0; REG_BLDCNT = 0x3F50; REG_BLDALPHA = 0x1F; REG_BLDY = 0; - + //Create left side of version banner - spriteId = CreateSprite(&gSpriteTemplate_8393ECC, 0x62, 0x1A, 0); + spriteId = CreateSprite(&sVersionBannerLeftSpriteTemplate, VERSION_BANNER_LEFT_X, VERSION_BANNER_Y, 0); gSprites[spriteId].invisible = TRUE; gSprites[spriteId].data1 = taskId; - + //Create right side of version banner - spriteId = CreateSprite(&gSpriteTemplate_8393EE4, 0xA2, 0x1A, 0); + spriteId = CreateSprite(&sVersionBannerRightSpriteTemplate, VERSION_BANNER_RIGHT_X, VERSION_BANNER_Y, 0); gSprites[spriteId].invisible = TRUE; gSprites[spriteId].data1 = taskId; - + gTasks[taskId].data[5] = 88; - gTasks[taskId].data[TD_COUNTER] = 144; + gTasks[taskId].tCounter = 144; gTasks[taskId].func = Task_TitleScreenPhase2; } } @@ -379,32 +768,32 @@ static void Task_TitleScreenPhase1(u8 taskId) static void Task_TitleScreenPhase2(u8 taskId) { //Skip to next phase when A, B, Start, or Select is pressed - if ((gMain.newKeys & A_B_START_SELECT) || gTasks[taskId].data[TD_SKIP]) + if ((gMain.newKeys & A_B_START_SELECT) || gTasks[taskId].tSkipToNext) { - gTasks[taskId].data[TD_SKIP] = TRUE; - gTasks[taskId].data[TD_COUNTER] = 0; + gTasks[taskId].tSkipToNext = TRUE; + gTasks[taskId].tCounter = 0; } - - if (gTasks[taskId].data[TD_COUNTER] != 0) - gTasks[taskId].data[TD_COUNTER]--; + + if (gTasks[taskId].tCounter != 0) + gTasks[taskId].tCounter--; else { - gTasks[taskId].data[TD_SKIP] = TRUE; + gTasks[taskId].tSkipToNext = TRUE; REG_DISPCNT = DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; - CreatePressStartBanner(DISPLAY_WIDTH / 2, 108); + CreatePressStartBanner(START_BANNER_X, 108); CreateCopyrightBanner(DISPLAY_WIDTH / 2, 148); gTasks[taskId].data[4] = 0; gTasks[taskId].func = Task_TitleScreenPhase3; } - - if (!(gTasks[taskId].data[TD_COUNTER] & 1) && gTasks[taskId].data[3] != 0) + + if (!(gTasks[taskId].tCounter & 1) && gTasks[taskId].data[3] != 0) gTasks[taskId].data[3]++; - + //Slide Pokemon logo up REG_BG2Y = gTasks[taskId].data[3] * 256; } @@ -415,7 +804,7 @@ static void Task_TitleScreenPhase3(u8 taskId) REG_BLDCNT = 0x2142; REG_BLDALPHA = 0x1F0F; REG_BLDY = 0; - + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & START_BUTTON)) { FadeOutBGM(4); @@ -427,7 +816,7 @@ static void Task_TitleScreenPhase3(u8 taskId) if ((gMain.heldKeys & CLEAR_SAVE_BUTTON_COMBO) == CLEAR_SAVE_BUTTON_COMBO) SetMainCallback2(CB2_GoToClearSaveDataScreen); if ((gMain.heldKeys & RESET_RTC_BUTTON_COMBO) == RESET_RTC_BUTTON_COMBO - && sub_80691DC() == 1) + && CanResetRTC() == 1) { FadeOutBGM(4); BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); @@ -436,14 +825,14 @@ static void Task_TitleScreenPhase3(u8 taskId) else { REG_BG2Y = 0; - gTasks[taskId].data[TD_COUNTER]++; - if (gTasks[taskId].data[TD_COUNTER] & 1) + gTasks[taskId].tCounter++; + if (gTasks[taskId].tCounter & 1) { gTasks[taskId].data[4]++; gUnknown_030041B4 = gTasks[taskId].data[4]; gUnknown_030042C0 = 0; } - UpdateLegendaryMarkingColor(gTasks[taskId].data[TD_COUNTER]); + UpdateLegendaryMarkingColor(gTasks[taskId].tCounter); if ((gMPlay_BGM.status & 0xFFFF) == 0) { BeginNormalPaletteFade(-1, 0, 0, 0x10, 0xFFFF); @@ -462,7 +851,7 @@ static void CB2_GoToMainMenu(void) static void CB2_GoToCopyrightScreen(void) { if (!UpdatePaletteFade()) - SetMainCallback2(CB2_InitCopyrightScreen); + SetMainCallback2(CB2_InitCopyrightScreenAfterTitleScreen); } static void CB2_GoToClearSaveDataScreen(void) @@ -480,12 +869,12 @@ static void CB2_GoToResetRtcScreen(void) static void UpdateLegendaryMarkingColor(u8 frameNum) { u16 palette; - + if ((frameNum % 4) == 0) //Change color every 4th frame { u8 colorIntensity = (frameNum >> 2) & 31; //Take bits 2-6 of frameNum the color intensity u8 fadeDarker = (frameNum >> 2) & 32; - + if (!fadeDarker) palette = LEGENDARY_MARKING_COLOR(colorIntensity); else diff --git a/src/trade.c b/src/trade.c new file mode 100644 index 000000000..cb190d194 --- /dev/null +++ b/src/trade.c @@ -0,0 +1,88 @@ +#include "global.h" +#include "name_string_util.h" +#include "string_util.h" +#include "text.h" + +struct InGameTrade { + /*0x00*/ u8 name[11]; + /*0x0C*/ u16 species; + /*0x0E*/ u8 ivs[6]; + /*0x14*/ bool8 secondAbility; + /*0x18*/ u32 otId; + /*0x1C*/ u8 stats[5]; + /*0x24*/ u32 personality; + /*0x28*/ u16 heldItem; + /*0x2A*/ u8 mailNum; + /*0x2B*/ u8 otName[11]; + /*0x36*/ u8 otGender; + /*0x37*/ u8 sheen; + /*0x38*/ u16 playerSpecies; +}; + +struct UnkStructC { + /*0x00*/ u16 words[9]; + /*0x10*/ u8 string[8]; + /*0x1A*/ u8 otId[4]; + /*0x1E*/ u16 species; + /*0x20*/ u16 heldItem; +}; + +struct UnkStructD { + /*0x00*/ u8 pad00[0x10]; + /*0x10*/ u8 var10; + /*0x11*/ u8 pad11[1]; + /*0x12*/ u16 var12[1]; +}; + +extern const struct InGameTrade gIngameTrades[]; +extern const u16 gIngameTradeMail[][10]; + + +void sub_804A96C(struct UnkStructD *arg0, u8 left, u8 top, u16 *tilemap, u8 width, u8 height, u16 sp8) { + int y, x; + + for (y = 0; y < height; y++) + { + + for (x = 0; x < width; x++) + { + arg0->var12[(top * 32 + left) + y * 32 + x] = tilemap[width * y + x] | sp8; + } + } + +#if ENGLISH + arg0->var10 = 1; +#endif +} + +#if GERMAN +void sub_804A96C_alt(struct UnkStructD *arg0, u8 left, u8 top, u16 *tilemap, u8 width, u8 height, u16 sp8) { + sub_804A96C(arg0, left, top, tilemap, width, height, sp8); + + arg0->var10 = 1; +} +#endif + +asm(".section .text.sub_804DAD4"); + +void sub_804DAD4(struct UnkStructC *arg0, struct InGameTrade *trade) { + s32 i; + + for (i = 0; i < 9; i++) + { + arg0->words[i] = gIngameTradeMail[trade->mailNum][i]; + } + + StringCopy(arg0->string, trade->otName); + +#if GERMAN + PadNameString(arg0->string, CHAR_SPACE); +#endif + + arg0->otId[0] = trade->otId >> 24; + arg0->otId[1] = trade->otId >> 16; + arg0->otId[2] = trade->otId >> 8; + arg0->otId[3] = trade->otId; + arg0->species = trade->species; + arg0->heldItem = trade->heldItem; +} diff --git a/src/trainer_card.c b/src/trainer_card.c index 041245bdc..876a3b426 100644 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -1,8 +1,8 @@ #include "global.h" #include "trainer_card.h" -#include "asm.h" -#include "flag.h" -#include "flags.h" +#include "easy_chat.h" +#include "event_data.h" +#include "field_effect.h" #include "link.h" #include "main.h" #include "menu.h" @@ -10,15 +10,20 @@ #include "palette.h" #include "pokedex.h" #include "rom4.h" +#include "script_pokemon_80C4.h" #include "songs.h" #include "sound.h" #include "sprite.h" #include "string_util.h" +#include "strings2.h" #include "task.h" +#include "unknown_task.h" +#include "util.h" typedef void (*Callback)(void); -struct Struct2000000 { +struct Struct2000000 +{ /*0x00*/ u8 var_0; /*0x01*/ bool8 var_1; /*0x02*/ u8 var_2; @@ -41,11 +46,18 @@ struct Struct2000000 { /*0x9C*/ u8 language; // 0x9C }; -extern struct Struct2000000 unk_2000000; +extern u8 ewram[]; +#define ewram0 (*(struct Struct2000000 *)(ewram)) + extern struct LinkPlayerMapObject gLinkPlayerMapObjects[]; extern struct TrainerCard gTrainerCards[4]; -extern u8 gUnknown_03004DE0[]; // TODO: find out correct type +struct UnknownStruct1 +{ + u8 filler0[0x780]; + u16 unk780[160]; +}; +extern struct UnknownStruct1 gUnknown_03004DE0; extern u8 gUnknown_083B5EF4[]; extern u16 *gUnknown_083B5EF8[5]; @@ -56,22 +68,15 @@ extern u16 gUnknown_083B5F4C[]; extern u16 gUnknown_08E8CFC0[]; extern u16 gUnknown_08E8D9C0[]; -extern u8 gOtherText_TrainersTrainerCard[]; -extern u8 gOtherText_FirstHOF[]; -extern u8 gOtherText_LinkCableBattles[]; -extern u8 gOtherText_BattleTowerWinRecord[]; -extern u8 gOtherText_ContestRecord[]; -extern u8 gOtherText_MixingRecord[]; -extern u8 gOtherText_TradeRecord[]; -extern u8 gOtherText_Boy[]; -extern u8 gOtherText_Girl[]; - -// Other signature than on save_menu_util.h -void FormatPlayTime(u8 *playtime, u16 hours, u16 minutes, s16 colon); +extern bool8 (*const gUnknown_083B5EBC[])(struct Task *); +extern bool8 (*const gUnknown_083B5ED8[])(struct Task *); +// FIXME: Other signature than on save_menu_util.h +void FormatPlayTime(u8 *playtime, u16 hours, u16 minutes, s16 colon); u16 GetPokedexSeenCount(void); -enum { +enum +{ TD_0, TD_1, TD_CALLBACK, @@ -145,78 +150,71 @@ static void TrainerCard_Back_PrintPokemonTrades_Label(void); static void TrainerCard_Back_PrintPokemonTrades(void); void unref_sub_8094588(u16 left, u16 top); -void sub_8093110(Callback arg1) { +void sub_8093110(Callback arg1) +{ sub_80932AC(arg1); SetMainCallback2(sub_8093174); - unk_2000000.language = 2; + ewram0.language = GAME_LANGUAGE; } -void sub_8093130(u8 playerIndex, Callback arg2) { - struct Struct2000000* r2; - struct LinkPlayer* r3; - struct LinkPlayerMapObject* r4; - u8 linkPlayerId; - +void sub_8093130(u8 playerIndex, Callback arg2) +{ sub_80932E4(playerIndex, arg2); SetMainCallback2(sub_8093174); - - r2 = &unk_2000000; - r3 = gLinkPlayers; - r4 = gLinkPlayerMapObjects; - - linkPlayerId = r4[playerIndex].linkPlayerId; - - r2->language = r3[linkPlayerId].language; + ewram0.language = gLinkPlayers[gLinkPlayerMapObjects[playerIndex].linkPlayerId].language; } - -static void sub_8093174(void) { - switch (gMain.state) { - case 0: - sub_8093534(); - sub_8093688(); - gMain.state += 1; - break; - case 1: - sub_8093598(); - gMain.state += 1; - break; - case 2: - sub_80935EC(); - gMain.state += 1; - break; - case 3: - sub_8093610(); - sub_80937A4(); - gMain.state += 1; - break; - case 4: - sub_80937BC(); - gMain.state += 1; - case 5: - if (MultistepInitMenuWindowContinue() == FALSE) { - return; - } - gMain.state += 1; - break; - case 6: - sub_80937F0(); - gMain.state += 1; - break; - case 7: - sub_80937D8(); - gMain.state += 1; - break; - case 8: - nullsub_15(); - sub_8093800(); - sub_8093550(); - SetMainCallback2(sub_809323C); - break; +static void sub_8093174(void) +{ + switch (gMain.state) + { + case 0: + sub_8093534(); + sub_8093688(); + gMain.state += 1; + break; + case 1: + sub_8093598(); + gMain.state += 1; + break; + case 2: + sub_80935EC(); + gMain.state += 1; + break; + case 3: + sub_8093610(); + sub_80937A4(); + gMain.state += 1; + break; + case 4: + sub_80937BC(); + gMain.state += 1; + case 5: + if (MultistepInitMenuWindowContinue() == FALSE) + { + return; + } + gMain.state += 1; + break; + case 6: + sub_80937F0(); + gMain.state += 1; + break; + case 7: + sub_80937D8(); + gMain.state += 1; + break; + case 8: + nullsub_15(); + sub_8093800(); + sub_8093550(); + SetMainCallback2(sub_809323C); + break; } } -static void sub_809323C(void) { +static void sub_809323C(void) +{ RunTasks(); AnimateSprites(); BuildOamBuffer(); @@ -228,53 +226,61 @@ static void sub_8093254(void) LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); - unk_2000000.var_6++; - if (unk_2000000.var_6 >= 60) + ewram0.var_6++; + if (ewram0.var_6 >= 60) { - unk_2000000.var_6 = 0; - unk_2000000.var_5 ^= 1; + ewram0.var_6 = 0; + ewram0.var_5 ^= 1; } - if (unk_2000000.var_4) - DmaCopy16(3, gUnknown_03004DE0, gUnknown_03004DE0 + 0x780, 320); + if (ewram0.var_4) + DmaCopy16(3, gUnknown_03004DE0.filler0, gUnknown_03004DE0.unk780, sizeof(gUnknown_03004DE0.unk780)); } -static void sub_80932AC(Callback callBack) { +static void sub_80932AC(Callback callBack) +{ u8 taskId = CreateTask(nullsub_60, 0xFF); struct Task *task = &gTasks[taskId]; task->data[TD_0] = FALSE; - StoreWordInTwoHalfwords(&task->data[TD_CALLBACK], (u32) callBack); + StoreWordInTwoHalfwords(&task->data[TD_CALLBACK], (u32)callBack); } -static void sub_80932E4(u8 arg1, Callback callBack) { +static void sub_80932E4(u8 arg1, Callback callBack) +{ u8 taskId = CreateTask(nullsub_60, 0xFF); struct Task *task = &gTasks[taskId]; task->data[TD_0] = TRUE; task->data[TD_1] = arg1; - StoreWordInTwoHalfwords(&task->data[TD_CALLBACK], (u32) callBack); + StoreWordInTwoHalfwords(&task->data[TD_CALLBACK], (u32)callBack); } -void sub_8093324(void) { +void sub_8093324(void) +{ u8 taskId = FindTaskIdByFunc(nullsub_60); struct Task *task = &gTasks[taskId]; - unk_2000000.var_1 = task->data[TD_0]; + ewram0.var_1 = task->data[TD_0]; - LoadWordFromTwoHalfwords((u16 *) &task->data[TD_CALLBACK], (u32 *) &unk_2000000.var_60); + LoadWordFromTwoHalfwords((u16 *)&task->data[TD_CALLBACK], (u32 *)&ewram0.var_60); - if (unk_2000000.var_1) { - struct TrainerCard (*trainerCards)[4] = &gTrainerCards; + if (ewram0.var_1) + { + struct TrainerCard(*trainerCards)[4] = &gTrainerCards; s16 var = task->data[TD_1]; struct TrainerCard *dest = &(*trainerCards)[var]; - memcpy(&unk_2000000.var_64, dest, sizeof(struct TrainerCard)); - } else { - sub_8093390(&unk_2000000.var_64); + memcpy(&ewram0.var_64, dest, sizeof(struct TrainerCard)); + } + else + { + sub_8093390(&ewram0.var_64); } } -static void nullsub_60(u8 taskid) { +static void nullsub_60(u8 taskid) +{ } -void sub_8093390(struct TrainerCard *arg1) { +void sub_8093390(struct TrainerCard *arg1) +{ u32 playTime; bool32 enteredHallOfFame; bool8 r4; @@ -284,9 +290,10 @@ void sub_8093390(struct TrainerCard *arg1) { arg1->playTimeHours = gSaveBlock2.playTimeHours; arg1->playTimeMinutes = gSaveBlock2.playTimeMinutes; - playTime = sub_8053108(GAME_STAT_FIRST_HOF_PLAY_TIME); - enteredHallOfFame = sub_8053108(GAME_STAT_ENTERED_HOF); - if (!enteredHallOfFame) { + playTime = GetGameStat(GAME_STAT_FIRST_HOF_PLAY_TIME); + enteredHallOfFame = GetGameStat(GAME_STAT_ENTERED_HOF); + if (!enteredHallOfFame) + { playTime = 0; } arg1->firstHallOfFameA = playTime >> 16; @@ -315,594 +322,401 @@ void sub_8093390(struct TrainerCard *arg1) { // Battle tower? arg1->battleTowerWins = gSaveBlock2.filler_A8.var_4C8; arg1->battleTowerLosses = gSaveBlock2.filler_A8.var_4CA; - if (arg1->battleTowerWins > 9999) { + if (arg1->battleTowerWins > 9999) + { arg1->battleTowerWins = 9999; } - if (arg1->battleTowerLosses > 9999) { + if (arg1->battleTowerLosses > 9999) + { arg1->battleTowerLosses = 9999; } r4 = FALSE; - if (sub_80C4D50() > 4) { + if (sub_80C4D50() > 4) + { r4 = TRUE; } arg1->var_4 = r4; arg1->money = gSaveBlock1.money; - for (i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) + { arg1->var_28[i] = gSaveBlock1.unk2B1C[i]; } - for (i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) + { arg1->playerName[i] = gSaveBlock2.playerName[i]; } arg1->stars = sub_80934F4(arg1); } -u8 sub_80934C4(u8 id) { +u8 sub_80934C4(u8 id) +{ return gTrainerCards[id].stars; -} +} -static u32 sav12_xor_get_clamped_above(u8 index, u32 maxVal) { - u32 value = sub_8053108(index); +static u32 sav12_xor_get_clamped_above(u8 index, u32 maxVal) +{ + u32 value = GetGameStat(index); - if (value > maxVal) { + if (value > maxVal) + { value = maxVal; } return value; } -static u8 sub_80934F4(struct TrainerCard *trainerCard) { +static u8 sub_80934F4(struct TrainerCard *trainerCard) +{ u8 value = 0; - if (trainerCard->firstHallOfFameA != 0 || trainerCard->firstHallOfFameB != 0 || trainerCard->firstHallOfFameC != 0) { + if (trainerCard->firstHallOfFameA != 0 || trainerCard->firstHallOfFameB != 0 || trainerCard->firstHallOfFameC != 0) + { value += 1; } - if (trainerCard->var_3) { + if (trainerCard->var_3) + { value += 1; } - if (trainerCard->battleTowerLosses > 49) { + if (trainerCard->battleTowerLosses > 49) + { value += 1; } - if (trainerCard->var_4) { + if (trainerCard->var_4) + { value += 1; } return value; } -static void sub_8093534(void) { +static void sub_8093534(void) +{ SetVBlankCallback(NULL); SetHBlankCallback(NULL); REG_DISPCNT = 0; } -static void sub_8093550(void) { +static void sub_8093550(void) +{ u16 backup; SetVBlankCallback(sub_8093254); backup = REG_IME; REG_IME = 0; - REG_IE |= INTR_FLAG_VBLANK| INTR_FLAG_HBLANK; + REG_IE |= INTR_FLAG_VBLANK | INTR_FLAG_HBLANK; REG_IME = backup; REG_DISPSTAT |= DISPSTAT_VBLANK_INTR | DISPSTAT_HBLANK_INTR; - REG_DISPCNT = 0x1f40; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON; } -__attribute__((naked)) -void sub_8093598() { - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - sub sp, 0x4\n\ - movs r2, 0xC0\n\ - lsls r2, 19\n\ - movs r3, 0x80\n\ - lsls r3, 9\n\ - mov r4, sp\n\ - movs r6, 0\n\ - ldr r1, _080935E4 @ =0x040000d4\n\ - movs r5, 0x80\n\ - lsls r5, 5\n\ - ldr r7, _080935E8 @ =0x81000800\n\ - movs r0, 0x81\n\ - lsls r0, 24\n\ - mov r12, r0\n\ -_080935B6:\n\ - strh r6, [r4]\n\ - mov r0, sp\n\ - str r0, [r1]\n\ - str r2, [r1, 0x4]\n\ - str r7, [r1, 0x8]\n\ - ldr r0, [r1, 0x8]\n\ - adds r2, r5\n\ - subs r3, r5\n\ - cmp r3, r5\n\ - bhi _080935B6\n\ - strh r6, [r4]\n\ - mov r0, sp\n\ - str r0, [r1]\n\ - str r2, [r1, 0x4]\n\ - lsrs r0, r3, 1\n\ - mov r2, r12\n\ - orrs r0, r2\n\ - str r0, [r1, 0x8]\n\ - ldr r0, [r1, 0x8]\n\ - add sp, 0x4\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_080935E4: .4byte 0x040000d4\n\ -_080935E8: .4byte 0x81000800\n\ - .syntax divided\n"); -} +void sub_8093598(void) +{ + u8 *addr = (void *)VRAM; + u32 size = 0x10000; -__attribute__((naked)) -void sub_80935EC() { - asm(".syntax unified\n\ - sub sp, 0x4\n\ - movs r2, 0xE0\n\ - lsls r2, 19\n\ - mov r1, sp\n\ - movs r0, 0\n\ - strh r0, [r1]\n\ - ldr r0, _08093608 @ =0x040000d4\n\ - str r1, [r0]\n\ - str r2, [r0, 0x4]\n\ - ldr r1, _0809360C @ =0x81000200\n\ - str r1, [r0, 0x8]\n\ - ldr r0, [r0, 0x8]\n\ - add sp, 0x4\n\ - bx lr\n\ - .align 2, 0\n\ -_08093608: .4byte 0x040000d4\n\ -_0809360C: .4byte 0x81000200\n\ - .syntax divided\n"); + while (1) + { + DmaFill16(3, 0, addr, 0x1000); + addr += 0x1000; + size -= 0x1000; + if (size <= 0x1000) + { + DmaFill16(3, 0, addr, size); + break; + } + } } -__attribute__((naked)) -void sub_8093610() { - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - ldr r5, _08093664 @ =REG_BG0CNT\n\ - movs r1, 0\n\ - strh r1, [r5]\n\ - ldr r2, _08093668 @ =REG_BG1CNT\n\ - strh r1, [r2]\n\ - ldr r3, _0809366C @ =REG_BG2CNT\n\ - strh r1, [r3]\n\ - ldr r4, _08093670 @ =REG_BG3CNT\n\ - strh r1, [r4]\n\ - ldr r0, _08093674 @ =REG_BG0HOFS\n\ - strh r1, [r0]\n\ - adds r0, 0x2\n\ - strh r1, [r0]\n\ - adds r0, 0x2\n\ - strh r1, [r0]\n\ - adds r0, 0x2\n\ - strh r1, [r0]\n\ - adds r0, 0x2\n\ - strh r1, [r0]\n\ - adds r0, 0x2\n\ - strh r1, [r0]\n\ - adds r0, 0x2\n\ - strh r1, [r0]\n\ - adds r0, 0x2\n\ - strh r1, [r0]\n\ - ldr r1, _08093678 @ =0x00001e08\n\ - adds r0, r1, 0\n\ - strh r0, [r5]\n\ - ldr r1, _0809367C @ =0x00000801\n\ - adds r0, r1, 0\n\ - strh r0, [r2]\n\ - ldr r1, _08093680 @ =0x00000902\n\ - adds r0, r1, 0\n\ - strh r0, [r3]\n\ - ldr r1, _08093684 @ =0x00000a03\n\ - adds r0, r1, 0\n\ - strh r0, [r4]\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_08093664: .4byte 0x4000008 @ REG_BG0CNT\n\ -_08093668: .4byte 0x400000A @ REG_BG1CNT\n\ -_0809366C: .4byte 0x400000C @ REG_BG2CNT\n\ -_08093670: .4byte 0x400000E @ REG_BG3CNT\n\ -_08093674: .4byte 0x4000010 @ REG_BG0HOFS\n\ -_08093678: .4byte 0x00001e08\n\ -_0809367C: .4byte 0x00000801\n\ -_08093680: .4byte 0x00000902\n\ -_08093684: .4byte 0x00000a03\n\ - .syntax divided\n"); +void sub_80935EC(void) +{ + void *addr = (void *)OAM; + + DmaFill16(3, 0, addr, 0x400); } -#ifdef NONMATCHING -static void sub_8093688(void) { - int i; +void sub_8093610(void) +{ + REG_BG0CNT = 0; + REG_BG1CNT = 0; + REG_BG2CNT = 0; + REG_BG3CNT = 0; + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG2HOFS = 0; + REG_BG2VOFS = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; + + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(30) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(8) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(9) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(10) | BGCNT_16COLOR | BGCNT_TXT256x256; +} + +static void sub_8093688(void) +{ + u8 i; - asm_comment("WIP"); sub_8093324(); - unk_2000000.var_0 = FALSE; - unk_2000000.var_3 = FALSE; - unk_2000000.var_4 = FALSE; + ewram0.var_0 = FALSE; + ewram0.var_3 = FALSE; + ewram0.var_4 = FALSE; - unk_2000000.var_2 = unk_2000000.var_64.stars; + ewram0.var_2 = ewram0.var_64.stars; - unk_2000000.var_5 = FALSE; - unk_2000000.var_6 = FALSE; + ewram0.var_5 = FALSE; + ewram0.var_6 = FALSE; - for (i = 0; i < 4; i++) { - sub_80EB3FC(unk_2000000.var_20[i], unk_2000000.var_64.var_28[i]); + for (i = 0; i < 4; i++) + { + sub_80EB3FC(ewram0.var_20[i], ewram0.var_64.var_28[i]); } sub_80936D4(); } -#else -__attribute__((naked)) -static void sub_8093688(void) { - asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - bl sub_8093324\n\ - ldr r2, _080936D0 @ =0x02000000\n\ - movs r1, 0\n\ - strb r1, [r2]\n\ - strb r1, [r2, 0x3]\n\ - strb r1, [r2, 0x4]\n\ - adds r0, r2, 0\n\ - adds r0, 0x65\n\ - ldrb r0, [r0]\n\ - strb r0, [r2, 0x2]\n\ - strb r1, [r2, 0x5]\n\ - strb r1, [r2, 0x6]\n\ - movs r4, 0\n\ - adds r6, r2, 0\n\ - adds r6, 0x20\n\ - adds r5, r2, 0\n\ - adds r5, 0x8C\n\ -_080936AE:\n\ - lsls r0, r4, 4\n\ - adds r0, r6\n\ - lsls r1, r4, 1\n\ - adds r1, r5, r1\n\ - ldrh r1, [r1]\n\ - bl sub_80EB3FC\n\ - adds r0, r4, 0x1\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - cmp r4, 0x3\n\ - bls _080936AE\n\ - bl sub_80936D4\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_080936D0: .4byte 0x02000000\n\ - .syntax divided\n"); -} - -#endif - -void sub_80936D4(void) { - unk_2000000.var_7 = FALSE; - unk_2000000.var_8 = FALSE; - unk_2000000.var_9 = FALSE; - unk_2000000.var_a = FALSE; - unk_2000000.var_b = FALSE; - unk_2000000.var_c = FALSE; - unk_2000000.var_d = FALSE; +void sub_80936D4(void) +{ + ewram0.var_7 = 0; + ewram0.var_8 = 0; + ewram0.var_9 = 0; + ewram0.var_a = 0; + ewram0.var_b = 0; + ewram0.var_c = 0; + ewram0.var_d = 0; - memset(unk_2000000.var_e, 0, sizeof(unk_2000000.var_e)); + memset(ewram0.var_e, 0, sizeof(ewram0.var_e)); - if (unk_2000000.var_64.hasPokedex) { - unk_2000000.var_7 += TRUE; + if (ewram0.var_64.hasPokedex) + { + ewram0.var_7 += 1; } - if (unk_2000000.var_64.firstHallOfFameA != 0 || unk_2000000.var_64.firstHallOfFameB != 0 || - unk_2000000.var_64.firstHallOfFameC != 0) { - unk_2000000.var_8 += TRUE; + if (ewram0.var_64.firstHallOfFameA != 0 || ewram0.var_64.firstHallOfFameB != 0 || + ewram0.var_64.firstHallOfFameC != 0) + { + ewram0.var_8 += 1; } - if (unk_2000000.var_64.linkBattleWins != 0 || unk_2000000.var_64.linkBattleLosses != 0) { - unk_2000000.var_9 += TRUE; + if (ewram0.var_64.linkBattleWins != 0 || ewram0.var_64.linkBattleLosses != 0) + { + ewram0.var_9 += 1; } - if (unk_2000000.var_64.battleTowerWins != 0 || unk_2000000.var_64.battleTowerLosses != 0) { - unk_2000000.var_a += TRUE; + if (ewram0.var_64.battleTowerWins != 0 || ewram0.var_64.battleTowerLosses != 0) + { + ewram0.var_a += 1; } - if (unk_2000000.var_64.contestsWithFriends != 0) { - unk_2000000.var_b += TRUE; + if (ewram0.var_64.contestsWithFriends != 0) + { + ewram0.var_b += 1; } - if (unk_2000000.var_64.pokeblocksWithFriends != 0) { - unk_2000000.var_c += TRUE; + if (ewram0.var_64.pokeblocksWithFriends != 0) + { + ewram0.var_c += 1; } - if (unk_2000000.var_64.pokemonTrades != 0) { - unk_2000000.var_d += TRUE; + if (ewram0.var_64.pokemonTrades != 0) + { + ewram0.var_d += 1; } - if (!unk_2000000.var_1) { + if (!ewram0.var_1) + { u32 badgeFlag; int i; i = 0; badgeFlag = BADGE01_GET; - while (TRUE) { - if (FlagGet(badgeFlag)) { - unk_2000000.var_e[i] += TRUE; + while (1) + { + if (FlagGet(badgeFlag)) + { + ewram0.var_e[i] += 1; } badgeFlag += 1; i += 1; - if (badgeFlag > BADGE08_GET) { + if (badgeFlag > BADGE08_GET) + { break; } } } } -void sub_80937A4() { +void sub_80937A4() +{ ResetPaletteFade(); ResetSpriteData(); FreeAllSpritePalettes(); ResetTasks(); } -void sub_80937BC() { +void sub_80937BC() +{ SetUpWindowConfig(&WindowConfig_TrainerCard_Back_Values); MultistepInitMenuWindowBegin(&WindowConfig_TrainerCard_Back_Values); } -static void sub_80937D8() { +static void sub_80937D8() +{ sub_8093E04(); sub_8093E28(); sub_8093F64(); sub_8093DAC(); } -static void sub_80937F0() { +static void sub_80937F0() +{ sub_8093EF8(); } -static void nullsub_15(void) { +static void nullsub_15(void) +{ } -static void sub_8093800() { +static void sub_8093800() +{ sub_809380C(); } -static void sub_809380C() { +static void sub_809380C() +{ u8 taskId; taskId = CreateTask(sub_809382C, 0); sub_809382C(taskId); } -__attribute__((naked)) -static void sub_809382C(u8 taskId) { - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - ldr r7, _08093858 @ =gUnknown_083B5EBC\n\ - lsls r1, r0, 2\n\ - adds r1, r0\n\ - lsls r4, r1, 3\n\ - ldr r6, _0809385C @ =0x02000000\n\ - ldr r5, _08093860 @ =gTasks\n\ -_0809383E:\n\ - ldrb r0, [r6]\n\ - lsls r0, 2\n\ - adds r0, r7\n\ - ldr r1, [r0]\n\ - adds r0, r4, r5\n\ - bl _call_via_r1\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - bne _0809383E\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_08093858: .4byte gUnknown_083B5EBC\n\ -_0809385C: .4byte 0x02000000\n\ -_08093860: .4byte gTasks\n\ - .syntax divided\n"); +static void sub_809382C(u8 taskId) +{ + while (gUnknown_083B5EBC[ewram0.var_0](&gTasks[taskId]) != 0) + ; } -__attribute__((naked)) -bool8 sub_8093864() { - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - sub sp, 0x4\n\ - ldr r4, _080938A0 @ =0x02000000\n\ - ldr r2, _080938A4 @ =gSaveBlock2\n\ - ldrb r1, [r2, 0x11]\n\ - movs r0, 0x1\n\ - ands r0, r1\n\ - movs r5, 0\n\ - strb r0, [r4, 0x5]\n\ - ldrb r0, [r2, 0x12]\n\ - strb r0, [r4, 0x6]\n\ - bl sub_80939A4\n\ - movs r0, 0x1\n\ - negs r0, r0\n\ - str r5, [sp]\n\ - movs r1, 0\n\ - movs r2, 0x10\n\ - movs r3, 0\n\ - bl BeginNormalPaletteFade\n\ - ldrb r0, [r4]\n\ - adds r0, 0x1\n\ - strb r0, [r4]\n\ - movs r0, 0\n\ - add sp, 0x4\n\ - pop {r4,r5}\n\ - pop {r1}\n\ - bx r1\n\ - .align 2, 0\n\ -_080938A0: .4byte 0x02000000\n\ -_080938A4: .4byte gSaveBlock2\n\ - .syntax divided\n"); +bool8 sub_8093864(struct Task *task) +{ + ewram0.var_5 = gSaveBlock2.playTimeSeconds & 1; + ewram0.var_6 = gSaveBlock2.playTimeVBlanks; + sub_80939A4(); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + ewram0.var_0 += 1; + return FALSE; } -__attribute__((naked)) -bool8 sub_80938A8() { - asm(".syntax unified\n\ - push {lr}\n\ - ldr r0, _080938C4 @ =gPaletteFade\n\ - ldrb r1, [r0, 0x7]\n\ - movs r0, 0x80\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - bne _080938BE\n\ - ldr r1, _080938C8 @ =0x02000000\n\ - ldrb r0, [r1]\n\ - adds r0, 0x1\n\ - strb r0, [r1]\n\ -_080938BE:\n\ - movs r0, 0\n\ - pop {r1}\n\ - bx r1\n\ - .align 2, 0\n\ -_080938C4: .4byte gPaletteFade\n\ -_080938C8: .4byte 0x02000000\n\ - .syntax divided\n"); +bool8 sub_80938A8(struct Task *task) +{ + if (!gPaletteFade.active) + ewram0.var_0 += 1; + return FALSE; } -__attribute__((naked)) -bool8 sub_80938CC() { - asm(".syntax unified\n\ - push {lr}\n\ - ldr r0, _080938E4 @ =gMain\n\ - ldrh r1, [r0, 0x2E]\n\ - movs r0, 0x2\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080938EC\n\ - ldr r1, _080938E8 @ =0x02000000\n\ - movs r0, 0x5\n\ - strb r0, [r1]\n\ - movs r0, 0x1\n\ - b _08093914\n\ - .align 2, 0\n\ -_080938E4: .4byte gMain\n\ -_080938E8: .4byte 0x02000000\n\ -_080938EC:\n\ - movs r0, 0x1\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _08093912\n\ - ldr r2, _08093900 @ =0x02000000\n\ - ldrb r1, [r2, 0x3]\n\ - cmp r1, 0\n\ - beq _08093904\n\ - movs r0, 0x5\n\ - b _0809390C\n\ - .align 2, 0\n\ -_08093900: .4byte 0x02000000\n\ -_08093904:\n\ - movs r0, 0x1\n\ - eors r0, r1\n\ - strb r0, [r2, 0x3]\n\ - movs r0, 0x3\n\ -_0809390C:\n\ - strb r0, [r2]\n\ - movs r0, 0x1\n\ - b _08093914\n\ -_08093912:\n\ - movs r0, 0\n\ -_08093914:\n\ - pop {r1}\n\ - bx r1\n\ - .syntax divided\n"); +bool8 sub_80938CC(struct Task *task) +{ + if (gMain.newKeys & B_BUTTON) + { + ewram0.var_0 = 5; + return TRUE; + } + else if (gMain.newKeys & A_BUTTON) + { + if (ewram0.var_3 != 0) + { + ewram0.var_0 = 5; + return TRUE; + } + else + { + ewram0.var_3 ^= 1; + ewram0.var_0 = 3; + return TRUE; + } + } + + return FALSE; } -bool8 sub_8093918() { +bool8 sub_8093918(struct Task *task) +{ sub_8093A28(); PlaySE(SE_CARD); - unk_2000000.var_0 += TRUE; + ewram0.var_0 += 1; return FALSE; } -bool8 sub_8093938() { - if (sub_8093A48()) { - unk_2000000.var_0 = 2; +bool8 sub_8093938(struct Task *task) +{ + if (sub_8093A48()) + { + ewram0.var_0 = 2; } return FALSE; } -__attribute__((naked)) -bool8 sub_8093954() { - asm(".syntax unified\n\ - push {lr}\n\ - sub sp, 0x4\n\ - bl sub_80939C0\n\ - movs r0, 0x1\n\ - negs r0, r0\n\ - movs r1, 0\n\ - str r1, [sp]\n\ - movs r2, 0\n\ - movs r3, 0x10\n\ - bl BeginNormalPaletteFade\n\ - ldr r1, _0809397C @ =0x02000000\n\ - ldrb r0, [r1]\n\ - adds r0, 0x1\n\ - strb r0, [r1]\n\ - movs r0, 0\n\ - add sp, 0x4\n\ - pop {r1}\n\ - bx r1\n\ - .align 2, 0\n\ -_0809397C: .4byte 0x02000000\n\ - .syntax divided\n"); +bool8 sub_8093954(struct Task *task) +{ + sub_80939C0(); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + ewram0.var_0 += 1; + return FALSE; } -bool8 sub_8093980() { - if (!gPaletteFade.active) { - SetMainCallback2((MainCallback) unk_2000000.var_60); +bool8 sub_8093980(struct Task *task) +{ + if (!gPaletteFade.active) + { + SetMainCallback2((MainCallback)ewram0.var_60); } return FALSE; } -static void sub_80939A4(void) { +static void sub_80939A4(void) +{ CreateTask(sub_80939DC, 0); BasicInitMenuWindow(&WindowConfig_TrainerCard_Back_Values); } -static void sub_80939C0(void) { +static void sub_80939C0(void) +{ u8 taskId; taskId = FindTaskIdByFunc(sub_80939DC); - if (taskId != 0xFF) { + if (taskId != 0xFF) + { DestroyTask(taskId); } } -static void sub_80939DC(u8 taskId) { +static void sub_80939DC(u8 taskId) +{ u8 buffer[32]; struct Task *task; task = &gTasks[taskId]; - if (unk_2000000.var_5 != task->data[TD_1]) { - task->data[TD_1] = unk_2000000.var_5; + if (ewram0.var_5 != task->data[TD_1]) + { + task->data[TD_1] = ewram0.var_5; task->data[TD_0] ^= TRUE; } @@ -910,252 +724,187 @@ static void sub_80939DC(u8 taskId) { MenuPrint(buffer, 10, 12); } -static void sub_8093A28(void) { +static void sub_8093A28(void) +{ u8 taskId; taskId = CreateTask(sub_8093A68, 0); sub_8093A68(taskId); } -__attribute__((naked)) -static u8 sub_8093A48() { - asm(".syntax unified\n\ - push {lr}\n\ - ldr r0, _08093A5C @ =sub_8093A68\n\ - bl FindTaskIdByFunc\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0xFF\n\ - beq _08093A60\n\ - movs r0, 0\n\ - b _08093A62\n\ - .align 2, 0\n\ -_08093A5C: .4byte sub_8093A68\n\ -_08093A60:\n\ - movs r0, 0x1\n\ -_08093A62:\n\ - pop {r1}\n\ - bx r1\n\ - .syntax divided\n"); +static u8 sub_8093A48(void) +{ + if (FindTaskIdByFunc(sub_8093A68) == 0xFF) + return TRUE; + else + return FALSE; } -__attribute__((naked)) -static void sub_8093A68(u8 taskId) { - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - ldr r5, _08093A98 @ =gUnknown_083B5ED8\n\ - ldr r2, _08093A9C @ =gTasks\n\ - lsls r1, r0, 2\n\ - adds r1, r0\n\ - lsls r1, 3\n\ - adds r4, r1, r2\n\ -_08093A7A:\n\ - movs r1, 0x8\n\ - ldrsh r0, [r4, r1]\n\ - lsls r0, 2\n\ - adds r0, r5\n\ - ldr r1, [r0]\n\ - adds r0, r4, 0\n\ - bl _call_via_r1\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - bne _08093A7A\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_08093A98: .4byte gUnknown_083B5ED8\n\ -_08093A9C: .4byte gTasks\n\ - .syntax divided\n"); +static void sub_8093A68(u8 taskId) +{ + while (gUnknown_083B5ED8[gTasks[taskId].data[0]](&gTasks[taskId]) != 0) + ; } -__attribute__((naked)) -bool8 sub_8093AA0() { - asm(".syntax unified\n\ - push {r4,lr}\n\ - adds r4, r0, 0\n\ - ldr r0, _08093AE0 @ =0x02000000\n\ - movs r1, 0\n\ - strb r1, [r0, 0x4]\n\ - bl dp12_8087EA4\n\ - movs r1, 0\n\ - ldr r0, _08093AE4 @ =gUnknown_03004DE0\n\ - ldr r2, _08093AE8 @ =0x0000fffc\n\ - movs r3, 0xF0\n\ - lsls r3, 3\n\ - adds r0, r3\n\ -_08093ABA:\n\ - strh r2, [r0]\n\ - adds r0, 0x2\n\ - adds r1, 0x1\n\ - cmp r1, 0x9F\n\ - bls _08093ABA\n\ - ldr r0, _08093AEC @ =sub_8093D7C\n\ - bl SetHBlankCallback\n\ - ldr r1, _08093AE0 @ =0x02000000\n\ - movs r0, 0x1\n\ - strb r0, [r1, 0x4]\n\ - ldrh r0, [r4, 0x8]\n\ - adds r0, 0x1\n\ - strh r0, [r4, 0x8]\n\ - movs r0, 0\n\ - pop {r4}\n\ - pop {r1}\n\ - bx r1\n\ - .align 2, 0\n\ -_08093AE0: .4byte 0x02000000\n\ -_08093AE4: .4byte gUnknown_03004DE0\n\ -_08093AE8: .4byte 0x0000fffc\n\ -_08093AEC: .4byte sub_8093D7C\n\ - .syntax divided\n"); +bool8 sub_8093AA0(struct Task *task) +{ + s32 i; + + ewram0.var_4 = 0; + dp12_8087EA4(); + for (i = 0; i < ARRAY_COUNT(gUnknown_03004DE0.unk780); i++) + gUnknown_03004DE0.unk780[i] = -4; + SetHBlankCallback(sub_8093D7C); + ewram0.var_4 = 1; + task->data[0]++; + return FALSE; } __attribute__((naked)) -bool8 sub_8093AF0() { +bool8 sub_8093AF0() +{ 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, 0x4\n\ - mov r8, r0\n\ - ldr r1, _08093BFC @ =0x02000000\n\ - movs r0, 0\n\ - strb r0, [r1, 0x4]\n\ - mov r2, r8\n\ - ldrh r0, [r2, 0xA]\n\ - adds r0, 0x3\n\ - strh r0, [r2, 0xA]\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x4F\n\ - ble _08093B18\n\ - movs r0, 0x4F\n\ - strh r0, [r2, 0xA]\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x4\n\ + mov r8, r0\n\ + ldr r1, _08093BFC @ =0x02000000\n\ + movs r0, 0\n\ + strb r0, [r1, 0x4]\n\ + mov r2, r8\n\ + ldrh r0, [r2, 0xA]\n\ + adds r0, 0x3\n\ + strh r0, [r2, 0xA]\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + cmp r0, 0x4F\n\ + ble _08093B18\n\ + movs r0, 0x4F\n\ + strh r0, [r2, 0xA]\n\ _08093B18:\n\ - mov r4, r8\n\ - movs r0, 0xA\n\ - ldrsh r7, [r4, r0]\n\ - movs r0, 0xA0\n\ - subs r0, r7\n\ - mov r9, r0\n\ - subs r4, r0, r7\n\ - negs r0, r7\n\ - lsls r6, r0, 16\n\ - movs r0, 0xA0\n\ - lsls r0, 16\n\ - adds r1, r4, 0\n\ - bl __udivsi3\n\ - adds r5, r0, 0\n\ - ldr r1, _08093C00 @ =0xffff0000\n\ - adds r5, r1\n\ - adds r0, r5, 0\n\ - muls r0, r4\n\ - adds r0, r6\n\ - mov r10, r0\n\ - adds r0, r5, 0\n\ - adds r1, r4, 0\n\ - bl __udivsi3\n\ - str r0, [sp]\n\ - lsls r5, 1\n\ - movs r3, 0\n\ - cmp r3, r7\n\ - bcs _08093B74\n\ - ldr r2, _08093C04 @ =gUnknown_03004DE0\n\ - mov r12, r2\n\ - ldr r0, _08093C08 @ =0x0000fffc\n\ - adds r4, r0, 0\n\ + mov r4, r8\n\ + movs r0, 0xA\n\ + ldrsh r7, [r4, r0]\n\ + movs r0, 0xA0\n\ + subs r0, r7\n\ + mov r9, r0\n\ + subs r4, r0, r7\n\ + negs r0, r7\n\ + lsls r6, r0, 16\n\ + movs r0, 0xA0\n\ + lsls r0, 16\n\ + adds r1, r4, 0\n\ + bl __udivsi3\n\ + adds r5, r0, 0\n\ + ldr r1, _08093C00 @ =0xffff0000\n\ + adds r5, r1\n\ + adds r0, r5, 0\n\ + muls r0, r4\n\ + adds r0, r6\n\ + mov r10, r0\n\ + adds r0, r5, 0\n\ + adds r1, r4, 0\n\ + bl __udivsi3\n\ + str r0, [sp]\n\ + lsls r5, 1\n\ + movs r3, 0\n\ + cmp r3, r7\n\ + bcs _08093B74\n\ + ldr r2, _08093C04 @ =gUnknown_03004DE0\n\ + mov r12, r2\n\ + ldr r0, _08093C08 @ =0x0000fffc\n\ + adds r4, r0, 0\n\ _08093B5C:\n\ - lsls r0, r3, 16\n\ - asrs r0, 16\n\ - lsls r1, r0, 1\n\ - add r1, r12\n\ - subs r2, r4, r0\n\ - strh r2, [r1]\n\ - adds r0, 0x1\n\ - lsls r0, 16\n\ - lsrs r3, r0, 16\n\ - asrs r0, 16\n\ - cmp r0, r7\n\ - bcc _08093B5C\n\ + lsls r0, r3, 16\n\ + asrs r0, 16\n\ + lsls r1, r0, 1\n\ + add r1, r12\n\ + subs r2, r4, r0\n\ + strh r2, [r1]\n\ + adds r0, 0x1\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + asrs r0, 16\n\ + cmp r0, r7\n\ + bcc _08093B5C\n\ _08093B74:\n\ - lsls r2, r3, 16\n\ - mov r1, r9\n\ - lsls r0, r1, 16\n\ - asrs r1, r0, 16\n\ - mov r4, r10\n\ - lsrs r7, r4, 16\n\ - cmp r2, r0\n\ - bge _08093BAE\n\ - ldr r0, _08093C04 @ =gUnknown_03004DE0\n\ - mov r9, r0\n\ - ldr r4, _08093C08 @ =0x0000fffc\n\ - mov r12, r4\n\ - adds r4, r1, 0\n\ + lsls r2, r3, 16\n\ + mov r1, r9\n\ + lsls r0, r1, 16\n\ + asrs r1, r0, 16\n\ + mov r4, r10\n\ + lsrs r7, r4, 16\n\ + cmp r2, r0\n\ + bge _08093BAE\n\ + ldr r0, _08093C04 @ =gUnknown_03004DE0\n\ + mov r9, r0\n\ + ldr r4, _08093C08 @ =0x0000fffc\n\ + mov r12, r4\n\ + adds r4, r1, 0\n\ _08093B8E:\n\ - lsrs r1, r6, 16\n\ - adds r6, r5\n\ - ldr r0, [sp]\n\ - subs r5, r0\n\ - asrs r2, 16\n\ - lsls r0, r2, 1\n\ - add r0, r9\n\ - add r1, r12\n\ - strh r1, [r0]\n\ - adds r2, 0x1\n\ - lsls r2, 16\n\ - lsrs r3, r2, 16\n\ - lsls r2, r3, 16\n\ - asrs r0, r2, 16\n\ - cmp r0, r4\n\ - blt _08093B8E\n\ + lsrs r1, r6, 16\n\ + adds r6, r5\n\ + ldr r0, [sp]\n\ + subs r5, r0\n\ + asrs r2, 16\n\ + lsls r0, r2, 1\n\ + add r0, r9\n\ + add r1, r12\n\ + strh r1, [r0]\n\ + adds r2, 0x1\n\ + lsls r2, 16\n\ + lsrs r3, r2, 16\n\ + lsls r2, r3, 16\n\ + asrs r0, r2, 16\n\ + cmp r0, r4\n\ + blt _08093B8E\n\ _08093BAE:\n\ - adds r1, r7, 0\n\ - lsls r0, r3, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x9F\n\ - bgt _08093BD4\n\ - ldr r4, _08093C04 @ =gUnknown_03004DE0\n\ - ldr r0, _08093C08 @ =0x0000fffc\n\ - adds r2, r1, r0\n\ + adds r1, r7, 0\n\ + lsls r0, r3, 16\n\ + asrs r0, 16\n\ + cmp r0, 0x9F\n\ + bgt _08093BD4\n\ + ldr r4, _08093C04 @ =gUnknown_03004DE0\n\ + ldr r0, _08093C08 @ =0x0000fffc\n\ + adds r2, r1, r0\n\ _08093BBE:\n\ - lsls r1, r3, 16\n\ - asrs r1, 16\n\ - lsls r0, r1, 1\n\ - adds r0, r4\n\ - strh r2, [r0]\n\ - adds r1, 0x1\n\ - lsls r1, 16\n\ - lsrs r3, r1, 16\n\ - asrs r1, 16\n\ - cmp r1, 0x9F\n\ - ble _08093BBE\n\ + lsls r1, r3, 16\n\ + asrs r1, 16\n\ + lsls r0, r1, 1\n\ + adds r0, r4\n\ + strh r2, [r0]\n\ + adds r1, 0x1\n\ + lsls r1, 16\n\ + lsrs r3, r1, 16\n\ + asrs r1, 16\n\ + cmp r1, 0x9F\n\ + ble _08093BBE\n\ _08093BD4:\n\ - movs r0, 0x1\n\ - ldr r1, _08093BFC @ =0x02000000\n\ - strb r0, [r1, 0x4]\n\ - mov r2, r8\n\ - movs r4, 0xA\n\ - ldrsh r0, [r2, r4]\n\ - cmp r0, 0x4A\n\ - ble _08093BEA\n\ - ldrh r0, [r2, 0x8]\n\ - adds r0, 0x1\n\ - strh r0, [r2, 0x8]\n\ + movs r0, 0x1\n\ + ldr r1, _08093BFC @ =0x02000000\n\ + strb r0, [r1, 0x4]\n\ + mov r2, r8\n\ + movs r4, 0xA\n\ + ldrsh r0, [r2, r4]\n\ + cmp r0, 0x4A\n\ + ble _08093BEA\n\ + ldrh r0, [r2, 0x8]\n\ + adds r0, 0x1\n\ + strh r0, [r2, 0x8]\n\ _08093BEA:\n\ - movs r0, 0\n\ - add sp, 0x4\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n\ - .align 2, 0\n\ + movs r0, 0\n\ + add sp, 0x4\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ _08093BFC: .4byte 0x02000000\n\ _08093C00: .4byte 0xffff0000\n\ _08093C04: .4byte gUnknown_03004DE0\n\ @@ -1163,11 +912,13 @@ _08093C08: .4byte 0x0000fffc\n\ .syntax divided\n"); } -bool8 sub_8093C0C(struct TrainerCard *trainerCard) { +bool8 sub_8093C0C(struct TrainerCard *trainerCard) +{ sub_80939C0(); sub_8093DAC(); - if (!unk_2000000.var_3) { + if (!ewram0.var_3) + { sub_80939A4(); } @@ -1177,147 +928,148 @@ bool8 sub_8093C0C(struct TrainerCard *trainerCard) { } __attribute__((naked)) -bool8 sub_8093C38() { +bool8 sub_8093C38() +{ 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, 0x4\n\ - mov r8, r0\n\ - ldr r1, _08093D40 @ =0x02000000\n\ - movs r2, 0\n\ - strb r2, [r1, 0x4]\n\ - ldrh r0, [r0, 0xA]\n\ - subs r0, 0x3\n\ - mov r3, r8\n\ - strh r0, [r3, 0xA]\n\ - lsls r0, 16\n\ - cmp r0, 0\n\ - bgt _08093C5C\n\ - strh r2, [r3, 0xA]\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x4\n\ + mov r8, r0\n\ + ldr r1, _08093D40 @ =0x02000000\n\ + movs r2, 0\n\ + strb r2, [r1, 0x4]\n\ + ldrh r0, [r0, 0xA]\n\ + subs r0, 0x3\n\ + mov r3, r8\n\ + strh r0, [r3, 0xA]\n\ + lsls r0, 16\n\ + cmp r0, 0\n\ + bgt _08093C5C\n\ + strh r2, [r3, 0xA]\n\ _08093C5C:\n\ - mov r4, r8\n\ - movs r0, 0xA\n\ - ldrsh r7, [r4, r0]\n\ - movs r0, 0xA0\n\ - subs r0, r7\n\ - mov r9, r0\n\ - subs r4, r0, r7\n\ - negs r0, r7\n\ - lsls r6, r0, 16\n\ - movs r0, 0xA0\n\ - lsls r0, 16\n\ - adds r1, r4, 0\n\ - bl __udivsi3\n\ - adds r5, r0, 0\n\ - ldr r1, _08093D44 @ =0xffff0000\n\ - adds r5, r1\n\ - adds r0, r5, 0\n\ - muls r0, r4\n\ - adds r0, r6\n\ - mov r10, r0\n\ - adds r0, r5, 0\n\ - adds r1, r4, 0\n\ - bl __udivsi3\n\ - str r0, [sp]\n\ - lsrs r5, 1\n\ - movs r3, 0\n\ - cmp r3, r7\n\ - bcs _08093CB8\n\ - ldr r2, _08093D48 @ =gUnknown_03004DE0\n\ - mov r12, r2\n\ - ldr r0, _08093D4C @ =0x0000fffc\n\ - adds r4, r0, 0\n\ + mov r4, r8\n\ + movs r0, 0xA\n\ + ldrsh r7, [r4, r0]\n\ + movs r0, 0xA0\n\ + subs r0, r7\n\ + mov r9, r0\n\ + subs r4, r0, r7\n\ + negs r0, r7\n\ + lsls r6, r0, 16\n\ + movs r0, 0xA0\n\ + lsls r0, 16\n\ + adds r1, r4, 0\n\ + bl __udivsi3\n\ + adds r5, r0, 0\n\ + ldr r1, _08093D44 @ =0xffff0000\n\ + adds r5, r1\n\ + adds r0, r5, 0\n\ + muls r0, r4\n\ + adds r0, r6\n\ + mov r10, r0\n\ + adds r0, r5, 0\n\ + adds r1, r4, 0\n\ + bl __udivsi3\n\ + str r0, [sp]\n\ + lsrs r5, 1\n\ + movs r3, 0\n\ + cmp r3, r7\n\ + bcs _08093CB8\n\ + ldr r2, _08093D48 @ =gUnknown_03004DE0\n\ + mov r12, r2\n\ + ldr r0, _08093D4C @ =0x0000fffc\n\ + adds r4, r0, 0\n\ _08093CA0:\n\ - lsls r0, r3, 16\n\ - asrs r0, 16\n\ - lsls r1, r0, 1\n\ - add r1, r12\n\ - subs r2, r4, r0\n\ - strh r2, [r1]\n\ - adds r0, 0x1\n\ - lsls r0, 16\n\ - lsrs r3, r0, 16\n\ - asrs r0, 16\n\ - cmp r0, r7\n\ - bcc _08093CA0\n\ + lsls r0, r3, 16\n\ + asrs r0, 16\n\ + lsls r1, r0, 1\n\ + add r1, r12\n\ + subs r2, r4, r0\n\ + strh r2, [r1]\n\ + adds r0, 0x1\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + asrs r0, 16\n\ + cmp r0, r7\n\ + bcc _08093CA0\n\ _08093CB8:\n\ - lsls r2, r3, 16\n\ - mov r1, r9\n\ - lsls r0, r1, 16\n\ - asrs r1, r0, 16\n\ - mov r4, r10\n\ - lsrs r7, r4, 16\n\ - cmp r2, r0\n\ - bge _08093CF2\n\ - ldr r0, _08093D48 @ =gUnknown_03004DE0\n\ - mov r9, r0\n\ - ldr r3, _08093D4C @ =0x0000fffc\n\ - mov r12, r3\n\ - adds r4, r1, 0\n\ + lsls r2, r3, 16\n\ + mov r1, r9\n\ + lsls r0, r1, 16\n\ + asrs r1, r0, 16\n\ + mov r4, r10\n\ + lsrs r7, r4, 16\n\ + cmp r2, r0\n\ + bge _08093CF2\n\ + ldr r0, _08093D48 @ =gUnknown_03004DE0\n\ + mov r9, r0\n\ + ldr r3, _08093D4C @ =0x0000fffc\n\ + mov r12, r3\n\ + adds r4, r1, 0\n\ _08093CD2:\n\ - lsrs r1, r6, 16\n\ - adds r6, r5\n\ - ldr r0, [sp]\n\ - adds r5, r0\n\ - asrs r2, 16\n\ - lsls r0, r2, 1\n\ - add r0, r9\n\ - add r1, r12\n\ - strh r1, [r0]\n\ - adds r2, 0x1\n\ - lsls r2, 16\n\ - lsrs r3, r2, 16\n\ - lsls r2, r3, 16\n\ - asrs r0, r2, 16\n\ - cmp r0, r4\n\ - blt _08093CD2\n\ + lsrs r1, r6, 16\n\ + adds r6, r5\n\ + ldr r0, [sp]\n\ + adds r5, r0\n\ + asrs r2, 16\n\ + lsls r0, r2, 1\n\ + add r0, r9\n\ + add r1, r12\n\ + strh r1, [r0]\n\ + adds r2, 0x1\n\ + lsls r2, 16\n\ + lsrs r3, r2, 16\n\ + lsls r2, r3, 16\n\ + asrs r0, r2, 16\n\ + cmp r0, r4\n\ + blt _08093CD2\n\ _08093CF2:\n\ - adds r1, r7, 0\n\ - lsls r0, r3, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x9F\n\ - bgt _08093D18\n\ - ldr r4, _08093D48 @ =gUnknown_03004DE0\n\ - ldr r0, _08093D4C @ =0x0000fffc\n\ - adds r2, r1, r0\n\ + adds r1, r7, 0\n\ + lsls r0, r3, 16\n\ + asrs r0, 16\n\ + cmp r0, 0x9F\n\ + bgt _08093D18\n\ + ldr r4, _08093D48 @ =gUnknown_03004DE0\n\ + ldr r0, _08093D4C @ =0x0000fffc\n\ + adds r2, r1, r0\n\ _08093D02:\n\ - lsls r1, r3, 16\n\ - asrs r1, 16\n\ - lsls r0, r1, 1\n\ - adds r0, r4\n\ - strh r2, [r0]\n\ - adds r1, 0x1\n\ - lsls r1, 16\n\ - lsrs r3, r1, 16\n\ - asrs r1, 16\n\ - cmp r1, 0x9F\n\ - ble _08093D02\n\ + lsls r1, r3, 16\n\ + asrs r1, 16\n\ + lsls r0, r1, 1\n\ + adds r0, r4\n\ + strh r2, [r0]\n\ + adds r1, 0x1\n\ + lsls r1, 16\n\ + lsrs r3, r1, 16\n\ + asrs r1, 16\n\ + cmp r1, 0x9F\n\ + ble _08093D02\n\ _08093D18:\n\ - movs r0, 0x1\n\ - ldr r1, _08093D40 @ =0x02000000\n\ - strb r0, [r1, 0x4]\n\ - mov r2, r8\n\ - movs r3, 0xA\n\ - ldrsh r0, [r2, r3]\n\ - cmp r0, 0\n\ - bgt _08093D2E\n\ - ldrh r0, [r2, 0x8]\n\ - adds r0, 0x1\n\ - strh r0, [r2, 0x8]\n\ + movs r0, 0x1\n\ + ldr r1, _08093D40 @ =0x02000000\n\ + strb r0, [r1, 0x4]\n\ + mov r2, r8\n\ + movs r3, 0xA\n\ + ldrsh r0, [r2, r3]\n\ + cmp r0, 0\n\ + bgt _08093D2E\n\ + ldrh r0, [r2, 0x8]\n\ + adds r0, 0x1\n\ + strh r0, [r2, 0x8]\n\ _08093D2E:\n\ - movs r0, 0\n\ - add sp, 0x4\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n\ - .align 2, 0\n\ + movs r0, 0\n\ + add sp, 0x4\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ _08093D40: .4byte 0x02000000\n\ _08093D44: .4byte 0xffff0000\n\ _08093D48: .4byte gUnknown_03004DE0\n\ @@ -1325,10 +1077,11 @@ _08093D4C: .4byte 0x0000fffc\n\ .syntax divided\n"); } -bool8 sub_8093D50(void) { +bool8 sub_8093D50(void) +{ u8 taskId; - unk_2000000.var_4 = FALSE; + ewram0.var_4 = FALSE; SetHBlankCallback(NULL); sub_8093E04(); @@ -1339,42 +1092,48 @@ bool8 sub_8093D50(void) { } __attribute__((naked)) -void sub_8093D7C(void) { +void sub_8093D7C(void) +{ asm(".syntax unified\n\ - ldr r1, _08093DA0 @ =gUnknown_03004DE0\n\ - ldr r0, _08093DA4 @ =REG_VCOUNT\n\ - ldrh r2, [r0]\n\ - movs r0, 0xFF\n\ - ands r0, r2\n\ - lsls r0, 1\n\ - movs r2, 0xF0\n\ - lsls r2, 3\n\ - adds r1, r2\n\ - adds r0, r1\n\ - ldrh r1, [r0]\n\ - ldr r0, _08093DA8 @ =REG_BG0VOFS\n\ - strh r1, [r0]\n\ - adds r0, 0x4\n\ - strh r1, [r0]\n\ - adds r0, 0x4\n\ - strh r1, [r0]\n\ - bx lr\n\ - .align 2, 0\n\ + ldr r1, _08093DA0 @ =gUnknown_03004DE0\n\ + ldr r0, _08093DA4 @ =REG_VCOUNT\n\ + ldrh r2, [r0]\n\ + movs r0, 0xFF\n\ + ands r0, r2\n\ + lsls r0, 1\n\ + movs r2, 0xF0\n\ + lsls r2, 3\n\ + adds r1, r2\n\ + adds r0, r1\n\ + ldrh r1, [r0]\n\ + ldr r0, _08093DA8 @ =REG_BG0VOFS\n\ + strh r1, [r0]\n\ + adds r0, 0x4\n\ + strh r1, [r0]\n\ + adds r0, 0x4\n\ + strh r1, [r0]\n\ + bx lr\n\ + .align 2, 0\n\ _08093DA0: .4byte gUnknown_03004DE0\n\ _08093DA4: .4byte 0x4000006 @ REG_VCOUNT\n\ _08093DA8: .4byte 0x4000012 @ REG_BG0VOFS\n\ .syntax divided\n"); } -static void sub_8093DAC(void) { - if (unk_2000000.var_3) { +static void sub_8093DAC(void) +{ + if (ewram0.var_3) + { sub_8093DEC(); - } else { + } + else + { sub_8093DC8(); } } -static void sub_8093DC8(void) { +static void sub_8093DC8(void) +{ MenuZeroFillScreen(); sub_80940E4(); sub_8093F14(); @@ -1384,7 +1143,8 @@ static void sub_8093DC8(void) { sub_8094140(); } -static void sub_8093DEC(void) { +static void sub_8093DEC(void) +{ MenuZeroFillScreen(); sub_80940E4(); sub_8093F48(); @@ -1392,76 +1152,78 @@ static void sub_8093DEC(void) { } __attribute__((naked)) -static void sub_8093E04() { +static void sub_8093E04() +{ asm(".syntax unified\n\ - ldr r0, _08093E20 @ =REG_BG0VOFS\n\ - ldr r2, _08093E24 @ =0x0000fffc\n\ - adds r1, r2, 0\n\ - strh r1, [r0]\n\ - adds r0, 0x2\n\ - movs r2, 0\n\ - strh r2, [r0]\n\ - adds r0, 0x2\n\ - strh r1, [r0]\n\ - adds r0, 0x2\n\ - strh r2, [r0]\n\ - adds r0, 0x2\n\ - strh r1, [r0]\n\ - bx lr\n\ - .align 2, 0\n\ + ldr r0, _08093E20 @ =REG_BG0VOFS\n\ + ldr r2, _08093E24 @ =0x0000fffc\n\ + adds r1, r2, 0\n\ + strh r1, [r0]\n\ + adds r0, 0x2\n\ + movs r2, 0\n\ + strh r2, [r0]\n\ + adds r0, 0x2\n\ + strh r1, [r0]\n\ + adds r0, 0x2\n\ + strh r2, [r0]\n\ + adds r0, 0x2\n\ + strh r1, [r0]\n\ + bx lr\n\ + .align 2, 0\n\ _08093E20: .4byte 0x4000012 @ REG_BG0VOFS\n\ _08093E24: .4byte 0x0000fffc\n\ .syntax divided\n"); } __attribute__((naked)) -static void sub_8093E28(void) { +static void sub_8093E28(void) +{ asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - bl sub_8093EA0\n\ - ldr r0, _08093E84 @ =gUnknown_083B5F6C\n\ - movs r1, 0xE0\n\ - movs r2, 0x20\n\ - bl LoadPalette\n\ - ldr r3, _08093E88 @ =gMenuTrainerCard_Gfx\n\ - movs r4, 0xC0\n\ - lsls r4, 19\n\ - movs r5, 0xA4\n\ - lsls r5, 5\n\ - ldr r1, _08093E8C @ =0x040000d4\n\ - ldr r6, _08093E90 @ =0x80000800\n\ - movs r2, 0x80\n\ - lsls r2, 5\n\ - movs r7, 0x80\n\ - lsls r7, 24\n\ + push {r4-r7,lr}\n\ + bl sub_8093EA0\n\ + ldr r0, _08093E84 @ =gUnknown_083B5F6C\n\ + movs r1, 0xE0\n\ + movs r2, 0x20\n\ + bl LoadPalette\n\ + ldr r3, _08093E88 @ =gMenuTrainerCard_Gfx\n\ + movs r4, 0xC0\n\ + lsls r4, 19\n\ + movs r5, 0xA4\n\ + lsls r5, 5\n\ + ldr r1, _08093E8C @ =0x040000d4\n\ + ldr r6, _08093E90 @ =0x80000800\n\ + movs r2, 0x80\n\ + lsls r2, 5\n\ + movs r7, 0x80\n\ + lsls r7, 24\n\ _08093E4E:\n\ - str r3, [r1]\n\ - str r4, [r1, 0x4]\n\ - str r6, [r1, 0x8]\n\ - ldr r0, [r1, 0x8]\n\ - adds r3, r2\n\ - adds r4, r2\n\ - subs r5, r2\n\ - cmp r5, r2\n\ - bhi _08093E4E\n\ - str r3, [r1]\n\ - str r4, [r1, 0x4]\n\ - lsrs r0, r5, 1\n\ - orrs r0, r7\n\ - str r0, [r1, 0x8]\n\ - ldr r0, [r1, 0x8]\n\ - ldr r1, _08093E94 @ =gBadgesTiles\n\ - ldr r2, _08093E98 @ =0x06001480\n\ - ldr r0, _08093E8C @ =0x040000d4\n\ - str r1, [r0]\n\ - str r2, [r0, 0x4]\n\ - ldr r1, _08093E9C @ =0x80000200\n\ - str r1, [r0, 0x8]\n\ - ldr r0, [r0, 0x8]\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ + str r3, [r1]\n\ + str r4, [r1, 0x4]\n\ + str r6, [r1, 0x8]\n\ + ldr r0, [r1, 0x8]\n\ + adds r3, r2\n\ + adds r4, r2\n\ + subs r5, r2\n\ + cmp r5, r2\n\ + bhi _08093E4E\n\ + str r3, [r1]\n\ + str r4, [r1, 0x4]\n\ + lsrs r0, r5, 1\n\ + orrs r0, r7\n\ + str r0, [r1, 0x8]\n\ + ldr r0, [r1, 0x8]\n\ + ldr r1, _08093E94 @ =gBadgesTiles\n\ + ldr r2, _08093E98 @ =0x06001480\n\ + ldr r0, _08093E8C @ =0x040000d4\n\ + str r1, [r0]\n\ + str r2, [r0, 0x4]\n\ + ldr r1, _08093E9C @ =0x80000200\n\ + str r1, [r0, 0x8]\n\ + ldr r0, [r0, 0x8]\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ _08093E84: .4byte gUnknown_083B5F6C\n\ _08093E88: .4byte gMenuTrainerCard_Gfx\n\ _08093E8C: .4byte 0x040000d4\n\ @@ -1472,157 +1234,165 @@ _08093E9C: .4byte 0x80000200\n\ .syntax divided\n"); } -void sub_8093EA0(void) { - LoadPalette(gUnknown_083B5EF8[unk_2000000.var_2], 0, 48 * 2); +void sub_8093EA0(void) +{ + LoadPalette(gUnknown_083B5EF8[ewram0.var_2], 0, 48 * 2); LoadPalette(gBadgesPalette, 48, 16 * 2); LoadPalette(gUnknown_083B5F4C, 64, 16 * 2); - if (unk_2000000.var_64.gender != MALE) { + if (ewram0.var_64.gender != MALE) + { LoadPalette(gUnknown_083B5F0C, 16, 16 * 2); } } -static void sub_8093EF8(void) { - LoadTrainerGfx_TrainerCard(unk_2000000.var_64.gender, 80, (void *) (VRAM + 0x1880)); +static void sub_8093EF8(void) +{ + LoadTrainerGfx_TrainerCard(ewram0.var_64.gender, 80, (void *)(VRAM + 0x1880)); } __attribute__((naked)) -static void sub_8093F14(void) { +static void sub_8093F14(void) +{ asm(".syntax unified\n\ - push {lr}\n\ - sub sp, 0x8\n\ - ldr r0, _08093F3C @ =gUnknown_083B5EEC\n\ - ldr r1, [r0, 0x4]\n\ - ldr r0, [r0]\n\ - str r0, [sp]\n\ - str r1, [sp, 0x4]\n\ - ldr r0, _08093F40 @ =0x02000000\n\ - ldrb r0, [r0, 0x1]\n\ - lsls r0, 2\n\ - add r0, sp\n\ - ldr r0, [r0]\n\ - ldr r1, _08093F44 @ =0x06004800\n\ - movs r2, 0xA0\n\ - lsls r2, 1\n\ - bl CpuFastSet\n\ - add sp, 0x8\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ + push {lr}\n\ + sub sp, 0x8\n\ + ldr r0, _08093F3C @ =gUnknown_083B5EEC\n\ + ldr r1, [r0, 0x4]\n\ + ldr r0, [r0]\n\ + str r0, [sp]\n\ + str r1, [sp, 0x4]\n\ + ldr r0, _08093F40 @ =0x02000000\n\ + ldrb r0, [r0, 0x1]\n\ + lsls r0, 2\n\ + add r0, sp\n\ + ldr r0, [r0]\n\ + ldr r1, _08093F44 @ =0x06004800\n\ + movs r2, 0xA0\n\ + lsls r2, 1\n\ + bl CpuFastSet\n\ + add sp, 0x8\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ _08093F3C: .4byte gUnknown_083B5EEC\n\ _08093F40: .4byte 0x02000000\n\ _08093F44: .4byte 0x06004800\n\ .syntax divided\n"); } -static void sub_8093F48(void) { - CpuFastSet(gUnknown_08E8CFC0, (void *) (VRAM + 0x4800), 320); +static void sub_8093F48(void) +{ + CpuFastSet(gUnknown_08E8CFC0, (void *)(VRAM + 0x4800), 320); } -static void sub_8093F64(void) { - CpuFastSet(gUnknown_08E8D9C0, (void *) (VRAM + 0x5000), 320); +static void sub_8093F64(void) +{ + CpuFastSet(gUnknown_08E8D9C0, (void *)(VRAM + 0x5000), 320); } __attribute__((naked)) -static void sub_8093F80(void) { +static void sub_8093F80(void) +{ asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - movs r5, 0xC4\n\ - ldr r7, _08093FCC @ =0x06004000\n\ - movs r1, 0x5\n\ - movs r0, 0xA0\n\ - lsls r0, 7\n\ - adds r6, r0, 0\n\ + push {r4-r7,lr}\n\ + movs r5, 0xC4\n\ + ldr r7, _08093FCC @ =0x06004000\n\ + movs r1, 0x5\n\ + movs r0, 0xA0\n\ + lsls r0, 7\n\ + adds r6, r0, 0\n\ _08093F8E:\n\ - movs r0, 0x13\n\ - lsls r3, r1, 16\n\ - asrs r4, r3, 11\n\ + movs r0, 0x13\n\ + lsls r3, r1, 16\n\ + asrs r4, r3, 11\n\ _08093F94:\n\ - lsls r2, r0, 16\n\ - asrs r2, 16\n\ - adds r1, r4, r2\n\ - lsls r1, 1\n\ - adds r1, r7\n\ - adds r0, r5, 0\n\ - orrs r0, r6\n\ - strh r0, [r1]\n\ - adds r2, 0x1\n\ - lsls r2, 16\n\ - adds r0, r5, 0x1\n\ - lsls r0, 16\n\ - lsrs r5, r0, 16\n\ - lsrs r0, r2, 16\n\ - asrs r2, 16\n\ - cmp r2, 0x1A\n\ - ble _08093F94\n\ - movs r1, 0x80\n\ - lsls r1, 9\n\ - adds r0, r3, r1\n\ - lsrs r1, r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0xC\n\ - ble _08093F8E\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ + lsls r2, r0, 16\n\ + asrs r2, 16\n\ + adds r1, r4, r2\n\ + lsls r1, 1\n\ + adds r1, r7\n\ + adds r0, r5, 0\n\ + orrs r0, r6\n\ + strh r0, [r1]\n\ + adds r2, 0x1\n\ + lsls r2, 16\n\ + adds r0, r5, 0x1\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + lsrs r0, r2, 16\n\ + asrs r2, 16\n\ + cmp r2, 0x1A\n\ + ble _08093F94\n\ + movs r1, 0x80\n\ + lsls r1, 9\n\ + adds r0, r3, r1\n\ + lsrs r1, r0, 16\n\ + asrs r0, 16\n\ + cmp r0, 0xC\n\ + ble _08093F8E\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ _08093FCC: .4byte 0x06004000\n\ .syntax divided\n"); } __attribute__((naked)) -static void sub_8093FD0(void) { +static void sub_8093FD0(void) +{ asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - ldr r4, _0809402C @ =0x06004000\n\ - movs r2, 0xF\n\ - ldr r0, _08094030 @ =0x02000000\n\ - ldrb r0, [r0, 0x2]\n\ - adds r0, 0xF\n\ - cmp r2, r0\n\ - bge _08094002\n\ - movs r6, 0xC0\n\ - lsls r6, 1\n\ - ldr r1, _08094034 @ =0x0000408f\n\ - adds r5, r1, 0\n\ - adds r3, r0, 0\n\ + push {r4-r6,lr}\n\ + ldr r4, _0809402C @ =0x06004000\n\ + movs r2, 0xF\n\ + ldr r0, _08094030 @ =0x02000000\n\ + ldrb r0, [r0, 0x2]\n\ + adds r0, 0xF\n\ + cmp r2, r0\n\ + bge _08094002\n\ + movs r6, 0xC0\n\ + lsls r6, 1\n\ + ldr r1, _08094034 @ =0x0000408f\n\ + adds r5, r1, 0\n\ + adds r3, r0, 0\n\ _08093FEA:\n\ - lsls r1, r2, 16\n\ - asrs r1, 16\n\ - lsls r0, r1, 1\n\ - adds r0, r4\n\ - adds r0, r6\n\ - strh r5, [r0]\n\ - adds r1, 0x1\n\ - lsls r1, 16\n\ - lsrs r2, r1, 16\n\ - asrs r1, 16\n\ - cmp r1, r3\n\ - blt _08093FEA\n\ + lsls r1, r2, 16\n\ + asrs r1, 16\n\ + lsls r0, r1, 1\n\ + adds r0, r4\n\ + adds r0, r6\n\ + strh r5, [r0]\n\ + adds r1, 0x1\n\ + lsls r1, 16\n\ + lsrs r2, r1, 16\n\ + asrs r1, 16\n\ + cmp r1, r3\n\ + blt _08093FEA\n\ _08094002:\n\ - lsls r1, r2, 16\n\ - asrs r0, r1, 16\n\ - cmp r0, 0x12\n\ - bgt _08094024\n\ - movs r3, 0xC0\n\ - lsls r3, 1\n\ - movs r2, 0\n\ + lsls r1, r2, 16\n\ + asrs r0, r1, 16\n\ + cmp r0, 0x12\n\ + bgt _08094024\n\ + movs r3, 0xC0\n\ + lsls r3, 1\n\ + movs r2, 0\n\ _08094010:\n\ - asrs r0, r1, 16\n\ - lsls r1, r0, 1\n\ - adds r1, r4\n\ - adds r1, r3\n\ - strh r2, [r1]\n\ - adds r0, 0x1\n\ - lsls r1, r0, 16\n\ - asrs r0, r1, 16\n\ - cmp r0, 0x12\n\ - ble _08094010\n\ + asrs r0, r1, 16\n\ + lsls r1, r0, 1\n\ + adds r1, r4\n\ + adds r1, r3\n\ + strh r2, [r1]\n\ + adds r0, 0x1\n\ + lsls r1, r0, 16\n\ + asrs r0, r1, 16\n\ + cmp r0, 0x12\n\ + ble _08094010\n\ _08094024:\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ _0809402C: .4byte 0x06004000\n\ _08094030: .4byte 0x02000000\n\ _08094034: .4byte 0x0000408f\n\ @@ -1630,87 +1400,88 @@ _08094034: .4byte 0x0000408f\n\ } __attribute__((naked)) -static void sub_8094038(void) { +static void sub_8094038(void) +{ asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r9\n\ - mov r6, r8\n\ - push {r6,r7}\n\ - ldr r1, _080940D0 @ =0x02000000\n\ - ldrb r0, [r1, 0x1]\n\ - cmp r0, 0\n\ - bne _080940C2\n\ - ldr r0, _080940D4 @ =0x06004000\n\ - mov r9, r0\n\ - movs r0, 0\n\ - movs r2, 0x4\n\ - adds r1, 0xE\n\ - mov r8, r1\n\ - ldr r7, _080940D8 @ =gUnknown_083B5F8C\n\ - movs r1, 0xC0\n\ - lsls r1, 6\n\ - adds r6, r1, 0\n\ - adds r1, r7, 0x6\n\ - mov r12, r1\n\ + push {r4-r7,lr}\n\ + mov r7, r9\n\ + mov r6, r8\n\ + push {r6,r7}\n\ + ldr r1, _080940D0 @ =0x02000000\n\ + ldrb r0, [r1, 0x1]\n\ + cmp r0, 0\n\ + bne _080940C2\n\ + ldr r0, _080940D4 @ =0x06004000\n\ + mov r9, r0\n\ + movs r0, 0\n\ + movs r2, 0x4\n\ + adds r1, 0xE\n\ + mov r8, r1\n\ + ldr r7, _080940D8 @ =gUnknown_083B5F8C\n\ + movs r1, 0xC0\n\ + lsls r1, 6\n\ + adds r6, r1, 0\n\ + adds r1, r7, 0x6\n\ + mov r12, r1\n\ _08094060:\n\ - lsls r0, 16\n\ - asrs r4, r0, 16\n\ - mov r1, r8\n\ - adds r0, r4, r1\n\ - ldrb r0, [r0]\n\ - lsls r5, r2, 16\n\ - cmp r0, 0\n\ - beq _080940AE\n\ - asrs r1, r5, 15\n\ - add r1, r9\n\ - movs r2, 0xF0\n\ - lsls r2, 2\n\ - adds r3, r1, r2\n\ - lsls r2, r4, 3\n\ - adds r0, r2, r7\n\ - ldrh r0, [r0]\n\ - orrs r0, r6\n\ - strh r0, [r3]\n\ - ldr r0, _080940DC @ =0x000003c2\n\ - adds r3, r1, r0\n\ - adds r0, r7, 0x2\n\ - adds r0, r2, r0\n\ - ldrh r0, [r0]\n\ - orrs r0, r6\n\ - strh r0, [r3]\n\ - movs r0, 0x80\n\ - lsls r0, 3\n\ - adds r3, r1, r0\n\ - adds r0, r7, 0x4\n\ - adds r0, r2, r0\n\ - ldrh r0, [r0]\n\ - orrs r0, r6\n\ - strh r0, [r3]\n\ - ldr r0, _080940E0 @ =0x00000402\n\ - adds r1, r0\n\ - add r2, r12\n\ - ldrh r0, [r2]\n\ - orrs r0, r6\n\ - strh r0, [r1]\n\ + lsls r0, 16\n\ + asrs r4, r0, 16\n\ + mov r1, r8\n\ + adds r0, r4, r1\n\ + ldrb r0, [r0]\n\ + lsls r5, r2, 16\n\ + cmp r0, 0\n\ + beq _080940AE\n\ + asrs r1, r5, 15\n\ + add r1, r9\n\ + movs r2, 0xF0\n\ + lsls r2, 2\n\ + adds r3, r1, r2\n\ + lsls r2, r4, 3\n\ + adds r0, r2, r7\n\ + ldrh r0, [r0]\n\ + orrs r0, r6\n\ + strh r0, [r3]\n\ + ldr r0, _080940DC @ =0x000003c2\n\ + adds r3, r1, r0\n\ + adds r0, r7, 0x2\n\ + adds r0, r2, r0\n\ + ldrh r0, [r0]\n\ + orrs r0, r6\n\ + strh r0, [r3]\n\ + movs r0, 0x80\n\ + lsls r0, 3\n\ + adds r3, r1, r0\n\ + adds r0, r7, 0x4\n\ + adds r0, r2, r0\n\ + ldrh r0, [r0]\n\ + orrs r0, r6\n\ + strh r0, [r3]\n\ + ldr r0, _080940E0 @ =0x00000402\n\ + adds r1, r0\n\ + add r2, r12\n\ + ldrh r0, [r2]\n\ + orrs r0, r6\n\ + strh r0, [r1]\n\ _080940AE:\n\ - adds r1, r4, 0x1\n\ - lsls r1, 16\n\ - movs r2, 0xC0\n\ - lsls r2, 10\n\ - adds r0, r5, r2\n\ - lsrs r2, r0, 16\n\ - lsrs r0, r1, 16\n\ - asrs r1, 16\n\ - cmp r1, 0x7\n\ - ble _08094060\n\ + adds r1, r4, 0x1\n\ + lsls r1, 16\n\ + movs r2, 0xC0\n\ + lsls r2, 10\n\ + adds r0, r5, r2\n\ + lsrs r2, r0, 16\n\ + lsrs r0, r1, 16\n\ + asrs r1, 16\n\ + cmp r1, 0x7\n\ + ble _08094060\n\ _080940C2:\n\ - pop {r3,r4}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ + pop {r3,r4}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ _080940D0: .4byte 0x02000000\n\ _080940D4: .4byte 0x06004000\n\ _080940D8: .4byte gUnknown_083B5F8C\n\ @@ -1720,73 +1491,76 @@ _080940E0: .4byte 0x00000402\n\ } __attribute__((naked)) -static void sub_80940E4() { +static void sub_80940E4() +{ asm(".syntax unified\n\ - push {r4,lr}\n\ - movs r2, 0\n\ - ldr r1, _08094108 @ =0x06004000\n\ - movs r4, 0\n\ - ldr r3, _0809410C @ =0x000003ff\n\ + push {r4,lr}\n\ + movs r2, 0\n\ + ldr r1, _08094108 @ =0x06004000\n\ + movs r4, 0\n\ + ldr r3, _0809410C @ =0x000003ff\n\ _080940EE:\n\ - strh r4, [r1]\n\ - lsls r0, r2, 16\n\ - movs r2, 0x80\n\ - lsls r2, 9\n\ - adds r0, r2\n\ - adds r1, 0x2\n\ - lsrs r2, r0, 16\n\ - asrs r0, 16\n\ - cmp r0, r3\n\ - ble _080940EE\n\ - pop {r4}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ + strh r4, [r1]\n\ + lsls r0, r2, 16\n\ + movs r2, 0x80\n\ + lsls r2, 9\n\ + adds r0, r2\n\ + adds r1, 0x2\n\ + lsrs r2, r0, 16\n\ + asrs r0, 16\n\ + cmp r0, r3\n\ + ble _080940EE\n\ + pop {r4}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ _08094108: .4byte 0x06004000\n\ _0809410C: .4byte 0x000003ff\n\ .syntax divided\n"); } __attribute__((naked)) -static void sub_8094110() { +static void sub_8094110() +{ asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - ldr r6, _0809413C @ =0x06004800\n\ - movs r2, 0x3\n\ - movs r5, 0xA0\n\ - lsls r5, 2\n\ - movs r3, 0x1\n\ - movs r4, 0xB0\n\ - lsls r4, 2\n\ + push {r4-r6,lr}\n\ + ldr r6, _0809413C @ =0x06004800\n\ + movs r2, 0x3\n\ + movs r5, 0xA0\n\ + lsls r5, 2\n\ + movs r3, 0x1\n\ + movs r4, 0xB0\n\ + lsls r4, 2\n\ _08094120:\n\ - lsls r0, r2, 1\n\ - adds r0, r6\n\ - adds r1, r0, r5\n\ - strh r3, [r1]\n\ - adds r0, r4\n\ - strh r3, [r0]\n\ - adds r0, r2, 0x1\n\ - lsls r0, 16\n\ - lsrs r2, r0, 16\n\ - cmp r2, 0x10\n\ - bls _08094120\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ + lsls r0, r2, 1\n\ + adds r0, r6\n\ + adds r1, r0, r5\n\ + strh r3, [r1]\n\ + adds r0, r4\n\ + strh r3, [r0]\n\ + adds r0, r2, 0x1\n\ + lsls r0, 16\n\ + lsrs r2, r0, 16\n\ + cmp r2, 0x10\n\ + bls _08094120\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ _0809413C: .4byte 0x06004800\n\ .syntax divided\n"); } -static void sub_8094140(void) { +static void sub_8094140(void) +{ u8 *buffer; BasicInitMenuWindow(&WindowConfig_TrainerCard_Back_Values); buffer = gStringVar1; - StringCopy(buffer, unk_2000000.var_64.playerName); - ConvertInternationalString(buffer, unk_2000000.language); + StringCopy(buffer, ewram0.var_64.playerName); + ConvertInternationalString(buffer, ewram0.language); MenuPrint(buffer, 7, 5); TrainerCard_Front_PrintTrainerID(); @@ -1795,7 +1569,8 @@ static void sub_8094140(void) { sub_809429C(); } -static void sub_8094188(void) { +static void sub_8094188(void) +{ BasicInitMenuWindow(&WindowConfig_TrainerCard_Back_Values); TrainerCard_Back_PrintName(); TrainerCard_Back_PrintHallOfFameTime_Label(); @@ -1814,30 +1589,35 @@ static void sub_8094188(void) { TrainerCard_Back_PrintPokemonTrades(); } -static void TrainerCard_Front_PrintTrainerID(void) { +static void TrainerCard_Front_PrintTrainerID(void) +{ u8 buffer[8]; - ConvertIntToDecimalStringN(buffer, unk_2000000.var_64.trainerId, STR_CONV_MODE_LEADING_ZEROS, 5); + ConvertIntToDecimalStringN(buffer, ewram0.var_64.trainerId, STR_CONV_MODE_LEADING_ZEROS, 5); MenuPrint(buffer, 20, 2); } -static void TrainerCard_Front_PrintMoney(void) { - sub_80B7AEC(unk_2000000.var_64.money, 16, 8); +static void TrainerCard_Front_PrintMoney(void) +{ + sub_80B7AEC(ewram0.var_64.money, 16, 8); } -static void TrainerCard_Front_PrintPokedexCount(void) { +static void TrainerCard_Front_PrintPokedexCount(void) +{ u8 buffer[16]; - if (unk_2000000.var_7 == FALSE) { + if (ewram0.var_7 == FALSE) + { sub_8094110(); return; } - ConvertIntToDecimalStringN(buffer, unk_2000000.var_64.pokedexSeen, STR_CONV_MODE_LEFT_ALIGN, 3); + ConvertIntToDecimalStringN(buffer, ewram0.var_64.pokedexSeen, STR_CONV_MODE_LEFT_ALIGN, 3); MenuPrint_RightAligned(buffer, 16, 10); } -static void TrainerCard_Front_PrintPlayTime(u8 *arg1, s16 colon) { +static void TrainerCard_Front_PrintPlayTime(u8 *arg1, s16 colon) +{ u8 buffer[16]; u16 playTimeHours; u16 playTimeMinutes; @@ -1845,184 +1625,215 @@ static void TrainerCard_Front_PrintPlayTime(u8 *arg1, s16 colon) { playTimeHours = gSaveBlock2.playTimeHours; playTimeMinutes = gSaveBlock2.playTimeMinutes; - if (unk_2000000.var_1 != 0) { - playTimeHours = unk_2000000.var_64.playTimeHours; - playTimeMinutes = unk_2000000.var_64.playTimeMinutes; + if (ewram0.var_1 != 0) + { + playTimeHours = ewram0.var_64.playTimeHours; + playTimeMinutes = ewram0.var_64.playTimeMinutes; } FormatPlayTime(buffer, playTimeHours, playTimeMinutes, colon); sub_8072C74(arg1, buffer, 48, 1); } -static void sub_809429C(void) { - u8 *bufferPtr; +static void sub_809429C(void) +{ + u8 *str; - if (unk_2000000.var_1 == FALSE) { + if (ewram0.var_1 == FALSE) + { return; } - bufferPtr = gStringVar1; - bufferPtr = StringCopy(bufferPtr, unk_2000000.var_20[0]); - bufferPtr[0] = 00; - bufferPtr++; - bufferPtr = StringCopy(bufferPtr, unk_2000000.var_20[1]); + str = gStringVar1; + str = StringCopy(str, ewram0.var_20[0]); + str[0] = 00; + str++; + str = StringCopy(str, ewram0.var_20[1]); MenuPrint(gStringVar1, 2, 14); - bufferPtr = gStringVar1; - bufferPtr = StringCopy(bufferPtr, unk_2000000.var_20[2]); - bufferPtr[0] = 00; - bufferPtr++; - bufferPtr = StringCopy(bufferPtr, unk_2000000.var_20[3]); + str = gStringVar1; + str = StringCopy(str, ewram0.var_20[2]); + str[0] = 00; + str++; + str = StringCopy(str, ewram0.var_20[3]); MenuPrint(gStringVar1, 2, 16); } -static void TrainerCard_Back_PrintName(void) { - u8 *bufferPtr; +static void TrainerCard_Back_PrintName(void) +{ + u8 *str; - bufferPtr = gStringVar1; - StringCopy(bufferPtr, unk_2000000.var_64.playerName); - ConvertInternationalString(bufferPtr, unk_2000000.language); + str = gStringVar1; + StringCopy(str, ewram0.var_64.playerName); + ConvertInternationalString(str, ewram0.language); - StringAppend(bufferPtr, gOtherText_TrainersTrainerCard); +#if ENGLISH + StringAppend(str, gOtherText_TrainersTrainerCard); +#elif GERMAN + de_sub_8073174(str, gOtherText_TrainersTrainerCard); +#endif MenuPrint_RightAligned(gStringVar1, 28, 2); } -static void TrainerCard_Back_PrintHallOfFameTime_Label(void) { - if (unk_2000000.var_8 == FALSE) { +static void TrainerCard_Back_PrintHallOfFameTime_Label(void) +{ + if (ewram0.var_8 == FALSE) + { return; } MenuPrint(gOtherText_FirstHOF, 3, 5); } -static void TrainerCard_Back_PrintHallOfFameTime(void) { - u8 *bufferPtr; +static void TrainerCard_Back_PrintHallOfFameTime(void) +{ + u8 *str; - if (unk_2000000.var_8 == FALSE) { + if (ewram0.var_8 == FALSE) + { return; } - bufferPtr = gStringVar1; - bufferPtr = ConvertIntToDecimalStringN(bufferPtr, unk_2000000.var_64.firstHallOfFameA, STR_CONV_MODE_RIGHT_ALIGN, - 3); - bufferPtr = StringCopy(bufferPtr, gUnknown_083B5EF4); - bufferPtr = ConvertIntToDecimalStringN(bufferPtr, unk_2000000.var_64.firstHallOfFameB, STR_CONV_MODE_LEADING_ZEROS, - 2); - bufferPtr = StringCopy(bufferPtr, gUnknown_083B5EF4); - bufferPtr = ConvertIntToDecimalStringN(bufferPtr, unk_2000000.var_64.firstHallOfFameC, STR_CONV_MODE_LEADING_ZEROS, - 2); + str = gStringVar1; + str = ConvertIntToDecimalStringN(str, ewram0.var_64.firstHallOfFameA, STR_CONV_MODE_RIGHT_ALIGN, 3); + str = StringCopy(str, gUnknown_083B5EF4); + str = ConvertIntToDecimalStringN(str, ewram0.var_64.firstHallOfFameB, STR_CONV_MODE_LEADING_ZEROS, 2); + str = StringCopy(str, gUnknown_083B5EF4); + str = ConvertIntToDecimalStringN(str, ewram0.var_64.firstHallOfFameC, STR_CONV_MODE_LEADING_ZEROS, 2); MenuPrint_RightAligned(gStringVar1, 28, 5); } -static void TrainerCard_Back_PrintLinkBattlesLabel(void) { - if (unk_2000000.var_9 == FALSE) { +static void TrainerCard_Back_PrintLinkBattlesLabel(void) +{ + if (ewram0.var_9 == FALSE) + { return; } MenuPrint(gOtherText_LinkCableBattles, 3, 7); } -static void TrainerCard_Back_PrintLinkBattles(void) { +static void TrainerCard_Back_PrintLinkBattles(void) +{ u8 buffer[16]; - if (unk_2000000.var_9 == FALSE) { + if (ewram0.var_9 == FALSE) + { return; } - ConvertIntToDecimalString(buffer, unk_2000000.var_64.linkBattleWins); + ConvertIntToDecimalString(buffer, ewram0.var_64.linkBattleWins); MenuPrint_RightAligned(buffer, 22, 7); - ConvertIntToDecimalString(buffer, unk_2000000.var_64.linkBattleLosses); + ConvertIntToDecimalString(buffer, ewram0.var_64.linkBattleLosses); MenuPrint_RightAligned(buffer, 28, 7); } -static void TrainerCard_Back_PrintBattleTower_Label(void) { - if (unk_2000000.var_a == FALSE) { +static void TrainerCard_Back_PrintBattleTower_Label(void) +{ + if (ewram0.var_a == FALSE) + { return; } MenuPrint(gOtherText_BattleTowerWinRecord, 3, 15); } -static void TrainerCard_Back_PrintBattleTower(void) { +static void TrainerCard_Back_PrintBattleTower(void) +{ u8 buffer[16]; - if (unk_2000000.var_a == FALSE) { + if (ewram0.var_a == FALSE) + { return; } - sub_8072C44(buffer, unk_2000000.var_64.battleTowerWins, 24, 1); + sub_8072C44(buffer, ewram0.var_64.battleTowerWins, 24, 1); MenuPrint_PixelCoords(buffer, 112, 120, 0); - sub_8072C44(buffer, unk_2000000.var_64.battleTowerLosses, 24, 1); + sub_8072C44(buffer, ewram0.var_64.battleTowerLosses, 24, 1); MenuPrint_PixelCoords(buffer, 149, 120, 0); } -static void TrainerCard_Back_PrintLinkContests_Label(void) { - if (unk_2000000.var_b == FALSE) { +static void TrainerCard_Back_PrintLinkContests_Label(void) +{ + if (ewram0.var_b == FALSE) + { return; } MenuPrint(gOtherText_ContestRecord, 3, 13); } -static void TrainerCard_Back_PrintLinkContests(void) { +static void TrainerCard_Back_PrintLinkContests(void) +{ u8 buffer[8]; - if (unk_2000000.var_b == FALSE) { + if (ewram0.var_b == FALSE) + { return; } - ConvertIntToDecimalStringN(buffer, unk_2000000.var_64.contestsWithFriends, STR_CONV_MODE_RIGHT_ALIGN, 3); + ConvertIntToDecimalStringN(buffer, ewram0.var_64.contestsWithFriends, STR_CONV_MODE_RIGHT_ALIGN, 3); MenuPrint_RightAligned(buffer, 28, 13); } -static void TrainerCard_Back_PrintLinkPokeblocks_Label(void) { - if (unk_2000000.var_c == FALSE) { +static void TrainerCard_Back_PrintLinkPokeblocks_Label(void) +{ + if (ewram0.var_c == FALSE) + { return; } MenuPrint(gOtherText_MixingRecord, 3, 11); } -static void TrainerCard_Back_PrintLinkPokeblocks(void) { +static void TrainerCard_Back_PrintLinkPokeblocks(void) +{ u8 buffer[8]; - if (unk_2000000.var_c == FALSE) { + if (ewram0.var_c == FALSE) + { return; } - ConvertIntToDecimalStringN(buffer, unk_2000000.var_64.pokeblocksWithFriends, STR_CONV_MODE_RIGHT_ALIGN, 5); + ConvertIntToDecimalStringN(buffer, ewram0.var_64.pokeblocksWithFriends, STR_CONV_MODE_RIGHT_ALIGN, 5); MenuPrint_RightAligned(buffer, 28, 11); } -static void TrainerCard_Back_PrintPokemonTrades_Label(void) { - if (unk_2000000.var_d == FALSE) { +static void TrainerCard_Back_PrintPokemonTrades_Label(void) +{ + if (ewram0.var_d == FALSE) + { return; } MenuPrint(gOtherText_TradeRecord, 3, 9); } -static void TrainerCard_Back_PrintPokemonTrades(void) { +static void TrainerCard_Back_PrintPokemonTrades(void) +{ u8 buffer[8]; - if (unk_2000000.var_d == FALSE) { + if (ewram0.var_d == FALSE) + { return; } - ConvertIntToDecimalStringN(buffer, unk_2000000.var_64.pokemonTrades, STR_CONV_MODE_RIGHT_ALIGN, 5); + ConvertIntToDecimalStringN(buffer, ewram0.var_64.pokemonTrades, STR_CONV_MODE_RIGHT_ALIGN, 5); MenuPrint_RightAligned(buffer, 28, 9); } -void unref_sub_8094588(u16 left, u16 top) { - u8 *text = gOtherText_Boy; +void unref_sub_8094588(u16 left, u16 top) +{ + const u8 *text = gOtherText_Boy; - if (gSaveBlock2.playerGender == FEMALE) { + if (gSaveBlock2.playerGender == FEMALE) + { text = gOtherText_Girl; } - MenuPrint(text, (u8) left, (u8) top); + MenuPrint(text, (u8)left, (u8)top); } diff --git a/src/trainer_see.c b/src/trainer_see.c index 969bc94c1..9b7a47f6b 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -1,14 +1,13 @@ #include "global.h" #include "trainer_see.h" -#include "asm.h" #include "battle_setup.h" -#include "field_player_avatar.h" -#include "field_map_obj.h" -#include "asm_fieldmap.h" -#include "task.h" -#include "sprite.h" #include "field_effect.h" +#include "field_map_obj.h" +#include "field_player_avatar.h" #include "script.h" +#include "sprite.h" +#include "task.h" +#include "util.h" extern bool8 (*gIsTrainerInRange[])(struct MapObject *, u16, s16, s16); extern bool8 (*gTrainerSeeFuncList[])(u8, struct Task *, struct MapObject *); @@ -16,12 +15,14 @@ extern bool8 (*gTrainerSeeFuncList2[])(u8, struct Task *, struct MapObject *); extern u32 gUnknown_0202FF84[]; +extern struct SpriteTemplate gSpriteTemplate_839B510; +extern struct SpriteTemplate gSpriteTemplate_839B528; bool8 CheckTrainers(void) { u8 i; - - for(i = 0; i < 16; i++) + + for (i = 0; i < 16; i++) { if ( gMapObjects[i].active ) if ( gMapObjects[i].trainerType == 1 || gMapObjects[i].trainerType == 3 ) @@ -35,14 +36,14 @@ bool8 CheckTrainer(u8 trainer) { u8 *scriptPtr = GetFieldObjectScriptPointerByFieldObjectId(trainer); - if(GetTrainerFlagFromScriptPointer(scriptPtr)) + if (GetTrainerFlagFromScriptPointer(scriptPtr)) return FALSE; else { struct MapObject *trainerObj = &gMapObjects[trainer]; u8 canApproach = TrainerCanApproachPlayer(trainerObj); - if(canApproach != 0) + if (canApproach != 0) { TrainerWantsBattle(trainer, scriptPtr); sub_80842C8(trainerObj, (canApproach - 1)); @@ -60,7 +61,7 @@ bool8 TrainerCanApproachPlayer(struct MapObject *trainerObj) s16 x, y; u8 i; u8 playerCoord; - + PlayerGetDestCoords(&x, &y); if ( trainerObj->trainerType == 1 ) // trainers that don't spin { @@ -69,7 +70,7 @@ bool8 TrainerCanApproachPlayer(struct MapObject *trainerObj) } else // spinners { - for(i = 0; i < 4; i++) + for (i = 0; i < 4; i++) { playerCoord = gIsTrainerInRange[i](trainerObj, trainerObj->trainerRange_berryTreeId, x, y); if ( CheckPathBetweenTrainerAndPlayer((struct MapObject2 *)trainerObj, playerCoord, i + 1) ) // directions are 1-4 instead of 0-3. south north west east @@ -119,6 +120,12 @@ bool8 IsTrainerInRangeEast(struct MapObject *trainerObj, s16 vision, s16 x, s16 return FALSE; } +#ifdef BUGFIX_TRAINERAPPROACH +#define COLLISION_MASK ~1 +#else +#define COLLISION_MASK 1 +#endif + bool8 CheckPathBetweenTrainerAndPlayer(struct MapObject2 *trainerObj, u8 playerCoord, u8 direction) { s16 x, y; @@ -127,21 +134,18 @@ bool8 CheckPathBetweenTrainerAndPlayer(struct MapObject2 *trainerObj, u8 playerC u8 i; u8 var; - if ( !playerCoord ) + if (!playerCoord) return FALSE; x = trainerObj->coords2.x; y = trainerObj->coords2.y; - for(i = 0; i <= playerCoord - 1;) + for (i = 0; i <= playerCoord - 1; i++, MoveCoords(direction, &x, &y)) { var = sub_8060024((struct MapObject *)trainerObj, x, y, direction); - if (var != 0 && (var & 1) != 0 ) + if (var && (var & COLLISION_MASK)) return FALSE; - - i++; - MoveCoords(direction, &x, &y); } // preserve mapobj_unk_19 before clearing. @@ -154,7 +158,7 @@ bool8 CheckPathBetweenTrainerAndPlayer(struct MapObject2 *trainerObj, u8 playerC trainerObj->mapobj_unk_19 = unk19_temp; trainerObj->mapobj_unk_19b = unk19b_temp; - if ( var == 4 ) + if (var == 4) return playerCoord; return FALSE; @@ -173,7 +177,7 @@ void sub_80842FC(TaskFunc func) { TaskFunc func2 = RunTrainerSeeFuncList; u8 taskId = FindTaskIdByFunc(func2); - + SetTaskFuncWithFollowupFunc(taskId, RunTrainerSeeFuncList, func); gTasks[taskId].data[0] = 1; func2(taskId); @@ -201,7 +205,7 @@ s8 sub_8084398(u8 taskId, struct Task *task, struct MapObject *trainerObj) FieldObjectGetLocalIdAndMap(trainerObj, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); FieldEffectStart(0); - + direction = GetFaceDirectionAnimId(trainerObj->mapobj_unk_18); FieldObjectSetSpecialAnim(trainerObj, direction); @@ -228,7 +232,7 @@ s8 sub_808441C(u8 taskId, struct Task *task, struct MapObject *trainerObj) { if (!(FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(trainerObj)) || FieldObjectClearAnimIfSpecialAnimFinished(trainerObj)) { - if(task->data[3]) + if (task->data[3]) { FieldObjectSetSpecialAnim(trainerObj, GetGoSpeed0AnimId(trainerObj->mapobj_unk_18)); task->data[3]--; @@ -267,17 +271,17 @@ s8 sub_8084478(u8 taskId, struct Task *task, struct MapObject *trainerObj) s8 sub_8084534(u8 taskId, struct Task *task, struct MapObject *trainerObj) // technically only 1 parameter, but needs all 3 for TrainerSeeFuncList call. { struct MapObject *playerObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + if ( !FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(playerObj) || FieldObjectClearAnimIfSpecialAnimFinished(playerObj) ) SwitchTaskToFollowupFunc(taskId); - + return 0; } s8 sub_8084578(u8 taskId, struct Task *task, struct MapObject *trainerObj) { - if(!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(trainerObj) + if (!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(trainerObj) || FieldObjectClearAnimIfSpecialAnimFinished(trainerObj)) { FieldObjectSetSpecialAnim(trainerObj, 0x59); @@ -290,13 +294,13 @@ s8 sub_80845AC(u8 taskId, struct Task *task, struct MapObject *trainerObj) { if ( FieldObjectClearAnimIfSpecialAnimFinished(trainerObj) ) task->data[0] = 3; - + return 0; } s8 sub_80845C8(u8 taskId, struct Task *task, struct MapObject *trainerObj) { - if(!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(trainerObj) + if (!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(trainerObj) || FieldObjectClearAnimIfSpecialAnimFinished(trainerObj)) { FieldObjectSetSpecialAnim(trainerObj, 0x3E); @@ -307,7 +311,7 @@ s8 sub_80845C8(u8 taskId, struct Task *task, struct MapObject *trainerObj) s8 sub_80845FC(u8 taskId, struct Task *task, struct MapObject *trainerObj) { - if(FieldObjectCheckIfSpecialAnimFinishedOrInactive(trainerObj)) + if (FieldObjectCheckIfSpecialAnimFinishedOrInactive(trainerObj)) { gUnknown_0202FF84[0] = trainerObj->coords2.x; gUnknown_0202FF84[1] = trainerObj->coords2.y; @@ -323,11 +327,11 @@ s8 sub_8084654(u8 taskId, struct Task *task, struct MapObject *trainerObj) { struct Sprite *sprite; - if(gSprites[task->data[4]].animCmdIndex == 2) + if (gSprites[task->data[4]].animCmdIndex == 2) { trainerObj->mapobj_bit_26 = 0; trainerObj->mapobj_bit_2 = 1; - + sprite = &gSprites[trainerObj->spriteId]; sprite->oam.priority = 2; FieldObjectClearAnimIfSpecialAnimFinished(trainerObj); @@ -339,7 +343,7 @@ s8 sub_8084654(u8 taskId, struct Task *task, struct MapObject *trainerObj) s8 sub_80846C8(u8 taskId, struct Task *task, struct MapObject *trainerObj) { - if(!FieldEffectActiveListContains(49)) + if (!FieldEffectActiveListContains(49)) task->data[0] = 3; return 0; @@ -352,13 +356,13 @@ void sub_80846E4(u8 taskId) // another mapObj loaded into by loadword? LoadWordFromTwoHalfwords(&task->data[1], (u32 *)&mapObj); - if(!task->data[7]) + if (!task->data[7]) { FieldObjectClearAnim(mapObj); task->data[7]++; } gTrainerSeeFuncList2[task->data[0]](taskId, task, mapObj); - if(task->data[0] == 3 && !FieldEffectActiveListContains(49)) + if (task->data[0] == 3 && !FieldEffectActiveListContains(49)) { npc_set_running_behaviour_etc(mapObj, npc_running_behaviour_by_direction(mapObj->mapobj_unk_18)); sub_805C774(mapObj, npc_running_behaviour_by_direction(mapObj->mapobj_unk_18)); @@ -368,9 +372,9 @@ void sub_80846E4(u8 taskId) mapObj->mapobj_bit_7 = 0; } -void sub_8084794(u32 var) +void sub_8084794(struct MapObject *var) { - StoreWordInTwoHalfwords(&gTasks[CreateTask(sub_80846E4, 0)].data[1], var); + StoreWordInTwoHalfwords(&gTasks[CreateTask(sub_80846E4, 0)].data[1], (u32)var); } void sub_80847C8(void) @@ -383,3 +387,71 @@ void sub_80847D8(u8 taskId) DestroyTask(taskId); EnableBothScriptContexts(); } + +u8 FldEff_ExclamationMarkIcon1(void) +{ + u8 spriteId = CreateSpriteAtEnd(&gSpriteTemplate_839B510, 0, 0, 0x53); + + if (spriteId != 64) + sub_8084894(&gSprites[spriteId], 0, 0); + + return 0; +} + +u8 FldEff_ExclamationMarkIcon2(void) +{ + u8 spriteId = CreateSpriteAtEnd(&gSpriteTemplate_839B510, 0, 0, 0x52); + + if (spriteId != 64) + sub_8084894(&gSprites[spriteId], 33, 1); + + return 0; +} + +u8 FldEff_HeartIcon(void) +{ + u8 spriteId = CreateSpriteAtEnd(&gSpriteTemplate_839B528, 0, 0, 0x52); + + if (spriteId != 64) + sub_8084894(&gSprites[spriteId], 46, 0); + + return 0; +} + +void sub_8084894(struct Sprite *sprite, u16 a2, u8 a3) +{ + sprite->oam.priority = 1; + sprite->coordOffsetEnabled = 1; + + sprite->data0 = gUnknown_0202FF84[0]; + sprite->data1 = gUnknown_0202FF84[1]; + sprite->data2 = gUnknown_0202FF84[2]; + sprite->data3 = -5; + sprite->data7 = a2; + + StartSpriteAnim(sprite, a3); +} + +void objc_exclamation_mark_probably(struct Sprite *sprite) +{ + u8 mapObjId; + + if (TryGetFieldObjectIdByLocalIdAndMap(sprite->data0, sprite->data1, sprite->data2, &mapObjId) + || sprite->animEnded) + { + FieldEffectStop(sprite, (u8)sprite->data7); + } + else + { + struct Sprite *mapObjSprite = &gSprites[gMapObjects[mapObjId].spriteId]; + sprite->data4 += sprite->data3; + sprite->pos1.x = mapObjSprite->pos1.x; + sprite->pos1.y = mapObjSprite->pos1.y - 16; + sprite->pos2.x = mapObjSprite->pos2.x; + sprite->pos2.y = mapObjSprite->pos2.y + sprite->data4; + if (sprite->data4) + sprite->data3++; + else + sprite->data3 = 0; + } +} diff --git a/src/trig.c b/src/trig.c index 8b75b3838..e16a69e63 100644 --- a/src/trig.c +++ b/src/trig.c @@ -1,8 +1,521 @@ #include "global.h" #include "trig.h" -extern s16 gSineTable[]; -extern s16 gSineDegreeTable[]; +// Converts a number to Q8.8 fixed-point format +#define Q_8_8(n) ((s16)((n) * 256)) + +// Converts a number to Q4.12 fixed-point format +#define Q_4_12(n) ((s16)((n) * 4096)) + +// Values of sin(x*(π/128)) as Q8.8 fixed-point numbers from x = 0 to x = 319 +const s16 gSineTable[] = +{ + Q_8_8(0), // sin(0*(π/128)) + Q_8_8(0.0234375), // sin(1*(π/128)) + Q_8_8(0.046875), // sin(2*(π/128)) + Q_8_8(0.0703125), // sin(3*(π/128)) + Q_8_8(0.09765625), // sin(4*(π/128)) + Q_8_8(0.12109375), // sin(5*(π/128)) + Q_8_8(0.14453125), // sin(6*(π/128)) + Q_8_8(0.16796875), // sin(7*(π/128)) + Q_8_8(0.19140625), // sin(8*(π/128)) + Q_8_8(0.21875), // sin(9*(π/128)) + Q_8_8(0.2421875), // sin(10*(π/128)) + Q_8_8(0.265625), // sin(11*(π/128)) + Q_8_8(0.2890625), // sin(12*(π/128)) + Q_8_8(0.3125), // sin(13*(π/128)) + Q_8_8(0.3359375), // sin(14*(π/128)) + Q_8_8(0.359375), // sin(15*(π/128)) + Q_8_8(0.37890625), // sin(16*(π/128)) + Q_8_8(0.40234375), // sin(17*(π/128)) + Q_8_8(0.42578125), // sin(18*(π/128)) + Q_8_8(0.44921875), // sin(19*(π/128)) + Q_8_8(0.46875), // sin(20*(π/128)) + Q_8_8(0.4921875), // sin(21*(π/128)) + Q_8_8(0.51171875), // sin(22*(π/128)) + Q_8_8(0.53125), // sin(23*(π/128)) + Q_8_8(0.5546875), // sin(24*(π/128)) + Q_8_8(0.57421875), // sin(25*(π/128)) + Q_8_8(0.59375), // sin(26*(π/128)) + Q_8_8(0.61328125), // sin(27*(π/128)) + Q_8_8(0.6328125), // sin(28*(π/128)) + Q_8_8(0.65234375), // sin(29*(π/128)) + Q_8_8(0.66796875), // sin(30*(π/128)) + Q_8_8(0.6875), // sin(31*(π/128)) + Q_8_8(0.70703125), // sin(32*(π/128)) + Q_8_8(0.72265625), // sin(33*(π/128)) + Q_8_8(0.73828125), // sin(34*(π/128)) + Q_8_8(0.75390625), // sin(35*(π/128)) + Q_8_8(0.76953125), // sin(36*(π/128)) + Q_8_8(0.78515625), // sin(37*(π/128)) + Q_8_8(0.80078125), // sin(38*(π/128)) + Q_8_8(0.81640625), // sin(39*(π/128)) + Q_8_8(0.828125), // sin(40*(π/128)) + Q_8_8(0.84375), // sin(41*(π/128)) + Q_8_8(0.85546875), // sin(42*(π/128)) + Q_8_8(0.8671875), // sin(43*(π/128)) + Q_8_8(0.87890625), // sin(44*(π/128)) + Q_8_8(0.890625), // sin(45*(π/128)) + Q_8_8(0.90234375), // sin(46*(π/128)) + Q_8_8(0.9140625), // sin(47*(π/128)) + Q_8_8(0.921875), // sin(48*(π/128)) + Q_8_8(0.9296875), // sin(49*(π/128)) + Q_8_8(0.94140625), // sin(50*(π/128)) + Q_8_8(0.94921875), // sin(51*(π/128)) + Q_8_8(0.953125), // sin(52*(π/128)) + Q_8_8(0.9609375), // sin(53*(π/128)) + Q_8_8(0.96875), // sin(54*(π/128)) + Q_8_8(0.97265625), // sin(55*(π/128)) + Q_8_8(0.98046875), // sin(56*(π/128)) + Q_8_8(0.984375), // sin(57*(π/128)) + Q_8_8(0.98828125), // sin(58*(π/128)) + Q_8_8(0.9921875), // sin(59*(π/128)) + Q_8_8(0.9921875), // sin(60*(π/128)) + Q_8_8(0.99609375), // sin(61*(π/128)) + Q_8_8(0.99609375), // sin(62*(π/128)) + Q_8_8(0.99609375), // sin(63*(π/128)) + Q_8_8(1), // sin(64*(π/128)) + Q_8_8(0.99609375), // sin(65*(π/128)) + Q_8_8(0.99609375), // sin(66*(π/128)) + Q_8_8(0.99609375), // sin(67*(π/128)) + Q_8_8(0.9921875), // sin(68*(π/128)) + Q_8_8(0.9921875), // sin(69*(π/128)) + Q_8_8(0.98828125), // sin(70*(π/128)) + Q_8_8(0.984375), // sin(71*(π/128)) + Q_8_8(0.98046875), // sin(72*(π/128)) + Q_8_8(0.97265625), // sin(73*(π/128)) + Q_8_8(0.96875), // sin(74*(π/128)) + Q_8_8(0.9609375), // sin(75*(π/128)) + Q_8_8(0.953125), // sin(76*(π/128)) + Q_8_8(0.94921875), // sin(77*(π/128)) + Q_8_8(0.94140625), // sin(78*(π/128)) + Q_8_8(0.9296875), // sin(79*(π/128)) + Q_8_8(0.921875), // sin(80*(π/128)) + Q_8_8(0.9140625), // sin(81*(π/128)) + Q_8_8(0.90234375), // sin(82*(π/128)) + Q_8_8(0.890625), // sin(83*(π/128)) + Q_8_8(0.87890625), // sin(84*(π/128)) + Q_8_8(0.8671875), // sin(85*(π/128)) + Q_8_8(0.85546875), // sin(86*(π/128)) + Q_8_8(0.84375), // sin(87*(π/128)) + Q_8_8(0.828125), // sin(88*(π/128)) + Q_8_8(0.81640625), // sin(89*(π/128)) + Q_8_8(0.80078125), // sin(90*(π/128)) + Q_8_8(0.78515625), // sin(91*(π/128)) + Q_8_8(0.76953125), // sin(92*(π/128)) + Q_8_8(0.75390625), // sin(93*(π/128)) + Q_8_8(0.73828125), // sin(94*(π/128)) + Q_8_8(0.72265625), // sin(95*(π/128)) + Q_8_8(0.70703125), // sin(96*(π/128)) + Q_8_8(0.6875), // sin(97*(π/128)) + Q_8_8(0.66796875), // sin(98*(π/128)) + Q_8_8(0.65234375), // sin(99*(π/128)) + Q_8_8(0.6328125), // sin(100*(π/128)) + Q_8_8(0.61328125), // sin(101*(π/128)) + Q_8_8(0.59375), // sin(102*(π/128)) + Q_8_8(0.57421875), // sin(103*(π/128)) + Q_8_8(0.5546875), // sin(104*(π/128)) + Q_8_8(0.53125), // sin(105*(π/128)) + Q_8_8(0.51171875), // sin(106*(π/128)) + Q_8_8(0.4921875), // sin(107*(π/128)) + Q_8_8(0.46875), // sin(108*(π/128)) + Q_8_8(0.44921875), // sin(109*(π/128)) + Q_8_8(0.42578125), // sin(110*(π/128)) + Q_8_8(0.40234375), // sin(111*(π/128)) + Q_8_8(0.37890625), // sin(112*(π/128)) + Q_8_8(0.359375), // sin(113*(π/128)) + Q_8_8(0.3359375), // sin(114*(π/128)) + Q_8_8(0.3125), // sin(115*(π/128)) + Q_8_8(0.2890625), // sin(116*(π/128)) + Q_8_8(0.265625), // sin(117*(π/128)) + Q_8_8(0.2421875), // sin(118*(π/128)) + Q_8_8(0.21875), // sin(119*(π/128)) + Q_8_8(0.19140625), // sin(120*(π/128)) + Q_8_8(0.16796875), // sin(121*(π/128)) + Q_8_8(0.14453125), // sin(122*(π/128)) + Q_8_8(0.12109375), // sin(123*(π/128)) + Q_8_8(0.09765625), // sin(124*(π/128)) + Q_8_8(0.0703125), // sin(125*(π/128)) + Q_8_8(0.046875), // sin(126*(π/128)) + Q_8_8(0.0234375), // sin(127*(π/128)) + Q_8_8(0), // sin(128*(π/128)) + Q_8_8(-0.0234375), // sin(129*(π/128)) + Q_8_8(-0.046875), // sin(130*(π/128)) + Q_8_8(-0.0703125), // sin(131*(π/128)) + Q_8_8(-0.09765625), // sin(132*(π/128)) + Q_8_8(-0.12109375), // sin(133*(π/128)) + Q_8_8(-0.14453125), // sin(134*(π/128)) + Q_8_8(-0.16796875), // sin(135*(π/128)) + Q_8_8(-0.19140625), // sin(136*(π/128)) + Q_8_8(-0.21875), // sin(137*(π/128)) + Q_8_8(-0.2421875), // sin(138*(π/128)) + Q_8_8(-0.265625), // sin(139*(π/128)) + Q_8_8(-0.2890625), // sin(140*(π/128)) + Q_8_8(-0.3125), // sin(141*(π/128)) + Q_8_8(-0.3359375), // sin(142*(π/128)) + Q_8_8(-0.359375), // sin(143*(π/128)) + Q_8_8(-0.37890625), // sin(144*(π/128)) + Q_8_8(-0.40234375), // sin(145*(π/128)) + Q_8_8(-0.42578125), // sin(146*(π/128)) + Q_8_8(-0.44921875), // sin(147*(π/128)) + Q_8_8(-0.46875), // sin(148*(π/128)) + Q_8_8(-0.4921875), // sin(149*(π/128)) + Q_8_8(-0.51171875), // sin(150*(π/128)) + Q_8_8(-0.53125), // sin(151*(π/128)) + Q_8_8(-0.5546875), // sin(152*(π/128)) + Q_8_8(-0.57421875), // sin(153*(π/128)) + Q_8_8(-0.59375), // sin(154*(π/128)) + Q_8_8(-0.61328125), // sin(155*(π/128)) + Q_8_8(-0.6328125), // sin(156*(π/128)) + Q_8_8(-0.65234375), // sin(157*(π/128)) + Q_8_8(-0.66796875), // sin(158*(π/128)) + Q_8_8(-0.6875), // sin(159*(π/128)) + Q_8_8(-0.70703125), // sin(160*(π/128)) + Q_8_8(-0.72265625), // sin(161*(π/128)) + Q_8_8(-0.73828125), // sin(162*(π/128)) + Q_8_8(-0.75390625), // sin(163*(π/128)) + Q_8_8(-0.76953125), // sin(164*(π/128)) + Q_8_8(-0.78515625), // sin(165*(π/128)) + Q_8_8(-0.80078125), // sin(166*(π/128)) + Q_8_8(-0.81640625), // sin(167*(π/128)) + Q_8_8(-0.828125), // sin(168*(π/128)) + Q_8_8(-0.84375), // sin(169*(π/128)) + Q_8_8(-0.85546875), // sin(170*(π/128)) + Q_8_8(-0.8671875), // sin(171*(π/128)) + Q_8_8(-0.87890625), // sin(172*(π/128)) + Q_8_8(-0.890625), // sin(173*(π/128)) + Q_8_8(-0.90234375), // sin(174*(π/128)) + Q_8_8(-0.9140625), // sin(175*(π/128)) + Q_8_8(-0.921875), // sin(176*(π/128)) + Q_8_8(-0.9296875), // sin(177*(π/128)) + Q_8_8(-0.94140625), // sin(178*(π/128)) + Q_8_8(-0.94921875), // sin(179*(π/128)) + Q_8_8(-0.953125), // sin(180*(π/128)) + Q_8_8(-0.9609375), // sin(181*(π/128)) + Q_8_8(-0.96875), // sin(182*(π/128)) + Q_8_8(-0.97265625), // sin(183*(π/128)) + Q_8_8(-0.98046875), // sin(184*(π/128)) + Q_8_8(-0.984375), // sin(185*(π/128)) + Q_8_8(-0.98828125), // sin(186*(π/128)) + Q_8_8(-0.9921875), // sin(187*(π/128)) + Q_8_8(-0.9921875), // sin(188*(π/128)) + Q_8_8(-0.99609375), // sin(189*(π/128)) + Q_8_8(-0.99609375), // sin(190*(π/128)) + Q_8_8(-0.99609375), // sin(191*(π/128)) + Q_8_8(-1), // sin(192*(π/128)) + Q_8_8(-0.99609375), // sin(193*(π/128)) + Q_8_8(-0.99609375), // sin(194*(π/128)) + Q_8_8(-0.99609375), // sin(195*(π/128)) + Q_8_8(-0.9921875), // sin(196*(π/128)) + Q_8_8(-0.9921875), // sin(197*(π/128)) + Q_8_8(-0.98828125), // sin(198*(π/128)) + Q_8_8(-0.984375), // sin(199*(π/128)) + Q_8_8(-0.98046875), // sin(200*(π/128)) + Q_8_8(-0.97265625), // sin(201*(π/128)) + Q_8_8(-0.96875), // sin(202*(π/128)) + Q_8_8(-0.9609375), // sin(203*(π/128)) + Q_8_8(-0.953125), // sin(204*(π/128)) + Q_8_8(-0.94921875), // sin(205*(π/128)) + Q_8_8(-0.94140625), // sin(206*(π/128)) + Q_8_8(-0.9296875), // sin(207*(π/128)) + Q_8_8(-0.921875), // sin(208*(π/128)) + Q_8_8(-0.9140625), // sin(209*(π/128)) + Q_8_8(-0.90234375), // sin(210*(π/128)) + Q_8_8(-0.890625), // sin(211*(π/128)) + Q_8_8(-0.87890625), // sin(212*(π/128)) + Q_8_8(-0.8671875), // sin(213*(π/128)) + Q_8_8(-0.85546875), // sin(214*(π/128)) + Q_8_8(-0.84375), // sin(215*(π/128)) + Q_8_8(-0.828125), // sin(216*(π/128)) + Q_8_8(-0.81640625), // sin(217*(π/128)) + Q_8_8(-0.80078125), // sin(218*(π/128)) + Q_8_8(-0.78515625), // sin(219*(π/128)) + Q_8_8(-0.76953125), // sin(220*(π/128)) + Q_8_8(-0.75390625), // sin(221*(π/128)) + Q_8_8(-0.73828125), // sin(222*(π/128)) + Q_8_8(-0.72265625), // sin(223*(π/128)) + Q_8_8(-0.70703125), // sin(224*(π/128)) + Q_8_8(-0.6875), // sin(225*(π/128)) + Q_8_8(-0.66796875), // sin(226*(π/128)) + Q_8_8(-0.65234375), // sin(227*(π/128)) + Q_8_8(-0.6328125), // sin(228*(π/128)) + Q_8_8(-0.61328125), // sin(229*(π/128)) + Q_8_8(-0.59375), // sin(230*(π/128)) + Q_8_8(-0.57421875), // sin(231*(π/128)) + Q_8_8(-0.5546875), // sin(232*(π/128)) + Q_8_8(-0.53125), // sin(233*(π/128)) + Q_8_8(-0.51171875), // sin(234*(π/128)) + Q_8_8(-0.4921875), // sin(235*(π/128)) + Q_8_8(-0.46875), // sin(236*(π/128)) + Q_8_8(-0.44921875), // sin(237*(π/128)) + Q_8_8(-0.42578125), // sin(238*(π/128)) + Q_8_8(-0.40234375), // sin(239*(π/128)) + Q_8_8(-0.37890625), // sin(240*(π/128)) + Q_8_8(-0.359375), // sin(241*(π/128)) + Q_8_8(-0.3359375), // sin(242*(π/128)) + Q_8_8(-0.3125), // sin(243*(π/128)) + Q_8_8(-0.2890625), // sin(244*(π/128)) + Q_8_8(-0.265625), // sin(245*(π/128)) + Q_8_8(-0.2421875), // sin(246*(π/128)) + Q_8_8(-0.21875), // sin(247*(π/128)) + Q_8_8(-0.19140625), // sin(248*(π/128)) + Q_8_8(-0.16796875), // sin(249*(π/128)) + Q_8_8(-0.14453125), // sin(250*(π/128)) + Q_8_8(-0.12109375), // sin(251*(π/128)) + Q_8_8(-0.09765625), // sin(252*(π/128)) + Q_8_8(-0.0703125), // sin(253*(π/128)) + Q_8_8(-0.046875), // sin(254*(π/128)) + Q_8_8(-0.0234375), // sin(255*(π/128)) + Q_8_8(0), // sin(256*(π/128)) + Q_8_8(0.0234375), // sin(257*(π/128)) + Q_8_8(0.046875), // sin(258*(π/128)) + Q_8_8(0.0703125), // sin(259*(π/128)) + Q_8_8(0.09765625), // sin(260*(π/128)) + Q_8_8(0.12109375), // sin(261*(π/128)) + Q_8_8(0.14453125), // sin(262*(π/128)) + Q_8_8(0.16796875), // sin(263*(π/128)) + Q_8_8(0.19140625), // sin(264*(π/128)) + Q_8_8(0.21875), // sin(265*(π/128)) + Q_8_8(0.2421875), // sin(266*(π/128)) + Q_8_8(0.265625), // sin(267*(π/128)) + Q_8_8(0.2890625), // sin(268*(π/128)) + Q_8_8(0.3125), // sin(269*(π/128)) + Q_8_8(0.3359375), // sin(270*(π/128)) + Q_8_8(0.359375), // sin(271*(π/128)) + Q_8_8(0.37890625), // sin(272*(π/128)) + Q_8_8(0.40234375), // sin(273*(π/128)) + Q_8_8(0.42578125), // sin(274*(π/128)) + Q_8_8(0.44921875), // sin(275*(π/128)) + Q_8_8(0.46875), // sin(276*(π/128)) + Q_8_8(0.4921875), // sin(277*(π/128)) + Q_8_8(0.51171875), // sin(278*(π/128)) + Q_8_8(0.53125), // sin(279*(π/128)) + Q_8_8(0.5546875), // sin(280*(π/128)) + Q_8_8(0.57421875), // sin(281*(π/128)) + Q_8_8(0.59375), // sin(282*(π/128)) + Q_8_8(0.61328125), // sin(283*(π/128)) + Q_8_8(0.6328125), // sin(284*(π/128)) + Q_8_8(0.65234375), // sin(285*(π/128)) + Q_8_8(0.66796875), // sin(286*(π/128)) + Q_8_8(0.6875), // sin(287*(π/128)) + Q_8_8(0.70703125), // sin(288*(π/128)) + Q_8_8(0.72265625), // sin(289*(π/128)) + Q_8_8(0.73828125), // sin(290*(π/128)) + Q_8_8(0.75390625), // sin(291*(π/128)) + Q_8_8(0.76953125), // sin(292*(π/128)) + Q_8_8(0.78515625), // sin(293*(π/128)) + Q_8_8(0.80078125), // sin(294*(π/128)) + Q_8_8(0.81640625), // sin(295*(π/128)) + Q_8_8(0.828125), // sin(296*(π/128)) + Q_8_8(0.84375), // sin(297*(π/128)) + Q_8_8(0.85546875), // sin(298*(π/128)) + Q_8_8(0.8671875), // sin(299*(π/128)) + Q_8_8(0.87890625), // sin(300*(π/128)) + Q_8_8(0.890625), // sin(301*(π/128)) + Q_8_8(0.90234375), // sin(302*(π/128)) + Q_8_8(0.9140625), // sin(303*(π/128)) + Q_8_8(0.921875), // sin(304*(π/128)) + Q_8_8(0.9296875), // sin(305*(π/128)) + Q_8_8(0.94140625), // sin(306*(π/128)) + Q_8_8(0.94921875), // sin(307*(π/128)) + Q_8_8(0.953125), // sin(308*(π/128)) + Q_8_8(0.9609375), // sin(309*(π/128)) + Q_8_8(0.96875), // sin(310*(π/128)) + Q_8_8(0.97265625), // sin(311*(π/128)) + Q_8_8(0.98046875), // sin(312*(π/128)) + Q_8_8(0.984375), // sin(313*(π/128)) + Q_8_8(0.98828125), // sin(314*(π/128)) + Q_8_8(0.9921875), // sin(315*(π/128)) + Q_8_8(0.9921875), // sin(316*(π/128)) + Q_8_8(0.99609375), // sin(317*(π/128)) + Q_8_8(0.99609375), // sin(318*(π/128)) + Q_8_8(0.99609375), // sin(319*(π/128)) +}; + +// values of sin(x) as Q4.12 fixed-point numbers from x = 0° to x = 179° +const s16 gSineDegreeTable[] = +{ + Q_4_12(0), // sin(0°) + Q_4_12(0.017333984375), // sin(1°) + Q_4_12(0.034912109375), // sin(2°) + Q_4_12(0.05224609375), // sin(3°) + Q_4_12(0.06982421875), // sin(4°) + Q_4_12(0.087158203125), // sin(5°) + Q_4_12(0.1044921875), // sin(6°) + Q_4_12(0.121826171875), // sin(7°) + Q_4_12(0.13916015625), // sin(8°) + Q_4_12(0.156494140625), // sin(9°) + Q_4_12(0.173583984375), // sin(10°) + Q_4_12(0.19091796875), // sin(11°) + Q_4_12(0.2080078125), // sin(12°) + Q_4_12(0.224853515625), // sin(13°) + Q_4_12(0.241943359375), // sin(14°) + Q_4_12(0.2587890625), // sin(15°) + Q_4_12(0.275634765625), // sin(16°) + Q_4_12(0.29248046875), // sin(17°) + Q_4_12(0.30908203125), // sin(18°) + Q_4_12(0.32568359375), // sin(19°) + Q_4_12(0.342041015625), // sin(20°) + Q_4_12(0.3583984375), // sin(21°) + Q_4_12(0.37451171875), // sin(22°) + Q_4_12(0.390625), // sin(23°) + Q_4_12(0.40673828125), // sin(24°) + Q_4_12(0.422607421875), // sin(25°) + Q_4_12(0.4384765625), // sin(26°) + Q_4_12(0.4541015625), // sin(27°) + Q_4_12(0.469482421875), // sin(28°) + Q_4_12(0.48486328125), // sin(29°) + Q_4_12(0.5), // sin(30°) + Q_4_12(0.51513671875), // sin(31°) + Q_4_12(0.530029296875), // sin(32°) + Q_4_12(0.544677734375), // sin(33°) + Q_4_12(0.55908203125), // sin(34°) + Q_4_12(0.573486328125), // sin(35°) + Q_4_12(0.587890625), // sin(36°) + Q_4_12(0.601806640625), // sin(37°) + Q_4_12(0.61572265625), // sin(38°) + Q_4_12(0.62939453125), // sin(39°) + Q_4_12(0.642822265625), // sin(40°) + Q_4_12(0.656005859375), // sin(41°) + Q_4_12(0.669189453125), // sin(42°) + Q_4_12(0.681884765625), // sin(43°) + Q_4_12(0.694580078125), // sin(44°) + Q_4_12(0.70703125), // sin(45°) + Q_4_12(0.71923828125), // sin(46°) + Q_4_12(0.7314453125), // sin(47°) + Q_4_12(0.7431640625), // sin(48°) + Q_4_12(0.754638671875), // sin(49°) + Q_4_12(0.76611328125), // sin(50°) + Q_4_12(0.777099609375), // sin(51°) + Q_4_12(0.7880859375), // sin(52°) + Q_4_12(0.798583984375), // sin(53°) + Q_4_12(0.80908203125), // sin(54°) + Q_4_12(0.819091796875), // sin(55°) + Q_4_12(0.8291015625), // sin(56°) + Q_4_12(0.838623046875), // sin(57°) + Q_4_12(0.84814453125), // sin(58°) + Q_4_12(0.857177734375), // sin(59°) + Q_4_12(0.865966796875), // sin(60°) + Q_4_12(0.87451171875), // sin(61°) + Q_4_12(0.883056640625), // sin(62°) + Q_4_12(0.89111328125), // sin(63°) + Q_4_12(0.898681640625), // sin(64°) + Q_4_12(0.90625), // sin(65°) + Q_4_12(0.91357421875), // sin(66°) + Q_4_12(0.92041015625), // sin(67°) + Q_4_12(0.92724609375), // sin(68°) + Q_4_12(0.93359375), // sin(69°) + Q_4_12(0.939697265625), // sin(70°) + Q_4_12(0.945556640625), // sin(71°) + Q_4_12(0.951171875), // sin(72°) + Q_4_12(0.956298828125), // sin(73°) + Q_4_12(0.961181640625), // sin(74°) + Q_4_12(0.9658203125), // sin(75°) + Q_4_12(0.97021484375), // sin(76°) + Q_4_12(0.974365234375), // sin(77°) + Q_4_12(0.97802734375), // sin(78°) + Q_4_12(0.981689453125), // sin(79°) + Q_4_12(0.98486328125), // sin(80°) + Q_4_12(0.98779296875), // sin(81°) + Q_4_12(0.990234375), // sin(82°) + Q_4_12(0.992431640625), // sin(83°) + Q_4_12(0.994384765625), // sin(84°) + Q_4_12(0.99609375), // sin(85°) + Q_4_12(0.99755859375), // sin(86°) + Q_4_12(0.99853515625), // sin(87°) + Q_4_12(0.999267578125), // sin(88°) + Q_4_12(0.999755859375), // sin(89°) + Q_4_12(1), // sin(90°) + Q_4_12(0.999755859375), // sin(91°) + Q_4_12(0.999267578125), // sin(92°) + Q_4_12(0.99853515625), // sin(93°) + Q_4_12(0.99755859375), // sin(94°) + Q_4_12(0.99609375), // sin(95°) + Q_4_12(0.994384765625), // sin(96°) + Q_4_12(0.992431640625), // sin(97°) + Q_4_12(0.990234375), // sin(98°) + Q_4_12(0.98779296875), // sin(99°) + Q_4_12(0.98486328125), // sin(100°) + Q_4_12(0.981689453125), // sin(101°) + Q_4_12(0.97802734375), // sin(102°) + Q_4_12(0.974365234375), // sin(103°) + Q_4_12(0.97021484375), // sin(104°) + Q_4_12(0.9658203125), // sin(105°) + Q_4_12(0.961181640625), // sin(106°) + Q_4_12(0.956298828125), // sin(107°) + Q_4_12(0.951171875), // sin(108°) + Q_4_12(0.945556640625), // sin(109°) + Q_4_12(0.939697265625), // sin(110°) + Q_4_12(0.93359375), // sin(111°) + Q_4_12(0.92724609375), // sin(112°) + Q_4_12(0.92041015625), // sin(113°) + Q_4_12(0.91357421875), // sin(114°) + Q_4_12(0.90625), // sin(115°) + Q_4_12(0.898681640625), // sin(116°) + Q_4_12(0.89111328125), // sin(117°) + Q_4_12(0.883056640625), // sin(118°) + Q_4_12(0.87451171875), // sin(119°) + Q_4_12(0.865966796875), // sin(120°) + Q_4_12(0.857177734375), // sin(121°) + Q_4_12(0.84814453125), // sin(122°) + Q_4_12(0.838623046875), // sin(123°) + Q_4_12(0.8291015625), // sin(124°) + Q_4_12(0.819091796875), // sin(125°) + Q_4_12(0.80908203125), // sin(126°) + Q_4_12(0.798583984375), // sin(127°) + Q_4_12(0.7880859375), // sin(128°) + Q_4_12(0.777099609375), // sin(129°) + Q_4_12(0.76611328125), // sin(130°) + Q_4_12(0.754638671875), // sin(131°) + Q_4_12(0.7431640625), // sin(132°) + Q_4_12(0.7314453125), // sin(133°) + Q_4_12(0.71923828125), // sin(134°) + Q_4_12(0.70703125), // sin(135°) + Q_4_12(0.694580078125), // sin(136°) + Q_4_12(0.681884765625), // sin(137°) + Q_4_12(0.669189453125), // sin(138°) + Q_4_12(0.656005859375), // sin(139°) + Q_4_12(0.642822265625), // sin(140°) + Q_4_12(0.62939453125), // sin(141°) + Q_4_12(0.61572265625), // sin(142°) + Q_4_12(0.601806640625), // sin(143°) + Q_4_12(0.587890625), // sin(144°) + Q_4_12(0.573486328125), // sin(145°) + Q_4_12(0.55908203125), // sin(146°) + Q_4_12(0.544677734375), // sin(147°) + Q_4_12(0.530029296875), // sin(148°) + Q_4_12(0.51513671875), // sin(149°) + Q_4_12(0.5), // sin(150°) + Q_4_12(0.48486328125), // sin(151°) + Q_4_12(0.469482421875), // sin(152°) + Q_4_12(0.4541015625), // sin(153°) + Q_4_12(0.4384765625), // sin(154°) + Q_4_12(0.422607421875), // sin(155°) + Q_4_12(0.40673828125), // sin(156°) + Q_4_12(0.390625), // sin(157°) + Q_4_12(0.37451171875), // sin(158°) + Q_4_12(0.3583984375), // sin(159°) + Q_4_12(0.342041015625), // sin(160°) + Q_4_12(0.32568359375), // sin(161°) + Q_4_12(0.30908203125), // sin(162°) + Q_4_12(0.29248046875), // sin(163°) + Q_4_12(0.275634765625), // sin(164°) + Q_4_12(0.2587890625), // sin(165°) + Q_4_12(0.241943359375), // sin(166°) + Q_4_12(0.224853515625), // sin(167°) + Q_4_12(0.2080078125), // sin(168°) + Q_4_12(0.19091796875), // sin(169°) + Q_4_12(0.173583984375), // sin(170°) + Q_4_12(0.156494140625), // sin(171°) + Q_4_12(0.13916015625), // sin(172°) + Q_4_12(0.121826171875), // sin(173°) + Q_4_12(0.1044921875), // sin(174°) + Q_4_12(0.087158203125), // sin(175°) + Q_4_12(0.06982421875), // sin(176°) + Q_4_12(0.05224609375), // sin(177°) + Q_4_12(0.034912109375), // sin(178°) + Q_4_12(0.017333984375), // sin(179°) +}; // amplitude * sin(index*(π/128)) s16 Sin(s16 index, s16 amplitude) diff --git a/src/truck_scene.c b/src/truck_scene.c deleted file mode 100644 index 64eca498c..000000000 --- a/src/truck_scene.c +++ /dev/null @@ -1,220 +0,0 @@ -#include "global.h" -#include "truck_scene.h" -#include "asm.h" -#include "palette.h" -#include "task.h" -#include "script.h" -#include "songs.h" -#include "sound.h" -#include "field_camera.h" - -extern s8 gTruckCamera_HorizontalTable[]; - -s32 GetTruckCameraBobbingY(int a1) -{ - if (!(a1 % 120)) - return -1; - else if ((a1 % 10) <= 4) - return 1; - - return 0; -} - -s32 GetTruckBoxMovement(int a1) // for the box movement? -{ - if (!((a1 + 120) % 180)) - return -1; - - return 0; -} - -void Task_Truck1(u8 taskId) -{ - s16 *data = gTasks[taskId].data; - s16 cameraYpan; - s16 box1 = 0; - s16 box2 = 0; - s16 box3 = 0; - u8 mapNum, mapGroup; - register s16 zero asm("r4"); - - box1 = GetTruckBoxMovement(data[0] + 30) * 4; // box 1 happens 30 frames earlier than the other 2. - sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3, box1 + 3); - box2 = GetTruckBoxMovement(data[0]) * 2; - sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 0, box2 - 3); - box3 = GetTruckBoxMovement(data[0]) * 4; - mapNum = gSaveBlock1.location.mapNum; - mapGroup = gSaveBlock1.location.mapGroup; - zero = 0; - sub_805BD90(3, mapNum, mapGroup, -3, box3); - - data[0]++; - - if (data[0] == 0x7530) // timer? - data[0] = zero; - - cameraYpan = GetTruckCameraBobbingY(data[0]); - SetCameraPanning(0, cameraYpan); -} - -void Task_Truck2(u8 taskId) -{ - s16 *data = gTasks[taskId].data; - s16 cameraYpan; - s16 cameraXpan; - s16 box1; - s16 box2; - s16 box3; - - data[0]++; - data[2]++; - - if (data[0] > 5) - { - data[0] = 0; - data[1]++; - } - if ((u16)data[1] == 19) - { - DestroyTask(taskId); - } - else - { - if (gTruckCamera_HorizontalTable[data[1]] == 2) - gTasks[taskId].func = Task_Truck3; - - cameraXpan = gTruckCamera_HorizontalTable[data[1]]; - cameraYpan = GetTruckCameraBobbingY(data[2]); - SetCameraPanning(cameraXpan, cameraYpan); - box1 = GetTruckBoxMovement(data[2] + 30) * 4; - sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3 - cameraXpan, box1 + 3); - box2 = GetTruckBoxMovement(data[2]) * 2; - sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -cameraXpan, box2 - 3); - box3 = GetTruckBoxMovement(data[2]) * 4; - sub_805BD90(3, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -3 - cameraXpan, box3); - } -} - -void Task_Truck3(u8 taskId) -{ - s16 *data = gTasks[taskId].data; - s16 cameraXpan; - s16 cameraYpan; - - data[0]++; - - if (data[0] > 5) - { - data[0] = 0; - data[1]++; - } - - if ((u16)data[1] == 19) - { - DestroyTask(taskId); - } - else - { - cameraXpan = gTruckCamera_HorizontalTable[data[1]]; - cameraYpan = 0; - SetCameraPanning(cameraXpan, 0); - sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3 - cameraXpan, cameraYpan + 3); - sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -cameraXpan, cameraYpan - 3); - sub_805BD90(3, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -3 - cameraXpan, cameraYpan); - } -} - -void Task_HandleTruckSequence(u8 taskId) -{ - s16 *data = gTasks[taskId].data; - - switch (data[0]) - { - /* - Each case has a timer which is handled with data[1], incrementing - until it reaches the if function's condition, which sets the next task up. - */ - case 0: - data[1]++; - if (data[1] == 90) - { - SetCameraPanningCallback(0); - data[1] = 0; // reset the timer. - data[2] = CreateTask(Task_Truck1, 0xA); - data[0] = 1; // run the next case. - PlaySE(SE_TRACK_MOVE); - } - break; - case 1: - data[1]++; - if (data[1] == 150) - { - pal_fill_black(); - data[1] = 0; - data[0] = 2; - } - break; - case 2: - data[1]++; - if(!gPaletteFade.active && data[1] > 300) - { - data[1] = 0; - DestroyTask(data[2]); - data[3] = CreateTask(Task_Truck2, 0xA); - data[0] = 3; - PlaySE(SE_TRACK_STOP); - } - break; - case 3: - if (!gTasks[data[3]].isActive) // is Truck2 no longer active (is Truck3 active?) - { - InstallCameraPanAheadCallback(); - data[1] = 0; - data[0] = 4; - } - break; - case 4: - data[1]++; - if (data[1] == 90) - { - PlaySE(SE_TRACK_HAIK); - data[1] = 0; - data[0] = 5; - } - break; - case 5: - data[1]++; - if (data[1] == 120) - { - MapGridSetMetatileIdAt(11, 8, 520); - MapGridSetMetatileIdAt(11, 9, 528); - MapGridSetMetatileIdAt(11, 10, 536); - DrawWholeMapView(); - PlaySE(SE_TRACK_DOOR); - DestroyTask(taskId); - ScriptContext2_Disable(); - } - break; - } -} - -void ExecuteTruckSequence(void) -{ - MapGridSetMetatileIdAt(11, 8, 525); - MapGridSetMetatileIdAt(11, 9, 533); - MapGridSetMetatileIdAt(11, 10, 541); - DrawWholeMapView(); - ScriptContext2_Enable(); - CpuFastFill(0, gPlttBufferFaded, 0x400); - CreateTask(Task_HandleTruckSequence, 0xA); -} - -void EndTruckSequence(void) -{ - if (!FuncIsActiveTask(Task_HandleTruckSequence)) - { - sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3, 3); - sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 0, -3); - sub_805BD90(3, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -3, 0); - } -} diff --git a/src/tv.c b/src/tv.c new file mode 100644 index 000000000..4bd11a9b9 --- /dev/null +++ b/src/tv.c @@ -0,0 +1,3788 @@ +#include "global.h" +#include "tv.h" +#include "battle_tower.h" +#include "contest_painting.h" +#include "data2.h" +#include "easy_chat.h" +#include "event_data.h" +#include "fieldmap.h" +#include "field_message_box.h" +#include "field_camera.h" +#include "flags.h" +#include "rng.h" +#include "string_util.h" +#include "text.h" +#include "species.h" +#include "pokedex.h" +#include "naming_screen.h" +#include "rom4.h" +#include "map_constants.h" +#include "strings.h" +#include "battle.h" +#include "link.h" +#include "easy_chat.h" +#include "field_map_obj.h" +#include "field_specials.h" +#include "item.h" +#include "items.h" +#include "link.h" +#include "map_constants.h" +#include "naming_screen.h" +#include "pokedex.h" +#include "region_map.h" +#include "rng.h" +#include "rom4.h" +#include "rtc.h" +#include "script_menu.h" +#include "species.h" +#include "string_util.h" +#include "strings.h" +#include "text.h" + +struct UnkTvStruct +{ + s8 var0; +}; + +extern struct Struct30042E0 gBattleResults; +extern u8 gUnknown_0300430A[11]; + +struct OutbreakPokemon +{ + /*0x00*/ u16 species; + /*0x02*/ u16 moves[4]; + /*0x0A*/ u8 level; + /*0x0B*/ u8 location; +}; + +struct TVSaleItem { + u16 item_id; + u16 item_amount; +}; + +extern u8 gUnknown_02038694; + +extern struct TVSaleItem gUnknown_02038724[3]; + +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u16 gSpecialVar_0x8006; +extern u8 gSpecialVar_0x8007; +extern u16 gScriptResult; +extern u8 gUnknown_020387E8; + +extern struct UnkTvStruct gUnknown_03005D38; + +extern u8 *gTVBravoTrainerTextGroup[]; +extern u8 *gTVBravoTrainerBattleTowerTextGroup[]; +extern u8 *gTVSmartShopperTextGroup[]; +extern u8 *gTVNameRaterTextGroup[]; +extern u8 *gTVPokemonTodayTextGroup[]; +extern u8 *gTVPokemonTodayFailedCaptureTextGroup[]; +extern u8 *gTVFanClubTextGroup[]; +extern u8 *gTVRecentHappeningsTextGroup[]; +extern u8 *gTVFanClubOpinionsTextGroup[]; +extern u8 *gTVPokemonOutbreakTextGroup[]; +extern u8 *gTVGabbyAndTyTextGroup[]; +extern u8 *gTVFishingGuruAdviceTextGroup[]; +extern u8 *gTVWorldOfMastersTextGroup[]; +extern struct OutbreakPokemon gPokeOutbreakSpeciesList[5]; + +extern u16 gUnknown_020387E0; +extern u16 gUnknown_020387E2; + +extern const u8 *gTVNewsTextGroup1[]; +extern const u8 *gTVNewsTextGroup2[]; +extern const u8 *gTVNewsTextGroup3[]; + +extern u16 gScriptLastTalked; + + +extern u8 gScriptContestCategory; +extern u8 gScriptContestRank; +extern u8 gUnknown_03004316[11]; +extern u8 gBattleOutcome; + +extern u16 gLastUsedItem; + +extern u8 ewram[]; +#define gUnknown_02007000 (*(ewramStruct_02007000 *)(ewram + 0x7000)) +extern u8 gUnknown_020387E4; + +extern u8 gUnknown_03000720; +extern s8 gUnknown_03000722; + +void ClearTVShowData(void) +{ + u8 showidx; + u8 extradataidx; + for (showidx=0; showidx<25; showidx++) { + gSaveBlock1.tvShows[showidx].common.var00 = 0; + gSaveBlock1.tvShows[showidx].common.var01 = 0; + for (extradataidx=0; extradataidx<34; extradataidx++) { + gSaveBlock1.tvShows[showidx].common.pad02[extradataidx] = 0; + } + } + sub_80BEBF4(); +} + +bool8 sub_80BF1B4(u8); +void sub_80BF20C(void); +extern u16 sub_8135D3C(u8); +extern u8 gScriptContestCategory; +extern u8 gScriptContestRank; +extern u8 gUnknown_03004316[11]; +extern u8 gBattleOutcome; + +void sub_80BF334(void); +void sub_80BF3A4(void); +void sub_80BF3DC(void); +void sub_80BF46C(void); +void sub_80BF478(void); +void sub_80BF484(void); +void sub_80BF4BC(void); + +void sub_80BE028(void); +void sub_80BE074(void); +void sub_80BE778(void); +void sub_80BEB20(void); + +u8 sub_80BFB54(u8); + +s8 sub_80BF74C(TVShow tvShow[]); + +void sub_80BF55C(TVShow tvShow[], u8 showidx); +void sub_80BEA88(void); + +void sub_80BE138(TVShow *show); +void sub_80BE160(TVShow *show); +extern u16 gLastUsedItem; + +void sub_80BE5FC(void); +void sub_80BE65C(void); +void sub_80BE6A0(void); +void nullsub_21(void); +void sub_80BE188(void); +void sub_80BE320(void); + +#ifdef NONMATCHING +u8 special_0x44(void) +{ + u8 i; + u8 j; + u8 var01; + TVShow *tvShow; + for (i=5; i<24; i++) + { + if (gSaveBlock1.tvShows[i].common.var00 == 0) + { + break; + } + } + i = Random() % i; + j = i; + do + { + if (sub_80BFB54(gSaveBlock1.tvShows[i].common.var00) != 4) + { + var01 = gSaveBlock1.tvShows[i].common.var01; + } else + { + tvShow = &gSaveBlock1.tvShows[i]; + if (tvShow->massOutbreak.var16 != 0) { + continue; + } else { + var01 = tvShow->common.var01; + } + } + if (var01 == 1) + { + return i; + } + } while (i == 0 ? i = 23 : i --, i != j); + return 0xff; +} +#else +__attribute__((naked)) +u8 special_0x44(void) +{ + asm(".syntax unified\n" + " push {r4-r7,lr}\n" + " mov r7, r9\n" + " mov r6, r8\n" + " push {r6,r7}\n" + " movs r4, 0x5\n" + " ldr r1, _080BD874 @ =gSaveBlock1\n" + " ldr r2, _080BD878 @ =0x000027ec\n" + " adds r0, r1, r2\n" + " ldrb r0, [r0]\n" + " cmp r0, 0\n" + " beq _080BD834\n" + " adds r2, r1, 0\n" + " ldr r1, _080BD87C @ =0x00002738\n" + "_080BD81A:\n" + " adds r0, r4, 0x1\n" + " lsls r0, 24\n" + " lsrs r4, r0, 24\n" + " cmp r4, 0x17\n" + " bhi _080BD834\n" + " lsls r0, r4, 3\n" + " adds r0, r4\n" + " lsls r0, 2\n" + " adds r0, r2\n" + " adds r0, r1\n" + " ldrb r0, [r0]\n" + " cmp r0, 0\n" + " bne _080BD81A\n" + "_080BD834:\n" + " bl Random\n" + " lsls r0, 16\n" + " lsrs r0, 16\n" + " adds r1, r4, 0\n" + " bl __modsi3\n" + " lsls r0, 24\n" + " lsrs r4, r0, 24\n" + " mov r8, r4\n" + " ldr r7, _080BD874 @ =gSaveBlock1\n" + " ldr r0, _080BD87C @ =0x00002738\n" + " adds r0, r7\n" + " mov r9, r0\n" + "_080BD850:\n" + " lsls r0, r4, 3\n" + " adds r0, r4\n" + " lsls r6, r0, 2\n" + " adds r5, r6, r7\n" + " ldr r1, _080BD87C @ =0x00002738\n" + " adds r0, r5, r1\n" + " ldrb r0, [r0]\n" + " bl sub_80BFB54\n" + " lsls r0, 24\n" + " lsrs r0, 24\n" + " cmp r0, 0x4\n" + " beq _080BD884\n" + " ldr r2, _080BD880 @ =0x00002739\n" + " adds r0, r5, r2\n" + " ldrb r0, [r0]\n" + " b _080BD890\n" + " .align 2, 0\n" + "_080BD874: .4byte gSaveBlock1\n" + "_080BD878: .4byte 0x000027ec\n" + "_080BD87C: .4byte 0x00002738\n" + "_080BD880: .4byte 0x00002739\n" + "_080BD884:\n" + " mov r0, r9\n" + " adds r1, r6, r0\n" + " ldrh r0, [r1, 0x16]\n" + " cmp r0, 0\n" + " bne _080BD898\n" + " ldrb r0, [r1, 0x1]\n" + "_080BD890:\n" + " cmp r0, 0x1\n" + " bne _080BD898\n" + " adds r0, r4, 0\n" + " b _080BD8AC\n" + "_080BD898:\n" + " cmp r4, 0\n" + " bne _080BD8A0\n" + " movs r4, 0x17\n" + " b _080BD8A6\n" + "_080BD8A0:\n" + " subs r0, r4, 0x1\n" + " lsls r0, 24\n" + " lsrs r4, r0, 24\n" + "_080BD8A6:\n" + " cmp r4, r8\n" + " bne _080BD850\n" + " movs r0, 0xFF\n" + "_080BD8AC:\n" + " pop {r3,r4}\n" + " mov r8, r3\n" + " mov r9, r4\n" + " pop {r4-r7}\n" + " pop {r1}\n" + " bx r1\n" + ".syntax divided\n"); +} +#endif + +u8 sub_80BDA30(void); + +u8 sub_80BD8B8(void) +{ + u8 retval; + retval = special_0x44(); + if (retval == 0xff) + { + return 0xff; + } + if (gSaveBlock1.outbreakPokemonSpecies != 0 && gSaveBlock1.tvShows[retval].common.var00 == TVSHOW_MASS_OUTBREAK) + { + return sub_80BDA30(); + } + return retval; +} + +u8 CheckForBigMovieOrEmergencyNewsOnTV(void); +void SetTVMetatilesOnMap(int, int, u16); +bool8 sub_80BECA0(void); +bool8 IsTVShowInSearchOfTrainersAiring(void); + +void UpdateTVScreensOnMap(int width, int height) +{ + u8 bigMovieOrEmergencyNewsOnTv; + FlagSet(SYS_TV_WATCH); + bigMovieOrEmergencyNewsOnTv = CheckForBigMovieOrEmergencyNewsOnTV(); + switch (bigMovieOrEmergencyNewsOnTv) + { + case 1: + SetTVMetatilesOnMap(width, height, 0x3); + break; + case 2: + break; + default: + if (gSaveBlock1.location.mapGroup == MAP_GROUP_LILYCOVE_CITY_COVE_LILY_MOTEL_1F && gSaveBlock1.location.mapNum == MAP_ID_LILYCOVE_CITY_COVE_LILY_MOTEL_1F) + { + SetTVMetatilesOnMap(width, height, 0x3); + } + else if (FlagGet(SYS_TV_START) && (sub_80BD8B8() != 0xff || sub_80BECA0() != 0xff || IsTVShowInSearchOfTrainersAiring())) + { + FlagReset(SYS_TV_WATCH); + SetTVMetatilesOnMap(width, height, 0x3); + } + } +} + +void SetTVMetatilesOnMap(int width, int height, u16 tileId) +{ + int x; + int y; + for (y=0; y<height; y++) + { + for (x=0; x<width; x++) + { + if (MapGridGetMetatileBehaviorAt(x, y) == 0x86) + { + MapGridSetMetatileIdAt(x, y, tileId | 0xc00); + } + } + } +} + +void TurnOffTVScreen(void) +{ + SetTVMetatilesOnMap(gUnknown_03004870.width, gUnknown_03004870.height, 0x2); + DrawWholeMapView(); +} + +u8 sub_80BDA0C(void) +{ + return gSaveBlock1.tvShows[gSpecialVar_0x8004].common.var00; +} + +u8 sub_80BDA30(void) +{ + u8 showIdx; + for (showIdx=0; showIdx<24; showIdx++) + { + if (gSaveBlock1.tvShows[showIdx].common.var00 != 0 && gSaveBlock1.tvShows[showIdx].common.var00 != TVSHOW_MASS_OUTBREAK && gSaveBlock1.tvShows[showIdx].common.var01 == 1) + { + return showIdx; + } + } + return 0xff; +} + +u8 special_0x4a(void) +{ + TVShow *tvShow; + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + if (tvShow->common.var00 == TVSHOW_MASS_OUTBREAK && gSaveBlock1.outbreakPokemonSpecies) + { + return sub_80BDA30(); + } + return gSpecialVar_0x8004; +} + +void ResetGabbyAndTy(void) +{ + gSaveBlock1.gabbyAndTyData.mon1 = 0; + gSaveBlock1.gabbyAndTyData.mon2 = 0; + gSaveBlock1.gabbyAndTyData.lastMove = 0; + gSaveBlock1.gabbyAndTyData.quote = 0xffff; + gSaveBlock1.gabbyAndTyData.valA_0 = 0; + gSaveBlock1.gabbyAndTyData.valA_1 = 0; + gSaveBlock1.gabbyAndTyData.valA_2 = 0; + gSaveBlock1.gabbyAndTyData.valA_3 = 0; + gSaveBlock1.gabbyAndTyData.valA_4 = 0; + gSaveBlock1.gabbyAndTyData.valA_5 = 0; + gSaveBlock1.gabbyAndTyData.valB_0 = 0; + gSaveBlock1.gabbyAndTyData.valB_1 = 0; + gSaveBlock1.gabbyAndTyData.valB_2 = 0; + gSaveBlock1.gabbyAndTyData.valB_3 = 0; + gSaveBlock1.gabbyAndTyData.valB_4 = 0; + gSaveBlock1.gabbyAndTyData.valB_5 = 0; + gSaveBlock1.gabbyAndTyData.mapnum = 0; + gSaveBlock1.gabbyAndTyData.battleNum = 0; +} + +void TakeTVShowInSearchOfTrainersOffTheAir(void); + +void GabbyAndTyBeforeInterview(void) +{ + u8 i; + gSaveBlock1.gabbyAndTyData.mon1 = gBattleResults.unk6; + gSaveBlock1.gabbyAndTyData.mon2 = gBattleResults.unk26; + gSaveBlock1.gabbyAndTyData.lastMove = gBattleResults.unk22; + if (gSaveBlock1.gabbyAndTyData.battleNum != 0xff) + { + gSaveBlock1.gabbyAndTyData.battleNum ++; + } + gSaveBlock1.gabbyAndTyData.valA_0 = gBattleResults.unk5_0; + if (gBattleResults.unk0) + { + gSaveBlock1.gabbyAndTyData.valA_1 = 1; + } else + { + gSaveBlock1.gabbyAndTyData.valA_1 = 0; + } + if (gBattleResults.unk3) + { + gSaveBlock1.gabbyAndTyData.valA_2 = 1; + } else + { + gSaveBlock1.gabbyAndTyData.valA_2 = 0; + } + if (!gBattleResults.unk5_1) + { + for (i=0; i<11; i++) + { + if (gBattleResults.unk36[i] != 0) + { + gSaveBlock1.gabbyAndTyData.valA_3 = 1; + break; + } + } + } else + { + gSaveBlock1.gabbyAndTyData.valA_3 = 1; + } + TakeTVShowInSearchOfTrainersOffTheAir(); + if (gSaveBlock1.gabbyAndTyData.lastMove == 0) + { + FlagSet(1); + } +} + +void sub_80BDC14(void) +{ + gSaveBlock1.gabbyAndTyData.valB_0 = gSaveBlock1.gabbyAndTyData.valA_0; + gSaveBlock1.gabbyAndTyData.valB_1 = gSaveBlock1.gabbyAndTyData.valA_1; + gSaveBlock1.gabbyAndTyData.valB_2 = gSaveBlock1.gabbyAndTyData.valA_2; + gSaveBlock1.gabbyAndTyData.valB_3 = gSaveBlock1.gabbyAndTyData.valA_3; + gSaveBlock1.gabbyAndTyData.valA_4 = 1; + gSaveBlock1.gabbyAndTyData.mapnum = gMapHeader.name; + IncrementGameStat(GAME_STAT_GOT_INTERVIEWED); +} + +void TakeTVShowInSearchOfTrainersOffTheAir(void) +{ + gSaveBlock1.gabbyAndTyData.valA_4 = 0; +} + +u8 GabbyAndTyGetBattleNum(void) +{ + if (gSaveBlock1.gabbyAndTyData.battleNum >= 6) + { + return (gSaveBlock1.gabbyAndTyData.battleNum % 3) + 6; + } + return gSaveBlock1.gabbyAndTyData.battleNum; +} + +bool8 IsTVShowInSearchOfTrainersAiring(void) +{ + return gSaveBlock1.gabbyAndTyData.valA_4; +} + +bool8 GabbyAndTyGetLastQuote(void) +{ + if (gSaveBlock1.gabbyAndTyData.quote == 0xffff) + { + return FALSE; + } + sub_80EB3FC(gStringVar1, gSaveBlock1.gabbyAndTyData.quote); + gSaveBlock1.gabbyAndTyData.quote |= 0xffff; + return TRUE; +} + +u8 sub_80BDD18(void) +{ + if (!gSaveBlock1.gabbyAndTyData.valB_0) + { + return 1; + } + if (gSaveBlock1.gabbyAndTyData.valB_3) + { + return 2; + } + if (gSaveBlock1.gabbyAndTyData.valB_2) + { + return 3; + } + if (gSaveBlock1.gabbyAndTyData.valB_1) + { + return 4; + } + return 0; +} + +void GabbyAndTySetScriptVarsToFieldObjectLocalIds(void) { + switch (GabbyAndTyGetBattleNum()) { + case 1: + gSpecialVar_0x8004 = 0xE; + gSpecialVar_0x8005 = 0xD; + break; + case 2: + gSpecialVar_0x8004 = 0x5; + gSpecialVar_0x8005 = 0x6; + break; + case 3: + gSpecialVar_0x8004 = 0x12; + gSpecialVar_0x8005 = 0x11; + break; + case 4: + gSpecialVar_0x8004 = 0x15; + gSpecialVar_0x8005 = 0x16; + break; + case 5: + gSpecialVar_0x8004 = 0x8; + gSpecialVar_0x8005 = 0x9; + break; + case 6: + gSpecialVar_0x8004 = 0x13; + gSpecialVar_0x8005 = 0x14; + break; + case 7: + gSpecialVar_0x8004 = 0x17; + gSpecialVar_0x8005 = 0x18; + break; + case 8: + gSpecialVar_0x8004 = 0xA; + gSpecialVar_0x8005 = 0xB; + break; + } +} + +void sub_80BDE48(void) { + switch (gSpecialVar_0x8005) { + case TVSHOW_FAN_CLUB_LETTER: + sub_80BE5FC(); + break; + case TVSHOW_RECENT_HAPPENINGS: + sub_80BE65C(); + break; + case TVSHOW_PKMN_FAN_CLUB_OPINIONS: + sub_80BE6A0(); + break; + case TVSHOW_UNKN_SHOWTYPE_04: + nullsub_21(); + break; + case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: + sub_80BE188(); + break; + case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: + sub_80BE320(); + break; + } +} + +u8 sub_80BDEAC(u8 *a0) { + u8 lang; + lang = GAME_LANGUAGE; + if (a0[0] == 0xFC && a0[1] == 0x15) { + lang = LANGUAGE_JAPANESE; + } + return lang; +} + +void sub_80BDEC8(void) { + TVShow *show; + u8 i; + u16 total; + u16 item; + total = 0; + sub_80BEB20(); + sub_80BE778(); + if (gBattleResults.unk28 == 0) { + sub_80BE074(); + } else { + sub_80BE028(); + if (sub_80BF77C(0xffff) == 0 && StringCompareWithoutExtCtrlCodes(gSpeciesNames[gBattleResults.unk28], gBattleResults.unk2A) != 0) { + gUnknown_03005D38.var0 = sub_80BF74C(gSaveBlock1.tvShows); + if (gUnknown_03005D38.var0 != -1 && sub_80BF1B4(TVSHOW_POKEMON_TODAY_CAUGHT) != 1) { + for (i=0; i<11; i++) { + total += gBattleResults.unk36[i]; + } + if (total != 0 || gBattleResults.unk5_1 != 0) { + total = FALSE; + show = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + show->pokemonToday.var00 = TVSHOW_POKEMON_TODAY_CAUGHT; + show->pokemonToday.var01 = total; + if (gBattleResults.unk5_1 != 0) { + total = 1; + item = ITEM_MASTER_BALL; + } else { + for (i=0; i<11; i++) { + total += gBattleResults.unk36[i]; + } + if (total > 0xff) { + total = 0xff; + } + item = gLastUsedItem; + } + show->pokemonToday.var12 = total; + show->pokemonToday.ball = item; + StringCopy(show->pokemonToday.playerName, gSaveBlock2.playerName); + StringCopy(show->pokemonToday.nickname, gBattleResults.unk2A); + show->pokemonToday.species = gBattleResults.unk28; + sub_80BE138(show); + show->pokemonToday.language = GAME_LANGUAGE; + show->pokemonToday.language2 = sub_80BDEAC(show->pokemonToday.nickname); + StripExtCtrlCodes(show->pokemonToday.nickname); + } + } + } + } +} + +void sub_80BE028(void) { + TVShow *buffer; + buffer = &gSaveBlock1.tvShows[24]; + if (buffer->worldOfMasters.var00 != TVSHOW_WORLD_OF_MASTERS) { + sub_80BF55C(gSaveBlock1.tvShows, 24); + buffer->worldOfMasters.var06 = GetGameStat(GAME_STAT_STEPS); + buffer->worldOfMasters.var00 = TVSHOW_WORLD_OF_MASTERS; + } + buffer->worldOfMasters.var02++; + buffer->worldOfMasters.var04 = gBattleResults.unk28; + buffer->worldOfMasters.var08 = gBattleResults.unk6; + buffer->worldOfMasters.var0a = gMapHeader.name; +} + +#ifdef NONMATCHING +void sub_80BE074(void) { + u8 i; + u16 total; + u8 flag; + TVShow *show; + if (sub_80BF77C(0xffff) == 0) { + for (i=0, total=0; i<ARRAY_COUNT(gUnknown_03004316); i++) { + total += gUnknown_03004316[i]; + } + if (total > 0xff) { + total = 0xff; + } + if (total > 2 && gBattleOutcome == 1) { + gUnknown_03005D38.var0 = sub_80BF74C(gSaveBlock1.tvShows); + if (gUnknown_03005D38.var0 != -1 && sub_80BF1B4(TVSHOW_POKEMON_TODAY_FAILED) != 1) { + flag = FALSE; + show = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + asm_comment("Here the wrong registers are used to hold the show ID and flag."); + show->pokemonTodayFailed.var00 = TVSHOW_POKEMON_TODAY_FAILED; + show->pokemonTodayFailed.var01 = flag; + show->pokemonTodayFailed.species = gBattleResults.unk6; + show->pokemonTodayFailed.species2 = gBattleResults.unk20; + show->pokemonTodayFailed.var10 = total; + show->pokemonTodayFailed.var11 = gBattleOutcome; + show->pokemonTodayFailed.var12 = gMapHeader.name; + StringCopy(show->pokemonTodayFailed.playerName, gSaveBlock2.playerName); + sub_80BE138(show); + show->pokemonTodayFailed.language = GAME_LANGUAGE; + } + } + } +} +#else +__attribute__((naked)) +void sub_80BE074(void) { + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + ldr r0, _080BE118 @ =0x0000ffff\n\ + bl sub_80BF77C\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _080BE112\n\ + movs r1, 0\n\ + movs r5, 0\n\ + ldr r2, _080BE11C @ =gUnknown_03004316\n\ +_080BE088:\n\ + adds r0, r1, r2\n\ + ldrb r0, [r0]\n\ + adds r0, r5, r0\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + adds r0, r1, 0x1\n\ + lsls r0, 24\n\ + lsrs r1, r0, 24\n\ + cmp r1, 0xA\n\ + bls _080BE088\n\ + cmp r5, 0xFF\n\ + bls _080BE0A2\n\ + movs r5, 0xFF\n\ +_080BE0A2:\n\ + cmp r5, 0x2\n\ + bls _080BE112\n\ + ldr r7, _080BE120 @ =gBattleOutcome\n\ + ldrb r0, [r7]\n\ + cmp r0, 0x1\n\ + bne _080BE112\n\ + ldr r6, _080BE124 @ =gSaveBlock1 + 0x2738\n\ + adds r0, r6, 0\n\ + bl sub_80BF74C\n\ + ldr r4, _080BE128 @ =gUnknown_03005D38\n\ + strb r0, [r4]\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + movs r1, 0x1\n\ + negs r1, r1\n\ + cmp r0, r1\n\ + beq _080BE112\n\ + movs r0, 0x17\n\ + bl sub_80BF1B4\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + beq _080BE112\n\ + movs r0, 0\n\ + ldrsb r0, [r4, r0]\n\ + lsls r4, r0, 3\n\ + adds r4, r0\n\ + lsls r4, 2\n\ + adds r4, r6\n\ + @ -- Here the compiler puts the status flag in the wrong register. --\n\ + movs r1, 0\n\ + movs r0, 0x17\n\ + strb r0, [r4]\n\ + strb r1, [r4, 0x1]\n\ + ldr r1, _080BE12C @ =gBattleResults\n\ + ldrh r0, [r1, 0x6]\n\ + strh r0, [r4, 0xC]\n\ + ldrh r0, [r1, 0x20]\n\ + strh r0, [r4, 0xE]\n\ + strb r5, [r4, 0x10]\n\ + ldrb r0, [r7]\n\ + strb r0, [r4, 0x11]\n\ + ldr r0, _080BE130 @ =gMapHeader\n\ + ldrb r0, [r0, 0x14]\n\ + strb r0, [r4, 0x12]\n\ + adds r0, r4, 0\n\ + adds r0, 0x13\n\ + ldr r1, _080BE134 @ =gSaveBlock2\n\ + bl StringCopy\n\ + adds r0, r4, 0\n\ + bl sub_80BE138\n"); +#if ENGLISH + asm("movs r0, 2 @ GAME_LANGUAGE\n"); +#elif GERMAN + asm("movs r0, 5 @ GAME_LANGUAGE\n"); +#endif + asm("strb r0, [r4, 0x2]\n\ +_080BE112:\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_080BE118: .4byte 0x0000ffff\n\ +_080BE11C: .4byte gUnknown_03004316\n\ +_080BE120: .4byte gBattleOutcome\n\ +_080BE124: .4byte gSaveBlock1 + 0x2738\n\ +_080BE128: .4byte gUnknown_03005D38\n\ +_080BE12C: .4byte gBattleResults\n\ +_080BE130: .4byte gMapHeader\n\ +_080BE134: .4byte gSaveBlock2\n\ +.syntax divided\n"); +} +#endif + +void sub_80BE138(TVShow *show) { + u32 playerId; + playerId = GetPlayerTrainerId(); + show->common.srcTrainerId2Lo = playerId & 0xFF; + show->common.srcTrainerId2Hi = playerId >> 8; + show->common.srcTrainerIdLo = playerId & 0xFF; + show->common.srcTrainerIdHi = playerId >> 8; + show->common.trainerIdLo = playerId & 0xFF; + show->common.trainerIdHi = playerId >> 8; +} + +void sub_80BE160(TVShow *show) { + u32 playerId; + playerId = GetPlayerTrainerId(); + show->common.srcTrainerIdLo = playerId & 0xFF; + show->common.srcTrainerIdHi = playerId >> 8; + show->common.trainerIdLo = playerId & 0xFF; + show->common.trainerIdHi = playerId >> 8; +} + +void sub_80BE188(void) { + TVShow *show; + TVShow *buffer; + buffer = &gSaveBlock1.tvShows[24]; + if (buffer->bravoTrainer.var00 == TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE) { + show = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + show->bravoTrainer.var00 = TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE; + show->bravoTrainer.var01 = 1; + show->bravoTrainer.species = buffer->bravoTrainer.species; + StringCopy(show->bravoTrainer.playerName, gSaveBlock2.playerName); + StringCopy(show->bravoTrainer.pokemonNickname, buffer->bravoTrainer.pokemonNickname); + show->bravoTrainer.contestCategory = buffer->bravoTrainer.contestCategory; + show->bravoTrainer.contestRank = buffer->bravoTrainer.contestRank; + show->bravoTrainer.var14 = buffer->bravoTrainer.var14; + show->bravoTrainer.contestResult = buffer->bravoTrainer.contestResult; + show->bravoTrainer.contestCategory = buffer->bravoTrainer.contestCategory; + sub_80BE160(show); + show->bravoTrainer.language = GAME_LANGUAGE; + show->bravoTrainer.var1f = sub_80BDEAC(show->bravoTrainer.pokemonNickname); + StripExtCtrlCodes(show->bravoTrainer.pokemonNickname); + } +} + +void sub_80BE23C(u16 a0) { + TVShow *show; + show = &gSaveBlock1.tvShows[24]; + sub_80BF484(); + gUnknown_03005D38.var0 = sub_80BF720(gSaveBlock1.tvShows); + if (gUnknown_03005D38.var0 != -1) { + sub_80BF55C(gSaveBlock1.tvShows, 24); + show->bravoTrainer.var14 = a0; + show->bravoTrainer.var00 = TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE; + } +} + +void sub_80BE284(u8 a0) { + TVShow *show; + show = &gSaveBlock1.tvShows[24]; + gUnknown_03005D38.var0 = sub_80BF720(gSaveBlock1.tvShows); + if (gUnknown_03005D38.var0 != -1) { + show->bravoTrainer.contestResult = a0; + show->bravoTrainer.contestCategory = gScriptContestCategory; + show->bravoTrainer.contestRank = gScriptContestRank; + show->bravoTrainer.species = GetMonData(&gPlayerParty[gUnknown_02038694], MON_DATA_SPECIES, NULL); + GetMonData(&gPlayerParty[gUnknown_02038694], MON_DATA_NICKNAME, show->bravoTrainer.pokemonNickname); + } +} + +void sub_80BE320(void) { + TVShow *show; + show = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + show->bravoTrainerTower.var00 = TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE; + show->bravoTrainerTower.var01 = 1; + StringCopy(show->bravoTrainerTower.trainerName, gSaveBlock2.playerName); + StringCopy(show->bravoTrainerTower.pokemonName, gSaveBlock2.filler_A8.filler_3DC); + show->bravoTrainerTower.species = gSaveBlock2.filler_A8.var_480; + show->bravoTrainerTower.defeatedSpecies = gSaveBlock2.filler_A8.var_482; + show->bravoTrainerTower.var16 = sub_8135D3C(gSaveBlock2.filler_A8.var_4D0); + show->bravoTrainerTower.var1c = gSaveBlock2.filler_A8.var_4AD; + if (gSaveBlock2.filler_A8.var_4D0 == 0) { + show->bravoTrainerTower.btLevel = 50; + } else { + show->bravoTrainerTower.btLevel = 100; + } + show->bravoTrainerTower.var1b = gSpecialVar_0x8004; + sub_80BE160(show); + show->bravoTrainerTower.language = GAME_LANGUAGE; +} + +void sub_80BE3BC(void) { + u8 rval; + TVShow *tvShow; + u8 i; + + rval = sub_80BF77C(0x5555); + if (rval == 0) { + gUnknown_03005D38.var0 = sub_80BF74C(gSaveBlock1.tvShows); + if (gUnknown_03005D38.var0 != -1 && sub_80BF1B4(TVSHOW_SMART_SHOPPER) != 1) { + sub_80BF20C(); + if (gUnknown_02038724[0].item_amount >= 20) { + tvShow = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + tvShow->smartshopperShow.var00 = TVSHOW_SMART_SHOPPER; + tvShow->smartshopperShow.var01 = rval; + tvShow->smartshopperShow.shopLocation = gMapHeader.name; + for (i=0; i<3; i++) { + tvShow->smartshopperShow.itemIds[i] = gUnknown_02038724[i].item_id; + tvShow->smartshopperShow.itemAmounts[i] = gUnknown_02038724[i].item_amount; + } + tvShow->smartshopperShow.priceReduced = GetPriceReduction(1); + StringCopy(tvShow->smartshopperShow.playerName, gSaveBlock2.playerName); + sub_80BE138(tvShow); + tvShow->smartshopperShow.language = GAME_LANGUAGE; + } + } + } +} + +void sub_80BE478(void) +{ + u16 playerNameLength; + u16 pokemonNicknameLength; + TVShow *tvShow; + + sub_80BF478(); + + if (gScriptResult == 1) + { + return; + } + + GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar1); + + playerNameLength = StringLength(gSaveBlock2.playerName); + if (playerNameLength <= 1) + { + return; + } + + pokemonNicknameLength = StringLength(gStringVar1); + if (pokemonNicknameLength <= 1) + { + return; + } + + tvShow = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + + tvShow->nameRaterShow.var00 = TVSHOW_NAME_RATER_SHOW; + tvShow->nameRaterShow.var01 = 1; + + tvShow->nameRaterShow.species = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES, NULL); + tvShow->nameRaterShow.random = Random() % 3; + tvShow->nameRaterShow.random2 = Random() % 2; + + tvShow->nameRaterShow.var1C = sub_80BF674(tvShow->nameRaterShow.species); + + StringCopy(tvShow->nameRaterShow.trainerName, gSaveBlock2.playerName); + + GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, tvShow->nameRaterShow.pokemonName); + + sub_80BE160(tvShow); + + tvShow->nameRaterShow.language = GAME_LANGUAGE; + tvShow->nameRaterShow.pokemonNameLanguage = sub_80BDEAC(tvShow->nameRaterShow.pokemonName); + + StripExtCtrlCodes(tvShow->nameRaterShow.pokemonName); +} + +void StartMassOutbreak(void) +{ + TVShow *tvShow; + + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + + gSaveBlock1.outbreakPokemonSpecies = tvShow->massOutbreak.species; + gSaveBlock1.outbreakLocationMapNum = tvShow->massOutbreak.locationMapNum; + gSaveBlock1.outbreakLocationMapGroup = tvShow->massOutbreak.locationMapGroup; + gSaveBlock1.outbreakPokemonLevel = tvShow->massOutbreak.level; + gSaveBlock1.outbreakUnk1 = tvShow->massOutbreak.var02; + gSaveBlock1.outbreakUnk2 = tvShow->massOutbreak.var0E; + gSaveBlock1.outbreakPokemonMoves[0] = tvShow->massOutbreak.moves[0]; + gSaveBlock1.outbreakPokemonMoves[1] = tvShow->massOutbreak.moves[1]; + gSaveBlock1.outbreakPokemonMoves[2] = tvShow->massOutbreak.moves[2]; + gSaveBlock1.outbreakPokemonMoves[3] = tvShow->massOutbreak.moves[3]; + gSaveBlock1.outbreakUnk4 = tvShow->massOutbreak.var03; + gSaveBlock1.outbreakPokemonProbability = tvShow->massOutbreak.probability; + gSaveBlock1.outbreakUnk5 = 2; +} + +void sub_80BE5FC(void) +{ + TVShow *tvShow; + u16 species; + + tvShow = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + + tvShow->fanclubLetter.var00 = TVSHOW_FAN_CLUB_LETTER; + tvShow->fanclubLetter.var01 = 1; + StringCopy(tvShow->fanclubLetter.playerName, gSaveBlock2.playerName); + + species = GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, NULL); + tvShow->fanclubLetter.species = species; + sub_80BE160(tvShow); + tvShow->fanclubLetter.language = GAME_LANGUAGE; +} + +void sub_80BE65C(void) +{ + TVShow *tvShow; + + tvShow = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + + tvShow->recentHappenings.var00 = TVSHOW_RECENT_HAPPENINGS; + tvShow->recentHappenings.var01 = 1; + StringCopy(tvShow->recentHappenings.playerName, gSaveBlock2.playerName); + tvShow->recentHappenings.var02 = 0; + + sub_80BE160(tvShow); + tvShow->recentHappenings.language = GAME_LANGUAGE; +} + +void sub_80BE6A0(void) +{ + TVShow *tvShow; + u8 monIndex; + + tvShow = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + + tvShow->fanclubOpinions.var00 = TVSHOW_PKMN_FAN_CLUB_OPINIONS; + tvShow->fanclubOpinions.var01 = 1; + + monIndex = GetLeadMonIndex(); + + tvShow->fanclubOpinions.var04A = GetMonData(&gPlayerParty[monIndex], MON_DATA_FRIENDSHIP, NULL) / 16; + tvShow->fanclubOpinions.var04B = gSpecialVar_0x8007; + + + StringCopy(tvShow->fanclubOpinions.playerName, gSaveBlock2.playerName); + + GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_NICKNAME, tvShow->fanclubOpinions.var10); + + tvShow->fanclubOpinions.var02 = GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, NULL); + sub_80BE160(tvShow); + tvShow->fanclubOpinions.language = GAME_LANGUAGE; + tvShow->fanclubOpinions.var0E = sub_80BDEAC(tvShow->fanclubOpinions.var10); + StripExtCtrlCodes(tvShow->fanclubOpinions.var10); +} + +void nullsub_21(void) +{ +} + +void sub_80BE778(void) +{ + u8 i; + + if (!FlagGet(SYS_GAME_CLEAR)) + { + return; + } + + + for (i = 0; i < 24; i++) + { + if (gSaveBlock1.tvShows[i].massOutbreak.var00 == TVSHOW_MASS_OUTBREAK) + { + return; + } + } + + if (sub_80BF77C(0x147)) + { + return; + } + + gUnknown_03005D38.var0 = sub_80BF720(gSaveBlock1.tvShows); + if (gUnknown_03005D38.var0 == -1) + { + return; + } + { + u16 rand; + u16 val; + s32 val2; + TVShow *tvShow; + + rand = Random(); + val = rand % 5; + + val2 = gUnknown_03005D38.var0; + + tvShow = &gSaveBlock1.tvShows[val2]; + + tvShow->massOutbreak.var00 = TVSHOW_MASS_OUTBREAK; + tvShow->massOutbreak.var01 = 1; + + tvShow->massOutbreak.level = gPokeOutbreakSpeciesList[val].level; + tvShow->massOutbreak.var02 = 0; + tvShow->massOutbreak.var03 = 0; + tvShow->massOutbreak.species = gPokeOutbreakSpeciesList[val].species; + tvShow->massOutbreak.var0E = 0; + tvShow->massOutbreak.moves[0] = gPokeOutbreakSpeciesList[val].moves[0]; + tvShow->massOutbreak.moves[1] = gPokeOutbreakSpeciesList[val].moves[1]; + tvShow->massOutbreak.moves[2] = gPokeOutbreakSpeciesList[val].moves[2]; + tvShow->massOutbreak.moves[3] = gPokeOutbreakSpeciesList[val].moves[3]; + tvShow->massOutbreak.locationMapNum = gPokeOutbreakSpeciesList[val].location; + tvShow->massOutbreak.locationMapGroup = 0; + tvShow->massOutbreak.var12 = 0; + tvShow->massOutbreak.probability = 0x32; + tvShow->massOutbreak.var15 = 0; + tvShow->massOutbreak.var16 = 0x01; + sub_80BE160(tvShow); + + tvShow->massOutbreak.language = GAME_LANGUAGE; + } +} + +void EndMassOutbreak(void) +{ + gSaveBlock1.outbreakPokemonSpecies = 0; + gSaveBlock1.outbreakLocationMapNum = 0; + gSaveBlock1.outbreakLocationMapGroup = 0; + gSaveBlock1.outbreakPokemonLevel = 0; + gSaveBlock1.outbreakUnk1 = 0; + gSaveBlock1.outbreakUnk2 = 0; + gSaveBlock1.outbreakPokemonMoves[0] = 0; + gSaveBlock1.outbreakPokemonMoves[1] = 0; + gSaveBlock1.outbreakPokemonMoves[2] = 0; + gSaveBlock1.outbreakPokemonMoves[3] = 0; + gSaveBlock1.outbreakUnk4 = 0; + gSaveBlock1.outbreakPokemonProbability = 0; + gSaveBlock1.outbreakUnk5 = 0; +} + +void UpdateTVShowsPerDay(u16 arg0) +{ + sub_80BE8EC(arg0); + UpdateMassOutbreakTimeLeft(arg0); + sub_80BEE84(arg0); + sub_80BEA5C(arg0); +} + +void sub_80BE8EC(u16 arg0) +{ + u8 showidx; + TVShow *tvShow; + if (gSaveBlock1.outbreakPokemonSpecies == 0) { + for (showidx=0; showidx<24; showidx++) { + if (gSaveBlock1.tvShows[showidx].massOutbreak.var00 == TVSHOW_MASS_OUTBREAK && gSaveBlock1.tvShows[showidx].massOutbreak.var01 == 0x01) { + tvShow = &(gSaveBlock1.tvShows[showidx]); + if (tvShow->massOutbreak.var16 < arg0) + tvShow->massOutbreak.var16 = 0; + else + tvShow->massOutbreak.var16 -= arg0; + break; + } + } + } +} + +void UpdateMassOutbreakTimeLeft(u16 arg0) +{ + if (gSaveBlock1.outbreakUnk5 <= arg0) + EndMassOutbreak(); + else + gSaveBlock1.outbreakUnk5 -= arg0; +} + +void sub_80BE97C(bool8 flag) +{ + u8 var0, var1; + if (flag != 0) { + var0 = gUnknown_020387E2 >> 8; + if (var0 > 4) + sub_80BE9D4(); + gUnknown_020387E2 &= 0xFF; + var1 = gUnknown_020387E2 & 0xFF; + if (var1 != 0xFF) + gUnknown_020387E2++; + } else { + var0 = gUnknown_020387E2 & 0xFF; + if (var0 > 4) + sub_80BE9D4(); + gUnknown_020387E2 &= 0xFF00; + var1 = gUnknown_020387E2 >> 8; + if (var1 != 0xFF) + gUnknown_020387E2 += 0x100; + } +} + +void sub_80BE9D4() +{ + TVShow *show; + gUnknown_03005D38.var0 = sub_80BF74C(gSaveBlock1.tvShows); + if (gUnknown_03005D38.var0 != -1 && sub_80BF1B4(TVSHOW_FISHING_ADVICE) != 1) { + show = &(gSaveBlock1.tvShows[gUnknown_03005D38.var0]); +#ifdef NONMATCHING + show->pokemonAngler.var00 = TVSHOW_FISHING_ADVICE; + show->pokemonAngler.var01 = 0; +#else + asm(".syntax unified\n\ + movs r1, 0\n\ + movs r0, 24\n\ + strb r0, [r4]\n\ + strb r1, [r4, 1]\n\ + .syntax divided\n"); +#endif + show->pokemonAngler.var02 = gUnknown_020387E2 & 0xFF; + show->pokemonAngler.var03 = gUnknown_020387E2 >> 8; + show->pokemonAngler.var04 = gUnknown_020387E0; + StringCopy(show->pokemonAngler.playerName, gSaveBlock2.playerName); + sub_80BE138(show); + show->pokemonAngler.language = GAME_LANGUAGE; + } +} + +void sub_80BEA50(u16 var) +{ + gUnknown_020387E0 = var; +} + +void sub_80BEA88(void); + +void sub_80BEA5C(u16 arg0) +{ + TVShow *unk_2a98; + unk_2a98 = &gSaveBlock1.tvShows[24]; + if (unk_2a98->common.var00 == TVSHOW_WORLD_OF_MASTERS) + { + if (unk_2a98->worldOfMasters.var02 < 20) + { + sub_80BF55C(gSaveBlock1.tvShows, 0x18); + } + else + { + sub_80BEA88(); + } + } +} +void sub_80BEA88(void) +{ + TVShow *unk_2a98; + TVShow *tvShow; + u8 rval; + unk_2a98 = &gSaveBlock1.tvShows[24]; + rval = sub_80BF77C(0xFFFF); + if (rval == 0) + { + gUnknown_03005D38.var0 = sub_80BF74C(gSaveBlock1.tvShows); + if (gUnknown_03005D38.var0 != -1 && sub_80BF1B4(TVSHOW_WORLD_OF_MASTERS) != 1) + { + tvShow = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + tvShow->worldOfMasters.var00 = TVSHOW_WORLD_OF_MASTERS; + tvShow->worldOfMasters.var01 = rval; + tvShow->worldOfMasters.var02 = unk_2a98->worldOfMasters.var02; + tvShow->worldOfMasters.var06 = GetGameStat(GAME_STAT_STEPS) - unk_2a98->worldOfMasters.var06; + tvShow->worldOfMasters.var04 = unk_2a98->worldOfMasters.var04; + tvShow->worldOfMasters.var08 = unk_2a98->worldOfMasters.var08; + tvShow->worldOfMasters.var0a = unk_2a98->worldOfMasters.var0a; + StringCopy(tvShow->worldOfMasters.playerName, gSaveBlock2.playerName); + sub_80BE138(tvShow); + tvShow->worldOfMasters.language = GAME_LANGUAGE; + } + } +} + +void sub_80BEB20(void) { + u16 rval; + struct SaveBlock1 *save; + struct UnknownSaveStruct2ABC *unk2abc; + if (FlagGet(SYS_GAME_CLEAR) != 0) { + unk2abc = gSaveBlock1.unknown_2ABC; + gUnknown_03005D38.var0 = sub_80BEBC8(unk2abc); + if (gUnknown_03005D38.var0 != -1 && sub_80BF77C(0x28f) != 1) { + rval = (Random() % 3) + 1; + if (sub_80BEE48(rval) != 1) { + save = &gSaveBlock1; + save->unknown_2ABC[gUnknown_03005D38.var0].val0 = rval; + save->unknown_2ABC[gUnknown_03005D38.var0].val2 = 4; + save->unknown_2ABC[gUnknown_03005D38.var0].val1 = 1; + } + } + } +} + +int sub_80BEBC8(struct UnknownSaveStruct2ABC *arg0) { + s8 i; + for (i=0; i<16; i++) { + if (arg0[i].val0 == 0) { + return i; + } + } + return -1; +} + +void sub_80BEBF4(void) { + u8 i; + for (i=0; i<16; i++) { + sub_80BEC10(i); + } +} + +void sub_80BEC10(u8 arg0) { + gSaveBlock1.unknown_2ABC[arg0].val0 = 0; + gSaveBlock1.unknown_2ABC[arg0].val1 = 0; + gSaveBlock1.unknown_2ABC[arg0].val2 = 0; +} + +void sub_80BEC40(void) { + u8 i, j; + for (i = 0; i < 15; i++) { + if (gSaveBlock1.unknown_2ABC[i].val0 == 0) { + for (j = i + 1; j < 16; j++) { + if (gSaveBlock1.unknown_2ABC[j].val0 != 0) { + gSaveBlock1.unknown_2ABC[i] = gSaveBlock1.unknown_2ABC[j]; + sub_80BEC10(j); + break; + } + } + } + } +} + +u8 sub_80BECA0(void) +{ + u8 i; + for (i=0; i<16; i++) + { + if (gSaveBlock1.unknown_2ABC[i].val0 != 0 && gSaveBlock1.unknown_2ABC[i].val1 == 1 && gSaveBlock1.unknown_2ABC[i].val2 < 3) + { + return i; + } + } + return 0xFF; +} + +void sub_80BECE8(void) +{ + u8 arg0; + arg0 = sub_80BECA0(); + if (arg0 == 0xff) + { + gScriptResult = 0; + return; + } + if (gSaveBlock1.unknown_2ABC[arg0].val2 == 0) + { + gSaveBlock1.unknown_2ABC[arg0].val1 = 2; + if (gLocalTime.hours < 20) + { + ShowFieldMessage(gTVNewsTextGroup2[gSaveBlock1.unknown_2ABC[arg0].val0]); + } + else + { + ShowFieldMessage(gTVNewsTextGroup3[gSaveBlock1.unknown_2ABC[arg0].val0]); + } + } + else + { + u16 value = gSaveBlock1.unknown_2ABC[arg0].val2; + ConvertIntToDecimalStringN(gStringVar1, value, 0, 1); + gSaveBlock1.unknown_2ABC[arg0].val1 = 0; + ShowFieldMessage(gTVNewsTextGroup1[gSaveBlock1.unknown_2ABC[arg0].val0]); + } + gScriptResult = 1; +} + +bool8 GetPriceReduction(u8 arg0) +{ + u8 i; + if (arg0 == 0) + { + return FALSE; + } + for (i=0; i<16; i++) + { + if (gSaveBlock1.unknown_2ABC[i].val0 == arg0) + { + if (gSaveBlock1.unknown_2ABC[i].val1 == 2 && IsPriceDiscounted(arg0) != 0) + { + return TRUE; + } + else + { + return FALSE; + } + } + } + return FALSE; +} + +bool8 IsPriceDiscounted(u8 arg0) +{ + switch (arg0) + { + case 1: + if (gSaveBlock1.location.mapGroup == MAP_GROUP_SLATEPORT_CITY && gSaveBlock1.location.mapNum == MAP_ID_SLATEPORT_CITY && gScriptLastTalked == 0x1a) + { + return TRUE; + } + else + { + return FALSE; + } + break; + case 3: + if (gSaveBlock1.location.mapGroup == MAP_GROUP_LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP && gSaveBlock1.location.mapNum == MAP_ID_LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP) + { + return TRUE; + } + else + { + return FALSE; + } + break; + default: + return TRUE; + } +} + +bool8 sub_80BEE48(u8 arg0) +{ + u8 i; + if (arg0 == 0) + { + return TRUE; + } + else + { + for (i=0; i<16; i++) + { + if (gSaveBlock1.unknown_2ABC[i].val0 == arg0) + { + return TRUE; + } + } + } + return FALSE; +} + +void sub_80BEE84(u16 var0) +{ + u8 i; + for (i=0; i<16; i++) + { + if (gSaveBlock1.unknown_2ABC[i].val0) + { + if (gSaveBlock1.unknown_2ABC[i].val2 < var0) + { + sub_80BEC10(i); + } + else + { + if (!gSaveBlock1.unknown_2ABC[i].val1 && FlagGet(SYS_GAME_CLEAR) == 1) + { + gSaveBlock1.unknown_2ABC[i].val1 = 1; + } + gSaveBlock1.unknown_2ABC[i].val2 -= var0; + } + } + } + sub_80BEC40(); +} + +void sub_80BEF10(u8 strvaridx, u8 rank) +{ + switch (rank) + { + case NORMAL_RANK: + StringCopy(gUnknown_083D1464[strvaridx], gUnknown_083CE048[NORMAL_RANK + 5].text); + break; + case SUPER_RANK: + StringCopy(gUnknown_083D1464[strvaridx], gUnknown_083CE048[SUPER_RANK + 5].text); + break; + case HYPER_RANK: + StringCopy(gUnknown_083D1464[strvaridx], gUnknown_083CE048[HYPER_RANK + 5].text); + break; + case MASTER_RANK: + StringCopy(gUnknown_083D1464[strvaridx], gUnknown_083CE048[MASTER_RANK + 5].text); + break; + } +} + +void CopyContestCategoryToStringVar(u8 strvaridx, u8 category) +{ + switch (category) + { + case CONTEST_COOL: + StringCopy(gUnknown_083D1464[strvaridx], gUnknown_083CE048[CONTEST_COOL].text); + break; + case CONTEST_BEAUTY: + StringCopy(gUnknown_083D1464[strvaridx], gUnknown_083CE048[CONTEST_BEAUTY].text); + break; + case CONTEST_CUTE: + StringCopy(gUnknown_083D1464[strvaridx], gUnknown_083CE048[CONTEST_CUTE].text); + break; + case CONTEST_SMART: + StringCopy(gUnknown_083D1464[strvaridx], gUnknown_083CE048[CONTEST_SMART].text); + break; + case CONTEST_TOUGH: + StringCopy(gUnknown_083D1464[strvaridx], gUnknown_083CE048[CONTEST_TOUGH].text); + break; + } +} + +void SetContestCategoryStringVarForInterview(void) +{ + TVShow *tvShow; + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + CopyContestCategoryToStringVar(1, tvShow->bravoTrainer.contestCategory); +} + +void sub_80BF088(u8 arg0, s32 price) +{ + size_t log10val; + log10val = sub_80BF0B8(price); + ConvertIntToDecimalStringN(gUnknown_083D1464[arg0], price, 0, log10val); +} + +size_t sub_80BF0B8(int value) +{ + if (value / 10 == 0) + return 1; + else if (value / 100 == 0) + return 2; + else if (value / 1000 == 0) + return 3; + else if (value / 10000 == 0) + return 4; + else if (value / 100000 == 0) + return 5; + else if (value / 1000000 == 0) + return 6; + else if (value / 10000000 == 0) + return 7; + else if (value / 100000000 == 0) + return 8; + else + return 1; +} + +void sub_80BF154(u8 arg0, struct TVShowSmartShopper *arg1) +{ + u8 i; + s32 price; + price = 0; + for (i=0; i<3; i++) + { + if (arg1->itemIds[i]) + { + price += ItemId_GetPrice(arg1->itemIds[i]) * arg1->itemAmounts[i]; + } + } + if (arg1->priceReduced == 1) + { + sub_80BF088(arg0, price >> 1); + } + else + { + sub_80BF088(arg0, price); + } +} + +bool8 sub_80BF1B4(u8 showIdx) +{ + TVShow *tvShows; + u8 i; + u32 trainerId; + tvShows = gSaveBlock1.tvShows; + trainerId = GetPlayerTrainerId(); + for (i=5; i<24; i++) + { + if (tvShows[i].common.var00 == showIdx) + { + if ((trainerId & 0xFF) == tvShows[i].common.trainerIdLo && ((trainerId >> 8) & 0xFF) == tvShows[i].common.trainerIdHi) + { + return TRUE; + } + } + } + return FALSE; +} + +void sub_80BF20C(void) +{ + u8 i, j; + u16 tmpId, tmpAmount; + for (i=0; i<2; i++) + { + for (j=i+1; j<3; j++) + { + if (gUnknown_02038724[i].item_amount < gUnknown_02038724[j].item_amount) + { + tmpId = gUnknown_02038724[i].item_id; + tmpAmount = gUnknown_02038724[i].item_amount; + gUnknown_02038724[i].item_id = gUnknown_02038724[j].item_id; + gUnknown_02038724[i].item_amount = gUnknown_02038724[j].item_amount; + gUnknown_02038724[j].item_id = tmpId; + gUnknown_02038724[j].item_amount = tmpAmount; + } + } + } +} + +void sub_80BF25C(u8 showType) +{ + u8 i; + for (i=0; i<5; i++) + { + if (gSaveBlock1.tvShows[i].common.var00 == showType) { + if(gSaveBlock1.tvShows[i].common.var01 == 1) + { + gScriptResult = 1; + } + else + { + sub_80BF55C(gSaveBlock1.tvShows, i); + sub_80BF588(gSaveBlock1.tvShows); + sub_80BF6D8(); + } + return; + } + } + sub_80BF6D8(); +} + +void sub_80BF2C4(void) +{ + gScriptResult = 0; + switch (gSpecialVar_0x8005) { + case TVSHOW_FAN_CLUB_LETTER: + sub_80BF334(); + break; + case TVSHOW_RECENT_HAPPENINGS: + sub_80BF3A4(); + break; + case TVSHOW_PKMN_FAN_CLUB_OPINIONS: + sub_80BF3DC(); + break; + case TVSHOW_UNKN_SHOWTYPE_04: + sub_80BF46C(); + break; + case TVSHOW_NAME_RATER_SHOW: + sub_80BF478(); + break; + case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: + sub_80BF484(); + break; + case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: + sub_80BF4BC(); + break; + } +} + +void sub_80BF334(void) +{ + TVShow *show; + sub_80BF25C(TVSHOW_FAN_CLUB_LETTER); + if (gScriptResult == 0) { + StringCopy(gStringVar1, gSpeciesNames[GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, 0)]); + show = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + sub_80EB6FC(show->fanclubLetter.pad04, 6); + } +} + +void sub_80BF3A4(void) +{ + TVShow *show; + sub_80BF25C(TVSHOW_RECENT_HAPPENINGS); + if (gScriptResult == 0) { + show = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + sub_80EB6FC(show->recentHappenings.var04, 6); + } +} + +void sub_80BF3DC(void) +{ + TVShow *show; + sub_80BF25C(TVSHOW_PKMN_FAN_CLUB_OPINIONS); + if (gScriptResult == 0) { + StringCopy(gStringVar1, gSpeciesNames[GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, 0)]); + GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_NICKNAME, gStringVar2); + StringGetEnd10(gStringVar2); + show = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + sub_80EB6FC(show->fanclubOpinions.var1C, 2); + } +} + +void sub_80BF46C(void) +{ + gScriptResult = 1; +} + +void sub_80BF478(void) +{ + sub_80BF25C(TVSHOW_NAME_RATER_SHOW); +} + +void sub_80BF484(void) +{ + TVShow *show; + sub_80BF25C(TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE); + if (gScriptResult == 0) { + show = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + sub_80EB6FC(show->bravoTrainer.var04, 2); + } +} + +void sub_80BF4BC(void) +{ + TVShow *show; + sub_80BF25C(TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE); + if (gScriptResult == 0) { + show = &gSaveBlock1.tvShows[gUnknown_03005D38.var0]; + sub_80EB6FC(show->bravoTrainerTower.var18, 1); // wrong struct ident, fix later + } +} + +#if ENGLISH +u8 sub_80BF4F4(u8 arg0) +{ + u32 species; + + GetMonData(&gPlayerParty[arg0], MON_DATA_NICKNAME, &gStringVar1); + + species = GetMonData(&gPlayerParty[arg0], MON_DATA_SPECIES, NULL); + + if (StringCompareWithoutExtCtrlCodes(gSpeciesNames[species], gStringVar1) == FALSE) + { + return FALSE; + } + + return TRUE; +} +#elif GERMAN +u8 sub_80BF4F4(u8 arg0) +{ + u8 langData[4]; + u32 species; + + u8 *tmp; + + GetMonData(&gPlayerParty[arg0], MON_DATA_NICKNAME, &gStringVar1); + + tmp = langData; + tmp[0] = GetMonData(&gPlayerParty[arg0], MON_DATA_LANGUAGE, &langData); + if (tmp[0] != GAME_LANGUAGE) { + return TRUE; + } + + species = GetMonData(&gPlayerParty[arg0], MON_DATA_SPECIES, NULL); + + if (StringCompareWithoutExtCtrlCodes(gSpeciesNames[species], gStringVar1)) { + return TRUE; + } + + return FALSE; +} +#endif + +u8 sub_80BF544(void) +{ + return sub_80BF4F4(GetLeadMonIndex()); +} + +void sub_80BF55C(TVShow tvShow[], u8 showidx) +{ + u8 idx; + tvShow[showidx].common.var00 = 0; + tvShow[showidx].common.var01 = 0; + for (idx=0; idx<34; idx++) { + tvShow[showidx].common.pad02[idx] = 0; + } +} + +void sub_80BF588(TVShow tvShow[]) +{ + u8 showidx; + u8 showidx2; + for (showidx=0; showidx<4; showidx++) { + if (tvShow[showidx].common.var00 == 0) { + for (showidx2=showidx+1; showidx2<5; showidx2++) { + if (tvShow[showidx2].common.var00 != 0) { + tvShow[showidx] = tvShow[showidx2]; + sub_80BF55C(tvShow, showidx2); + break; + } + } + } + } + for (showidx=5; showidx<24; showidx++) { + if (tvShow[showidx].common.var00 == 0) { + for (showidx2=showidx+1; showidx2<24; showidx2++) { + if (tvShow[showidx2].common.var00 != 0) { + tvShow[showidx] = tvShow[showidx2]; + sub_80BF55C(gSaveBlock1.tvShows, showidx2); + break; + } + } + } + } +} + +u16 sub_80BF638(u8 arg0, u16 arg1) +{ + u16 retval = sub_80BF674(arg1); + StringCopy(gUnknown_083D1464[arg0], gSpeciesNames[retval]); + return retval; +} + +u16 sub_80BF674(u16 species) +{ + u16 rspecies; + u16 cspecies; + rspecies = (Random() % (NUM_SPECIES - 1)) + 1; + cspecies = rspecies; + while ((s8)GetNationalPokedexFlag(SpeciesToNationalPokedexNum(cspecies), 0) != 1 || cspecies == species) { + if (cspecies == SPECIES_BULBASAUR) + cspecies = NUM_SPECIES - 1; + else + cspecies --; + if (cspecies == rspecies) { + cspecies = species; + return cspecies; + } + } + return cspecies; +} + +void sub_80BF6D8(void) +{ + gUnknown_03005D38.var0 = sub_80BF720(gSaveBlock1.tvShows); + gSpecialVar_0x8006 = gUnknown_03005D38.var0; + if (gUnknown_03005D38.var0 == -1) + gScriptResult = 1; + else + gScriptResult = 0; +} + +s8 sub_80BF720(TVShow tvShow[]) +{ + u8 idx; + for (idx=0; idx<5; idx++) { + if (tvShow[idx].common.var00 == 0) + return idx; + } + return -1; +} + +s8 sub_80BF74C(TVShow tvShow[]) +{ + s8 idx; + for (idx=5; idx<24; idx++) { + if (tvShow[idx].common.var00 == 0) + return idx; + } + return -1; +} + +bool8 sub_80BF77C(u16 value) +{ + if (Random() <= value) + return FALSE; + return TRUE; +} + +void sub_80BF79C(TVShow *arg0) +{ + u8 i = Random() % 6; + while (1) { + if (i == 6) + i = 0; + if (arg0->recentHappenings.var04[i] != 0xFFFF) + break; + i ++; + } + sub_80EB3FC(gStringVar3, arg0->recentHappenings.var04[i]); +} + +u8 sub_80BF7E8(struct TVShowNameRaterShow *arg0) +{ + u16 flagsum = 0; + u8 i = 0; + if (arg0->pokemonName[0] != 0xFF) { + while (i < 11 && arg0->pokemonName[i] != 0xFF) { + flagsum += arg0->pokemonName[i]; + i++; + } + } + return flagsum & 0x7; +} + +void sub_80BF820(u8 arg0, u8 arg1, u8 arg2, u16 arg3, u16 arg4, struct TVShowNameRaterShow *tvShow) +{ + u8 flags[3]; + u16 nameLength; + u8 i; + for (i=0; i<3; i++) + flags[i] = EOS; + if (arg3 == 0) { + nameLength = StringLength(tvShow->trainerName); + if (arg2 == 0) { + flags[0] = tvShow->trainerName[arg1]; + } else if (arg2 == 1) { + flags[0] = tvShow->trainerName[nameLength - arg1]; + } else if (arg2 == 2) { + flags[0] = tvShow->trainerName[arg1]; + flags[1] = tvShow->trainerName[arg1 + 1]; + } else { + flags[0] = tvShow->trainerName[nameLength - (arg1 + 2)]; + flags[1] = tvShow->trainerName[nameLength - (arg1 + 1)]; + } + } else if (arg3 == 1) { + nameLength = StringLength(tvShow->pokemonName); + if (arg2 == 0) { + flags[0] = tvShow->pokemonName[arg1]; + } else if (arg2 == 1) { + flags[0] = tvShow->pokemonName[nameLength - arg1]; + } else if (arg2 == 2) { + flags[0] = tvShow->pokemonName[arg1]; + flags[1] = tvShow->pokemonName[arg1 + 1]; + } else { + flags[0] = tvShow->pokemonName[nameLength - (arg1 + 2)]; + flags[1] = tvShow->pokemonName[nameLength - (arg1 + 1)]; + } + } else { + nameLength = StringLength(gSpeciesNames[arg4]); + if (arg2 == 0) { + flags[0] = gSpeciesNames[arg4][arg1]; + } else if (arg2 == 1) { + flags[0] = gSpeciesNames[arg4][nameLength - arg1]; + } else if (arg2 == 2) { + flags[0] = gSpeciesNames[arg4][arg1]; + flags[1] = gSpeciesNames[arg4][arg1 + 1]; + } else { + flags[0] = gSpeciesNames[arg4][nameLength - (arg1 + 2)]; + flags[1] = gSpeciesNames[arg4][nameLength - (arg1 + 1)]; + } + } + StringCopy(gUnknown_083D1464[arg0], flags); +} + +bool8 sub_80BF974(void) +{ + u8 i; + for (i=0; i<5; i++) + { + if (gSaveBlock1.tvShows[i].common.var00 == gSpecialVar_0x8004) + return TRUE; + } + return FALSE; +} + +bool8 sub_80BF9B4(void) +{ + GetMonData(&(gPlayerParty[gSpecialVar_0x8004]), MON_DATA_NICKNAME, &gStringVar1); + if (!StringCompareWithoutExtCtrlCodes(gStringVar3, gStringVar1)) + return FALSE; + sub_80BE478(); + return TRUE; +} + +void c2_080CC144(void); + +void sub_80BF9F8(void) +{ + u16 spec; + u16 gender; + u32 pval; + GetMonData(&(gPlayerParty[gSpecialVar_0x8004]), MON_DATA_NICKNAME, &gStringVar3); + GetMonData(&(gPlayerParty[gSpecialVar_0x8004]), MON_DATA_NICKNAME, &gStringVar2); + spec = GetMonData(&(gPlayerParty[gSpecialVar_0x8004]), MON_DATA_SPECIES, 0); + gender = GetMonGender(&(gPlayerParty[gSpecialVar_0x8004])); + pval = GetMonData(&(gPlayerParty[gSpecialVar_0x8004]), MON_DATA_PERSONALITY, 0); + DoNamingScreen(3, gStringVar2, spec, gender, pval, c2_080CC144); +} + +void c2_080CC144(void) +{ + SetMonData(&(gPlayerParty[gSpecialVar_0x8004]), MON_DATA_NICKNAME, gStringVar2); + c2_exit_to_overworld_1_continue_scripts_restart_music(); +} + +void sub_80BFAE0(void) +{ + GetMonData(&(gPlayerParty[gSpecialVar_0x8004]), MON_DATA_NICKNAME, &gStringVar1); + StringGetEnd10(gStringVar1); +} + +void sub_80BFB10(void) +{ + if (GetPlayerTrainerId() == GetMonData(&(gPlayerParty[gSpecialVar_0x8004]), MON_DATA_OT_ID, 0)) + gScriptResult = 0; + else + gScriptResult = 1; +} + +u8 sub_80BFB54(u8 arg0) +{ + if (arg0 == 0) + return 0; + else if (arg0 > 0 && arg0 <= 20) + return 2; + else if (arg0 > 20 && arg0 <= 40) + return 3; + else if (arg0 > 40 && arg0 <= 60) + return 4; + else + return 0; +} + +u32 GetPlayerTrainerId(void) +{ + return (gSaveBlock2.playerTrainerId[3] << 24) | (gSaveBlock2.playerTrainerId[2] << 16) | (gSaveBlock2.playerTrainerId[1] << 8) | (gSaveBlock2.playerTrainerId[0]); +} + +u8 CheckForBigMovieOrEmergencyNewsOnTV(void) +{ + if (gSaveBlock1.location.mapGroup != MAP_GROUP_LITTLEROOT_TOWN_BRENDANS_HOUSE_1F) + return 0; + if (gSaveBlock2.playerGender == MALE) { + if (gSaveBlock1.location.mapNum != MAP_ID_LITTLEROOT_TOWN_BRENDANS_HOUSE_1F) + return 0; + } else { + if (gSaveBlock1.location.mapNum != MAP_ID_LITTLEROOT_TOWN_MAYS_HOUSE_1F) + return 0; + } + if (FlagGet(SYS_TV_LATI) == 1) + return 1; + if (FlagGet(SYS_TV_HOME) == 1) + return 2; + return 1; +} + +#ifdef NONMATCHING +void GetMomOrDadStringForTVMessage(void) +{ + if (gSaveBlock1.location.mapGroup == MAP_GROUP_LITTLEROOT_TOWN_BRENDANS_HOUSE_1F) { + if (gSaveBlock2.playerGender == MALE) { + if (gSaveBlock1.location.mapNum == MAP_ID_LITTLEROOT_TOWN_BRENDANS_HOUSE_1F) { + StringCopy(gStringVar1, gOtherText_Mom); + VarSet(VAR_0x4003, 1); + } + } else { + if (gSaveBlock1.location.mapNum == MAP_ID_LITTLEROOT_TOWN_MAYS_HOUSE_1F) { + StringCopy(gStringVar1, gOtherText_Mom); + VarSet(VAR_0x4003, 1); + } + } + } + if (VarGet(VAR_0x4003) == 1) { + StringCopy(gStringVar1, gOtherText_Mom); + } else if (VarGet(VAR_0x4003) == 2) { + StringCopy(gStringVar1, gOtherText_Dad); + } else if (VarGet(VAR_0x4003) > 2) { + if ((u16)(VarGet(VAR_0x4003) & 1) == 0) { + StringCopy(gStringVar1, gOtherText_Mom); + } else { + StringCopy(gStringVar1, gOtherText_Dad); + } + } else { + if ((u16)(Random() & 1) != 0) { + StringCopy(gStringVar1, gOtherText_Mom); + VarSet(VAR_0x4003, 1); + } else { + StringCopy(gStringVar1, gOtherText_Dad); + VarSet(VAR_0x4003, 2); + } + } +} +#else +__attribute__((naked)) +void GetMomOrDadStringForTVMessage(void) +{ + asm(".syntax unified\n\ + push {r4,lr}\n\ + ldr r1, _080BFC40 @ =gSaveBlock1\n\ + movs r0, 0x4\n\ + ldrsb r0, [r1, r0]\n\ + cmp r0, 0x1\n\ + bne _080BFC6C\n\ + ldr r0, _080BFC44 @ =gSaveBlock2\n\ + ldrb r0, [r0, 0x8]\n\ + cmp r0, 0\n\ + bne _080BFC54\n\ + movs r0, 0x5\n\ + ldrsb r0, [r1, r0]\n\ + cmp r0, 0\n\ + bne _080BFC6C\n\ + ldr r0, _080BFC48 @ =gStringVar1\n\ + ldr r1, _080BFC4C @ =gOtherText_Mom\n\ + bl StringCopy\n\ + ldr r0, _080BFC50 @ =0x00004003\n\ + movs r1, 0x1\n\ + bl VarSet\n\ + b _080BFC6C\n\ + .align 2, 0\n\ +_080BFC40: .4byte gSaveBlock1\n\ +_080BFC44: .4byte gSaveBlock2\n\ +_080BFC48: .4byte gStringVar1\n\ +_080BFC4C: .4byte gOtherText_Mom\n\ +_080BFC50: .4byte 0x00004003\n\ +_080BFC54:\n\ + movs r0, 0x5\n\ + ldrsb r0, [r1, r0]\n\ + cmp r0, 0x2\n\ + bne _080BFC6C\n\ + ldr r0, _080BFCB4 @ =gStringVar1\n\ + ldr r1, _080BFCB8 @ =gOtherText_Mom\n\ + bl StringCopy\n\ + ldr r0, _080BFCBC @ =0x00004003\n\ + movs r1, 0x1\n\ + bl VarSet\n\ +_080BFC6C:\n\ + ldr r4, _080BFCBC @ =0x00004003\n\ + adds r0, r4, 0\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r0, 0x1\n\ + beq _080BFCAA\n\ + adds r0, r4, 0\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r0, 0x2\n\ + beq _080BFCC0\n\ + adds r0, r4, 0\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r0, 0x2\n\ + bls _080BFCD4\n\ + adds r0, r4, 0\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _080BFCC0\n\ +_080BFCAA:\n\ + ldr r0, _080BFCB4 @ =gStringVar1\n\ + ldr r1, _080BFCB8 @ =gOtherText_Mom\n\ + bl StringCopy\n\ + b _080BFD10\n\ + .align 2, 0\n\ +_080BFCB4: .4byte gStringVar1\n\ +_080BFCB8: .4byte gOtherText_Mom\n\ +_080BFCBC: .4byte 0x00004003\n\ +_080BFCC0:\n\ + ldr r0, _080BFCCC @ =gStringVar1\n\ + ldr r1, _080BFCD0 @ =gOtherText_Dad\n\ + bl StringCopy\n\ + b _080BFD10\n\ + .align 2, 0\n\ +_080BFCCC: .4byte gStringVar1\n\ +_080BFCD0: .4byte gOtherText_Dad\n\ +_080BFCD4:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080BFD00\n\ + ldr r0, _080BFCF8 @ =gStringVar1\n\ + ldr r1, _080BFCFC @ =gOtherText_Mom\n\ + bl StringCopy\n\ + adds r0, r4, 0\n\ + movs r1, 0x1\n\ + bl VarSet\n\ + b _080BFD10\n\ + .align 2, 0\n\ +_080BFCF8: .4byte gStringVar1\n\ +_080BFCFC: .4byte gOtherText_Mom\n\ +_080BFD00:\n\ + ldr r0, _080BFD18 @ =gStringVar1\n\ + ldr r1, _080BFD1C @ =gOtherText_Dad\n\ + bl StringCopy\n\ + adds r0, r4, 0\n\ + movs r1, 0x2\n\ + bl VarSet\n\ +_080BFD10:\n\ + pop {r4}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_080BFD18: .4byte gStringVar1\n\ +_080BFD1C: .4byte gOtherText_Dad\n\ +.syntax divided\n"); +} +#endif + +void sub_80BFD20(void) +{ + VarSet(VAR_0x40BC, 0); + RemoveFieldObjectByLocalIdAndMap(5, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup); +} + +typedef union ewramStruct_02007000 { + TVShow tvshows[4][25]; + struct UnknownSaveStruct2ABC unknown_2abc[4][16]; +} ewramStruct_02007000; + +void sub_80BFE24(TVShow arg0[25], TVShow arg1[25], TVShow arg2[25], TVShow arg3[25]); + +void sub_80C04A0(void); +void sub_80C01D4(void); +void sub_80C0408(void); + +void sub_80BFD44(u8 *arg0, u32 arg1, u8 arg2) +{ + u8 i; + ewramStruct_02007000 *ewramTVShows; + for (i=0; i<4; i++) { + memcpy(&gUnknown_02007000.tvshows[i], &arg0[i * arg1], 25 * sizeof(TVShow)); + } + ewramTVShows = &gUnknown_02007000; + switch (arg2) { + case 0: + sub_80BFE24(gSaveBlock1.tvShows, ewramTVShows->tvshows[1], ewramTVShows->tvshows[2], ewramTVShows->tvshows[3]); + break; + case 1: + sub_80BFE24(ewramTVShows->tvshows[0], gSaveBlock1.tvShows, ewramTVShows->tvshows[2], ewramTVShows->tvshows[3]); + break; + case 2: + sub_80BFE24(ewramTVShows->tvshows[0], ewramTVShows->tvshows[1], gSaveBlock1.tvShows, ewramTVShows->tvshows[3]); + break; + case 3: + sub_80BFE24(ewramTVShows->tvshows[0], ewramTVShows->tvshows[1], ewramTVShows->tvshows[2], gSaveBlock1.tvShows); + break; + } + sub_80BF588(gSaveBlock1.tvShows); + sub_80C04A0(); + sub_80BF588(gSaveBlock1.tvShows); + sub_80C01D4(); + sub_80C0408(); +} + +extern u8 gUnknown_03000720; +extern u8 gUnknown_03000721; +extern s8 gUnknown_03000722; +s8 sub_80C019C(TVShow tvShows[]); +bool8 sub_80BFF68(TVShow * tv1[25], TVShow * tv2[25], u8 idx); +u8 sub_80C004C(TVShow *tv1, TVShow *tv2, u8 idx); +u8 sub_80C00B4(TVShow *tv1, TVShow *tv2, u8 idx); +u8 sub_80C0134(TVShow *tv1, TVShow *tv2, u8 idx); + +void sub_80BFE24(TVShow arg0[25], TVShow arg1[25], TVShow arg2[25], TVShow arg3[25]) +{ + u8 i, j; + TVShow ** argslist[4]; + argslist[0] = &arg0; + argslist[1] = &arg1; + argslist[2] = &arg2; + argslist[3] = &arg3; + gUnknown_03000720 = GetLinkPlayerCount(); + while (1) { + for (i=0; i<gUnknown_03000720; i++) { + if (i == 0) + gUnknown_020387E4 = i; + gUnknown_03000722 = sub_80C019C(argslist[i][0]); + if (gUnknown_03000722 == -1) { + gUnknown_020387E4++; + if (gUnknown_020387E4 == gUnknown_03000720) + return; + } else { + for (j=0; j<gUnknown_03000720-1; j++) { + gUnknown_03005D38.var0 = sub_80BF74C(argslist[(i + j + 1) % gUnknown_03000720][0]); + if (gUnknown_03005D38.var0 != -1 && sub_80BFF68(&argslist[(i + j + 1) % gUnknown_03000720][0], &argslist[i][0], (i + j + 1) % gUnknown_03000720) == 1) { + break; + } + } + if (j == gUnknown_03000720 - 1) { + sub_80BF55C(argslist[i][0], gUnknown_03000722); + } + } + } + } +} + +#ifdef NONMATCHING +bool8 sub_80BFF68(TVShow * arg1[25], TVShow * arg2[25], u8 idx) { + u8 value; + u8 switchval; + TVShow tv1[25]; + TVShow tv2[25]; + tv1 = *arg1; + tv2 = *arg2; + value = FALSE; + switchval = sub_80BFB54(tv2[gUnknown_03000722].common.var00); + switch (switchval) { + case 2: + value = sub_80C004C(&tv1[gUnknown_03005D38.var0], &tv2[gUnknown_03000722], idx); + break; + case 3: + value = sub_80C00B4(&tv1[gUnknown_03005D38.var0], &tv2[gUnknown_03000722], idx); + break; + case 4: + value = sub_80C0134(&tv1[gUnknown_03005D38.var0], &tv2[gUnknown_03000722], idx); + break; + } + if (value == TRUE) { + sub_80BF55C(tv2, gUnknown_03000722); + return TRUE; + } else { + return FALSE; + } +} +#else +__attribute__((naked)) +bool8 sub_80BFF68(TVShow * arg1[25], TVShow * arg2[25], u8 idx) { + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + sub sp, 0x4\n\ + lsls r2, 24\n\ + lsrs r7, r2, 24\n\ + ldr r4, [r0]\n\ + ldr r6, [r1]\n\ + movs r5, 0\n\ + ldr r2, _080BFFA4 @ =gUnknown_03000722\n\ + movs r1, 0\n\ + ldrsb r1, [r2, r1]\n\ + lsls r0, r1, 3\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r6 @ this is the only mimsmatch\n\ + ldrb r0, [r0]\n\ + str r2, [sp]\n\ + bl sub_80BFB54\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + adds r1, r0, 0\n\ + ldr r2, [sp]\n\ + cmp r0, 0x3\n\ + beq _080BFFD8\n\ + cmp r0, 0x3\n\ + bgt _080BFFA8\n\ + cmp r0, 0x2\n\ + beq _080BFFAE\n\ + b _080C0026\n\ + .align 2, 0\n\ +_080BFFA4: .4byte gUnknown_03000722\n\ +_080BFFA8:\n\ + cmp r1, 0x4\n\ + beq _080C0000\n\ + b _080C0026\n\ +_080BFFAE:\n\ + ldr r0, _080BFFD4 @ =gUnknown_03005D38\n\ + movs r1, 0\n\ + ldrsb r1, [r0, r1]\n\ + lsls r0, r1, 3\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r4, r0\n\ + ldrb r2, [r2]\n\ + lsls r2, 24\n\ + asrs r2, 24\n\ + lsls r1, r2, 3\n\ + adds r1, r2\n\ + lsls r1, 2\n\ + adds r1, r6, r1\n\ + adds r2, r7, 0\n\ + bl sub_80C004C\n\ + b _080C0022\n\ + .align 2, 0\n\ +_080BFFD4: .4byte gUnknown_03005D38\n\ +_080BFFD8:\n\ + ldr r0, _080BFFFC @ =gUnknown_03005D38\n\ + movs r1, 0\n\ + ldrsb r1, [r0, r1]\n\ + lsls r0, r1, 3\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r4, r0\n\ + ldrb r2, [r2]\n\ + lsls r2, 24\n\ + asrs r2, 24\n\ + lsls r1, r2, 3\n\ + adds r1, r2\n\ + lsls r1, 2\n\ + adds r1, r6, r1\n\ + adds r2, r7, 0\n\ + bl sub_80C00B4\n\ + b _080C0022\n\ + .align 2, 0\n\ +_080BFFFC: .4byte gUnknown_03005D38\n\ +_080C0000:\n\ + ldr r0, _080C0030 @ =gUnknown_03005D38\n\ + movs r1, 0\n\ + ldrsb r1, [r0, r1]\n\ + lsls r0, r1, 3\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r4, r0\n\ + ldrb r2, [r2]\n\ + lsls r2, 24\n\ + asrs r2, 24\n\ + lsls r1, r2, 3\n\ + adds r1, r2\n\ + lsls r1, 2\n\ + adds r1, r6, r1\n\ + adds r2, r7, 0\n\ + bl sub_80C0134\n\ +_080C0022:\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ +_080C0026:\n\ + cmp r5, 0x1\n\ + beq _080C0034\n\ + movs r0, 0\n\ + b _080C0040\n\ + .align 2, 0\n\ +_080C0030: .4byte gUnknown_03005D38\n\ +_080C0034:\n\ + ldr r0, _080C0048 @ =gUnknown_03000722\n\ + ldrb r1, [r0]\n\ + adds r0, r6, 0\n\ + bl sub_80BF55C\n\ + movs r0, 0x1\n\ +_080C0040:\n\ + add sp, 0x4\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ +_080C0048: .4byte gUnknown_03000722\n\ +.syntax divided\n"); +} +#endif + +u8 sub_80C004C(TVShow *tv1, TVShow *tv2, u8 idx) { + u32 linkTrainerId = GetLinkPlayerTrainerId(idx); + if ((linkTrainerId & 0xFF) == tv2->common.trainerIdLo && ((linkTrainerId >> 8) & 0xFF) == tv2->common.trainerIdHi) { + return FALSE; + } + tv2->common.trainerIdLo = tv2->common.srcTrainerIdLo; + tv2->common.trainerIdHi = tv2->common.srcTrainerIdHi; + tv2->common.srcTrainerIdLo = linkTrainerId & 0xFF; + tv2->common.srcTrainerIdHi = linkTrainerId >> 8; + *tv1 = *tv2; + tv1->common.var01 = 1; + return TRUE; +} + +u8 sub_80C00B4(TVShow *tv1, TVShow *tv2, u8 idx) { + u32 linkTrainerId = GetLinkPlayerTrainerId(idx); + if ((linkTrainerId & 0xFF) == tv2->common.srcTrainerIdLo && ((linkTrainerId >> 8) & 0xFF) == tv2->common.srcTrainerIdHi) { + return FALSE; + } + if ((linkTrainerId & 0xFF) == tv2->common.trainerIdLo && ((linkTrainerId >> 8) & 0xFF) == tv2->common.trainerIdHi) { + return FALSE; + } + tv2->common.srcTrainerIdLo = tv2->common.srcTrainerId2Lo; + tv2->common.srcTrainerIdHi = tv2->common.srcTrainerId2Hi; + tv2->common.srcTrainerId2Lo = linkTrainerId & 0xFF; + tv2->common.srcTrainerId2Hi = linkTrainerId >> 8; + *tv1 = *tv2; + tv1->common.var01 = 1; + return TRUE; +} + +u8 sub_80C0134(TVShow *tv1, TVShow *tv2, u8 idx) { + u32 linkTrainerId = GetLinkPlayerTrainerId(idx); + if ((linkTrainerId & 0xFF) == tv2->common.trainerIdLo && ((linkTrainerId >> 8) & 0xFF) == tv2->common.trainerIdHi) { + return FALSE; + } + tv2->common.trainerIdLo = tv2->common.srcTrainerIdLo; + tv2->common.trainerIdHi = tv2->common.srcTrainerIdHi; + tv2->common.srcTrainerIdLo = linkTrainerId & 0xFF; + tv2->common.srcTrainerIdHi = linkTrainerId >> 8; + *tv1 = *tv2; + tv1->common.var01 = 1; + tv1->common.var16[0] = 1; + return TRUE; +} + +s8 sub_80C019C(TVShow tvShows[]) { + u8 i; + for (i=0; i<24; i++) { + if (tvShows[i].common.var01 == 0 && (u8)(tvShows[i].common.var00 - 1) < 60) { + return i; + } + } + return -1; +} + +#ifdef NONMATCHING +void sub_80C01D4(void) +{ + u16 i; + for (i=0; i<24; i++) + { + switch (gSaveBlock1.tvShows[i].common.var00) + { + case 0: + case TVSHOW_RECENT_HAPPENINGS: + case TVSHOW_SMART_SHOPPER: + case TVSHOW_MASS_OUTBREAK: + break; + case TVSHOW_FAN_CLUB_LETTER: + sub_80C03C8((&gSaveBlock1.tvShows[i])->fanclubLetter.species, i); + break; + case TVSHOW_PKMN_FAN_CLUB_OPINIONS: + sub_80C03C8((&gSaveBlock1.tvShows[i])->fanclubOpinions.var02, i); + break; + case TVSHOW_UNKN_SHOWTYPE_04: + sub_80C03C8((&gSaveBlock1.tvShows[i])->unkShow04.var06, i); + break; + case TVSHOW_NAME_RATER_SHOW: + sub_80C03C8((&gSaveBlock1.tvShows[i])->nameRaterShow.species, i); + sub_80C03C8((&gSaveBlock1.tvShows[i])->nameRaterShow.var1C, i); + break; + case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: + sub_80C03C8((&gSaveBlock1.tvShows[i])->bravoTrainer.species, i); + break; + case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: + sub_80C03C8((&gSaveBlock1.tvShows[i])->bravoTrainerTower.species, i); + sub_80C03C8((&gSaveBlock1.tvShows[i])->bravoTrainerTower.defeatedSpecies, i); + break; + case TVSHOW_POKEMON_TODAY_CAUGHT: + sub_80C03C8((&gSaveBlock1.tvShows[i])->pokemonToday.species, i); + break; + case TVSHOW_POKEMON_TODAY_FAILED: + sub_80C03C8((&gSaveBlock1.tvShows[i])->pokemonTodayFailed.species, i); + sub_80C03C8((&gSaveBlock1.tvShows[i])->pokemonTodayFailed.species2, i); + break; + case TVSHOW_FISHING_ADVICE: + sub_80C03C8((&gSaveBlock1.tvShows[i])->pokemonAngler.var04, i); + break; + case TVSHOW_WORLD_OF_MASTERS: + sub_80C03C8((&gSaveBlock1.tvShows[i])->worldOfMasters.var08, i); + sub_80C03C8((&gSaveBlock1.tvShows[i])->worldOfMasters.var04, i); + break; + default: + sub_80C03A8(i); + } + } +} +#else +__attribute__((naked)) +void sub_80C01D4(void) { + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + movs r6, 0\n\ +_080C01D8:\n\ + ldr r0, _080C01F8 @ =gSaveBlock1\n\ + lsls r2, r6, 3\n\ + adds r1, r2, r6\n\ + lsls r1, 2\n\ + adds r1, r0\n\ + ldr r0, _080C01FC @ =0x00002738\n\ + adds r1, r0\n\ + ldrb r0, [r1]\n\ + cmp r0, 0x29\n\ + bls _080C01EE\n\ + b _default\n\ +_080C01EE:\n\ + lsls r0, 2\n\ + ldr r1, _080C0200 @ =_080C0204\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + mov pc, r0\n\ + .align 2, 0\n\ +_080C01F8: .4byte gSaveBlock1\n\ +_080C01FC: .4byte 0x00002738\n\ +_080C0200: .4byte _080C0204\n\ + .align 2, 0\n\ +_080C0204:\n\ + .4byte _break\n\ + .4byte _fanclubLetter @ TVSHOW_FAN_CLUB_LETTER\n\ + .4byte _break @ TVSHOW_RECENT_HAPPENINGS\n\ + .4byte _fanclubOpinions @ TVSHOW_PKMN_FAN_CLUB_OPINIONS\n\ + .4byte _showtype4 @ TVSHOW_UNKN_SHOWTYPE_04\n\ + .4byte _nameRater @ TVSHOW_NAME_RATER_SHOW\n\ + .4byte _bravoTrainerContest @ TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE\n\ + .4byte _bravoTrainerTower @ TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _pokemonTodayS @ TVSHOW_POKEMON_TODAY_CAUGHT\n\ + .4byte _break @ TVSHOW_SMART_SHOPPER\n\ + .4byte _pokemonTodayF @ TVSHOW_POKEMON_TODAY_FAILED\n\ + .4byte _fishing @ TVSHOW_FISHING_ADVICE\n\ + .4byte _worldOfMasters @ TVSHOW_WORLD_OF_MASTERS\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _default\n\ + .4byte _break @ TVSHOW_MASS_OUTBREAK\n\ +_fanclubLetter:\n\ + adds r0, r2, r6\n\ + lsls r0, 2\n\ + ldr r1, _080C02B8 @ =gSaveBlock1 + 0x2738\n\ + adds r0, r1\n\ + ldrh r0, [r0, 0x2]\n\ + b _checkSpecies1 @ sub_80C03C8(r0, i)\n\ + .align 2, 0\n\ +_080C02B8: .4byte gSaveBlock1 + 0x2738\n\ +_fanclubOpinions:\n\ + adds r0, r2, r6\n\ + lsls r0, 2\n\ + ldr r1, _080C02C8 @ =gSaveBlock1 + 0x2738\n\ + adds r0, r1\n\ + ldrh r0, [r0, 0x2]\n\ + b _checkSpecies1 @ sub_80C03C8(r0, i)\n\ + .align 2, 0\n\ +_080C02C8: .4byte gSaveBlock1 + 0x2738\n\ +_showtype4:\n\ + adds r0, r2, r6\n\ + lsls r0, 2\n\ + ldr r1, _080C02D8 @ =gSaveBlock1 + 0x2738\n\ + adds r0, r1\n\ + ldrh r0, [r0, 0x6]\n\ + b _checkSpecies1 @ sub_80C03C8(r0, i)\n\ + .align 2, 0\n\ +_080C02D8: .4byte gSaveBlock1 + 0x2738\n\ +_nameRater:\n\ + adds r4, r2, r6\n\ + lsls r4, 2\n\ + ldr r0, _080C02F4 @ =gSaveBlock1 + 0x2738\n\ + adds r4, r0\n\ + ldrh r0, [r4, 0x2]\n\ + lsls r5, r6, 24\n\ + lsrs r5, 24\n\ + adds r1, r5, 0\n\ + bl sub_80C03C8\n\ + ldrh r0, [r4, 0x1C]\n\ + b _checkSpecies2 @ sub_80C03C8(r0, i)\n\ + .align 2, 0\n\ +_080C02F4: .4byte gSaveBlock1 + 0x2738\n\ +_bravoTrainerContest:\n\ + adds r0, r2, r6\n\ + lsls r0, 2\n\ + ldr r1, _080C0304 @ =gSaveBlock1 + 0x2738\n\ + adds r0, r1\n\ + ldrh r0, [r0, 0x2]\n\ + b _checkSpecies1 @ sub_80C03C8(r0, i)\n\ + .align 2, 0\n\ +_080C0304: .4byte gSaveBlock1 + 0x2738\n\ +_bravoTrainerTower:\n\ + adds r4, r2, r6\n\ + lsls r4, 2\n\ + ldr r0, _080C0320 @ =gSaveBlock1 + 0x2738\n\ + adds r4, r0\n\ + ldrh r0, [r4, 0xA]\n\ + lsls r5, r6, 24\n\ + lsrs r5, 24\n\ + adds r1, r5, 0\n\ + bl sub_80C03C8\n\ + ldrh r0, [r4, 0x14]\n\ + b _checkSpecies2 @ sub_80C03C8(r0, i)\n\ + .align 2, 0\n\ +_080C0320: .4byte gSaveBlock1 + 0x2738\n\ +_pokemonTodayS:\n\ + adds r0, r2, r6\n\ + lsls r0, 2\n\ + ldr r1, _080C0330 @ =gSaveBlock1 + 0x2738\n\ + adds r0, r1\n\ + ldrh r0, [r0, 0x10]\n\ + b _checkSpecies1 @ sub_80C03C8(r0, i)\n\ + .align 2, 0\n\ +_080C0330: .4byte gSaveBlock1 + 0x2738\n\ +_pokemonTodayF:\n\ + adds r4, r2, r6\n\ + lsls r4, 2\n\ + ldr r0, _080C034C @ =gSaveBlock1 + 0x2738\n\ + adds r4, r0\n\ + ldrh r0, [r4, 0xC]\n\ + lsls r5, r6, 24\n\ + lsrs r5, 24\n\ + adds r1, r5, 0\n\ + bl sub_80C03C8\n\ + ldrh r0, [r4, 0xE]\n\ + b _checkSpecies2 @ sub_80C03C8(r0, i)\n\ + .align 2, 0\n\ +_080C034C: .4byte gSaveBlock1 + 0x2738\n\ +_fishing:\n\ + adds r0, r2, r6\n\ + lsls r0, 2\n\ + ldr r1, _080C0364 @ =gSaveBlock1 + 0x2738\n\ + adds r0, r1\n\ + ldrh r0, [r0, 0x4]\n\ +_checkSpecies1:\n\ + lsls r1, r6, 24\n\ + lsrs r1, 24\n\ + bl sub_80C03C8\n\ + b _break\n\ + .align 2, 0\n\ +_080C0364: .4byte gSaveBlock1 + 0x2738\n\ +_worldOfMasters:\n\ + adds r4, r2, r6\n\ + lsls r4, 2\n\ + ldr r0, _080C0388 @ =gSaveBlock1 + 0x2738\n\ + adds r4, r0\n\ + ldrh r0, [r4, 0x8]\n\ + lsls r5, r6, 24\n\ + lsrs r5, 24\n\ + adds r1, r5, 0\n\ + bl sub_80C03C8\n\ + ldrh r0, [r4, 0x4]\n\ +_checkSpecies2:\n\ + adds r1, r5, 0\n\ + bl sub_80C03C8\n\ + b _break\n\ + .align 2, 0\n\ +_080C0388: .4byte gSaveBlock1 + 0x2738\n\ +_default:\n\ + lsls r0, r6, 24\n\ + lsrs r0, 24\n\ + bl sub_80C03A8\n\ +_break:\n\ + adds r0, r6, 0x1\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ + cmp r6, 0x17\n\ + bhi _080C03A0\n\ + b _080C01D8\n\ +_080C03A0:\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ +.syntax divided\n"); +} +#endif + +void sub_80C03A8(u8 showidx) { + gSaveBlock1.tvShows[showidx].common.var01 = 0; +} + +void sub_80C03C8(u16 species, u8 showidx) { + if (GetNationalPokedexFlag(SpeciesToNationalPokedexNum(species), 0) == 0) { + gSaveBlock1.tvShows[showidx].common.var01 = 0; + } +} + +#ifdef NONMATCHING +void sub_80C0408(void) { + u16 i; + if (FlagGet(SYS_GAME_CLEAR) != 1) { + for (i=0; i<24; i++) { + if (gSaveBlock1.tvShows[i].common.var00 == TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE || gSaveBlock1.tvShows[i].common.var00 == TVSHOW_MASS_OUTBREAK) { + gSaveBlock1.tvShows[i].common.var01 = 0; + } + } + } +} +#else +__attribute__((naked)) +void sub_80C0408(void) { + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + ldr r0, _080C044C @ =0x00000804\n\ + bl FlagGet\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + beq _080C0444\n\ + movs r2, 0\n\ + ldr r6, _080C0450 @ =gSaveBlock1\n\ + ldr r4, _080C0454 @ =0x00002739\n\ + movs r3, 0\n\ + ldr r5, _080C0458 @ =0x00002738\n\ +_080C0422:\n\ + lsls r0, r2, 3\n\ + adds r0, r2\n\ + lsls r0, 2\n\ + adds r1, r0, r6\n\ + adds r0, r1, r5\n\ + ldrb r0, [r0]\n\ + cmp r0, 0x7\n\ + beq _080C0436\n\ + cmp r0, 0x29\n\ + bne _080C043A\n\ +_080C0436:\n\ + adds r0, r1, r4\n\ + strb r3, [r0]\n\ +_080C043A:\n\ + adds r0, r2, 0x1\n\ + lsls r0, 16\n\ + lsrs r2, r0, 16\n\ + cmp r2, 0x17\n\ + bls _080C0422\n\ +_080C0444:\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_080C044C: .4byte 0x00000804\n\ +_080C0450: .4byte gSaveBlock1\n\ +_080C0454: .4byte 0x00002739\n\ +_080C0458: .4byte 0x00002738\n\ +.syntax divided\n"); +} +#endif + +void sub_80C045C(void) { + u8 i; + for (i=0; i<5; i++) { + if (sub_80BFB54(gSaveBlock1.tvShows[i].common.var00) == 2) { + gSaveBlock1.tvShows[i].common.var01 = 0; + } + } +} + +void sub_80C04A0(void) +{ + s8 showIdx; + s8 count; + count = 0; + for (showIdx=5; showIdx<24; showIdx++) + { + if (gSaveBlock1.tvShows[showIdx].common.var00 == 0) + { + count ++; + } + } + for (showIdx=0; showIdx<5-count; showIdx++) + { + sub_80BF55C(gSaveBlock1.tvShows, showIdx+5); + } +} + +void sub_80C05C4(struct UnknownSaveStruct2ABC[16], struct UnknownSaveStruct2ABC[16], struct UnknownSaveStruct2ABC[16], struct UnknownSaveStruct2ABC[16]); +void sub_80C0750(void); +void sub_80C0788(void); +s8 sub_80C0730(struct UnknownSaveStruct2ABC[16], u8); +void sub_80C06BC(struct UnknownSaveStruct2ABC *[16], struct UnknownSaveStruct2ABC *[16]); + +void sub_80C0514(void *a0, u32 a1, u8 a2) +{ + ewramStruct_02007000 *struct02007000; + u8 i; + for (i=0; i<4; i++) + { + memcpy(gUnknown_02007000.unknown_2abc[i], a0 + i * a1, 64); + } + struct02007000 = &gUnknown_02007000; + switch (a2) + { + case 0: + sub_80C05C4(gSaveBlock1.unknown_2ABC, struct02007000->unknown_2abc[1], struct02007000->unknown_2abc[2], struct02007000->unknown_2abc[3]); + break; + case 1: + sub_80C05C4(struct02007000->unknown_2abc[0], gSaveBlock1.unknown_2ABC, struct02007000->unknown_2abc[2], struct02007000->unknown_2abc[3]); + break; + case 2: + sub_80C05C4(struct02007000->unknown_2abc[0], struct02007000->unknown_2abc[1], gSaveBlock1.unknown_2ABC, struct02007000->unknown_2abc[3]); + break; + case 3: + sub_80C05C4(struct02007000->unknown_2abc[0], struct02007000->unknown_2abc[1], struct02007000->unknown_2abc[2], gSaveBlock1.unknown_2ABC); + break; + } + sub_80C0750(); + sub_80C0788(); +} + +void sub_80C05C4(struct UnknownSaveStruct2ABC a0[16], struct UnknownSaveStruct2ABC a1[16], struct UnknownSaveStruct2ABC a2[16], struct UnknownSaveStruct2ABC a3[16]) +{ + u8 i; + u8 j; + u8 k; + struct UnknownSaveStruct2ABC ** arglist[4]; + arglist[0] = &a0; + arglist[1] = &a1; + arglist[2] = &a2; + arglist[3] = &a3; + gUnknown_03000721 = GetLinkPlayerCount(); + for (i=0; i<16; i++) + { + for (j=0; j<gUnknown_03000721; j++) + { + gUnknown_03000722 = sub_80C0730(*arglist[j], i); + if (gUnknown_03000722 != -1) + { + for (k=0; k<gUnknown_03000721-1; k++) + { + gUnknown_03005D38.var0 = sub_80BEBC8(*arglist[(j + k + 1) % gUnknown_03000721]); + if (gUnknown_03005D38.var0 != -1) + { + sub_80C06BC(arglist[(j + k + 1) % gUnknown_03000721], arglist[j]); + } + } + } + } + } +} + +void sub_80C06BC(struct UnknownSaveStruct2ABC *arg0[16], struct UnknownSaveStruct2ABC *arg1[16]) { + struct UnknownSaveStruct2ABC *str0; + struct UnknownSaveStruct2ABC *str1; + str0 = arg0[0]; + str1 = arg1[0]; + str1 += gUnknown_03000722; + sub_80C06E8(str0, str1, gUnknown_03005D38.var0); +} + +bool8 sub_80C06E8(struct UnknownSaveStruct2ABC *arg0, struct UnknownSaveStruct2ABC *arg1, s8 arg2) { + u8 i; + if (arg1->val0 == 0) { + return FALSE; + } + for (i=0; i<16; i++) { + if (arg0[i].val0 == arg1->val0) { + return FALSE; + } + } + arg0[arg2].val0 = arg1->val0; + arg0[arg2].val1 = 1; + arg0[arg2].val2 = arg1->val2; + return TRUE; +} + +s8 sub_80C0730(struct UnknownSaveStruct2ABC *arg0, u8 arg1) { + if (arg0[arg1].val0 == 0) { + return -1; + } + return arg1; +} + +void sub_80C0750(void) { + u8 i; + for (i=0; i<16; i++) { + if (gSaveBlock1.unknown_2ABC[i].val0 > 3) { + sub_80BEC10(i); + } + } + sub_80BEC40(); +} + +void sub_80C0788(void) { + u8 i; + if (FlagGet(SYS_GAME_CLEAR) != 1) { + for (i=0; i<16; i++) { + gSaveBlock1.unknown_2ABC[i].val1 = 0; + } + } +} + +void DoTVShow(void) { + if (gSaveBlock1.tvShows[gSpecialVar_0x8004].common.var01 != 0) { + switch (gSaveBlock1.tvShows[gSpecialVar_0x8004].common.var00) { + case TVSHOW_FAN_CLUB_LETTER: + DoTVShowPokemonFanClubLetter(); + break; + case TVSHOW_RECENT_HAPPENINGS: + DoTVShowRecentHappenings(); + break; + case TVSHOW_PKMN_FAN_CLUB_OPINIONS: + DoTVShowPokemonFanClubOpinions(); + break; + case TVSHOW_UNKN_SHOWTYPE_04: + nullsub_22(); + break; + case TVSHOW_MASS_OUTBREAK: + DoTVShowPokemonNewsMassOutbreak(); + break; + case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: + DoTVShowBravoTrainerPokemonProfile(); + break; + case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: + DoTVShowBravoTrainerBattleTowerProfile(); + break; + case TVSHOW_POKEMON_TODAY_CAUGHT: + DoTVShowPokemonTodaySuccessfulCapture(); + break; + case TVSHOW_SMART_SHOPPER: + DoTVShowTodaysSmartShopper(); + break; + case TVSHOW_NAME_RATER_SHOW: + DoTVShowTheNameRaterShow(); + break; + case TVSHOW_POKEMON_TODAY_FAILED: + DoTVShowPokemonTodayFailedCapture(); + break; + case TVSHOW_FISHING_ADVICE: + DoTVShowPokemonAngler(); + break; + case TVSHOW_WORLD_OF_MASTERS: + DoTVShowTheWorldOfMasters(); + break; + } + } +} + +void TVShowConvertInternationalString(u8 *dest, u8 *src, u8 language) { + StringCopy(dest, src); + if (language < LANGUAGE_ENGLISH) { + ConvertInternationalString(dest, LANGUAGE_JAPANESE); + } +} + +void DoTVShowBravoTrainerPokemonProfile(void) +{ + TVShow *tvShow; + u8 switchval; + + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + gScriptResult = 0; + switchval = gUnknown_020387E8; + switch(switchval) + { + case 0: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainer.playerName, tvShow->bravoTrainer.language); + CopyContestCategoryToStringVar(1, tvShow->bravoTrainer.contestCategory); + sub_80BEF10(2, tvShow->bravoTrainer.contestRank); + if (!StringCompareWithoutExtCtrlCodes(gSpeciesNames[tvShow->bravoTrainer.species], tvShow->bravoTrainer.pokemonNickname)) + { + gUnknown_020387E8 = 8; + } else + { + gUnknown_020387E8 = 1; + } + break; + case 1: + StringCopy(gStringVar1, gSpeciesNames[tvShow->bravoTrainer.species]); + TVShowConvertInternationalString(gStringVar2, tvShow->bravoTrainer.pokemonNickname, tvShow->bravoTrainer.var1f); + CopyContestCategoryToStringVar(2, tvShow->bravoTrainer.contestCategory); + gUnknown_020387E8 = 2; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainer.playerName, tvShow->bravoTrainer.language); + if (tvShow->bravoTrainer.contestResult == 0) // placed first + { + gUnknown_020387E8 = 3; + } else + { + gUnknown_020387E8 = 4; + } + break; + case 3: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainer.playerName, tvShow->bravoTrainer.language); + sub_80EB3FC(gStringVar2, tvShow->bravoTrainer.var04[0]); + sub_80BF088(2, tvShow->bravoTrainer.contestResult + 1); + gUnknown_020387E8 = 5; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainer.playerName, tvShow->bravoTrainer.language); + sub_80EB3FC(gStringVar2, tvShow->bravoTrainer.var04[0]); + sub_80BF088(2, tvShow->bravoTrainer.contestResult + 1); + gUnknown_020387E8 = 5; + break; + case 5: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainer.playerName, tvShow->bravoTrainer.language); + CopyContestCategoryToStringVar(1, tvShow->bravoTrainer.contestCategory); + sub_80EB3FC(gStringVar3, tvShow->bravoTrainer.var04[1]); + if (tvShow->bravoTrainer.var14) + { + gUnknown_020387E8 = 6; + } else + { + gUnknown_020387E8 = 7; + } + break; + case 6: + StringCopy(gStringVar1, gSpeciesNames[tvShow->bravoTrainer.species]); + StringCopy(gStringVar2, gMoveNames[tvShow->bravoTrainer.var14]); + sub_80EB3FC(gStringVar3, tvShow->bravoTrainer.var04[1]); + gUnknown_020387E8 = 7; + break; + case 7: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainer.playerName, tvShow->bravoTrainer.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->bravoTrainer.species]); + TVShowDone(); + break; + case 8: + StringCopy(gStringVar1, gSpeciesNames[tvShow->bravoTrainer.species]); + gUnknown_020387E8 = 2; + break; + } + ShowFieldMessage(gTVBravoTrainerTextGroup[switchval]); +} + +void DoTVShowBravoTrainerBattleTowerProfile(void) +{ + TVShow *tvShow; + u8 switchval; + + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + gScriptResult = 0; + switchval = gUnknown_020387E8; + switch(switchval) + { + case 0: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainerTower.trainerName, tvShow->bravoTrainerTower.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->bravoTrainerTower.species]); + if (tvShow->bravoTrainerTower.var16 >= 7) + { + gUnknown_020387E8 = 1; + } else + { + gUnknown_020387E8 = 2; + } + break; + case 1: + sub_80BF088(0, tvShow->bravoTrainerTower.btLevel); + sub_80BF088(1, tvShow->bravoTrainerTower.var16); + if (tvShow->bravoTrainerTower.var1c == 1) + { + gUnknown_020387E8 = 3; + } else + { + gUnknown_020387E8 = 4; + } + break; + case 2: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainerTower.pokemonName, tvShow->bravoTrainerTower.language); + sub_80BF088(1, tvShow->bravoTrainerTower.var16 + 1); + if (tvShow->bravoTrainerTower.var1b == 0) + { + gUnknown_020387E8 = 5; + } else + { + gUnknown_020387E8 = 6; + } + break; + case 3: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainerTower.pokemonName, tvShow->bravoTrainerTower.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->bravoTrainerTower.defeatedSpecies]); + if (tvShow->bravoTrainerTower.var1b == 0) + { + gUnknown_020387E8 = 5; + } else + { + gUnknown_020387E8 = 6; + } + break; + case 4: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainerTower.pokemonName, tvShow->bravoTrainerTower.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->bravoTrainerTower.defeatedSpecies]); + if (tvShow->bravoTrainerTower.var1b == 0) + { + gUnknown_020387E8 = 5; + } else + { + gUnknown_020387E8 = 6; + } + break; + case 5: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainerTower.pokemonName, tvShow->bravoTrainerTower.language); + gUnknown_020387E8 = 11; + break; + case 6: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainerTower.pokemonName, tvShow->bravoTrainerTower.language); + gUnknown_020387E8 = 11; + break; + case 7: + gUnknown_020387E8 = 11; + break; + case 8: + case 9: + case 10: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainerTower.trainerName, tvShow->bravoTrainerTower.language); + gUnknown_020387E8 = 11; + break; + case 11: + sub_80EB3FC(gStringVar1, tvShow->bravoTrainerTower.var18[0]); + if (tvShow->bravoTrainerTower.var1b == 0) + { + gUnknown_020387E8 = 12; + } else + { + gUnknown_020387E8 = 13; + } + break; + case 12: + case 13: + sub_80EB3FC(gStringVar1, tvShow->bravoTrainerTower.var18[0]); + TVShowConvertInternationalString(gStringVar2, tvShow->bravoTrainerTower.trainerName, tvShow->bravoTrainerTower.language); + TVShowConvertInternationalString(gStringVar3, tvShow->bravoTrainerTower.pokemonName, tvShow->bravoTrainerTower.language); + gUnknown_020387E8 = 14; + break; + case 14: + TVShowConvertInternationalString(gStringVar1, tvShow->bravoTrainerTower.trainerName, tvShow->bravoTrainerTower.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->bravoTrainerTower.species]); + TVShowDone(); + break; + } + ShowFieldMessage(gTVBravoTrainerBattleTowerTextGroup[switchval]); +} + +void DoTVShowTodaysSmartShopper(void) +{ + TVShow *tvShow; + u8 switchval; + + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + gScriptResult = 0; + switchval = gUnknown_020387E8; + switch(switchval) + { + case 0: + TVShowConvertInternationalString(gStringVar1, tvShow->smartshopperShow.playerName, tvShow->smartshopperShow.language); + sub_80FBFB4(gStringVar2, tvShow->smartshopperShow.shopLocation, 0); + if (tvShow->smartshopperShow.itemAmounts[0] >= 0xff) + { + gUnknown_020387E8 = 11; + } else + { + gUnknown_020387E8 = 1; + } + break; + case 1: + TVShowConvertInternationalString(gStringVar1, tvShow->smartshopperShow.playerName, tvShow->smartshopperShow.language); + StringCopy(gStringVar2, ItemId_GetItem(tvShow->smartshopperShow.itemIds[0])->name); + sub_80BF088(2, tvShow->smartshopperShow.itemAmounts[0]); + gUnknown_020387E8 += (Random() % 4) + 1; + break; + case 2: + case 4: + case 5: + if (tvShow->smartshopperShow.itemIds[1] != 0) + { + gUnknown_020387E8 = 6; + } else + { + gUnknown_020387E8 = 10; + } + break; + case 3: + sub_80BF088(2, tvShow->smartshopperShow.itemAmounts[0] + 1); + if (tvShow->smartshopperShow.itemIds[1] != 0) + { + gUnknown_020387E8 = 6; + } else + { + gUnknown_020387E8 = 10; + } + break; + case 6: + StringCopy(gStringVar2, ItemId_GetItem(tvShow->smartshopperShow.itemIds[1])->name); + sub_80BF088(2, tvShow->smartshopperShow.itemAmounts[1]); + if (tvShow->smartshopperShow.itemIds[2] != 0) + { + gUnknown_020387E8 = 7; + } else if (tvShow->smartshopperShow.priceReduced == 1) + { + gUnknown_020387E8 = 8; + } else + { + gUnknown_020387E8 = 9; + } + break; + case 7: + StringCopy(gStringVar2, ItemId_GetItem(tvShow->smartshopperShow.itemIds[2])->name); + sub_80BF088(2, tvShow->smartshopperShow.itemAmounts[2]); + if (tvShow->smartshopperShow.priceReduced == 1) + { + gUnknown_020387E8 = 8; + } else + { + gUnknown_020387E8 = 9; + } + break; + case 8: + if (tvShow->smartshopperShow.itemAmounts[0] < 0xff) + { + gUnknown_020387E8 = 9; + } else + { + gUnknown_020387E8 = 12; + } + break; + case 9: + sub_80BF154(1, &tvShow->smartshopperShow); + TVShowDone(); + break; + case 10: + if (tvShow->smartshopperShow.priceReduced == 1) + { + gUnknown_020387E8 = 8; + } else + { + gUnknown_020387E8 = 9; + } + break; + case 11: + TVShowConvertInternationalString(gStringVar1, tvShow->smartshopperShow.playerName, tvShow->smartshopperShow.language); + StringCopy(gStringVar2, ItemId_GetItem(tvShow->smartshopperShow.itemIds[0])->name); + if (tvShow->smartshopperShow.priceReduced == 1) + { + gUnknown_020387E8 = 8; + } else + { + gUnknown_020387E8 = 12; + } + break; + case 12: + TVShowConvertInternationalString(gStringVar1, tvShow->smartshopperShow.playerName, tvShow->smartshopperShow.language); + TVShowDone(); + break; + } + ShowFieldMessage(gTVSmartShopperTextGroup[switchval]); +} + +void DoTVShowTheNameRaterShow(void) { + TVShow *tvShow; + u8 switchval; + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + gScriptResult = 0; + switchval = gUnknown_020387E8; + switch (switchval) { + case 0: + TVShowConvertInternationalString(gStringVar1, tvShow->nameRaterShow.trainerName, tvShow->nameRaterShow.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->nameRaterShow.species]); + TVShowConvertInternationalString(gStringVar3, tvShow->nameRaterShow.pokemonName, tvShow->nameRaterShow.pokemonNameLanguage); + gUnknown_020387E8 = sub_80BF7E8(&tvShow->nameRaterShow) + 1; + break; + case 1: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + if (tvShow->nameRaterShow.random == 0) { + gUnknown_020387E8 = 9; + } else if (tvShow->nameRaterShow.random == 1) { + gUnknown_020387E8 = 10; + } else if (tvShow->nameRaterShow.random == 2) { + gUnknown_020387E8 = 11; + } + break; + case 2: + TVShowConvertInternationalString(gStringVar1, tvShow->nameRaterShow.trainerName, tvShow->nameRaterShow.language); + if (tvShow->nameRaterShow.random == 0) { + gUnknown_020387E8 = 9; + } else if (tvShow->nameRaterShow.random == 1) { + gUnknown_020387E8 = 10; + } else if (tvShow->nameRaterShow.random == 2) { + gUnknown_020387E8 = 11; + } + break; + case 9: + case 10: + case 11: + sub_80BF820(0, 1, 0, 1, 0, &tvShow->nameRaterShow); + TVShowConvertInternationalString(gStringVar3, gStringVar1, tvShow->nameRaterShow.pokemonNameLanguage); + sub_80BF820(0, 0, 0, 1, 0, &tvShow->nameRaterShow); + TVShowConvertInternationalString(gStringVar2, gStringVar1, tvShow->nameRaterShow.pokemonNameLanguage); + TVShowConvertInternationalString(gStringVar1, tvShow->nameRaterShow.pokemonName, tvShow->nameRaterShow.pokemonNameLanguage); + gUnknown_020387E8 = 12; + break; + case 13: + sub_80BF820(0, 0, 3, 1, 0, &tvShow->nameRaterShow); + TVShowConvertInternationalString(gStringVar3, gStringVar1, tvShow->nameRaterShow.pokemonNameLanguage); + sub_80BF820(0, 0, 2, 0, 0, &tvShow->nameRaterShow); + TVShowConvertInternationalString(gStringVar2, gStringVar1, tvShow->nameRaterShow.language); + TVShowConvertInternationalString(gStringVar1, tvShow->nameRaterShow.trainerName, tvShow->nameRaterShow.language); + gUnknown_020387E8 = 14; + break; + case 14: + sub_80BF820(0, 0, 3, 0, 0, &tvShow->nameRaterShow); + TVShowConvertInternationalString(gStringVar3, gStringVar1, tvShow->nameRaterShow.language); + sub_80BF820(0, 0, 2, 1, 0, &tvShow->nameRaterShow); + TVShowConvertInternationalString(gStringVar2, gStringVar1, tvShow->nameRaterShow.pokemonNameLanguage); + TVShowConvertInternationalString(gStringVar1, tvShow->nameRaterShow.trainerName, tvShow->nameRaterShow.language); + gUnknown_020387E8 = 18; + break; + case 15: + sub_80BF820(1, 0, 2, 1, 0, &tvShow->nameRaterShow); + TVShowConvertInternationalString(gStringVar1, gStringVar2, tvShow->nameRaterShow.pokemonNameLanguage); + StringCopy(gStringVar2, gSpeciesNames[tvShow->nameRaterShow.species]); + sub_80BF820(2, 0, 3, 2, tvShow->nameRaterShow.species, &tvShow->nameRaterShow); + gUnknown_020387E8 = 16; + break; + case 16: + sub_80BF820(0, 0, 3, 1, 0, &tvShow->nameRaterShow); + TVShowConvertInternationalString(gStringVar3, gStringVar1, tvShow->nameRaterShow.pokemonNameLanguage); + sub_80BF820(0, 0, 2, 2, tvShow->nameRaterShow.species, &tvShow->nameRaterShow); + gUnknown_020387E8 = 17; + break; + case 17: + sub_80BF820(1, 0, 2, 1, 0, &tvShow->nameRaterShow); + TVShowConvertInternationalString(gStringVar1, gStringVar2, tvShow->nameRaterShow.pokemonNameLanguage); + sub_80BF820(2, 0, 3, 2, tvShow->nameRaterShow.var1C, &tvShow->nameRaterShow); + StringCopy(gStringVar2, gSpeciesNames[tvShow->nameRaterShow.var1C]); + gUnknown_020387E8 = 18; + break; + case 12: + switchval = 18; + gUnknown_020387E8 = 18; + case 18: + TVShowConvertInternationalString(gStringVar1, tvShow->nameRaterShow.pokemonName, tvShow->nameRaterShow.pokemonNameLanguage); + TVShowConvertInternationalString(gStringVar2, tvShow->nameRaterShow.trainerName, tvShow->nameRaterShow.language); + TVShowDone(); + break; + } + ShowFieldMessage(gTVNameRaterTextGroup[switchval]); +} + +void DoTVShowPokemonTodaySuccessfulCapture(void) { + TVShow *tvShow; + u8 switchval; + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + gScriptResult = 0; + switchval = gUnknown_020387E8; + switch (switchval) { + case 0: + TVShowConvertInternationalString(gStringVar1, tvShow->pokemonToday.playerName, tvShow->pokemonToday.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->pokemonToday.species]); + TVShowConvertInternationalString(gStringVar3, tvShow->pokemonToday.nickname, tvShow->pokemonToday.language2); + if (tvShow->pokemonToday.ball == ITEM_MASTER_BALL) { + gUnknown_020387E8 = 5; + } else { + gUnknown_020387E8 = 1; + } + break; + case 1: + gUnknown_020387E8 = 2; + break; + case 2: + StringCopy(gStringVar2, ItemId_GetItem(tvShow->pokemonToday.ball)->name); + sub_80BF088(2, tvShow->pokemonToday.var12); + if (tvShow->pokemonToday.var12 < 4) { + gUnknown_020387E8 = 3; + } else { + gUnknown_020387E8 = 4; + } + break; + case 3: + TVShowConvertInternationalString(gStringVar1, tvShow->pokemonToday.playerName, tvShow->pokemonToday.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->pokemonToday.species]); + TVShowConvertInternationalString(gStringVar3, tvShow->pokemonToday.nickname, tvShow->pokemonToday.language2); + gUnknown_020387E8 = 6; + break; + case 4: + gUnknown_020387E8 = 6; + break; + case 5: + TVShowConvertInternationalString(gStringVar1, tvShow->pokemonToday.playerName, tvShow->pokemonToday.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->pokemonToday.species]); + gUnknown_020387E8 = 6; + break; + case 6: + TVShowConvertInternationalString(gStringVar1, tvShow->pokemonToday.playerName, tvShow->pokemonToday.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->pokemonToday.species]); + TVShowConvertInternationalString(gStringVar3, tvShow->pokemonToday.nickname, tvShow->pokemonToday.language2); + gUnknown_020387E8 += (Random() % 4) + 1; + break; + case 7: + case 8: + StringCopy(gStringVar1, gSpeciesNames[tvShow->pokemonToday.species]); + TVShowConvertInternationalString(gStringVar2, tvShow->pokemonToday.nickname, tvShow->pokemonToday.language2); + sub_80BF638(2, tvShow->pokemonToday.species); + gUnknown_020387E8 = 11; + break; + case 9: + case 10: + StringCopy(gStringVar1, gSpeciesNames[tvShow->pokemonToday.species]); + TVShowConvertInternationalString(gStringVar2, tvShow->pokemonToday.nickname, tvShow->pokemonToday.language2); + gUnknown_020387E8 = 11; + break; + case 11: + TVShowDone(); + break; + } + ShowFieldMessage(gTVPokemonTodayTextGroup[switchval]); +} + +void DoTVShowPokemonTodayFailedCapture(void) { + TVShow *tvShow; + u8 switchval; + u16 rval; + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + gScriptResult = 0; + switchval = gUnknown_020387E8; + switch (switchval) { + case 0: + TVShowConvertInternationalString(gStringVar1, tvShow->pokemonTodayFailed.playerName, tvShow->pokemonTodayFailed.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->pokemonTodayFailed.species]); + gUnknown_020387E8 = 1; + break; + case 1: + TVShowConvertInternationalString(gStringVar1, tvShow->pokemonTodayFailed.playerName, tvShow->pokemonTodayFailed.language); + sub_80FBFB4(gStringVar2, tvShow->pokemonTodayFailed.var12, 0); + StringCopy(gStringVar3, gSpeciesNames[tvShow->pokemonTodayFailed.species2]); + if (tvShow->pokemonTodayFailed.var11 == 1) { + gUnknown_020387E8 = 3; + } else { + gUnknown_020387E8 = 2; + } + break; + case 2: + case 3: + TVShowConvertInternationalString(gStringVar1, tvShow->pokemonTodayFailed.playerName, tvShow->pokemonTodayFailed.language); + sub_80BF088(1, tvShow->pokemonTodayFailed.var10); + rval = (Random() % 3); + if (rval == 0) { + gUnknown_020387E8 = 5; + } else { + gUnknown_020387E8 = 4; + } + break; + case 4: + case 5: + TVShowConvertInternationalString(gStringVar1, tvShow->pokemonTodayFailed.playerName, tvShow->pokemonTodayFailed.language); + gUnknown_020387E8 = 6; + break; + case 6: + TVShowDone(); + break; + } + ShowFieldMessage(gTVPokemonTodayFailedCaptureTextGroup[switchval]); +} + +void DoTVShowPokemonFanClubLetter(void) { + TVShow *tvShow; + u8 switchval; + u16 rval; + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + gScriptResult = 0; + switchval = gUnknown_020387E8; + switch (switchval) { + case 0: + TVShowConvertInternationalString(gStringVar1, tvShow->fanclubLetter.playerName, tvShow->fanclubLetter.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->fanclubLetter.species]); + gUnknown_020387E8 = 50; + break; + case 1: + rval = (Random() % 4) + 1; + if (rval == 1) { + gUnknown_020387E8 = 2; + } else { + gUnknown_020387E8 = rval + 2; + } + break; + case 2: + gUnknown_020387E8 = 51; + break; + case 3: + gUnknown_020387E8 += (Random() % 3) + 1; + break; + case 4: + case 5: + case 6: + sub_80BF79C(tvShow); + gUnknown_020387E8 = 7; + break; + case 7: + rval = (Random() % 0x1f) + 0x46; + sub_80BF088(2, rval); + TVShowDone(); + break; + case 50: + ConvertEasyChatWordsToString(gStringVar4, tvShow->fanclubLetter.pad04, 2, 2); + ShowFieldMessage(gStringVar4); + gUnknown_020387E8 = 1; + return; + case 51: + ConvertEasyChatWordsToString(gStringVar4, tvShow->fanclubLetter.pad04, 2, 2); + ShowFieldMessage(gStringVar4); + gUnknown_020387E8 = 3; + return; + } + ShowFieldMessage(gTVFanClubTextGroup[switchval]); +} + +void DoTVShowRecentHappenings(void) { + TVShow *tvShow; + u8 switchval; + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + gScriptResult = 0; + switchval = gUnknown_020387E8; + switch (switchval) { + case 0: + TVShowConvertInternationalString(gStringVar1, tvShow->recentHappenings.playerName, tvShow->recentHappenings.language); + sub_80BF79C(tvShow); + gUnknown_020387E8 = 50; + break; + case 1: + gUnknown_020387E8 += 1 + (Random() % 3); + break; + case 2: + case 3: + case 4: + gUnknown_020387E8 = 5; + break; + case 5: + TVShowDone(); + break; + case 50: + ConvertEasyChatWordsToString(gStringVar4, tvShow->recentHappenings.var04, 2, 2); + ShowFieldMessage(gStringVar4); + gUnknown_020387E8 = 1; + return; + } + ShowFieldMessage(gTVRecentHappeningsTextGroup[switchval]); +} + +void DoTVShowPokemonFanClubOpinions(void) { + TVShow *tvShow; + u8 switchval; + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + gScriptResult = 0; + switchval = gUnknown_020387E8; + switch (switchval) { + case 0: + TVShowConvertInternationalString(gStringVar1, tvShow->fanclubOpinions.playerName, tvShow->fanclubOpinions.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->fanclubOpinions.var02]); + TVShowConvertInternationalString(gStringVar3, tvShow->fanclubOpinions.var10, tvShow->fanclubOpinions.var0E); + gUnknown_020387E8 = tvShow->fanclubOpinions.var04B + 1; + break; + case 1: + case 2: + case 3: + TVShowConvertInternationalString(gStringVar1, tvShow->fanclubOpinions.playerName, tvShow->fanclubOpinions.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->fanclubOpinions.var02]); + sub_80EB3FC(gStringVar3, tvShow->fanclubOpinions.var1C[0]); + gUnknown_020387E8 = 4; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, tvShow->fanclubOpinions.playerName, tvShow->fanclubOpinions.language); + sub_80EB3FC(gStringVar3, tvShow->fanclubOpinions.var1C[1]); + TVShowDone(); + break; + } + ShowFieldMessage(gTVFanClubOpinionsTextGroup[switchval]); +} + +void nullsub_22(void) { + +} + +void DoTVShowPokemonNewsMassOutbreak(void) +{ + TVShow *tvShow; + + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + + sub_80FBFB4(gStringVar1, tvShow->massOutbreak.locationMapNum, 0); + + StringCopy(gStringVar2, gSpeciesNames[tvShow->massOutbreak.species]); + + TVShowDone(); + StartMassOutbreak(); + + ShowFieldMessage(gTVPokemonOutbreakTextGroup[gUnknown_020387E8]); +} + +void DoTVShowInSearchOfTrainers(void) { + u8 switchval; + gScriptResult = 0; + switchval = gUnknown_020387E8; + switch (switchval) { + case 0: + sub_80FBFB4(gStringVar1, gSaveBlock1.gabbyAndTyData.mapnum, 0); + if (gSaveBlock1.gabbyAndTyData.battleNum > 1) { + gUnknown_020387E8 = 1; + } else { + gUnknown_020387E8 = 2; + } + break; + case 1: + gUnknown_020387E8 = 2; + break; + case 2: + if (gSaveBlock1.gabbyAndTyData.valA_0 == 0) { + gUnknown_020387E8 = 4; + } else if (gSaveBlock1.gabbyAndTyData.valA_3 != 0) { + gUnknown_020387E8 = 5; + } else if (gSaveBlock1.gabbyAndTyData.valA_2 != 0) { + gUnknown_020387E8 = 6; + } else if (gSaveBlock1.gabbyAndTyData.valA_1 != 0) { + gUnknown_020387E8 = 7; + } else { + gUnknown_020387E8 = 3; + } + break; + case 3: + StringCopy(gStringVar1, gSpeciesNames[gSaveBlock1.gabbyAndTyData.mon1]); + StringCopy(gStringVar2, gMoveNames[gSaveBlock1.gabbyAndTyData.lastMove]); + StringCopy(gStringVar3, gSpeciesNames[gSaveBlock1.gabbyAndTyData.mon2]); + gUnknown_020387E8 = 8; + break; + case 4: + case 5: + case 6: + case 7: + gUnknown_020387E8 = 8; + break; + case 8: + sub_80EB3FC(gStringVar1, gSaveBlock1.gabbyAndTyData.quote); + StringCopy(gStringVar2, gSpeciesNames[gSaveBlock1.gabbyAndTyData.mon1]); + StringCopy(gStringVar3, gSpeciesNames[gSaveBlock1.gabbyAndTyData.mon2]); + gScriptResult = 1; + gUnknown_020387E8 = 0;; + TakeTVShowInSearchOfTrainersOffTheAir(); + break; + } + ShowFieldMessage(gTVGabbyAndTyTextGroup[switchval]); +} + +void DoTVShowPokemonAngler(void) { + TVShow *tvShow; + u8 switchval; + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + gScriptResult = 0; + if (tvShow->pokemonAngler.var02 < tvShow->pokemonAngler.var03) { + gUnknown_020387E8 = 0; + } else { + gUnknown_020387E8 = 1; + } + switchval = gUnknown_020387E8; + switch (switchval) { + case 0: + TVShowConvertInternationalString(gStringVar1, tvShow->pokemonAngler.playerName, tvShow->pokemonAngler.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->pokemonAngler.var04]); + sub_80BF088(2, tvShow->pokemonAngler.var03); + TVShowDone(); + break; + case 1: + TVShowConvertInternationalString(gStringVar1, tvShow->pokemonAngler.playerName, tvShow->pokemonAngler.language); + StringCopy(gStringVar2, gSpeciesNames[tvShow->pokemonAngler.var04]); + sub_80BF088(2, tvShow->pokemonAngler.var02); + TVShowDone(); + break; + } + ShowFieldMessage(gTVFishingGuruAdviceTextGroup[switchval]); +} + +void DoTVShowTheWorldOfMasters(void) { + TVShow *tvShow; + u8 switchval; + tvShow = &gSaveBlock1.tvShows[gSpecialVar_0x8004]; + gScriptResult = 0; + switchval = gUnknown_020387E8; + switch (switchval) { + case 0: + TVShowConvertInternationalString(gStringVar1, tvShow->worldOfMasters.playerName, + tvShow->worldOfMasters.language); + sub_80BF088(1, tvShow->worldOfMasters.var06); + sub_80BF088(2, tvShow->worldOfMasters.var02); + gUnknown_020387E8 = 1; + break; + case 1: + StringCopy(gStringVar1, gSpeciesNames[tvShow->worldOfMasters.var08]); + gUnknown_020387E8 = 2; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, tvShow->worldOfMasters.playerName, + tvShow->worldOfMasters.language); + sub_80FBFB4(gStringVar2, tvShow->worldOfMasters.var0a, 0); + StringCopy(gStringVar3, gSpeciesNames[tvShow->worldOfMasters.var04]); + TVShowDone(); + break; + } + ShowFieldMessage(gTVWorldOfMastersTextGroup[switchval]); +} + +void TVShowDone(void) +{ + gScriptResult = 1; + gUnknown_020387E8 = 0; + + gSaveBlock1.tvShows[gSpecialVar_0x8004].common.var01 = 0; +} + +void sub_80C2014(void) +{ + gUnknown_020387E8 = 0; +} diff --git a/src/unknown_debug_menu.c b/src/unknown_debug_menu.c new file mode 100644 index 000000000..6a8bad0d4 --- /dev/null +++ b/src/unknown_debug_menu.c @@ -0,0 +1,52 @@ +#include "global.h" +#include "menu.h" + +extern u8 gBattleCommunication[]; + +extern u8 (*gCallback_03004AE8)(void); + +extern const struct MenuAction gUnknown_0842C29C[]; + +static u8 sub_814A464(void); + +int unref_sub_814A414(void) +{ + MenuZeroFillScreen(); + MenuDrawTextWindow(0, 0, 16, 18); + PrintMenuItems(2, 1, 8, gUnknown_0842C29C); + InitMenu(0, 1, 1, 8, 0, 15); + gCallback_03004AE8 = sub_814A464; + return 0; +} + +static u8 sub_814A464(void) +{ + s8 result = ProcessMenuInput(); + if (result == -2) + { + return 0; + } + else if (result == -1) + { + CloseMenu(); + return 1; + } + else + { + gBattleCommunication[0] = result; + gCallback_03004AE8 = gUnknown_0842C29C[result].func; + return 0; + } +} + +u8 sub_814A4B8(void) +{ + gSaveBlock2.filler_A8.var_4AE = 3; + gSaveBlock2.filler_A8.var_4AF = 3; + gSaveBlock2.filler_A8.var_4B4 = gBattleCommunication[0] + 1; + gSaveBlock2.filler_A8.var_4B6 = gBattleCommunication[0] + 1; + gSaveBlock2.filler_A8.var_4B0 = 1; + gSaveBlock2.filler_A8.var_4B2 = 1; + CloseMenu(); + return 1; +} diff --git a/src/unused_8124F94.c b/src/unused_8124F94.c new file mode 100644 index 000000000..93b569058 --- /dev/null +++ b/src/unused_8124F94.c @@ -0,0 +1,126 @@ +#include "global.h" +#include "decompress.h" +#include "palette.h" + +struct UnknownStruct2 +{ + void *src; + u8 unk4; + u8 unk5; + u8 unk6; + u16 unk8; +}; + +struct UnknownStruct3 +{ + u16 *paletteSrc; + u8 unk4; + u8 paletteCount; +}; + +struct UnknownStruct1 +{ + u8 paletteNum; + u8 unk1; + u16 unk2; + u8 *dest; + struct UnknownStruct3 unk8[16]; + struct UnknownStruct2 unk88[32]; +}; + +void unref_sub_8124F94(struct UnknownStruct1 *a) +{ + a->unk1 = 0; + a->paletteNum = 0; + a->unk2 = 0; + a->dest = (void *)VRAM; + DmaFill16(3, 0, a->unk8, sizeof(a->unk8)); + DmaFill16(3, 0, a->unk88, sizeof(a->unk88)); +} + +u8 unref_sub_8124FD8(struct UnknownStruct1 *a, const struct UnknownStruct2 *b) +{ + while (1) + { + s32 r6; + s32 temp; + + // Couldn't get it to match any other way + if (a->unk1 < 32 && b->src == NULL) + return 0; + if (a->unk1 >= 32) + break; + + a->unk88[a->unk1].src = b->src; + a->unk88[a->unk1].unk6 = b->unk6; + a->unk88[a->unk1].unk4 = b->unk4; + a->unk88[a->unk1].unk5 = b->unk5; + r6 = b->unk4 * b->unk5; + if (a->unk2 + r6 > 0x400) + return 2; + if (b->unk8 == 0) + { + DmaCopy16(3, b->src, a->dest + a->unk2 * 64, r6 * 32); + } + else + { + sub_800D238(b->src, a->dest + a->unk2 * 64); + } + a->unk88[a->unk1].unk8 = a->unk2; + temp = r6 + a->unk2; + a->unk2 = temp; + a->unk1++; + b++; + } + return 1; +} + +u8 unref_sub_81250A4(struct UnknownStruct1 *a, struct UnknownStruct3 *b) +{ + while (1) + { + // Couldn't get it to match any other way + if (a->paletteNum < 16 && b->paletteSrc == NULL) + return 0; + if (a->paletteNum >= 16) + break; + + a->unk8[a->paletteNum].paletteSrc = b->paletteSrc; + a->unk8[a->paletteNum].unk4 = b->unk4; + if (b->paletteCount == 0) + { + LoadPalette(b->paletteSrc, a->paletteNum * 16, 32); + } + else + { + u16 palette[16]; + + sub_800D238(b->paletteSrc, palette); + LoadPalette(palette, a->paletteNum * 16, 32); + } + a->unk8[a->paletteNum].paletteCount = a->paletteNum; + a->paletteNum = a->paletteNum + 1; + b++; + } + return 1; +} + +u8 unref_sub_8125118(struct UnknownStruct1 *a, struct UnknownStruct3 *b) +{ + u16 palettes[16][16] = {0}; + u8 r7 = b->paletteCount; + u8 i; + + sub_800D238(b->paletteSrc, palettes); + for (i = a->paletteNum; i < r7; i++) + { + if (a->paletteNum + i >= 16) + return 1; + a->unk8[i].paletteSrc = b->paletteSrc; + a->unk8[i].unk4 = b->unk4 + i; + a->unk8[i].paletteCount = a->paletteNum; + LoadPalette(palettes[i], a->paletteNum * 16, sizeof(palettes[i])); + a->paletteNum++; + } + return 0; +} diff --git a/src/util.c b/src/util.c new file mode 100644 index 000000000..c83fe8c8a --- /dev/null +++ b/src/util.c @@ -0,0 +1,389 @@ +#include "global.h" +#include "util.h" + +extern const struct SpriteTemplate gInvisibleSpriteTemplate; +extern const u8 gSpriteDimensions[3][4][2]; +extern const u16 gCrc16Table[]; + +u8 CreateInvisibleSpriteWithCallback(void (*callback)(struct Sprite *)) { + u8 sprite = CreateSprite(&gInvisibleSpriteTemplate, 248, 168, 14); + gSprites[sprite].invisible = TRUE; + gSprites[sprite].callback = callback; + return sprite; +} + +void StoreWordInTwoHalfwords(u16 *h, u32 w) { + h[0] = (u16)(w); + h[1] = (u16)(w >> 16); +} + +void LoadWordFromTwoHalfwords(u16 *h, u32 *w) { + *w = h[0] | (s16)h[1] << 16; +} + +void SetBgAffineStruct(struct BgAffineSrcData *src, u32 texX, u32 texY, s16 scrX, s16 scrY, s16 sx, s16 sy, u16 alpha) { + src->texX = texX; + src->texY = texY; + src->scrX = scrX; + src->scrY = scrY; + src->sx = sx; + src->sy = sy; + src->alpha = alpha; +} + +void DoBgAffineSet(struct BgAffineDstData *dest, u32 texX, u32 texY, s16 scrX, s16 scrY, s16 sx, s16 sy, u16 alpha) { + struct BgAffineSrcData src; + SetBgAffineStruct( + &src, + texX, texY, + scrX, scrY, + sx, sy, + alpha + ); + BgAffineSet(&src, dest, 1); +} + +#ifdef NONMATCHING + +// Functionally equivalent. +// Only the two yflip loops don't match. +void CopySpriteTiles(u8 shape, u8 size, u8 *tiles, u16 *tilemap, u8 *output) { + u8 x, y; + s8 i, j; + u8 xflip[32]; + u8 h = gSpriteDimensions[shape][size][1]; + u8 w = gSpriteDimensions[shape][size][0]; + for (y = 0; y < h; y++) { + int filler = 32 - w; + for (x = 0; x < w; x++) { + int tile = (*tilemap & 0x3ff) * 32; + int attr = *tilemap & 0xc00; + if (attr == 0) { + void *src = tiles + tile; + void *dest = output; + int length = 32; + DmaCopy32(3, src, dest, length); + } else if (attr == 0x800) { // yflip + for (i = 0; i < 8; i++) { + void *src = tiles; + void *dest = output; + int length = 4; + // this is likely wrong, but makes it closer to matching + src += tile + (7 - i) * 4; + dest += i * 4; + DmaCopy32(3, src, dest, length); + } + } else { // xflip + for (i = 0; i < 8; i++) { + for (j = 0; j < 4; j++) { + u8 i2 = i * 4; + xflip[i2 + (3-j)] = (tiles[tile + i2 + j] & 0xf) << 4; + xflip[i2 + (3-j)] |= tiles[tile + i2 + j] >> 4; + } + } + if (*tilemap & 0x800) { // yflip + for (i = 0; i < 8; i++) { + void *src = xflip + (7-i) * 4; + void *dest = output + i*4; + int length = 4; + DmaCopy32(3, src, dest, length); + } + } else { + void *src = xflip; + void *dest = output; + int length = 32; + DmaCopy32(3, src, dest, length); + } + } + tilemap++; + output += 32; + } + tilemap += filler; + } +} + +#else + +__attribute__((naked)) void CopySpriteTiles(u8 shape, u8 size, u8 *tiles, u16 *tilemap, u8 *output) { + asm("\n" + " .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, 0x3C\n" + " str r2, [sp, 0x20]\n" + " adds r4, r3, 0\n" + " ldr r7, [sp, 0x5C]\n" + " lsls r0, 24\n" + " lsls r1, 24\n" + " ldr r2, _08041008 @ =gSpriteDimensions\n" + " lsrs r1, 23\n" + " lsrs r0, 21\n" + " adds r1, r0\n" + " adds r0, r2, 0x1\n" + " adds r0, r1, r0\n" + " ldrb r0, [r0]\n" + " str r0, [sp, 0x24]\n" + " adds r1, r2\n" + " ldrb r1, [r1]\n" + " str r1, [sp, 0x28]\n" + " movs r1, 0\n" + " cmp r1, r0\n" + " bcc _08040FB4\n" + " b _08041136\n" + "_08040FB4:\n" + " movs r0, 0x20\n" + " ldr r2, [sp, 0x28]\n" + " subs r0, r2\n" + " lsls r0, 1\n" + " str r0, [sp, 0x2C]\n" + "_08040FBE:\n" + " movs r2, 0\n" + " adds r1, 0x1\n" + " str r1, [sp, 0x34]\n" + " ldr r3, [sp, 0x28]\n" + " cmp r2, r3\n" + " bcc _08040FCC\n" + " b _08041124\n" + "_08040FCC:\n" + " ldr r0, _0804100C @ =0x040000d4\n" + " mov r8, r0\n" + "_08040FD0:\n" + " ldrh r1, [r4]\n" + " ldr r0, _08041010 @ =0x000003ff\n" + " ands r0, r1\n" + " lsls r0, 5\n" + " mov r12, r0\n" + " movs r0, 0xC0\n" + " lsls r0, 4\n" + " ands r0, r1\n" + " mov r3, sp\n" + " strh r1, [r3, 0x38]\n" + " cmp r0, 0\n" + " bne _08041018\n" + " ldr r0, [sp, 0x20]\n" + " add r0, r12\n" + " mov r1, r8\n" + " str r0, [r1]\n" + " str r7, [r1, 0x4]\n" + " ldr r3, _08041014 @ =0x84000008\n" + " str r3, [r1, 0x8]\n" + " ldr r0, [r1, 0x8]\n" + " adds r4, 0x2\n" + " str r4, [sp, 0x30]\n" + " adds r7, 0x20\n" + " mov r10, r7\n" + " adds r2, 0x1\n" + " mov r9, r2\n" + " b _08041112\n" + " .align 2, 0\n" + "_08041008: .4byte gSpriteDimensions\n" + "_0804100C: .4byte 0x040000d4\n" + "_08041010: .4byte 0x000003ff\n" + "_08041014: .4byte 0x84000008\n" + "_08041018:\n" + " movs r1, 0x80\n" + " lsls r1, 4\n" + " cmp r0, r1\n" + " bne _08041068\n" + " movs r3, 0\n" + " adds r4, 0x2\n" + " str r4, [sp, 0x30]\n" + " movs r0, 0x20\n" + " adds r0, r7\n" + " mov r10, r0\n" + " adds r2, 0x1\n" + " mov r9, r2\n" + " ldr r4, _08041060 @ =0x040000d4\n" + " ldr r6, _08041064 @ =0x84000001\n" + " movs r5, 0x7\n" + "_08041036:\n" + " lsls r2, r3, 24\n" + " asrs r2, 24\n" + " subs r0, r5, r2\n" + " lsls r0, 2\n" + " add r0, r12\n" + " ldr r1, [sp, 0x20]\n" + " adds r0, r1, r0\n" + " lsls r1, r2, 2\n" + " adds r1, r7, r1\n" + " str r0, [r4]\n" + " str r1, [r4, 0x4]\n" + " str r6, [r4, 0x8]\n" + " ldr r0, [r4, 0x8]\n" + " adds r2, 0x1\n" + " lsls r2, 24\n" + " lsrs r3, r2, 24\n" + " asrs r2, 24\n" + " cmp r2, 0x7\n" + " ble _08041036\n" + " b _08041112\n" + " .align 2, 0\n" + "_08041060: .4byte 0x040000d4\n" + "_08041064: .4byte 0x84000001\n" + "_08041068:\n" + " movs r3, 0\n" + " adds r4, 0x2\n" + " str r4, [sp, 0x30]\n" + " movs r0, 0x20\n" + " adds r0, r7\n" + " mov r10, r0\n" + " adds r2, 0x1\n" + " mov r9, r2\n" + "_08041078:\n" + " movs r2, 0\n" + " lsls r4, r3, 24\n" + " lsls r0, r4, 2\n" + " lsrs r0, 24\n" + " adds r6, r0, 0x3\n" + " mov r1, r12\n" + " adds r5, r1, r0\n" + "_08041086:\n" + " lsls r1, r2, 24\n" + " asrs r1, 24\n" + " subs r0, r6, r1\n" + " mov r2, sp\n" + " adds r3, r2, r0\n" + " adds r0, r5, r1\n" + " ldr r2, [sp, 0x20]\n" + " adds r0, r2, r0\n" + " ldrb r2, [r0]\n" + " movs r0, 0xF\n" + " ands r0, r2\n" + " lsls r0, 4\n" + " lsrs r2, 4\n" + " orrs r0, r2\n" + " strb r0, [r3]\n" + " adds r1, 0x1\n" + " lsls r1, 24\n" + " lsrs r2, r1, 24\n" + " asrs r1, 24\n" + " cmp r1, 0x3\n" + " ble _08041086\n" + " movs r3, 0x80\n" + " lsls r3, 17\n" + " adds r0, r4, r3\n" + " lsrs r3, r0, 24\n" + " asrs r0, 24\n" + " cmp r0, 0x7\n" + " ble _08041078\n" + " movs r0, 0x80\n" + " lsls r0, 4\n" + " mov r1, sp\n" + " ldrh r1, [r1, 0x38]\n" + " ands r0, r1\n" + " cmp r0, 0\n" + " beq _08041104\n" + " movs r3, 0\n" + " ldr r4, _080410FC @ =0x040000d4\n" + " ldr r6, _08041100 @ =0x84000001\n" + " movs r5, 0x7\n" + "_080410D4:\n" + " lsls r1, r3, 24\n" + " asrs r1, 24\n" + " subs r0, r5, r1\n" + " lsls r0, 2\n" + " mov r3, sp\n" + " adds r2, r3, r0\n" + " lsls r0, r1, 2\n" + " adds r0, r7, r0\n" + " str r2, [r4]\n" + " str r0, [r4, 0x4]\n" + " str r6, [r4, 0x8]\n" + " ldr r0, [r4, 0x8]\n" + " adds r1, 0x1\n" + " lsls r1, 24\n" + " lsrs r3, r1, 24\n" + " asrs r1, 24\n" + " cmp r1, 0x7\n" + " ble _080410D4\n" + " b _08041112\n" + " .align 2, 0\n" + "_080410FC: .4byte 0x040000d4\n" + "_08041100: .4byte 0x84000001\n" + "_08041104:\n" + " mov r0, sp\n" + " mov r1, r8\n" + " str r0, [r1]\n" + " str r7, [r1, 0x4]\n" + " ldr r2, _08041148 @ =0x84000008\n" + " str r2, [r1, 0x8]\n" + " ldr r0, [r1, 0x8]\n" + "_08041112:\n" + " ldr r4, [sp, 0x30]\n" + " mov r7, r10\n" + " mov r3, r9\n" + " lsls r0, r3, 24\n" + " lsrs r2, r0, 24\n" + " ldr r0, [sp, 0x28]\n" + " cmp r2, r0\n" + " bcs _08041124\n" + " b _08040FD0\n" + "_08041124:\n" + " ldr r1, [sp, 0x2C]\n" + " adds r4, r1\n" + " ldr r2, [sp, 0x34]\n" + " lsls r0, r2, 24\n" + " lsrs r1, r0, 24\n" + " ldr r3, [sp, 0x24]\n" + " cmp r1, r3\n" + " bcs _08041136\n" + " b _08040FBE\n" + "_08041136:\n" + " add sp, 0x3C\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" + " .align 2, 0\n" + "_08041148: .4byte 0x84000008\n" + " .syntax divided\n" + ); +} + +#endif + +int CountTrailingZeroBits(u32 value) { + u8 i; + for (i = 0; i < 32; i++) { + if ((value & 1) == 0) { + value >>= 1; + } else { + return i; + } + } + return 0; +} + +u16 CalcCRC16(u8 *data, int length) { + u16 i, j; + u16 crc = 0x1121; + for (i = 0; i < length; i++) { + crc ^= data[i]; + for (j = 0; j < 8; j++) { + if (crc & 1) { + crc = (crc >> 1) ^ 0x8408; + } else { + crc >>= 1; + } + } + } + return ~crc; +} + +u16 CalcCRC16WithTable(u8 *data, int length) { + u16 i; + u16 crc = 0x1121; + u8 byte; + for (i = 0; i < length; i++) { + byte = crc >> 8; + crc ^= data[i]; + crc = byte ^ gCrc16Table[(u8)crc]; + } + return ~crc; +} diff --git a/src/var.c b/src/var.c deleted file mode 100644 index 08b109e6f..000000000 --- a/src/var.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "global.h" -#include "var.h" - -extern u16 *gSpecialVars[]; - -u16 *GetVarPointer(u16 id) -{ - if (id < 0x4000) - return NULL; - - if ((s16)id >= 0) - return &gSaveBlock1.vars[id - 0x4000]; - - return gSpecialVars[id - 0x8000]; -} - -u16 VarGet(u16 id) -{ - u16 *ptr = GetVarPointer(id); - if (!ptr) - return id; - return *ptr; -} - -bool8 VarSet(u16 id, u16 value) -{ - u16 *ptr = GetVarPointer(id); - if (!ptr) - return FALSE; - *ptr = value; - return TRUE; -} - -u8 VarGetFieldObjectGraphicsId(u8 id) -{ - return VarGet(0x4010 + id); -} diff --git a/src/wallclock.c b/src/wallclock.c index e3b79efea..8db13dc2d 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -1,32 +1,152 @@ #include "global.h" #include "wallclock.h" -#include "asm.h" #include "decompress.h" #include "main.h" #include "menu.h" #include "palette.h" #include "rtc.h" #include "songs.h" +#include "sound.h" +#include "strings2.h" #include "task.h" #include "trig.h" -#include "sound.h" +#include "unknown_task.h" extern u16 gSpecialVar_0x8004; -extern u16 gMiscClockMale_Pal[]; -extern u16 gMiscClockFemale_Pal[]; extern u8 gMiscClock_Gfx[]; -extern struct SpriteSheet gUnknown_083F7A90; -extern struct SpritePalette gUnknown_083F7AA0; extern u8 gUnknown_08E95774[]; extern u8 gUnknown_08E954B0[]; -extern u8 gOtherText_CorrectTimePrompt[]; -extern const struct MenuAction gUnknown_08376D74[]; -extern s8 gClockHandCoords[][2]; +extern u16 gMiscClockMale_Pal[]; +extern u16 gMiscClockFemale_Pal[]; + +//-------------------------------------------------- +// Graphics Data +//-------------------------------------------------- -extern struct SpriteTemplate gSpriteTemplate_83F7AD8; -extern struct SpriteTemplate gSpriteTemplate_83F7AF0; -extern struct SpriteTemplate gSpriteTemplate_83F7B28; -extern struct SpriteTemplate gSpriteTemplate_83F7B40; +static const u8 ClockGfx_Misc[] = INCBIN_U8("graphics/misc/clock_misc.4bpp.lz"); +static const struct CompressedSpriteSheet gUnknown_083F7A90[] = +{ + {ClockGfx_Misc, 0x2000, 0x1000}, + {NULL}, +}; +static const struct SpritePalette gUnknown_083F7AA0[] = +{ + {gMiscClockMale_Pal, 0x1000}, + {gMiscClockFemale_Pal, 0x1001}, + {NULL}, +}; +static const struct OamData gOamData_83F7AB8 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_83F7AC0[] = +{ + ANIMCMD_FRAME(0, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83F7AC8[] = +{ + ANIMCMD_FRAME(64, 30), + ANIMCMD_END, +}; +static const union AnimCmd *const gSpriteAnimTable_83F7AD0[] = +{ + gSpriteAnim_83F7AC0, +}; +static const union AnimCmd *const gSpriteAnimTable_83F7AD4[] = +{ + gSpriteAnim_83F7AC8, +}; +static void sub_810B05C(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_83F7AD8 = +{ + .tileTag = 0x1000, + .paletteTag = 0x1000, + .oam = &gOamData_83F7AB8, + .anims = gSpriteAnimTable_83F7AD0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_810B05C, +}; +static void sub_810B0F4(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_83F7AF0 = +{ + .tileTag = 0x1000, + .paletteTag = 0x1000, + .oam = &gOamData_83F7AB8, + .anims = gSpriteAnimTable_83F7AD4, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_810B0F4, +}; +static const struct OamData gOamData_83F7B08 = +{ + .y = 160, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 2, + .paletteNum = 0, + .affineParam = 0, +}; +static const union AnimCmd gSpriteAnim_83F7B10[] = +{ + ANIMCMD_FRAME(132, 30), + ANIMCMD_END, +}; +static const union AnimCmd gSpriteAnim_83F7B18[] = +{ + ANIMCMD_FRAME(128, 30), + ANIMCMD_END, +}; +static const union AnimCmd *const gSpriteAnimTable_83F7B20[] = +{ + gSpriteAnim_83F7B10, +}; +static const union AnimCmd *const gSpriteAnimTable_83F7B24[] = +{ + gSpriteAnim_83F7B18, +}; +static void sub_810B18C(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_83F7B28 = +{ + .tileTag = 0x1000, + .paletteTag = 0x1000, + .oam = &gOamData_83F7B08, + .anims = gSpriteAnimTable_83F7B20, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_810B18C, +}; +static void sub_810B230(struct Sprite *sprite); +static const struct SpriteTemplate gSpriteTemplate_83F7B40 = +{ + .tileTag = 0x1000, + .paletteTag = 0x1000, + .oam = &gOamData_83F7B08, + .anims = gSpriteAnimTable_83F7B24, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_810B230, +}; static void WallClockVblankCallback(void); static void LoadWallClockGraphics(void); @@ -48,25 +168,17 @@ static u8 AdvanceClock(u8 taskId, u8 direction); static void UpdateClockPeriod(u8 taskId, u8 direction); static void InitClockWithRtc(u8 taskId); -//Task data -enum { - TD_MHAND_ANGLE, - TD_HHAND_ANGLE, - TD_HOURS, - TD_MINUTES, - TD_SETDIRECTION, //Movement direction when setting the clock - TD_PERIOD, //Whether the time is AM or PM - TD_SETSPEED, //Movement speed when setting the clock -}; - -enum { - AM, - PM +enum +{ + PERIOD_AM, + PERIOD_PM, }; -enum { - BACKWARD = 1, - FORWARD +enum +{ + MVMT_NONE, + MVMT_BACKWARD, + MVMT_FORWARD, }; static void WallClockVblankCallback(void) @@ -80,7 +192,7 @@ static void LoadWallClockGraphics(void) { u8 *addr; u32 size; - + SetVBlankCallback(0); REG_DISPCNT = 0; REG_BG3CNT = 0; @@ -95,15 +207,15 @@ static void LoadWallClockGraphics(void) REG_BG1VOFS = 0; REG_BG0HOFS = 0; REG_BG0VOFS = 0; - + addr = (void *)VRAM; size = 0x18000; - while(1) + while (1) { DmaFill16(3, 0, addr, 0x1000); addr += 0x1000; size -= 0x1000; - if(size <= 0x1000) + if (size <= 0x1000) { DmaFill16(3, 0, addr, size); break; @@ -111,9 +223,9 @@ static void LoadWallClockGraphics(void) } DmaClear32(3, OAM, OAM_SIZE); DmaClear16(3, PLTT, PLTT_SIZE); - + LZ77UnCompVram(gMiscClock_Gfx, (void *)VRAM); - if(gSpecialVar_0x8004 == MALE) + if (gSpecialVar_0x8004 == MALE) LoadPalette(gMiscClockMale_Pal, 0, 32); else LoadPalette(gMiscClockFemale_Pal, 0, 32); @@ -122,8 +234,8 @@ static void LoadWallClockGraphics(void) ResetSpriteData(); ResetPaletteFade(); FreeAllSpritePalettes(); - LoadCompressedObjectPic(&gUnknown_083F7A90); - LoadSpritePalettes(&gUnknown_083F7AA0); + LoadCompressedObjectPic(&gUnknown_083F7A90[0]); + LoadSpritePalettes(gUnknown_083F7AA0); SetUpWindowConfig(&gWindowConfig_81E6C3C); InitMenuWindow(&gWindowConfig_81E6CE4); } @@ -131,7 +243,7 @@ static void LoadWallClockGraphics(void) static void WallClockInit(void) { u16 ime; - + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); ime = REG_IME; REG_IME = 0; @@ -143,65 +255,73 @@ static void WallClockInit(void) REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; - REG_BG3CNT = 0x701; - REG_BG0CNT = 0x1F08; + REG_BG3CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; } +#define tMinuteHandAngle data[0] +#define tHourHandAngle data[1] +#define tHours data[2] +#define tMinutes data[3] +#define tMvmtDir data[4] +#define tPeriod data[5] +#define tMvmtSpeed data[6] + //Allow player to set the clock -void Cb2_StartWallClock(void) +void CB2_StartWallClock(void) { u8 taskId; u8 spriteId; - + LoadWallClockGraphics(); LZ77UnCompVram(&gUnknown_08E954B0, (void *)(VRAM + 0x3800)); - + taskId = CreateTask(Task_SetClock1, 0); - gTasks[taskId].data[TD_HOURS] = 10; - gTasks[taskId].data[TD_MINUTES] = 0; - gTasks[taskId].data[TD_SETDIRECTION] = 0; - gTasks[taskId].data[TD_PERIOD] = AM; - gTasks[taskId].data[TD_SETSPEED] = 0; - gTasks[taskId].data[TD_MHAND_ANGLE] = 0; - gTasks[taskId].data[TD_HHAND_ANGLE] = 300; - - spriteId = CreateSprite(&gSpriteTemplate_83F7AD8, 0x78, 0x50, 1); + gTasks[taskId].tHours = 10; + gTasks[taskId].tMinutes = 0; + gTasks[taskId].tMvmtDir = MVMT_NONE; + gTasks[taskId].tPeriod = PERIOD_AM; + gTasks[taskId].tMvmtSpeed = 0; + gTasks[taskId].tMinuteHandAngle = 0; + gTasks[taskId].tHourHandAngle = 300; + + spriteId = CreateSprite(&gSpriteTemplate_83F7AD8, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, 1); gSprites[spriteId].data0 = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 0; - - spriteId = CreateSprite(&gSpriteTemplate_83F7AF0, 0x78, 0x50, 0); + + spriteId = CreateSprite(&gSpriteTemplate_83F7AF0, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, 0); gSprites[spriteId].data0 = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 1; - - spriteId = CreateSprite(&gSpriteTemplate_83F7B28, 0x78, 0x50, 2); + + spriteId = CreateSprite(&gSpriteTemplate_83F7B28, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, 2); gSprites[spriteId].data0 = taskId; gSprites[spriteId].data1 = 45; - - spriteId = CreateSprite(&gSpriteTemplate_83F7B40, 0x78, 0x50, 2); + + spriteId = CreateSprite(&gSpriteTemplate_83F7B40, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, 2); gSprites[spriteId].data0 = taskId; gSprites[spriteId].data1 = 90; - + WallClockInit(); } //View, but don't set, the clock -void Cb2_ViewWallClock(void) +void CB2_ViewWallClock(void) { u8 taskId; s16 angle1; s16 angle2; u8 spriteId; - + LoadWallClockGraphics(); LZ77UnCompVram(gUnknown_08E95774, (void *)(VRAM + 0x3800)); - + taskId = CreateTask(Task_ViewClock1, 0); InitClockWithRtc(taskId); - if(gTasks[taskId].data[TD_PERIOD] == 0) + if (gTasks[taskId].tPeriod == PERIOD_AM) { angle1 = 45; angle2 = 90; @@ -211,25 +331,25 @@ void Cb2_ViewWallClock(void) angle1 = 90; angle2 = 135; } - + spriteId = CreateSprite(&gSpriteTemplate_83F7AD8, 120, 80, 1); gSprites[spriteId].data0 = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 0; - + spriteId = CreateSprite(&gSpriteTemplate_83F7AF0, 120, 80, 0); gSprites[spriteId].data0 = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 1; - + spriteId = CreateSprite(&gSpriteTemplate_83F7B28, 120, 80, 2); gSprites[spriteId].data0 = taskId; gSprites[spriteId].data1 = angle1; - + spriteId = CreateSprite(&gSpriteTemplate_83F7B40, 120, 80, 2); gSprites[spriteId].data0 = taskId; gSprites[spriteId].data1 = angle2; - + WallClockInit(); } @@ -243,49 +363,49 @@ static void WallClockMainCallback(void) static void Task_SetClock1(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) gTasks[taskId].func = Task_SetClock2; } //Handle keypresses when setting clock static void Task_SetClock2(u8 taskId) { - if(gTasks[taskId].data[TD_MHAND_ANGLE] % 6) + if (gTasks[taskId].tMinuteHandAngle % 6) { - gTasks[taskId].data[TD_MHAND_ANGLE] = CalcNewMinHandAngle( - gTasks[taskId].data[TD_MHAND_ANGLE], - gTasks[taskId].data[TD_SETDIRECTION], - gTasks[taskId].data[TD_SETSPEED]); + gTasks[taskId].tMinuteHandAngle = CalcNewMinHandAngle( + gTasks[taskId].tMinuteHandAngle, + gTasks[taskId].tMvmtDir, + gTasks[taskId].tMvmtSpeed); } else { - gTasks[taskId].data[TD_MHAND_ANGLE] = gTasks[taskId].data[TD_MINUTES] * 6; - gTasks[taskId].data[TD_HHAND_ANGLE] = (gTasks[taskId].data[TD_HOURS] % 12) * 30 + (gTasks[taskId].data[TD_MINUTES] / 10) * 5; - if(gMain.newKeys & A_BUTTON) + gTasks[taskId].tMinuteHandAngle = gTasks[taskId].tMinutes * 6; + gTasks[taskId].tHourHandAngle = (gTasks[taskId].tHours % 12) * 30 + (gTasks[taskId].tMinutes / 10) * 5; + if (gMain.newKeys & A_BUTTON) { gTasks[taskId].func = Task_SetClock3; return; } else { - gTasks[taskId].data[TD_SETDIRECTION] = gMain.newKeys & A_BUTTON; - if(gMain.heldKeys & DPAD_LEFT) - gTasks[taskId].data[TD_SETDIRECTION] = BACKWARD; - if(gMain.heldKeys & DPAD_RIGHT) - gTasks[taskId].data[TD_SETDIRECTION] = FORWARD; - if(gTasks[taskId].data[TD_SETDIRECTION]) + gTasks[taskId].tMvmtDir = gMain.newKeys & A_BUTTON; + if (gMain.heldKeys & DPAD_LEFT) + gTasks[taskId].tMvmtDir = MVMT_BACKWARD; + if (gMain.heldKeys & DPAD_RIGHT) + gTasks[taskId].tMvmtDir = MVMT_FORWARD; + if (gTasks[taskId].tMvmtDir) { - if(gTasks[taskId].data[TD_SETSPEED] <= 0xFE) - gTasks[taskId].data[TD_SETSPEED]++; - gTasks[taskId].data[TD_MHAND_ANGLE] = CalcNewMinHandAngle( - gTasks[taskId].data[TD_MHAND_ANGLE], - gTasks[taskId].data[TD_SETDIRECTION], - gTasks[taskId].data[TD_SETSPEED]); - AdvanceClock(taskId, gTasks[taskId].data[TD_SETDIRECTION]); + if (gTasks[taskId].tMvmtSpeed < 0xFF) + gTasks[taskId].tMvmtSpeed++; + gTasks[taskId].tMinuteHandAngle = CalcNewMinHandAngle( + gTasks[taskId].tMinuteHandAngle, + gTasks[taskId].tMvmtDir, + gTasks[taskId].tMvmtSpeed); + AdvanceClock(taskId, gTasks[taskId].tMvmtDir); } else { - gTasks[taskId].data[TD_SETSPEED] = 0; + gTasks[taskId].tMvmtSpeed = 0; } } } @@ -297,7 +417,7 @@ static void Task_SetClock3(u8 taskId) MenuDrawTextWindow(2, 16, 27, 19); MenuPrint(gOtherText_CorrectTimePrompt, 3, 17); MenuDrawTextWindow(23, 8, 29, 13); - PrintMenuItems(24, 9, 2, gUnknown_08376D74); + PrintMenuItems(24, 9, 2, gMenuYesNoItems); InitMenu(0, 24, 9, 2, 1, 5); gTasks[taskId].func = Task_SetClock4; } @@ -305,39 +425,39 @@ static void Task_SetClock3(u8 taskId) //Get menu selection static void Task_SetClock4(u8 taskId) { - switch(ProcessMenuInputNoWrap_()) + switch (ProcessMenuInputNoWrap_()) { - case 0: //YES - PlaySE(SE_SELECT); - gTasks[taskId].func = Task_SetClock5; //Move on - return; - case -1: //B button - case 1: //NO - sub_8072DEC(); - PlaySE(SE_SELECT); - MenuZeroFillWindowRect(23, 8, 29, 13); - MenuZeroFillWindowRect(2, 16, 27, 19); - gTasks[taskId].func = Task_SetClock2; //Go back and let player adjust clock + case 0: //YES + PlaySE(SE_SELECT); + gTasks[taskId].func = Task_SetClock5; //Move on + return; + case -1: //B button + case 1: //NO + HandleDestroyMenuCursors(); + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(23, 8, 29, 13); + MenuZeroFillWindowRect(2, 16, 27, 19); + gTasks[taskId].func = Task_SetClock2; //Go back and let player adjust clock } } //Set the time offset based on the wall clock's time static void Task_SetClock5(u8 taskId) { - RtcInitLocalTimeOffset(gTasks[taskId].data[TD_HOURS], gTasks[taskId].data[TD_MINUTES]); + RtcInitLocalTimeOffset(gTasks[taskId].tHours, gTasks[taskId].tMinutes); BeginNormalPaletteFade(-1, 0, 0, 16, 0); gTasks[taskId].func = Task_SetClock6; } static void Task_SetClock6(u8 taskId) { - if(!gPaletteFade.active) - SetMainCallback2((MainCallback)gMain.field_8); + if (!gPaletteFade.active) + SetMainCallback2((MainCallback)gMain.savedCallback); } static void Task_ViewClock1(u8 taskId) { - if(!gPaletteFade.active) + if (!gPaletteFade.active) gTasks[taskId].func = Task_ViewClock2; } @@ -345,7 +465,7 @@ static void Task_ViewClock1(u8 taskId) static void Task_ViewClock2(u8 taskId) { InitClockWithRtc(taskId); - if(gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) gTasks[taskId].func = Task_ViewClock3; } @@ -357,41 +477,41 @@ static void Task_ViewClock3(u8 taskId) static void Task_ViewClock4(u8 taskId) { - if(!gPaletteFade.active) - SetMainCallback2((MainCallback)gMain.field_8); + if (!gPaletteFade.active) + SetMainCallback2((MainCallback)gMain.savedCallback); } static u8 CalcMinHandDelta(u16 speed) { - if(speed > 60) + if (speed > 60) return 6; - else if(speed > 30) + else if (speed > 30) return 3; - else if(speed > 10) + else if (speed > 10) return 2; else return 1; } -//Calculates the new position of the minute hand when setting the clock +//Calculates the new angle of the minute hand when setting the clock static u16 CalcNewMinHandAngle(u16 angle, u8 direction, u8 speed) { u8 delta = CalcMinHandDelta(speed); - - switch(direction) + + switch (direction) { - case BACKWARD: - if(angle) - angle = angle - delta; - else - angle = 360 - delta; - break; - case FORWARD: - if(angle < 360 - delta) - angle = angle + delta; - else - angle = 0; - break; + case MVMT_BACKWARD: + if (angle) + angle = angle - delta; + else + angle = 360 - delta; + break; + case MVMT_FORWARD: + if (angle < 360 - delta) + angle = angle + delta; + else + angle = 0; + break; } return angle; } @@ -399,34 +519,34 @@ static u16 CalcNewMinHandAngle(u16 angle, u8 direction, u8 speed) //Advances clock forward or backward by 1 minute static u8 AdvanceClock(u8 taskId, u8 direction) { - switch(direction) + switch (direction) { - case BACKWARD: - if(gTasks[taskId].data[TD_MINUTES] > 0) - gTasks[taskId].data[TD_MINUTES]--; + case MVMT_BACKWARD: + if (gTasks[taskId].tMinutes > 0) + gTasks[taskId].tMinutes--; + else + { + gTasks[taskId].tMinutes = 59; + if (gTasks[taskId].tHours > 0) + gTasks[taskId].tHours--; else - { - gTasks[taskId].data[TD_MINUTES] = 59; - if(gTasks[taskId].data[TD_HOURS] > 0) - gTasks[taskId].data[TD_HOURS]--; - else - gTasks[taskId].data[TD_HOURS] = 23; - UpdateClockPeriod(taskId, direction); - } - break; - case FORWARD: - if(gTasks[taskId].data[TD_MINUTES] <= 58) - gTasks[taskId].data[TD_MINUTES]++; + gTasks[taskId].tHours = 23; + UpdateClockPeriod(taskId, direction); + } + break; + case MVMT_FORWARD: + if (gTasks[taskId].tMinutes < 59) + gTasks[taskId].tMinutes++; + else + { + gTasks[taskId].tMinutes = 0; + if (gTasks[taskId].tHours < 23) + gTasks[taskId].tHours++; else - { - gTasks[taskId].data[TD_MINUTES] = 0; - if(gTasks[taskId].data[TD_HOURS] <= 22) - gTasks[taskId].data[TD_HOURS]++; - else - gTasks[taskId].data[TD_HOURS] = 0; - UpdateClockPeriod(taskId, direction); - } - break; + gTasks[taskId].tHours = 0; + UpdateClockPeriod(taskId, direction); + } + break; } return 0; } @@ -434,115 +554,479 @@ static u8 AdvanceClock(u8 taskId, u8 direction) //Updates the clock period (AM/PM) if it needs to change static void UpdateClockPeriod(u8 taskId, u8 direction) { - u8 hours = gTasks[taskId].data[TD_HOURS]; - - switch(direction) + u8 hours = gTasks[taskId].tHours; + + switch (direction) { - case BACKWARD: - switch(hours) - { - case 11: - gTasks[taskId].data[TD_PERIOD] = AM; - break; - case 23: - gTasks[taskId].data[TD_PERIOD] = PM; - break; - } + case MVMT_BACKWARD: + switch (hours) + { + case 11: + gTasks[taskId].tPeriod = PERIOD_AM; break; - case FORWARD: - switch(hours) - { - case 0: - gTasks[taskId].data[TD_PERIOD] = AM; - break; - case 12: - gTasks[taskId].data[TD_PERIOD] = PM; - break; - } + case 23: + gTasks[taskId].tPeriod = PERIOD_PM; + break; + } + break; + case MVMT_FORWARD: + switch (hours) + { + case 0: + gTasks[taskId].tPeriod = PERIOD_AM; break; + case 12: + gTasks[taskId].tPeriod = PERIOD_PM; + break; + } + break; } } static void InitClockWithRtc(u8 taskId) { RtcCalcLocalTime(); - gTasks[taskId].data[TD_HOURS] = gLocalTime.hours; - gTasks[taskId].data[TD_MINUTES] = gLocalTime.minutes; - gTasks[taskId].data[TD_MHAND_ANGLE] = gTasks[taskId].data[TD_MINUTES] * 6; - gTasks[taskId].data[TD_HHAND_ANGLE] = (gTasks[taskId].data[TD_HOURS] % 12) * 30 + (gTasks[taskId].data[TD_MINUTES] / 10) * 5; - if(gLocalTime.hours <= 11) - gTasks[taskId].data[TD_PERIOD] = AM; + gTasks[taskId].tHours = gLocalTime.hours; + gTasks[taskId].tMinutes = gLocalTime.minutes; + gTasks[taskId].tMinuteHandAngle = gTasks[taskId].tMinutes * 6; + gTasks[taskId].tHourHandAngle = (gTasks[taskId].tHours % 12) * 30 + (gTasks[taskId].tMinutes / 10) * 5; + if (gLocalTime.hours <= 11) + gTasks[taskId].tPeriod = PERIOD_AM; else - gTasks[taskId].data[TD_PERIOD] = PM; + gTasks[taskId].tPeriod = PERIOD_PM; } -void sub_810B05C(struct Sprite *sprite) +static const s8 gClockHandCoords[][2] = +{ + { 0, -24}, + { 1, -25}, + { 1, -25}, + { 2, -25}, + { 2, -25}, + { 2, -25}, + { 3, -24}, + { 3, -25}, + { 4, -25}, + { 4, -25}, + { 4, -25}, + { 5, -25}, + { 5, -25}, + { 6, -24}, + { 6, -24}, + { 6, -24}, + { 7, -24}, + { 7, -24}, + { 7, -24}, + { 8, -24}, + { 8, -24}, + { 9, -24}, + { 9, -24}, + { 10, -23}, + { 10, -23}, + { 11, -22}, + { 11, -22}, + { 11, -22}, + { 12, -22}, + { 12, -21}, + { 13, -21}, + { 13, -21}, + { 13, -21}, + { 14, -21}, + { 14, -21}, + { 14, -20}, + { 14, -20}, + { 15, -20}, + { 15, -19}, + { 16, -19}, + { 16, -19}, + { 16, -19}, + { 16, -18}, + { 16, -18}, + { 17, -18}, + { 17, -17}, + { 17, -17}, + { 18, -17}, + { 18, -17}, + { 18, -16}, + { 18, -16}, + { 19, -16}, + { 19, -15}, + { 19, -15}, + { 20, -15}, + { 20, -14}, + { 20, -14}, + { 20, -13}, + { 20, -13}, + { 21, -13}, + { 21, -13}, + { 21, -12}, + { 22, -12}, + { 22, -12}, + { 22, -11}, + { 22, -11}, + { 22, -10}, + { 23, -10}, + { 23, -9}, + { 23, -9}, + { 23, -9}, + { 23, -9}, + { 23, -8}, + { 23, -8}, + { 23, -7}, + { 23, -7}, + { 23, -6}, + { 24, -6}, + { 24, -6}, + { 25, -5}, + { 25, -5}, + { 24, -4}, + { 25, -4}, + { 24, -3}, + { 25, -3}, + { 25, -3}, + { 25, -2}, + { 25, -2}, + { 24, -1}, + { 25, -1}, + { 24, 0}, + { 24, 0}, + { 24, 0}, + { 24, 1}, + { 24, 1}, + { 25, 2}, + { 24, 2}, + { 25, 2}, + { 24, 3}, + { 24, 3}, + { 25, 4}, + { 24, 4}, + { 24, 5}, + { 24, 5}, + { 24, 5}, + { 24, 6}, + { 23, 6}, + { 23, 6}, + { 23, 7}, + { 23, 8}, + { 23, 8}, + { 23, 8}, + { 23, 9}, + { 23, 9}, + { 23, 10}, + { 22, 10}, + { 22, 10}, + { 22, 11}, + { 22, 11}, + { 22, 11}, + { 22, 12}, + { 21, 12}, + { 21, 12}, + { 21, 13}, + { 20, 13}, + { 20, 13}, + { 19, 13}, + { 19, 13}, + { 19, 14}, + { 19, 14}, + { 19, 15}, + { 19, 15}, + { 18, 15}, + { 18, 16}, + { 17, 16}, + { 17, 16}, + { 17, 17}, + { 17, 17}, + { 16, 17}, + { 16, 18}, + { 16, 18}, + { 15, 18}, + { 14, 18}, + { 15, 19}, + { 14, 19}, + { 14, 19}, + { 13, 19}, + { 13, 20}, + { 13, 20}, + { 13, 20}, + { 12, 20}, + { 12, 20}, + { 12, 21}, + { 11, 21}, + { 11, 21}, + { 11, 21}, + { 10, 21}, + { 10, 22}, + { 10, 22}, + { 9, 22}, + { 9, 22}, + { 8, 22}, + { 7, 22}, + { 7, 23}, + { 7, 23}, + { 6, 23}, + { 6, 23}, + { 5, 23}, + { 5, 23}, + { 5, 24}, + { 4, 24}, + { 4, 24}, + { 4, 24}, + { 3, 24}, + { 2, 24}, + { 2, 24}, + { 1, 24}, + { 1, 24}, + { 0, 24}, + { 0, 24}, + { -1, 23}, + { 0, 24}, + { 0, 24}, + { -1, 24}, + { -1, 24}, + { -2, 24}, + { -2, 24}, + { -3, 24}, + { -3, 24}, + { -4, 24}, + { -4, 24}, + { -5, 24}, + { -5, 23}, + { -5, 23}, + { -6, 23}, + { -6, 23}, + { -7, 23}, + { -7, 23}, + { -7, 23}, + { -8, 23}, + { -8, 22}, + { -9, 22}, + { -9, 22}, + {-10, 22}, + {-10, 22}, + {-10, 21}, + {-11, 21}, + {-11, 21}, + {-11, 21}, + {-11, 20}, + {-12, 20}, + {-12, 20}, + {-13, 20}, + {-13, 20}, + {-13, 19}, + {-14, 19}, + {-14, 19}, + {-14, 19}, + {-14, 18}, + {-15, 18}, + {-15, 18}, + {-15, 17}, + {-16, 17}, + {-16, 17}, + {-17, 17}, + {-17, 16}, + {-17, 16}, + {-18, 16}, + {-17, 15}, + {-18, 15}, + {-18, 15}, + {-19, 15}, + {-19, 14}, + {-19, 14}, + {-19, 13}, + {-19, 13}, + {-20, 13}, + {-20, 12}, + {-20, 12}, + {-21, 12}, + {-21, 12}, + {-21, 11}, + {-21, 11}, + {-21, 10}, + {-21, 10}, + {-21, 9}, + {-22, 9}, + {-22, 9}, + {-22, 8}, + {-22, 8}, + {-22, 7}, + {-23, 7}, + {-23, 7}, + {-23, 6}, + {-23, 6}, + {-23, 5}, + {-24, 5}, + {-23, 4}, + {-23, 4}, + {-24, 4}, + {-24, 4}, + {-24, 3}, + {-24, 3}, + {-24, 2}, + {-24, 2}, + {-24, 1}, + {-24, 1}, + {-24, 1}, + {-24, 0}, + {-25, 0}, + {-24, -1}, + {-25, -1}, + {-24, -1}, + {-24, -2}, + {-24, -2}, + {-24, -3}, + {-24, -3}, + {-24, -4}, + {-24, -4}, + {-24, -4}, + {-24, -5}, + {-24, -5}, + {-24, -6}, + {-24, -6}, + {-23, -6}, + {-23, -7}, + {-23, -7}, + {-23, -8}, + {-23, -8}, + {-23, -9}, + {-23, -9}, + {-22, -9}, + {-22, -9}, + {-22, -10}, + {-22, -10}, + {-21, -10}, + {-21, -11}, + {-22, -11}, + {-22, -12}, + {-21, -12}, + {-21, -13}, + {-21, -13}, + {-20, -13}, + {-21, -14}, + {-20, -14}, + {-20, -14}, + {-19, -14}, + {-19, -15}, + {-19, -15}, + {-18, -16}, + {-18, -16}, + {-18, -16}, + {-18, -17}, + {-18, -17}, + {-17, -17}, + {-17, -18}, + {-17, -18}, + {-16, -18}, + {-16, -18}, + {-16, -19}, + {-16, -19}, + {-15, -19}, + {-15, -19}, + {-15, -20}, + {-14, -20}, + {-14, -20}, + {-14, -21}, + {-13, -21}, + {-13, -21}, + {-13, -21}, + {-12, -21}, + {-12, -22}, + {-11, -22}, + {-11, -22}, + {-11, -22}, + {-10, -22}, + {-10, -22}, + { -9, -22}, + { -9, -23}, + { -9, -23}, + { -8, -23}, + { -8, -23}, + { -7, -23}, + { -7, -23}, + { -7, -24}, + { -6, -24}, + { -6, -24}, + { -5, -24}, + { -5, -24}, + { -4, -24}, + { -4, -24}, + { -4, -24}, + { -4, -25}, + { -3, -25}, + { -2, -25}, + { -2, -24}, + { -2, -24}, + { -1, -25}, + { -1, -25}, + { 0, -25}, +}; + +static void sub_810B05C(struct Sprite *sprite) { u16 angle; s16 sin; s16 cos; u16 x; u16 y; - - angle = gTasks[sprite->data0].data[TD_MHAND_ANGLE]; + + angle = gTasks[sprite->data0].tMinuteHandAngle; sin = Sin2(angle) / 16; cos = Cos2(angle) / 16; SetOamMatrix(0, cos, sin, -sin, cos); x = gClockHandCoords[angle][0]; y = gClockHandCoords[angle][1]; - + //Manual sign extension - if(x > 0x80) + if (x > 0x80) x |= 0xFF00; - if(y > 0x80) + if (y > 0x80) y |= 0xFF00; - + sprite->pos2.x = x; sprite->pos2.y = y; } -void sub_810B0F4(struct Sprite *sprite) +static void sub_810B0F4(struct Sprite *sprite) { u16 angle; s16 sin; s16 cos; u16 x; u16 y; - - angle = gTasks[sprite->data0].data[TD_HHAND_ANGLE]; + + angle = gTasks[sprite->data0].tHourHandAngle; sin = Sin2(angle) / 16; cos = Cos2(angle) / 16; SetOamMatrix(1, cos, sin, -sin, cos); x = gClockHandCoords[angle][0]; y = gClockHandCoords[angle][1]; - + //Manual sign extension - if(x > 0x80) + if (x > 0x80) x |= 0xFF00; - if(y > 0x80) + if (y > 0x80) y |= 0xFF00; - + sprite->pos2.x = x; sprite->pos2.y = y; } -void sub_810B18C(struct Sprite *sprite) +static void sub_810B18C(struct Sprite *sprite) { s16 sin; s16 cos; - - if(gTasks[sprite->data0].data[TD_PERIOD] != AM) + + if (gTasks[sprite->data0].tPeriod != PERIOD_AM) { - if((u16)(sprite->data1 - 60) <= 29) + if (sprite->data1 >= 60 && sprite->data1 < 90) sprite->data1 += 5; - if(sprite->data1 <= 59) + if (sprite->data1 < 60) sprite->data1++; } else { - if((u16)(sprite->data1 - 46) <= 29) + if (sprite->data1 > 45 && sprite->data1 <= 75) sprite->data1 -= 5; - if(sprite->data1 > 75) + if (sprite->data1 > 75) sprite->data1--; } cos = Cos2((u16)sprite->data1); @@ -551,23 +1035,23 @@ void sub_810B18C(struct Sprite *sprite) sprite->pos2.y = sin * 30 / 4096; } -void sub_810B230(struct Sprite *sprite) +static void sub_810B230(struct Sprite *sprite) { s16 sin; s16 cos; - - if(gTasks[sprite->data0].data[TD_PERIOD] != AM) + + if (gTasks[sprite->data0].tPeriod != PERIOD_AM) { - if(sprite->data1 >= 105 && sprite->data1 < 135) + if (sprite->data1 >= 105 && sprite->data1 < 135) sprite->data1 += 5; - if(sprite->data1 < 105) + if (sprite->data1 < 105) sprite->data1++; } else { - if(sprite->data1 > 90 && sprite->data1 <= 120) + if (sprite->data1 > 90 && sprite->data1 <= 120) sprite->data1 -= 5; - if(sprite->data1 > 120) + if (sprite->data1 > 120) sprite->data1--; } cos = Cos2((u16)sprite->data1); diff --git a/src/weather.c b/src/weather.c deleted file mode 100644 index 520185441..000000000 --- a/src/weather.c +++ /dev/null @@ -1,307 +0,0 @@ -#include "global.h" -#include "weather.h" -#include "asm.h" -#include "task.h" -#include "sprite.h" -#include "palette.h" - -struct Weather { - u8 filler_000[0x200]; - u8 unknown_200[2][32]; - u8 filler_240[0x480]; - s8 unknown_6C0; - s8 unknown_6C1; - u8 unknown_6C2; - u8 unknown_6C3; - u16 unknown_6C4; - u8 unknown_6C6; - u8 unknown_6C7; - u8 unknown_6C8; - u8 unknown_6C9; - u8 unknown_6CA; - u8 unknown_6CB; - u8 filler_6CC[2]; - u16 unknown_6CE; - u8 unknown_6D0; - u8 unknown_6D1; - u8 filler_6D2[1]; - u8 unknown_6D3; - u8 unknown_6D4; - u8 unknown_6D5; - u8 filler_6D6[2]; - u8 unknown_6D8; - u8 filler_6D9[1]; - u8 unknown_6DA; - u8 filler_6DB[3]; - u8 unknown_6DE; - u8 filler_6DF[5]; - u8 unknown_6E4; - u8 filler_6E5[0x15]; - u8 unknown_6FA; - u8 unknown_6FB; - u8 filler_6FC[4]; - u8 unknown_700; - u8 filler_701[0x15]; - u8 unknown_716; - u8 unknown_717; - u8 filler_718[0xc]; - u8 unknown_724; - u8 filler_725[9]; - u8 unknown_72E; -}; - -#define gWeather gUnknown_0202F7E8 -extern struct Weather gWeather; -extern u8 *gUnknown_083970E8; -extern u8 (*gUnknown_08396FC8[][4])(void); -extern u8 (*gUnknown_083970B8[])(void); -extern u8 *gUnknown_030006DC; -extern u8 gUnknown_083970C8; -extern u8 (*gUnknown_0202FC48)[32]; -extern u8 gUnknown_0202F9E8[32]; - - -void sub_807C828(void) { - u8 index; - if (!FuncIsActiveTask(&sub_807CA34)) { - index = AllocSpritePalette(0x1200); - CpuCopy32(&gUnknown_083970E8, &gPlttBufferUnfaded[0x100 + index * 16], 32); - sub_807CB10(); - gWeather.unknown_6D5 = index; - gWeather.unknown_6D4 = AllocSpritePalette(0x1201); - gWeather.unknown_6DA = 0; - gWeather.unknown_6D8 = 0; - gWeather.unknown_6DE = 0; - gWeather.unknown_6E4 = 0; - gWeather.unknown_700 = 0; - gWeather.unknown_6FB = 0; - gWeather.unknown_724 = 0; - gWeather.unknown_716 = 0; - gWeather.unknown_717 = 0; - gWeather.unknown_72E = 0; - gWeather.unknown_6FA = 0; - sub_807DB64(16, 0); - gWeather.unknown_6D0 = 0; - gWeather.unknown_6C6 = 3; - gWeather.unknown_6C8 = 0; - gWeather.unknown_6D3 = 1; - gWeather.unknown_6C9 = CreateTask(&sub_807C9E4, 80); - } -} - -void DoWeatherEffect(u8 effect) { - if (effect != 3 && effect != 5 && effect != 13) { - PlayRainSoundEffect(); - } - if (gWeather.unknown_6D1 != effect && gWeather.unknown_6D0 == effect) { - gUnknown_08396FC8[effect][0](); - } - gWeather.unknown_6D3 = 0; - gWeather.unknown_6D1 = effect; - gWeather.unknown_6CE = 0; -} - -void sub_807C988(u8 effect) { - PlayRainSoundEffect(); - gWeather.unknown_6D0 = effect; - gWeather.unknown_6D1 = effect; -} - -void sub_807C9B4(u8 effect) { - PlayRainSoundEffect(); - gWeather.unknown_6D0 = effect; - gWeather.unknown_6D1 = effect; - gWeather.unknown_6C8 = 1; -} - -void sub_807C9E4(u8 task) { - if (gWeather.unknown_6C8) { - gUnknown_08396FC8[gWeather.unknown_6D0][2](); - gTasks[task].func = &sub_807CA34; - } -} - -void sub_807CA34(u8 task) { - u8 v1; - if (gWeather.unknown_6D0 != gWeather.unknown_6D1) { - v1 = gUnknown_08396FC8[gWeather.unknown_6D0][3](); - if (!v1) { - gUnknown_08396FC8[gWeather.unknown_6D1][0](); - gWeather.unknown_6C3 = 0; // compiler reuses v1 - gWeather.unknown_6C6 = 0; // compiler reuses v1 - gWeather.unknown_6D0 = gWeather.unknown_6D1; - gWeather.unknown_6D3 = 1; - } - } else { - gUnknown_08396FC8[gWeather.unknown_6D0][1](); - } - gUnknown_083970B8[gWeather.unknown_6C6](); -} - -void sub_807CAE8(void) { - gWeather.unknown_6C1 = 0; - gWeather.unknown_6C2 = 0; -} - -void nullsub_38(void) { -} - -u32 sub_807CB0C(void) { - return 0; -} - -void sub_807CB10(void) { - u16 v0; - u8 (*v1)[32]; - u16 v2; - u16 v4; - u16 v5; - u16 v6; - u16 v9; - u32 v10; - u16 v11; - s16 dunno; - - gUnknown_030006DC = &gUnknown_083970C8; - for (v0 = 0; v0 <= 1; v0++) { - if (v0 == 0) { - v1 = &gUnknown_0202F9E8; - } else { - v1 = &gUnknown_0202F9E8 + 19; - } - for (v2 = 0; (u16)v2 <= 0x1f; v2++) { - v4 = v2 << 8; - if (v0 == 0) { - v5 = (v2 << 8) / 16; - } else { - v5 = 0; - } - v6 = 0; - for (; v6 <= 2; v6++) { - v4 = (v4 - v5); - v1[v6][v2] = v4 >> 8; - } - v9 = v4; - v10 = 0x1f00 - v4; - if ((0x1f00 - v4) < 0) { - v10 += 0xf; - } - v11 = v10 >> 4; - if (v2 <= 0xb) { - for (; v6 <= 0x12; v6++) { - v4 += v11; - dunno = v4 - v9; - if (dunno > 0) { - v4 -= (dunno + ((u16)dunno >> 15)) >> 1; - } - v1[v6][v2] = v4 >> 8; - if (v1[v6][v2] > 0x1f) { - v1[v6][v2] = 0x1f; - } - } - } else { - for (; v6 <= 0x12; v6++) { - v4 += v11; - v1[v6][v2] = v4 >> 8; - if (v1[v6][v2] > 0x1f) { - v1[v6][v2] = 0x1f; - } - } - } - } - } -} - -void sub_807CC24(void) { - if (gWeather.unknown_6C0 == gWeather.unknown_6C1) { - gWeather.unknown_6C6 = 3; - } else { - if (++gWeather.unknown_6C3 >= gWeather.unknown_6C2) { - gWeather.unknown_6C3 = 0; - if (gWeather.unknown_6C0 < gWeather.unknown_6C1) { - gWeather.unknown_6C0++; - } else { - gWeather.unknown_6C0--; - } - sub_807CEBC(0, 0x20, gWeather.unknown_6C0); - } - } -} - -void sub_807CCAC(void) { - if (++gWeather.unknown_6CB > 1) { - gWeather.unknown_6CA = 0; - } - switch (gWeather.unknown_6D0) { - case 3: - case 4: - case 5: - case 11: - case 13: - if (sub_807CDC4() == 0) { - gWeather.unknown_6C0 = 3; - gWeather.unknown_6C6 = 3; - } - break; - case 12: - if (sub_807CE24() == 0) { - gWeather.unknown_6C0 = -6; - gWeather.unknown_6C6 = 3; - } - break; - case 6: - if (sub_807CE7C() == 0) { - gWeather.unknown_6C0 = 0; - gWeather.unknown_6C6 = 3; - } - break; - case 7: - case 8: - case 9: - case 10: - default: - if (!gPaletteFade.active) { - gWeather.unknown_6C0 = gWeather.unknown_6C1; - gWeather.unknown_6C6 = 3; - } - break; - } -} - -u8 sub_807CDC4(void) { - if (gWeather.unknown_6C7 == 0x10) { - return 0; - } - if (++gWeather.unknown_6C7 >= 0x10) { - sub_807CEBC(0, 0x20, 3); - gWeather.unknown_6C7 = 0x10; - return 0; - } - sub_807D1BC(0, 0x20, 3, 0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); - return 1; -} - -u8 sub_807CE24(void) { - if (gWeather.unknown_6C7 == 0x10) { - return 0; - } - if (++gWeather.unknown_6C7 >= 0x10) { - sub_807CEBC(0, 0x20, -6); - gWeather.unknown_6C7 = 0x10; - return 0; - } - sub_807D304(-6, 0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); - return 1; -} - -u8 sub_807CE7C(void) { - if (gWeather.unknown_6C7 == 0x10) { - return 0; - } - ++gWeather.unknown_6C7; - sub_807D424(0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); - return 1; -} - -void nullsub_39(void) { -} diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 48fe3c116..96f47c067 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -1,44 +1,2904 @@ #include "global.h" #include "wild_encounter.h" -#include "asm.h" -#include "field_player_avatar.h" -#include "safari_zone.h" -#include "battle_setup.h" #include "abilities.h" +#include "battle_setup.h" +#include "event_data.h" +#include "field_player_avatar.h" +#include "fieldmap.h" +#include "metatile_behavior.h" +#include "pokeblock.h" #include "rng.h" -#include "script.h" -#include "flag.h" -#include "var.h" +#include "roamer.h" #include "rom4.h" -#include "vars.h" +#include "safari_zone.h" +#include "script.h" +#include "species.h" +#include "tv.h" -struct WildPokemon +const struct WildPokemon PetalburgCity_WaterMons [] = { - u8 minLevel; - u8 maxLevel; - u16 species; + {20, 30, SPECIES_MARILL}, + {10, 20, SPECIES_MARILL}, + {30, 35, SPECIES_MARILL}, + {5, 10, SPECIES_MARILL}, + {5, 10, SPECIES_MARILL}, }; +const struct WildPokemonInfo PetalburgCity_WaterMonsInfo = {1, PetalburgCity_WaterMons}; -struct WildPokemonInfo +const struct WildPokemon PetalburgCity_FishingMons [] = { - u8 encounterRate; - struct WildPokemon *wildPokemon; + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_GOLDEEN}, + {10, 30, SPECIES_CORPHISH}, + {25, 30, SPECIES_CORPHISH}, + {30, 35, SPECIES_CORPHISH}, + {20, 25, SPECIES_CORPHISH}, + {35, 40, SPECIES_CORPHISH}, + {40, 45, SPECIES_CORPHISH}, }; +const struct WildPokemonInfo PetalburgCity_FishingMonsInfo = {10, PetalburgCity_FishingMons}; -struct WildPokemonHeader +const struct WildPokemon SlateportCity_WaterMons [] = { - u8 mapGroup; - u8 mapNum; - struct WildPokemonInfo *landMonsInfo; - struct WildPokemonInfo *waterMonsInfo; - struct WildPokemonInfo *rockSmashMonsInfo; - struct WildPokemonInfo *fishingMonsInfo; + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo SlateportCity_WaterMonsInfo = {4, SlateportCity_WaterMons}; + +const struct WildPokemon SlateportCity_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo SlateportCity_FishingMonsInfo = {10, SlateportCity_FishingMons}; + +const struct WildPokemon LilycoveCity_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo LilycoveCity_WaterMonsInfo = {4, LilycoveCity_WaterMons}; + +const struct WildPokemon LilycoveCity_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_STARYU}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo LilycoveCity_FishingMonsInfo = {10, LilycoveCity_FishingMons}; + +const struct WildPokemon MossdeepCity_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo MossdeepCity_WaterMonsInfo = {4, MossdeepCity_WaterMons}; + +const struct WildPokemon MossdeepCity_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo MossdeepCity_FishingMonsInfo = {10, MossdeepCity_FishingMons}; + +const struct WildPokemon SootopolisCity_WaterMons [] = +{ + {5, 35, SPECIES_MAGIKARP}, + {10, 30, SPECIES_MAGIKARP}, + {15, 25, SPECIES_MAGIKARP}, + {25, 30, SPECIES_MAGIKARP}, + {25, 30, SPECIES_MAGIKARP}, +}; +const struct WildPokemonInfo SootopolisCity_WaterMonsInfo = {1, SootopolisCity_WaterMons}; + +const struct WildPokemon SootopolisCity_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, +#ifdef SAPPHIRE + {5, 10, SPECIES_TENTACOOL}, +#else + {10, 15, SPECIES_MAGIKARP}, +#endif + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_MAGIKARP}, + {30, 35, SPECIES_MAGIKARP}, + {30, 35, SPECIES_MAGIKARP}, + {35, 40, SPECIES_GYARADOS}, + {35, 45, SPECIES_GYARADOS}, + {5, 45, SPECIES_GYARADOS}, +}; +const struct WildPokemonInfo SootopolisCity_FishingMonsInfo = {10, SootopolisCity_FishingMons}; + +const struct WildPokemon EverGrandeCity_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo EverGrandeCity_WaterMonsInfo = {4, EverGrandeCity_WaterMons}; + +const struct WildPokemon EverGrandeCity_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_LUVDISC}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_LUVDISC}, + {30, 35, SPECIES_WAILMER}, + {30, 35, SPECIES_CORSOLA}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo EverGrandeCity_FishingMonsInfo = {10, EverGrandeCity_FishingMons}; + +const struct WildPokemon MeteorFalls_1F_1R_LandMons [] = +{ + {16, 16, SPECIES_ZUBAT}, + {17, 17, SPECIES_ZUBAT}, + {18, 18, SPECIES_ZUBAT}, + {15, 15, SPECIES_ZUBAT}, + {14, 14, SPECIES_ZUBAT}, +#ifdef SAPPHIRE + {16, 16, SPECIES_LUNATONE}, + {18, 18, SPECIES_LUNATONE}, + {14, 14, SPECIES_LUNATONE}, +#else + {16, 16, SPECIES_SOLROCK}, + {18, 18, SPECIES_SOLROCK}, + {14, 14, SPECIES_SOLROCK}, +#endif + {19, 19, SPECIES_ZUBAT}, + {20, 20, SPECIES_ZUBAT}, + {19, 19, SPECIES_ZUBAT}, + {20, 20, SPECIES_ZUBAT}, +}; +const struct WildPokemonInfo MeteorFalls_1F_1R_LandMonsInfo = {10, MeteorFalls_1F_1R_LandMons}; + +const struct WildPokemon MeteorFalls_1F_1R_WaterMons [] = +{ + {5, 35, SPECIES_ZUBAT}, + {30, 35, SPECIES_ZUBAT}, +#ifdef SAPPHIRE + {25, 35, SPECIES_LUNATONE}, + {15, 25, SPECIES_LUNATONE}, + {5, 15, SPECIES_LUNATONE}, +#else + {25, 35, SPECIES_SOLROCK}, + {15, 25, SPECIES_SOLROCK}, + {5, 15, SPECIES_SOLROCK}, +#endif +}; +const struct WildPokemonInfo MeteorFalls_1F_1R_WaterMonsInfo = {4, MeteorFalls_1F_1R_WaterMons}; + +const struct WildPokemon MeteorFalls_1F_1R_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_GOLDEEN}, + {10, 30, SPECIES_BARBOACH}, + {25, 30, SPECIES_BARBOACH}, + {30, 35, SPECIES_BARBOACH}, + {20, 25, SPECIES_BARBOACH}, + {35, 40, SPECIES_BARBOACH}, + {40, 45, SPECIES_BARBOACH}, +}; +const struct WildPokemonInfo MeteorFalls_1F_1R_FishingMonsInfo = {30, MeteorFalls_1F_1R_FishingMons}; + +const struct WildPokemon MeteorFalls_1F_2R_LandMons [] = +{ + {33, 33, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {35, 35, SPECIES_LUNATONE}, + {33, 33, SPECIES_LUNATONE}, + {37, 37, SPECIES_LUNATONE}, +#else + {35, 35, SPECIES_SOLROCK}, + {33, 33, SPECIES_SOLROCK}, + {37, 37, SPECIES_SOLROCK}, +#endif + {35, 35, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {39, 39, SPECIES_LUNATONE}, +#else + {39, 39, SPECIES_SOLROCK}, +#endif + {38, 38, SPECIES_GOLBAT}, + {40, 40, SPECIES_GOLBAT}, + {38, 38, SPECIES_GOLBAT}, + {40, 40, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo MeteorFalls_1F_2R_LandMonsInfo = {10, MeteorFalls_1F_2R_LandMons}; + +const struct WildPokemon MeteorFalls_1F_2R_WaterMons [] = +{ + {30, 35, SPECIES_GOLBAT}, + {30, 35, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {25, 35, SPECIES_LUNATONE}, + {15, 25, SPECIES_LUNATONE}, + {5, 15, SPECIES_LUNATONE}, +#else + {25, 35, SPECIES_SOLROCK}, + {15, 25, SPECIES_SOLROCK}, + {5, 15, SPECIES_SOLROCK}, +#endif +}; +const struct WildPokemonInfo MeteorFalls_1F_2R_WaterMonsInfo = {4, MeteorFalls_1F_2R_WaterMons}; + +const struct WildPokemon MeteorFalls_1F_2R_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_GOLDEEN}, + {10, 30, SPECIES_BARBOACH}, + {25, 30, SPECIES_BARBOACH}, + {30, 35, SPECIES_BARBOACH}, + {30, 35, SPECIES_WHISCASH}, + {35, 40, SPECIES_WHISCASH}, + {40, 45, SPECIES_WHISCASH}, +}; +const struct WildPokemonInfo MeteorFalls_1F_2R_FishingMonsInfo = {30, MeteorFalls_1F_2R_FishingMons}; + +const struct WildPokemon MeteorFalls_B1F_1R_LandMons [] = +{ + {33, 33, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {35, 35, SPECIES_LUNATONE}, + {33, 33, SPECIES_LUNATONE}, + {37, 37, SPECIES_LUNATONE}, +#else + {35, 35, SPECIES_SOLROCK}, + {33, 33, SPECIES_SOLROCK}, + {37, 37, SPECIES_SOLROCK}, +#endif + {35, 35, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {39, 39, SPECIES_LUNATONE}, +#else + {39, 39, SPECIES_SOLROCK}, +#endif + {38, 38, SPECIES_GOLBAT}, + {40, 40, SPECIES_GOLBAT}, + {38, 38, SPECIES_GOLBAT}, + {40, 40, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo MeteorFalls_B1F_1R_LandMonsInfo = {10, MeteorFalls_B1F_1R_LandMons}; + +const struct WildPokemon MeteorFalls_B1F_1R_WaterMons [] = +{ + {30, 35, SPECIES_GOLBAT}, + {30, 35, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {25, 35, SPECIES_LUNATONE}, + {15, 25, SPECIES_LUNATONE}, + {5, 15, SPECIES_LUNATONE}, +#else + {25, 35, SPECIES_SOLROCK}, + {15, 25, SPECIES_SOLROCK}, + {5, 15, SPECIES_SOLROCK}, +#endif +}; +const struct WildPokemonInfo MeteorFalls_B1F_1R_WaterMonsInfo = {4, MeteorFalls_B1F_1R_WaterMons}; + +const struct WildPokemon MeteorFalls_B1F_1R_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_GOLDEEN}, + {10, 30, SPECIES_BARBOACH}, + {25, 30, SPECIES_BARBOACH}, + {30, 35, SPECIES_BARBOACH}, + {30, 35, SPECIES_WHISCASH}, + {35, 40, SPECIES_WHISCASH}, + {40, 45, SPECIES_WHISCASH}, +}; +const struct WildPokemonInfo MeteorFalls_B1F_1R_FishingMonsInfo = {30, MeteorFalls_B1F_1R_FishingMons}; + +const struct WildPokemon MeteorFalls_B1F_2R_LandMons [] = +{ + {33, 33, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {30, 30, SPECIES_BAGON}, +#ifdef SAPPHIRE + {35, 35, SPECIES_LUNATONE}, +#else + {35, 35, SPECIES_SOLROCK}, +#endif + {35, 35, SPECIES_BAGON}, +#ifdef SAPPHIRE + {37, 37, SPECIES_LUNATONE}, +#else + {37, 37, SPECIES_SOLROCK}, +#endif + {25, 25, SPECIES_BAGON}, +#ifdef SAPPHIRE + {39, 39, SPECIES_LUNATONE}, +#else + {39, 39, SPECIES_SOLROCK}, +#endif + {38, 38, SPECIES_GOLBAT}, + {40, 40, SPECIES_GOLBAT}, + {38, 38, SPECIES_GOLBAT}, + {40, 40, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo MeteorFalls_B1F_2R_LandMonsInfo = {10, MeteorFalls_B1F_2R_LandMons}; + +const struct WildPokemon MeteorFalls_B1F_2R_WaterMons [] = +{ + {30, 35, SPECIES_GOLBAT}, + {30, 35, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {25, 35, SPECIES_LUNATONE}, + {15, 25, SPECIES_LUNATONE}, + {5, 15, SPECIES_LUNATONE}, +#else + {25, 35, SPECIES_SOLROCK}, + {15, 25, SPECIES_SOLROCK}, + {5, 15, SPECIES_SOLROCK}, +#endif +}; +const struct WildPokemonInfo MeteorFalls_B1F_2R_WaterMonsInfo = {4, MeteorFalls_B1F_2R_WaterMons}; + +const struct WildPokemon MeteorFalls_B1F_2R_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_GOLDEEN}, + {10, 30, SPECIES_BARBOACH}, + {25, 30, SPECIES_BARBOACH}, + {30, 35, SPECIES_BARBOACH}, + {30, 35, SPECIES_WHISCASH}, + {35, 40, SPECIES_WHISCASH}, + {40, 45, SPECIES_WHISCASH}, +}; +const struct WildPokemonInfo MeteorFalls_B1F_2R_FishingMonsInfo = {30, MeteorFalls_B1F_2R_FishingMons}; + +const struct WildPokemon RusturfTunnel_LandMons [] = +{ + {6, 6, SPECIES_WHISMUR}, + {7, 7, SPECIES_WHISMUR}, + {6, 6, SPECIES_WHISMUR}, + {6, 6, SPECIES_WHISMUR}, + {7, 7, SPECIES_WHISMUR}, + {7, 7, SPECIES_WHISMUR}, + {5, 5, SPECIES_WHISMUR}, + {8, 8, SPECIES_WHISMUR}, + {5, 5, SPECIES_WHISMUR}, + {8, 8, SPECIES_WHISMUR}, + {5, 5, SPECIES_WHISMUR}, + {8, 8, SPECIES_WHISMUR}, +}; +const struct WildPokemonInfo RusturfTunnel_LandMonsInfo = {10, RusturfTunnel_LandMons}; + +const struct WildPokemon GraniteCave_1F_LandMons [] = +{ + {7, 7, SPECIES_ZUBAT}, + {8, 8, SPECIES_MAKUHITA}, + {7, 7, SPECIES_MAKUHITA}, + {8, 8, SPECIES_ZUBAT}, + {9, 9, SPECIES_MAKUHITA}, + {8, 8, SPECIES_ABRA}, + {10, 10, SPECIES_MAKUHITA}, + {6, 6, SPECIES_MAKUHITA}, + {7, 7, SPECIES_GEODUDE}, + {8, 8, SPECIES_GEODUDE}, + {6, 6, SPECIES_GEODUDE}, + {9, 9, SPECIES_GEODUDE}, +}; +const struct WildPokemonInfo GraniteCave_1F_LandMonsInfo = {10, GraniteCave_1F_LandMons}; + +const struct WildPokemon GraniteCave_B1F_LandMons [] = +{ + {9, 9, SPECIES_ZUBAT}, + {10, 10, SPECIES_ARON}, + {9, 9, SPECIES_ARON}, + {11, 11, SPECIES_ARON}, + {10, 10, SPECIES_ZUBAT}, + {9, 9, SPECIES_ABRA}, + {10, 10, SPECIES_MAKUHITA}, + {11, 11, SPECIES_MAKUHITA}, +#ifdef SAPPHIRE + {10, 10, SPECIES_SABLEYE}, + {10, 10, SPECIES_SABLEYE}, + {9, 9, SPECIES_SABLEYE}, + {11, 11, SPECIES_SABLEYE}, +#else + {10, 10, SPECIES_MAWILE}, + {10, 10, SPECIES_MAWILE}, + {9, 9, SPECIES_MAWILE}, + {11, 11, SPECIES_MAWILE}, +#endif +}; +const struct WildPokemonInfo GraniteCave_B1F_LandMonsInfo = {10, GraniteCave_B1F_LandMons}; + +const struct WildPokemon GraniteCave_B2F_LandMons [] = +{ + {10, 10, SPECIES_ZUBAT}, + {11, 11, SPECIES_ARON}, + {10, 10, SPECIES_ARON}, + {11, 11, SPECIES_ZUBAT}, + {12, 12, SPECIES_ARON}, + {10, 10, SPECIES_ABRA}, +#ifdef SAPPHIRE + {10, 10, SPECIES_SABLEYE}, + {11, 11, SPECIES_SABLEYE}, + {12, 12, SPECIES_SABLEYE}, + {10, 10, SPECIES_SABLEYE}, + {12, 12, SPECIES_SABLEYE}, + {10, 10, SPECIES_SABLEYE}, +#else + {10, 10, SPECIES_MAWILE}, + {11, 11, SPECIES_MAWILE}, + {12, 12, SPECIES_MAWILE}, + {10, 10, SPECIES_MAWILE}, + {12, 12, SPECIES_MAWILE}, + {10, 10, SPECIES_MAWILE}, +#endif +}; +const struct WildPokemonInfo GraniteCave_B2F_LandMonsInfo = {10, GraniteCave_B2F_LandMons}; + +const struct WildPokemon GraniteCave_B2F_RockSmashMons [] = +{ + {10, 15, SPECIES_GEODUDE}, + {10, 20, SPECIES_NOSEPASS}, + {5, 10, SPECIES_GEODUDE}, + {15, 20, SPECIES_GEODUDE}, + {15, 20, SPECIES_GEODUDE}, +}; +const struct WildPokemonInfo GraniteCave_B2F_RockSmashMonsInfo = {20, GraniteCave_B2F_RockSmashMons}; + +const struct WildPokemon GraniteCave_StevensRoom_LandMons [] = +{ + {7, 7, SPECIES_ZUBAT}, + {8, 8, SPECIES_MAKUHITA}, + {7, 7, SPECIES_MAKUHITA}, + {8, 8, SPECIES_ZUBAT}, + {9, 9, SPECIES_MAKUHITA}, + {8, 8, SPECIES_ABRA}, + {10, 10, SPECIES_MAKUHITA}, + {6, 6, SPECIES_MAKUHITA}, + {7, 7, SPECIES_ARON}, + {8, 8, SPECIES_ARON}, + {7, 7, SPECIES_ARON}, + {8, 8, SPECIES_ARON}, +}; +const struct WildPokemonInfo GraniteCave_StevensRoom_LandMonsInfo = {10, GraniteCave_StevensRoom_LandMons}; + +const struct WildPokemon PetalburgWoods_LandMons [] = +{ + {5, 5, SPECIES_ZIGZAGOON}, + {5, 5, SPECIES_WURMPLE}, + {5, 5, SPECIES_SHROOMISH}, + {6, 6, SPECIES_ZIGZAGOON}, + {5, 5, SPECIES_SILCOON}, + {5, 5, SPECIES_CASCOON}, + {6, 6, SPECIES_WURMPLE}, + {6, 6, SPECIES_SHROOMISH}, + {5, 5, SPECIES_TAILLOW}, + {5, 5, SPECIES_SLAKOTH}, + {6, 6, SPECIES_TAILLOW}, + {6, 6, SPECIES_SLAKOTH}, +}; +const struct WildPokemonInfo PetalburgWoods_LandMonsInfo = {20, PetalburgWoods_LandMons}; + +//Jagged Pass Pokemon are 2 levels higher on Sapphire +#ifdef SAPPHIRE +#define JAGGED_PASS_LEVEL_DIFF 2 +#else +#define JAGGED_PASS_LEVEL_DIFF 0 +#endif + +const struct WildPokemon JaggedPass_LandMons [] = +{ + {19 + JAGGED_PASS_LEVEL_DIFF, 19 + JAGGED_PASS_LEVEL_DIFF, SPECIES_NUMEL}, + {19 + JAGGED_PASS_LEVEL_DIFF, 19 + JAGGED_PASS_LEVEL_DIFF, SPECIES_NUMEL}, + {19 + JAGGED_PASS_LEVEL_DIFF, 19 + JAGGED_PASS_LEVEL_DIFF, SPECIES_MACHOP}, + {18 + JAGGED_PASS_LEVEL_DIFF, 18 + JAGGED_PASS_LEVEL_DIFF, SPECIES_NUMEL}, + {18 + JAGGED_PASS_LEVEL_DIFF, 18 + JAGGED_PASS_LEVEL_DIFF, SPECIES_SPOINK}, + {18 + JAGGED_PASS_LEVEL_DIFF, 18 + JAGGED_PASS_LEVEL_DIFF, SPECIES_MACHOP}, + {19 + JAGGED_PASS_LEVEL_DIFF, 19 + JAGGED_PASS_LEVEL_DIFF, SPECIES_SPOINK}, + {20 + JAGGED_PASS_LEVEL_DIFF, 20 + JAGGED_PASS_LEVEL_DIFF, SPECIES_MACHOP}, + {20 + JAGGED_PASS_LEVEL_DIFF, 20 + JAGGED_PASS_LEVEL_DIFF, SPECIES_NUMEL}, + {20 + JAGGED_PASS_LEVEL_DIFF, 20 + JAGGED_PASS_LEVEL_DIFF, SPECIES_SPOINK}, + {20 + JAGGED_PASS_LEVEL_DIFF, 20 + JAGGED_PASS_LEVEL_DIFF, SPECIES_NUMEL}, + {20 + JAGGED_PASS_LEVEL_DIFF, 20 + JAGGED_PASS_LEVEL_DIFF, SPECIES_SPOINK}, +}; +const struct WildPokemonInfo JaggedPass_LandMonsInfo = {20, JaggedPass_LandMons}; + +const struct WildPokemon FieryPath_LandMons [] = +{ + {15, 15, SPECIES_NUMEL}, +#ifdef SAPPHIRE + {15, 15, SPECIES_GRIMER}, +#else + {15, 15, SPECIES_KOFFING}, +#endif + {16, 16, SPECIES_NUMEL}, + {15, 15, SPECIES_MACHOP}, + {15, 15, SPECIES_TORKOAL}, + {15, 15, SPECIES_SLUGMA}, +#ifdef SAPPHIRE + {16, 16, SPECIES_GRIMER}, +#else + {16, 16, SPECIES_KOFFING}, +#endif + {16, 16, SPECIES_MACHOP}, + {14, 14, SPECIES_TORKOAL}, + {16, 16, SPECIES_TORKOAL}, +#ifdef SAPPHIRE + {14, 14, SPECIES_KOFFING}, + {14, 14, SPECIES_KOFFING}, +#else + {14, 14, SPECIES_GRIMER}, + {14, 14, SPECIES_GRIMER}, +#endif +}; +const struct WildPokemonInfo FieryPath_LandMonsInfo = {10, FieryPath_LandMons}; + +const struct WildPokemon MtPyre_1F_LandMons [] = +{ +#ifdef SAPPHIRE + {27, 27, SPECIES_SHUPPET}, + {28, 28, SPECIES_SHUPPET}, + {26, 26, SPECIES_SHUPPET}, + {25, 25, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, + {23, 23, SPECIES_SHUPPET}, + {22, 22, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, +#else + {27, 27, SPECIES_DUSKULL}, + {28, 28, SPECIES_DUSKULL}, + {26, 26, SPECIES_DUSKULL}, + {25, 25, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, + {23, 23, SPECIES_DUSKULL}, + {22, 22, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, +#endif +}; +const struct WildPokemonInfo MtPyre_1F_LandMonsInfo = {10, MtPyre_1F_LandMons}; + +const struct WildPokemon MtPyre_2F_LandMons [] = +{ +#ifdef SAPPHIRE + {27, 27, SPECIES_SHUPPET}, + {28, 28, SPECIES_SHUPPET}, + {26, 26, SPECIES_SHUPPET}, + {25, 25, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, + {23, 23, SPECIES_SHUPPET}, + {22, 22, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, +#else + {27, 27, SPECIES_DUSKULL}, + {28, 28, SPECIES_DUSKULL}, + {26, 26, SPECIES_DUSKULL}, + {25, 25, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, + {23, 23, SPECIES_DUSKULL}, + {22, 22, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, +#endif +}; +const struct WildPokemonInfo MtPyre_2F_LandMonsInfo = {10, MtPyre_2F_LandMons}; + +const struct WildPokemon MtPyre_3F_LandMons [] = +{ +#ifdef SAPPHIRE + {27, 27, SPECIES_SHUPPET}, + {28, 28, SPECIES_SHUPPET}, + {26, 26, SPECIES_SHUPPET}, + {25, 25, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, + {23, 23, SPECIES_SHUPPET}, + {22, 22, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, +#else + {27, 27, SPECIES_DUSKULL}, + {28, 28, SPECIES_DUSKULL}, + {26, 26, SPECIES_DUSKULL}, + {25, 25, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, + {23, 23, SPECIES_DUSKULL}, + {22, 22, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, +#endif +}; +const struct WildPokemonInfo MtPyre_3F_LandMonsInfo = {10, MtPyre_3F_LandMons}; + +const struct WildPokemon MtPyre_4F_LandMons [] = +{ +#ifdef SAPPHIRE + {27, 27, SPECIES_SHUPPET}, + {28, 28, SPECIES_SHUPPET}, + {26, 26, SPECIES_SHUPPET}, + {25, 25, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, + {23, 23, SPECIES_SHUPPET}, + {22, 22, SPECIES_SHUPPET}, + {27, 27, SPECIES_DUSKULL}, + {27, 27, SPECIES_DUSKULL}, + {25, 25, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, +#else + {27, 27, SPECIES_DUSKULL}, + {28, 28, SPECIES_DUSKULL}, + {26, 26, SPECIES_DUSKULL}, + {25, 25, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, + {23, 23, SPECIES_DUSKULL}, + {22, 22, SPECIES_DUSKULL}, + {27, 27, SPECIES_SHUPPET}, + {27, 27, SPECIES_SHUPPET}, + {25, 25, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, +#endif +}; +const struct WildPokemonInfo MtPyre_4F_LandMonsInfo = {10, MtPyre_4F_LandMons}; + +const struct WildPokemon MtPyre_5F_LandMons [] = +{ +#ifdef SAPPHIRE + {27, 27, SPECIES_SHUPPET}, + {28, 28, SPECIES_SHUPPET}, + {26, 26, SPECIES_SHUPPET}, + {25, 25, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, + {23, 23, SPECIES_SHUPPET}, + {22, 22, SPECIES_SHUPPET}, + {27, 27, SPECIES_DUSKULL}, + {27, 27, SPECIES_DUSKULL}, + {25, 25, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, +#else + {27, 27, SPECIES_DUSKULL}, + {28, 28, SPECIES_DUSKULL}, + {26, 26, SPECIES_DUSKULL}, + {25, 25, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, + {23, 23, SPECIES_DUSKULL}, + {22, 22, SPECIES_DUSKULL}, + {27, 27, SPECIES_SHUPPET}, + {27, 27, SPECIES_SHUPPET}, + {25, 25, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, +#endif +}; +const struct WildPokemonInfo MtPyre_5F_LandMonsInfo = {10, MtPyre_5F_LandMons}; + +const struct WildPokemon MtPyre_6F_LandMons [] = +{ +#ifdef SAPPHIRE + {27, 27, SPECIES_SHUPPET}, + {28, 28, SPECIES_SHUPPET}, + {26, 26, SPECIES_SHUPPET}, + {25, 25, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, + {23, 23, SPECIES_SHUPPET}, + {22, 22, SPECIES_SHUPPET}, + {27, 27, SPECIES_DUSKULL}, + {27, 27, SPECIES_DUSKULL}, + {25, 25, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, +#else + {27, 27, SPECIES_DUSKULL}, + {28, 28, SPECIES_DUSKULL}, + {26, 26, SPECIES_DUSKULL}, + {25, 25, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, + {23, 23, SPECIES_DUSKULL}, + {22, 22, SPECIES_DUSKULL}, + {27, 27, SPECIES_SHUPPET}, + {27, 27, SPECIES_SHUPPET}, + {25, 25, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, +#endif +}; +const struct WildPokemonInfo MtPyre_6F_LandMonsInfo = {10, MtPyre_6F_LandMons}; + +const struct WildPokemon MtPyre_Exterior_LandMons [] = +{ +#ifdef SAPPHIRE + {27, 27, SPECIES_SHUPPET}, +#else + {27, 27, SPECIES_DUSKULL}, +#endif + {27, 27, SPECIES_MEDITITE}, +#ifdef SAPPHIRE + {28, 28, SPECIES_SHUPPET}, +#else + {28, 28, SPECIES_DUSKULL}, +#endif + {29, 29, SPECIES_MEDITITE}, +#ifdef SAPPHIRE + {29, 29, SPECIES_SHUPPET}, +#else + {29, 29, SPECIES_DUSKULL}, +#endif + {27, 27, SPECIES_VULPIX}, + {29, 29, SPECIES_VULPIX}, + {25, 25, SPECIES_VULPIX}, + {27, 27, SPECIES_WINGULL}, + {27, 27, SPECIES_WINGULL}, + {26, 26, SPECIES_WINGULL}, + {28, 28, SPECIES_WINGULL}, +}; +const struct WildPokemonInfo MtPyre_Exterior_LandMonsInfo = {10, MtPyre_Exterior_LandMons}; + +const struct WildPokemon MtPyre_Summit_LandMons [] = +{ +#ifdef SAPPHIRE + {28, 28, SPECIES_SHUPPET}, + {29, 29, SPECIES_SHUPPET}, + {27, 27, SPECIES_SHUPPET}, + {26, 26, SPECIES_SHUPPET}, + {30, 30, SPECIES_SHUPPET}, + {25, 25, SPECIES_SHUPPET}, + {24, 24, SPECIES_SHUPPET}, + {28, 28, SPECIES_DUSKULL}, + {26, 26, SPECIES_DUSKULL}, + {30, 30, SPECIES_DUSKULL}, +#else + {28, 28, SPECIES_DUSKULL}, + {29, 29, SPECIES_DUSKULL}, + {27, 27, SPECIES_DUSKULL}, + {26, 26, SPECIES_DUSKULL}, + {30, 30, SPECIES_DUSKULL}, + {25, 25, SPECIES_DUSKULL}, + {24, 24, SPECIES_DUSKULL}, + {28, 28, SPECIES_SHUPPET}, + {26, 26, SPECIES_SHUPPET}, + {30, 30, SPECIES_SHUPPET}, +#endif + {28, 28, SPECIES_CHIMECHO}, + {28, 28, SPECIES_CHIMECHO}, +}; +const struct WildPokemonInfo MtPyre_Summit_LandMonsInfo = {10, MtPyre_Summit_LandMons}; + +const struct WildPokemon SeafloorCavern_Entrance_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {5, 35, SPECIES_ZUBAT}, + {30, 35, SPECIES_ZUBAT}, + {30, 35, SPECIES_GOLBAT}, + {30, 35, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo SeafloorCavern_Entrance_WaterMonsInfo = {4, SeafloorCavern_Entrance_WaterMons}; + +const struct WildPokemon SeafloorCavern_Entrance_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo SeafloorCavern_Entrance_FishingMonsInfo = {10, SeafloorCavern_Entrance_FishingMons}; + +const struct WildPokemon SeafloorCavern_Room1_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, + {33, 33, SPECIES_ZUBAT}, + {28, 28, SPECIES_ZUBAT}, + {29, 29, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {35, 35, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo SeafloorCavern_Room1_LandMonsInfo = {4, SeafloorCavern_Room1_LandMons}; + +const struct WildPokemon SeafloorCavern_Room2_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, + {33, 33, SPECIES_ZUBAT}, + {28, 28, SPECIES_ZUBAT}, + {29, 29, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {35, 35, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo SeafloorCavern_Room2_LandMonsInfo = {4, SeafloorCavern_Room2_LandMons}; + +const struct WildPokemon SeafloorCavern_Room3_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, + {33, 33, SPECIES_ZUBAT}, + {28, 28, SPECIES_ZUBAT}, + {29, 29, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {35, 35, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo SeafloorCavern_Room3_LandMonsInfo = {4, SeafloorCavern_Room3_LandMons}; + +const struct WildPokemon SeafloorCavern_Room4_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, + {33, 33, SPECIES_ZUBAT}, + {28, 28, SPECIES_ZUBAT}, + {29, 29, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {35, 35, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo SeafloorCavern_Room4_LandMonsInfo = {4, SeafloorCavern_Room4_LandMons}; + +const struct WildPokemon SeafloorCavern_Room5_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, + {33, 33, SPECIES_ZUBAT}, + {28, 28, SPECIES_ZUBAT}, + {29, 29, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {35, 35, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo SeafloorCavern_Room5_LandMonsInfo = {4, SeafloorCavern_Room5_LandMons}; + +const struct WildPokemon SeafloorCavern_Room6_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, + {33, 33, SPECIES_ZUBAT}, + {28, 28, SPECIES_ZUBAT}, + {29, 29, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {35, 35, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo SeafloorCavern_Room6_LandMonsInfo = {4, SeafloorCavern_Room6_LandMons}; + +const struct WildPokemon SeafloorCavern_Room6_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {5, 35, SPECIES_ZUBAT}, + {30, 35, SPECIES_ZUBAT}, + {30, 35, SPECIES_GOLBAT}, + {30, 35, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo SeafloorCavern_Room6_WaterMonsInfo = {4, SeafloorCavern_Room6_WaterMons}; + +const struct WildPokemon SeafloorCavern_Room6_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo SeafloorCavern_Room6_FishingMonsInfo = {10, SeafloorCavern_Room6_FishingMons}; + +const struct WildPokemon SeafloorCavern_Room7_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, + {33, 33, SPECIES_ZUBAT}, + {28, 28, SPECIES_ZUBAT}, + {29, 29, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {35, 35, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo SeafloorCavern_Room7_LandMonsInfo = {4, SeafloorCavern_Room7_LandMons}; + +const struct WildPokemon SeafloorCavern_Room7_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {5, 35, SPECIES_ZUBAT}, + {30, 35, SPECIES_ZUBAT}, + {30, 35, SPECIES_GOLBAT}, + {30, 35, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo SeafloorCavern_Room7_WaterMonsInfo = {4, SeafloorCavern_Room7_WaterMons}; + +const struct WildPokemon SeafloorCavern_Room7_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo SeafloorCavern_Room7_FishingMonsInfo = {10, SeafloorCavern_Room7_FishingMons}; + +const struct WildPokemon SeafloorCavern_Room8_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, + {33, 33, SPECIES_ZUBAT}, + {28, 28, SPECIES_ZUBAT}, + {29, 29, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {35, 35, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo SeafloorCavern_Room8_LandMonsInfo = {4, SeafloorCavern_Room8_LandMons}; + +const struct WildPokemon CaveOfOrigin_Entrance_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, + {33, 33, SPECIES_ZUBAT}, + {28, 28, SPECIES_ZUBAT}, + {29, 29, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {35, 35, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo CaveOfOrigin_Entrance_LandMonsInfo = {4, CaveOfOrigin_Entrance_LandMons}; + +const struct WildPokemon CaveOfOrigin_1F_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, +#ifdef SAPPHIRE + {30, 30, SPECIES_SABLEYE}, + {32, 32, SPECIES_SABLEYE}, + {34, 34, SPECIES_SABLEYE}, +#else + {30, 30, SPECIES_MAWILE}, + {32, 32, SPECIES_MAWILE}, + {34, 34, SPECIES_MAWILE}, +#endif + {33, 33, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo CaveOfOrigin_1F_LandMonsInfo = {4, CaveOfOrigin_1F_LandMons}; + +const struct WildPokemon CaveOfOrigin_B1F_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, +#ifdef SAPPHIRE + {30, 30, SPECIES_SABLEYE}, + {32, 32, SPECIES_SABLEYE}, + {34, 34, SPECIES_SABLEYE}, +#else + {30, 30, SPECIES_MAWILE}, + {32, 32, SPECIES_MAWILE}, + {34, 34, SPECIES_MAWILE}, +#endif + {33, 33, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo CaveOfOrigin_B1F_LandMonsInfo = {4, CaveOfOrigin_B1F_LandMons}; + +const struct WildPokemon CaveOfOrigin_B2F_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, +#ifdef SAPPHIRE + {30, 30, SPECIES_SABLEYE}, + {32, 32, SPECIES_SABLEYE}, + {34, 34, SPECIES_SABLEYE}, +#else + {30, 30, SPECIES_MAWILE}, + {32, 32, SPECIES_MAWILE}, + {34, 34, SPECIES_MAWILE}, +#endif + {33, 33, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo CaveOfOrigin_B2F_LandMonsInfo = {4, CaveOfOrigin_B2F_LandMons}; + +const struct WildPokemon CaveOfOrigin_B3F_LandMons [] = +{ + {30, 30, SPECIES_ZUBAT}, + {31, 31, SPECIES_ZUBAT}, + {32, 32, SPECIES_ZUBAT}, +#ifdef SAPPHIRE + {30, 30, SPECIES_SABLEYE}, + {32, 32, SPECIES_SABLEYE}, + {34, 34, SPECIES_SABLEYE}, +#else + {30, 30, SPECIES_MAWILE}, + {32, 32, SPECIES_MAWILE}, + {34, 34, SPECIES_MAWILE}, +#endif + {33, 33, SPECIES_ZUBAT}, + {34, 34, SPECIES_ZUBAT}, + {34, 34, SPECIES_GOLBAT}, + {35, 35, SPECIES_GOLBAT}, + {33, 33, SPECIES_GOLBAT}, + {36, 36, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo CaveOfOrigin_B3F_LandMonsInfo = {4, CaveOfOrigin_B3F_LandMons}; + +const struct WildPokemon VictoryRoad_1F_LandMons [] = +{ + {40, 40, SPECIES_GOLBAT}, + {40, 40, SPECIES_HARIYAMA}, + {40, 40, SPECIES_LAIRON}, + {40, 40, SPECIES_LOUDRED}, + {36, 36, SPECIES_ZUBAT}, + {36, 36, SPECIES_MAKUHITA}, + {38, 38, SPECIES_GOLBAT}, + {38, 38, SPECIES_HARIYAMA}, + {36, 36, SPECIES_ARON}, + {36, 36, SPECIES_WHISMUR}, + {36, 36, SPECIES_ARON}, + {36, 36, SPECIES_WHISMUR}, +}; +const struct WildPokemonInfo VictoryRoad_1F_LandMonsInfo = {10, VictoryRoad_1F_LandMons}; + +const struct WildPokemon VictoryRoad_B1F_LandMons [] = +{ + {40, 40, SPECIES_GOLBAT}, + {40, 40, SPECIES_HARIYAMA}, + {40, 40, SPECIES_LAIRON}, + {40, 40, SPECIES_MEDICHAM}, + {38, 38, SPECIES_GOLBAT}, + {38, 38, SPECIES_HARIYAMA}, + {42, 42, SPECIES_GOLBAT}, + {42, 42, SPECIES_HARIYAMA}, + {42, 42, SPECIES_LAIRON}, + {38, 38, SPECIES_MEDITITE}, + {42, 42, SPECIES_LAIRON}, + {38, 38, SPECIES_MEDITITE}, +}; +const struct WildPokemonInfo VictoryRoad_B1F_LandMonsInfo = {10, VictoryRoad_B1F_LandMons}; + +const struct WildPokemon VictoryRoad_B1F_RockSmashMons [] = +{ + {30, 40, SPECIES_GRAVELER}, + {30, 40, SPECIES_GEODUDE}, + {35, 40, SPECIES_GRAVELER}, + {35, 40, SPECIES_GRAVELER}, + {35, 40, SPECIES_GRAVELER}, +}; +const struct WildPokemonInfo VictoryRoad_B1F_RockSmashMonsInfo = {20, VictoryRoad_B1F_RockSmashMons}; + +const struct WildPokemon VictoryRoad_B2F_LandMons [] = +{ + {40, 40, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {40, 40, SPECIES_SABLEYE}, +#else + {40, 40, SPECIES_MAWILE}, +#endif + {40, 40, SPECIES_LAIRON}, + {40, 40, SPECIES_MEDICHAM}, + {42, 42, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {42, 42, SPECIES_SABLEYE}, +#else + {42, 42, SPECIES_MAWILE}, +#endif + {44, 44, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {44, 44, SPECIES_SABLEYE}, +#else + {44, 44, SPECIES_MAWILE}, +#endif + {42, 42, SPECIES_LAIRON}, + {42, 42, SPECIES_MEDICHAM}, + {44, 44, SPECIES_LAIRON}, + {44, 44, SPECIES_MEDICHAM}, +}; +const struct WildPokemonInfo VictoryRoad_B2F_LandMonsInfo = {10, VictoryRoad_B2F_LandMons}; + +const struct WildPokemon VictoryRoad_B2F_WaterMons [] = +{ + {30, 35, SPECIES_GOLBAT}, + {25, 30, SPECIES_GOLBAT}, + {35, 40, SPECIES_GOLBAT}, + {35, 40, SPECIES_GOLBAT}, + {35, 40, SPECIES_GOLBAT}, +}; +const struct WildPokemonInfo VictoryRoad_B2F_WaterMonsInfo = {4, VictoryRoad_B2F_WaterMons}; + +const struct WildPokemon VictoryRoad_B2F_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_GOLDEEN}, + {10, 30, SPECIES_BARBOACH}, + {25, 30, SPECIES_BARBOACH}, + {30, 35, SPECIES_BARBOACH}, + {30, 35, SPECIES_WHISCASH}, + {35, 40, SPECIES_WHISCASH}, + {40, 45, SPECIES_WHISCASH}, +}; +const struct WildPokemonInfo VictoryRoad_B2F_FishingMonsInfo = {30, VictoryRoad_B2F_FishingMons}; + +const struct WildPokemon ShoalCave_LowTideEntranceRoom_LandMons [] = +{ + {26, 26, SPECIES_ZUBAT}, + {26, 26, SPECIES_SPHEAL}, + {28, 28, SPECIES_ZUBAT}, + {28, 28, SPECIES_SPHEAL}, + {30, 30, SPECIES_ZUBAT}, + {30, 30, SPECIES_SPHEAL}, + {32, 32, SPECIES_ZUBAT}, + {32, 32, SPECIES_SPHEAL}, + {32, 32, SPECIES_GOLBAT}, + {32, 32, SPECIES_SPHEAL}, + {32, 32, SPECIES_GOLBAT}, + {32, 32, SPECIES_SPHEAL}, +}; +const struct WildPokemonInfo ShoalCave_LowTideEntranceRoom_LandMonsInfo = {10, ShoalCave_LowTideEntranceRoom_LandMons}; + +const struct WildPokemon ShoalCave_LowTideEntranceRoom_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {5, 35, SPECIES_ZUBAT}, + {25, 30, SPECIES_SPHEAL}, + {25, 30, SPECIES_SPHEAL}, + {25, 35, SPECIES_SPHEAL}, +}; +const struct WildPokemonInfo ShoalCave_LowTideEntranceRoom_WaterMonsInfo = {4, ShoalCave_LowTideEntranceRoom_WaterMons}; + +const struct WildPokemon ShoalCave_LowTideEntranceRoom_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo ShoalCave_LowTideEntranceRoom_FishingMonsInfo = {10, ShoalCave_LowTideEntranceRoom_FishingMons}; + +const struct WildPokemon ShoalCave_LowTideInnerRoom_LandMons [] = +{ + {26, 26, SPECIES_ZUBAT}, + {26, 26, SPECIES_SPHEAL}, + {28, 28, SPECIES_ZUBAT}, + {28, 28, SPECIES_SPHEAL}, + {30, 30, SPECIES_ZUBAT}, + {30, 30, SPECIES_SPHEAL}, + {32, 32, SPECIES_ZUBAT}, + {32, 32, SPECIES_SPHEAL}, + {32, 32, SPECIES_GOLBAT}, + {32, 32, SPECIES_SPHEAL}, + {32, 32, SPECIES_GOLBAT}, + {32, 32, SPECIES_SPHEAL}, +}; +const struct WildPokemonInfo ShoalCave_LowTideInnerRoom_LandMonsInfo = {10, ShoalCave_LowTideInnerRoom_LandMons}; + +const struct WildPokemon ShoalCave_LowTideInnerRoom_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {5, 35, SPECIES_ZUBAT}, + {25, 30, SPECIES_SPHEAL}, + {25, 30, SPECIES_SPHEAL}, + {25, 35, SPECIES_SPHEAL}, +}; +const struct WildPokemonInfo ShoalCave_LowTideInnerRoom_WaterMonsInfo = {4, ShoalCave_LowTideInnerRoom_WaterMons}; + +const struct WildPokemon ShoalCave_LowTideInnerRoom_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo ShoalCave_LowTideInnerRoom_FishingMonsInfo = {10, ShoalCave_LowTideInnerRoom_FishingMons}; + +const struct WildPokemon ShoalCave_LowTideStairsRoom_LandMons [] = +{ + {26, 26, SPECIES_ZUBAT}, + {26, 26, SPECIES_SPHEAL}, + {28, 28, SPECIES_ZUBAT}, + {28, 28, SPECIES_SPHEAL}, + {30, 30, SPECIES_ZUBAT}, + {30, 30, SPECIES_SPHEAL}, + {32, 32, SPECIES_ZUBAT}, + {32, 32, SPECIES_SPHEAL}, + {32, 32, SPECIES_GOLBAT}, + {32, 32, SPECIES_SPHEAL}, + {32, 32, SPECIES_GOLBAT}, + {32, 32, SPECIES_SPHEAL}, +}; +const struct WildPokemonInfo ShoalCave_LowTideStairsRoom_LandMonsInfo = {10, ShoalCave_LowTideStairsRoom_LandMons}; + +const struct WildPokemon ShoalCave_LowTideLowerRoom_LandMons [] = +{ + {26, 26, SPECIES_ZUBAT}, + {26, 26, SPECIES_SPHEAL}, + {28, 28, SPECIES_ZUBAT}, + {28, 28, SPECIES_SPHEAL}, + {30, 30, SPECIES_ZUBAT}, + {30, 30, SPECIES_SPHEAL}, + {32, 32, SPECIES_ZUBAT}, + {32, 32, SPECIES_SPHEAL}, + {32, 32, SPECIES_GOLBAT}, + {32, 32, SPECIES_SPHEAL}, + {32, 32, SPECIES_GOLBAT}, + {32, 32, SPECIES_SPHEAL}, +}; +const struct WildPokemonInfo ShoalCave_LowTideLowerRoom_LandMonsInfo = {10, ShoalCave_LowTideLowerRoom_LandMons}; + +const struct WildPokemon ShoalCave_LowTideIceRoom_LandMons [] = +{ + {26, 26, SPECIES_ZUBAT}, + {26, 26, SPECIES_SPHEAL}, + {28, 28, SPECIES_ZUBAT}, + {28, 28, SPECIES_SPHEAL}, + {30, 30, SPECIES_ZUBAT}, + {30, 30, SPECIES_SPHEAL}, + {26, 26, SPECIES_SNORUNT}, + {32, 32, SPECIES_SPHEAL}, + {30, 30, SPECIES_GOLBAT}, + {28, 28, SPECIES_SNORUNT}, + {32, 32, SPECIES_GOLBAT}, + {30, 30, SPECIES_SNORUNT}, +}; +const struct WildPokemonInfo ShoalCave_LowTideIceRoom_LandMonsInfo = {10, ShoalCave_LowTideIceRoom_LandMons}; + +const struct WildPokemon NewMauville_Entrance_LandMons [] = +{ + {24, 24, SPECIES_VOLTORB}, + {24, 24, SPECIES_MAGNEMITE}, + {25, 25, SPECIES_VOLTORB}, + {25, 25, SPECIES_MAGNEMITE}, + {23, 23, SPECIES_VOLTORB}, + {23, 23, SPECIES_MAGNEMITE}, + {26, 26, SPECIES_VOLTORB}, + {26, 26, SPECIES_MAGNEMITE}, + {22, 22, SPECIES_VOLTORB}, + {22, 22, SPECIES_MAGNEMITE}, + {22, 22, SPECIES_VOLTORB}, + {22, 22, SPECIES_MAGNEMITE}, +}; +const struct WildPokemonInfo NewMauville_Entrance_LandMonsInfo = {10, NewMauville_Entrance_LandMons}; + +const struct WildPokemon NewMauville_Inside_LandMons [] = +{ + {24, 24, SPECIES_VOLTORB}, + {24, 24, SPECIES_MAGNEMITE}, + {25, 25, SPECIES_VOLTORB}, + {25, 25, SPECIES_MAGNEMITE}, + {23, 23, SPECIES_VOLTORB}, + {23, 23, SPECIES_MAGNEMITE}, + {26, 26, SPECIES_VOLTORB}, + {26, 26, SPECIES_MAGNEMITE}, + {22, 22, SPECIES_VOLTORB}, + {22, 22, SPECIES_MAGNEMITE}, + {26, 26, SPECIES_ELECTRODE}, + {26, 26, SPECIES_MAGNETON}, +}; +const struct WildPokemonInfo NewMauville_Inside_LandMonsInfo = {10, NewMauville_Inside_LandMons}; + +const struct WildPokemon AbandonedShip_Rooms_B1F_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {5, 35, SPECIES_TENTACOOL}, + {5, 35, SPECIES_TENTACOOL}, + {5, 35, SPECIES_TENTACOOL}, + {30, 35, SPECIES_TENTACRUEL}, +}; +const struct WildPokemonInfo AbandonedShip_Rooms_B1F_WaterMonsInfo = {4, AbandonedShip_Rooms_B1F_WaterMons}; + +const struct WildPokemon AbandonedShip_Rooms_B1F_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_TENTACOOL}, + {25, 30, SPECIES_TENTACOOL}, + {30, 35, SPECIES_TENTACOOL}, + {30, 35, SPECIES_TENTACRUEL}, + {25, 30, SPECIES_TENTACRUEL}, + {20, 25, SPECIES_TENTACRUEL}, +}; +const struct WildPokemonInfo AbandonedShip_Rooms_B1F_FishingMonsInfo = {20, AbandonedShip_Rooms_B1F_FishingMons}; + +const struct WildPokemon AbandonedShip_HiddenFloorCorridors_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {5, 35, SPECIES_TENTACOOL}, + {5, 35, SPECIES_TENTACOOL}, + {5, 35, SPECIES_TENTACOOL}, + {30, 35, SPECIES_TENTACRUEL}, +}; +const struct WildPokemonInfo AbandonedShip_HiddenFloorCorridors_WaterMonsInfo = {4, AbandonedShip_HiddenFloorCorridors_WaterMons}; + +const struct WildPokemon AbandonedShip_HiddenFloorCorridors_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_TENTACOOL}, + {25, 30, SPECIES_TENTACOOL}, + {30, 35, SPECIES_TENTACOOL}, + {30, 35, SPECIES_TENTACRUEL}, + {25, 30, SPECIES_TENTACRUEL}, + {20, 25, SPECIES_TENTACRUEL}, +}; +const struct WildPokemonInfo AbandonedShip_HiddenFloorCorridors_FishingMonsInfo = {20, AbandonedShip_HiddenFloorCorridors_FishingMons}; + +const struct WildPokemon SkyPillar_1F_LandMons [] = +{ +#ifdef SAPPHIRE + {48, 48, SPECIES_SABLEYE}, +#else + {48, 48, SPECIES_MAWILE}, +#endif + {48, 48, SPECIES_GOLBAT}, + {50, 50, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {50, 50, SPECIES_SABLEYE}, +#else + {50, 50, SPECIES_MAWILE}, +#endif + {48, 48, SPECIES_CLAYDOL}, +#ifdef SAPPHIRE + {48, 48, SPECIES_BANETTE}, + {50, 50, SPECIES_BANETTE}, +#else + {48, 48, SPECIES_DUSCLOPS}, + {50, 50, SPECIES_DUSCLOPS}, +#endif + {49, 49, SPECIES_CLAYDOL}, + {47, 47, SPECIES_CLAYDOL}, + {50, 50, SPECIES_CLAYDOL}, + {47, 47, SPECIES_CLAYDOL}, + {50, 50, SPECIES_CLAYDOL}, +}; +const struct WildPokemonInfo SkyPillar_1F_LandMonsInfo = {10, SkyPillar_1F_LandMons}; + +const struct WildPokemon SkyPillar_3F_LandMons [] = +{ +#ifdef SAPPHIRE + {51, 51, SPECIES_SABLEYE}, +#else + {51, 51, SPECIES_MAWILE}, +#endif + {51, 51, SPECIES_GOLBAT}, + {53, 53, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {53, 53, SPECIES_SABLEYE}, +#else + {53, 53, SPECIES_MAWILE}, +#endif + {51, 51, SPECIES_CLAYDOL}, +#ifdef SAPPHIRE + {51, 51, SPECIES_BANETTE}, + {53, 53, SPECIES_BANETTE}, +#else + {51, 51, SPECIES_DUSCLOPS}, + {53, 53, SPECIES_DUSCLOPS}, +#endif + {52, 52, SPECIES_CLAYDOL}, + {50, 50, SPECIES_CLAYDOL}, + {53, 53, SPECIES_CLAYDOL}, + {50, 50, SPECIES_CLAYDOL}, + {53, 53, SPECIES_CLAYDOL}, +}; +const struct WildPokemonInfo SkyPillar_3F_LandMonsInfo = {10, SkyPillar_3F_LandMons}; + +const struct WildPokemon SkyPillar_5F_LandMons [] = +{ +#ifdef SAPPHIRE + {54, 54, SPECIES_SABLEYE}, +#else + {54, 54, SPECIES_MAWILE}, +#endif + {54, 54, SPECIES_GOLBAT}, + {56, 56, SPECIES_GOLBAT}, +#ifdef SAPPHIRE + {56, 56, SPECIES_SABLEYE}, +#else + {56, 56, SPECIES_MAWILE}, +#endif + {54, 54, SPECIES_CLAYDOL}, +#ifdef SAPPHIRE + {54, 54, SPECIES_BANETTE}, + {56, 56, SPECIES_BANETTE}, +#else + {54, 54, SPECIES_DUSCLOPS}, + {56, 56, SPECIES_DUSCLOPS}, +#endif + {55, 55, SPECIES_CLAYDOL}, + {56, 56, SPECIES_CLAYDOL}, + {57, 57, SPECIES_ALTARIA}, + {54, 54, SPECIES_ALTARIA}, + {60, 60, SPECIES_ALTARIA}, +}; +const struct WildPokemonInfo SkyPillar_5F_LandMonsInfo = {10, SkyPillar_5F_LandMons}; + +const struct WildPokemon Route101_LandMons [] = +{ + {2, 2, SPECIES_WURMPLE}, + {2, 2, SPECIES_ZIGZAGOON}, + {2, 2, SPECIES_WURMPLE}, + {3, 3, SPECIES_WURMPLE}, + {3, 3, SPECIES_ZIGZAGOON}, + {3, 3, SPECIES_ZIGZAGOON}, + {3, 3, SPECIES_WURMPLE}, + {3, 3, SPECIES_ZIGZAGOON}, + {2, 2, SPECIES_POOCHYENA}, + {2, 2, SPECIES_POOCHYENA}, + {3, 3, SPECIES_POOCHYENA}, + {3, 3, SPECIES_POOCHYENA}, +}; +const struct WildPokemonInfo Route101_LandMonsInfo = {20, Route101_LandMons}; + +const struct WildPokemon Route102_LandMons [] = +{ + {3, 3, SPECIES_ZIGZAGOON}, + {3, 3, SPECIES_WURMPLE}, + {4, 4, SPECIES_ZIGZAGOON}, + {4, 4, SPECIES_WURMPLE}, +#ifdef SAPPHIRE + {3, 3, SPECIES_LOTAD}, + {4, 4, SPECIES_LOTAD}, +#else + {3, 3, SPECIES_SEEDOT}, + {4, 4, SPECIES_SEEDOT}, +#endif + {3, 3, SPECIES_POOCHYENA}, + {3, 3, SPECIES_POOCHYENA}, + {4, 4, SPECIES_POOCHYENA}, + {4, 4, SPECIES_RALTS}, + {4, 4, SPECIES_POOCHYENA}, + {3, 3, SPECIES_SURSKIT}, +}; +const struct WildPokemonInfo Route102_LandMonsInfo = {20, Route102_LandMons}; + +const struct WildPokemon Route102_WaterMons [] = +{ + {20, 30, SPECIES_MARILL}, + {10, 20, SPECIES_MARILL}, + {30, 35, SPECIES_MARILL}, + {5, 10, SPECIES_MARILL}, + {20, 30, SPECIES_SURSKIT}, +}; +const struct WildPokemonInfo Route102_WaterMonsInfo = {4, Route102_WaterMons}; + +const struct WildPokemon Route102_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_GOLDEEN}, + {10, 30, SPECIES_CORPHISH}, + {25, 30, SPECIES_CORPHISH}, + {30, 35, SPECIES_CORPHISH}, + {20, 25, SPECIES_CORPHISH}, + {35, 40, SPECIES_CORPHISH}, + {40, 45, SPECIES_CORPHISH}, +}; +const struct WildPokemonInfo Route102_FishingMonsInfo = {30, Route102_FishingMons}; + +const struct WildPokemon Route103_LandMons [] = +{ + {2, 2, SPECIES_ZIGZAGOON}, + {3, 3, SPECIES_ZIGZAGOON}, + {3, 3, SPECIES_ZIGZAGOON}, + {4, 4, SPECIES_ZIGZAGOON}, + {2, 2, SPECIES_POOCHYENA}, + {3, 3, SPECIES_POOCHYENA}, + {3, 3, SPECIES_POOCHYENA}, + {4, 4, SPECIES_POOCHYENA}, + {3, 3, SPECIES_WINGULL}, + {3, 3, SPECIES_WINGULL}, + {2, 2, SPECIES_WINGULL}, + {4, 4, SPECIES_WINGULL}, +}; +const struct WildPokemonInfo Route103_LandMonsInfo = {20, Route103_LandMons}; + +const struct WildPokemon Route103_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route103_WaterMonsInfo = {4, Route103_WaterMons}; + +const struct WildPokemon Route103_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route103_FishingMonsInfo = {30, Route103_FishingMons}; + +const struct WildPokemon Route104_LandMons [] = +{ + {4, 4, SPECIES_ZIGZAGOON}, + {4, 4, SPECIES_WURMPLE}, + {5, 5, SPECIES_ZIGZAGOON}, + {5, 5, SPECIES_WURMPLE}, + {4, 4, SPECIES_ZIGZAGOON}, + {5, 5, SPECIES_ZIGZAGOON}, + {4, 4, SPECIES_TAILLOW}, + {5, 5, SPECIES_TAILLOW}, + {4, 4, SPECIES_WINGULL}, + {4, 4, SPECIES_WINGULL}, + {3, 3, SPECIES_WINGULL}, + {5, 5, SPECIES_WINGULL}, +}; +const struct WildPokemonInfo Route104_LandMonsInfo = {20, Route104_LandMons}; + +const struct WildPokemon Route104_WaterMons [] = +{ + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route104_WaterMonsInfo = {4, Route104_WaterMons}; + +const struct WildPokemon Route104_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_MAGIKARP}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_MAGIKARP}, + {25, 30, SPECIES_MAGIKARP}, + {30, 35, SPECIES_MAGIKARP}, + {20, 25, SPECIES_MAGIKARP}, + {35, 40, SPECIES_MAGIKARP}, + {40, 45, SPECIES_MAGIKARP}, +}; +const struct WildPokemonInfo Route104_FishingMonsInfo = {30, Route104_FishingMons}; + +const struct WildPokemon Route105_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route105_WaterMonsInfo = {4, Route105_WaterMons}; + +const struct WildPokemon Route105_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route105_FishingMonsInfo = {30, Route105_FishingMons}; + +const struct WildPokemon Route106_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route106_WaterMonsInfo = {4, Route106_WaterMons}; + +const struct WildPokemon Route106_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route106_FishingMonsInfo = {30, Route106_FishingMons}; + +const struct WildPokemon Route107_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route107_WaterMonsInfo = {4, Route107_WaterMons}; + +const struct WildPokemon Route107_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route107_FishingMonsInfo = {30, Route107_FishingMons}; + +const struct WildPokemon Route108_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route108_WaterMonsInfo = {4, Route108_WaterMons}; + +const struct WildPokemon Route108_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route108_FishingMonsInfo = {30, Route108_FishingMons}; + +const struct WildPokemon Route109_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route109_WaterMonsInfo = {4, Route109_WaterMons}; + +const struct WildPokemon Route109_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route109_FishingMonsInfo = {30, Route109_FishingMons}; + +const struct WildPokemon Route110_LandMons [] = +{ + {12, 12, SPECIES_ZIGZAGOON}, + {12, 12, SPECIES_ELECTRIKE}, + {12, 12, SPECIES_GULPIN}, + {13, 13, SPECIES_ELECTRIKE}, +#ifdef SAPPHIRE + {13, 13, SPECIES_PLUSLE}, +#else + {13, 13, SPECIES_MINUN}, +#endif + {13, 13, SPECIES_ODDISH}, +#ifdef SAPPHIRE + {13, 13, SPECIES_PLUSLE}, +#else + {13, 13, SPECIES_MINUN}, +#endif + {13, 13, SPECIES_GULPIN}, + {12, 12, SPECIES_WINGULL}, + {12, 12, SPECIES_WINGULL}, +#ifdef SAPPHIRE + {12, 12, SPECIES_MINUN}, + {13, 13, SPECIES_MINUN}, +#else + {12, 12, SPECIES_PLUSLE}, + {13, 13, SPECIES_PLUSLE}, +#endif +}; +const struct WildPokemonInfo Route110_LandMonsInfo = {20, Route110_LandMons}; + +const struct WildPokemon Route110_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route110_WaterMonsInfo = {4, Route110_WaterMons}; + +const struct WildPokemon Route110_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route110_FishingMonsInfo = {30, Route110_FishingMons}; + +const struct WildPokemon Route111_LandMons [] = +{ + {20, 20, SPECIES_SANDSHREW}, + {20, 20, SPECIES_TRAPINCH}, + {21, 21, SPECIES_SANDSHREW}, + {21, 21, SPECIES_TRAPINCH}, + {19, 19, SPECIES_CACNEA}, + {21, 21, SPECIES_CACNEA}, + {19, 19, SPECIES_SANDSHREW}, + {19, 19, SPECIES_TRAPINCH}, + {20, 20, SPECIES_BALTOY}, + {20, 20, SPECIES_BALTOY}, + {22, 22, SPECIES_BALTOY}, + {22, 22, SPECIES_BALTOY}, +}; +const struct WildPokemonInfo Route111_LandMonsInfo = {10, Route111_LandMons}; + +const struct WildPokemon Route111_WaterMons [] = +{ + {20, 30, SPECIES_MARILL}, + {10, 20, SPECIES_MARILL}, + {30, 35, SPECIES_MARILL}, + {5, 10, SPECIES_MARILL}, + {20, 30, SPECIES_SURSKIT}, +}; +const struct WildPokemonInfo Route111_WaterMonsInfo = {4, Route111_WaterMons}; + +const struct WildPokemon Route111_RockSmashMons [] = +{ + {10, 15, SPECIES_GEODUDE}, + {5, 10, SPECIES_GEODUDE}, + {15, 20, SPECIES_GEODUDE}, + {15, 20, SPECIES_GEODUDE}, + {15, 20, SPECIES_GEODUDE}, +}; +const struct WildPokemonInfo Route111_RockSmashMonsInfo = {20, Route111_RockSmashMons}; + +const struct WildPokemon Route111_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_GOLDEEN}, + {10, 30, SPECIES_BARBOACH}, + {25, 30, SPECIES_BARBOACH}, + {30, 35, SPECIES_BARBOACH}, + {20, 25, SPECIES_BARBOACH}, + {35, 40, SPECIES_BARBOACH}, + {40, 45, SPECIES_BARBOACH}, +}; +const struct WildPokemonInfo Route111_FishingMonsInfo = {30, Route111_FishingMons}; + +const struct WildPokemon Route112_LandMons [] = +{ + {15, 15, SPECIES_NUMEL}, + {15, 15, SPECIES_NUMEL}, + {15, 15, SPECIES_MACHOP}, + {14, 14, SPECIES_NUMEL}, + {14, 14, SPECIES_NUMEL}, + {14, 14, SPECIES_MACHOP}, + {16, 16, SPECIES_NUMEL}, + {16, 16, SPECIES_MACHOP}, + {16, 16, SPECIES_NUMEL}, + {16, 16, SPECIES_NUMEL}, + {16, 16, SPECIES_NUMEL}, + {16, 16, SPECIES_NUMEL}, +}; +const struct WildPokemonInfo Route112_LandMonsInfo = {20, Route112_LandMons}; + +const struct WildPokemon Route113_LandMons [] = +{ + {15, 15, SPECIES_SPINDA}, + {15, 15, SPECIES_SPINDA}, + {15, 15, SPECIES_SANDSHREW}, + {14, 14, SPECIES_SPINDA}, + {14, 14, SPECIES_SPINDA}, + {14, 14, SPECIES_SANDSHREW}, + {16, 16, SPECIES_SPINDA}, + {16, 16, SPECIES_SANDSHREW}, + {16, 16, SPECIES_SPINDA}, + {16, 16, SPECIES_SKARMORY}, + {16, 16, SPECIES_SPINDA}, + {16, 16, SPECIES_SKARMORY}, +}; +const struct WildPokemonInfo Route113_LandMonsInfo = {20, Route113_LandMons}; + +const struct WildPokemon Route114_LandMons [] = +{ + {16, 16, SPECIES_SWABLU}, +#ifdef SAPPHIRE + {16, 16, SPECIES_LOTAD}, +#else + {16, 16, SPECIES_SEEDOT}, +#endif + {17, 17, SPECIES_SWABLU}, + {15, 15, SPECIES_SWABLU}, +#ifdef SAPPHIRE + {15, 15, SPECIES_LOTAD}, + {16, 16, SPECIES_SEVIPER}, + {16, 16, SPECIES_LOMBRE}, + {18, 18, SPECIES_LOMBRE}, + {17, 17, SPECIES_SEVIPER}, + {15, 15, SPECIES_SEVIPER}, + {17, 17, SPECIES_SEVIPER}, +#else + {15, 15, SPECIES_SEEDOT}, + {16, 16, SPECIES_ZANGOOSE}, + {16, 16, SPECIES_NUZLEAF}, + {18, 18, SPECIES_NUZLEAF}, + {17, 17, SPECIES_ZANGOOSE}, + {15, 15, SPECIES_ZANGOOSE}, + {17, 17, SPECIES_ZANGOOSE}, +#endif + {15, 15, SPECIES_SURSKIT}, +}; +const struct WildPokemonInfo Route114_LandMonsInfo = {20, Route114_LandMons}; + +const struct WildPokemon Route114_WaterMons [] = +{ + {20, 30, SPECIES_MARILL}, + {10, 20, SPECIES_MARILL}, + {30, 35, SPECIES_MARILL}, + {5, 10, SPECIES_MARILL}, + {20, 30, SPECIES_SURSKIT}, +}; +const struct WildPokemonInfo Route114_WaterMonsInfo = {4, Route114_WaterMons}; + +const struct WildPokemon Route114_RockSmashMons [] = +{ + {10, 15, SPECIES_GEODUDE}, + {5, 10, SPECIES_GEODUDE}, + {15, 20, SPECIES_GEODUDE}, + {15, 20, SPECIES_GEODUDE}, + {15, 20, SPECIES_GEODUDE}, +}; +const struct WildPokemonInfo Route114_RockSmashMonsInfo = {20, Route114_RockSmashMons}; + +const struct WildPokemon Route114_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_GOLDEEN}, + {10, 30, SPECIES_BARBOACH}, + {25, 30, SPECIES_BARBOACH}, + {30, 35, SPECIES_BARBOACH}, + {20, 25, SPECIES_BARBOACH}, + {35, 40, SPECIES_BARBOACH}, + {40, 45, SPECIES_BARBOACH}, +}; +const struct WildPokemonInfo Route114_FishingMonsInfo = {30, Route114_FishingMons}; + +const struct WildPokemon Route115_LandMons [] = +{ + {23, 23, SPECIES_SWABLU}, + {23, 23, SPECIES_TAILLOW}, + {25, 25, SPECIES_SWABLU}, + {24, 24, SPECIES_TAILLOW}, + {25, 25, SPECIES_TAILLOW}, + {25, 25, SPECIES_SWELLOW}, + {24, 24, SPECIES_JIGGLYPUFF}, + {25, 25, SPECIES_JIGGLYPUFF}, + {24, 24, SPECIES_WINGULL}, + {24, 24, SPECIES_WINGULL}, + {26, 26, SPECIES_WINGULL}, + {25, 25, SPECIES_WINGULL}, +}; +const struct WildPokemonInfo Route115_LandMonsInfo = {20, Route115_LandMons}; + +const struct WildPokemon Route115_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route115_WaterMonsInfo = {4, Route115_WaterMons}; + +const struct WildPokemon Route115_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route115_FishingMonsInfo = {30, Route115_FishingMons}; + +const struct WildPokemon Route116_LandMons [] = +{ + {6, 6, SPECIES_ZIGZAGOON}, + {6, 6, SPECIES_WHISMUR}, + {6, 6, SPECIES_NINCADA}, + {7, 7, SPECIES_WHISMUR}, + {7, 7, SPECIES_NINCADA}, + {6, 6, SPECIES_TAILLOW}, + {7, 7, SPECIES_TAILLOW}, + {8, 8, SPECIES_TAILLOW}, + {7, 7, SPECIES_ZIGZAGOON}, + {8, 8, SPECIES_ZIGZAGOON}, + {7, 7, SPECIES_SKITTY}, + {8, 8, SPECIES_SKITTY}, +}; +const struct WildPokemonInfo Route116_LandMonsInfo = {20, Route116_LandMons}; + +const struct WildPokemon Route117_LandMons [] = +{ + {13, 13, SPECIES_ZIGZAGOON}, + {13, 13, SPECIES_ROSELIA}, + {14, 14, SPECIES_ZIGZAGOON}, + {14, 14, SPECIES_ROSELIA}, + {13, 13, SPECIES_MARILL}, + {13, 13, SPECIES_ODDISH}, +#ifdef SAPPHIRE + {13, 13, SPECIES_VOLBEAT}, + {13, 13, SPECIES_VOLBEAT}, + {14, 14, SPECIES_VOLBEAT}, + {14, 14, SPECIES_VOLBEAT}, + {13, 13, SPECIES_ILLUMISE}, +#else + {13, 13, SPECIES_ILLUMISE}, + {13, 13, SPECIES_ILLUMISE}, + {14, 14, SPECIES_ILLUMISE}, + {14, 14, SPECIES_ILLUMISE}, + {13, 13, SPECIES_VOLBEAT}, +#endif + {13, 13, SPECIES_SURSKIT}, +}; +const struct WildPokemonInfo Route117_LandMonsInfo = {20, Route117_LandMons}; + +const struct WildPokemon Route117_WaterMons [] = +{ + {20, 30, SPECIES_MARILL}, + {10, 20, SPECIES_MARILL}, + {30, 35, SPECIES_MARILL}, + {5, 10, SPECIES_MARILL}, + {20, 30, SPECIES_SURSKIT}, +}; +const struct WildPokemonInfo Route117_WaterMonsInfo = {4, Route117_WaterMons}; + +const struct WildPokemon Route117_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_GOLDEEN}, + {10, 30, SPECIES_CORPHISH}, + {25, 30, SPECIES_CORPHISH}, + {30, 35, SPECIES_CORPHISH}, + {20, 25, SPECIES_CORPHISH}, + {35, 40, SPECIES_CORPHISH}, + {40, 45, SPECIES_CORPHISH}, +}; +const struct WildPokemonInfo Route117_FishingMonsInfo = {30, Route117_FishingMons}; + +const struct WildPokemon Route118_LandMons [] = +{ + {24, 24, SPECIES_ZIGZAGOON}, + {24, 24, SPECIES_ELECTRIKE}, + {26, 26, SPECIES_ZIGZAGOON}, + {26, 26, SPECIES_ELECTRIKE}, + {26, 26, SPECIES_LINOONE}, + {26, 26, SPECIES_MANECTRIC}, + {25, 25, SPECIES_WINGULL}, + {25, 25, SPECIES_WINGULL}, + {26, 26, SPECIES_WINGULL}, + {26, 26, SPECIES_WINGULL}, + {27, 27, SPECIES_WINGULL}, + {25, 25, SPECIES_KECLEON}, +}; +const struct WildPokemonInfo Route118_LandMonsInfo = {20, Route118_LandMons}; + +const struct WildPokemon Route118_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route118_WaterMonsInfo = {4, Route118_WaterMons}; + +const struct WildPokemon Route118_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_CARVANHA}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_CARVANHA}, + {20, 25, SPECIES_CARVANHA}, + {35, 40, SPECIES_CARVANHA}, + {40, 45, SPECIES_CARVANHA}, +}; +const struct WildPokemonInfo Route118_FishingMonsInfo = {30, Route118_FishingMons}; + +const struct WildPokemon Route119_LandMons [] = +{ + {25, 25, SPECIES_ZIGZAGOON}, + {25, 25, SPECIES_LINOONE}, + {27, 27, SPECIES_ZIGZAGOON}, + {25, 25, SPECIES_ODDISH}, + {27, 27, SPECIES_LINOONE}, + {26, 26, SPECIES_ODDISH}, + {27, 27, SPECIES_ODDISH}, + {24, 24, SPECIES_ODDISH}, + {25, 25, SPECIES_TROPIUS}, + {26, 26, SPECIES_TROPIUS}, + {27, 27, SPECIES_TROPIUS}, + {25, 25, SPECIES_KECLEON}, +}; +const struct WildPokemonInfo Route119_LandMonsInfo = {15, Route119_LandMons}; + +const struct WildPokemon Route119_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route119_WaterMonsInfo = {4, Route119_WaterMons}; + +const struct WildPokemon Route119_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_CARVANHA}, + {25, 30, SPECIES_CARVANHA}, + {30, 35, SPECIES_CARVANHA}, + {20, 25, SPECIES_CARVANHA}, + {35, 40, SPECIES_CARVANHA}, + {40, 45, SPECIES_CARVANHA}, }; +const struct WildPokemonInfo Route119_FishingMonsInfo = {30, Route119_FishingMons}; + +const struct WildPokemon Route120_LandMons [] = +{ + {25, 25, SPECIES_ZIGZAGOON}, + {25, 25, SPECIES_LINOONE}, + {27, 27, SPECIES_LINOONE}, + {25, 25, SPECIES_ODDISH}, + {25, 25, SPECIES_MARILL}, + {26, 26, SPECIES_ODDISH}, + {27, 27, SPECIES_ODDISH}, + {27, 27, SPECIES_MARILL}, + {25, 25, SPECIES_ABSOL}, + {27, 27, SPECIES_ABSOL}, + {25, 25, SPECIES_KECLEON}, + {25, 25, SPECIES_SURSKIT}, +}; +const struct WildPokemonInfo Route120_LandMonsInfo = {20, Route120_LandMons}; + +const struct WildPokemon Route120_WaterMons [] = +{ + {20, 30, SPECIES_MARILL}, + {10, 20, SPECIES_MARILL}, + {30, 35, SPECIES_MARILL}, + {5, 10, SPECIES_MARILL}, + {20, 30, SPECIES_SURSKIT}, +}; +const struct WildPokemonInfo Route120_WaterMonsInfo = {4, Route120_WaterMons}; + +const struct WildPokemon Route120_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_GOLDEEN}, + {10, 30, SPECIES_BARBOACH}, + {25, 30, SPECIES_BARBOACH}, + {30, 35, SPECIES_BARBOACH}, + {20, 25, SPECIES_BARBOACH}, + {35, 40, SPECIES_BARBOACH}, + {40, 45, SPECIES_BARBOACH}, +}; +const struct WildPokemonInfo Route120_FishingMonsInfo = {30, Route120_FishingMons}; + +const struct WildPokemon Route121_LandMons [] = +{ + {26, 26, SPECIES_ZIGZAGOON}, +#ifdef SAPPHIRE + {26, 26, SPECIES_SHUPPET}, +#else + {26, 26, SPECIES_DUSKULL}, +#endif + {26, 26, SPECIES_LINOONE}, +#ifdef SAPPHIRE + {28, 28, SPECIES_SHUPPET}, +#else + {28, 28, SPECIES_DUSKULL}, +#endif + {28, 28, SPECIES_LINOONE}, + {26, 26, SPECIES_ODDISH}, + {28, 28, SPECIES_ODDISH}, + {28, 28, SPECIES_GLOOM}, + {26, 26, SPECIES_WINGULL}, + {27, 27, SPECIES_WINGULL}, + {28, 28, SPECIES_WINGULL}, + {25, 25, SPECIES_KECLEON}, +}; +const struct WildPokemonInfo Route121_LandMonsInfo = {20, Route121_LandMons}; + +const struct WildPokemon Route121_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route121_WaterMonsInfo = {4, Route121_WaterMons}; + +const struct WildPokemon Route121_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route121_FishingMonsInfo = {30, Route121_FishingMons}; + +const struct WildPokemon Route122_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route122_WaterMonsInfo = {4, Route122_WaterMons}; + +const struct WildPokemon Route122_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route122_FishingMonsInfo = {30, Route122_FishingMons}; + +const struct WildPokemon Route123_LandMons [] = +{ + {26, 26, SPECIES_ZIGZAGOON}, +#ifdef SAPPHIRE + {26, 26, SPECIES_SHUPPET}, +#else + {26, 26, SPECIES_DUSKULL}, +#endif + {26, 26, SPECIES_LINOONE}, +#ifdef SAPPHIRE + {28, 28, SPECIES_SHUPPET}, +#else + {28, 28, SPECIES_DUSKULL}, +#endif + {28, 28, SPECIES_LINOONE}, + {26, 26, SPECIES_ODDISH}, + {28, 28, SPECIES_ODDISH}, + {28, 28, SPECIES_GLOOM}, + {26, 26, SPECIES_WINGULL}, + {27, 27, SPECIES_WINGULL}, + {28, 28, SPECIES_WINGULL}, + {25, 25, SPECIES_KECLEON}, +}; +const struct WildPokemonInfo Route123_LandMonsInfo = {20, Route123_LandMons}; + +const struct WildPokemon Route123_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route123_WaterMonsInfo = {4, Route123_WaterMons}; + +const struct WildPokemon Route123_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route123_FishingMonsInfo = {30, Route123_FishingMons}; + +const struct WildPokemon Route124_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route124_WaterMonsInfo = {4, Route124_WaterMons}; + +const struct WildPokemon Route124_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route124_FishingMonsInfo = {30, Route124_FishingMons}; + +const struct WildPokemon Route125_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route125_WaterMonsInfo = {4, Route125_WaterMons}; + +const struct WildPokemon Route125_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route125_FishingMonsInfo = {30, Route125_FishingMons}; + +const struct WildPokemon Route126_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route126_WaterMonsInfo = {4, Route126_WaterMons}; + +const struct WildPokemon Route126_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route126_FishingMonsInfo = {30, Route126_FishingMons}; + +const struct WildPokemon Route127_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route127_WaterMonsInfo = {4, Route127_WaterMons}; + +const struct WildPokemon Route127_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route127_FishingMonsInfo = {30, Route127_FishingMons}; + +const struct WildPokemon Route128_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route128_WaterMonsInfo = {4, Route128_WaterMons}; + +const struct WildPokemon Route128_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_LUVDISC}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_LUVDISC}, + {30, 35, SPECIES_WAILMER}, + {30, 35, SPECIES_CORSOLA}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route128_FishingMonsInfo = {30, Route128_FishingMons}; + +const struct WildPokemon Route129_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, +#ifdef SAPPHIRE + {25, 30, SPECIES_WAILORD}, +#else + {35, 40, SPECIES_WAILORD}, +#endif +}; +const struct WildPokemonInfo Route129_WaterMonsInfo = {4, Route129_WaterMons}; + +const struct WildPokemon Route129_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route129_FishingMonsInfo = {30, Route129_FishingMons}; + +const struct WildPokemon Route130_LandMons [] = +{ + {30, 30, SPECIES_WYNAUT}, + {35, 35, SPECIES_WYNAUT}, + {25, 25, SPECIES_WYNAUT}, + {40, 40, SPECIES_WYNAUT}, + {20, 20, SPECIES_WYNAUT}, + {45, 45, SPECIES_WYNAUT}, + {15, 15, SPECIES_WYNAUT}, + {50, 50, SPECIES_WYNAUT}, + {10, 10, SPECIES_WYNAUT}, + {5, 5, SPECIES_WYNAUT}, + {10, 10, SPECIES_WYNAUT}, + {5, 5, SPECIES_WYNAUT}, +}; +const struct WildPokemonInfo Route130_LandMonsInfo = {20, Route130_LandMons}; + +const struct WildPokemon Route130_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route130_WaterMonsInfo = {4, Route130_WaterMons}; + +const struct WildPokemon Route130_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route130_FishingMonsInfo = {30, Route130_FishingMons}; + +const struct WildPokemon Route131_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route131_WaterMonsInfo = {4, Route131_WaterMons}; + +const struct WildPokemon Route131_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route131_FishingMonsInfo = {30, Route131_FishingMons}; + +const struct WildPokemon Route132_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route132_WaterMonsInfo = {4, Route132_WaterMons}; + +const struct WildPokemon Route132_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_HORSEA}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route132_FishingMonsInfo = {30, Route132_FishingMons}; + +const struct WildPokemon Route133_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route133_WaterMonsInfo = {4, Route133_WaterMons}; + +const struct WildPokemon Route133_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_HORSEA}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route133_FishingMonsInfo = {30, Route133_FishingMons}; + +const struct WildPokemon Route134_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo Route134_WaterMonsInfo = {4, Route134_WaterMons}; + +const struct WildPokemon Route134_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_HORSEA}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo Route134_FishingMonsInfo = {30, Route134_FishingMons}; + +const struct WildPokemon SafariZone_Northwest_LandMons [] = +{ + {27, 27, SPECIES_RHYHORN}, + {27, 27, SPECIES_ODDISH}, + {29, 29, SPECIES_RHYHORN}, + {29, 29, SPECIES_ODDISH}, + {27, 27, SPECIES_DODUO}, + {29, 29, SPECIES_GLOOM}, + {31, 31, SPECIES_GLOOM}, + {29, 29, SPECIES_DODUO}, + {29, 29, SPECIES_DODRIO}, + {27, 27, SPECIES_PINSIR}, + {31, 31, SPECIES_DODRIO}, + {29, 29, SPECIES_PINSIR}, +}; +const struct WildPokemonInfo SafariZone_Northwest_LandMonsInfo = {25, SafariZone_Northwest_LandMons}; + +const struct WildPokemon SafariZone_Northwest_WaterMons [] = +{ + {20, 30, SPECIES_PSYDUCK}, + {20, 30, SPECIES_PSYDUCK}, + {30, 35, SPECIES_PSYDUCK}, + {30, 35, SPECIES_GOLDUCK}, + {25, 40, SPECIES_GOLDUCK}, +}; +const struct WildPokemonInfo SafariZone_Northwest_WaterMonsInfo = {9, SafariZone_Northwest_WaterMons}; + +const struct WildPokemon SafariZone_Northwest_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 25, SPECIES_GOLDEEN}, + {10, 30, SPECIES_GOLDEEN}, + {25, 30, SPECIES_GOLDEEN}, + {30, 35, SPECIES_GOLDEEN}, + {30, 35, SPECIES_SEAKING}, + {35, 40, SPECIES_SEAKING}, + {25, 30, SPECIES_SEAKING}, +}; +const struct WildPokemonInfo SafariZone_Northwest_FishingMonsInfo = {35, SafariZone_Northwest_FishingMons}; + +const struct WildPokemon SafariZone_Northeast_LandMons [] = +{ + {27, 27, SPECIES_PHANPY}, + {27, 27, SPECIES_ODDISH}, + {29, 29, SPECIES_PHANPY}, + {29, 29, SPECIES_ODDISH}, + {27, 27, SPECIES_NATU}, + {29, 29, SPECIES_GLOOM}, + {31, 31, SPECIES_GLOOM}, + {29, 29, SPECIES_NATU}, + {29, 29, SPECIES_XATU}, + {27, 27, SPECIES_HERACROSS}, + {31, 31, SPECIES_XATU}, + {29, 29, SPECIES_HERACROSS}, +}; +const struct WildPokemonInfo SafariZone_Northeast_LandMonsInfo = {25, SafariZone_Northeast_LandMons}; + +const struct WildPokemon SafariZone_Northeast_RockSmashMons [] = +{ + {10, 15, SPECIES_GEODUDE}, + {5, 10, SPECIES_GEODUDE}, + {15, 20, SPECIES_GEODUDE}, + {20, 25, SPECIES_GEODUDE}, + {25, 30, SPECIES_GEODUDE}, +}; +const struct WildPokemonInfo SafariZone_Northeast_RockSmashMonsInfo = {25, SafariZone_Northeast_RockSmashMons}; + +const struct WildPokemon SafariZone_Southwest_LandMons [] = +{ + {25, 25, SPECIES_ODDISH}, + {27, 27, SPECIES_ODDISH}, + {25, 25, SPECIES_GIRAFARIG}, + {27, 27, SPECIES_GIRAFARIG}, + {25, 25, SPECIES_NATU}, +#ifdef SAPPHIRE + {27, 27, SPECIES_DODUO}, +#else + {25, 25, SPECIES_DODUO}, +#endif + {25, 25, SPECIES_GLOOM}, + {27, 27, SPECIES_WOBBUFFET}, + {25, 25, SPECIES_PIKACHU}, + {27, 27, SPECIES_WOBBUFFET}, + {27, 27, SPECIES_PIKACHU}, + {29, 29, SPECIES_WOBBUFFET}, +}; +const struct WildPokemonInfo SafariZone_Southwest_LandMonsInfo = {25, SafariZone_Southwest_LandMons}; + +const struct WildPokemon SafariZone_Southwest_WaterMons [] = +{ + {20, 30, SPECIES_PSYDUCK}, + {20, 30, SPECIES_PSYDUCK}, + {30, 35, SPECIES_PSYDUCK}, + {30, 35, SPECIES_PSYDUCK}, + {30, 35, SPECIES_PSYDUCK}, +}; +const struct WildPokemonInfo SafariZone_Southwest_WaterMonsInfo = {9, SafariZone_Southwest_WaterMons}; + +const struct WildPokemon SafariZone_Southwest_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_GOLDEEN}, + {10, 30, SPECIES_MAGIKARP}, + {10, 25, SPECIES_GOLDEEN}, + {10, 30, SPECIES_GOLDEEN}, + {25, 30, SPECIES_GOLDEEN}, + {30, 35, SPECIES_GOLDEEN}, + {30, 35, SPECIES_SEAKING}, + {35, 40, SPECIES_SEAKING}, + {25, 30, SPECIES_SEAKING}, +}; +const struct WildPokemonInfo SafariZone_Southwest_FishingMonsInfo = {35, SafariZone_Southwest_FishingMons}; + +const struct WildPokemon SafariZone_Southeast_LandMons [] = +{ + {25, 25, SPECIES_ODDISH}, + {27, 27, SPECIES_ODDISH}, + {25, 25, SPECIES_GIRAFARIG}, + {27, 27, SPECIES_GIRAFARIG}, + {25, 25, SPECIES_NATU}, + {25, 25, SPECIES_DODUO}, + {25, 25, SPECIES_GLOOM}, + {27, 27, SPECIES_WOBBUFFET}, + {25, 25, SPECIES_PIKACHU}, + {27, 27, SPECIES_WOBBUFFET}, + {27, 27, SPECIES_PIKACHU}, + {29, 29, SPECIES_WOBBUFFET}, +}; +const struct WildPokemonInfo SafariZone_Southeast_LandMonsInfo = {25, SafariZone_Southeast_LandMons}; + +const struct WildPokemon DewfordTown_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo DewfordTown_WaterMonsInfo = {4, DewfordTown_WaterMons}; + +const struct WildPokemon DewfordTown_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_WAILMER}, + {20, 25, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo DewfordTown_FishingMonsInfo = {10, DewfordTown_FishingMons}; + +const struct WildPokemon PacifidlogTown_WaterMons [] = +{ + {5, 35, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WINGULL}, + {15, 25, SPECIES_WINGULL}, + {25, 30, SPECIES_PELIPPER}, + {25, 30, SPECIES_PELIPPER}, +}; +const struct WildPokemonInfo PacifidlogTown_WaterMonsInfo = {4, PacifidlogTown_WaterMons}; + +const struct WildPokemon PacifidlogTown_FishingMons [] = +{ + {5, 10, SPECIES_MAGIKARP}, + {5, 10, SPECIES_TENTACOOL}, + {10, 30, SPECIES_MAGIKARP}, + {10, 30, SPECIES_TENTACOOL}, + {10, 30, SPECIES_WAILMER}, + {30, 35, SPECIES_SHARPEDO}, + {30, 35, SPECIES_WAILMER}, + {25, 30, SPECIES_WAILMER}, + {35, 40, SPECIES_WAILMER}, + {40, 45, SPECIES_WAILMER}, +}; +const struct WildPokemonInfo PacifidlogTown_FishingMonsInfo = {10, PacifidlogTown_FishingMons}; + +const struct WildPokemon Underwater1_WaterMons [] = +{ + {20, 30, SPECIES_CLAMPERL}, + {20, 30, SPECIES_CHINCHOU}, + {30, 35, SPECIES_CLAMPERL}, + {30, 35, SPECIES_RELICANTH}, + {30, 35, SPECIES_RELICANTH}, +}; +const struct WildPokemonInfo Underwater1_WaterMonsInfo = {4, Underwater1_WaterMons}; + +const struct WildPokemon Underwater2_WaterMons [] = +{ + {20, 30, SPECIES_CLAMPERL}, + {20, 30, SPECIES_CHINCHOU}, + {30, 35, SPECIES_CLAMPERL}, + {30, 35, SPECIES_RELICANTH}, + {30, 35, SPECIES_RELICANTH}, +}; +const struct WildPokemonInfo Underwater2_WaterMonsInfo = {4, Underwater2_WaterMons}; + extern u16 gRoute119WaterTileData[]; -extern struct WildPokemonHeader gWildMonHeaders[]; -extern struct Pokemon gEnemyParty[6]; -extern struct Pokemon gPlayerParty[6]; extern u16 gScriptResult; extern struct WildPokemon gWildFeebasRoute119Data; extern u8 Event_RepelWoreOff[]; @@ -67,7 +2927,7 @@ static u16 GetRoute119WaterTileNum(s16 x, s16 y, u8 section) u16 yMin = gRoute119WaterTileData[section * 3 + 0]; u16 yMax = gRoute119WaterTileData[section * 3 + 1]; u16 tileNum = gRoute119WaterTileData[section * 3 + 2]; - + for (yCur = yMin; yCur <= yMax; yCur++) { for (xCur = 0; xCur < gMapHeader.mapData->width; xCur++) @@ -97,7 +2957,7 @@ static bool8 CheckFeebas(void) GetXYCoordsOneStepInFrontOfPlayer(&x, &y); x -= 7; y -= 7; - + #ifdef NONMATCHING if (y >= gRoute119WaterTileData[3 * 1 + 0] && y <= gRoute119WaterTileData[3 * 1 + 1]) route119section = 1; @@ -112,9 +2972,10 @@ static bool8 CheckFeebas(void) route119section = 2; } #endif - + if (Random() % 100 > 49) //50% chance of encountering Feebas return FALSE; + FeebasSeedRng(gSaveBlock1.easyChatPairs[0].unk2); for (i = 0; i != NUM_FEEBAS_SPOTS;) { @@ -186,7 +3047,7 @@ static u8 ChooseWildMonIndex_Water(void) if (rand >= 90 && rand < 95) //5% chance return 2; if (rand >= 95 && rand < 99) //4% chance - return 3; + return 3; else //1% chance return 4; } @@ -235,7 +3096,7 @@ static u8 ChooseWildMonIndex_Fishing(u8 rod) return wildMonIndex; } -static u8 ChooseWildMonLevel(struct WildPokemon *wildPokemon) +static u8 ChooseWildMonLevel(const struct WildPokemon *wildPokemon) { u8 min; u8 max; @@ -438,12 +3299,12 @@ bool8 StandardWildEncounter(u16 a, u16 b) if (DoWildEncounterTest(gWildMonHeaders[headerNum].landMonsInfo->encounterRate, 0) == TRUE) { - if (sub_81344CC() == TRUE) + if (TryStartRoamerEncounter() == TRUE) { roamer = &gSaveBlock1.roamer; if (RepelCheck(roamer->level)) { - sub_8081A5C(); + StartBattle_Roamer(); return 1; } } @@ -472,12 +3333,12 @@ bool8 StandardWildEncounter(u16 a, u16 b) if (DoWildEncounterTest(gWildMonHeaders[headerNum].waterMonsInfo->encounterRate, 0) == TRUE) { - if (sub_81344CC() == TRUE) + if (TryStartRoamerEncounter() == TRUE) { roamer = &gSaveBlock1.roamer; if (RepelCheck(roamer->level)) { - sub_8081A5C(); + StartBattle_Roamer(); return 1; } } @@ -540,9 +3401,9 @@ bool8 SweetScentWildEncounter(void) wildPokemonInfo = gWildMonHeaders[headerNum].landMonsInfo; if (wildPokemonInfo == NULL) return FALSE; - if (sub_81344CC() == TRUE) + if (TryStartRoamerEncounter() == TRUE) { - sub_8081A5C(); + StartBattle_Roamer(); return TRUE; } if (DoMassOutbreakEncounterTest() == TRUE) @@ -557,9 +3418,9 @@ bool8 SweetScentWildEncounter(void) wildPokemonInfo = gWildMonHeaders[headerNum].waterMonsInfo; if (wildPokemonInfo == NULL) return FALSE; - if (sub_81344CC() == TRUE) + if (TryStartRoamerEncounter() == TRUE) { - sub_8081A5C(); + StartBattle_Roamer(); return TRUE; } GenerateWildMon(wildPokemonInfo, 1, FALSE); @@ -597,7 +3458,7 @@ void FishingWildEncounter(u8 rod) gWildMonHeaders[GetCurrentMapWildMonHeader()].fishingMonsInfo, rod); } - sav12_xor_increment(12); + IncrementGameStat(12); sub_80BEA50(species); CheckForSafariZoneAndProceed(); } |