pokeemerald/src/battle_bg.c

1380 lines
41 KiB
C
Raw Normal View History

2017-12-17 20:10:57 +01:00
#include "global.h"
#include "battle.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"
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"
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;
};
2018-09-12 00:37:47 +02:00
// .rodata
static const u16 sUnrefArray[] = {0x0300, 0x0000}; //OamData?
static const struct OamData gUnknown_0831A988 =
{
.y = 0,
.affineMode = 3,
.objMode = 0,
.mosaic = 0,
.bpp = 0,
.shape = 0,
.x = 0,
.matrixNum = 0,
.size = 3,
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData gUnknown_0831A990 =
{
.y = 0,
.affineMode = 3,
.objMode = 0,
.mosaic = 0,
.bpp = 0,
.shape = 0,
.x = 0,
.matrixNum = 0,
.size = 3,
.tileNum = 64,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
static const union AffineAnimCmd gUnknown_0831A998[] =
{
AFFINEANIMCMD_FRAME(0x0080, 0x0080, 0x00, 0x00),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd gUnknown_0831A9A8[] =
{
AFFINEANIMCMD_FRAME(0x0080, 0x0080, 0x00, 0x00),
AFFINEANIMCMD_FRAME(0x0018, 0x0018, 0x00, 0x80),
AFFINEANIMCMD_FRAME(0x0018, 0x0018, 0x00, 0x80),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd * const gUnknown_0831A9C8[] =
{
gUnknown_0831A998,
gUnknown_0831A9A8,
};
static const struct SpriteTemplate gUnknown_0831A9D0 =
{
.tileTag = 0x2710,
.paletteTag = 0x2710,
.oam = &gUnknown_0831A988,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gUnknown_0831A9C8,
.callback = nullsub_17
};
static const struct SpriteTemplate gUnknown_0831A9E8 =
{
.tileTag = 0x2710,
.paletteTag = 0x2710,
.oam = &gUnknown_0831A990,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gUnknown_0831A9C8,
.callback = nullsub_17
};
static const struct CompressedSpriteSheet gUnknown_0831AA00 =
{
gUnknown_08D77B0C, 0x1000, 0x2710
};
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
},
};
2018-11-22 02:10:50 +01:00
static const struct WindowTemplate gStandardBattleWindowTemplates[] =
2018-09-12 00:37:47 +02:00
{
2018-11-22 02:10:50 +01:00
{ // 0 Standard battle message
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,
},
2018-11-22 02:10:50 +01:00
{ // 1 "What will (pokemon) do?"
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,
},
2018-11-22 02:10:50 +01:00
{ // 2 "Fight/Pokemon/Bag/Run"
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,
},
2018-11-22 02:10:50 +01:00
{ // 3 Top left move
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,
},
2018-11-22 02:10:50 +01:00
{ // 4 Top right move
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,
},
2018-11-22 02:10:50 +01:00
{ // 5 Bottom left move
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,
},
2018-11-22 02:10:50 +01:00
{ // 6 Bottom right move
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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
};
2018-11-22 02:10:50 +01:00
static const struct WindowTemplate gBattleArenaWindowTemplates[] =
2018-09-12 00:37:47 +02:00
{
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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,
},
{
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[] =
{
2018-11-22 02:10:50 +01:00
gStandardBattleWindowTemplates,
gBattleArenaWindowTemplates,
2018-09-12 00:37:47 +02:00
};
static const struct BattleBackground gBattleTerrainTable[] =
{
{
.tileset = gBattleTerrainTiles_TallGrass,
.tilemap = gBattleTerrainTilemap_TallGrass,
.entryTileset = gBattleTerrainAnimTiles_TallGrass,
.entryTilemap = gBattleTerrainAnimTilemap_TallGrass,
.palette = gBattleTerrainPalette_TallGrass,
},
{
.tileset = gBattleTerrainTiles_LongGrass,
.tilemap = gBattleTerrainTilemap_LongGrass,
.entryTileset = gBattleTerrainAnimTiles_LongGrass,
.entryTilemap = gBattleTerrainAnimTilemap_LongGrass,
.palette = gBattleTerrainPalette_LongGrass,
},
{
.tileset = gBattleTerrainTiles_Sand,
.tilemap = gBattleTerrainTilemap_Sand,
.entryTileset = gBattleTerrainAnimTiles_Sand,
.entryTilemap = gBattleTerrainAnimTilemap_Sand,
.palette = gBattleTerrainPalette_Sand,
},
{
.tileset = gBattleTerrainTiles_Underwater,
.tilemap = gBattleTerrainTilemap_Underwater,
.entryTileset = gBattleTerrainAnimTiles_Underwater,
.entryTilemap = gBattleTerrainAnimTilemap_Underwater,
.palette = gBattleTerrainPalette_Underwater,
},
{
.tileset = gBattleTerrainTiles_Water,
.tilemap = gBattleTerrainTilemap_Water,
.entryTileset = gBattleTerrainAnimTiles_Water,
.entryTilemap = gBattleTerrainAnimTilemap_Water,
.palette = gBattleTerrainPalette_Water,
},
{
.tileset = gBattleTerrainTiles_PondWater,
.tilemap = gBattleTerrainTilemap_PondWater,
.entryTileset = gBattleTerrainAnimTiles_PondWater,
.entryTilemap = gBattleTerrainAnimTilemap_PondWater,
.palette = gBattleTerrainPalette_PondWater,
},
{
.tileset = gBattleTerrainTiles_Rock,
.tilemap = gBattleTerrainTilemap_Rock,
.entryTileset = gBattleTerrainAnimTiles_Rock,
.entryTilemap = gBattleTerrainAnimTilemap_Rock,
.palette = gBattleTerrainPalette_Rock,
},
{
.tileset = gBattleTerrainTiles_Cave,
.tilemap = gBattleTerrainTilemap_Cave,
.entryTileset = gBattleTerrainAnimTiles_Cave,
.entryTilemap = gBattleTerrainAnimTilemap_Cave,
.palette = gBattleTerrainPalette_Cave,
},
{
.tileset = gBattleTerrainTiles_Building,
.tilemap = gBattleTerrainTilemap_Building,
.entryTileset = gBattleTerrainAnimTiles_Building,
.entryTilemap = gBattleTerrainAnimTilemap_Building,
.palette = gBattleTerrainPalette_Building,
},
{// plain
.tileset = gBattleTerrainTiles_Building,
.tilemap = gBattleTerrainTilemap_Building,
.entryTileset = gBattleTerrainAnimTiles_Building,
.entryTilemap = gBattleTerrainAnimTilemap_Building,
.palette = gBattleTerrainPalette_Plain,
},
};
// .text
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)
{
2018-06-17 16:48:58 +02:00
gBattleScripting.windowsType = 1;
2017-12-17 20:10:57 +01:00
SetBgTilemapBuffer(1, gUnknown_02023060);
SetBgTilemapBuffer(2, gUnknown_02023060);
}
else
{
2018-06-17 16:48:58 +02:00
gBattleScripting.windowsType = 0;
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();
}
void sub_80356D0(void)
{
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);
2017-12-17 20:10:57 +01:00
LoadCompressedPalette(gUnknown_08D85600, 0x50, 0x20);
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
{
sub_81978B0(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)
{
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_x2000000))
{
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60);
}
else if (gBattleTypeFlags & BATTLE_TYPE_GROUDON)
{
LZDecompressVram(gBattleTerrainTiles_Cave, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Cave, (void*)(VRAM + 0xD000));
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
{
LZDecompressVram(gBattleTerrainTiles_Water, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Water, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_Kyogre, 0x20, 0x60);
}
else if (gBattleTypeFlags & BATTLE_TYPE_RAYQUAZA)
{
LZDecompressVram(gBattleTerrainTiles_Rayquaza, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Rayquaza, (void*)(VRAM + 0xD000));
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
{
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
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
{
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumWallace, 0x20, 0x60);
return;
}
}
switch (GetCurrentMapBattleScene())
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].tileset, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].tilemap, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainTable[gBattleTerrain].palette, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_GYM:
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_BuildingGym, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_MAGMA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumMagma, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_AQUA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumAqua, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_SIDNEY:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumSidney, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_PHOEBE:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumPhoebe, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_GLACIA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumGlacia, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_DRAKE:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumDrake, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_FRONTIER:
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60);
break;
}
}
}
void LoadBattleTextboxAndBackground(void)
{
LZDecompressVram(gBattleTextboxTiles, (void*)(VRAM));
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
CopyBgTilemapBufferToVram(0);
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40);
2018-06-17 16:48:58 +02:00
LoadBattleMenuWindowGfx();
2017-12-17 20:10:57 +01:00
DrawMainBattleBackground();
}
2018-06-17 16:48:58 +02:00
static void sub_8035AE4(u8 taskId, u8 battlerId, u8 bgId, u8 destX, u8 destY)
2017-12-17 20:10:57 +01:00
{
s32 i;
u16 var = 0;
u16 src[6];
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
if (gTasks[taskId].data[5] != 0)
{
2018-06-17 16:48:58 +02:00
switch (battlerId)
2017-12-17 20:10:57 +01:00
{
case 0:
var = 0x3F & gTasks[taskId].data[3];
break;
case 1:
var = (0xFC0 & gTasks[taskId].data[4]) >> 6;
break;
case 2:
var = (0xFC0 & gTasks[taskId].data[3]) >> 6;
break;
case 3:
var = 0x3F & gTasks[taskId].data[4];
break;
}
}
else
{
2018-06-17 16:48:58 +02:00
switch (battlerId)
2017-12-17 20:10:57 +01:00
{
case 0:
var = 0x3F & gTasks[taskId].data[3];
break;
case 1:
var = 0x3F & gTasks[taskId].data[4];
break;
case 2:
var = (0xFC0 & gTasks[taskId].data[3]) >> 6;
break;
case 3:
var = (0xFC0 & gTasks[taskId].data[4]) >> 6;
break;
}
}
for (i = 0; i < 3; i++)
{
src[i] = ((var & (3 << (i * 2))) >> (i * 2)) + 0x6001;
}
CopyToBgTilemapBufferRect_ChangePalette(bgId, src, destX, destY, 3, 1, 0x11);
CopyBgTilemapBufferToVram(bgId);
}
else
{
2018-06-17 16:48:58 +02:00
if (battlerId == gBattleScripting.multiplayerId)
2017-12-17 20:10:57 +01:00
var = gTasks[taskId].data[3];
else
var = gTasks[taskId].data[4];
for (i = 0; i < 6; i++)
{
src[i] = ((var & (3 << (i * 2))) >> (i * 2)) + 0x6001;
}
CopyToBgTilemapBufferRect_ChangePalette(bgId, src, destX, destY, 6, 1, 0x11);
CopyBgTilemapBufferToVram(bgId);
}
}
static void sub_8035C4C(void)
{
2018-01-16 22:12:38 +01:00
if (gBattleOutcome == B_OUTCOME_DREW)
2017-12-17 20:10:57 +01:00
{
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Draw, 0x15);
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:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x16);
BattlePutTextOnWindow(gText_Loss, 0x17);
2017-12-17 20:10:57 +01:00
break;
case 1:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x17);
BattlePutTextOnWindow(gText_Loss, 0x16);
2017-12-17 20:10:57 +01:00
break;
case 2:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x16);
BattlePutTextOnWindow(gText_Loss, 0x17);
2017-12-17 20:10:57 +01:00
break;
case 3:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x17);
BattlePutTextOnWindow(gText_Loss, 0x16);
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:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x17);
BattlePutTextOnWindow(gText_Loss, 0x16);
2017-12-17 20:10:57 +01:00
break;
case 1:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x16);
BattlePutTextOnWindow(gText_Loss, 0x17);
2017-12-17 20:10:57 +01:00
break;
case 2:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x17);
BattlePutTextOnWindow(gText_Loss, 0x16);
2017-12-17 20:10:57 +01:00
break;
case 3:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x16);
BattlePutTextOnWindow(gText_Loss, 0x17);
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
{
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x17);
BattlePutTextOnWindow(gText_Loss, 0x16);
2017-12-17 20:10:57 +01:00
}
else
{
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x16);
BattlePutTextOnWindow(gText_Loss, 0x17);
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
{
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x16);
BattlePutTextOnWindow(gText_Loss, 0x17);
2017-12-17 20:10:57 +01:00
}
else
{
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(gText_Win, 0x17);
BattlePutTextOnWindow(gText_Loss, 0x16);
2017-12-17 20:10:57 +01:00
}
}
}
void sub_8035D74(u8 taskId)
{
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:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(name, 0x11);
2018-07-22 12:49:49 +02:00
sub_8035AE4(taskId, linkPlayer->id, 1, 2, 4);
2017-12-17 20:10:57 +01:00
break;
case 1:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(name, 0x12);
2018-07-22 12:49:49 +02:00
sub_8035AE4(taskId, linkPlayer->id, 2, 2, 4);
2017-12-17 20:10:57 +01:00
break;
case 2:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(name, 0x13);
2018-07-22 12:49:49 +02:00
sub_8035AE4(taskId, linkPlayer->id, 1, 2, 8);
2017-12-17 20:10:57 +01:00
break;
case 3:
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(name, 0x14);
2018-07-22 12:49:49 +02:00
sub_8035AE4(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;
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(name, 0xF);
2017-12-17 20:10:57 +01:00
name = gLinkPlayers[opponentId].name;
2018-06-17 16:48:58 +02:00
BattlePutTextOnWindow(name, 0x10);
2017-12-17 20:10:57 +01:00
sub_8035AE4(taskId, playerId, 1, 2, 7);
sub_8035AE4(taskId, opponentId, 2, 2, 7);
}
gTasks[taskId].data[0]++;
break;
case 1:
palId = AllocSpritePalette(0x2710);
gPlttBufferUnfaded[palId * 16 + 0x10F] = gPlttBufferFaded[palId * 16 + 0x10F] = 0x7FFF;
gBattleStruct->linkBattleVsSpriteId_V = CreateSprite(&gUnknown_0831A9D0, 111, 80, 0);
gBattleStruct->linkBattleVsSpriteId_S = CreateSprite(&gUnknown_0831A9E8, 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)
sub_8035C4C();
PlaySE(SE_W231);
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;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].data[1] = gSprites[gBattleStruct->linkBattleVsSpriteId_V].pos1.x;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].data[1] = gSprites[gBattleStruct->linkBattleVsSpriteId_S].pos1.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)
{
LZDecompressVram(gUnknown_08D778F0, (void*)(VRAM + 0x4000));
LZDecompressVram(gUnknown_08D77B0C, (void*)(VRAM + 0x10000));
LoadCompressedPalette(gUnknown_08D77AE4, 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);
CopyToBgTilemapBuffer(1, gUnknown_08D779D8, 0, 0);
CopyToBgTilemapBuffer(2, gUnknown_08D779D8, 0, 0);
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2);
SetGpuReg(REG_OFFSET_WININ, 0x36);
SetGpuReg(REG_OFFSET_WINOUT, 0x36);
gBattle_BG1_Y = 0xFF5C;
gBattle_BG2_Y = 0xFF5C;
2018-12-17 23:00:08 +01:00
LoadCompressedSpriteSheetUsingHeap(&gUnknown_0831AA00);
2017-12-17 20:10:57 +01:00
}
else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
{
if (!(gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || gPartnerTrainerId == TRAINER_STEVEN_PARTNER)
2017-12-17 20:10:57 +01:00
{
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void*)(VRAM + 0xE000));
}
else
{
2018-12-26 13:05:02 +01:00
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 2);
SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 2);
2017-12-17 20:10:57 +01:00
CopyToBgTilemapBuffer(1, gUnknown_08D857A8, 0, 0);
CopyToBgTilemapBuffer(2, gUnknown_08D85A1C, 0, 0);
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2);
}
}
else if (gBattleTypeFlags & BATTLE_TYPE_GROUDON)
{
LZDecompressVram(gBattleTerrainAnimTiles_Cave, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Cave, (void*)(VRAM + 0xE000));
}
2017-12-19 17:41:05 +01:00
else if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE)
2017-12-17 20:10:57 +01:00
{
LZDecompressVram(gBattleTerrainAnimTiles_Underwater, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Underwater, (void*)(VRAM + 0xE000));
}
else if (gBattleTypeFlags & BATTLE_TYPE_RAYQUAZA)
{
LZDecompressVram(gBattleTerrainAnimTiles_Rayquaza, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Rayquaza, (void*)(VRAM + 0xE000));
}
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
{
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void*)(VRAM + 0xE000));
return;
}
2017-12-19 17:41:05 +01:00
else if (trainerClass == TRAINER_CLASS_CHAMPION)
2017-12-17 20:10:57 +01:00
{
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void*)(VRAM + 0xE000));
return;
}
}
if (GetCurrentMapBattleScene() == MAP_BATTLE_SCENE_NORMAL)
{
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].entryTileset, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].entryTilemap, (void*)(VRAM + 0xE000));
}
else
{
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void*)(VRAM + 0xE000));
}
}
}
bool8 LoadChosenBattleElement(u8 caseId)
{
bool8 ret = FALSE;
switch (caseId)
{
case 0:
LZDecompressVram(gBattleTextboxTiles, (void*)(VRAM));
break;
case 1:
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
CopyBgTilemapBufferToVram(0);
break;
case 2:
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40);
break;
case 3:
if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
{
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
}
else if (gBattleTypeFlags & BATTLE_TYPE_GROUDON)
{
LZDecompressVram(gBattleTerrainTiles_Cave, (void*)(VRAM + 0x8000));
}
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
{
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
break;
}
2017-12-19 17:41:05 +01:00
else if (trainerClass == TRAINER_CLASS_CHAMPION)
2017-12-17 20:10:57 +01:00
{
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
}
}
switch (GetCurrentMapBattleScene())
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].tileset, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_GYM:
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_MAGMA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_AQUA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_SIDNEY:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_PHOEBE:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_GLACIA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_DRAKE:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_FRONTIER:
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
break;
}
}
break;
case 4:
if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
{
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
}
else if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE_GROUDON)
{
if (gGameVersion == VERSION_RUBY)
LZDecompressVram(gBattleTerrainTilemap_Cave, (void*)(VRAM + 0xD000));
else
LZDecompressVram(gBattleTerrainTilemap_Water, (void*)(VRAM + 0xD000));
}
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
{
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
break;
}
2017-12-19 17:41:05 +01:00
else if (trainerClass == TRAINER_CLASS_CHAMPION)
2017-12-17 20:10:57 +01:00
{
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
}
}
switch (GetCurrentMapBattleScene())
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].tilemap, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_GYM:
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_MAGMA:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_AQUA:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_SIDNEY:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_PHOEBE:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_GLACIA:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_DRAKE:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_FRONTIER:
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
break;
}
}
break;
case 5:
if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
{
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(gBattleTerrainTable[gBattleTerrain].palette, 0x20, 0x60);
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;
}