Merge pull request #1965 from TheXaman/pokemon_expansion_debug

Pokemon expansion debug
This commit is contained in:
Eduardo Quezada D'Ottone 2021-12-18 13:08:37 -03:00 committed by GitHub
commit 9adbf3350e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 2020 additions and 5 deletions

View File

@ -1,6 +1,17 @@
#ifndef GUARD_BATTLE_BG_H
#define GUARD_BATTLE_BG_H
#if P_ENABLE_DEBUG == TRUE
struct BattleBackground
{
const void *tileset;
const void *tilemap;
const void *entryTileset;
const void *entryTilemap;
const void *palette;
};
#endif
void BattleInitBgsAndWindows(void);
void InitBattleBgsVideo(void);
void LoadBattleMenuWindowGfx(void);

View File

@ -18,6 +18,8 @@
#define P_UPDATED_EGG_GROUPS GEN_8 // Since Gen 8, certain Pokémon have gained new egg groups.
#define P_SHEDINJA_BALL GEN_8 // Since Gen 4, Shedinja requires a Poké Ball for its evolution. In Gen 3, Shedinja inherits Nincada's Ball.
#define P_ENABLE_DEBUG TRUE // Enables a debug menu for pokemon sprites and icons, accessed by pressing SELECT in the summary screen.
#ifndef ITEM_EXPANSION
//Item Definitions for gEvolutionTable

View File

@ -0,0 +1,53 @@
#ifndef GUARD_CONSTANTS_POKEMON_DEBUG_H
#define GUARD_CONSTANTS_POKEMON_DEBUG_H
//Defines
#define DEBUG_MON_BACK_X 62
#define DEBUG_MON_BACK_Y 80
#define DEBUG_ICON_X 220
#define DEBUG_ICON_Y 140
#define DEBUG_MON_SHINY 0
#define DEBUG_MON_NORMAL 9
#define MODIFY_DIGITS_MAX 4
#define MODIFY_DIGITS_ARROW_X 129
#define MODIFY_DIGITS_ARROW1_Y 94
#define MODIFY_DIGITS_ARROW2_Y 113
#define OPTIONS_ARROW_1_X 4
#define OPTIONS_ARROW_2_X 236
#define OPTIONS_ARROW_Y 119
#define GENDER_MALE 0
#define GENDER_FEMALE 1
#define MON_PIC_BACK 0
#define MON_PIC_FRONT 1
//Sprite offset
#define MAX_Y_OFFSET 20
//Windows
#define WIN_NAME_NUMBERS 0
#define WIN_INSTRUCTIONS 1
#define WIN_BOTTOM_LEFT 2
#define WIN_BOTTOM_RIGHT 3
#define WIN_FOOTPRINT 4
#define WIN_END 5
//Battle backgrounds
#define MAP_BATTLE_SCENE_NORMAL 0
#define MAP_BATTLE_SCENE_GYM 1
#define MAP_BATTLE_SCENE_MAGMA 2
#define MAP_BATTLE_SCENE_AQUA 3
#define MAP_BATTLE_SCENE_SIDNEY 4
#define MAP_BATTLE_SCENE_PHOEBE 5
#define MAP_BATTLE_SCENE_GLACIA 6
#define MAP_BATTLE_SCENE_DRAKE 7
#define MAP_BATTLE_SCENE_FRONTIER 8
#define MAP_BATTLE_SCENE_LEADER 9
#define MAP_BATTLE_SCENE_WALLACE 10
#define MAP_BATTLE_SCENE_GROUDON 11
#define MAP_BATTLE_SCENE_KYOGRE 12
#define MAP_BATTLE_SCENE_RAYQUAZA 13
#endif // GUARD_CONSTANTS_POKEMON_DEBUG_H

View File

@ -21,6 +21,7 @@ void DecompressPicFromTable(const struct CompressedSpriteSheet *src, void* buffe
void DecompressPicFromTableGender(void* buffer, s32 species, u32 personality);
void HandleLoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality);
void HandleLoadSpecialPokePicCustom(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFemale);
void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFrontPic);

View File

@ -4,6 +4,10 @@
extern u8 gUnusedPokedexU8;
extern void (*gPokedexVBlankCB)(void);
#if P_ENABLE_DEBUG == TRUE
extern const u8 *const gMonFootprintTable[];
#endif
enum
{
DEX_MODE_HOENN,

View File

@ -8,6 +8,7 @@
#include "constants/map_groups.h"
#define GET_BASE_SPECIES_ID(speciesId) (GetFormSpeciesId(speciesId, 0))
#define FORM_SPECIES_END (0xffff)
struct PokemonSubstruct0
{
@ -302,6 +303,7 @@ extern const u8 gStatStageRatios[MAX_STAT_STAGE + 1][2];
extern const u16 gLinkPlayerFacilityClasses[];
extern const struct SpriteTemplate gBattlerSpriteTemplates[];
extern const s8 gNatureStatTable[][5];
extern const u16 *const gFormSpeciesIdTables[NUM_SPECIES];
void ZeroBoxMonData(struct BoxPokemon *boxMon);
void ZeroMonData(struct Pokemon *mon);

73
include/pokemon_debug.h Normal file
View File

@ -0,0 +1,73 @@
#ifndef GUARD_POKEMON_DEBUG_H
#define GUARD_POKEMON_DEBUG_H
#include "constants/pokemon_debug.h"
//Structs
struct PokemonDebugModifyArrows
{
u8 arrowSpriteId[2];
u16 minValue;
u16 maxValue;
int currValue;
u8 currentDigit;
u8 maxDigits;
u8 charDigits[MODIFY_DIGITS_MAX];
void *modifiedValPtr;
u8 typeOfVal;
};
struct PokemonDebugOptionArrows
{
u8 arrowSpriteId[1];
u8 currentDigit;
};
struct PokemonDebugYPosModifiyArrows
{
u8 arrowSpriteId[1];
u8 currentDigit;
};
struct PokemonSpriteConstValues
{
u8 backPicCoords;
u8 frontPicCoords;
u8 frontElevation;
};
struct PokemonSpriteOffsets
{
s8 offset_back_picCoords;
s8 offset_front_picCoords;
s8 offset_front_elevation;
};
struct PokemonDebugMenu
{
u16 currentmonId;
u8 currentmonWindowId;
u8 InstructionsWindowId;
u8 frontspriteId;
u8 backspriteId;
u8 iconspriteId;
u8 frontShadowSpriteId;
bool8 isShiny;
bool8 isFemale;
struct PokemonDebugModifyArrows modifyArrows;
struct PokemonDebugOptionArrows optionArrows;
struct PokemonDebugYPosModifiyArrows yPosModifyArrows;
struct PokemonSpriteConstValues constSpriteValues;
struct PokemonSpriteOffsets offsetsSpriteValues;
u8 animIdBack;
u8 animIdFront;
u8 battleBgType;
u8 battleTerrain;
u8 currentSubmenu;
u8 submenuYpos[3];
};
void CB2_Debug_Pokemon(void);
#endif // GUARD_POKEMON_DEBUG_H

View File

@ -21,6 +21,7 @@ u8 CreateMonIconNoPersonality(u16 species, void (*callback)(struct Sprite *), s1
void FreeMonIconPalette(u16 species);
void FreeAndDestroyMonIconSprite(struct Sprite *sprite);
u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality);
u8 CreateMonIconCustom(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality, bool8 isFemale, bool8 isShiny);
u8 UpdateMonIconFrame(struct Sprite *sprite);
void LoadMonIconPalette(u16 species);
void SpriteCB_MonIcon(struct Sprite *sprite);

View File

@ -1,6 +1,9 @@
#ifndef GUARD_RESET_RTC_SCREEN_H
#define GUARD_RESET_RTC_SCREEN_H
extern const struct SpritePalette sSpritePalette_Arrow;
extern const struct SpriteTemplate sSpriteTemplate_Arrow;
void CB2_InitResetRtcScreen(void);
#endif // GUARD_RESET_RTC_SCREEN_H

View File

@ -329,6 +329,7 @@ SECTIONS {
src/gym_leader_rematch.o(.text);
src/battle_transition_frontier.o(.text);
src/international_string_util.o(.text);
src/pokemon_debug.o(.text);
} =0
script_data :
@ -689,6 +690,7 @@ SECTIONS {
data/mystery_gift.o(.rodata);
src/m4a_tables.o(.rodata);
data/sound_data.o(.rodata);
src/pokemon_debug.o(.rodata);
} =0
song_data :

View File

@ -35,7 +35,11 @@ static void CreateBattlerTrace(struct Task *task, u8 taskId);
EWRAM_DATA static union AffineAnimCmd *sAnimTaskAffineAnim = NULL;
#if P_ENABLE_DEBUG == TRUE
const struct UCoords8 sBattlerCoords[][MAX_BATTLERS_COUNT] =
#else
static const struct UCoords8 sBattlerCoords[][MAX_BATTLERS_COUNT] =
#endif
{
{ // Single battle
{ 72, 80 },
@ -60,7 +64,11 @@ const struct MonCoords gCastformFrontSpriteCoords[NUM_CASTFORM_FORMS] =
[CASTFORM_ICE] = { .size = MON_COORDS_SIZE(64, 48), .y_offset = 8 },
};
#if P_ENABLE_DEBUG == TRUE
const u8 sCastformElevations[NUM_CASTFORM_FORMS] =
#else
static const u8 sCastformElevations[NUM_CASTFORM_FORMS] =
#endif
{
[CASTFORM_NORMAL] = 13,
[CASTFORM_FIRE] = 14,

View File

@ -24,6 +24,7 @@
#include "constants/songs.h"
#include "constants/trainers.h"
#if !P_ENABLE_DEBUG
struct BattleBackground
{
const void *tileset;
@ -32,6 +33,7 @@ struct BattleBackground
const void *entryTilemap;
const void *palette;
};
#endif
// .rodata
static const u16 sUnrefArray[] = {0x0300, 0x0000}; //OamData?
@ -598,7 +600,11 @@ const struct WindowTemplate * const gBattleWindowTemplates[] =
[B_WIN_TYPE_ARENA] = gBattleArenaWindowTemplates,
};
#if P_ENABLE_DEBUG == TRUE
const struct BattleBackground sBattleTerrainTable[] =
#else
static const struct BattleBackground sBattleTerrainTable[] =
#endif
{
[BATTLE_TERRAIN_GRASS] =
{

View File

@ -77,7 +77,11 @@ static const struct CompressedSpriteSheet sSpriteSheets_HealthBar[MAX_BATTLERS_C
{gBlankGfxCompressed, 0x0120, TAG_HEALTHBAR_OPPONENT2_TILE}
};
#if P_ENABLE_DEBUG == TRUE
const struct SpritePalette sSpritePalettes_HealthBoxHealthBar[2] =
#else
static const struct SpritePalette sSpritePalettes_HealthBoxHealthBar[2] =
#endif
{
{gBattleInterface_BallStatusBarPal, TAG_HEALTHBOX_PAL},
{gBattleInterface_BallDisplayPal, TAG_HEALTHBAR_PAL}

View File

@ -1,5 +1,3 @@
#define FORM_SPECIES_END (0xffff)
static const u16 sVenusaurFormSpeciesIdTable[] = {
SPECIES_VENUSAUR,
SPECIES_VENUSAUR_MEGA,

View File

@ -3,6 +3,7 @@
#include "data.h"
#include "decompress.h"
#include "pokemon.h"
#include "pokemon_debug.h"
#include "text.h"
EWRAM_DATA ALIGNED(4) u8 gDecompressionBuffer[0x4000] = {0};
@ -113,6 +114,45 @@ void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32
DrawSpindaSpots(species, personality, dest, isFrontPic);
}
#if P_ENABLE_DEBUG == TRUE
static void LoadSpecialPokePicCustom(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFrontPic, bool8 isFemale)
{
if (species == SPECIES_UNOWN)
{
u32 id = GetUnownSpeciesId(personality);
if (!isFrontPic)
LZ77UnCompWram(gMonBackPicTable[id].data, dest);
else
LZ77UnCompWram(gMonFrontPicTable[id].data, dest);
}
else if (species > NUM_SPECIES) // is species unknown? draw the ? icon
LZ77UnCompWram(gMonFrontPicTable[0].data, dest);
else if (SpeciesHasGenderDifference[species] && isFemale)
{
if (isFrontPic)
LZ77UnCompWram(gMonFrontPicTableFemale[species].data, dest);
else
LZ77UnCompWram(gMonBackPicTableFemale[species].data, dest);
}
else
LZ77UnCompWram(src->data, dest);
DrawSpindaSpots(species, personality, dest, isFrontPic);
}
void HandleLoadSpecialPokePicCustom(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFemale)
{
bool8 isFrontPic;
if (src == &gMonFrontPicTable[species])
isFrontPic = TRUE; // frontPic
else
isFrontPic = FALSE; // backPic
LoadSpecialPokePicCustom(src, dest, species, personality, isFrontPic, isFemale);
}
#endif
void Unused_LZDecompressWramIndirect(const void **src, void *dest)
{
LZ77UnCompWram(*src, dest);

View File

@ -1856,8 +1856,11 @@ const s8 gNatureStatTable[NUM_NATURES][NUM_NATURE_STATS] =
#include "data/pokemon/form_change_table_pointers.h"
// SPECIES_NONE are ignored in the following two tables, so decrement before accessing these arrays to get the right result
#if P_ENABLE_DEBUG == TRUE
const u8 sMonFrontAnimIdsTable[NUM_SPECIES - 1] =
#else
static const u8 sMonFrontAnimIdsTable[NUM_SPECIES - 1] =
#endif
{
[SPECIES_BULBASAUR - 1] = ANIM_V_JUMPS_H_JUMPS,
[SPECIES_IVYSAUR - 1] = ANIM_V_STRETCH,

1744
src/pokemon_debug.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
#include "graphics.h"
#include "mail.h"
#include "palette.h"
#include "pokemon_debug.h"
#include "pokemon_icon.h"
#include "sprite.h"
#include "data.h"
@ -22,6 +23,10 @@ struct MonIconSpriteTemplate
static u8 CreateMonIconSprite(struct MonIconSpriteTemplate *, s16, s16, u8);
static void FreeAndDestroyMonIconSprite_(struct Sprite *sprite);
#if P_ENABLE_DEBUG == TRUE
static const u8 *GetMonIconPtrCustom(u16 species, u32 personality, bool8 isFemale);
static const u8* GetMonIconTilesCustom(u16 species, bool8 isFemale);
#endif
const u8 *const gMonIconTable[] =
{
@ -2573,6 +2578,33 @@ u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u
return spriteId;
}
#if P_ENABLE_DEBUG == TRUE
u8 CreateMonIconCustom(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality, bool8 isFemale, bool8 isShiny)
{
u8 spriteId;
struct MonIconSpriteTemplate iconTemplate =
{
.oam = &sMonIconOamData,
.image = GetMonIconPtrCustom(species, personality, isFemale),
.anims = sMonIconAnims,
.affineAnims = sMonIconAffineAnims,
.callback = callback,
.paletteTag = POKE_ICON_BASE_PAL_TAG + gMonIconPaletteIndices[species],
};
if (species > NUM_SPECIES)
iconTemplate.paletteTag = POKE_ICON_BASE_PAL_TAG;
else if (SpeciesHasGenderDifference[species] && isFemale)
iconTemplate.paletteTag = POKE_ICON_BASE_PAL_TAG + gMonIconPaletteIndicesFemale[species];
spriteId = CreateMonIconSprite(&iconTemplate, x, y, subpriority);
UpdateMonIconFrame(&gSprites[spriteId]);
return spriteId;
}
#endif
u8 CreateMonIconNoPersonality(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority)
{
u8 spriteId;
@ -2644,6 +2676,13 @@ const u8 *GetMonIconPtr(u16 species, u32 personality)
return GetMonIconTiles(GetIconSpecies(species, personality), personality);
}
#if P_ENABLE_DEBUG == TRUE
static const u8 *GetMonIconPtrCustom(u16 species, u32 personality, bool8 isFemale)
{
return GetMonIconTilesCustom(GetIconSpecies(species, personality), isFemale);
}
#endif
void FreeAndDestroyMonIconSprite(struct Sprite *sprite)
{
FreeAndDestroyMonIconSprite_(sprite);
@ -2712,6 +2751,17 @@ const u8* GetMonIconTiles(u16 species, u32 personality)
}
return iconSprite;
}
#if P_ENABLE_DEBUG == TRUE
static const u8* GetMonIconTilesCustom(u16 species, bool8 isFemale)
{
const u8* iconSprite = gMonIconTable[species];
if (SpeciesHasGenderDifference[species] && isFemale)
{
iconSprite = gMonIconTableFemale[species];
}
return iconSprite;
}
#endif
void TryLoadAllMonIconPalettesAtOffset(u16 offset)
{

View File

@ -28,6 +28,7 @@
#include "palette.h"
#include "pokeball.h"
#include "pokemon.h"
#include "pokemon_debug.h"
#include "pokemon_storage_system.h"
#include "pokemon_summary_screen.h"
#include "region_map.h"
@ -1555,6 +1556,15 @@ static void Task_HandleInput(u8 taskId)
PlaySE(SE_SELECT);
BeginCloseSummaryScreen(taskId);
}
#if P_ENABLE_DEBUG == TRUE
else if (JOY_NEW(SELECT_BUTTON) && !gMain.inBattle)
{
sMonSummaryScreen->callback = CB2_Debug_Pokemon;
StopPokemonAnimations();
PlaySE(SE_SELECT);
CloseSummaryScreen(taskId);
}
#endif
}
}

View File

@ -181,7 +181,7 @@ static const struct SpriteFrameImage sPicTable_Arrow[] =
obj_frame_tiles(sArrowRight_Gfx)
};
static const struct SpritePalette sSpritePalette_Arrow =
const struct SpritePalette sSpritePalette_Arrow =
{
sArrow_Pal, PALTAG_ARROW
};
@ -217,7 +217,7 @@ static const union AnimCmd *const sAnims_Arrow[] =
[ARROW_RIGHT] = sAnim_Arrow_Right,
};
static const struct SpriteTemplate sSpriteTemplate_Arrow =
const struct SpriteTemplate sSpriteTemplate_Arrow =
{
.tileTag = TAG_NONE,
.paletteTag = PALTAG_ARROW,