2019-01-20 18:24:35 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "gpu_regs.h"
|
2019-01-25 23:32:45 +01:00
|
|
|
#include "main.h"
|
|
|
|
#include "trainer_card.h"
|
2019-01-26 20:56:06 +01:00
|
|
|
#include "battle_anim.h"
|
2019-01-25 23:32:45 +01:00
|
|
|
#include "event_data.h"
|
|
|
|
#include "recorded_battle.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2019-01-25 23:32:45 +01:00
|
|
|
#include "sprite.h"
|
|
|
|
#include "scanline_effect.h"
|
|
|
|
#include "text_window.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "graphics.h"
|
2019-01-26 14:50:24 +01:00
|
|
|
#include "strings.h"
|
|
|
|
#include "frontier_pass.h"
|
|
|
|
#include "international_string_util.h"
|
2019-01-25 23:32:45 +01:00
|
|
|
#include "palette.h"
|
|
|
|
#include "window.h"
|
2019-01-26 14:50:24 +01:00
|
|
|
#include "decompress.h"
|
2019-01-25 23:32:45 +01:00
|
|
|
#include "menu_helpers.h"
|
|
|
|
#include "menu.h"
|
2019-01-20 18:24:35 +01:00
|
|
|
#include "bg.h"
|
2019-01-25 23:32:45 +01:00
|
|
|
#include "sound.h"
|
2019-01-26 14:50:24 +01:00
|
|
|
#include "string_util.h"
|
2019-01-25 23:32:45 +01:00
|
|
|
#include "battle_pyramid.h"
|
|
|
|
#include "overworld.h"
|
2019-01-26 14:50:24 +01:00
|
|
|
#include "math_util.h"
|
2019-01-25 23:32:45 +01:00
|
|
|
#include "constants/battle_frontier.h"
|
|
|
|
#include "constants/rgb.h"
|
|
|
|
#include "constants/region_map_sections.h"
|
|
|
|
#include "constants/songs.h"
|
2019-01-20 18:24:35 +01:00
|
|
|
|
2019-01-26 14:50:24 +01:00
|
|
|
// All windows displayed in the frontier pass.
|
|
|
|
enum
|
|
|
|
{
|
2019-01-26 22:09:24 +01:00
|
|
|
WINDOW_EARNED_SYMBOLS,
|
|
|
|
WINDOW_BATTLE_RECORD,
|
|
|
|
WINDOW_BATTLE_POINTS,
|
|
|
|
WINDOW_DESCRIPTION,
|
2021-01-19 10:03:51 +01:00
|
|
|
WINDOW_DUMMY,
|
2019-01-26 22:09:24 +01:00
|
|
|
WINDOW_COUNT
|
2019-01-26 14:50:24 +01:00
|
|
|
};
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
// Windows displayed in the facilities map view.
|
|
|
|
enum
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
MAP_WINDOW_UNUSED, // Overlaps the "Battle Frontier" title area of the map
|
2019-01-26 20:56:06 +01:00
|
|
|
MAP_WINDOW_NAME,
|
|
|
|
MAP_WINDOW_DESCRIPTION,
|
|
|
|
MAP_WINDOW_COUNT
|
|
|
|
};
|
|
|
|
|
2019-01-25 23:32:45 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CURSOR_AREA_NOTHING,
|
|
|
|
CURSOR_AREA_MAP,
|
|
|
|
CURSOR_AREA_CARD,
|
|
|
|
CURSOR_AREA_RECORD,
|
|
|
|
CURSOR_AREA_CANCEL,
|
|
|
|
CURSOR_AREA_POINTS,
|
2021-01-19 10:03:51 +01:00
|
|
|
CURSOR_AREA_EARNED_SYMBOLS, // The window containing the symbols
|
|
|
|
CURSOR_AREA_SYMBOL_TOWER,
|
|
|
|
CURSOR_AREA_SYMBOL_DOME,
|
|
|
|
CURSOR_AREA_SYMBOL_PALACE,
|
|
|
|
CURSOR_AREA_SYMBOL_ARENA,
|
|
|
|
CURSOR_AREA_SYMBOL_FACTORY,
|
|
|
|
CURSOR_AREA_SYMBOL_PIKE,
|
|
|
|
CURSOR_AREA_SYMBOL_PYRAMID,
|
|
|
|
CURSOR_AREA_COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
// Start of symbol cursor areas
|
|
|
|
#define CURSOR_AREA_SYMBOL CURSOR_AREA_SYMBOL_TOWER
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MAP_INDICATOR_RECTANGLE,
|
|
|
|
MAP_INDICATOR_SQUARE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
TAG_CURSOR,
|
|
|
|
TAG_MAP_INDICATOR,
|
|
|
|
TAG_MEDAL_SILVER,
|
|
|
|
TAG_MEDAL_GOLD,
|
|
|
|
TAG_HEAD_MALE,
|
|
|
|
TAG_HEAD_FEMALE,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Error return codes. Never read
|
|
|
|
enum {
|
|
|
|
SUCCESS,
|
|
|
|
ERR_ALREADY_DONE,
|
|
|
|
ERR_ALLOC_FAILED,
|
2019-01-25 23:32:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FrontierPassData
|
|
|
|
{
|
|
|
|
void (*callback)(void);
|
|
|
|
u16 state;
|
|
|
|
u16 battlePoints;
|
2019-01-26 14:50:24 +01:00
|
|
|
s16 cursorX;
|
|
|
|
s16 cursorY;
|
2019-01-25 23:32:45 +01:00
|
|
|
u8 cursorArea;
|
|
|
|
u8 previousCursorArea;
|
2021-01-19 10:03:51 +01:00
|
|
|
bool8 hasBattleRecord:1;
|
|
|
|
u8 areaToShow:3;
|
2019-01-25 23:32:45 +01:00
|
|
|
u8 trainerStars:4;
|
2021-01-19 10:03:51 +01:00
|
|
|
u8 facilitySymbols[NUM_FRONTIER_FACILITIES]; // 0: no symbol, 1: silver, 2: gold
|
2019-01-25 23:32:45 +01:00
|
|
|
};
|
|
|
|
|
2019-01-26 14:50:24 +01:00
|
|
|
struct FrontierPassGfx
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 14:50:24 +01:00
|
|
|
struct Sprite *cursorSprite;
|
|
|
|
struct Sprite *symbolSprites[NUM_FRONTIER_FACILITIES];
|
2021-01-19 10:03:51 +01:00
|
|
|
// These 3 tilemaps are used to overwrite the respective area when highlighted
|
|
|
|
u8 *mapAndCardZoomTilemap;
|
|
|
|
u8 *mapAndCardTilemap;
|
|
|
|
u8 *battleRecordTilemap;
|
|
|
|
bool8 zooming;
|
|
|
|
s16 scaleX;
|
|
|
|
s16 scaleY;
|
|
|
|
u8 tilemapBuff1[BG_SCREEN_SIZE * 2];
|
|
|
|
u8 tilemapBuff2[BG_SCREEN_SIZE * 2];
|
|
|
|
u8 tilemapBuff3[BG_SCREEN_SIZE / 2];
|
2019-01-25 23:32:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FrontierPassSaved
|
|
|
|
{
|
|
|
|
void (*callback)(void);
|
2019-01-26 14:50:24 +01:00
|
|
|
s16 cursorX;
|
|
|
|
s16 cursorY;
|
2019-01-25 23:32:45 +01:00
|
|
|
};
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
struct FrontierMapData
|
|
|
|
{
|
|
|
|
void (*callback)(void);
|
|
|
|
struct Sprite *cursorSprite;
|
|
|
|
struct Sprite *playerHeadSprite;
|
|
|
|
struct Sprite *mapIndicatorSprite;
|
|
|
|
u8 cursorPos;
|
|
|
|
u8 unused;
|
2021-01-19 10:03:51 +01:00
|
|
|
u8 tilemapBuff0[BG_SCREEN_SIZE * 2];
|
|
|
|
u8 tilemapBuff1[BG_SCREEN_SIZE * 2];
|
|
|
|
u8 tilemapBuff2[BG_SCREEN_SIZE * 2];
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static EWRAM_DATA struct FrontierPassData *sPassData = NULL;
|
|
|
|
static EWRAM_DATA struct FrontierPassGfx *sPassGfx = NULL;
|
|
|
|
static EWRAM_DATA struct FrontierMapData *sMapData = NULL;
|
|
|
|
static EWRAM_DATA struct FrontierPassSaved sSavedPassData = {0};
|
2019-01-25 23:32:45 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static u32 AllocateFrontierPassData(void (*callback)(void));
|
|
|
|
static void ShowFrontierMap(void (*callback)(void));
|
|
|
|
static void CB2_InitFrontierPass(void);
|
2021-01-19 10:03:51 +01:00
|
|
|
static void DrawFrontierPassBg(void);
|
2019-01-26 20:56:06 +01:00
|
|
|
static void FreeCursorAndSymbolSprites(void);
|
|
|
|
static void LoadCursorAndSymbolSprites(void);
|
|
|
|
static u32 FreeFrontierPassData(void);
|
|
|
|
static bool32 InitFrontierPass(void);
|
|
|
|
static bool32 HideFrontierPass(void);
|
2021-01-19 10:03:51 +01:00
|
|
|
static void Task_HandleFrontierPassInput(u8);
|
|
|
|
static void Task_PassAreaZoom(u8);
|
|
|
|
static void UpdateAreaHighlight(u8, u8);
|
|
|
|
static void PrintAreaDescription(u8);
|
|
|
|
static void ShowHideZoomingArea(bool8, bool8);
|
|
|
|
static void SpriteCB_PlayerHead(struct Sprite *);
|
|
|
|
|
|
|
|
static const u16 sMaleHead_Pal[] = INCBIN_U16("graphics/frontier_pass/map_heads.gbapal");
|
|
|
|
static const u16 sFemaleHead_Pal[] = INCBIN_U16("graphics/frontier_pass/map_heads_female.gbapal");
|
|
|
|
static const u32 sMapScreen_Gfx[] = INCBIN_U32("graphics/frontier_pass/map_screen.4bpp.lz");
|
|
|
|
static const u32 sCursor_Gfx[] = INCBIN_U32("graphics/frontier_pass/cursor.4bpp.lz");
|
|
|
|
static const u32 sHeads_Gfx[] = INCBIN_U32("graphics/frontier_pass/map_heads.4bpp.lz");
|
|
|
|
static const u32 sMapCursor_Gfx[] = INCBIN_U32("graphics/frontier_pass/map_cursor.4bpp.lz");
|
|
|
|
static const u32 sMapScreen_Tilemap[] = INCBIN_U32("graphics/frontier_pass/map_screen.bin.lz");
|
|
|
|
static const u32 sMapAndCard_ZoomedOut_Tilemap[] = INCBIN_U32("graphics/frontier_pass/small_map_and_card.bin.lz");
|
2021-12-28 20:54:09 +01:00
|
|
|
static const u32 sCardBall_Filled_Tilemap[] = INCBIN_U32("graphics/frontier_pass/card_ball_filled.bin"); // Unused
|
2021-01-19 10:03:51 +01:00
|
|
|
static const u32 sBattleRecord_Tilemap[] = INCBIN_U32("graphics/frontier_pass/record_frame.bin.lz");
|
|
|
|
static const u32 sMapAndCard_Zooming_Tilemap[] = INCBIN_U32("graphics/frontier_pass/small_map_and_card_affine.bin.lz");
|
|
|
|
|
2021-08-25 00:59:32 +02:00
|
|
|
static const s16 sBgAffineCoords[][2] =
|
2021-01-19 10:03:51 +01:00
|
|
|
{
|
2021-08-25 00:59:32 +02:00
|
|
|
[CURSOR_AREA_MAP - 1] = {216, 32},
|
2021-01-19 10:03:51 +01:00
|
|
|
[CURSOR_AREA_CARD - 1] = {216, 128}
|
|
|
|
};
|
2019-01-26 20:56:06 +01:00
|
|
|
|
|
|
|
static const struct BgTemplate sPassBgTemplates[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 2,
|
|
|
|
.mapBaseIndex = 31,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 30,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 2,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 2,
|
|
|
|
.charBaseIndex = 1,
|
|
|
|
.mapBaseIndex = 29,
|
|
|
|
.screenSize = 1,
|
|
|
|
.paletteMode = 1,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct BgTemplate sMapBgTemplates[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 2,
|
|
|
|
.mapBaseIndex = 31,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 30,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 2,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 29,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 2,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const struct WindowTemplate sPassWindowTemplates[WINDOW_COUNT] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
[WINDOW_EARNED_SYMBOLS] = {
|
2019-01-26 22:09:24 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 3,
|
|
|
|
.width = 12,
|
|
|
|
.height = 3,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x1,
|
|
|
|
},
|
2021-01-19 10:03:51 +01:00
|
|
|
[WINDOW_BATTLE_RECORD] = {
|
2019-01-26 22:09:24 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 10,
|
|
|
|
.width = 12,
|
|
|
|
.height = 3,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x26,
|
|
|
|
},
|
2021-01-19 10:03:51 +01:00
|
|
|
[WINDOW_BATTLE_POINTS] = {
|
2019-01-26 22:09:24 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 13,
|
|
|
|
.width = 12,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x4B,
|
|
|
|
},
|
2021-01-19 10:03:51 +01:00
|
|
|
[WINDOW_DESCRIPTION] = {
|
2019-01-26 22:09:24 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 0,
|
|
|
|
.tilemapTop = 18,
|
|
|
|
.width = 30,
|
|
|
|
.height = 3,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x7C,
|
|
|
|
},
|
|
|
|
DUMMY_WIN_TEMPLATE
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct WindowTemplate sMapWindowTemplates[] =
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
[MAP_WINDOW_UNUSED] = {
|
2019-01-26 22:09:24 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 0,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 15,
|
|
|
|
.height = 5,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x1,
|
|
|
|
},
|
2021-01-19 10:03:51 +01:00
|
|
|
[MAP_WINDOW_NAME] = {
|
2019-01-26 22:09:24 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 20,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 10,
|
|
|
|
.height = 14,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x4D,
|
|
|
|
},
|
2021-01-19 10:03:51 +01:00
|
|
|
[MAP_WINDOW_DESCRIPTION] = {
|
2019-01-26 22:09:24 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 16,
|
|
|
|
.width = 26,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0xDA,
|
|
|
|
},
|
|
|
|
DUMMY_WIN_TEMPLATE
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sTextColors[][3] =
|
|
|
|
{
|
2021-04-10 04:39:34 +02:00
|
|
|
{TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY},
|
2019-12-10 19:48:20 +01:00
|
|
|
{TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_BLUE},
|
|
|
|
{TEXT_COLOR_TRANSPARENT, TEXT_COLOR_RED, TEXT_COLOR_LIGHT_RED},
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
s16 yStart;
|
|
|
|
s16 yEnd;
|
|
|
|
s16 xStart;
|
|
|
|
s16 xEnd;
|
|
|
|
}
|
2021-01-19 10:03:51 +01:00
|
|
|
static const sPassAreasLayout[CURSOR_AREA_COUNT - 1] =
|
|
|
|
{
|
|
|
|
[CURSOR_AREA_MAP - 1] = { 28, 76, 132, 220},
|
|
|
|
[CURSOR_AREA_CARD - 1] = { 84, 132, 132, 220},
|
|
|
|
[CURSOR_AREA_RECORD - 1] = { 80, 102, 20, 108},
|
|
|
|
[CURSOR_AREA_CANCEL - 1] = { 0, 16, 152, 240},
|
|
|
|
[CURSOR_AREA_POINTS - 1] = {108, 134, 20, 108},
|
|
|
|
[CURSOR_AREA_EARNED_SYMBOLS - 1] = { 24, 48, 20, 108},
|
|
|
|
[CURSOR_AREA_SYMBOL_TOWER - 1] = { 50, 66, 20, 36},
|
|
|
|
[CURSOR_AREA_SYMBOL_DOME - 1] = { 66, 82, 32, 48},
|
|
|
|
[CURSOR_AREA_SYMBOL_PALACE - 1] = { 50, 66, 44, 60},
|
|
|
|
[CURSOR_AREA_SYMBOL_ARENA - 1] = { 66, 82, 56, 72},
|
|
|
|
[CURSOR_AREA_SYMBOL_FACTORY - 1] = { 50, 66, 68, 84},
|
|
|
|
[CURSOR_AREA_SYMBOL_PIKE - 1] = { 66, 82, 80, 96},
|
|
|
|
[CURSOR_AREA_SYMBOL_PYRAMID - 1] = { 50, 66, 92, 108},
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct CompressedSpriteSheet sCursorSpriteSheets[] =
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
{sCursor_Gfx, 0x100, TAG_CURSOR},
|
|
|
|
{sMapCursor_Gfx, 0x400, TAG_MAP_INDICATOR},
|
|
|
|
{gFrontierPassMedals_Gfx, 0x380, TAG_MEDAL_SILVER},
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct CompressedSpriteSheet sHeadsSpriteSheet[] =
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
{sHeads_Gfx, 0x100, TAG_HEAD_MALE},
|
2019-01-26 20:56:06 +01:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpritePalette sSpritePalettes[] =
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
{gFrontierPassCursor_Pal, TAG_CURSOR},
|
|
|
|
{gFrontierPassMapCursor_Pal, TAG_MAP_INDICATOR},
|
|
|
|
{gFrontierPassMedalsSilver_Pal, TAG_MEDAL_SILVER},
|
|
|
|
{gFrontierPassMedalsGold_Pal, TAG_MEDAL_GOLD},
|
|
|
|
{sMaleHead_Pal, TAG_HEAD_MALE},
|
|
|
|
{sFemaleHead_Pal, TAG_HEAD_FEMALE},
|
2019-01-26 20:56:06 +01:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd sAnim_Frame1_Unused[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd sAnim_Frame1[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd sAnim_Frame2[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(4, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd sAnim_Frame3[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(8, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd sAnim_Frame4[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(12, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd sAnim_Frame5[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(16, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd sAnim_Frame6[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(20, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd sAnim_Frame7[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(24, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd sAnim_MapIndicatorCursor_Rectangle[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 45),
|
|
|
|
ANIMCMD_FRAME(8, 45),
|
|
|
|
ANIMCMD_JUMP(0)
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd sAnim_MapIndicatorCursor_Square[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(16, 45),
|
|
|
|
ANIMCMD_FRAME(24, 45),
|
|
|
|
ANIMCMD_JUMP(0)
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
// Used both by the cursor and the map head icons
|
|
|
|
static const union AnimCmd *const sAnims_TwoFrame[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
sAnim_Frame1,
|
|
|
|
sAnim_Frame2
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd *const sAnims_Medal[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
[CURSOR_AREA_SYMBOL_TOWER - CURSOR_AREA_SYMBOL] = sAnim_Frame1,
|
|
|
|
[CURSOR_AREA_SYMBOL_DOME - CURSOR_AREA_SYMBOL] = sAnim_Frame2,
|
|
|
|
[CURSOR_AREA_SYMBOL_PALACE - CURSOR_AREA_SYMBOL] = sAnim_Frame3,
|
|
|
|
[CURSOR_AREA_SYMBOL_ARENA - CURSOR_AREA_SYMBOL] = sAnim_Frame4,
|
|
|
|
[CURSOR_AREA_SYMBOL_FACTORY - CURSOR_AREA_SYMBOL] = sAnim_Frame5,
|
|
|
|
[CURSOR_AREA_SYMBOL_PIKE - CURSOR_AREA_SYMBOL] = sAnim_Frame6,
|
|
|
|
[CURSOR_AREA_SYMBOL_PYRAMID - CURSOR_AREA_SYMBOL] = sAnim_Frame7
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AnimCmd *const sAnims_MapIndicatorCursor[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
[MAP_INDICATOR_RECTANGLE] = sAnim_MapIndicatorCursor_Rectangle,
|
|
|
|
[MAP_INDICATOR_SQUARE] = sAnim_MapIndicatorCursor_Square
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AffineAnimCmd sAffineAnim_Unused[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const union AffineAnimCmd *const sAffineAnims_Unused[] =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
sAffineAnim_Unused
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteTemplate sSpriteTemplates_Cursors[] =
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
// Triangular cursor
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
.tileTag = TAG_CURSOR,
|
|
|
|
.paletteTag = TAG_CURSOR,
|
2019-10-15 01:26:47 +02:00
|
|
|
.oam = &gOamData_AffineOff_ObjNormal_16x16,
|
2021-01-19 10:03:51 +01:00
|
|
|
.anims = sAnims_TwoFrame,
|
2019-01-26 20:56:06 +01:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
},
|
2021-01-19 10:03:51 +01:00
|
|
|
// Map indicator cursor
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
.tileTag = TAG_MAP_INDICATOR,
|
|
|
|
.paletteTag = TAG_MAP_INDICATOR,
|
2019-10-15 01:26:47 +02:00
|
|
|
.oam = &gOamData_AffineOff_ObjNormal_32x16,
|
2021-01-19 10:03:51 +01:00
|
|
|
.anims = sAnims_MapIndicatorCursor,
|
2019-01-26 20:56:06 +01:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Medal =
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
.tileTag = TAG_MEDAL_SILVER,
|
|
|
|
.paletteTag = TAG_MEDAL_SILVER,
|
2019-10-15 01:26:47 +02:00
|
|
|
.oam = &gOamData_AffineOff_ObjNormal_16x16,
|
2021-01-19 10:03:51 +01:00
|
|
|
.anims = sAnims_Medal,
|
2019-01-26 20:56:06 +01:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_PlayerHead =
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
.tileTag = TAG_HEAD_MALE,
|
|
|
|
.paletteTag = TAG_HEAD_MALE,
|
2019-10-15 01:26:47 +02:00
|
|
|
.oam = &gOamData_AffineOff_ObjNormal_16x16,
|
2021-01-19 10:03:51 +01:00
|
|
|
.anims = sAnims_TwoFrame,
|
2019-01-26 20:56:06 +01:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2021-01-19 10:03:51 +01:00
|
|
|
.callback = SpriteCB_PlayerHead,
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static const u8 *const sPassAreaDescriptions[CURSOR_AREA_COUNT + 1] =
|
|
|
|
{
|
|
|
|
[CURSOR_AREA_NOTHING] = gText_ThereIsNoBattleRecord, // NOTHING is re-used for CURSOR_AREA_RECORD when no Record is present
|
|
|
|
[CURSOR_AREA_MAP] = gText_CheckFrontierMap,
|
|
|
|
[CURSOR_AREA_CARD] = gText_CheckTrainerCard,
|
|
|
|
[CURSOR_AREA_RECORD] = gText_ViewRecordedBattle,
|
|
|
|
[CURSOR_AREA_CANCEL] = gText_PutAwayFrontierPass,
|
|
|
|
[CURSOR_AREA_POINTS] = gText_CurrentBattlePoints,
|
|
|
|
[CURSOR_AREA_EARNED_SYMBOLS] = gText_CollectedSymbols,
|
|
|
|
[CURSOR_AREA_SYMBOL_TOWER] = gText_BattleTowerAbilitySymbol,
|
|
|
|
[CURSOR_AREA_SYMBOL_DOME] = gText_BattleDomeTacticsSymbol,
|
|
|
|
[CURSOR_AREA_SYMBOL_PALACE] = gText_BattlePalaceSpiritsSymbol,
|
|
|
|
[CURSOR_AREA_SYMBOL_ARENA] = gText_BattleArenaGutsSymbol,
|
|
|
|
[CURSOR_AREA_SYMBOL_FACTORY] = gText_BattleFactoryKnowledgeSymbol,
|
|
|
|
[CURSOR_AREA_SYMBOL_PIKE] = gText_BattlePikeLuckSymbol,
|
|
|
|
[CURSOR_AREA_SYMBOL_PYRAMID] = gText_BattlePyramidBraveSymbol,
|
|
|
|
[CURSOR_AREA_COUNT] = gText_EmptyString7,
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
const u8 *name;
|
|
|
|
const u8 *description;
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
u8 animNum;
|
2021-01-19 10:03:51 +01:00
|
|
|
} static const sMapLandmarks[NUM_FRONTIER_FACILITIES] =
|
|
|
|
{
|
|
|
|
[FRONTIER_FACILITY_TOWER] = {gText_BattleTower3, gText_BattleTowerDesc, 89, 40, MAP_INDICATOR_SQUARE},
|
|
|
|
[FRONTIER_FACILITY_DOME] = {gText_BattleDome2, gText_BattleDomeDesc, 33, 42, MAP_INDICATOR_SQUARE},
|
|
|
|
[FRONTIER_FACILITY_PALACE] = {gText_BattlePalace2, gText_BattlePalaceDesc, 120, 86, MAP_INDICATOR_RECTANGLE},
|
|
|
|
[FRONTIER_FACILITY_ARENA] = {gText_BattleArena2, gText_BattleArenaDesc, 114, 59, MAP_INDICATOR_RECTANGLE},
|
|
|
|
[FRONTIER_FACILITY_FACTORY] = {gText_BattleFactory2, gText_BattleFactoryDesc, 25, 67, MAP_INDICATOR_RECTANGLE},
|
|
|
|
[FRONTIER_FACILITY_PIKE] = {gText_BattlePike2, gText_BattlePikeDesc, 57, 57, MAP_INDICATOR_SQUARE},
|
|
|
|
[FRONTIER_FACILITY_PYRAMID] = {gText_BattlePyramid2, gText_BattlePyramidDesc, 134, 41, MAP_INDICATOR_SQUARE},
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
2019-01-25 23:32:45 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void ResetGpuRegsAndBgs(void)
|
2019-01-20 18:24:35 +01:00
|
|
|
{
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG3CNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG2CNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG1CNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG0CNT, 0);
|
2021-11-04 04:02:06 +01:00
|
|
|
ChangeBgX(0, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(0, 0, BG_COORD_SET);
|
|
|
|
ChangeBgX(1, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(1, 0, BG_COORD_SET);
|
|
|
|
ChangeBgX(2, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(2, 0, BG_COORD_SET);
|
|
|
|
ChangeBgX(3, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(3, 0, BG_COORD_SET);
|
2019-01-20 18:24:35 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDY, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_WIN0H, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_WIN0V, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_WIN1H, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_WIN1V, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_WININ, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_WINOUT, 0);
|
|
|
|
CpuFill16(0, (void *)VRAM, VRAM_SIZE);
|
|
|
|
CpuFill32(0, (void *)OAM, OAM_SIZE);
|
|
|
|
}
|
2019-01-25 23:32:45 +01:00
|
|
|
|
2019-01-26 14:50:24 +01:00
|
|
|
void ShowFrontierPass(void (*callback)(void))
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 14:50:24 +01:00
|
|
|
AllocateFrontierPassData(callback);
|
|
|
|
SetMainCallback2(CB2_InitFrontierPass);
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void LeaveFrontierPass(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
SetMainCallback2(sPassData->callback);
|
2019-01-26 14:50:24 +01:00
|
|
|
FreeFrontierPassData();
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static u32 AllocateFrontierPassData(void (*callback)(void))
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassData != NULL)
|
2021-01-19 10:03:51 +01:00
|
|
|
return ERR_ALREADY_DONE;
|
2019-01-25 23:32:45 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData = AllocZeroed(sizeof(*sPassData));
|
|
|
|
if (sPassData == NULL)
|
2021-01-19 10:03:51 +01:00
|
|
|
return ERR_ALLOC_FAILED;
|
2019-01-25 23:32:45 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->callback = callback;
|
2019-01-25 23:32:45 +01:00
|
|
|
i = GetCurrentRegionMapSectionId();
|
|
|
|
if (i != MAPSEC_BATTLE_FRONTIER && i != MAPSEC_ARTISAN_CAVE)
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
// Player is not in the frontier, set
|
|
|
|
// cursor position to the Trainer Card
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->cursorX = 176;
|
|
|
|
sPassData->cursorY = 104;
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
// Player is in the frontier, set
|
|
|
|
// cursor position to the frontier map
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->cursorX = 176;
|
|
|
|
sPassData->cursorY = 48;
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->battlePoints = gSaveBlock2Ptr->frontier.battlePoints;
|
|
|
|
sPassData->hasBattleRecord = CanCopyRecordedBattleSaveData();
|
2021-01-19 10:03:51 +01:00
|
|
|
sPassData->areaToShow = CURSOR_AREA_NOTHING;
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->trainerStars = CountPlayerTrainerStars();
|
2021-01-19 10:03:51 +01:00
|
|
|
for (i = 0; i < NUM_FRONTIER_FACILITIES; i++)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
if (FlagGet(FLAG_SYS_TOWER_SILVER + i * 2))
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->facilitySymbols[i]++;
|
2019-01-25 23:32:45 +01:00
|
|
|
if (FlagGet(FLAG_SYS_TOWER_GOLD + i * 2))
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->facilitySymbols[i]++;
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
return SUCCESS;
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static u32 FreeFrontierPassData(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassData == NULL)
|
2021-01-19 10:03:51 +01:00
|
|
|
return ERR_ALREADY_DONE;
|
2019-01-25 23:32:45 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
memset(sPassData, 0, sizeof(*sPassData)); // Why clear data, if it's going to be freed anyway?
|
|
|
|
FREE_AND_SET_NULL(sPassData);
|
2021-01-19 10:03:51 +01:00
|
|
|
return SUCCESS;
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static u32 AllocateFrontierPassGfx(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassGfx != NULL)
|
2021-01-19 10:03:51 +01:00
|
|
|
return ERR_ALREADY_DONE;
|
2019-01-25 23:32:45 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassGfx = AllocZeroed(sizeof(*sPassGfx));
|
|
|
|
if (sPassGfx == NULL)
|
2021-01-19 10:03:51 +01:00
|
|
|
return ERR_ALLOC_FAILED;
|
2019-01-25 23:32:45 +01:00
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
return SUCCESS;
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static u32 FreeFrontierPassGfx(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
FreeAllWindowBuffers();
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassGfx == NULL)
|
2021-01-19 10:03:51 +01:00
|
|
|
return ERR_ALREADY_DONE;
|
2019-01-25 23:32:45 +01:00
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
TRY_FREE_AND_SET_NULL(sPassGfx->battleRecordTilemap);
|
|
|
|
TRY_FREE_AND_SET_NULL(sPassGfx->mapAndCardTilemap);
|
|
|
|
TRY_FREE_AND_SET_NULL(sPassGfx->mapAndCardZoomTilemap);
|
2019-01-25 23:32:45 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
memset(sPassGfx, 0, sizeof(*sPassGfx)); // Why clear data, if it's going to be freed anyway?
|
|
|
|
FREE_AND_SET_NULL(sPassGfx);
|
2021-01-19 10:03:51 +01:00
|
|
|
return SUCCESS;
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static void VBlankCB_FrontierPass(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
if (sPassGfx->zooming)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
SetBgAffine(2,
|
2021-01-19 10:03:51 +01:00
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][0] << 8,
|
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][1] << 8,
|
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][0],
|
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][1],
|
|
|
|
sPassGfx->scaleX,
|
|
|
|
sPassGfx->scaleY,
|
2019-01-25 23:32:45 +01:00
|
|
|
0);
|
|
|
|
}
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
TransferPlttBuffer();
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void CB2_FrontierPass(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
RunTasks();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void CB2_InitFrontierPass(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 14:50:24 +01:00
|
|
|
if (InitFrontierPass())
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 14:50:24 +01:00
|
|
|
CreateTask(Task_HandleFrontierPassInput, 0);
|
|
|
|
SetMainCallback2(CB2_FrontierPass);
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void CB2_HideFrontierPass(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 14:50:24 +01:00
|
|
|
if (HideFrontierPass())
|
|
|
|
LeaveFrontierPass();
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static bool32 InitFrontierPass(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
u32 sizeOut = 0;
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
switch (sPassData->state)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
ScanlineEffect_Stop();
|
|
|
|
SetVBlankHBlankCallbacksToNull();
|
|
|
|
DisableInterrupts(INTR_FLAG_HBLANK);
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-01-26 20:56:06 +01:00
|
|
|
ResetGpuRegsAndBgs();
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ResetTasks();
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
ResetPaletteFade();
|
2020-05-14 10:37:09 +02:00
|
|
|
ResetTempTileDataBuffers();
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2019-01-26 14:50:24 +01:00
|
|
|
AllocateFrontierPassGfx();
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
2019-01-26 20:56:06 +01:00
|
|
|
InitBgsFromTemplates(1, sPassBgTemplates, ARRAY_COUNT(sPassBgTemplates));
|
|
|
|
SetBgTilemapBuffer(1, sPassGfx->tilemapBuff1);
|
|
|
|
SetBgTilemapBuffer(2, sPassGfx->tilemapBuff2);
|
|
|
|
SetBgTilemapBuffer(3, sPassGfx->tilemapBuff3);
|
2019-01-25 23:32:45 +01:00
|
|
|
SetBgAttribute(2, BG_ATTR_WRAPAROUND, 1);
|
|
|
|
break;
|
|
|
|
case 5:
|
2019-01-26 20:56:06 +01:00
|
|
|
InitWindows(sPassWindowTemplates);
|
2019-01-25 23:32:45 +01:00
|
|
|
DeactivateAllTextPrinters();
|
|
|
|
break;
|
|
|
|
case 6:
|
2021-01-19 10:03:51 +01:00
|
|
|
sPassGfx->mapAndCardZoomTilemap = malloc_and_decompress(sMapAndCard_Zooming_Tilemap, &sizeOut);
|
|
|
|
sPassGfx->mapAndCardTilemap = malloc_and_decompress(sMapAndCard_ZoomedOut_Tilemap, &sizeOut);
|
|
|
|
sPassGfx->battleRecordTilemap = malloc_and_decompress(sBattleRecord_Tilemap, &sizeOut);
|
|
|
|
DecompressAndCopyTileDataToVram(1, gFrontierPassBg_Gfx, 0, 0, 0);
|
|
|
|
DecompressAndCopyTileDataToVram(2, gFrontierPassMapAndCard_Gfx, 0, 0, 0);
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
|
|
|
case 7:
|
2020-05-14 10:37:09 +02:00
|
|
|
if (FreeTempTileDataBuffersIfPossible())
|
2019-01-25 23:32:45 +01:00
|
|
|
return FALSE;
|
|
|
|
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20);
|
|
|
|
FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 30, 20);
|
|
|
|
FillBgTilemapBufferRect_Palette0(2, 0, 0, 0, 30, 20);
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
CopyBgTilemapBufferToVram(2);
|
|
|
|
break;
|
|
|
|
case 8:
|
2021-01-19 10:03:51 +01:00
|
|
|
LoadPalette(gFrontierPassBg_Pal[0], 0, 0x1A0);
|
|
|
|
LoadPalette(gFrontierPassBg_Pal[1 + sPassData->trainerStars], 0x10, 0x20);
|
2020-08-07 08:00:41 +02:00
|
|
|
LoadPalette(GetTextWindowPalette(0), 0xF0, 0x20);
|
2021-01-19 10:03:51 +01:00
|
|
|
DrawFrontierPassBg();
|
|
|
|
UpdateAreaHighlight(sPassData->cursorArea, sPassData->previousCursorArea);
|
|
|
|
if (sPassData->areaToShow == CURSOR_AREA_MAP || sPassData->areaToShow == CURSOR_AREA_CARD)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state = 0;
|
2019-01-25 23:32:45 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
|
|
|
ShowBg(0);
|
|
|
|
ShowBg(1);
|
|
|
|
ShowBg(2);
|
2019-01-26 14:50:24 +01:00
|
|
|
LoadCursorAndSymbolSprites();
|
2021-01-19 10:03:51 +01:00
|
|
|
SetVBlankCallback(VBlankCB_FrontierPass);
|
|
|
|
BlendPalettes(PALETTES_ALL, 16, RGB_BLACK);
|
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
if (UpdatePaletteFade())
|
|
|
|
return FALSE;
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state = 0;
|
2019-01-25 23:32:45 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state++;
|
2019-01-25 23:32:45 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static bool32 HideFrontierPass(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
switch (sPassData->state)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-01-19 10:03:51 +01:00
|
|
|
if (sPassData->areaToShow != CURSOR_AREA_MAP && sPassData->areaToShow != CURSOR_AREA_CARD)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state = 2;
|
2019-01-25 23:32:45 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (UpdatePaletteFade())
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
|
|
|
HideBg(0);
|
|
|
|
HideBg(1);
|
|
|
|
HideBg(2);
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
ScanlineEffect_Stop();
|
|
|
|
SetVBlankHBlankCallbacksToNull();
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-01-26 14:50:24 +01:00
|
|
|
FreeCursorAndSymbolSprites();
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2019-01-26 20:56:06 +01:00
|
|
|
ResetGpuRegsAndBgs();
|
2019-01-25 23:32:45 +01:00
|
|
|
ResetTasks();
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
UnsetBgTilemapBuffer(0);
|
|
|
|
UnsetBgTilemapBuffer(1);
|
|
|
|
UnsetBgTilemapBuffer(2);
|
2019-01-26 14:50:24 +01:00
|
|
|
FreeFrontierPassGfx();
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state = 0;
|
2019-01-25 23:32:45 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state++;
|
2019-01-25 23:32:45 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static u8 GetCursorAreaFromCoords(s16 x, s16 y)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
// Minus/Plus 1, because the table doesn't take CURSOR_AREA_NOTHING into account.
|
2019-01-25 23:32:45 +01:00
|
|
|
for (i = 0; i < CURSOR_AREA_COUNT - 1; i++)
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassAreasLayout[i].yStart <= y && sPassAreasLayout[i].yEnd >= y
|
2021-01-19 10:03:51 +01:00
|
|
|
&& sPassAreasLayout[i].xStart <= x && sPassAreasLayout[i].xEnd >= x)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (i >= CURSOR_AREA_SYMBOL - 1 && sPassData->facilitySymbols[i - CURSOR_AREA_SYMBOL + 1] == 0)
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
return i + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
return CURSOR_AREA_NOTHING;
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
// For Task_PassAreaZoom
|
|
|
|
#define tZoomOut data[0]
|
|
|
|
|
2019-01-26 14:50:24 +01:00
|
|
|
void CB2_ReshowFrontierPass(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
|
2019-01-26 14:50:24 +01:00
|
|
|
if (!InitFrontierPass())
|
2019-01-25 23:32:45 +01:00
|
|
|
return;
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
switch (sPassData->areaToShow)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
case CURSOR_AREA_MAP:
|
|
|
|
case CURSOR_AREA_CARD:
|
|
|
|
taskId = CreateTask(Task_PassAreaZoom, 0);
|
|
|
|
gTasks[taskId].tZoomOut = TRUE;
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
2021-01-19 10:03:51 +01:00
|
|
|
case CURSOR_AREA_RECORD:
|
2019-01-25 23:32:45 +01:00
|
|
|
default:
|
2021-01-19 10:03:51 +01:00
|
|
|
sPassData->areaToShow = CURSOR_AREA_NOTHING;
|
2019-01-26 14:50:24 +01:00
|
|
|
taskId = CreateTask(Task_HandleFrontierPassInput, 0);
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-01-26 14:50:24 +01:00
|
|
|
SetMainCallback2(CB2_FrontierPass);
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void CB2_ReturnFromRecord(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
AllocateFrontierPassData(sSavedPassData.callback);
|
|
|
|
sPassData->cursorX = sSavedPassData.cursorX;
|
|
|
|
sPassData->cursorY = sSavedPassData.cursorY;
|
|
|
|
memset(&sSavedPassData, 0, sizeof(sSavedPassData));
|
2019-01-25 23:32:45 +01:00
|
|
|
switch (InBattlePyramid())
|
|
|
|
{
|
|
|
|
case 1:
|
2020-08-21 00:02:00 +02:00
|
|
|
PlayBGM(MUS_B_PYRAMID);
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-08-21 00:02:00 +02:00
|
|
|
PlayBGM(MUS_B_PYRAMID_TOP);
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Overworld_PlaySpecialMapMusic();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-01-26 14:50:24 +01:00
|
|
|
SetMainCallback2(CB2_ReshowFrontierPass);
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void CB2_ShowFrontierPassFeature(void)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
if (!HideFrontierPass())
|
|
|
|
return;
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
switch (sPassData->areaToShow)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
case CURSOR_AREA_MAP:
|
2019-01-26 14:50:24 +01:00
|
|
|
ShowFrontierMap(CB2_ReshowFrontierPass);
|
|
|
|
break;
|
2021-01-19 10:03:51 +01:00
|
|
|
case CURSOR_AREA_RECORD:
|
2019-01-26 20:56:06 +01:00
|
|
|
sSavedPassData.callback = sPassData->callback;
|
|
|
|
sSavedPassData.cursorX = sPassData->cursorX;
|
|
|
|
sSavedPassData.cursorY = sPassData->cursorY;
|
2019-01-26 14:50:24 +01:00
|
|
|
FreeFrontierPassData();
|
|
|
|
PlayRecordedBattle(CB2_ReturnFromRecord);
|
|
|
|
break;
|
2021-01-19 10:03:51 +01:00
|
|
|
case CURSOR_AREA_CARD:
|
2019-01-26 14:50:24 +01:00
|
|
|
ShowPlayerTrainerCard(CB2_ReshowFrontierPass);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static bool32 TryCallPassAreaFunction(u8 taskId, u8 cursorArea)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
switch (cursorArea)
|
|
|
|
{
|
|
|
|
case CURSOR_AREA_RECORD:
|
2019-01-26 20:56:06 +01:00
|
|
|
if (!sPassData->hasBattleRecord)
|
2019-01-26 14:50:24 +01:00
|
|
|
return FALSE;
|
2021-01-19 10:03:51 +01:00
|
|
|
sPassData->areaToShow = CURSOR_AREA_RECORD;
|
2019-01-26 14:50:24 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
SetMainCallback2(CB2_ShowFrontierPassFeature);
|
|
|
|
break;
|
|
|
|
case CURSOR_AREA_MAP:
|
|
|
|
case CURSOR_AREA_CARD:
|
2021-01-19 10:03:51 +01:00
|
|
|
sPassData->areaToShow = cursorArea;
|
|
|
|
gTasks[taskId].func = Task_PassAreaZoom;
|
|
|
|
gTasks[taskId].tZoomOut = FALSE;
|
2019-01-26 14:50:24 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
sPassData->cursorX = sPassGfx->cursorSprite->x;
|
|
|
|
sPassData->cursorY = sPassGfx->cursorSprite->y;
|
2019-01-26 14:50:24 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void Task_HandleFrontierPassInput(u8 taskId)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
u8 var = FALSE; // Reused, first informs whether the cursor moves, then used as the new cursor area.
|
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
if (JOY_HELD(DPAD_UP) && sPassGfx->cursorSprite->y >= 9)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sPassGfx->cursorSprite->y -= 2;
|
|
|
|
if (sPassGfx->cursorSprite->y <= 7)
|
|
|
|
sPassGfx->cursorSprite->y = 2;
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
}
|
2021-07-07 15:11:52 +02:00
|
|
|
if (JOY_HELD(DPAD_DOWN) && sPassGfx->cursorSprite->y <= 135)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sPassGfx->cursorSprite->y += 2;
|
|
|
|
if (sPassGfx->cursorSprite->y >= 137)
|
|
|
|
sPassGfx->cursorSprite->y = 136;
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
}
|
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
if (JOY_HELD(DPAD_LEFT) && sPassGfx->cursorSprite->x >= 6)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sPassGfx->cursorSprite->x -= 2;
|
|
|
|
if (sPassGfx->cursorSprite->x <= 4)
|
|
|
|
sPassGfx->cursorSprite->x = 5;
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
}
|
2021-07-07 15:11:52 +02:00
|
|
|
if (JOY_HELD(DPAD_RIGHT) && sPassGfx->cursorSprite->x <= 231)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sPassGfx->cursorSprite->x += 2;
|
|
|
|
if (sPassGfx->cursorSprite->x >= 233)
|
|
|
|
sPassGfx->cursorSprite->x = 232;
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!var) // Cursor did not change.
|
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (sPassData->cursorArea != CURSOR_AREA_NOTHING && JOY_NEW(A_BUTTON))
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassData->cursorArea <= CURSOR_AREA_RECORD) // Map, Card, Record
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-01-26 20:56:06 +01:00
|
|
|
if (TryCallPassAreaFunction(taskId, sPassData->cursorArea))
|
2019-01-26 14:50:24 +01:00
|
|
|
return;
|
|
|
|
}
|
2019-01-26 20:56:06 +01:00
|
|
|
else if (sPassData->cursorArea == CURSOR_AREA_CANCEL)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_PC_OFF);
|
|
|
|
SetMainCallback2(CB2_HideFrontierPass);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
// BUG. The function should return here. Otherwise, it can play the same sound twice and destroy the same task twice.
|
2020-12-13 05:28:01 +01:00
|
|
|
#ifdef BUGFIX
|
|
|
|
return;
|
|
|
|
#endif
|
2019-01-26 14:50:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_PC_OFF);
|
|
|
|
SetMainCallback2(CB2_HideFrontierPass);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
var = GetCursorAreaFromCoords(sPassGfx->cursorSprite->x - 5, sPassGfx->cursorSprite->y + 5);
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassData->cursorArea != var)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
PrintAreaDescription(var);
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->previousCursorArea = sPassData->cursorArea;
|
|
|
|
sPassData->cursorArea = var;
|
2021-01-19 10:03:51 +01:00
|
|
|
UpdateAreaHighlight(sPassData->cursorArea, sPassData->previousCursorArea);
|
2019-01-26 14:50:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
#define tScaleX data[1]
|
|
|
|
#define tScaleY data[2]
|
|
|
|
#define tScaleSpeedX data[3]
|
|
|
|
#define tScaleSpeedY data[4]
|
|
|
|
|
|
|
|
// Zoom in/out for the Frontier map or the trainer card
|
|
|
|
static void Task_PassAreaZoom(u8 taskId)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
switch (sPassData->state)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-01-19 10:03:51 +01:00
|
|
|
// Initialize the zoom, start fading in/out
|
|
|
|
if (!tZoomOut)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
// Zooming in to map/card screen
|
|
|
|
ShowHideZoomingArea(TRUE, FALSE);
|
|
|
|
tScaleX = Q_8_8(1);
|
|
|
|
tScaleY = Q_8_8(1);
|
|
|
|
tScaleSpeedX = 0x15;
|
|
|
|
tScaleSpeedY = 0x15;
|
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_WHITE);
|
2019-01-26 14:50:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
// Zooming out of map/card screen back to frontier pass
|
|
|
|
tScaleX = Q_8_8(1.984375); // 1 and 63/64
|
|
|
|
tScaleY = Q_8_8(1.984375);
|
|
|
|
tScaleSpeedX = -0x15;
|
|
|
|
tScaleSpeedY = -0x15;
|
2019-01-26 14:50:24 +01:00
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
|
|
|
ShowBg(0);
|
|
|
|
ShowBg(1);
|
|
|
|
ShowBg(2);
|
|
|
|
LoadCursorAndSymbolSprites();
|
2021-01-19 10:03:51 +01:00
|
|
|
SetVBlankCallback(VBlankCB_FrontierPass);
|
|
|
|
BlendPalettes(PALETTES_ALL, 16, RGB_WHITE);
|
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_WHITE);
|
2019-01-26 14:50:24 +01:00
|
|
|
}
|
2021-01-19 10:03:51 +01:00
|
|
|
sPassGfx->zooming = TRUE;
|
|
|
|
sPassGfx->scaleX = MathUtil_Inv16(tScaleX);
|
|
|
|
sPassGfx->scaleY = MathUtil_Inv16(tScaleY);
|
2019-01-26 14:50:24 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-01-19 10:03:51 +01:00
|
|
|
// Update the fade and zoom
|
2019-01-26 14:50:24 +01:00
|
|
|
UpdatePaletteFade();
|
2021-01-19 10:03:51 +01:00
|
|
|
tScaleX += tScaleSpeedX;
|
|
|
|
tScaleY += tScaleSpeedY;
|
|
|
|
sPassGfx->scaleX = MathUtil_Inv16(tScaleX);
|
|
|
|
sPassGfx->scaleY = MathUtil_Inv16(tScaleY);
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
// Check if zoom hasn't reached target
|
|
|
|
if (!tZoomOut)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
if (tScaleX <= Q_8_8(1.984375))
|
2019-01-26 14:50:24 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
if (tScaleX != Q_8_8(1))
|
2019-01-26 14:50:24 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-01-19 10:03:51 +01:00
|
|
|
if (sPassGfx->zooming)
|
|
|
|
sPassGfx->zooming = FALSE;
|
2019-01-26 14:50:24 +01:00
|
|
|
if (UpdatePaletteFade())
|
|
|
|
return;
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
if (!tZoomOut)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
// Zoomed in and faded out, switch to map or trainer card
|
2019-01-26 14:50:24 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
SetMainCallback2(CB2_ShowFrontierPassFeature);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
// Zoomed out and faded in, return to frontier pass
|
|
|
|
ShowHideZoomingArea(FALSE, FALSE);
|
|
|
|
sPassData->areaToShow = CURSOR_AREA_NOTHING;
|
2019-01-26 14:50:24 +01:00
|
|
|
gTasks[taskId].func = Task_HandleFrontierPassInput;
|
|
|
|
}
|
|
|
|
SetBgAttribute(2, BG_ATTR_WRAPAROUND, 0);
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state = 0;
|
2019-01-26 14:50:24 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state++;
|
2019-01-26 14:50:24 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void ShowAndPrintWindows(void)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
s32 x;
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
for (i = 0; i < WINDOW_COUNT; i++)
|
|
|
|
{
|
|
|
|
PutWindowTilemap(i);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(i, PIXEL_FILL(0));
|
2019-01-26 14:50:24 +01:00
|
|
|
}
|
|
|
|
|
2021-10-30 22:47:37 +02:00
|
|
|
x = GetStringCenterAlignXOffset(FONT_NORMAL, gText_SymbolsEarned, 96);
|
|
|
|
AddTextPrinterParameterized3(WINDOW_EARNED_SYMBOLS, FONT_NORMAL, x, 5, sTextColors[0], 0, gText_SymbolsEarned);
|
2019-01-26 14:50:24 +01:00
|
|
|
|
2021-10-30 22:47:37 +02:00
|
|
|
x = GetStringCenterAlignXOffset(FONT_NORMAL, gText_BattleRecord, 96);
|
|
|
|
AddTextPrinterParameterized3(WINDOW_BATTLE_RECORD, FONT_NORMAL, x, 5, sTextColors[0], 0, gText_BattleRecord);
|
2019-01-26 14:50:24 +01:00
|
|
|
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized3(WINDOW_BATTLE_POINTS, FONT_SMALL_NARROW, 5, 4, sTextColors[0], 0, gText_BattlePoints);
|
2019-01-26 20:56:06 +01:00
|
|
|
ConvertIntToDecimalStringN(gStringVar4, sPassData->battlePoints, STR_CONV_MODE_LEFT_ALIGN, 5);
|
2021-10-30 22:47:37 +02:00
|
|
|
x = GetStringRightAlignXOffset(FONT_SMALL_NARROW, gStringVar4, 91);
|
|
|
|
AddTextPrinterParameterized3(WINDOW_BATTLE_POINTS, FONT_SMALL_NARROW, x, 16, sTextColors[0], 0, gStringVar4);
|
2019-01-26 14:50:24 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->cursorArea = GetCursorAreaFromCoords(sPassData->cursorX - 5, sPassData->cursorY + 5);
|
|
|
|
sPassData->previousCursorArea = CURSOR_AREA_NOTHING;
|
|
|
|
PrintAreaDescription(sPassData->cursorArea);
|
2019-01-26 14:50:24 +01:00
|
|
|
|
|
|
|
for (i = 0; i < WINDOW_COUNT; i++)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(i, COPYWIN_FULL);
|
2019-01-26 14:50:24 +01:00
|
|
|
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void PrintAreaDescription(u8 cursorArea)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(WINDOW_DESCRIPTION, PIXEL_FILL(0));
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
if (cursorArea == CURSOR_AREA_RECORD && !sPassData->hasBattleRecord)
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized3(WINDOW_DESCRIPTION, FONT_NORMAL, 2, 0, sTextColors[1], 0, sPassAreaDescriptions[CURSOR_AREA_NOTHING]);
|
2019-01-26 14:50:24 +01:00
|
|
|
else if (cursorArea != CURSOR_AREA_NOTHING)
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized3(WINDOW_DESCRIPTION, FONT_NORMAL, 2, 0, sTextColors[1], 0, sPassAreaDescriptions[cursorArea]);
|
2019-01-26 14:50:24 +01:00
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(WINDOW_DESCRIPTION, COPYWIN_FULL);
|
2019-01-26 14:50:24 +01:00
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
}
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static void ShowHideZoomingArea(bool8 show, bool8 zoomedIn)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
switch (sPassData->areaToShow)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
case CURSOR_AREA_MAP:
|
|
|
|
if (show)
|
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(2, sPassGfx->mapAndCardZoomTilemap, 16, 3, 12, 7, 16);
|
2019-01-26 14:50:24 +01:00
|
|
|
else
|
|
|
|
FillBgTilemapBufferRect(2, 0, 16, 3, 12, 7, 16);
|
|
|
|
break;
|
2021-01-19 10:03:51 +01:00
|
|
|
case CURSOR_AREA_CARD:
|
|
|
|
if (show)
|
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(2, sPassGfx->mapAndCardZoomTilemap + 84, 16, 10, 12, 7, 16);
|
2019-01-26 14:50:24 +01:00
|
|
|
else
|
|
|
|
FillBgTilemapBufferRect(2, 0, 16, 10, 12, 7, 16);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyBgTilemapBufferToVram(2);
|
2021-01-19 10:03:51 +01:00
|
|
|
if (zoomedIn)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
SetBgAffine(2,
|
2021-01-19 10:03:51 +01:00
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][0] << 8,
|
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][1] << 8,
|
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][0],
|
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][1],
|
2020-05-20 21:23:21 +02:00
|
|
|
MathUtil_Inv16(Q_8_8(1.984375)), // 1 and 63/64
|
|
|
|
MathUtil_Inv16(Q_8_8(1.984375)),
|
2019-01-26 14:50:24 +01:00
|
|
|
0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetBgAffine(2,
|
2021-01-19 10:03:51 +01:00
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][0] << 8,
|
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][1] << 8,
|
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][0],
|
|
|
|
sBgAffineCoords[sPassData->areaToShow - 1][1],
|
2020-05-20 21:23:21 +02:00
|
|
|
MathUtil_Inv16(Q_8_8(1)),
|
|
|
|
MathUtil_Inv16(Q_8_8(1)),
|
2019-01-26 14:50:24 +01:00
|
|
|
0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static void UpdateAreaHighlight(u8 cursorArea, u8 previousCursorArea)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
#define NON_HIGHLIGHT_AREA(area)((area) == CURSOR_AREA_NOTHING || (area) > CURSOR_AREA_CANCEL)
|
|
|
|
|
|
|
|
// If moving off highlightable area, unhighlight it
|
2019-01-26 14:50:24 +01:00
|
|
|
switch (previousCursorArea)
|
|
|
|
{
|
|
|
|
case CURSOR_AREA_MAP:
|
2021-01-19 10:03:51 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->mapAndCardTilemap, 16, 3, 12, 7, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_CARD:
|
2021-01-19 10:03:51 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->mapAndCardTilemap + 336, 16, 10, 12, 7, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_RECORD:
|
2020-10-26 05:46:01 +01:00
|
|
|
if (sPassData->hasBattleRecord)
|
2021-01-19 10:03:51 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->battleRecordTilemap, 2, 10, 12, 3, 17);
|
|
|
|
else if (NON_HIGHLIGHT_AREA(cursorArea))
|
2020-10-26 05:46:01 +01:00
|
|
|
return;
|
2019-01-26 14:50:24 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_CANCEL:
|
2021-01-19 10:03:51 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, gFrontierPassCancelButton_Tilemap, 21, 0, 9, 2, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
break;
|
|
|
|
default:
|
2021-01-19 10:03:51 +01:00
|
|
|
if (NON_HIGHLIGHT_AREA(cursorArea))
|
2019-01-26 14:50:24 +01:00
|
|
|
return;
|
2020-10-26 05:46:01 +01:00
|
|
|
break;
|
2019-01-26 14:50:24 +01:00
|
|
|
}
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
// If moving on to highlightable area, highlight it
|
2019-01-26 14:50:24 +01:00
|
|
|
switch (cursorArea)
|
|
|
|
{
|
|
|
|
case CURSOR_AREA_MAP:
|
2021-01-19 10:03:51 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->mapAndCardTilemap + 168, 16, 3, 12, 7, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_CARD:
|
2021-01-19 10:03:51 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->mapAndCardTilemap + 504, 16, 10, 12, 7, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_RECORD:
|
2020-10-26 05:46:01 +01:00
|
|
|
if (sPassData->hasBattleRecord)
|
2021-01-19 10:03:51 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->battleRecordTilemap + 72, 2, 10, 12, 3, 17);
|
2020-10-26 05:46:01 +01:00
|
|
|
else
|
2019-01-26 14:50:24 +01:00
|
|
|
return;
|
2021-01-19 10:03:51 +01:00
|
|
|
break;
|
2019-01-26 14:50:24 +01:00
|
|
|
case CURSOR_AREA_CANCEL:
|
2021-01-19 10:03:51 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, gFrontierPassCancelButtonHighlighted_Tilemap, 21, 0, 9, 2, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
break;
|
|
|
|
default:
|
2021-01-19 10:03:51 +01:00
|
|
|
if (NON_HIGHLIGHT_AREA(previousCursorArea))
|
2019-01-26 14:50:24 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
}
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static void DrawFrontierPassBg(void)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
CopyToBgTilemapBuffer(1, gFrontierPassBg_Tilemap, 0, 0);
|
|
|
|
UpdateAreaHighlight(sPassData->cursorArea, sPassData->previousCursorArea);
|
|
|
|
ShowHideZoomingArea(TRUE, sPassData->areaToShow); // If returning to frontier pass from map/card (areaToShow will be != 0)
|
2019-01-26 14:50:24 +01:00
|
|
|
ShowAndPrintWindows();
|
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void LoadCursorAndSymbolSprites(void)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
u8 i = 0;
|
|
|
|
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
ResetAffineAnimData();
|
2019-01-26 20:56:06 +01:00
|
|
|
LoadSpritePalettes(sSpritePalettes);
|
|
|
|
LoadCompressedSpriteSheet(&sCursorSpriteSheets[0]);
|
|
|
|
LoadCompressedSpriteSheet(&sCursorSpriteSheets[2]);
|
|
|
|
spriteId = CreateSprite(&sSpriteTemplates_Cursors[0], sPassData->cursorX, sPassData->cursorY, 0);
|
|
|
|
sPassGfx->cursorSprite = &gSprites[spriteId];
|
|
|
|
sPassGfx->cursorSprite->oam.priority = 0;
|
2019-01-26 14:50:24 +01:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_FRONTIER_FACILITIES; i++)
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassData->facilitySymbols[i] != 0)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
struct SpriteTemplate sprite = sSpriteTemplate_Medal;
|
2019-01-26 14:50:24 +01:00
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
sprite.paletteTag += sPassData->facilitySymbols[i] - 1; // Adds 1 if gold for TAG_MEDAL_GOLD
|
2019-01-26 20:56:06 +01:00
|
|
|
spriteId = CreateSprite(&sprite, sPassAreasLayout[i + CURSOR_AREA_SYMBOL - 1].xStart + 8, sPassAreasLayout[i + CURSOR_AREA_SYMBOL - 1].yStart + 6, i + 1);
|
|
|
|
sPassGfx->symbolSprites[i] = &gSprites[spriteId];
|
|
|
|
sPassGfx->symbolSprites[i]->oam.priority = 2;
|
|
|
|
StartSpriteAnim(sPassGfx->symbolSprites[i], i);
|
2019-01-26 14:50:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void FreeCursorAndSymbolSprites(void)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
u8 i = 0;
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
DestroySprite(sPassGfx->cursorSprite);
|
|
|
|
sPassGfx->cursorSprite = NULL;
|
2019-01-26 14:50:24 +01:00
|
|
|
for (i = 0; i < NUM_FRONTIER_FACILITIES; i++)
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassGfx->symbolSprites[i] != NULL)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
DestroySprite(sPassGfx->symbolSprites[i]);
|
|
|
|
sPassGfx->symbolSprites[i] = NULL;
|
2019-01-26 14:50:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
FreeAllSpritePalettes();
|
2021-01-19 10:03:51 +01:00
|
|
|
FreeSpriteTilesByTag(TAG_MEDAL_SILVER);
|
|
|
|
FreeSpriteTilesByTag(TAG_CURSOR);
|
2019-01-26 14:50:24 +01:00
|
|
|
}
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
static void SpriteCB_PlayerHead(struct Sprite *sprite)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Frontier Map code.
|
2019-01-26 19:20:14 +01:00
|
|
|
|
|
|
|
// Forward declarations.
|
2019-01-26 20:56:06 +01:00
|
|
|
static void Task_HandleFrontierMap(u8 taskId);
|
|
|
|
static void PrintOnFrontierMap(void);
|
|
|
|
static void InitFrontierMapSprites(void);
|
|
|
|
static void HandleFrontierMapCursorMove(u8 direction);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void ShowFrontierMap(void (*callback)(void))
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sMapData != NULL)
|
2019-01-26 19:20:14 +01:00
|
|
|
SetMainCallback2(callback); // This line doesn't make sense at all, since it gets overwritten later anyway.
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sMapData = AllocZeroed(sizeof(*sMapData));
|
|
|
|
sMapData->callback = callback;
|
2019-01-26 19:20:14 +01:00
|
|
|
ResetTasks();
|
2019-01-26 20:56:06 +01:00
|
|
|
CreateTask(Task_HandleFrontierMap, 0);
|
2019-01-26 19:20:14 +01:00
|
|
|
SetMainCallback2(CB2_FrontierPass);
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void FreeFrontierMap(void)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
|
|
|
ResetTasks();
|
2019-01-26 20:56:06 +01:00
|
|
|
SetMainCallback2(sMapData->callback);
|
|
|
|
memset(sMapData, 0, sizeof(*sMapData)); // Pointless memory clear.
|
|
|
|
FREE_AND_SET_NULL(sMapData);
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static bool32 InitFrontierMap(void)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
switch (sPassData->state)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
ScanlineEffect_Stop();
|
|
|
|
SetVBlankHBlankCallbacksToNull();
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-01-26 20:56:06 +01:00
|
|
|
ResetGpuRegsAndBgs();
|
2019-01-26 19:20:14 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
ResetPaletteFade();
|
2020-05-14 10:37:09 +02:00
|
|
|
ResetTempTileDataBuffers();
|
2019-01-26 19:20:14 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
2019-01-26 20:56:06 +01:00
|
|
|
InitBgsFromTemplates(0, sMapBgTemplates, ARRAY_COUNT(sMapBgTemplates));
|
|
|
|
SetBgTilemapBuffer(0, sMapData->tilemapBuff0);
|
|
|
|
SetBgTilemapBuffer(1, sMapData->tilemapBuff1);
|
|
|
|
SetBgTilemapBuffer(2, sMapData->tilemapBuff2);
|
2019-01-26 19:20:14 +01:00
|
|
|
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20);
|
|
|
|
FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 30, 20);
|
|
|
|
FillBgTilemapBufferRect_Palette0(2, 0, 0, 0, 30, 20);
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
CopyBgTilemapBufferToVram(2);
|
|
|
|
break;
|
|
|
|
case 4:
|
2019-01-26 20:56:06 +01:00
|
|
|
InitWindows(sMapWindowTemplates);
|
2019-01-26 19:20:14 +01:00
|
|
|
DeactivateAllTextPrinters();
|
2019-01-26 20:56:06 +01:00
|
|
|
PrintOnFrontierMap();
|
2021-01-19 10:03:51 +01:00
|
|
|
DecompressAndCopyTileDataToVram(1, sMapScreen_Gfx, 0, 0, 0);
|
2019-01-26 19:20:14 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2020-05-14 10:37:09 +02:00
|
|
|
if (FreeTempTileDataBuffersIfPossible())
|
2019-01-26 19:20:14 +01:00
|
|
|
return FALSE;
|
2021-01-19 10:03:51 +01:00
|
|
|
LoadPalette(gFrontierPassBg_Pal[0], 0, 0x1A0);
|
2020-08-07 08:00:41 +02:00
|
|
|
LoadPalette(GetTextWindowPalette(0), 0xF0, 0x20);
|
2021-01-19 10:03:51 +01:00
|
|
|
CopyToBgTilemapBuffer(2, sMapScreen_Tilemap, 0, 0);
|
2019-01-26 19:20:14 +01:00
|
|
|
CopyBgTilemapBufferToVram(2);
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
|
|
|
ShowBg(0);
|
|
|
|
ShowBg(1);
|
|
|
|
ShowBg(2);
|
2019-01-26 20:56:06 +01:00
|
|
|
InitFrontierMapSprites();
|
2021-01-19 10:03:51 +01:00
|
|
|
SetVBlankCallback(VBlankCB_FrontierPass);
|
|
|
|
BlendPalettes(PALETTES_ALL, 16, RGB_WHITE);
|
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_WHITE);
|
2019-01-26 19:20:14 +01:00
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
if (UpdatePaletteFade())
|
|
|
|
return FALSE;
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state = 0;
|
2019-01-26 19:20:14 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state++;
|
2019-01-26 19:20:14 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static bool32 ExitFrontierMap(void)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
switch (sPassData->state)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-01-19 10:03:51 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_WHITE);
|
2019-01-26 19:20:14 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (UpdatePaletteFade())
|
|
|
|
return FALSE;
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
|
|
|
HideBg(0);
|
|
|
|
HideBg(1);
|
|
|
|
HideBg(2);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
ScanlineEffect_Stop();
|
|
|
|
SetVBlankHBlankCallbacksToNull();
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sMapData->cursorSprite != NULL)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
DestroySprite(sMapData->cursorSprite);
|
2021-01-19 10:03:51 +01:00
|
|
|
FreeSpriteTilesByTag(TAG_CURSOR);
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sMapData->mapIndicatorSprite != NULL)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
DestroySprite(sMapData->mapIndicatorSprite);
|
2021-01-19 10:03:51 +01:00
|
|
|
FreeSpriteTilesByTag(TAG_MAP_INDICATOR);
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sMapData->playerHeadSprite != NULL)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
DestroySprite(sMapData->playerHeadSprite);
|
2021-01-19 10:03:51 +01:00
|
|
|
FreeSpriteTilesByTag(TAG_HEAD_MALE);
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
FreeAllWindowBuffers();
|
|
|
|
break;
|
|
|
|
case 4:
|
2019-01-26 20:56:06 +01:00
|
|
|
ResetGpuRegsAndBgs();
|
2019-01-26 19:20:14 +01:00
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
UnsetBgTilemapBuffer(0);
|
|
|
|
UnsetBgTilemapBuffer(1);
|
|
|
|
UnsetBgTilemapBuffer(2);
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state = 0;
|
2019-01-26 19:20:14 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-01-26 14:50:24 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->state++;
|
2019-01-26 19:20:14 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
#define tState data[0]
|
|
|
|
#define tMoveSteps data[1]
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void Task_HandleFrontierMap(u8 taskId)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
switch (tState)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2019-01-26 20:56:06 +01:00
|
|
|
if (InitFrontierMap())
|
2019-01-26 19:20:14 +01:00
|
|
|
break;
|
|
|
|
return;
|
|
|
|
case 1:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_PC_OFF);
|
2021-01-19 10:03:51 +01:00
|
|
|
tState = 4;
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_DOWN))
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sMapData->cursorPos >= NUM_FRONTIER_FACILITIES - 1)
|
|
|
|
HandleFrontierMapCursorMove(0);
|
2019-01-26 19:20:14 +01:00
|
|
|
else
|
2021-01-19 10:03:51 +01:00
|
|
|
tState = 2;
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_UP))
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sMapData->cursorPos == 0)
|
|
|
|
HandleFrontierMapCursorMove(1);
|
2019-01-26 19:20:14 +01:00
|
|
|
else
|
2021-01-19 10:03:51 +01:00
|
|
|
tState = 3;
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 2:
|
2021-01-19 10:03:51 +01:00
|
|
|
if (tMoveSteps > 3)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
HandleFrontierMapCursorMove(0);
|
2021-01-19 10:03:51 +01:00
|
|
|
tMoveSteps = 0;
|
|
|
|
tState = 1;
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sMapData->cursorSprite->y += 4;
|
2021-01-19 10:03:51 +01:00
|
|
|
tMoveSteps++;
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 3:
|
2021-01-19 10:03:51 +01:00
|
|
|
if (tMoveSteps > 3)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
HandleFrontierMapCursorMove(1);
|
2021-01-19 10:03:51 +01:00
|
|
|
tMoveSteps = 0;
|
|
|
|
tState = 1;
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sMapData->cursorSprite->y -= 4;
|
2021-01-19 10:03:51 +01:00
|
|
|
tMoveSteps++;
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 4:
|
2019-01-26 20:56:06 +01:00
|
|
|
if (ExitFrontierMap())
|
2019-01-26 19:20:14 +01:00
|
|
|
break;
|
|
|
|
return;
|
|
|
|
case 5:
|
|
|
|
DestroyTask(taskId);
|
2019-01-26 20:56:06 +01:00
|
|
|
FreeFrontierMap();
|
2019-01-26 19:20:14 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
tState++;
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static u8 MapNumToFrontierFacilityId(u16 mapNum) // id + 1, zero means not a frontier map number
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2021-01-19 10:03:51 +01:00
|
|
|
// In Battle Tower
|
2019-01-26 19:20:14 +01:00
|
|
|
if ((mapNum >= MAP_NUM(BATTLE_FRONTIER_BATTLE_TOWER_LOBBY) && mapNum <= MAP_NUM(BATTLE_FRONTIER_BATTLE_TOWER_BATTLE_ROOM))
|
2021-01-19 10:03:51 +01:00
|
|
|
|| (mapNum >= MAP_NUM(BATTLE_FRONTIER_BATTLE_TOWER_MULTI_PARTNER_ROOM) && mapNum <= MAP_NUM(BATTLE_FRONTIER_BATTLE_TOWER_MULTI_BATTLE_ROOM)))
|
2019-01-26 19:20:14 +01:00
|
|
|
return FRONTIER_FACILITY_TOWER + 1;
|
2021-01-19 10:03:51 +01:00
|
|
|
|
|
|
|
// In Battle Dome
|
2019-01-26 19:20:14 +01:00
|
|
|
else if (mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_DOME_LOBBY)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_DOME_CORRIDOR)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_DOME_PRE_BATTLE_ROOM)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_DOME_BATTLE_ROOM))
|
|
|
|
return FRONTIER_FACILITY_DOME + 1;
|
2021-01-19 10:03:51 +01:00
|
|
|
|
|
|
|
// In Battle Palace
|
2019-01-26 19:20:14 +01:00
|
|
|
else if (mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PALACE_LOBBY)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PALACE_CORRIDOR)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PALACE_BATTLE_ROOM))
|
|
|
|
return FRONTIER_FACILITY_PALACE + 1;
|
2021-01-19 10:03:51 +01:00
|
|
|
|
|
|
|
// In Battle Arena
|
2019-01-26 19:20:14 +01:00
|
|
|
else if (mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_ARENA_LOBBY)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_ARENA_CORRIDOR)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_ARENA_BATTLE_ROOM))
|
|
|
|
return FRONTIER_FACILITY_ARENA + 1;
|
2021-01-19 10:03:51 +01:00
|
|
|
|
|
|
|
// In Battle Factory
|
2019-01-26 19:20:14 +01:00
|
|
|
else if (mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_FACTORY_LOBBY)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_FACTORY_PRE_BATTLE_ROOM)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_FACTORY_BATTLE_ROOM))
|
|
|
|
return FRONTIER_FACILITY_FACTORY + 1;
|
2021-01-19 10:03:51 +01:00
|
|
|
|
|
|
|
// In Battle Pike
|
2019-01-26 19:20:14 +01:00
|
|
|
else if (mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PIKE_LOBBY)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PIKE_CORRIDOR)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PIKE_THREE_PATH_ROOM)
|
2019-11-21 03:46:29 +01:00
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PIKE_ROOM_NORMAL)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PIKE_ROOM_FINAL)
|
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PIKE_ROOM_WILD_MONS))
|
2019-01-26 19:20:14 +01:00
|
|
|
return FRONTIER_FACILITY_PIKE + 1;
|
2021-01-19 10:03:51 +01:00
|
|
|
|
|
|
|
// In Battle Pyramid
|
2019-01-26 19:20:14 +01:00
|
|
|
else if (mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY)
|
2019-12-11 09:28:55 +01:00
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PYRAMID_FLOOR)
|
2019-01-26 19:20:14 +01:00
|
|
|
|| mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PYRAMID_TOP))
|
|
|
|
return FRONTIER_FACILITY_PYRAMID + 1;
|
2021-01-19 10:03:51 +01:00
|
|
|
|
2019-01-26 19:20:14 +01:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void InitFrontierMapSprites(void)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
|
|
|
struct SpriteTemplate sprite;
|
|
|
|
u8 spriteId;
|
|
|
|
u8 id;
|
|
|
|
s16 x = 0, y;
|
|
|
|
|
|
|
|
FreeAllSpritePalettes();
|
2019-01-26 20:56:06 +01:00
|
|
|
LoadSpritePalettes(sSpritePalettes);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
LoadCompressedSpriteSheet(&sCursorSpriteSheets[0]);
|
|
|
|
spriteId = CreateSprite(&sSpriteTemplates_Cursors[0], 155, (sMapData->cursorPos * 16) + 8, 2);
|
|
|
|
sMapData->cursorSprite = &gSprites[spriteId];
|
|
|
|
sMapData->cursorSprite->oam.priority = 0;
|
|
|
|
sMapData->cursorSprite->hFlip = TRUE;
|
|
|
|
StartSpriteAnim(sMapData->cursorSprite, 1);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
LoadCompressedSpriteSheet(&sCursorSpriteSheets[1]);
|
|
|
|
spriteId = CreateSprite(&sSpriteTemplates_Cursors[1], sMapLandmarks[sMapData->cursorPos].x, sMapLandmarks[sMapData->cursorPos].y, 1);
|
|
|
|
sMapData->mapIndicatorSprite = &gSprites[spriteId];
|
|
|
|
sMapData->mapIndicatorSprite->oam.priority = 0;
|
|
|
|
StartSpriteAnim(sMapData->mapIndicatorSprite, sMapLandmarks[sMapData->cursorPos].animNum);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
|
|
|
// Create player indicator head sprite only if it's in vicinity of battle frontier.
|
|
|
|
id = GetCurrentRegionMapSectionId();
|
|
|
|
if (id == MAPSEC_BATTLE_FRONTIER || id == MAPSEC_ARTISAN_CAVE)
|
|
|
|
{
|
|
|
|
s8 mapNum = gSaveBlock1Ptr->location.mapNum;
|
|
|
|
|
|
|
|
if (mapNum == MAP_NUM(BATTLE_FRONTIER_OUTSIDE_WEST)
|
|
|
|
|| (mapNum == MAP_NUM(BATTLE_FRONTIER_OUTSIDE_EAST) && (x = 55)))
|
|
|
|
{
|
|
|
|
x += gSaveBlock1Ptr->pos.x;
|
|
|
|
y = gSaveBlock1Ptr->pos.y;
|
|
|
|
|
|
|
|
x /= 8;
|
|
|
|
y /= 8;
|
|
|
|
|
|
|
|
id = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
id = MapNumToFrontierFacilityId(mapNum);
|
2019-01-26 19:20:14 +01:00
|
|
|
if (id != 0)
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
x = sMapLandmarks[id - 1].x;
|
|
|
|
y = sMapLandmarks[id - 1].y;
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Handle Artisan Cave.
|
|
|
|
if (gSaveBlock1Ptr->escapeWarp.mapNum == MAP_NUM(BATTLE_FRONTIER_OUTSIDE_EAST))
|
|
|
|
x = gSaveBlock1Ptr->escapeWarp.x + 55;
|
|
|
|
else
|
|
|
|
x = gSaveBlock1Ptr->escapeWarp.x;
|
|
|
|
|
|
|
|
y = gSaveBlock1Ptr->escapeWarp.y;
|
|
|
|
|
|
|
|
x /= 8;
|
|
|
|
y /= 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
LoadCompressedSpriteSheet(sHeadsSpriteSheet);
|
2021-01-19 10:03:51 +01:00
|
|
|
sprite = sSpriteTemplate_PlayerHead;
|
|
|
|
sprite.paletteTag = gSaveBlock2Ptr->playerGender + TAG_HEAD_MALE; // TAG_HEAD_FEMALE if gender is FEMALE
|
2019-01-26 19:20:14 +01:00
|
|
|
if (id != 0)
|
|
|
|
{
|
|
|
|
spriteId = CreateSprite(&sprite, x, y, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x *= 8;
|
|
|
|
y *= 8;
|
|
|
|
spriteId = CreateSprite(&sprite, x + 20, y + 36, 0);
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sMapData->playerHeadSprite = &gSprites[spriteId];
|
|
|
|
sMapData->playerHeadSprite->oam.priority = 0;
|
2019-01-26 19:20:14 +01:00
|
|
|
if (gSaveBlock2Ptr->playerGender != MALE)
|
2019-01-26 20:56:06 +01:00
|
|
|
StartSpriteAnim(sMapData->playerHeadSprite, 1);
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void PrintOnFrontierMap(void)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
for (i = 0; i < MAP_WINDOW_COUNT; i++)
|
|
|
|
{
|
|
|
|
PutWindowTilemap(i);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(i, PIXEL_FILL(0));
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_FRONTIER_FACILITIES; i++)
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (i == sMapData->cursorPos)
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_NAME, FONT_NARROW, 4, (i * 16) + 1, sTextColors[2], 0, sMapLandmarks[i].name);
|
2019-01-26 19:20:14 +01:00
|
|
|
else
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_NAME, FONT_NARROW, 4, (i * 16) + 1, sTextColors[1], 0, sMapLandmarks[i].name);
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_DESCRIPTION, FONT_NORMAL, 4, 0, sTextColors[0], 0, sMapLandmarks[sMapData->cursorPos].description);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
|
|
|
for (i = 0; i < MAP_WINDOW_COUNT; i++)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(i, COPYWIN_FULL);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void HandleFrontierMapCursorMove(u8 direction)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
|
|
|
u8 oldCursorPos, i;
|
|
|
|
|
|
|
|
if (direction)
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
oldCursorPos = sMapData->cursorPos;
|
|
|
|
sMapData->cursorPos = (oldCursorPos + 6) % NUM_FRONTIER_FACILITIES;
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
oldCursorPos = sMapData->cursorPos;
|
|
|
|
sMapData->cursorPos = (oldCursorPos + 1) % NUM_FRONTIER_FACILITIES;
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_NAME, FONT_NARROW, 4, (oldCursorPos * 16) + 1, sTextColors[1], 0, sMapLandmarks[oldCursorPos].name);
|
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_NAME, FONT_NARROW, 4, (sMapData->cursorPos * 16) + 1, sTextColors[2], 0, sMapLandmarks[sMapData->cursorPos].name);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
sMapData->cursorSprite->y = (sMapData->cursorPos * 16) + 8;
|
2019-01-26 19:20:14 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
StartSpriteAnim(sMapData->mapIndicatorSprite, sMapLandmarks[sMapData->cursorPos].animNum);
|
2021-07-07 15:11:52 +02:00
|
|
|
sMapData->mapIndicatorSprite->x = sMapLandmarks[sMapData->cursorPos].x;
|
|
|
|
sMapData->mapIndicatorSprite->y = sMapLandmarks[sMapData->cursorPos].y;
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(MAP_WINDOW_DESCRIPTION, PIXEL_FILL(0));
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_DESCRIPTION, FONT_NORMAL, 4, 0, sTextColors[0], 0, sMapLandmarks[sMapData->cursorPos].description);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
2021-01-19 10:03:51 +01:00
|
|
|
for (i = 0; i < MAP_WINDOW_COUNT; i++)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(i, COPYWIN_FULL);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_DEX_SCROLL);
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|