Document some battle_bg-related things

This commit is contained in:
Marcus Huderle 2019-11-06 18:18:11 -06:00 committed by huderlem
parent 1475c4d8da
commit 01e6fb6dd0
10 changed files with 79 additions and 82 deletions

View file

@ -2,11 +2,11 @@
#define GUARD_BATTLE_BG_H
void BattleInitBgsAndWindows(void);
void sub_80356D0(void);
void InitBattleBgsVideo(void);
void LoadBattleMenuWindowGfx(void);
void DrawMainBattleBackground(void);
void LoadBattleTextboxAndBackground(void);
void sub_8035D74(u8 taskId);
void InitLinkBattleVsScreen(u8 taskId);
void DrawBattleEntryBackground(void);
bool8 LoadChosenBattleElement(u8 caseId);

View file

@ -213,7 +213,7 @@ struct BattleMsgData
void BufferStringBattle(u16 stringID);
u32 BattleStringExpandPlaceholdersToDisplayedString(const u8* src);
u32 BattleStringExpandPlaceholders(const u8* src, u8* dst);
void BattlePutTextOnWindow(const u8* text, u8 arg1);
void BattlePutTextOnWindow(const u8* text, u8 windowId);
void SetPpNumbersPaletteInMoveSelection(void);
u8 GetCurrentPpToMaxPpState(u8 currentPp, u8 maxPp);

View file

@ -3208,7 +3208,7 @@ extern const u32 gBattleTextboxTiles[];
extern const u32 gBattleTextboxTilemap[];
extern const u32 gBattleTextboxPalette[];
extern const u32 gUnknown_08D778F0[];
extern const u32 gUnknown_08D77B0C[];
extern const u32 gVsLettersGfx[];
extern const u32 gUnknown_08D77AE4[];
extern const u32 gUnknown_08D779D8[];
extern const u32 gUnknown_08D857A8[];
@ -4122,7 +4122,7 @@ extern const u32 gUnknown_08D84970[];
extern const u32 gUnknown_08D84F00[];
extern const u32 gUnknown_08D85444[];
extern const u32 gUnknown_08D85358[];
extern const u32 gUnknown_08D85600[];
extern const u32 gBattleWindowTextPalette[];
extern const u32 gUnknown_08D854C8[];
extern const u32 gUnknown_08D82F10[];
extern const u32 gUnknown_08D834FC[];

View file

@ -36,7 +36,7 @@ struct BattleBackground
// .rodata
static const u16 sUnrefArray[] = {0x0300, 0x0000}; //OamData?
static const struct OamData gUnknown_0831A988 =
static const struct OamData sVsLetter_V_OamData =
{
.y = 0,
.affineMode = 3,
@ -53,7 +53,7 @@ static const struct OamData gUnknown_0831A988 =
.affineParam = 0,
};
static const struct OamData gUnknown_0831A990 =
static const struct OamData sVsLetter_S_OamData =
{
.y = 0,
.affineMode = 3,
@ -70,13 +70,13 @@ static const struct OamData gUnknown_0831A990 =
.affineParam = 0,
};
static const union AffineAnimCmd gUnknown_0831A998[] =
static const union AffineAnimCmd sVsLetterAffineAnimCmds0[] =
{
AFFINEANIMCMD_FRAME(0x0080, 0x0080, 0x00, 0x00),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd gUnknown_0831A9A8[] =
static const union AffineAnimCmd sVsLetterAffineAnimCmds1[] =
{
AFFINEANIMCMD_FRAME(0x0080, 0x0080, 0x00, 0x00),
AFFINEANIMCMD_FRAME(0x0018, 0x0018, 0x00, 0x80),
@ -84,37 +84,39 @@ static const union AffineAnimCmd gUnknown_0831A9A8[] =
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd * const gUnknown_0831A9C8[] =
static const union AffineAnimCmd *const sVsLetterAffineAnimTable[] =
{
gUnknown_0831A998,
gUnknown_0831A9A8,
sVsLetterAffineAnimCmds0,
sVsLetterAffineAnimCmds1,
};
static const struct SpriteTemplate gUnknown_0831A9D0 =
#define TAG_VS_LETTERS 10000
static const struct SpriteTemplate sVsLetter_V_SpriteTemplate =
{
.tileTag = 0x2710,
.paletteTag = 0x2710,
.oam = &gUnknown_0831A988,
.tileTag = TAG_VS_LETTERS,
.paletteTag = TAG_VS_LETTERS,
.oam = &sVsLetter_V_OamData,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gUnknown_0831A9C8,
.affineAnims = sVsLetterAffineAnimTable,
.callback = nullsub_17
};
static const struct SpriteTemplate gUnknown_0831A9E8 =
static const struct SpriteTemplate sVsLetter_S_SpriteTemplate =
{
.tileTag = 0x2710,
.paletteTag = 0x2710,
.oam = &gUnknown_0831A990,
.tileTag = TAG_VS_LETTERS,
.paletteTag = TAG_VS_LETTERS,
.oam = &sVsLetter_S_OamData,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gUnknown_0831A9C8,
.affineAnims = sVsLetterAffineAnimTable,
.callback = nullsub_17
};
static const struct CompressedSpriteSheet gUnknown_0831AA00 =
static const struct CompressedSpriteSheet sVsLettersSpriteSheet =
{
gUnknown_08D77B0C, 0x1000, 0x2710
gVsLettersGfx, 0x1000, TAG_VS_LETTERS
};
const struct BgTemplate gBattleBgTemplates[] =
@ -689,7 +691,6 @@ static const struct BattleBackground gBattleTerrainTable[] =
},
};
// .text
void BattleInitBgsAndWindows(void)
{
ResetBgsAndClearDma3BusyFlags(0);
@ -710,7 +711,7 @@ void BattleInitBgsAndWindows(void)
DeactivateAllTextPrinters();
}
void sub_80356D0(void)
void InitBattleBgsVideo(void)
{
DisableInterrupts(INTR_FLAG_HBLANK);
EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL);
@ -725,10 +726,11 @@ void LoadBattleMenuWindowGfx(void)
{
LoadUserWindowBorderGfx(2, 0x12, 0x10);
LoadUserWindowBorderGfx(2, 0x22, 0x10);
LoadCompressedPalette(gUnknown_08D85600, 0x50, 0x20);
LoadCompressedPalette(gBattleWindowTextPalette, 0x50, 0x20);
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
{
// Load graphics for the Battle Arena referee's mid-battle messages.
Menu_LoadStdPalAt(0x70);
LoadMessageBoxGfx(0, 0x30, 0x70);
gPlttBufferUnfaded[0x76] = 0;
@ -837,86 +839,81 @@ void DrawMainBattleBackground(void)
void LoadBattleTextboxAndBackground(void)
{
LZDecompressVram(gBattleTextboxTiles, (void*)(VRAM));
LZDecompressVram(gBattleTextboxTiles, (void*)(BG_CHAR_ADDR(0)));
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
CopyBgTilemapBufferToVram(0);
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40);
LoadBattleMenuWindowGfx();
DrawMainBattleBackground();
}
static void sub_8035AE4(u8 taskId, u8 battlerId, u8 bgId, u8 destX, u8 destY)
static void DrawLinkBattleParticipantPokeballs(u8 taskId, u8 multiplayerId, u8 bgId, u8 destX, u8 destY)
{
s32 i;
u16 var = 0;
u16 src[6];
u16 pokeballStatuses = 0;
u16 tiles[6];
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
if (gTasks[taskId].data[5] != 0)
{
switch (battlerId)
switch (multiplayerId)
{
case 0:
var = 0x3F & gTasks[taskId].data[3];
pokeballStatuses = 0x3F & gTasks[taskId].data[3];
break;
case 1:
var = (0xFC0 & gTasks[taskId].data[4]) >> 6;
pokeballStatuses = (0xFC0 & gTasks[taskId].data[4]) >> 6;
break;
case 2:
var = (0xFC0 & gTasks[taskId].data[3]) >> 6;
pokeballStatuses = (0xFC0 & gTasks[taskId].data[3]) >> 6;
break;
case 3:
var = 0x3F & gTasks[taskId].data[4];
pokeballStatuses = 0x3F & gTasks[taskId].data[4];
break;
}
}
else
{
switch (battlerId)
switch (multiplayerId)
{
case 0:
var = 0x3F & gTasks[taskId].data[3];
pokeballStatuses = 0x3F & gTasks[taskId].data[3];
break;
case 1:
var = 0x3F & gTasks[taskId].data[4];
pokeballStatuses = 0x3F & gTasks[taskId].data[4];
break;
case 2:
var = (0xFC0 & gTasks[taskId].data[3]) >> 6;
pokeballStatuses = (0xFC0 & gTasks[taskId].data[3]) >> 6;
break;
case 3:
var = (0xFC0 & gTasks[taskId].data[4]) >> 6;
pokeballStatuses = (0xFC0 & gTasks[taskId].data[4]) >> 6;
break;
}
}
for (i = 0; i < 3; i++)
{
src[i] = ((var & (3 << (i * 2))) >> (i * 2)) + 0x6001;
}
tiles[i] = ((pokeballStatuses & (3 << (i * 2))) >> (i * 2)) + 0x6001;
CopyToBgTilemapBufferRect_ChangePalette(bgId, src, destX, destY, 3, 1, 0x11);
CopyToBgTilemapBufferRect_ChangePalette(bgId, tiles, destX, destY, 3, 1, 0x11);
CopyBgTilemapBufferToVram(bgId);
}
else
{
if (battlerId == gBattleScripting.multiplayerId)
var = gTasks[taskId].data[3];
if (multiplayerId == gBattleScripting.multiplayerId)
pokeballStatuses = gTasks[taskId].data[3];
else
var = gTasks[taskId].data[4];
pokeballStatuses = gTasks[taskId].data[4];
for (i = 0; i < 6; i++)
{
src[i] = ((var & (3 << (i * 2))) >> (i * 2)) + 0x6001;
}
tiles[i] = ((pokeballStatuses & (3 << (i * 2))) >> (i * 2)) + 0x6001;
CopyToBgTilemapBufferRect_ChangePalette(bgId, src, destX, destY, 6, 1, 0x11);
CopyToBgTilemapBufferRect_ChangePalette(bgId, tiles, destX, destY, 6, 1, 0x11);
CopyBgTilemapBufferToVram(bgId);
}
}
static void sub_8035C4C(void)
static void DrawLinkBattleVsScreenOutcomeText(void)
{
if (gBattleOutcome == B_OUTCOME_DREW)
{
@ -997,7 +994,7 @@ static void sub_8035C4C(void)
}
}
void sub_8035D74(u8 taskId)
void InitLinkBattleVsScreen(u8 taskId)
{
struct LinkPlayer *linkPlayer;
u8 *name;
@ -1017,19 +1014,19 @@ void sub_8035D74(u8 taskId)
{
case 0:
BattlePutTextOnWindow(name, 0x11);
sub_8035AE4(taskId, linkPlayer->id, 1, 2, 4);
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 1, 2, 4);
break;
case 1:
BattlePutTextOnWindow(name, 0x12);
sub_8035AE4(taskId, linkPlayer->id, 2, 2, 4);
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 2, 2, 4);
break;
case 2:
BattlePutTextOnWindow(name, 0x13);
sub_8035AE4(taskId, linkPlayer->id, 1, 2, 8);
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 1, 2, 8);
break;
case 3:
BattlePutTextOnWindow(name, 0x14);
sub_8035AE4(taskId, linkPlayer->id, 2, 2, 8);
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 2, 2, 8);
break;
}
}
@ -1049,16 +1046,16 @@ void sub_8035D74(u8 taskId)
name = gLinkPlayers[opponentId].name;
BattlePutTextOnWindow(name, 0x10);
sub_8035AE4(taskId, playerId, 1, 2, 7);
sub_8035AE4(taskId, opponentId, 2, 2, 7);
DrawLinkBattleParticipantPokeballs(taskId, playerId, 1, 2, 7);
DrawLinkBattleParticipantPokeballs(taskId, opponentId, 2, 2, 7);
}
gTasks[taskId].data[0]++;
break;
case 1:
palId = AllocSpritePalette(0x2710);
palId = AllocSpritePalette(TAG_VS_LETTERS);
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);
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;
gTasks[taskId].data[0]++;
@ -1087,7 +1084,7 @@ void sub_8035D74(u8 taskId)
else
{
if (gTasks[taskId].data[5] != 0)
sub_8035C4C();
DrawLinkBattleVsScreenOutcomeText();
PlaySE(SE_W231);
DestroyTask(taskId);
@ -1110,7 +1107,7 @@ void DrawBattleEntryBackground(void)
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
LZDecompressVram(gUnknown_08D778F0, (void*)(BG_CHAR_ADDR(1)));
LZDecompressVram(gUnknown_08D77B0C, (void*)(VRAM + 0x10000));
LZDecompressVram(gVsLettersGfx, (void*)(VRAM + 0x10000));
LoadCompressedPalette(gUnknown_08D77AE4, 0x60, 0x20);
SetBgAttribute(1, BG_ATTR_SCREENSIZE, 1);
SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04);
@ -1122,7 +1119,7 @@ void DrawBattleEntryBackground(void)
SetGpuReg(REG_OFFSET_WINOUT, 0x36);
gBattle_BG1_Y = 0xFF5C;
gBattle_BG2_Y = 0xFF5C;
LoadCompressedSpriteSheetUsingHeap(&gUnknown_0831AA00);
LoadCompressedSpriteSheetUsingHeap(&sVsLettersSpriteSheet);
}
else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
{
@ -1195,7 +1192,7 @@ bool8 LoadChosenBattleElement(u8 caseId)
switch (caseId)
{
case 0:
LZDecompressVram(gBattleTextboxTiles, (void*)(VRAM));
LZDecompressVram(gBattleTextboxTiles, (void*)(BG_CHAR_ADDR(0)));
break;
case 1:
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);

View file

@ -3414,7 +3414,7 @@ static void Task_ShowOpponentInfo(u8 taskId)
LoadCompressedSpriteSheet(sDomeOptionsSpriteSheet);
LoadCompressedPalette(gUnknown_08D85358, 0, 0x200);
LoadCompressedPalette(gUnknown_08D85444, 0x100, 0x200);
LoadCompressedPalette(gUnknown_08D85600, 0xF0, 0x20);
LoadCompressedPalette(gBattleWindowTextPalette, 0xF0, 0x20);
if (r9 == 2)
LoadCompressedPalette(gUnknown_08D854C8, 0x50, 0x20);
CpuFill32(0, gPlttBufferFaded, 0x400);
@ -5574,7 +5574,7 @@ static void Task_ShowTourneyTree(u8 taskId)
DecompressAndLoadBgGfxUsingHeap(3, gUnknown_08D83C3C, 0x2000, 0, 1);
LoadCompressedPalette(gUnknown_08D85358, 0, 0x200);
LoadCompressedPalette(gUnknown_08D85444, 0x100, 0x200);
LoadCompressedPalette(gUnknown_08D85600, 0xF0, 0x20);
LoadCompressedPalette(gBattleWindowTextPalette, 0xF0, 0x20);
CpuFill32(0, gPlttBufferFaded, 0x400);
ShowBg(0);
ShowBg(1);

View file

@ -687,7 +687,7 @@ static void CB2_InitBattleInternal(void)
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
gBattleTerrain = BATTLE_TERRAIN_BUILDING;
sub_80356D0();
InitBattleBgsVideo();
LoadBattleTextboxAndBackground();
ResetSpriteData();
ResetTasks();
@ -1024,7 +1024,7 @@ static void CB2_HandleStartBattle(void)
ResetBlockReceivedFlags();
sub_8036EB8(2, playerMultiplayerId);
SetAllPlayersBerryData();
taskId = CreateTask(sub_8035D74, 0);
taskId = CreateTask(InitLinkBattleVsScreen, 0);
gTasks[taskId].data[1] = 0x10E;
gTasks[taskId].data[2] = 0x5A;
gTasks[taskId].data[5] = 0;
@ -1226,7 +1226,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
ResetBlockReceivedFlags();
sub_8036EB8(2, playerMultiplayerId);
SetAllPlayersBerryData();
taskId = CreateTask(sub_8035D74, 0);
taskId = CreateTask(InitLinkBattleVsScreen, 0);
gTasks[taskId].data[1] = 0x10E;
gTasks[taskId].data[2] = 0x5A;
gTasks[taskId].data[5] = 0;
@ -1612,7 +1612,7 @@ static void CB2_HandleStartMultiBattle(void)
sub_8036EB8(4, playerMultiplayerId);
SetAllPlayersBerryData();
SetDeoxysStats();
var = CreateTask(sub_8035D74, 0);
var = CreateTask(InitLinkBattleVsScreen, 0);
gTasks[var].data[1] = 0x10E;
gTasks[var].data[2] = 0x5A;
gTasks[var].data[5] = 0;
@ -2250,7 +2250,7 @@ void sub_8038D64(void)
gBattle_BG3_X = 0;
gBattle_BG3_Y = 0;
sub_80356D0();
InitBattleBgsVideo();
LoadCompressedPalette(gBattleTextboxPalette, 0, 64);
LoadBattleMenuWindowGfx();
ResetSpriteData();
@ -2261,7 +2261,7 @@ void sub_8038D64(void)
gReservedSpritePaletteCount = 4;
SetVBlankCallback(VBlankCB_Battle);
taskId = CreateTask(sub_8035D74, 0);
taskId = CreateTask(InitLinkBattleVsScreen, 0);
gTasks[taskId].data[1] = 0x10E;
gTasks[taskId].data[2] = 0x5A;
gTasks[taskId].data[5] = 1;
@ -2446,7 +2446,7 @@ static void sub_80392A8(void)
gBattle_BG2_Y = 0;
gBattle_BG3_X = 0;
gBattle_BG3_Y = 0;
sub_80356D0();
InitBattleBgsVideo();
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
LoadBattleMenuWindowGfx();

View file

@ -10279,7 +10279,7 @@ static void Cmd_displaydexinfo(void)
}
break;
case 3:
sub_80356D0();
InitBattleBgsVideo();
LoadBattleTextboxAndBackground();
gBattle_BG3_X = 0x100;
gBattleCommunication[0]++;

View file

@ -235,7 +235,7 @@ void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo,
gBattleTerrain = BATTLE_TERRAIN_PLAIN;
sub_80356D0();
InitBattleBgsVideo();
LoadBattleTextboxAndBackground();
ResetSpriteData();
ScanlineEffect_Stop();
@ -341,7 +341,7 @@ static void CB2_EvolutionSceneLoadGraphics(void)
gBattleTerrain = BATTLE_TERRAIN_PLAIN;
sub_80356D0();
InitBattleBgsVideo();
LoadBattleTextboxAndBackground();
ResetSpriteData();
FreeAllSpritePalettes();

View file

@ -960,7 +960,7 @@ const u32 gUnknown_08D778F0[] = INCBIN_U32("graphics/battle_transitions/vs_frame
const u32 gUnknown_08D779D8[] = INCBIN_U32("graphics/battle_transitions/vs_frame.bin.lz");
const u32 gUnknown_08D77AE4[] = INCBIN_U32("graphics/battle_transitions/vs_frame.gbapal.lz");
const u32 gUnknown_08D77B0C[] = INCBIN_U32("graphics/battle_transitions/vs.4bpp.lz");
const u32 gVsLettersGfx[] = INCBIN_U32("graphics/battle_transitions/vs.4bpp.lz");
#include "data/graphics/battle_terrain.h"
@ -987,7 +987,7 @@ const u32 gUnknown_08D854C8[] = INCBIN_U32("graphics/battle_frontier/options_pal
const u32 gBattleArenaJudgementSymbolsGfx[] = INCBIN_U32("graphics/battle_frontier/arena_judgement_symbols.4bpp.lz");
const u32 gBattleArenaJudgementSymbolsPalette[] = INCBIN_U32("graphics/battle_frontier/arena_judgement_symbols.gbapal.lz");
const u32 gUnknown_08D85600[] = INCBIN_U32("graphics/battle_frontier/text.gbapal.lz");
const u32 gBattleWindowTextPalette[] = INCBIN_U32("graphics/battle_interface/text.gbapal.lz");
const u16 gUnknown_08D85620[] = INCBIN_U16("graphics/battle_frontier/text_pp.gbapal");
const u16 gTilesetAnims_BattleDomePals0_0[] = INCBIN_U16("graphics/battle_frontier/dome_anim1.gbapal");