Support for Battle Engine and Pokémon Expansion (#1)

* Changed comment method to avoid conflict with Pokemon Expansion.

* Changes the way level up moves are read if it detects either Battle Engine or Pokémon Expansion.

* Support for Battle Engine's spit icon.
This commit is contained in:
Eduardo Quezada D'Ottone 2020-11-08 10:53:52 -03:00 committed by GitHub
parent abf5d238c2
commit 38f36955fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,6 +40,9 @@
#include "constants/party_menu.h"
#include "constants/rgb.h"
#include "constants/songs.h"
#ifdef BATTLE_ENGINE
#include "battle_util.h"
#endif
enum
{
@ -193,7 +196,9 @@ struct PokedexView
u8 typeIconSpriteIds[2]; //HGSS_Ui
u16 moveSelected; //HGSS_Ui
u8 moveMax; //HGSS_Ui
// u8 splitIconSpriteId; //HGSS_Ui Physical/Special Split from BE
#ifdef BATTLE_ENGINE
u8 splitIconSpriteId; //HGSS_Ui Physical/Special Split from BE
#endif
u8 numEggMoves;
u8 numLevelUpMoves;
u8 numTMHMMoves;
@ -343,61 +348,64 @@ static void PrintMonStatsToggle(u8 taskId);
static void PrintInfoScreenTextWhite(const u8* str, u8 left, u8 top);
static void PrintInfoScreenTextSmall(const u8* str, u8 left, u8 top);
static void PrintInfoScreenTextSmallWhite(const u8* str, u8 left, u8 top);
// static u8 ShowSplitIcon(u32 split); //Physical/Special Split from BE
// static void DestroySplitIcon(void); //Physical/Special Split from BE
#ifdef BATTLE_ENGINE
static u8 ShowSplitIcon(u32 split); //Physical/Special Split from BE
static void DestroySplitIcon(void); //Physical/Special Split from BE
//Physical/Special Split from BE
// #define TAG_SPLIT_ICONS 30004
// static const u16 sSplitIcons_Pal[] = INCBIN_U16("graphics/interface/split_icons.gbapal");
// static const u32 sSplitIcons_Gfx[] = INCBIN_U32("graphics/interface/split_icons.4bpp.lz");
// static const struct OamData sOamData_SplitIcons =
// {
// .size = SPRITE_SIZE(16x16),
// .shape = SPRITE_SHAPE(16x16),
// .priority = 0,
// };
// static const struct CompressedSpriteSheet sSpriteSheet_SplitIcons =
// {
// .data = sSplitIcons_Gfx,
// .size = 16*16*3/2,
// .tag = TAG_SPLIT_ICONS,
// };
// static const struct SpritePalette sSpritePal_SplitIcons =
// {
// .data = sSplitIcons_Pal,
// .tag = TAG_SPLIT_ICONS
// };
// static const union AnimCmd sSpriteAnim_SplitIcon0[] =
// {
// ANIMCMD_FRAME(0, 0),
// ANIMCMD_END
// };
// static const union AnimCmd sSpriteAnim_SplitIcon1[] =
// {
// ANIMCMD_FRAME(4, 0),
// ANIMCMD_END
// };
// static const union AnimCmd sSpriteAnim_SplitIcon2[] =
// {
// ANIMCMD_FRAME(8, 0),
// ANIMCMD_END
// };
// static const union AnimCmd *const sSpriteAnimTable_SplitIcons[] =
// {
// sSpriteAnim_SplitIcon0,
// sSpriteAnim_SplitIcon1,
// sSpriteAnim_SplitIcon2,
// };
// static const struct SpriteTemplate sSpriteTemplate_SplitIcons =
// {
// .tileTag = TAG_SPLIT_ICONS,
// .paletteTag = TAG_SPLIT_ICONS,
// .oam = &sOamData_SplitIcons,
// .anims = sSpriteAnimTable_SplitIcons,
// .images = NULL,
// .affineAnims = gDummySpriteAffineAnimTable,
// .callback = SpriteCallbackDummy
// };
#define TAG_SPLIT_ICONS 30004
static const u16 sSplitIcons_Pal[] = INCBIN_U16("graphics/interface/split_icons.gbapal");
static const u32 sSplitIcons_Gfx[] = INCBIN_U32("graphics/interface/split_icons.4bpp.lz");
static const struct OamData sOamData_SplitIcons =
{
.size = SPRITE_SIZE(16x16),
.shape = SPRITE_SHAPE(16x16),
.priority = 0,
};
static const struct CompressedSpriteSheet sSpriteSheet_SplitIcons =
{
.data = sSplitIcons_Gfx,
.size = 16*16*3/2,
.tag = TAG_SPLIT_ICONS,
};
static const struct SpritePalette sSpritePal_SplitIcons =
{
.data = sSplitIcons_Pal,
.tag = TAG_SPLIT_ICONS
};
static const union AnimCmd sSpriteAnim_SplitIcon0[] =
{
ANIMCMD_FRAME(0, 0),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_SplitIcon1[] =
{
ANIMCMD_FRAME(4, 0),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_SplitIcon2[] =
{
ANIMCMD_FRAME(8, 0),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_SplitIcons[] =
{
sSpriteAnim_SplitIcon0,
sSpriteAnim_SplitIcon1,
sSpriteAnim_SplitIcon2,
};
static const struct SpriteTemplate sSpriteTemplate_SplitIcons =
{
.tileTag = TAG_SPLIT_ICONS,
.paletteTag = TAG_SPLIT_ICONS,
.oam = &sOamData_SplitIcons,
.anims = sSpriteAnimTable_SplitIcons,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
#endif
// const rom data
@ -3554,61 +3562,63 @@ static void Task_HandleInfoScreenInput(u8 taskId)
PlaySE(SE_PC_OFF);
return;
}
// if (JOY_NEW(A_BUTTON))
// {
// switch (sPokedexView->selectedScreen)
// {
// case AREA_SCREEN:
// BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB_BLACK);
// sPokedexView->screenSwitchState = 1;
// gTasks[taskId].func = Task_SwitchScreensFromInfoScreen;
// PlaySE(SE_PIN);
// break;
// case CRY_SCREEN:
// BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK);
// sPokedexView->screenSwitchState = 2;
// gTasks[taskId].func = Task_SwitchScreensFromInfoScreen;
// PlaySE(SE_PIN);
// break;
// case SIZE_SCREEN:
// if (!sPokedexListItem->owned)
// {
// PlaySE(SE_FAILURE);
// }
// else
// {
// BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK);
// sPokedexView->screenSwitchState = 3;
// gTasks[taskId].func = Task_SwitchScreensFromInfoScreen;
// PlaySE(SE_PIN);
// }
// break;
// case CANCEL_SCREEN:
// BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
// gTasks[taskId].func = Task_ExitInfoScreen;
// PlaySE(SE_PC_OFF);
// break;
// }
// return;
// }
// if ((JOY_NEW(DPAD_LEFT)
// || (JOY_NEW(L_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
// && sPokedexView->selectedScreen > 0)
// {
// sPokedexView->selectedScreen--;
// HighlightScreenSelectBarItem(sPokedexView->selectedScreen, 0xD);
// PlaySE(SE_DEX_PAGE);
// return;
// }
// if ((JOY_NEW(DPAD_RIGHT)
// || (JOY_NEW(R_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
// && sPokedexView->selectedScreen < CANCEL_SCREEN)
// {
// sPokedexView->selectedScreen++;
// HighlightScreenSelectBarItem(sPokedexView->selectedScreen, 0xD);
// PlaySE(SE_DEX_PAGE);
// return;
// }
/*
if (JOY_NEW(A_BUTTON))
{
switch (sPokedexView->selectedScreen)
{
case AREA_SCREEN:
BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB_BLACK);
sPokedexView->screenSwitchState = 1;
gTasks[taskId].func = Task_SwitchScreensFromInfoScreen;
PlaySE(SE_PIN);
break;
case CRY_SCREEN:
BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK);
sPokedexView->screenSwitchState = 2;
gTasks[taskId].func = Task_SwitchScreensFromInfoScreen;
PlaySE(SE_PIN);
break;
case SIZE_SCREEN:
if (!sPokedexListItem->owned)
{
PlaySE(SE_FAILURE);
}
else
{
BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK);
sPokedexView->screenSwitchState = 3;
gTasks[taskId].func = Task_SwitchScreensFromInfoScreen;
PlaySE(SE_PIN);
}
break;
case CANCEL_SCREEN:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
gTasks[taskId].func = Task_ExitInfoScreen;
PlaySE(SE_PC_OFF);
break;
}
return;
}
if (((JOY_NEW(DPAD_LEFT))
|| ((JOY_NEW(L_BUTTON)) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
&& sPokedexView->selectedScreen > 0)
{
sPokedexView->selectedScreen--;
HighlightScreenSelectBarItem(sPokedexView->selectedScreen, 0xD);
PlaySE(SE_DEX_PAGE);
return;
}
if (((JOY_NEW(DPAD_RIGHT))
|| ((JOY_NEW(R_BUTTON)) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR))
&& sPokedexView->selectedScreen < CANCEL_SCREEN)
{
sPokedexView->selectedScreen++;
HighlightScreenSelectBarItem(sPokedexView->selectedScreen, 0xD);
PlaySE(SE_DEX_PAGE);
return;
}
*/
if ((JOY_NEW(DPAD_RIGHT) || (JOY_NEW(R_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)))
{
@ -4963,13 +4973,23 @@ static u16 CreateSizeScreenTrainerPic(u16 species, s16 x, s16 y, s8 paletteSlot)
bool8 SpeciesCanLearnLvlUpMove(u16 species, u16 move) //Move search PokedexPlus HGSS_Ui
{
u16 j;
for (j = 0; j < MAX_LEVEL_UP_MOVES && gLevelUpLearnsets[species][j] != LEVEL_UP_END; j++)
{
if (move == (gLevelUpLearnsets[species][j] & LEVEL_UP_MOVE_ID))
#if defined (BATTLE_ENGINE) || defined (POKEMON_EXPANSION)
for (j = 0; j < MAX_LEVEL_UP_MOVES && gLevelUpLearnsets[species][j].move != LEVEL_UP_END; j++)
{
return TRUE;
if (move == (gLevelUpLearnsets[species][j].move & LEVEL_UP_MOVE_ID))
{
return TRUE;
}
}
}
#else
for (j = 0; j < MAX_LEVEL_UP_MOVES && gLevelUpLearnsets[species][j] != LEVEL_UP_END; j++)
{
if (move == (gLevelUpLearnsets[species][j] & LEVEL_UP_MOVE_ID))
{
return TRUE;
}
}
#endif
return FALSE;
}
@ -6064,10 +6084,12 @@ static void Task_LoadStatsScreen(u8 taskId)
sPokedexView->typeIconSpriteIds[0] = 0xFF;
sPokedexView->typeIconSpriteIds[1] = 0xFF;
CreateTypeIconSprites();
// sMonSummaryScreen->splitIconSpriteId = 0xFF; //Physical/Special Split from BE
// LoadCompressedPalette(gMoveTypes_Pal, 0x1D0, 0x60); //Physical/Special Split from BE
// LoadCompressedSpriteSheet(&sSpriteSheet_SplitIcons); //Physical/Special Split from BE
// LoadSpritePalette(&sSpritePal_SplitIcons); //Physical/Special Split from BE
#ifdef BATTLE_ENGINE
sPokedexView->splitIconSpriteId = 0xFF; //Physical/Special Split from BE
LoadCompressedPalette(gMoveTypes_Pal, 0x1D0, 0x60); //Physical/Special Split from BE
LoadCompressedSpriteSheet(&sSpriteSheet_SplitIcons); //Physical/Special Split from BE
LoadSpritePalette(&sSpritePal_SplitIcons); //Physical/Special Split from BE
#endif
gMain.state++;
break;
case 4:
@ -6316,13 +6338,18 @@ static void PrintMoveNameAndInfo(u8 taskId, bool8 toggle)
move = sStatsMovesLevelUp[sPokedexView->moveSelected - numEggMoves];
StringCopy(gStringVar3, gMoveNames[move]);
StringCopy(gStringVar4, gMoveDescriptionPointers[(move - 1)]);
//Calculate level of the move
while (((gLevelUpLearnsets[species][(selected-numEggMoves)] & LEVEL_UP_MOVE_LV) != (level << 9)) && level < 0xFF)
{
level++;
if (gLevelUpLearnsets[species][(selected-numEggMoves)] == LEVEL_UP_END)
level = 0xFF;
}
#if defined (BATTLE_ENGINE) || defined (POKEMON_EXPANSION)
level = gLevelUpLearnsets[species][(selected-numEggMoves)].level;
#else
//Calculate level of the move
while (((gLevelUpLearnsets[species][(selected-numEggMoves)] & LEVEL_UP_MOVE_LV) != (level << 9)) && level < 0xFF)
{
level++;
if (gLevelUpLearnsets[species][(selected-numEggMoves)] == LEVEL_UP_END)
level = 0xFF;
}
#endif
ConvertIntToDecimalStringN(gStringVar1, level, STR_CONV_MODE_LEFT_ALIGN, 3); //Move learn lvl
PrintInfoScreenTextSmall(gText_Stats_MoveLevel, moves_x + 113, moves_y + 3); //Level text
PrintInfoScreenTextSmall(gStringVar1, moves_x + 113, moves_y + 14); //Print level
@ -6382,6 +6409,11 @@ static void PrintMoveNameAndInfo(u8 taskId, bool8 toggle)
else
ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[move].power, STR_CONV_MODE_RIGHT_ALIGN, 3);
PrintInfoScreenTextSmall(gStringVar1, moves_x + 48, moves_y + 64);
//Physical/Special Split from BE
#ifdef BATTLE_ENGINE
DestroySplitIcon();
ShowSplitIcon(GetBattleMoveSplit(move));
#endif
//Accuracy
PrintInfoScreenTextSmall(gText_Accuracy2, moves_x + 69, moves_y + 64);
if (gBattleMoves[move].accuracy == 0)
@ -6392,6 +6424,10 @@ static void PrintMoveNameAndInfo(u8 taskId, bool8 toggle)
}
else
{
#ifdef BATTLE_ENGINE
DestroySplitIcon();
gSprites[sPokedexView->splitIconSpriteId].invisible = TRUE;
#endif
//Appeal
PrintInfoScreenTextSmall(gText_Appeal, moves_x + 3, moves_y + 64);
contest_appeal = 0;
@ -6436,11 +6472,6 @@ static void PrintMoveNameAndInfo(u8 taskId, bool8 toggle)
SetTypeIconPosAndPal(NUMBER_OF_MON_TYPES + gContestMoves[move].contestCategory, moves_x + 50, moves_y+1, 1);
SetSpriteInvisibility(0, TRUE);
}
//Physical/Special Split from BE
// DestroySplitIcon();
// ShowSplitIcon(GetBattleMoveSplit(move));
}
// u32 value is re-used, but passed as a bool that's TRUE if national dex is enabled
static void PrintMonStats(u8 taskId, u32 num, u32 value, u32 owned, u32 newEntry) //HGSS_Ui
@ -6834,20 +6865,21 @@ static void Task_ExitStatsScreen(u8 taskId)
}
//Physical/Special Split from BE
// static u8 ShowSplitIcon(u32 split)
// {
// if (sPokedexListItem->splitIconSpriteId == 0xFF)
// sPokedexListItem->splitIconSpriteId = CreateSprite(&sSpriteTemplate_SplitIcons, 48, 129, 0);
#ifdef BATTLE_ENGINE
static u8 ShowSplitIcon(u32 split)
{
if (sPokedexView->splitIconSpriteId == 0xFF)
sPokedexView->splitIconSpriteId = CreateSprite(&sSpriteTemplate_SplitIcons, 139, 90, 0);
// gSprites[sPokedexListItem->splitIconSpriteId].invisible = FALSE;
// StartSpriteAnim(&gSprites[sPokedexListItem->splitIconSpriteId], split);
// return sPokedexListItem->splitIconSpriteId;
// }
// static void DestroySplitIcon(void)
// {
// if (sPokedexListItem->splitIconSpriteId != 0xFF)
// DestroySprite(&gSprites[sPokedexListItem->splitIconSpriteId]);
// sPokedexListItem->splitIconSpriteId = 0xFF;
// }
gSprites[sPokedexView->splitIconSpriteId].invisible = FALSE;
StartSpriteAnim(&gSprites[sPokedexView->splitIconSpriteId], split);
return sPokedexView->splitIconSpriteId;
}
static void DestroySplitIcon(void)
{
if (sPokedexView->splitIconSpriteId != 0xFF)
DestroySprite(&gSprites[sPokedexView->splitIconSpriteId]);
sPokedexView->splitIconSpriteId = 0xFF;
}
#endif