pokeemerald/src/battle_bg.c

1452 lines
46 KiB
C
Raw Normal View History

2017-12-17 20:10:57 +01:00
#include "global.h"
#include "battle.h"
2020-11-18 03:45:27 +01:00
#include "battle_anim.h"
2018-09-12 00:37:47 +02:00
#include "battle_bg.h"
#include "battle_main.h"
#include "battle_message.h"
#include "battle_setup.h"
2017-12-17 20:10:57 +01:00
#include "bg.h"
2019-04-05 00:05:51 +02:00
#include "data.h"
2018-09-12 00:37:47 +02:00
#include "decompress.h"
2017-12-17 20:10:57 +01:00
#include "gpu_regs.h"
2018-09-12 00:37:47 +02:00
#include "graphics.h"
2017-12-17 20:10:57 +01:00
#include "link.h"
2018-09-12 00:37:47 +02:00
#include "main.h"
#include "menu.h"
2018-12-23 14:52:47 +01:00
#include "overworld.h"
2018-09-12 00:37:47 +02:00
#include "palette.h"
#include "sound.h"
#include "sprite.h"
2017-12-17 20:10:57 +01:00
#include "task.h"
2018-09-12 00:37:47 +02:00
#include "text_window.h"
2017-12-17 20:10:57 +01:00
#include "trig.h"
#include "window.h"
2018-07-13 05:39:38 +02:00
#include "constants/map_types.h"
2018-09-12 00:37:47 +02:00
#include "constants/songs.h"
#include "constants/trainers.h"
2020-11-18 03:45:27 +01:00
#include "constants/battle_anim.h"
2017-12-17 20:10:57 +01:00
#if !P_ENABLE_DEBUG
2017-12-17 20:10:57 +01:00
struct BattleBackground
{
const void *tileset;
const void *tilemap;
const void *entryTileset;
const void *entryTilemap;
const void *palette;
};
#endif
2017-12-17 20:10:57 +01:00
2018-09-12 00:37:47 +02:00
// .rodata
static const u16 sUnrefArray[] = {0x0300, 0x0000}; //OamData?
2019-11-07 01:18:11 +01:00
static const struct OamData sVsLetter_V_OamData =
2018-09-12 00:37:47 +02:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_DOUBLE,
.objMode = ST_OAM_OBJ_NORMAL,
2022-07-30 03:27:39 +02:00
.mosaic = FALSE,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(64x64),
2018-09-12 00:37:47 +02:00
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(64x64),
2018-09-12 00:37:47 +02:00
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
2019-11-07 01:18:11 +01:00
static const struct OamData sVsLetter_S_OamData =
2018-09-12 00:37:47 +02:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_DOUBLE,
.objMode = ST_OAM_OBJ_NORMAL,
2022-07-30 03:27:39 +02:00
.mosaic = FALSE,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(64x64),
2018-09-12 00:37:47 +02:00
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(64x64),
2018-09-12 00:37:47 +02:00
.tileNum = 64,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
2019-11-07 01:18:11 +01:00
static const union AffineAnimCmd sVsLetterAffineAnimCmds0[] =
2018-09-12 00:37:47 +02:00
{
AFFINEANIMCMD_FRAME(0x0080, 0x0080, 0x00, 0x00),
AFFINEANIMCMD_END,
};
2019-11-07 01:18:11 +01:00
static const union AffineAnimCmd sVsLetterAffineAnimCmds1[] =
2018-09-12 00:37:47 +02:00
{
AFFINEANIMCMD_FRAME(0x0080, 0x0080, 0x00, 0x00),
AFFINEANIMCMD_FRAME(0x0018, 0x0018, 0x00, 0x80),
AFFINEANIMCMD_FRAME(0x0018, 0x0018, 0x00, 0x80),
AFFINEANIMCMD_END,
};
2019-11-07 01:18:11 +01:00
static const union AffineAnimCmd *const sVsLetterAffineAnimTable[] =
2018-09-12 00:37:47 +02:00
{
2019-11-07 01:18:11 +01:00
sVsLetterAffineAnimCmds0,
sVsLetterAffineAnimCmds1,
2018-09-12 00:37:47 +02:00
};
2019-11-07 01:18:11 +01:00
#define TAG_VS_LETTERS 10000
static const struct SpriteTemplate sVsLetter_V_SpriteTemplate =
2018-09-12 00:37:47 +02:00
{
2019-11-07 01:18:11 +01:00
.tileTag = TAG_VS_LETTERS,
.paletteTag = TAG_VS_LETTERS,
.oam = &sVsLetter_V_OamData,
2018-09-12 00:37:47 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
2019-11-07 01:18:11 +01:00
.affineAnims = sVsLetterAffineAnimTable,
2021-01-23 05:22:37 +01:00
.callback = SpriteCB_VsLetterDummy
2018-09-12 00:37:47 +02:00
};
2019-11-07 01:18:11 +01:00
static const struct SpriteTemplate sVsLetter_S_SpriteTemplate =
2018-09-12 00:37:47 +02:00
{
2019-11-07 01:18:11 +01:00
.tileTag = TAG_VS_LETTERS,
.paletteTag = TAG_VS_LETTERS,
.oam = &sVsLetter_S_OamData,
2018-09-12 00:37:47 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
2019-11-07 01:18:11 +01:00
.affineAnims = sVsLetterAffineAnimTable,
2021-01-23 05:22:37 +01:00
.callback = SpriteCB_VsLetterDummy
2018-09-12 00:37:47 +02:00
};
2019-11-07 01:18:11 +01:00
static const struct CompressedSpriteSheet sVsLettersSpriteSheet =
2018-09-12 00:37:47 +02:00
{
2019-11-07 01:18:11 +01:00
gVsLettersGfx, 0x1000, TAG_VS_LETTERS
2018-09-12 00:37:47 +02:00
};
const struct BgTemplate gBattleBgTemplates[] =
{
{
.bg = 0,
.charBaseIndex = 0,
.mapBaseIndex = 24,
.screenSize = 2,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 28,
.screenSize = 2,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 2,
.charBaseIndex = 1,
.mapBaseIndex = 30,
.screenSize = 1,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 2,
.mapBaseIndex = 26,
.screenSize = 1,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
},
};
2022-05-17 19:51:54 +02:00
static const struct WindowTemplate sStandardBattleWindowTemplates[] =
2018-09-12 00:37:47 +02:00
{
2021-10-08 22:50:52 +02:00
[B_WIN_MSG] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 15,
.width = 26,
.height = 4,
.paletteNum = 0,
.baseBlock = 0x0090,
},
2021-10-08 22:50:52 +02:00
[B_WIN_ACTION_PROMPT] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 1,
.tilemapTop = 35,
.width = 14,
.height = 4,
.paletteNum = 0,
.baseBlock = 0x01c0,
},
2021-10-08 22:50:52 +02:00
[B_WIN_ACTION_MENU] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 17,
.tilemapTop = 35,
.width = 12,
.height = 4,
.paletteNum = 5,
.baseBlock = 0x0190,
},
2021-10-08 22:50:52 +02:00
[B_WIN_MOVE_NAME_1] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 55,
.width = 12, //for z move names
2018-09-12 00:37:47 +02:00
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0300,
},
2021-10-08 22:50:52 +02:00
[B_WIN_MOVE_NAME_2] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 11,
.tilemapTop = 55,
.width = 8,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0318,
2018-09-12 00:37:47 +02:00
},
2021-10-08 22:50:52 +02:00
[B_WIN_MOVE_NAME_3] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 57,
.width = 8,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0328,
2018-09-12 00:37:47 +02:00
},
2021-10-08 22:50:52 +02:00
[B_WIN_MOVE_NAME_4] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 11,
.tilemapTop = 57,
.width = 8,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0338,
2018-09-12 00:37:47 +02:00
},
2021-10-08 22:50:52 +02:00
[B_WIN_PP] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 21,
.tilemapTop = 55,
.width = 4,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0290,
},
2021-10-08 22:50:52 +02:00
[B_WIN_DUMMY] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 21,
.tilemapTop = 57,
.width = 0,
.height = 0,
.paletteNum = 5,
.baseBlock = 0x0298,
},
2021-10-08 22:50:52 +02:00
[B_WIN_PP_REMAINING] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 25,
.tilemapTop = 55,
.width = 4,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0298,
},
2021-10-08 22:50:52 +02:00
[B_WIN_MOVE_TYPE] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 21,
.tilemapTop = 57,
.width = 8,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x02a0,
},
2021-10-08 22:50:52 +02:00
[B_WIN_SWITCH_PROMPT] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 21,
.tilemapTop = 55,
.width = 8,
.height = 4,
.paletteNum = 5,
.baseBlock = 0x02b0,
},
2021-10-08 22:50:52 +02:00
[B_WIN_YESNO] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 26,
.tilemapTop = 9,
.width = 3,
.height = 4,
.paletteNum = 5,
.baseBlock = 0x0100,
},
2021-10-08 22:50:52 +02:00
[B_WIN_LEVEL_UP_BOX] = {
2018-10-27 00:53:07 +02:00
.bg = 1,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 19,
.tilemapTop = 8,
.width = 10,
.height = 11,
.paletteNum = 5,
.baseBlock = 0x0100,
},
2021-10-08 22:50:52 +02:00
[B_WIN_LEVEL_UP_BANNER] = {
2018-10-27 00:53:07 +02:00
.bg = 2,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 18,
.tilemapTop = 0,
.width = 12,
.height = 3,
.paletteNum = 6,
.baseBlock = 0x016e,
},
2021-10-08 22:50:52 +02:00
[B_WIN_VS_PLAYER] = {
2018-10-27 00:53:07 +02:00
.bg = 1,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 3,
.width = 6,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0020,
},
2021-10-08 22:50:52 +02:00
[B_WIN_VS_OPPONENT] = {
2018-10-27 00:53:07 +02:00
.bg = 2,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 3,
.width = 6,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0040,
},
2021-10-08 22:50:52 +02:00
[B_WIN_VS_MULTI_PLAYER_1] = {
2018-10-27 00:53:07 +02:00
.bg = 1,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 2,
.width = 6,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0020,
},
2021-10-08 22:50:52 +02:00
[B_WIN_VS_MULTI_PLAYER_2] = {
2018-10-27 00:53:07 +02:00
.bg = 2,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 2,
.width = 6,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0040,
},
2021-10-08 22:50:52 +02:00
[B_WIN_VS_MULTI_PLAYER_3] = {
2018-10-27 00:53:07 +02:00
.bg = 1,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 6,
.width = 6,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0060,
},
2021-10-08 22:50:52 +02:00
[B_WIN_VS_MULTI_PLAYER_4] = {
2018-10-27 00:53:07 +02:00
.bg = 2,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 6,
.width = 6,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0080,
},
2021-10-08 22:50:52 +02:00
[B_WIN_VS_OUTCOME_DRAW] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 12,
.tilemapTop = 2,
.width = 6,
.height = 2,
.paletteNum = 0,
.baseBlock = 0x00a0,
},
2021-10-08 22:50:52 +02:00
[B_WIN_VS_OUTCOME_LEFT] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 4,
.tilemapTop = 2,
.width = 7,
.height = 2,
.paletteNum = 0,
.baseBlock = 0x00a0,
},
2021-10-08 22:50:52 +02:00
[B_WIN_VS_OUTCOME_RIGHT] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 19,
.tilemapTop = 2,
.width = 7,
.height = 2,
.paletteNum = 0,
.baseBlock = 0x00b0,
},
DUMMY_WIN_TEMPLATE
};
2022-05-17 19:51:54 +02:00
static const struct WindowTemplate sBattleArenaWindowTemplates[] =
2018-09-12 00:37:47 +02:00
{
2021-10-08 22:50:52 +02:00
[B_WIN_MSG] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 15,
.width = 26,
.height = 4,
.paletteNum = 0,
.baseBlock = 0x0090,
},
2021-10-08 22:50:52 +02:00
[B_WIN_ACTION_PROMPT] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 1,
.tilemapTop = 35,
.width = 14,
.height = 4,
.paletteNum = 0,
.baseBlock = 0x01c0,
},
2021-10-08 22:50:52 +02:00
[B_WIN_ACTION_MENU] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 17,
.tilemapTop = 35,
.width = 12,
.height = 4,
.paletteNum = 5,
.baseBlock = 0x0190,
},
2021-10-08 22:50:52 +02:00
[B_WIN_MOVE_NAME_1] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 55,
.width = 8,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0300,
},
2021-10-08 22:50:52 +02:00
[B_WIN_MOVE_NAME_2] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 11,
.tilemapTop = 55,
.width = 8,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0310,
},
2021-10-08 22:50:52 +02:00
[B_WIN_MOVE_NAME_3] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 57,
.width = 8,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0320,
},
2021-10-08 22:50:52 +02:00
[B_WIN_MOVE_NAME_4] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 11,
.tilemapTop = 57,
.width = 8,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0330,
},
2021-10-08 22:50:52 +02:00
[B_WIN_PP] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 21,
.tilemapTop = 55,
.width = 4,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0290,
},
2021-10-08 22:50:52 +02:00
[B_WIN_DUMMY] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 21,
.tilemapTop = 57,
.width = 0,
.height = 0,
.paletteNum = 5,
.baseBlock = 0x0298,
},
2021-10-08 22:50:52 +02:00
[B_WIN_PP_REMAINING] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 25,
.tilemapTop = 55,
.width = 4,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0298,
},
2021-10-08 22:50:52 +02:00
[B_WIN_MOVE_TYPE] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 21,
.tilemapTop = 57,
.width = 8,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x02a0,
},
2021-10-08 22:50:52 +02:00
[B_WIN_SWITCH_PROMPT] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 21,
.tilemapTop = 55,
.width = 8,
.height = 4,
.paletteNum = 5,
.baseBlock = 0x02b0,
},
2021-10-08 22:50:52 +02:00
[B_WIN_YESNO] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 26,
.tilemapTop = 9,
.width = 3,
.height = 4,
.paletteNum = 5,
.baseBlock = 0x0100,
},
2021-10-08 22:50:52 +02:00
[B_WIN_LEVEL_UP_BOX] = {
2018-10-27 00:53:07 +02:00
.bg = 1,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 19,
.tilemapTop = 8,
.width = 10,
.height = 11,
.paletteNum = 5,
.baseBlock = 0x0100,
},
2021-10-08 22:50:52 +02:00
[B_WIN_LEVEL_UP_BANNER] = {
2018-10-27 00:53:07 +02:00
.bg = 2,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 18,
.tilemapTop = 0,
.width = 12,
.height = 3,
.paletteNum = 6,
.baseBlock = 0x016e,
},
2021-10-08 22:50:52 +02:00
[ARENA_WIN_PLAYER_NAME] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 6,
.tilemapTop = 1,
.width = 8,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0100,
},
2021-10-08 22:50:52 +02:00
[ARENA_WIN_VS] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 14,
.tilemapTop = 1,
.width = 2,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0110,
},
2021-10-08 22:50:52 +02:00
[ARENA_WIN_OPPONENT_NAME] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 16,
.tilemapTop = 1,
.width = 8,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0114,
},
2021-10-08 22:50:52 +02:00
[ARENA_WIN_MIND] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 12,
.tilemapTop = 4,
.width = 6,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0124,
},
2021-10-08 22:50:52 +02:00
[ARENA_WIN_SKILL] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 12,
.tilemapTop = 6,
.width = 6,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0130,
},
2021-10-08 22:50:52 +02:00
[ARENA_WIN_BODY] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 12,
.tilemapTop = 8,
.width = 6,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x013c,
},
2021-10-08 22:50:52 +02:00
[ARENA_WIN_JUDGEMENT_TITLE] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 8,
.tilemapTop = 11,
.width = 14,
.height = 2,
.paletteNum = 5,
.baseBlock = 0x0148,
},
2021-10-08 22:50:52 +02:00
[ARENA_WIN_JUDGEMENT_TEXT] = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-09-12 00:37:47 +02:00
.tilemapLeft = 2,
.tilemapTop = 15,
.width = 26,
.height = 4,
.paletteNum = 7,
.baseBlock = 0x0090,
},
DUMMY_WIN_TEMPLATE
};
const struct WindowTemplate * const gBattleWindowTemplates[] =
{
2022-05-17 19:51:54 +02:00
[B_WIN_TYPE_NORMAL] = sStandardBattleWindowTemplates,
[B_WIN_TYPE_ARENA] = sBattleArenaWindowTemplates,
2018-09-12 00:37:47 +02:00
};
#if P_ENABLE_DEBUG == TRUE
const struct BattleBackground sBattleTerrainTable[] =
#else
static const struct BattleBackground sBattleTerrainTable[] =
#endif
2018-09-12 00:37:47 +02:00
{
2019-04-06 18:38:15 +02:00
[BATTLE_TERRAIN_GRASS] =
2018-09-12 00:37:47 +02:00
{
.tileset = gBattleTerrainTiles_TallGrass,
.tilemap = gBattleTerrainTilemap_TallGrass,
.entryTileset = gBattleTerrainAnimTiles_TallGrass,
.entryTilemap = gBattleTerrainAnimTilemap_TallGrass,
.palette = gBattleTerrainPalette_TallGrass,
},
2019-04-06 18:38:15 +02:00
[BATTLE_TERRAIN_LONG_GRASS] =
2018-09-12 00:37:47 +02:00
{
.tileset = gBattleTerrainTiles_LongGrass,
.tilemap = gBattleTerrainTilemap_LongGrass,
.entryTileset = gBattleTerrainAnimTiles_LongGrass,
.entryTilemap = gBattleTerrainAnimTilemap_LongGrass,
.palette = gBattleTerrainPalette_LongGrass,
},
2019-04-06 18:38:15 +02:00
[BATTLE_TERRAIN_SAND] =
2018-09-12 00:37:47 +02:00
{
.tileset = gBattleTerrainTiles_Sand,
.tilemap = gBattleTerrainTilemap_Sand,
.entryTileset = gBattleTerrainAnimTiles_Sand,
.entryTilemap = gBattleTerrainAnimTilemap_Sand,
.palette = gBattleTerrainPalette_Sand,
},
2019-04-06 18:38:15 +02:00
[BATTLE_TERRAIN_UNDERWATER] =
2018-09-12 00:37:47 +02:00
{
.tileset = gBattleTerrainTiles_Underwater,
.tilemap = gBattleTerrainTilemap_Underwater,
.entryTileset = gBattleTerrainAnimTiles_Underwater,
.entryTilemap = gBattleTerrainAnimTilemap_Underwater,
.palette = gBattleTerrainPalette_Underwater,
},
2019-04-06 18:38:15 +02:00
[BATTLE_TERRAIN_WATER] =
2018-09-12 00:37:47 +02:00
{
.tileset = gBattleTerrainTiles_Water,
.tilemap = gBattleTerrainTilemap_Water,
.entryTileset = gBattleTerrainAnimTiles_Water,
.entryTilemap = gBattleTerrainAnimTilemap_Water,
.palette = gBattleTerrainPalette_Water,
},
2019-04-06 18:38:15 +02:00
[BATTLE_TERRAIN_POND] =
2018-09-12 00:37:47 +02:00
{
.tileset = gBattleTerrainTiles_PondWater,
.tilemap = gBattleTerrainTilemap_PondWater,
.entryTileset = gBattleTerrainAnimTiles_PondWater,
.entryTilemap = gBattleTerrainAnimTilemap_PondWater,
.palette = gBattleTerrainPalette_PondWater,
},
2019-04-06 18:38:15 +02:00
[BATTLE_TERRAIN_MOUNTAIN] =
2018-09-12 00:37:47 +02:00
{
.tileset = gBattleTerrainTiles_Rock,
.tilemap = gBattleTerrainTilemap_Rock,
.entryTileset = gBattleTerrainAnimTiles_Rock,
.entryTilemap = gBattleTerrainAnimTilemap_Rock,
.palette = gBattleTerrainPalette_Rock,
},
2019-04-06 18:38:15 +02:00
[BATTLE_TERRAIN_CAVE] =
2018-09-12 00:37:47 +02:00
{
.tileset = gBattleTerrainTiles_Cave,
.tilemap = gBattleTerrainTilemap_Cave,
.entryTileset = gBattleTerrainAnimTiles_Cave,
.entryTilemap = gBattleTerrainAnimTilemap_Cave,
.palette = gBattleTerrainPalette_Cave,
},
2019-04-06 18:38:15 +02:00
[BATTLE_TERRAIN_BUILDING] =
2018-09-12 00:37:47 +02:00
{
.tileset = gBattleTerrainTiles_Building,
.tilemap = gBattleTerrainTilemap_Building,
.entryTileset = gBattleTerrainAnimTiles_Building,
.entryTilemap = gBattleTerrainAnimTilemap_Building,
.palette = gBattleTerrainPalette_Building,
},
2019-04-06 18:38:15 +02:00
[BATTLE_TERRAIN_PLAIN] =
{
2018-09-12 00:37:47 +02:00
.tileset = gBattleTerrainTiles_Building,
.tilemap = gBattleTerrainTilemap_Building,
.entryTileset = gBattleTerrainAnimTiles_Building,
.entryTilemap = gBattleTerrainAnimTilemap_Building,
.palette = gBattleTerrainPalette_Plain,
},
};
2021-10-04 16:21:03 +02:00
static void CB2_UnusedBattleInit(void);
2020-04-08 22:24:30 +02:00
2021-10-04 16:21:03 +02:00
static void UnusedBattleInit(void)
2020-04-08 22:24:30 +02:00
{
u8 spriteId;
ResetSpriteData();
2021-10-04 16:21:03 +02:00
spriteId = CreateSprite(&gUnusedBattleInitSprite, 0, 0, 0);
2020-04-08 22:24:30 +02:00
gSprites[spriteId].invisible = TRUE;
2021-10-04 16:21:03 +02:00
SetMainCallback2(CB2_UnusedBattleInit);
2020-04-08 22:24:30 +02:00
}
2021-10-04 16:21:03 +02:00
static void CB2_UnusedBattleInit(void)
2020-04-08 22:24:30 +02:00
{
AnimateSprites();
BuildOamBuffer();
}
2018-06-17 16:48:58 +02:00
void BattleInitBgsAndWindows(void)
2017-12-17 20:10:57 +01:00
{
ResetBgsAndClearDma3BusyFlags(0);
2018-06-17 16:48:58 +02:00
InitBgsFromTemplates(0, gBattleBgTemplates, ARRAY_COUNT(gBattleBgTemplates));
2017-12-17 20:10:57 +01:00
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
{
2021-10-04 16:21:03 +02:00
gBattleScripting.windowsType = B_WIN_TYPE_ARENA;
SetBgTilemapBuffer(1, gBattleAnimBgTilemapBuffer);
SetBgTilemapBuffer(2, gBattleAnimBgTilemapBuffer);
2017-12-17 20:10:57 +01:00
}
else
{
2021-10-04 16:21:03 +02:00
gBattleScripting.windowsType = B_WIN_TYPE_NORMAL;
2017-12-17 20:10:57 +01:00
}
2018-06-17 16:48:58 +02:00
InitWindows(gBattleWindowTemplates[gBattleScripting.windowsType]);
2017-12-17 20:10:57 +01:00
DeactivateAllTextPrinters();
}
2019-11-07 01:18:11 +01:00
void InitBattleBgsVideo(void)
2017-12-17 20:10:57 +01:00
{
DisableInterrupts(INTR_FLAG_HBLANK);
EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL);
2018-06-17 16:48:58 +02:00
BattleInitBgsAndWindows();
2017-12-17 20:10:57 +01:00
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON | DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
}
2018-06-17 16:48:58 +02:00
void LoadBattleMenuWindowGfx(void)
2017-12-17 20:10:57 +01:00
{
2018-07-15 13:23:38 +02:00
LoadUserWindowBorderGfx(2, 0x12, 0x10);
LoadUserWindowBorderGfx(2, 0x22, 0x10);
2019-11-07 01:18:11 +01:00
LoadCompressedPalette(gBattleWindowTextPalette, 0x50, 0x20);
2017-12-17 20:10:57 +01:00
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
{
2019-11-07 01:18:11 +01:00
// Load graphics for the Battle Arena referee's mid-battle messages.
2019-04-01 00:59:52 +02:00
Menu_LoadStdPalAt(0x70);
2018-06-17 16:48:58 +02:00
LoadMessageBoxGfx(0, 0x30, 0x70);
2017-12-17 20:10:57 +01:00
gPlttBufferUnfaded[0x76] = 0;
CpuCopy16(&gPlttBufferUnfaded[0x76], &gPlttBufferFaded[0x76], 2);
}
}
void DrawMainBattleBackground(void)
{
2021-01-13 21:17:32 +01:00
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_RECORDED_LINK))
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Building, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60);
}
else if (gBattleTypeFlags & BATTLE_TYPE_GROUDON)
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Cave, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Cave, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_Groudon, 0x20, 0x60);
}
2017-12-19 17:41:05 +01:00
else if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE)
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Water, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Water, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_Kyogre, 0x20, 0x60);
}
else if (gBattleTypeFlags & BATTLE_TYPE_RAYQUAZA)
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Rayquaza, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Rayquaza, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_Rayquaza, 0x20, 0x60);
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{
u8 trainerClass = gTrainers[gTrainerBattleOpponent_A].trainerClass;
2017-12-19 17:41:05 +01:00
if (trainerClass == TRAINER_CLASS_LEADER)
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Building, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_BuildingLeader, 0x20, 0x60);
return;
}
2017-12-19 17:41:05 +01:00
else if (trainerClass == TRAINER_CLASS_CHAMPION)
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_StadiumWallace, 0x20, 0x60);
return;
}
}
switch (GetCurrentMapBattleScene())
{
default:
case MAP_BATTLE_SCENE_NORMAL:
2022-07-29 16:52:35 +02:00
LZDecompressVram(sBattleTerrainTable[gBattleTerrain].tileset, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(sBattleTerrainTable[gBattleTerrain].tilemap, (void *)(BG_SCREEN_ADDR(26)));
LoadCompressedPalette(sBattleTerrainTable[gBattleTerrain].palette, 0x20, 0x60);
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_GYM:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Building, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_BuildingGym, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_MAGMA:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_StadiumMagma, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_AQUA:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_StadiumAqua, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_SIDNEY:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_StadiumSidney, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_PHOEBE:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_StadiumPhoebe, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_GLACIA:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_StadiumGlacia, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_DRAKE:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_StadiumDrake, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_FRONTIER:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Building, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60);
break;
}
}
}
void LoadBattleTextboxAndBackground(void)
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTextboxTiles, (void *)(BG_CHAR_ADDR(0)));
2017-12-17 20:10:57 +01:00
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
CopyBgTilemapBufferToVram(0);
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40);
2018-06-17 16:48:58 +02:00
LoadBattleMenuWindowGfx();
#if B_TERRAIN_BG_CHANGE == TRUE
DrawTerrainTypeBattleBackground();
#else
DrawMainBattleBackground();
#endif
2017-12-17 20:10:57 +01:00
}
2019-11-07 01:18:11 +01:00
static void DrawLinkBattleParticipantPokeballs(u8 taskId, u8 multiplayerId, u8 bgId, u8 destX, u8 destY)
2017-12-17 20:10:57 +01:00
{
s32 i;
2019-11-07 01:18:11 +01:00
u16 pokeballStatuses = 0;
u16 tiles[6];
2017-12-17 20:10:57 +01:00
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
if (gTasks[taskId].data[5] != 0)
{
2019-11-07 01:18:11 +01:00
switch (multiplayerId)
2017-12-17 20:10:57 +01:00
{
case 0:
2019-11-07 01:18:11 +01:00
pokeballStatuses = 0x3F & gTasks[taskId].data[3];
2017-12-17 20:10:57 +01:00
break;
case 1:
2019-11-07 01:18:11 +01:00
pokeballStatuses = (0xFC0 & gTasks[taskId].data[4]) >> 6;
2017-12-17 20:10:57 +01:00
break;
case 2:
2019-11-07 01:18:11 +01:00
pokeballStatuses = (0xFC0 & gTasks[taskId].data[3]) >> 6;
2017-12-17 20:10:57 +01:00
break;
case 3:
2019-11-07 01:18:11 +01:00
pokeballStatuses = 0x3F & gTasks[taskId].data[4];
2017-12-17 20:10:57 +01:00
break;
}
}
else
{
2019-11-07 01:18:11 +01:00
switch (multiplayerId)
2017-12-17 20:10:57 +01:00
{
case 0:
2019-11-07 01:18:11 +01:00
pokeballStatuses = 0x3F & gTasks[taskId].data[3];
2017-12-17 20:10:57 +01:00
break;
case 1:
2019-11-07 01:18:11 +01:00
pokeballStatuses = 0x3F & gTasks[taskId].data[4];
2017-12-17 20:10:57 +01:00
break;
case 2:
2019-11-07 01:18:11 +01:00
pokeballStatuses = (0xFC0 & gTasks[taskId].data[3]) >> 6;
2017-12-17 20:10:57 +01:00
break;
case 3:
2019-11-07 01:18:11 +01:00
pokeballStatuses = (0xFC0 & gTasks[taskId].data[4]) >> 6;
2017-12-17 20:10:57 +01:00
break;
}
}
for (i = 0; i < 3; i++)
2019-11-07 01:18:11 +01:00
tiles[i] = ((pokeballStatuses & (3 << (i * 2))) >> (i * 2)) + 0x6001;
2017-12-17 20:10:57 +01:00
2019-11-07 01:18:11 +01:00
CopyToBgTilemapBufferRect_ChangePalette(bgId, tiles, destX, destY, 3, 1, 0x11);
2017-12-17 20:10:57 +01:00
CopyBgTilemapBufferToVram(bgId);
}
else
{
2019-11-07 01:18:11 +01:00
if (multiplayerId == gBattleScripting.multiplayerId)
pokeballStatuses = gTasks[taskId].data[3];
2017-12-17 20:10:57 +01:00
else
2019-11-07 01:18:11 +01:00
pokeballStatuses = gTasks[taskId].data[4];
2017-12-17 20:10:57 +01:00
for (i = 0; i < 6; i++)
2019-11-07 01:18:11 +01:00
tiles[i] = ((pokeballStatuses & (3 << (i * 2))) >> (i * 2)) + 0x6001;
2017-12-17 20:10:57 +01:00
2019-11-07 01:18:11 +01:00
CopyToBgTilemapBufferRect_ChangePalette(bgId, tiles, destX, destY, 6, 1, 0x11);
2017-12-17 20:10:57 +01:00
CopyBgTilemapBufferToVram(bgId);
}
}
2019-11-07 01:18:11 +01:00
static void DrawLinkBattleVsScreenOutcomeText(void)
2017-12-17 20:10:57 +01:00
{
2018-01-16 22:12:38 +01:00
if (gBattleOutcome == B_OUTCOME_DREW)
2017-12-17 20:10:57 +01:00
{
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Draw, B_WIN_VS_OUTCOME_DRAW);
2017-12-17 20:10:57 +01:00
}
else if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
2018-01-16 22:12:38 +01:00
if (gBattleOutcome == B_OUTCOME_WON)
2017-12-17 20:10:57 +01:00
{
2018-07-22 12:49:49 +02:00
switch (gLinkPlayers[gBattleScripting.multiplayerId].id)
2017-12-17 20:10:57 +01:00
{
case 0:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_LEFT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_RIGHT);
2017-12-17 20:10:57 +01:00
break;
case 1:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_RIGHT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_LEFT);
2017-12-17 20:10:57 +01:00
break;
case 2:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_LEFT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_RIGHT);
2017-12-17 20:10:57 +01:00
break;
case 3:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_RIGHT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_LEFT);
2017-12-17 20:10:57 +01:00
break;
}
}
else
{
2018-07-22 12:49:49 +02:00
switch (gLinkPlayers[gBattleScripting.multiplayerId].id)
2017-12-17 20:10:57 +01:00
{
case 0:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_RIGHT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_LEFT);
2017-12-17 20:10:57 +01:00
break;
case 1:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_LEFT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_RIGHT);
2017-12-17 20:10:57 +01:00
break;
case 2:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_RIGHT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_LEFT);
2017-12-17 20:10:57 +01:00
break;
case 3:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_LEFT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_RIGHT);
2017-12-17 20:10:57 +01:00
break;
}
}
}
2018-01-16 22:12:38 +01:00
else if (gBattleOutcome == B_OUTCOME_WON)
2017-12-17 20:10:57 +01:00
{
2018-07-22 12:49:49 +02:00
if (gLinkPlayers[gBattleScripting.multiplayerId].id != 0)
2017-12-17 20:10:57 +01:00
{
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_RIGHT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_LEFT);
2017-12-17 20:10:57 +01:00
}
else
{
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_LEFT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_RIGHT);
2017-12-17 20:10:57 +01:00
}
}
else
{
2018-07-22 12:49:49 +02:00
if (gLinkPlayers[gBattleScripting.multiplayerId].id != 0)
2017-12-17 20:10:57 +01:00
{
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_LEFT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_RIGHT);
2017-12-17 20:10:57 +01:00
}
else
{
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(gText_Win, B_WIN_VS_OUTCOME_RIGHT);
BattlePutTextOnWindow(gText_Loss, B_WIN_VS_OUTCOME_LEFT);
2017-12-17 20:10:57 +01:00
}
}
}
2019-11-07 01:18:11 +01:00
void InitLinkBattleVsScreen(u8 taskId)
2017-12-17 20:10:57 +01:00
{
struct LinkPlayer *linkPlayer;
u8 *name;
s32 i, palId;
switch (gTasks[taskId].data[0])
{
case 0:
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
2018-02-06 02:46:59 +01:00
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
2017-12-17 20:10:57 +01:00
{
name = gLinkPlayers[i].name;
linkPlayer = &gLinkPlayers[i];
2018-07-22 12:49:49 +02:00
switch (linkPlayer->id)
2017-12-17 20:10:57 +01:00
{
case 0:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(name, B_WIN_VS_MULTI_PLAYER_1);
2019-11-07 01:18:11 +01:00
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 1, 2, 4);
2017-12-17 20:10:57 +01:00
break;
case 1:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(name, B_WIN_VS_MULTI_PLAYER_2);
2019-11-07 01:18:11 +01:00
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 2, 2, 4);
2017-12-17 20:10:57 +01:00
break;
case 2:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(name, B_WIN_VS_MULTI_PLAYER_3);
2019-11-07 01:18:11 +01:00
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 1, 2, 8);
2017-12-17 20:10:57 +01:00
break;
case 3:
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(name, B_WIN_VS_MULTI_PLAYER_4);
2019-11-07 01:18:11 +01:00
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 2, 2, 8);
2017-12-17 20:10:57 +01:00
break;
}
}
}
else
{
u8 playerId = gBattleScripting.multiplayerId;
u8 opponentId = playerId ^ BIT_SIDE;
u8 opponentId_copy = opponentId;
2018-07-22 12:49:49 +02:00
if (gLinkPlayers[playerId].id != 0)
2017-12-17 20:10:57 +01:00
opponentId = playerId, playerId = opponentId_copy;
name = gLinkPlayers[playerId].name;
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(name, B_WIN_VS_PLAYER);
2017-12-17 20:10:57 +01:00
name = gLinkPlayers[opponentId].name;
2021-10-08 22:50:52 +02:00
BattlePutTextOnWindow(name, B_WIN_VS_OPPONENT);
2017-12-17 20:10:57 +01:00
2019-11-07 01:18:11 +01:00
DrawLinkBattleParticipantPokeballs(taskId, playerId, 1, 2, 7);
DrawLinkBattleParticipantPokeballs(taskId, opponentId, 2, 2, 7);
2017-12-17 20:10:57 +01:00
}
gTasks[taskId].data[0]++;
break;
case 1:
2019-11-07 01:18:11 +01:00
palId = AllocSpritePalette(TAG_VS_LETTERS);
2017-12-17 20:10:57 +01:00
gPlttBufferUnfaded[palId * 16 + 0x10F] = gPlttBufferFaded[palId * 16 + 0x10F] = 0x7FFF;
2019-11-07 01:18:11 +01:00
gBattleStruct->linkBattleVsSpriteId_V = CreateSprite(&sVsLetter_V_SpriteTemplate, 111, 80, 0);
gBattleStruct->linkBattleVsSpriteId_S = CreateSprite(&sVsLetter_S_SpriteTemplate, 129, 80, 0);
gSprites[gBattleStruct->linkBattleVsSpriteId_V].invisible = TRUE;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].invisible = TRUE;
2017-12-17 20:10:57 +01:00
gTasks[taskId].data[0]++;
break;
case 2:
if (gTasks[taskId].data[5] != 0)
{
gBattle_BG1_X = -(20) - (Sin2(gTasks[taskId].data[1]) / 32);
gBattle_BG2_X = -(140) - (Sin2(gTasks[taskId].data[2]) / 32);
gBattle_BG1_Y = -36;
gBattle_BG2_Y = -36;
}
else
{
gBattle_BG1_X = -(20) - (Sin2(gTasks[taskId].data[1]) / 32);
gBattle_BG1_Y = (Cos2(gTasks[taskId].data[1]) / 32) - 164;
gBattle_BG2_X = -(140) - (Sin2(gTasks[taskId].data[2]) / 32);
gBattle_BG2_Y = (Cos2(gTasks[taskId].data[2]) / 32) - 164;
}
if (gTasks[taskId].data[2] != 0)
{
gTasks[taskId].data[2] -= 2;
gTasks[taskId].data[1] += 2;
}
else
{
if (gTasks[taskId].data[5] != 0)
2019-11-07 01:18:11 +01:00
DrawLinkBattleVsScreenOutcomeText();
2017-12-17 20:10:57 +01:00
2020-08-21 00:02:00 +02:00
PlaySE(SE_M_HARDEN);
2017-12-17 20:10:57 +01:00
DestroyTask(taskId);
gSprites[gBattleStruct->linkBattleVsSpriteId_V].invisible = FALSE;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].invisible = FALSE;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].oam.tileNum += 0x40;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].data[0] = 0;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].data[0] = 1;
2021-07-07 15:11:52 +02:00
gSprites[gBattleStruct->linkBattleVsSpriteId_V].data[1] = gSprites[gBattleStruct->linkBattleVsSpriteId_V].x;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].data[1] = gSprites[gBattleStruct->linkBattleVsSpriteId_S].x;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].data[2] = 0;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].data[2] = 0;
2017-12-17 20:10:57 +01:00
}
break;
}
}
2018-06-17 16:48:58 +02:00
void DrawBattleEntryBackground(void)
2017-12-17 20:10:57 +01:00
{
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleVSFrame_Gfx, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gVsLettersGfx, (void *)OBJ_VRAM0);
2021-10-26 22:52:23 +02:00
LoadCompressedPalette(gBattleVSFrame_Pal, 0x60, 0x20);
2018-12-26 13:05:02 +01:00
SetBgAttribute(1, BG_ATTR_SCREENSIZE, 1);
2017-12-17 20:10:57 +01:00
SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04);
2021-10-26 22:52:23 +02:00
CopyToBgTilemapBuffer(1, gBattleVSFrame_Tilemap, 0, 0);
CopyToBgTilemapBuffer(2, gBattleVSFrame_Tilemap, 0, 0);
2017-12-17 20:10:57 +01:00
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2);
2021-04-15 08:43:09 +02:00
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
2017-12-17 20:10:57 +01:00
gBattle_BG1_Y = 0xFF5C;
gBattle_BG2_Y = 0xFF5C;
2019-11-07 01:18:11 +01:00
LoadCompressedSpriteSheetUsingHeap(&sVsLettersSpriteSheet);
2017-12-17 20:10:57 +01:00
}
2021-01-13 21:17:32 +01:00
else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_EREADER_TRAINER))
2017-12-17 20:10:57 +01:00
{
2018-11-24 01:02:02 +01:00
if (!(gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || gPartnerTrainerId == TRAINER_STEVEN_PARTNER || gPartnerTrainerId >= TRAINER_CUSTOM_PARTNER)
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
2017-12-17 20:10:57 +01:00
}
else
{
2021-10-26 22:52:23 +02:00
// Set up bg for the multi battle intro where both teams slide in facing the screen.
// Note Steven's multi battle (which has a dedicated back pic) is excluded above.
2018-12-26 13:05:02 +01:00
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 2);
SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 2);
2021-10-26 22:52:23 +02:00
CopyToBgTilemapBuffer(1, gMultiBattleIntroBg_Opponent_Tilemap, 0, 0);
CopyToBgTilemapBuffer(2, gMultiBattleIntroBg_Player_Tilemap, 0, 0);
2017-12-17 20:10:57 +01:00
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2);
}
}
else if (gBattleTypeFlags & BATTLE_TYPE_GROUDON)
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainAnimTiles_Cave, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleTerrainAnimTilemap_Cave, (void *)(BG_SCREEN_ADDR(28)));
2017-12-17 20:10:57 +01:00
}
2017-12-19 17:41:05 +01:00
else if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE)
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainAnimTiles_Underwater, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleTerrainAnimTilemap_Underwater, (void *)(BG_SCREEN_ADDR(28)));
2017-12-17 20:10:57 +01:00
}
else if (gBattleTypeFlags & BATTLE_TYPE_RAYQUAZA)
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainAnimTiles_Rayquaza, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleTerrainAnimTilemap_Rayquaza, (void *)(BG_SCREEN_ADDR(28)));
2017-12-17 20:10:57 +01:00
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{
u8 trainerClass = gTrainers[gTrainerBattleOpponent_A].trainerClass;
2017-12-19 17:41:05 +01:00
if (trainerClass == TRAINER_CLASS_LEADER)
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
2017-12-17 20:10:57 +01:00
return;
}
2017-12-19 17:41:05 +01:00
else if (trainerClass == TRAINER_CLASS_CHAMPION)
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
2017-12-17 20:10:57 +01:00
return;
}
}
if (GetCurrentMapBattleScene() == MAP_BATTLE_SCENE_NORMAL)
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(sBattleTerrainTable[gBattleTerrain].entryTileset, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(sBattleTerrainTable[gBattleTerrain].entryTilemap, (void *)(BG_SCREEN_ADDR(28)));
2017-12-17 20:10:57 +01:00
}
else
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
2017-12-17 20:10:57 +01:00
}
}
}
bool8 LoadChosenBattleElement(u8 caseId)
{
bool8 ret = FALSE;
switch (caseId)
{
case 0:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTextboxTiles, (void *)(BG_CHAR_ADDR(0)));
2017-12-17 20:10:57 +01:00
break;
case 1:
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
CopyBgTilemapBufferToVram(0);
break;
case 2:
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40);
break;
case 3:
2021-01-13 21:17:32 +01:00
if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_EREADER_TRAINER))
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Building, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
}
else if (gBattleTypeFlags & BATTLE_TYPE_GROUDON)
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Cave, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{
u8 trainerClass = gTrainers[gTrainerBattleOpponent_A].trainerClass;
2017-12-19 17:41:05 +01:00
if (trainerClass == TRAINER_CLASS_LEADER)
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Building, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
break;
}
2017-12-19 17:41:05 +01:00
else if (trainerClass == TRAINER_CLASS_CHAMPION)
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
break;
}
}
switch (GetCurrentMapBattleScene())
{
default:
case MAP_BATTLE_SCENE_NORMAL:
2022-07-29 16:52:35 +02:00
LZDecompressVram(sBattleTerrainTable[gBattleTerrain].tileset, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_GYM:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Building, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_MAGMA:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_AQUA:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_SIDNEY:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_PHOEBE:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_GLACIA:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_DRAKE:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_FRONTIER:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTiles_Building, (void *)(BG_CHAR_ADDR(2)));
2017-12-17 20:10:57 +01:00
break;
}
}
break;
case 4:
2021-01-13 21:17:32 +01:00
if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_EREADER_TRAINER))
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
}
else if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE_GROUDON)
{
if (gGameVersion == VERSION_RUBY)
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Cave, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
else
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Water, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{
u8 trainerClass = gTrainers[gTrainerBattleOpponent_A].trainerClass;
2017-12-19 17:41:05 +01:00
if (trainerClass == TRAINER_CLASS_LEADER)
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
break;
}
2017-12-19 17:41:05 +01:00
else if (trainerClass == TRAINER_CLASS_CHAMPION)
2017-12-17 20:10:57 +01:00
{
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
break;
}
}
switch (GetCurrentMapBattleScene())
{
default:
case MAP_BATTLE_SCENE_NORMAL:
2022-07-29 16:52:35 +02:00
LZDecompressVram(sBattleTerrainTable[gBattleTerrain].tilemap, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_GYM:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_MAGMA:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_AQUA:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_SIDNEY:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_PHOEBE:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_GLACIA:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_DRAKE:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_FRONTIER:
2022-07-29 16:52:35 +02:00
LZDecompressVram(gBattleTerrainTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
2017-12-17 20:10:57 +01:00
break;
}
}
break;
case 5:
2021-01-13 21:17:32 +01:00
if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_EREADER_TRAINER))
2017-12-17 20:10:57 +01:00
{
LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60);
}
else if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE_GROUDON)
{
if (gGameVersion == VERSION_RUBY)
LoadCompressedPalette(gBattleTerrainPalette_Groudon, 0x20, 0x60);
else
LoadCompressedPalette(gBattleTerrainPalette_Kyogre, 0x20, 0x60);
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{
u8 trainerClass = gTrainers[gTrainerBattleOpponent_A].trainerClass;
2017-12-19 17:41:05 +01:00
if (trainerClass == TRAINER_CLASS_LEADER)
2017-12-17 20:10:57 +01:00
{
LoadCompressedPalette(gBattleTerrainPalette_BuildingLeader, 0x20, 0x60);
break;
}
2017-12-19 17:41:05 +01:00
else if (trainerClass == TRAINER_CLASS_CHAMPION)
2017-12-17 20:10:57 +01:00
{
LoadCompressedPalette(gBattleTerrainPalette_StadiumWallace, 0x20, 0x60);
break;
}
}
switch (GetCurrentMapBattleScene())
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LoadCompressedPalette(sBattleTerrainTable[gBattleTerrain].palette, 0x20, 0x60);
2017-12-17 20:10:57 +01:00
break;
case MAP_BATTLE_SCENE_GYM:
LoadCompressedPalette(gBattleTerrainPalette_BuildingGym, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_MAGMA:
LoadCompressedPalette(gBattleTerrainPalette_StadiumMagma, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_AQUA:
LoadCompressedPalette(gBattleTerrainPalette_StadiumAqua, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_SIDNEY:
LoadCompressedPalette(gBattleTerrainPalette_StadiumSidney, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_PHOEBE:
LoadCompressedPalette(gBattleTerrainPalette_StadiumPhoebe, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_GLACIA:
LoadCompressedPalette(gBattleTerrainPalette_StadiumGlacia, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_DRAKE:
LoadCompressedPalette(gBattleTerrainPalette_StadiumDrake, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_FRONTIER:
LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60);
break;
}
}
break;
case 6:
2018-06-17 16:48:58 +02:00
LoadBattleMenuWindowGfx();
2017-12-17 20:10:57 +01:00
break;
default:
ret = TRUE;
break;
}
return ret;
}
2020-11-18 03:45:27 +01:00
void DrawTerrainTypeBattleBackground(void)
{
switch (gFieldStatuses & STATUS_FIELD_TERRAIN_ANY)
2020-11-18 03:45:27 +01:00
{
case STATUS_FIELD_GRASSY_TERRAIN:
LoadMoveBg(BG_GRASSY_TERRAIN);
break;
case STATUS_FIELD_MISTY_TERRAIN:
LoadMoveBg(BG_MISTY_TERRAIN);
break;
case STATUS_FIELD_ELECTRIC_TERRAIN:
LoadMoveBg(BG_ELECTRIC_TERRAIN);
break;
case STATUS_FIELD_PSYCHIC_TERRAIN:
LoadMoveBg(BG_PSYCHIC_TERRAIN);
break;
default:
DrawMainBattleBackground();
break;
}
}