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"
|
2019-01-26 19:20:14 +01:00
|
|
|
#include "constants/maps.h"
|
2019-01-25 23:32:45 +01:00
|
|
|
#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,
|
|
|
|
WINDOW_4,
|
|
|
|
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
|
|
|
|
{
|
|
|
|
MAP_WINDOW_0,
|
|
|
|
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,
|
|
|
|
CURSOR_AREA_EARNED_SYMBOLS, // The window.
|
|
|
|
CURSOR_AREA_SYMBOL, // All 7 symbols.
|
|
|
|
CURSOR_AREA_COUNT = CURSOR_AREA_SYMBOL + NUM_FRONTIER_FACILITIES,
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
u8 hasBattleRecord:1;
|
|
|
|
u8 unkE:3;
|
|
|
|
u8 trainerStars:4;
|
|
|
|
u8 facilitySymbols[NUM_FRONTIER_FACILITIES];
|
|
|
|
};
|
|
|
|
|
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];
|
2019-01-25 23:32:45 +01:00
|
|
|
u8 *unk20;
|
|
|
|
u8 *unk24;
|
|
|
|
u8 *unk28;
|
2019-01-26 14:50:24 +01:00
|
|
|
bool8 setAffine;
|
2019-01-25 23:32:45 +01:00
|
|
|
s16 unk2E;
|
|
|
|
s16 unk30;
|
|
|
|
u8 tilemapBuff1[0x1000];
|
|
|
|
u8 tilemapBuff2[0x1000];
|
|
|
|
u8 tilemapBuff3[0x400];
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
u8 tilemapBuff0[0x1000];
|
|
|
|
u8 tilemapBuff1[0x1000];
|
|
|
|
u8 tilemapBuff2[0x1000];
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
// This file's functions.
|
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);
|
|
|
|
static void sub_80C629C(void);
|
|
|
|
static void FreeCursorAndSymbolSprites(void);
|
|
|
|
static void LoadCursorAndSymbolSprites(void);
|
|
|
|
static u32 FreeFrontierPassData(void);
|
|
|
|
static bool32 InitFrontierPass(void);
|
|
|
|
static bool32 HideFrontierPass(void);
|
|
|
|
static void Task_HandleFrontierPassInput(u8 taskId);
|
|
|
|
static void Task_DoFadeEffect(u8 taskId);
|
|
|
|
static void sub_80C6104(u8 cursorArea, u8 previousCursorArea);
|
|
|
|
static void PrintAreaDescription(u8 cursorArea);
|
|
|
|
static void sub_80C5F58(bool8 arg0, bool8 arg1);
|
|
|
|
static void SpriteCb_Dummy(struct Sprite *sprite);
|
2019-01-25 23:32:45 +01:00
|
|
|
|
|
|
|
// Const rom data.
|
2019-01-26 20:56:06 +01:00
|
|
|
static const u16 sMaleHeadPalette[] = INCBIN_U16("graphics/frontier_pass/map_heads.gbapal");
|
|
|
|
static const u16 sFemaleHeadPalette[] = INCBIN_U16("graphics/frontier_pass/map_heads_female.gbapal");
|
|
|
|
static const u32 gUnknown_0856FBBC[] = INCBIN_U32("graphics/frontier_pass/map_screen.4bpp.lz");
|
|
|
|
static const u32 sCursorGfx[] = INCBIN_U32("graphics/frontier_pass/cursor.4bpp.lz");
|
|
|
|
static const u32 sHeadsGfx[] = INCBIN_U32("graphics/frontier_pass/map_heads.4bpp.lz");
|
|
|
|
static const u32 sMapCursorGfx[] = INCBIN_U32("graphics/frontier_pass/map_cursor.4bpp.lz");
|
|
|
|
static const u32 gUnknown_08570E00[] = INCBIN_U32("graphics/frontier_pass/map_screen.bin.lz");
|
|
|
|
static const u32 gUnknown_08571060[] = INCBIN_U32("graphics/frontier_pass/small_map_and_card.bin.lz");
|
|
|
|
static const u32 gUnknown_08571298[] = INCBIN_U32("graphics/frontier_pass/unknown_571298.bin");
|
|
|
|
static const u32 gUnknown_085712C0[] = INCBIN_U32("graphics/frontier_pass/record_frame.bin.lz");
|
|
|
|
static const u32 gUnknown_085712F8[] = INCBIN_U32("graphics/frontier_pass/small_map_and_card_affine.bin.lz");
|
|
|
|
|
|
|
|
static const s16 gUnknown_085713E0[][2] = {{216, 32}, {216, 128}};
|
|
|
|
|
|
|
|
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
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct WindowTemplate sPassWindowTemplates[] =
|
|
|
|
{
|
2019-01-26 22:09:24 +01:00
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 3,
|
|
|
|
.width = 12,
|
|
|
|
.height = 3,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 10,
|
|
|
|
.width = 12,
|
|
|
|
.height = 3,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x26,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 13,
|
|
|
|
.width = 12,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x4B,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.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[] =
|
|
|
|
{
|
2019-01-26 22:09:24 +01:00
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 0,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 15,
|
|
|
|
.height = 5,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 20,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 10,
|
|
|
|
.height = 14,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x4D,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.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] =
|
|
|
|
{
|
2019-12-10 19:48:20 +01:00
|
|
|
{TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY},
|
|
|
|
{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;
|
|
|
|
}
|
|
|
|
static const sPassAreasLayout[] =
|
|
|
|
{
|
|
|
|
{28, 76, 132, 220},
|
|
|
|
{84, 132, 132, 220},
|
|
|
|
{80, 102, 20, 108},
|
|
|
|
{0, 16, 152, 240},
|
|
|
|
{108, 134, 20, 108},
|
|
|
|
{24, 48, 20, 108},
|
|
|
|
{50, 66, 20, 36},
|
|
|
|
{66, 82, 32, 48},
|
|
|
|
{50, 66, 44, 60},
|
|
|
|
{66, 82, 56, 72},
|
|
|
|
{50, 66, 68, 84},
|
|
|
|
{66, 82, 80, 96},
|
|
|
|
{50, 66, 92, 108},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct CompressedSpriteSheet sCursorSpriteSheets[] =
|
|
|
|
{
|
|
|
|
{sCursorGfx, 0x100, 0},
|
|
|
|
{sMapCursorGfx, 0x400, 1},
|
|
|
|
{gFrontierPassMedals_Gfx, 0x380, 2},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct CompressedSpriteSheet sHeadsSpriteSheet[] =
|
|
|
|
{
|
|
|
|
{sHeadsGfx, 0x100, 4},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpritePalette sSpritePalettes[] =
|
|
|
|
{
|
|
|
|
{gFrontierPassCursor_Pal, 0},
|
|
|
|
{gFrontierPassMapCursor_Pal, 1},
|
|
|
|
{gFrontierPassMedalsSilver_Pal, 2},
|
|
|
|
{gFrontierPassMedalsGold_Pal, 3},
|
|
|
|
{sMaleHeadPalette, 4},
|
|
|
|
{sFemaleHeadPalette, 5},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_857151C[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_8571524[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_857152C[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(4, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_8571534[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(8, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_857153C[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(12, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_8571544[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(16, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_857154C[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(20, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_8571554[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(24, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_857155C[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 45),
|
|
|
|
ANIMCMD_FRAME(8, 45),
|
|
|
|
ANIMCMD_JUMP(0)
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_8571568[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(16, 45),
|
|
|
|
ANIMCMD_FRAME(24, 45),
|
|
|
|
ANIMCMD_JUMP(0)
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd *const sSpriteAnimTable_8571574[] =
|
|
|
|
{
|
|
|
|
sSpriteAnim_8571524,
|
|
|
|
sSpriteAnim_857152C
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd *const sSpriteAnimTable_857157C[] =
|
|
|
|
{
|
|
|
|
sSpriteAnim_8571524,
|
|
|
|
sSpriteAnim_857152C,
|
|
|
|
sSpriteAnim_8571534,
|
|
|
|
sSpriteAnim_857153C,
|
|
|
|
sSpriteAnim_8571544,
|
|
|
|
sSpriteAnim_857154C,
|
|
|
|
sSpriteAnim_8571554
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd *const sSpriteAnimTable_8571598[] =
|
|
|
|
{
|
|
|
|
sSpriteAnim_857155C,
|
|
|
|
sSpriteAnim_8571568
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AffineAnimCmd sSpriteAffineAnim_85715A0[] =
|
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AffineAnimCmd *const sSpriteAffineAnimTable_85715B0[] =
|
|
|
|
{
|
|
|
|
sSpriteAffineAnim_85715A0
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteTemplate sSpriteTemplates_Cursors[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.tileTag = 0,
|
|
|
|
.paletteTag = 0,
|
2019-10-15 01:26:47 +02:00
|
|
|
.oam = &gOamData_AffineOff_ObjNormal_16x16,
|
2019-01-26 20:56:06 +01:00
|
|
|
.anims = sSpriteAnimTable_8571574,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.tileTag = 1,
|
|
|
|
.paletteTag = 1,
|
2019-10-15 01:26:47 +02:00
|
|
|
.oam = &gOamData_AffineOff_ObjNormal_32x16,
|
2019-01-26 20:56:06 +01:00
|
|
|
.anims = sSpriteAnimTable_8571598,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Medal =
|
|
|
|
{
|
|
|
|
.tileTag = 2,
|
|
|
|
.paletteTag = 2,
|
2019-10-15 01:26:47 +02:00
|
|
|
.oam = &gOamData_AffineOff_ObjNormal_16x16,
|
2019-01-26 20:56:06 +01:00
|
|
|
.anims = sSpriteAnimTable_857157C,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Head =
|
|
|
|
{
|
|
|
|
.tileTag = 4,
|
|
|
|
.paletteTag = 4,
|
2019-10-15 01:26:47 +02:00
|
|
|
.oam = &gOamData_AffineOff_ObjNormal_16x16,
|
2019-01-26 20:56:06 +01:00
|
|
|
.anims = sSpriteAnimTable_8571574,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCb_Dummy,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 *const sPassAreaDescriptions[] =
|
|
|
|
{
|
2019-12-10 19:48:20 +01:00
|
|
|
gText_ThereIsNoBattleRecord,
|
|
|
|
gText_CheckFrontierMap,
|
|
|
|
gText_CheckTrainerCard,
|
|
|
|
gText_ViewRecordedBattle,
|
|
|
|
gText_PutAwayFrontierPass,
|
|
|
|
gText_CurrentBattlePoints,
|
|
|
|
gText_CollectedSymbols,
|
|
|
|
gText_BattleTowerAbilitySymbol,
|
|
|
|
gText_BattleDomeTacticsSymbol,
|
|
|
|
gText_BattlePalaceSpiritsSymbol,
|
|
|
|
gText_BattleArenaGutsSymbol,
|
|
|
|
gText_BattleFactoryKnowledgeSymbol,
|
|
|
|
gText_BattlePikeLuckSymbol,
|
|
|
|
gText_BattlePyramidBraveSymbol,
|
|
|
|
gText_EmptyString7,
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
const u8 *name;
|
|
|
|
const u8 *description;
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
u8 animNum;
|
|
|
|
} static const sMapLandmarks[] =
|
|
|
|
{
|
2019-12-10 19:48:20 +01:00
|
|
|
{gText_BattleTower3, gText_BattleTowerDesc, 0x59, 0x28, 1},
|
|
|
|
{gText_BattleDome2, gText_BattleDomeDesc, 0x21, 0x2A, 1},
|
|
|
|
{gText_BattlePalace2, gText_BattlePalaceDesc, 0x78, 0x56, 0},
|
|
|
|
{gText_BattleArena2, gText_BattleArenaDesc, 0x72, 0x3B, 0},
|
|
|
|
{gText_BattleFactory2, gText_BattleFactoryDesc, 0x19, 0x43, 0},
|
|
|
|
{gText_BattlePike2, gText_BattlePikeDesc, 0x39, 0x39, 1},
|
|
|
|
{gText_BattlePyramid2, gText_BattlePyramidDesc, 0x86, 0x29, 1},
|
2019-01-26 20:56:06 +01:00
|
|
|
};
|
2019-01-25 23:32:45 +01:00
|
|
|
|
|
|
|
// code
|
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);
|
|
|
|
ChangeBgX(0, 0, 0);
|
|
|
|
ChangeBgY(0, 0, 0);
|
|
|
|
ChangeBgX(1, 0, 0);
|
|
|
|
ChangeBgY(1, 0, 0);
|
|
|
|
ChangeBgX(2, 0, 0);
|
|
|
|
ChangeBgY(2, 0, 0);
|
|
|
|
ChangeBgX(3, 0, 0);
|
|
|
|
ChangeBgY(3, 0, 0);
|
|
|
|
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)
|
2019-01-25 23:32:45 +01:00
|
|
|
return 1;
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData = AllocZeroed(sizeof(*sPassData));
|
|
|
|
if (sPassData == NULL)
|
2019-01-25 23:32:45 +01:00
|
|
|
return 2;
|
|
|
|
|
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)
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->cursorX = 176;
|
|
|
|
sPassData->cursorY = 104;
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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();
|
|
|
|
sPassData->unkE = 0;
|
|
|
|
sPassData->trainerStars = CountPlayerTrainerStars();
|
2019-01-25 23:32:45 +01:00
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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)
|
2019-01-25 23:32:45 +01:00
|
|
|
return 1;
|
|
|
|
|
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);
|
2019-01-25 23:32:45 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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)
|
2019-01-25 23:32:45 +01:00
|
|
|
return 1;
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassGfx = AllocZeroed(sizeof(*sPassGfx));
|
|
|
|
if (sPassGfx == NULL)
|
2019-01-25 23:32:45 +01:00
|
|
|
return 2;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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)
|
2019-01-25 23:32:45 +01:00
|
|
|
return 1;
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassGfx->unk28 != NULL)
|
|
|
|
FREE_AND_SET_NULL(sPassGfx->unk28);
|
|
|
|
if (sPassGfx->unk24 != NULL)
|
|
|
|
FREE_AND_SET_NULL(sPassGfx->unk24);
|
|
|
|
if (sPassGfx->unk20 != NULL)
|
|
|
|
FREE_AND_SET_NULL(sPassGfx->unk20);
|
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);
|
2019-01-25 23:32:45 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void VblankCb_FrontierPass(void)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassGfx->setAffine)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
SetBgAffine(2,
|
2019-01-26 20:56:06 +01:00
|
|
|
gUnknown_085713E0[sPassData->unkE - 1][0] << 8,
|
|
|
|
gUnknown_085713E0[sPassData->unkE - 1][1] << 8,
|
|
|
|
gUnknown_085713E0[sPassData->unkE - 1][0],
|
|
|
|
gUnknown_085713E0[sPassData->unkE - 1][1],
|
|
|
|
sPassGfx->unk2E,
|
|
|
|
sPassGfx->unk30,
|
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:
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassGfx->unk20 = malloc_and_decompress(gUnknown_085712F8, &sizeOut);
|
|
|
|
sPassGfx->unk24 = malloc_and_decompress(gUnknown_08571060, &sizeOut);
|
|
|
|
sPassGfx->unk28 = malloc_and_decompress(gUnknown_085712C0, &sizeOut);
|
2020-05-14 10:37:09 +02:00
|
|
|
DecompressAndCopyTileDataToVram(1, gUnknown_08DE08C8, 0, 0, 0);
|
|
|
|
DecompressAndCopyTileDataToVram(2, gUnknown_08DE2084, 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:
|
|
|
|
LoadPalette(gUnknown_08DE07C8[0], 0, 0x1A0);
|
2019-01-26 20:56:06 +01:00
|
|
|
LoadPalette(gUnknown_08DE07C8[1 + sPassData->trainerStars], 0x10, 0x20);
|
2020-08-07 08:00:41 +02:00
|
|
|
LoadPalette(GetTextWindowPalette(0), 0xF0, 0x20);
|
2019-01-25 23:32:45 +01:00
|
|
|
sub_80C629C();
|
2019-01-26 20:56:06 +01:00
|
|
|
sub_80C6104(sPassData->cursorArea, sPassData->previousCursorArea);
|
|
|
|
if (sPassData->unkE == 1 || sPassData->unkE == 2)
|
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();
|
|
|
|
SetVBlankCallback(VblankCb_FrontierPass);
|
2019-01-26 22:09:24 +01:00
|
|
|
BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK);
|
2019-01-25 23:32:45 +01:00
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK);
|
|
|
|
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:
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassData->unkE != 1 && sPassData->unkE != 2)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
|
|
|
// Minus/Plus 1, because the table doesn't take into account the nothing field.
|
|
|
|
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
|
|
|
|
&& 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 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;
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
switch (sPassData->unkE)
|
2019-01-25 23:32:45 +01:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2019-01-26 14:50:24 +01:00
|
|
|
taskId = CreateTask(Task_DoFadeEffect, 0);
|
|
|
|
gTasks[taskId].data[0] = TRUE;
|
2019-01-25 23:32:45 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
default:
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->unkE = 0;
|
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:
|
|
|
|
PlayBGM(MUS_PYRAMID);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
PlayBGM(MUS_PYRAMID_TOP);
|
|
|
|
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;
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
switch (sPassData->unkE)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
ShowFrontierMap(CB2_ReshowFrontierPass);
|
|
|
|
break;
|
|
|
|
case 3:
|
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;
|
|
|
|
case 2:
|
|
|
|
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;
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->unkE = 3;
|
2019-01-26 14:50:24 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
SetMainCallback2(CB2_ShowFrontierPassFeature);
|
|
|
|
break;
|
|
|
|
case CURSOR_AREA_MAP:
|
|
|
|
case CURSOR_AREA_CARD:
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->unkE = cursorArea;
|
2019-01-26 14:50:24 +01:00
|
|
|
gTasks[taskId].func = Task_DoFadeEffect;
|
|
|
|
gTasks[taskId].data[0] = FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->cursorX = sPassGfx->cursorSprite->pos1.x;
|
|
|
|
sPassData->cursorY = sPassGfx->cursorSprite->pos1.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.
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
if (gMain.heldKeys & DPAD_UP && sPassGfx->cursorSprite->pos1.y >= 9)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassGfx->cursorSprite->pos1.y -= 2;
|
|
|
|
if (sPassGfx->cursorSprite->pos1.y <= 7)
|
|
|
|
sPassGfx->cursorSprite->pos1.y = 2;
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
}
|
2019-01-26 20:56:06 +01:00
|
|
|
if (gMain.heldKeys & DPAD_DOWN && sPassGfx->cursorSprite->pos1.y <= 135)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassGfx->cursorSprite->pos1.y += 2;
|
|
|
|
if (sPassGfx->cursorSprite->pos1.y >= 137)
|
|
|
|
sPassGfx->cursorSprite->pos1.y = 136;
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
if (gMain.heldKeys & DPAD_LEFT && sPassGfx->cursorSprite->pos1.x >= 6)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassGfx->cursorSprite->pos1.x -= 2;
|
|
|
|
if (sPassGfx->cursorSprite->pos1.x <= 4)
|
|
|
|
sPassGfx->cursorSprite->pos1.x = 5;
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
}
|
2019-01-26 20:56:06 +01:00
|
|
|
if (gMain.heldKeys & DPAD_RIGHT && sPassGfx->cursorSprite->pos1.x <= 231)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassGfx->cursorSprite->pos1.x += 2;
|
|
|
|
if (sPassGfx->cursorSprite->pos1.x >= 233)
|
|
|
|
sPassGfx->cursorSprite->pos1.x = 232;
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!var) // Cursor did not change.
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassData->cursorArea != CURSOR_AREA_NOTHING && gMain.newKeys & 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.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gMain.newKeys & B_BUTTON)
|
|
|
|
{
|
|
|
|
PlaySE(SE_PC_OFF);
|
|
|
|
SetMainCallback2(CB2_HideFrontierPass);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
var = GetCursorAreaFromCoords(sPassGfx->cursorSprite->pos1.x - 5, sPassGfx->cursorSprite->pos1.y + 5);
|
|
|
|
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;
|
|
|
|
sub_80C6104(sPassData->cursorArea, sPassData->previousCursorArea);
|
2019-01-26 14:50:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void Task_DoFadeEffect(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:
|
|
|
|
if (!data[0])
|
|
|
|
{
|
|
|
|
sub_80C5F58(TRUE, FALSE);
|
2020-05-20 21:23:21 +02:00
|
|
|
data[1] = Q_8_8(1);
|
|
|
|
data[2] = Q_8_8(1);
|
2019-01-26 14:50:24 +01:00
|
|
|
data[3] = 0x15;
|
|
|
|
data[4] = 0x15;
|
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_WHITE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-20 21:23:21 +02:00
|
|
|
data[1] = Q_8_8(1.984375); // 1 and 63/64
|
|
|
|
data[2] = Q_8_8(1.984375);
|
2019-01-26 14:50:24 +01:00
|
|
|
data[3] = -0x15;
|
|
|
|
data[4] = -0x15;
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
|
|
|
ShowBg(0);
|
|
|
|
ShowBg(1);
|
|
|
|
ShowBg(2);
|
|
|
|
LoadCursorAndSymbolSprites();
|
|
|
|
SetVBlankCallback(VblankCb_FrontierPass);
|
|
|
|
BlendPalettes(0xFFFFFFFF, 0x10, RGB_WHITE);
|
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_WHITE);
|
|
|
|
}
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassGfx->setAffine = TRUE;
|
2020-05-20 20:22:41 +02:00
|
|
|
sPassGfx->unk2E = MathUtil_Inv16(data[1]);
|
|
|
|
sPassGfx->unk30 = MathUtil_Inv16(data[2]);
|
2019-01-26 14:50:24 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
UpdatePaletteFade();
|
|
|
|
data[1] += data[3];
|
|
|
|
data[2] += data[4];
|
2020-05-20 20:22:41 +02:00
|
|
|
sPassGfx->unk2E = MathUtil_Inv16(data[1]);
|
|
|
|
sPassGfx->unk30 = MathUtil_Inv16(data[2]);
|
2019-01-26 14:50:24 +01:00
|
|
|
if (!data[0])
|
|
|
|
{
|
2020-05-20 21:23:21 +02:00
|
|
|
if (data[1] <= Q_8_8(1.984375))
|
2019-01-26 14:50:24 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-20 21:23:21 +02:00
|
|
|
if (data[1] != Q_8_8(1))
|
2019-01-26 14:50:24 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sPassGfx->setAffine) // Nonsensical check.
|
|
|
|
sPassGfx->setAffine = FALSE;
|
2019-01-26 14:50:24 +01:00
|
|
|
if (UpdatePaletteFade())
|
|
|
|
return;
|
|
|
|
if (!data[0])
|
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
SetMainCallback2(CB2_ShowFrontierPassFeature);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_80C5F58(FALSE, FALSE);
|
2019-01-26 20:56:06 +01:00
|
|
|
sPassData->unkE = 0;
|
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
|
|
|
}
|
|
|
|
|
2019-01-26 22:09:24 +01:00
|
|
|
x = GetStringCenterAlignXOffset(1, gText_SymbolsEarned, 96);
|
2019-01-26 20:56:06 +01:00
|
|
|
AddTextPrinterParameterized3(WINDOW_EARNED_SYMBOLS, 1, x, 5, sTextColors[0], 0, gText_SymbolsEarned);
|
2019-01-26 14:50:24 +01:00
|
|
|
|
2019-01-26 22:09:24 +01:00
|
|
|
x = GetStringCenterAlignXOffset(1, gText_BattleRecord, 96);
|
2019-01-26 20:56:06 +01:00
|
|
|
AddTextPrinterParameterized3(WINDOW_BATTLE_RECORD, 1, x, 5, sTextColors[0], 0, gText_BattleRecord);
|
2019-01-26 14:50:24 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
AddTextPrinterParameterized3(WINDOW_BATTLE_POINTS, 8, 5, 4, sTextColors[0], 0, gText_BattlePoints);
|
|
|
|
ConvertIntToDecimalStringN(gStringVar4, sPassData->battlePoints, STR_CONV_MODE_LEFT_ALIGN, 5);
|
2019-01-26 22:09:24 +01:00
|
|
|
x = GetStringRightAlignXOffset(8, gStringVar4, 91);
|
2019-01-26 20:56:06 +01:00
|
|
|
AddTextPrinterParameterized3(WINDOW_BATTLE_POINTS, 8, 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++)
|
|
|
|
CopyWindowToVram(i, 3);
|
|
|
|
|
|
|
|
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));
|
2019-01-26 20:56:06 +01:00
|
|
|
if (cursorArea == CURSOR_AREA_RECORD && !sPassData->hasBattleRecord)
|
|
|
|
AddTextPrinterParameterized3(WINDOW_DESCRIPTION, 1, 2, 0, sTextColors[1], 0, sPassAreaDescriptions[0]);
|
2019-01-26 14:50:24 +01:00
|
|
|
else if (cursorArea != CURSOR_AREA_NOTHING)
|
2019-01-26 20:56:06 +01:00
|
|
|
AddTextPrinterParameterized3(WINDOW_DESCRIPTION, 1, 2, 0, sTextColors[1], 0, sPassAreaDescriptions[cursorArea]);
|
2019-01-26 14:50:24 +01:00
|
|
|
|
|
|
|
CopyWindowToVram(WINDOW_DESCRIPTION, 3);
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void sub_80C5F58(bool8 arg0, bool8 arg1)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
switch (sPassData->unkE)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
if (arg0)
|
2019-01-26 20:56:06 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(2, sPassGfx->unk20, 16, 3, 12, 7, 16);
|
2019-01-26 14:50:24 +01:00
|
|
|
else
|
|
|
|
FillBgTilemapBufferRect(2, 0, 16, 3, 12, 7, 16);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (arg0)
|
2019-01-26 20:56:06 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(2, sPassGfx->unk20 + 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);
|
|
|
|
if (arg1)
|
|
|
|
{
|
|
|
|
SetBgAffine(2,
|
2019-01-26 20:56:06 +01:00
|
|
|
gUnknown_085713E0[sPassData->unkE - 1][0] << 8,
|
|
|
|
gUnknown_085713E0[sPassData->unkE - 1][1] << 8,
|
|
|
|
gUnknown_085713E0[sPassData->unkE - 1][0],
|
|
|
|
gUnknown_085713E0[sPassData->unkE - 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,
|
2019-01-26 20:56:06 +01:00
|
|
|
gUnknown_085713E0[sPassData->unkE - 1][0] << 8,
|
|
|
|
gUnknown_085713E0[sPassData->unkE - 1][1] << 8,
|
|
|
|
gUnknown_085713E0[sPassData->unkE - 1][0],
|
|
|
|
gUnknown_085713E0[sPassData->unkE - 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void sub_80C6104(u8 cursorArea, u8 previousCursorArea)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
bool32 var;
|
|
|
|
|
|
|
|
switch (previousCursorArea)
|
|
|
|
{
|
|
|
|
case CURSOR_AREA_MAP:
|
2019-01-26 20:56:06 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->unk24, 16, 3, 12, 7, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
break;
|
|
|
|
case CURSOR_AREA_CARD:
|
2019-01-26 20:56:06 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->unk24 + 336, 16, 10, 12, 7, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
break;
|
|
|
|
case CURSOR_AREA_RECORD:
|
2019-01-26 20:56:06 +01:00
|
|
|
if (!sPassData->hasBattleRecord)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
var = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->unk28, 2, 10, 12, 3, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CURSOR_AREA_CANCEL:
|
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_08DE3350, 21, 0, 9, 2, 17);
|
|
|
|
var = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
var = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!var)
|
|
|
|
{
|
|
|
|
if (cursorArea == CURSOR_AREA_NOTHING || cursorArea > CURSOR_AREA_CANCEL)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (cursorArea)
|
|
|
|
{
|
|
|
|
case CURSOR_AREA_MAP:
|
2019-01-26 20:56:06 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->unk24 + 168, 16, 3, 12, 7, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
break;
|
|
|
|
case CURSOR_AREA_CARD:
|
2019-01-26 20:56:06 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->unk24 + 504, 16, 10, 12, 7, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
break;
|
|
|
|
case CURSOR_AREA_RECORD:
|
2019-01-26 20:56:06 +01:00
|
|
|
if (!sPassData->hasBattleRecord)
|
2019-01-26 14:50:24 +01:00
|
|
|
return;
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, sPassGfx->unk28 + 72, 2, 10, 12, 3, 17);
|
2019-01-26 14:50:24 +01:00
|
|
|
var = TRUE;
|
|
|
|
break;
|
|
|
|
case CURSOR_AREA_CANCEL:
|
|
|
|
CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_08DE3374, 21, 0, 9, 2, 17);
|
|
|
|
var = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
var = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!var)
|
|
|
|
{
|
|
|
|
asm("":::"r4");
|
|
|
|
if (previousCursorArea == CURSOR_AREA_NOTHING || previousCursorArea > CURSOR_AREA_CANCEL)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void sub_80C629C(void)
|
2019-01-26 14:50:24 +01:00
|
|
|
{
|
|
|
|
CopyToBgTilemapBuffer(1, gUnknown_08DE3060, 0, 0);
|
2019-01-26 20:56:06 +01:00
|
|
|
sub_80C6104(sPassData->cursorArea, sPassData->previousCursorArea);
|
|
|
|
sub_80C5F58(TRUE, sPassData->unkE);
|
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
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sprite.paletteTag += sPassData->facilitySymbols[i] - 1;
|
|
|
|
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();
|
|
|
|
FreeSpriteTilesByTag(2);
|
|
|
|
FreeSpriteTilesByTag(0);
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
static void SpriteCb_Dummy(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();
|
2020-05-14 10:37:09 +02:00
|
|
|
DecompressAndCopyTileDataToVram(1, gUnknown_0856FBBC, 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;
|
|
|
|
LoadPalette(gUnknown_08DE07C8[0], 0, 0x1A0);
|
2020-08-07 08:00:41 +02:00
|
|
|
LoadPalette(GetTextWindowPalette(0), 0xF0, 0x20);
|
2019-01-26 19:20:14 +01:00
|
|
|
CopyToBgTilemapBuffer(2, gUnknown_08570E00, 0, 0);
|
|
|
|
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();
|
2019-01-26 19:20:14 +01:00
|
|
|
SetVBlankCallback(VblankCb_FrontierPass);
|
|
|
|
BlendPalettes(0xFFFFFFFF, 0x10, RGB_WHITE);
|
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_WHITE);
|
|
|
|
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:
|
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_WHITE);
|
|
|
|
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);
|
2019-01-26 19:20:14 +01:00
|
|
|
FreeSpriteTilesByTag(0);
|
|
|
|
}
|
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);
|
2019-01-26 19:20:14 +01:00
|
|
|
FreeSpriteTilesByTag(1);
|
|
|
|
}
|
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);
|
2019-01-26 19:20:14 +01:00
|
|
|
FreeSpriteTilesByTag(4);
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
switch (data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
2019-01-26 20:56:06 +01:00
|
|
|
if (InitFrontierMap())
|
2019-01-26 19:20:14 +01:00
|
|
|
break;
|
|
|
|
return;
|
|
|
|
case 1:
|
|
|
|
if (gMain.newKeys & B_BUTTON)
|
|
|
|
{
|
|
|
|
PlaySE(SE_PC_OFF);
|
|
|
|
data[0] = 4;
|
|
|
|
}
|
|
|
|
else if (gMain.newKeys & DPAD_DOWN)
|
|
|
|
{
|
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
|
|
|
|
data[0] = 2;
|
|
|
|
}
|
|
|
|
else if (gMain.newKeys & DPAD_UP)
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
if (sMapData->cursorPos == 0)
|
|
|
|
HandleFrontierMapCursorMove(1);
|
2019-01-26 19:20:14 +01:00
|
|
|
else
|
|
|
|
data[0] = 3;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 2:
|
|
|
|
if (data[1] > 3)
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
HandleFrontierMapCursorMove(0);
|
2019-01-26 19:20:14 +01:00
|
|
|
data[1] = 0;
|
|
|
|
data[0] = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
sMapData->cursorSprite->pos1.y += 4;
|
2019-01-26 19:20:14 +01:00
|
|
|
data[1]++;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 3:
|
|
|
|
if (data[1] > 3)
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
HandleFrontierMapCursorMove(1);
|
2019-01-26 19:20:14 +01:00
|
|
|
data[1] = 0;
|
|
|
|
data[0] = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-26 20:56:06 +01:00
|
|
|
sMapData->cursorSprite->pos1.y -= 4;
|
2019-01-26 19:20:14 +01:00
|
|
|
data[1]++;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
data[0]++;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
if ((mapNum >= MAP_NUM(BATTLE_FRONTIER_BATTLE_TOWER_LOBBY) && mapNum <= MAP_NUM(BATTLE_FRONTIER_BATTLE_TOWER_BATTLE_ROOM))
|
2019-12-14 09:58:20 +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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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);
|
|
|
|
sprite = sSpriteTemplate_Head;
|
2019-01-26 19:20:14 +01:00
|
|
|
sprite.paletteTag = gSaveBlock2Ptr->playerGender + 4;
|
|
|
|
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)
|
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_NAME, 7, 4, (i * 16) + 1, sTextColors[2], 0, sMapLandmarks[i].name);
|
2019-01-26 19:20:14 +01:00
|
|
|
else
|
2019-01-26 20:56:06 +01:00
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_NAME, 7, 4, (i * 16) + 1, sTextColors[1], 0, sMapLandmarks[i].name);
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_DESCRIPTION, 1, 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++)
|
|
|
|
CopyWindowToVram(i, 3);
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_NAME, 7, 4, (oldCursorPos * 16) + 1, sTextColors[1], 0, sMapLandmarks[oldCursorPos].name);
|
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_NAME, 7, 4, (sMapData->cursorPos * 16) + 1, sTextColors[2], 0, sMapLandmarks[sMapData->cursorPos].name);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
sMapData->cursorSprite->pos1.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);
|
|
|
|
sMapData->mapIndicatorSprite->pos1.x = sMapLandmarks[sMapData->cursorPos].x;
|
|
|
|
sMapData->mapIndicatorSprite->pos1.y = sMapLandmarks[sMapData->cursorPos].y;
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(MAP_WINDOW_DESCRIPTION, PIXEL_FILL(0));
|
2019-01-26 20:56:06 +01:00
|
|
|
AddTextPrinterParameterized3(MAP_WINDOW_DESCRIPTION, 1, 4, 0, sTextColors[0], 0, sMapLandmarks[sMapData->cursorPos].description);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
CopyWindowToVram(i, 3);
|
|
|
|
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
PlaySE(SE_Z_SCROLL);
|
2019-01-25 23:32:45 +01:00
|
|
|
}
|