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