pokeemerald/src/pokedex_area_region_map.c

70 lines
2.5 KiB
C
Raw Normal View History

2020-02-05 02:47:32 -05:00
#include "global.h"
#include "main.h"
#include "menu.h"
#include "bg.h"
#include "malloc.h"
#include "palette.h"
#include "pokedex_area_region_map.h"
static EWRAM_DATA u8 *sPokedexAreaMapBgNum = NULL;
2021-12-29 03:23:58 -05:00
static const u16 sPokedexAreaMap_Pal[] = INCBIN_U16("graphics/pokedex/region_map.gbapal");
static const u32 sPokedexAreaMap_Gfx[] = INCBIN_U32("graphics/pokedex/region_map.8bpp.lz");
static const u32 sPokedexAreaMap_Tilemap[] = INCBIN_U32("graphics/pokedex/region_map.bin.lz");
static const u32 sPokedexAreaMapAffine_Gfx[] = INCBIN_U32("graphics/pokedex/region_map_affine.8bpp.lz");
static const u32 sPokedexAreaMapAffine_Tilemap[] = INCBIN_U32("graphics/pokedex/region_map_affine.bin.lz");
2020-02-05 02:47:32 -05:00
void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *template)
{
u8 mode;
2021-11-03 20:28:43 -04:00
void * tilemap;
2021-09-24 14:30:15 -04:00
sPokedexAreaMapBgNum = Alloc(sizeof(sPokedexAreaMapBgNum));
2020-02-05 02:47:32 -05:00
mode = template->mode;
if (mode == 0)
{
SetBgAttribute(template->bg, BG_ATTR_METRIC, 0);
2020-05-14 01:37:09 -07:00
DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMap_Gfx, 0, template->offset, 0);
2021-11-03 20:28:43 -04:00
tilemap = DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMap_Tilemap, 0, 0, 1);
AddValToTilemapBuffer(tilemap, template->offset, 32, 32, FALSE); // template->offset is always 0, so this does nothing.
2020-02-05 02:47:32 -05:00
}
else
{
2021-09-24 14:30:15 -04:00
// This is never reached, only a mode of 0 is given
2020-02-05 02:47:32 -05:00
SetBgAttribute(template->bg, BG_ATTR_METRIC, 2);
2021-09-24 14:30:15 -04:00
SetBgAttribute(template->bg, BG_ATTR_TYPE, BG_TYPE_AFFINE); // This does nothing. BG_ATTR_TYPE can't be set with this function
2020-05-14 01:37:09 -07:00
DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMapAffine_Gfx, 0, template->offset, 0);
2021-11-03 20:28:43 -04:00
tilemap = DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMapAffine_Tilemap, 0, 0, 1);
AddValToTilemapBuffer(tilemap, template->offset, 64, 64, TRUE); // template->offset is always 0, so this does nothing.
2020-02-05 02:47:32 -05:00
}
2021-11-03 23:02:06 -04:00
ChangeBgX(template->bg, 0, BG_COORD_SET);
ChangeBgY(template->bg, 0, BG_COORD_SET);
2020-02-05 02:47:32 -05:00
SetBgAttribute(template->bg, BG_ATTR_PALETTEMODE, 1);
2021-12-29 03:23:58 -05:00
CpuCopy32(sPokedexAreaMap_Pal, &gPlttBufferUnfaded[0x70], sizeof(sPokedexAreaMap_Pal));
2020-02-05 02:47:32 -05:00
*sPokedexAreaMapBgNum = template->bg;
}
2021-09-24 14:30:15 -04:00
bool32 TryShowPokedexAreaMap(void)
2020-02-05 02:47:32 -05:00
{
2020-05-14 01:37:09 -07:00
if (!FreeTempTileDataBuffersIfPossible())
2020-02-05 02:47:32 -05:00
{
ShowBg(*sPokedexAreaMapBgNum);
return FALSE;
}
else
{
return TRUE;
}
}
void FreePokedexAreaMapBgNum(void)
{
2021-09-24 14:30:15 -04:00
TRY_FREE_AND_SET_NULL(sPokedexAreaMapBgNum);
2020-02-05 02:47:32 -05:00
}
2022-06-01 12:41:57 -04:00
void PokedexAreaMapChangeBgY(u32 move)
2020-02-05 02:47:32 -05:00
{
2022-06-01 12:41:57 -04:00
ChangeBgY(*sPokedexAreaMapBgNum, move * 0x100, BG_COORD_SET);
2020-02-05 02:47:32 -05:00
}