From f1f4082f62c53196ac1cdb512fe1dafdbf8946a0 Mon Sep 17 00:00:00 2001 From: TheXaman <48356183+TheXaman@users.noreply.github.com> Date: Mon, 13 Dec 2021 19:24:19 +0100 Subject: [PATCH] added footprints --- include/constants/pokemon_debug.h | 3 ++- include/pokedex.h | 4 +++ src/pokemon_debug.c | 44 +++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/include/constants/pokemon_debug.h b/include/constants/pokemon_debug.h index e9e1a58a3..26d757fe3 100644 --- a/include/constants/pokemon_debug.h +++ b/include/constants/pokemon_debug.h @@ -28,7 +28,8 @@ #define WIN_INSTRUCTIONS 1 #define WIN_BOTTOM_LEFT 2 #define WIN_BOTTOM_RIGHT 3 -#define WIN_END 4 +#define WIN_FOOTPRINT 4 +#define WIN_END 5 //Battle backgrounds #define MAP_BATTLE_SCENE_NORMAL 0 diff --git a/include/pokedex.h b/include/pokedex.h index 49063f6b1..703b9ab8d 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -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, diff --git a/src/pokemon_debug.c b/src/pokemon_debug.c index 9f0135be1..a2438453f 100644 --- a/src/pokemon_debug.c +++ b/src/pokemon_debug.c @@ -21,6 +21,7 @@ #include "overworld.h" #include "palette.h" #include "palette_util.h" +#include "pokedex.h" #include "pokemon.h" #include "pokemon_animation.h" #include "pokemon_debug.h" @@ -136,6 +137,16 @@ static const struct WindowTemplate sPokemonDebugWindowTemplate[] = .paletteNum = 0xF, .baseBlock = 1 + 30 + 60 + 30 }, + [WIN_FOOTPRINT] = + { + .bg = 0, + .tilemapLeft = 27, + .tilemapTop = 14, + .width = 2, + .height = 2, + .paletteNum = 0xF, + .baseBlock = 1 + 30 + 60 + 30 + 150, + }, DUMMY_WIN_TEMPLATE, }; @@ -750,6 +761,31 @@ static void LoadAndCreateEnemyShadowSpriteCustom(struct PokemonDebugMenu *data, gSprites[data->frontShadowSpriteId].invisible = FALSE; } +//Tile functions (footprints) +static void DrawFootprintCustom(u8 windowId, u16 species) +{ + u8 footprint[32 * 4] = {0}; + const u8 * footprintGfx = gMonFootprintTable[species]; + u32 i, j, tileIdx = 0; + + if (footprintGfx != NULL) + { + for (i = 0; i < 32; i++) + { + u8 tile = footprintGfx[i]; + for (j = 0; j < 4; j++) + { + u8 value = ((tile >> (2 * j)) & 1 ? 2 : 0); + if (tile & (2 << (2 * j))) + value |= 0x20; + footprint[tileIdx] = value; + tileIdx++; + } + } + } + CopyToWindowPixelBuffer(windowId, footprint, sizeof(footprint), 0); +} + //Battle background functions static void LoadBattleBg(u8 battleBgType, u8 battleTerrain) { @@ -1050,6 +1086,10 @@ void CB2_Debug_Pokemon(void) //BattleNg Name PrintBattleBgName(taskId); + //Footprint + DrawFootprintCustom(WIN_FOOTPRINT, species); + CopyWindowToVram(WIN_FOOTPRINT, COPYWIN_GFX); + gMain.state++; break; case 4: @@ -1406,6 +1446,10 @@ static void ReloadPokemonSprites(struct PokemonDebugMenu *data) //Arrow invisibility SetArrowInvisibility(data); + + //Footprint + DrawFootprintCustom(WIN_FOOTPRINT, species); + CopyWindowToVram(WIN_FOOTPRINT, COPYWIN_GFX); } static void Exit_Debug_Pokemon(u8 taskId)