Skip to content

Commit 01e6fb6

Browse files
committed
Document some battle_bg-related things
1 parent 1475c4d commit 01e6fb6

10 files changed

+79
-82
lines changed
File renamed without changes.

include/battle_bg.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
#define GUARD_BATTLE_BG_H
33

44
void BattleInitBgsAndWindows(void);
5-
void sub_80356D0(void);
5+
void InitBattleBgsVideo(void);
66
void LoadBattleMenuWindowGfx(void);
77
void DrawMainBattleBackground(void);
88
void LoadBattleTextboxAndBackground(void);
9-
void sub_8035D74(u8 taskId);
9+
void InitLinkBattleVsScreen(u8 taskId);
1010
void DrawBattleEntryBackground(void);
1111
bool8 LoadChosenBattleElement(u8 caseId);
1212

include/battle_message.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ struct BattleMsgData
213213
void BufferStringBattle(u16 stringID);
214214
u32 BattleStringExpandPlaceholdersToDisplayedString(const u8* src);
215215
u32 BattleStringExpandPlaceholders(const u8* src, u8* dst);
216-
void BattlePutTextOnWindow(const u8* text, u8 arg1);
216+
void BattlePutTextOnWindow(const u8* text, u8 windowId);
217217
void SetPpNumbersPaletteInMoveSelection(void);
218218
u8 GetCurrentPpToMaxPpState(u8 currentPp, u8 maxPp);
219219

include/graphics.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3208,7 +3208,7 @@ extern const u32 gBattleTextboxTiles[];
32083208
extern const u32 gBattleTextboxTilemap[];
32093209
extern const u32 gBattleTextboxPalette[];
32103210
extern const u32 gUnknown_08D778F0[];
3211-
extern const u32 gUnknown_08D77B0C[];
3211+
extern const u32 gVsLettersGfx[];
32123212
extern const u32 gUnknown_08D77AE4[];
32133213
extern const u32 gUnknown_08D779D8[];
32143214
extern const u32 gUnknown_08D857A8[];
@@ -4122,7 +4122,7 @@ extern const u32 gUnknown_08D84970[];
41224122
extern const u32 gUnknown_08D84F00[];
41234123
extern const u32 gUnknown_08D85444[];
41244124
extern const u32 gUnknown_08D85358[];
4125-
extern const u32 gUnknown_08D85600[];
4125+
extern const u32 gBattleWindowTextPalette[];
41264126
extern const u32 gUnknown_08D854C8[];
41274127
extern const u32 gUnknown_08D82F10[];
41284128
extern const u32 gUnknown_08D834FC[];

src/battle_bg.c

+60-63
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct BattleBackground
3636
// .rodata
3737
static const u16 sUnrefArray[] = {0x0300, 0x0000}; //OamData?
3838

39-
static const struct OamData gUnknown_0831A988 =
39+
static const struct OamData sVsLetter_V_OamData =
4040
{
4141
.y = 0,
4242
.affineMode = 3,
@@ -53,7 +53,7 @@ static const struct OamData gUnknown_0831A988 =
5353
.affineParam = 0,
5454
};
5555

56-
static const struct OamData gUnknown_0831A990 =
56+
static const struct OamData sVsLetter_S_OamData =
5757
{
5858
.y = 0,
5959
.affineMode = 3,
@@ -70,51 +70,53 @@ static const struct OamData gUnknown_0831A990 =
7070
.affineParam = 0,
7171
};
7272

73-
static const union AffineAnimCmd gUnknown_0831A998[] =
73+
static const union AffineAnimCmd sVsLetterAffineAnimCmds0[] =
7474
{
7575
AFFINEANIMCMD_FRAME(0x0080, 0x0080, 0x00, 0x00),
7676
AFFINEANIMCMD_END,
7777
};
7878

79-
static const union AffineAnimCmd gUnknown_0831A9A8[] =
79+
static const union AffineAnimCmd sVsLetterAffineAnimCmds1[] =
8080
{
8181
AFFINEANIMCMD_FRAME(0x0080, 0x0080, 0x00, 0x00),
8282
AFFINEANIMCMD_FRAME(0x0018, 0x0018, 0x00, 0x80),
8383
AFFINEANIMCMD_FRAME(0x0018, 0x0018, 0x00, 0x80),
8484
AFFINEANIMCMD_END,
8585
};
8686

87-
static const union AffineAnimCmd * const gUnknown_0831A9C8[] =
87+
static const union AffineAnimCmd *const sVsLetterAffineAnimTable[] =
8888
{
89-
gUnknown_0831A998,
90-
gUnknown_0831A9A8,
89+
sVsLetterAffineAnimCmds0,
90+
sVsLetterAffineAnimCmds1,
9191
};
9292

93-
static const struct SpriteTemplate gUnknown_0831A9D0 =
93+
#define TAG_VS_LETTERS 10000
94+
95+
static const struct SpriteTemplate sVsLetter_V_SpriteTemplate =
9496
{
95-
.tileTag = 0x2710,
96-
.paletteTag = 0x2710,
97-
.oam = &gUnknown_0831A988,
97+
.tileTag = TAG_VS_LETTERS,
98+
.paletteTag = TAG_VS_LETTERS,
99+
.oam = &sVsLetter_V_OamData,
98100
.anims = gDummySpriteAnimTable,
99101
.images = NULL,
100-
.affineAnims = gUnknown_0831A9C8,
102+
.affineAnims = sVsLetterAffineAnimTable,
101103
.callback = nullsub_17
102104
};
103105

104-
static const struct SpriteTemplate gUnknown_0831A9E8 =
106+
static const struct SpriteTemplate sVsLetter_S_SpriteTemplate =
105107
{
106-
.tileTag = 0x2710,
107-
.paletteTag = 0x2710,
108-
.oam = &gUnknown_0831A990,
108+
.tileTag = TAG_VS_LETTERS,
109+
.paletteTag = TAG_VS_LETTERS,
110+
.oam = &sVsLetter_S_OamData,
109111
.anims = gDummySpriteAnimTable,
110112
.images = NULL,
111-
.affineAnims = gUnknown_0831A9C8,
113+
.affineAnims = sVsLetterAffineAnimTable,
112114
.callback = nullsub_17
113115
};
114116

115-
static const struct CompressedSpriteSheet gUnknown_0831AA00 =
117+
static const struct CompressedSpriteSheet sVsLettersSpriteSheet =
116118
{
117-
gUnknown_08D77B0C, 0x1000, 0x2710
119+
gVsLettersGfx, 0x1000, TAG_VS_LETTERS
118120
};
119121

120122
const struct BgTemplate gBattleBgTemplates[] =
@@ -689,7 +691,6 @@ static const struct BattleBackground gBattleTerrainTable[] =
689691
},
690692
};
691693

692-
// .text
693694
void BattleInitBgsAndWindows(void)
694695
{
695696
ResetBgsAndClearDma3BusyFlags(0);
@@ -710,7 +711,7 @@ void BattleInitBgsAndWindows(void)
710711
DeactivateAllTextPrinters();
711712
}
712713

713-
void sub_80356D0(void)
714+
void InitBattleBgsVideo(void)
714715
{
715716
DisableInterrupts(INTR_FLAG_HBLANK);
716717
EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL);
@@ -725,10 +726,11 @@ void LoadBattleMenuWindowGfx(void)
725726
{
726727
LoadUserWindowBorderGfx(2, 0x12, 0x10);
727728
LoadUserWindowBorderGfx(2, 0x22, 0x10);
728-
LoadCompressedPalette(gUnknown_08D85600, 0x50, 0x20);
729+
LoadCompressedPalette(gBattleWindowTextPalette, 0x50, 0x20);
729730

730731
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
731732
{
733+
// Load graphics for the Battle Arena referee's mid-battle messages.
732734
Menu_LoadStdPalAt(0x70);
733735
LoadMessageBoxGfx(0, 0x30, 0x70);
734736
gPlttBufferUnfaded[0x76] = 0;
@@ -837,86 +839,81 @@ void DrawMainBattleBackground(void)
837839

838840
void LoadBattleTextboxAndBackground(void)
839841
{
840-
LZDecompressVram(gBattleTextboxTiles, (void*)(VRAM));
842+
LZDecompressVram(gBattleTextboxTiles, (void*)(BG_CHAR_ADDR(0)));
841843
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
842844
CopyBgTilemapBufferToVram(0);
843845
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40);
844846
LoadBattleMenuWindowGfx();
845-
846847
DrawMainBattleBackground();
847848
}
848849

849-
static void sub_8035AE4(u8 taskId, u8 battlerId, u8 bgId, u8 destX, u8 destY)
850+
static void DrawLinkBattleParticipantPokeballs(u8 taskId, u8 multiplayerId, u8 bgId, u8 destX, u8 destY)
850851
{
851852
s32 i;
852-
u16 var = 0;
853-
u16 src[6];
853+
u16 pokeballStatuses = 0;
854+
u16 tiles[6];
854855

855856
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
856857
{
857858
if (gTasks[taskId].data[5] != 0)
858859
{
859-
switch (battlerId)
860+
switch (multiplayerId)
860861
{
861862
case 0:
862-
var = 0x3F & gTasks[taskId].data[3];
863+
pokeballStatuses = 0x3F & gTasks[taskId].data[3];
863864
break;
864865
case 1:
865-
var = (0xFC0 & gTasks[taskId].data[4]) >> 6;
866+
pokeballStatuses = (0xFC0 & gTasks[taskId].data[4]) >> 6;
866867
break;
867868
case 2:
868-
var = (0xFC0 & gTasks[taskId].data[3]) >> 6;
869+
pokeballStatuses = (0xFC0 & gTasks[taskId].data[3]) >> 6;
869870
break;
870871
case 3:
871-
var = 0x3F & gTasks[taskId].data[4];
872+
pokeballStatuses = 0x3F & gTasks[taskId].data[4];
872873
break;
873874
}
874875
}
875876
else
876877
{
877-
switch (battlerId)
878+
switch (multiplayerId)
878879
{
879880
case 0:
880-
var = 0x3F & gTasks[taskId].data[3];
881+
pokeballStatuses = 0x3F & gTasks[taskId].data[3];
881882
break;
882883
case 1:
883-
var = 0x3F & gTasks[taskId].data[4];
884+
pokeballStatuses = 0x3F & gTasks[taskId].data[4];
884885
break;
885886
case 2:
886-
var = (0xFC0 & gTasks[taskId].data[3]) >> 6;
887+
pokeballStatuses = (0xFC0 & gTasks[taskId].data[3]) >> 6;
887888
break;
888889
case 3:
889-
var = (0xFC0 & gTasks[taskId].data[4]) >> 6;
890+
pokeballStatuses = (0xFC0 & gTasks[taskId].data[4]) >> 6;
890891
break;
891892
}
892893
}
893894

894895
for (i = 0; i < 3; i++)
895-
{
896-
src[i] = ((var & (3 << (i * 2))) >> (i * 2)) + 0x6001;
897-
}
896+
tiles[i] = ((pokeballStatuses & (3 << (i * 2))) >> (i * 2)) + 0x6001;
898897

899-
CopyToBgTilemapBufferRect_ChangePalette(bgId, src, destX, destY, 3, 1, 0x11);
898+
CopyToBgTilemapBufferRect_ChangePalette(bgId, tiles, destX, destY, 3, 1, 0x11);
900899
CopyBgTilemapBufferToVram(bgId);
901900
}
902901
else
903902
{
904-
if (battlerId == gBattleScripting.multiplayerId)
905-
var = gTasks[taskId].data[3];
903+
if (multiplayerId == gBattleScripting.multiplayerId)
904+
pokeballStatuses = gTasks[taskId].data[3];
906905
else
907-
var = gTasks[taskId].data[4];
906+
pokeballStatuses = gTasks[taskId].data[4];
908907

909908
for (i = 0; i < 6; i++)
910-
{
911-
src[i] = ((var & (3 << (i * 2))) >> (i * 2)) + 0x6001;
912-
}
909+
tiles[i] = ((pokeballStatuses & (3 << (i * 2))) >> (i * 2)) + 0x6001;
913910

914-
CopyToBgTilemapBufferRect_ChangePalette(bgId, src, destX, destY, 6, 1, 0x11);
911+
CopyToBgTilemapBufferRect_ChangePalette(bgId, tiles, destX, destY, 6, 1, 0x11);
915912
CopyBgTilemapBufferToVram(bgId);
916913
}
917914
}
918915

919-
static void sub_8035C4C(void)
916+
static void DrawLinkBattleVsScreenOutcomeText(void)
920917
{
921918
if (gBattleOutcome == B_OUTCOME_DREW)
922919
{
@@ -997,7 +994,7 @@ static void sub_8035C4C(void)
997994
}
998995
}
999996

1000-
void sub_8035D74(u8 taskId)
997+
void InitLinkBattleVsScreen(u8 taskId)
1001998
{
1002999
struct LinkPlayer *linkPlayer;
10031000
u8 *name;
@@ -1017,19 +1014,19 @@ void sub_8035D74(u8 taskId)
10171014
{
10181015
case 0:
10191016
BattlePutTextOnWindow(name, 0x11);
1020-
sub_8035AE4(taskId, linkPlayer->id, 1, 2, 4);
1017+
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 1, 2, 4);
10211018
break;
10221019
case 1:
10231020
BattlePutTextOnWindow(name, 0x12);
1024-
sub_8035AE4(taskId, linkPlayer->id, 2, 2, 4);
1021+
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 2, 2, 4);
10251022
break;
10261023
case 2:
10271024
BattlePutTextOnWindow(name, 0x13);
1028-
sub_8035AE4(taskId, linkPlayer->id, 1, 2, 8);
1025+
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 1, 2, 8);
10291026
break;
10301027
case 3:
10311028
BattlePutTextOnWindow(name, 0x14);
1032-
sub_8035AE4(taskId, linkPlayer->id, 2, 2, 8);
1029+
DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 2, 2, 8);
10331030
break;
10341031
}
10351032
}
@@ -1049,16 +1046,16 @@ void sub_8035D74(u8 taskId)
10491046
name = gLinkPlayers[opponentId].name;
10501047
BattlePutTextOnWindow(name, 0x10);
10511048

1052-
sub_8035AE4(taskId, playerId, 1, 2, 7);
1053-
sub_8035AE4(taskId, opponentId, 2, 2, 7);
1049+
DrawLinkBattleParticipantPokeballs(taskId, playerId, 1, 2, 7);
1050+
DrawLinkBattleParticipantPokeballs(taskId, opponentId, 2, 2, 7);
10541051
}
10551052
gTasks[taskId].data[0]++;
10561053
break;
10571054
case 1:
1058-
palId = AllocSpritePalette(0x2710);
1055+
palId = AllocSpritePalette(TAG_VS_LETTERS);
10591056
gPlttBufferUnfaded[palId * 16 + 0x10F] = gPlttBufferFaded[palId * 16 + 0x10F] = 0x7FFF;
1060-
gBattleStruct->linkBattleVsSpriteId_V = CreateSprite(&gUnknown_0831A9D0, 111, 80, 0);
1061-
gBattleStruct->linkBattleVsSpriteId_S = CreateSprite(&gUnknown_0831A9E8, 129, 80, 0);
1057+
gBattleStruct->linkBattleVsSpriteId_V = CreateSprite(&sVsLetter_V_SpriteTemplate, 111, 80, 0);
1058+
gBattleStruct->linkBattleVsSpriteId_S = CreateSprite(&sVsLetter_S_SpriteTemplate, 129, 80, 0);
10621059
gSprites[gBattleStruct->linkBattleVsSpriteId_V].invisible = TRUE;
10631060
gSprites[gBattleStruct->linkBattleVsSpriteId_S].invisible = TRUE;
10641061
gTasks[taskId].data[0]++;
@@ -1087,7 +1084,7 @@ void sub_8035D74(u8 taskId)
10871084
else
10881085
{
10891086
if (gTasks[taskId].data[5] != 0)
1090-
sub_8035C4C();
1087+
DrawLinkBattleVsScreenOutcomeText();
10911088

10921089
PlaySE(SE_W231);
10931090
DestroyTask(taskId);
@@ -1110,7 +1107,7 @@ void DrawBattleEntryBackground(void)
11101107
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
11111108
{
11121109
LZDecompressVram(gUnknown_08D778F0, (void*)(BG_CHAR_ADDR(1)));
1113-
LZDecompressVram(gUnknown_08D77B0C, (void*)(VRAM + 0x10000));
1110+
LZDecompressVram(gVsLettersGfx, (void*)(VRAM + 0x10000));
11141111
LoadCompressedPalette(gUnknown_08D77AE4, 0x60, 0x20);
11151112
SetBgAttribute(1, BG_ATTR_SCREENSIZE, 1);
11161113
SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04);
@@ -1122,7 +1119,7 @@ void DrawBattleEntryBackground(void)
11221119
SetGpuReg(REG_OFFSET_WINOUT, 0x36);
11231120
gBattle_BG1_Y = 0xFF5C;
11241121
gBattle_BG2_Y = 0xFF5C;
1125-
LoadCompressedSpriteSheetUsingHeap(&gUnknown_0831AA00);
1122+
LoadCompressedSpriteSheetUsingHeap(&sVsLettersSpriteSheet);
11261123
}
11271124
else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
11281125
{
@@ -1195,7 +1192,7 @@ bool8 LoadChosenBattleElement(u8 caseId)
11951192
switch (caseId)
11961193
{
11971194
case 0:
1198-
LZDecompressVram(gBattleTextboxTiles, (void*)(VRAM));
1195+
LZDecompressVram(gBattleTextboxTiles, (void*)(BG_CHAR_ADDR(0)));
11991196
break;
12001197
case 1:
12011198
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);

src/battle_dome.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3414,7 +3414,7 @@ static void Task_ShowOpponentInfo(u8 taskId)
34143414
LoadCompressedSpriteSheet(sDomeOptionsSpriteSheet);
34153415
LoadCompressedPalette(gUnknown_08D85358, 0, 0x200);
34163416
LoadCompressedPalette(gUnknown_08D85444, 0x100, 0x200);
3417-
LoadCompressedPalette(gUnknown_08D85600, 0xF0, 0x20);
3417+
LoadCompressedPalette(gBattleWindowTextPalette, 0xF0, 0x20);
34183418
if (r9 == 2)
34193419
LoadCompressedPalette(gUnknown_08D854C8, 0x50, 0x20);
34203420
CpuFill32(0, gPlttBufferFaded, 0x400);
@@ -5574,7 +5574,7 @@ static void Task_ShowTourneyTree(u8 taskId)
55745574
DecompressAndLoadBgGfxUsingHeap(3, gUnknown_08D83C3C, 0x2000, 0, 1);
55755575
LoadCompressedPalette(gUnknown_08D85358, 0, 0x200);
55765576
LoadCompressedPalette(gUnknown_08D85444, 0x100, 0x200);
5577-
LoadCompressedPalette(gUnknown_08D85600, 0xF0, 0x20);
5577+
LoadCompressedPalette(gBattleWindowTextPalette, 0xF0, 0x20);
55785578
CpuFill32(0, gPlttBufferFaded, 0x400);
55795579
ShowBg(0);
55805580
ShowBg(1);

0 commit comments

Comments
 (0)