summaryrefslogtreecommitdiff
path: root/src/battle/battle_interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/battle/battle_interface.c')
-rw-r--r--src/battle/battle_interface.c570
1 files changed, 467 insertions, 103 deletions
diff --git a/src/battle/battle_interface.c b/src/battle/battle_interface.c
index 9be026d53..ec882bcce 100644
--- a/src/battle/battle_interface.c
+++ b/src/battle/battle_interface.c
@@ -14,6 +14,7 @@
#include "task.h"
#include "text.h"
#include "ewram.h"
+#include "graphics.h"
struct UnknownStruct5
{
@@ -29,43 +30,406 @@ struct UnknownStruct7
u8 filler0[0x180];
};
+static void sub_8043CEC(struct Sprite *sprite);
+static void sub_8045030(struct Sprite *sprite);
+static void sub_804507C(struct Sprite *sprite);
+
+const struct OamData gOamData_820A4E4 =
+{
+ .shape = 1,
+ .size = 3,
+ .priority = 1,
+};
+
+const struct SpriteTemplate gSpriteTemplates_820A4EC[] =
+{
+ {
+ .tileTag = 55039,
+ .paletteTag = 55039,
+ .oam = &gOamData_820A4E4,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+ },
+ {
+ .tileTag = 55040,
+ .paletteTag = 55039,
+ .oam = &gOamData_820A4E4,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+ },
+};
+
+const struct SpriteTemplate gSpriteTemplates_820A51C[] =
+{
+ {
+ .tileTag = 55041,
+ .paletteTag = 55039,
+ .oam = &gOamData_820A4E4,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+ },
+ {
+ .tileTag = 55042,
+ .paletteTag = 55039,
+ .oam = &gOamData_820A4E4,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+ },
+};
+
+const struct SpriteTemplate gSpriteTemplate_820A54C =
+{
+ .tileTag = 55051,
+ .paletteTag = 55039,
+ .oam = &gOamData_820A4E4,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct OamData gOamData_820A564 =
+{
+ .shape = 1,
+ .size = 1,
+ .priority = 1,
+};
+
+const struct SpriteTemplate gSpriteTemplates_820A56C[] =
+{
+ {
+ .tileTag = 55044,
+ .paletteTag = 55044,
+ .oam = &gOamData_820A564,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_8043CEC,
+ },
+ {
+ .tileTag = 55045,
+ .paletteTag = 55044,
+ .oam = &gOamData_820A564,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_8043CEC,
+ },
+ {
+ .tileTag = 55046,
+ .paletteTag = 55044,
+ .oam = &gOamData_820A564,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_8043CEC,
+ },
+ {
+ .tileTag = 55047,
+ .paletteTag = 55044,
+ .oam = &gOamData_820A564,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_8043CEC,
+ },
+};
+
+const struct Subsprite gSubspriteTable_820A5CC[] =
+{
+ { .x = -16, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 0, .size = 3 }, // size := 64x32
+ { .x = 48, .y = 0, .shape = ST_OAM_SQUARE, .priority = 1, .tileOffset = 32, .size = 2 }, // size := 32x32
+ { .x = -16, .y = 32, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 48, .size = 1 }, // size := 32x8
+ { .x = 16, .y = 32, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 52, .size = 1 }, // size := 32x8
+ { .x = 48, .y = 32, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 56, .size = 1 }, // size := 32x8
+};
+
+const struct Subsprite gSubspriteTable_820A5F4[] =
+{
+ { .x = -16, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 64, .size = 3 }, // size := 64x32
+ { .x = 48, .y = 0, .shape = ST_OAM_SQUARE, .priority = 1, .tileOffset = 96, .size = 2 }, // size := 32x32
+ { .x = -16, .y = 32, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset =112, .size = 1 }, // size := 32x8
+ { .x = 16, .y = 32, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset =116, .size = 1 }, // size := 32x8
+ { .x = 48, .y = 32, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset =120, .size = 1 }, // size := 32x8
+};
+
+const struct Subsprite gSubspriteTable_820A61C[] =
+{
+ { .x = -16, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 0, .size = 3 }, // size := 64x32
+ { .x = 48, .y = 0, .shape = ST_OAM_SQUARE, .priority = 1, .tileOffset = 32, .size = 2 }, // size := 32x32
+};
+
+const struct Subsprite gSubspriteTable_820A62C[] =
+{
+ { .x = -16, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 0, .size = 3 }, // size := 64x32
+ { .x = 48, .y = 0, .shape = ST_OAM_SQUARE, .priority = 1, .tileOffset = 32, .size = 2 }, // size := 32x32
+};
+
+const struct Subsprite gSubspriteTable_820A63C[] =
+{
+ { .x = -16, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 0, .size = 1 }, // size := 32x8
+ { .x = 16, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 4, .size = 1 }, // size := 32x8
+};
+
+const struct Subsprite gSubspriteTable_820A64C[] =
+{
+ { .x = -16, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 0, .size = 1 }, // size := 32x8
+ { .x = 16, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 4, .size = 1 }, // size := 32x8
+ { .x = -32, .y = 0, .shape = ST_OAM_SQUARE, .priority = 1, .tileOffset = 8, .size = 0 }, // size := 8x8
+};
+
+const struct SubspriteTable gSubspriteTables_unreferenced[] =
+{
+ { ARRAY_COUNT(gSubspriteTable_820A5CC), gSubspriteTable_820A5CC },
+ { ARRAY_COUNT(gSubspriteTable_820A61C), gSubspriteTable_820A61C },
+ { ARRAY_COUNT(gSubspriteTable_820A5F4), gSubspriteTable_820A5F4 },
+ { ARRAY_COUNT(gSubspriteTable_820A62C), gSubspriteTable_820A62C },
+};
+
+const struct SubspriteTable gSubspriteTables_820A684[] =
+{
+ { ARRAY_COUNT(gSubspriteTable_820A63C), gSubspriteTable_820A63C },
+ { ARRAY_COUNT(gSubspriteTable_820A64C), gSubspriteTable_820A64C },
+};
+
+const struct Subsprite gSubspriteTable_820A694[] =
+{
+ { .x = -96, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 0, .size = 1 }, // size := 32x8
+ { .x = -64, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 4, .size = 1 }, // size := 32x8
+ { .x = -32, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 8, .size = 1 }, // size := 32x8
+ { .x = 0, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 12, .size = 1 }, // size := 32x8
+};
+
+const struct Subsprite gSubspriteTable_820A6B4[] =
+{
+ { .x = -96, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 0, .size = 1 }, // size := 32x8
+ { .x = -64, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 4, .size = 1 }, // size := 32x8
+ { .x = -32, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 8, .size = 1 }, // size := 32x8
+ { .x = 0, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 8, .size = 1 }, // size := 32x8
+ { .x = 32, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 8, .size = 1 }, // size := 32x8
+ { .x = 64, .y = 0, .shape = ST_OAM_H_RECTANGLE, .priority = 1, .tileOffset = 12, .size = 1 }, // size := 32x8
+};
+
+const struct SubspriteTable gSubspriteTables_820A6E4[] =
+{
+ { ARRAY_COUNT(gSubspriteTable_820A694), gSubspriteTable_820A694 },
+};
+
+const struct SubspriteTable gSubspriteTables_820A6EC[] =
+{
+ { ARRAY_COUNT(gSubspriteTable_820A6B4), gSubspriteTable_820A6B4 },
+};
+
+// unused dakuten/handakuten tiles
+const u8 gUnusedDakuten[] = INCBIN_U8("graphics/unused/dakuten.4bpp");
+
+const struct CompressedSpriteSheet gUnknown_0820A754[] =
+{
+ { gBattleGfx_BallStatusBar, 512, 0xd70c },
+ { gBattleGfx_BallStatusBar, 512, 0xd70d },
+};
+
+const struct SpritePalette gUnknown_0820A764[] =
+{
+ { gUnknown_08D1212C, 0xd710 },
+ { gUnknown_08D1212C, 0xd711 },
+};
+
+const struct SpritePalette gUnknown_0820A774[] =
+{
+ { gUnknown_08D1214C, 0xd712 },
+ { gUnknown_08D1214C, 0xd713 },
+};
+
+const struct CompressedSpriteSheet gUnknown_0820A784[] =
+{
+ { Tiles_D129AC, 0x80, 0xd714 },
+ { Tiles_D129AC, 0x80, 0xd715 },
+};
+
+const struct OamData gOamData_820A794 =
+{
+ .shape = 1,
+ .size = 3,
+ .priority = 1,
+};
+
+const struct OamData gOamData_820A79C =
+{
+ .shape = 0,
+ .size = 0,
+ .priority = 1,
+};
+
+const struct SpriteTemplate gSpriteTemplate_820A7A4 =
+{
+ .tileTag = 55052,
+ .paletteTag = 55056,
+ .oam = &gOamData_820A4E4,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_8045030,
+};
+
+const struct SpriteTemplate gSpriteTemplate_820A7BC =
+{
+ .tileTag = 55053,
+ .paletteTag = 55057,
+ .oam = &gOamData_820A4E4,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_8045030,
+};
+
+const struct SpriteTemplate gSpriteTemplate_820A7D4 =
+{
+ .tileTag = 55060,
+ .paletteTag = 55058,
+ .oam = &gOamData_820A79C,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_804507C,
+};
+
+const struct SpriteTemplate gSpriteTemplate_820A7EC =
+{
+ .tileTag = 55061,
+ .paletteTag = 55059,
+ .oam = &gOamData_820A79C,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_804507C,
+};
+
+u8 *const gUnknown_0820A804[2] =
+{
+ OBJ_VRAM0 + 32 * 74,
+ OBJ_VRAM0 + 32 * 75,
+};
+
+u8 *const gUnknown_0820A80C[2] =
+{
+ OBJ_VRAM0 + 32 * 41,
+ OBJ_VRAM0 + 32 * 42,
+};
+
+u8 *const gUnknown_0820A814[2] =
+{
+ OBJ_VRAM0 + 32 * 42,
+ OBJ_VRAM0 + 32 * 43,
+};
+
+const u8 gUnknown_0820A81C[] = __("{COLOR DARK_GREY}{HIGHLIGHT RED} ");
+
+u8 *const gUnknown_0820A83C[3] =
+{
+ OBJ_VRAM0 + 32 * 31,
+ OBJ_VRAM0 + 32 * 88,
+ OBJ_VRAM0 + 32 * 89,
+};
+
+u8 *const gUnknown_0820A848[3] =
+{
+ OBJ_VRAM0 + 32 * 22,
+ OBJ_VRAM0 + 32 * 23,
+ OBJ_VRAM0 + 32 * 48,
+};
+
+u8 *const gUnknown_0820A854[2] =
+{
+ OBJ_VRAM0 + 32 * 90,
+ OBJ_VRAM0 + 32 * 91,
+};
+
+u8 *const gUnknown_0820A85C[2] =
+{
+ OBJ_VRAM0 + 32 * 49,
+ OBJ_VRAM0 + 32 * 50,
+};
+
+const u8 gUnknown_0820A864[] = _("{COLOR DARK_GREY}{HIGHLIGHT RED} /");
+
+u8 *const gUnknown_0820A87C[6] =
+{
+ OBJ_VRAM0 + 32 * 0,
+ OBJ_VRAM0 + 32 * 1,
+ OBJ_VRAM0 + 32 * 2,
+ OBJ_VRAM0 + 32 * 3,
+ OBJ_VRAM0 + 32 * 4,
+ OBJ_VRAM0 + 32 * 5,
+};
+
+u8 *const gUnknown_0820A894[2] =
+{
+ OBJ_VRAM0 + 32 * 6,
+ OBJ_VRAM0 + 32 * 7,
+};
+
+const u8 gUnknown_0820A89C[] = __("{COLOR DARK_GREY}{HIGHLIGHT TRANSPARENT} ");
+const u8 gUnknown_0820A8B0[] = _("{HIGHLIGHT RED}");
+
+u8 *const gUnknown_0820A8B4[10] =
+{
+ OBJ_VRAM0 + 32 * 2,
+ OBJ_VRAM0 + 32 * 3,
+ OBJ_VRAM0 + 32 * 4,
+ OBJ_VRAM0 + 32 * 5,
+ OBJ_VRAM0 + 32 * 6,
+ OBJ_VRAM0 + 32 * 7,
+ OBJ_VRAM0 + 32 * 64,
+ OBJ_VRAM0 + 32 * 65,
+ OBJ_VRAM0 + 32 * 66,
+ OBJ_VRAM0 + 32 * 67,
+};
+
+u8 *const gUnknown_0820A8DC[10] =
+{
+ OBJ_VRAM0 + 32 * 1,
+ OBJ_VRAM0 + 32 * 2,
+ OBJ_VRAM0 + 32 * 3,
+ OBJ_VRAM0 + 32 * 4,
+ OBJ_VRAM0 + 32 * 5,
+ OBJ_VRAM0 + 32 * 6,
+ OBJ_VRAM0 + 32 * 7,
+ OBJ_VRAM0 + 32 * 32,
+ OBJ_VRAM0 + 32 * 33,
+ OBJ_VRAM0 + 32 * 34,
+};
+
+u8 *const gUnknown_0820A904[10] =
+{
+ OBJ_VRAM0 + 32 * 2,
+ OBJ_VRAM0 + 32 * 3,
+ OBJ_VRAM0 + 32 * 4,
+ OBJ_VRAM0 + 32 * 5,
+ OBJ_VRAM0 + 32 * 6,
+ OBJ_VRAM0 + 32 * 7,
+ OBJ_VRAM0 + 32 * 32,
+ OBJ_VRAM0 + 32 * 33,
+ OBJ_VRAM0 + 32 * 34,
+ OBJ_VRAM0 + 32 * 35,
+};
+
extern u8 gDisplayedStringBattle[];
-extern u8 gNoOfAllBanks;
-extern u16 gBattlePartyID[];
+extern u8 gBattlersCount;
+extern u16 gBattlerPartyIndexes[];
extern u8 gBanksBySide[];
extern u8 gHealthboxIDs[];
extern u16 gBattleTypeFlags;
-extern const struct SpriteTemplate gSpriteTemplate_820A4EC[];
-extern const struct SpriteTemplate gSpriteTemplate_820A51C[];
-extern const struct SpriteTemplate gSpriteTemplate_820A54C;
-extern const struct SpriteTemplate gSpriteTemplate_820A56C[];
-extern const struct SubspriteTable gSubspriteTables_820A684[];
-extern const struct SubspriteTable gSubspriteTables_820A6E4[];
-extern const struct SubspriteTable gSubspriteTables_820A6EC[];
-extern const struct SpriteSheet gUnknown_0820A754[];
-extern const struct SpritePalette gUnknown_0820A764[];
-extern const struct SpritePalette gUnknown_0820A774[];
-extern const struct SpriteSheet gUnknown_0820A784[];
-extern const struct SpriteTemplate gSpriteTemplate_820A7A4[];
-extern const struct SpriteTemplate gSpriteTemplate_820A7D4[];
-extern void *const gUnknown_0820A804[];
-extern void *const gUnknown_0820A80C[];
-extern void *const gUnknown_0820A814[];
-extern void *const gUnknown_0820A83C[];
-extern void *const gUnknown_0820A848[];
-extern void *const gUnknown_0820A854[];
-extern void *const gUnknown_0820A85C[];
-extern void *const gUnknown_0820A87C[];
-extern void *const gUnknown_0820A894[];
-extern void *const gUnknown_0820A8B4[];
-extern void *const gUnknown_0820A8DC[];
-extern void *const gUnknown_0820A904[];
-extern const u8 gUnknown_0820A81C[];
-extern const u8 gUnknown_0820A864[];
-extern const u8 gUnknown_0820A89C[];
-extern const u8 gUnknown_0820A8B0[];
extern const u8 BattleText_SafariBalls[];
extern const u8 BattleText_SafariBallsLeft[];
extern const u8 BattleText_HighlightRed[];
@@ -175,7 +539,7 @@ void sub_8043740(s16 a, u16 *b, u8 c)
asm(""::"r"(r9));
}
#else
-__attribute__((naked))
+NAKED
void sub_8043740(s16 a, u16 *b, u8 c)
{
asm(".syntax unified\n\
@@ -419,10 +783,10 @@ u8 battle_make_oam_normal_battle(u8 a)
if (!IsDoubleBattle())
{
- if (GetBankSide(a) == 0)
+ if (GetBattlerSide(a) == 0)
{
- spriteId1 = CreateSprite(&gSpriteTemplate_820A4EC[0], 240, 160, 1);
- spriteId2 = CreateSpriteAtEnd(&gSpriteTemplate_820A4EC[0], 240, 160, 1);
+ spriteId1 = CreateSprite(&gSpriteTemplates_820A4EC[0], 240, 160, 1);
+ spriteId2 = CreateSpriteAtEnd(&gSpriteTemplates_820A4EC[0], 240, 160, 1);
gSprites[spriteId1].oam.shape = 0;
gSprites[spriteId2].oam.shape = 0;
@@ -430,8 +794,8 @@ u8 battle_make_oam_normal_battle(u8 a)
}
else
{
- spriteId1 = CreateSprite(&gSpriteTemplate_820A51C[0], 240, 160, 1);
- spriteId2 = CreateSpriteAtEnd(&gSpriteTemplate_820A51C[0], 240, 160, 1);
+ spriteId1 = CreateSprite(&gSpriteTemplates_820A51C[0], 240, 160, 1);
+ spriteId2 = CreateSpriteAtEnd(&gSpriteTemplates_820A51C[0], 240, 160, 1);
gSprites[spriteId2].oam.tileNum += 32;
sp0 = 2;
@@ -445,10 +809,10 @@ u8 battle_make_oam_normal_battle(u8 a)
//_08043A28
else
{
- if (GetBankSide(a) == 0)
+ if (GetBattlerSide(a) == 0)
{
- spriteId1 = CreateSprite(&gSpriteTemplate_820A4EC[GetBankIdentity(a) / 2], 240, 160, 1);
- spriteId2 = CreateSpriteAtEnd(&gSpriteTemplate_820A4EC[GetBankIdentity(a) / 2], 240, 160, 1);
+ spriteId1 = CreateSprite(&gSpriteTemplates_820A4EC[GetBattlerPosition(a) / 2], 240, 160, 1);
+ spriteId2 = CreateSpriteAtEnd(&gSpriteTemplates_820A4EC[GetBattlerPosition(a) / 2], 240, 160, 1);
gSprites[spriteId1].oam.affineParam = spriteId2;
gSprites[spriteId2].data[5] = spriteId1;
@@ -459,8 +823,8 @@ u8 battle_make_oam_normal_battle(u8 a)
//_08043ACC
else
{
- spriteId1 = CreateSprite(&gSpriteTemplate_820A51C[GetBankIdentity(a) / 2], 240, 160, 1);
- spriteId2 = CreateSpriteAtEnd(&gSpriteTemplate_820A51C[GetBankIdentity(a) / 2], 240, 160, 1);
+ spriteId1 = CreateSprite(&gSpriteTemplates_820A51C[GetBattlerPosition(a) / 2], 240, 160, 1);
+ spriteId2 = CreateSpriteAtEnd(&gSpriteTemplates_820A51C[GetBattlerPosition(a) / 2], 240, 160, 1);
gSprites[spriteId1].oam.affineParam = spriteId2;
gSprites[spriteId2].data[5] = spriteId1;
@@ -472,9 +836,9 @@ u8 battle_make_oam_normal_battle(u8 a)
}
//_08043B50
- spriteId3 = CreateSpriteAtEnd(&gSpriteTemplate_820A56C[gBanksBySide[a]], 140, 60, 0);
+ spriteId3 = CreateSpriteAtEnd(&gSpriteTemplates_820A56C[gBanksBySide[a]], 140, 60, 0);
sprite = &gSprites[spriteId3];
- SetSubspriteTables(sprite, &gSubspriteTables_820A684[GetBankSide(a)]);
+ SetSubspriteTables(sprite, &gSubspriteTables_820A684[GetBattlerSide(a)]);
sprite->subspriteMode = 2;
sprite->oam.priority = 1;
CpuCopy32(sub_8043CDC(1), OBJ_VRAM0 + sprite->oam.tileNum * 32, 64);
@@ -509,7 +873,7 @@ static const void *sub_8043CDC(u8 a)
return gUnknown_08D1216C[a];
}
-void sub_8043CEC(struct Sprite *sprite)
+static void sub_8043CEC(struct Sprite *sprite)
{
u8 r5 = sprite->data[5];
@@ -587,7 +951,7 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority)
{
s32 i;
- for (i = 0; i < gNoOfAllBanks; i++)
+ for (i = 0; i < gBattlersCount; i++)
{
u8 spriteId1;
u8 spriteId2;
@@ -609,7 +973,7 @@ void sub_8043F44(u8 a)
if (!IsDoubleBattle())
{
- if (GetBankSide(a) != 0)
+ if (GetBattlerSide(a) != 0)
{
x = 44;
y = 30;
@@ -622,7 +986,7 @@ void sub_8043F44(u8 a)
}
else
{
- switch (GetBankIdentity(a))
+ switch (GetBattlerPosition(a))
{
case 0:
x = 159;
@@ -654,7 +1018,7 @@ void sub_8043F44(u8 a)
/*static*/ void sub_8043FC0(u8 a, u8 b)
{
u8 str[30];
- void *const *r7;
+ u8 *const *r7;
u8 *ptr;
s32 i;
s32 two;
@@ -663,14 +1027,14 @@ void sub_8043F44(u8 a)
memcpy(str, gUnknown_0820A81C, sizeof(str));
if (!IsDoubleBattle())
{
- if (GetBankSide(gSprites[a].data[6]) == 0)
+ if (GetBattlerSide(gSprites[a].data[6]) == 0)
r7 = gUnknown_0820A804;
else
r7 = gUnknown_0820A80C;
}
else
{
- if (GetBankSide(gSprites[a].data[6]) == 0)
+ if (GetBattlerSide(gSprites[a].data[6]) == 0)
r7 = gUnknown_0820A814;
else
r7 = gUnknown_0820A80C;
@@ -713,14 +1077,14 @@ void sub_80440EC(u8 a, s16 b, u8 c)
u8 str[0x14];
u8 *ptr;
s32 foo;
- void *const *r4;
+ u8 *const *r4;
s32 i;
// TODO: make this a local variable
memcpy(str, gUnknown_0820A864, sizeof(str));
foo = gSprites[a].data[6];
- if (IsDoubleBattle() == TRUE || GetBankSide(foo) == 1)
+ if (IsDoubleBattle() == TRUE || GetBattlerSide(foo) == 1)
{
//_08044136
sub_8044210(a, b, c);
@@ -730,7 +1094,7 @@ void sub_80440EC(u8 a, s16 b, u8 c)
ptr = str + 6;
if (c == 0)
{
- if (GetBankSide(gSprites[a].data[6]) == 0)
+ if (GetBattlerSide(gSprites[a].data[6]) == 0)
r4 = gUnknown_0820A83C;
else
r4 = gUnknown_0820A848;
@@ -742,7 +1106,7 @@ void sub_80440EC(u8 a, s16 b, u8 c)
}
else
{
- if (GetBankSide(gSprites[a].data[6]) == 0)
+ if (GetBattlerSide(gSprites[a].data[6]) == 0)
r4 = gUnknown_0820A854;
else
r4 = gUnknown_0820A85C;
@@ -759,7 +1123,7 @@ void sub_80440EC(u8 a, s16 b, u8 c)
}
}
#else
-__attribute__((naked))
+NAKED
void sub_80440EC(u8 a, s16 b, u8 c)
{
asm(".syntax unified\n\
@@ -792,7 +1156,7 @@ void sub_80440EC(u8 a, s16 b, u8 c)
beq _08044136\n\
lsls r0, r5, 24\n\
lsrs r0, 24\n\
- bl GetBankSide\n\
+ bl GetBattlerSide\n\
lsls r0, 24\n\
lsrs r0, 24\n\
cmp r0, 0x1\n\
@@ -816,7 +1180,7 @@ _0804414C:\n\
ldrh r0, [r4, 0x3A]\n\
lsls r0, 24\n\
lsrs r0, 24\n\
- bl GetBankSide\n\
+ bl GetBattlerSide\n\
lsls r0, 24\n\
ldr r4, _08044188 @ =gUnknown_0820A848\n\
cmp r0, 0\n\
@@ -844,7 +1208,7 @@ _08044190:\n\
ldrh r0, [r4, 0x3A]\n\
lsls r0, 24\n\
lsrs r0, 24\n\
- bl GetBankSide\n\
+ bl GetBattlerSide\n\
lsls r0, 24\n\
ldr r4, _080441FC @ =gUnknown_0820A85C\n\
cmp r0, 0\n\
@@ -909,7 +1273,7 @@ _0804420C: .4byte 0x04000008\n\
{
u8 str[0x14];
u8 *ptr;
- void *const *r7;
+ u8 *const *r7;
int r10;
int r4;
int i;
@@ -933,7 +1297,7 @@ _0804420C: .4byte 0x04000008\n\
r7 = gUnknown_0820A894;
r10 = 2;
sub_8003504(ptr, b, 0xF, 1);
- if (GetBankSide(r4) == 0)
+ if (GetBattlerSide(r4) == 0)
{
CpuCopy32(sub_8043CDC(0x74), OBJ_VRAM0 + (gSprites[a].oam.tileNum + 0x34) * 32, 32);
}
@@ -942,7 +1306,7 @@ _0804420C: .4byte 0x04000008\n\
sub_80034D4(ewram0_9(0), str);
for (i = 0; i < r10; i++)
{
- CpuCopy32((void *)(ewram0_9(1) + i * 0x40), r7[i] + gSprites[r4].oam.tileNum * 32, 0x20);
+ CpuCopy32((void *)(ewram0_9(1) + i * 0x40), r7[i] + gSprites[r4].oam.tileNum * 32, 32);
}
}
@@ -959,7 +1323,7 @@ void sub_8044338(u8 a, struct Pokemon *pkmn)
// TODO: make this a local variable
memcpy(str, gUnknown_0820A864, sizeof(str));
- r6 = ewram520[GetBankIdentity(gSprites[a].data[6])].filler0;
+ r6 = ewram520[GetBattlerPosition(gSprites[a].data[6])].filler0;
r8 = 5;
nature = GetNature(pkmn);
StringCopy(str + 6, gNatureNames[nature]);
@@ -1016,7 +1380,7 @@ void sub_8044338(u8 a, struct Pokemon *pkmn)
}
}
#else
-__attribute__((naked))
+NAKED
void sub_8044338(u8 a, struct Pokemon *pkmn)
{
asm(".syntax unified\n\
@@ -1043,7 +1407,7 @@ void sub_8044338(u8 a, struct Pokemon *pkmn)
ldrh r0, [r0, 0x3A]\n\
lsls r0, 24\n\
lsrs r0, 24\n\
- bl GetBankIdentity\n\
+ bl GetBattlerPosition\n\
lsls r0, 24\n\
lsrs r0, 24\n\
lsls r1, r0, 1\n\
@@ -1284,21 +1648,21 @@ void sub_804454C(void)
s32 i;
u8 spriteId;
- for (i = 0; i < gNoOfAllBanks; i++)
+ for (i = 0; i < gBattlersCount; i++)
{
if (gSprites[gHealthboxIDs[i]].callback == SpriteCallbackDummy
#if DEBUG
- && (gUnknown_020297ED != 0 || GetBankSide(i) != 1)
+ && (gUnknown_020297ED != 0 || GetBattlerSide(i) != 1)
#else
- && GetBankSide(i) != 1
+ && GetBattlerSide(i) != 1
#endif
- && (IsDoubleBattle() || GetBankSide(i) != 0))
+ && (IsDoubleBattle() || GetBattlerSide(i) != 0))
{
u8 r6;
ewram17800[i].unk0_4 ^= 1;
r6 = ewram17800[i].unk0_4;
- if (GetBankSide(i) == 0)
+ if (GetBattlerSide(i) == 0)
{
if (!IsDoubleBattle())
@@ -1311,13 +1675,13 @@ void sub_804454C(void)
spriteId = gSprites[gHealthboxIDs[i]].data[5];
CpuFill32(0, OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * 32, 0x100);
- sub_8044210(gHealthboxIDs[i], GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_HP), 0);
- sub_8044210(gHealthboxIDs[i], GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_MAX_HP), 1);
+ sub_8044210(gHealthboxIDs[i], GetMonData(&gPlayerParty[gBattlerPartyIndexes[i]], MON_DATA_HP), 0);
+ sub_8044210(gHealthboxIDs[i], GetMonData(&gPlayerParty[gBattlerPartyIndexes[i]], MON_DATA_MAX_HP), 1);
}
else
{
draw_status_ailment_maybe(gHealthboxIDs[i]);
- sub_8045A5C(gHealthboxIDs[i], &gPlayerParty[gBattlePartyID[i]], 5);
+ sub_8045A5C(gHealthboxIDs[i], &gPlayerParty[gBattlerPartyIndexes[i]], 5);
CpuCopy32(sub_8043CDC(0x75), OBJ_VRAM0 + 0x680 + gSprites[gHealthboxIDs[i]].oam.tileNum * 32, 32);
}
}
@@ -1327,23 +1691,23 @@ void sub_804454C(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
{
- sub_8044338(gHealthboxIDs[i], &gEnemyParty[gBattlePartyID[i]]);
+ sub_8044338(gHealthboxIDs[i], &gEnemyParty[gBattlerPartyIndexes[i]]);
}
else
{
spriteId = gSprites[gHealthboxIDs[i]].data[5];
CpuFill32(0, OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * 32, 0x100);
- sub_8044210(gHealthboxIDs[i], GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_HP), 0);
- sub_8044210(gHealthboxIDs[i], GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_MAX_HP), 1);
+ sub_8044210(gHealthboxIDs[i], GetMonData(&gEnemyParty[gBattlerPartyIndexes[i]], MON_DATA_HP), 0);
+ sub_8044210(gHealthboxIDs[i], GetMonData(&gEnemyParty[gBattlerPartyIndexes[i]], MON_DATA_MAX_HP), 1);
}
}
else
{
draw_status_ailment_maybe(gHealthboxIDs[i]);
- sub_8045A5C(gHealthboxIDs[i], &gEnemyParty[gBattlePartyID[i]], 5);
+ sub_8045A5C(gHealthboxIDs[i], &gEnemyParty[gBattlerPartyIndexes[i]], 5);
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
- sub_8045A5C(gHealthboxIDs[i], &gEnemyParty[gBattlePartyID[i]], 4);
+ sub_8045A5C(gHealthboxIDs[i], &gEnemyParty[gBattlerPartyIndexes[i]], 4);
}
}
gSprites[gHealthboxIDs[i]].data[7] ^= 1;
@@ -1367,9 +1731,9 @@ u8 sub_8044804(u8 a, const struct BattleInterfaceStruct2 *b, u8 c, u8 d)
u8 sp18;
u8 taskId;
- if (c == 0 || GetBankIdentity(a) != 3)
+ if (c == 0 || GetBattlerPosition(a) != 3)
{
- if (GetBankSide(a) == 0)
+ if (GetBattlerSide(a) == 0)
{
r7 = 0;
x = 136;
@@ -1462,7 +1826,7 @@ u8 sub_8044804(u8 a, const struct BattleInterfaceStruct2 *b, u8 c, u8 d)
gSprites[sp[i]].data[2] = r7;
}
//_08044A76
- if (GetBankSide(a) == 0)
+ if (GetBattlerSide(a) == 0)
{
for (i = 0; i < 6; i++) //_08044A9A
{
@@ -1561,7 +1925,7 @@ u8 sub_8044804(u8 a, const struct BattleInterfaceStruct2 *b, u8 c, u8 d)
return taskId;
}
#else
-__attribute__((naked))
+NAKED
u8 sub_8044804(u8 a, const struct BattleInterfaceStruct2 *b, u8 c, u8 d)
{
asm(".syntax unified\n\
@@ -1583,14 +1947,14 @@ u8 sub_8044804(u8 a, const struct BattleInterfaceStruct2 *b, u8 c, u8 d)
str r3, [sp, 0x10]\n\
cmp r4, 0\n\
beq _08044834\n\
- bl GetBankIdentity\n\
+ bl GetBattlerPosition\n\
lsls r0, 24\n\
lsrs r0, 24\n\
cmp r0, 0x3\n\
beq _08044878\n\
_08044834:\n\
ldr r0, [sp, 0x8]\n\
- bl GetBankSide\n\
+ bl GetBattlerSide\n\
lsls r0, 24\n\
cmp r0, 0\n\
bne _08044854\n\
@@ -1872,7 +2236,7 @@ _08044A56:\n\
b _08044970\n\
_08044A76:\n\
ldr r0, [sp, 0x8]\n\
- bl GetBankSide\n\
+ bl GetBattlerSide\n\
lsls r0, 24\n\
cmp r0, 0\n\
bne _08044B5E\n\
@@ -2178,7 +2542,7 @@ void sub_8044CA0(u8 taskId)
{
for (i = 0; i < 6; i++)
{
- if (GetBankSide(sp8) != 0)
+ if (GetBattlerSide(sp8) != 0)
{
gSprites[sp[5 - i]].data[1] = 7 * i;
gSprites[sp[5 - i]].data[3] = 0;
@@ -2275,7 +2639,7 @@ static void sub_8044F70(u8 taskId)
}
}
-void sub_8045030(struct Sprite *sprite)
+static void sub_8045030(struct Sprite *sprite)
{
if (sprite->pos2.x != 0)
sprite->pos2.x += sprite->data[0];
@@ -2291,7 +2655,7 @@ static void sub_8045048(struct Sprite *sprite)
sprite->data[1] &= 0xF;
}
-void sub_804507C(struct Sprite *sprite)
+static void sub_804507C(struct Sprite *sprite)
{
u8 r3;
u16 r2;
@@ -2415,7 +2779,7 @@ void sub_8045180(struct Sprite *sprite)
ptr[1] = 0x13;
ptr[2] = 0x37;
ptr[3] = EOS;
- ptr = ewram520_2 + GetBankIdentity(gSprites[a].data[6]) * 0x180;
+ ptr = ewram520_2 + GetBattlerPosition(gSprites[a].data[6]) * 0x180;
sub_80034D4(ptr, gDisplayedStringBattle);
i = 0;
@@ -2452,7 +2816,7 @@ void sub_8045180(struct Sprite *sprite)
for (; i < _7; i++)
CpuCopy32(sub_8043CDC(0x2B), ptr + 64 * i, 32);
- if (GetBankSide(gSprites[a].data[6]) == 0 && !IsDoubleBattle())
+ if (GetBattlerSide(gSprites[a].data[6]) == 0 && !IsDoubleBattle())
{
r1 = (u8 *const *)gUnknown_0820A8B4;
for (i = 0; i < _7; i++)
@@ -2470,7 +2834,7 @@ void sub_8045180(struct Sprite *sprite)
}
else
{
- if (GetBankSide(gSprites[a].data[6]) == 0)
+ if (GetBattlerSide(gSprites[a].data[6]) == 0)
r1 = (u8 *const *)gUnknown_0820A904;
else
r1 = (u8 *const *)gUnknown_0820A8DC;
@@ -2499,9 +2863,9 @@ static void sub_8045458(u8 a, u8 b)
return;
r4 = gSprites[a].data[6];
- if (GetBankSide(r4) != 0)
+ if (GetBattlerSide(r4) != 0)
{
- u16 species = GetMonData(&gEnemyParty[gBattlePartyID[r4]], MON_DATA_SPECIES);
+ u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[r4]], MON_DATA_SPECIES);
if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), 1) != 0)
{
r4 = gSprites[a].data[5];
@@ -2526,9 +2890,9 @@ static void sub_8045458(u8 a, u8 b)
r7 = gSprites[a].data[6];
r10 = gSprites[a].data[5];
- if (GetBankSide(r7) == 0)
+ if (GetBattlerSide(r7) == 0)
{
- r4 = GetMonData(&gPlayerParty[gBattlePartyID[r7]], MON_DATA_STATUS);
+ r4 = GetMonData(&gPlayerParty[gBattlerPartyIndexes[r7]], MON_DATA_STATUS);
if (!IsDoubleBattle())
r8 = 0x1A;
else
@@ -2536,7 +2900,7 @@ static void sub_8045458(u8 a, u8 b)
}
else
{
- r4 = GetMonData(&gEnemyParty[gBattlePartyID[r7]], MON_DATA_STATUS);
+ r4 = GetMonData(&gEnemyParty[gBattlerPartyIndexes[r7]], MON_DATA_STATUS);
r8 = 0x11;
}
if (r4 & 7)
@@ -2584,7 +2948,7 @@ static void sub_8045458(u8 a, u8 b)
FillPalette(r0[gBattleInterfaceStatusIcons_DynPal], r4_2 + 0x100, 2);
CpuCopy16(gPlttBufferUnfaded + 0x100 + r4_2, (void *)(OBJ_PLTT + r4_2 * 2), 2);
CpuCopy32(r6, OBJ_VRAM0 + (gSprites[a].oam.tileNum + r8) * 32, 96);
- if (IsDoubleBattle() == TRUE || GetBankSide(r7) == TRUE)
+ if (IsDoubleBattle() == TRUE || GetBattlerSide(r7) == TRUE)
{
if (!ewram17800[r7].unk0_4)
{
@@ -2663,7 +3027,7 @@ static u8 sub_80457E8(u8 a, u8 b)
s32 r7;
u8 *addr;
- r6 = ewram520_2 + GetBankIdentity(gSprites[a].data[6]) * 0x180;
+ r6 = ewram520_2 + GetBattlerPosition(gSprites[a].data[6]) * 0x180;
r8 = 7;
sub_80034D4(r6, BattleText_SafariBalls);
for (i = 0; i < r8; i++)
@@ -2691,7 +3055,7 @@ static u8 sub_80457E8(u8 a, u8 b)
r7 = StringCopy(gDisplayedStringBattle, BattleText_SafariBallsLeft);
r7 = sub_8003504(r7, gNumSafariBalls, 10, 1);
StringAppend(r7, BattleText_HighlightRed);
- status = GetBankIdentity(gSprites[a].data[6]);
+ status = GetBattlerPosition(gSprites[a].data[6]);
r7 = ewram520_2 + status * 0x180;
r6 = 5;
sub_80034D4(r7, gDisplayedStringBattle);
@@ -2710,7 +3074,7 @@ void sub_8045A5C(u8 a, struct Pokemon *pkmn, u8 c)
u32 currhp;
r10 = gSprites[a].data[6];
- if (GetBankSide(r10) == 0)
+ if (GetBattlerSide(r10) == 0)
{
if (c == 3 || c == 0)
sub_8043FC0(a, GetMonData(pkmn, MON_DATA_LEVEL));
@@ -2838,7 +3202,7 @@ static void sub_8045D58(u8 a, u8 b)
break;
case 1:
sub_804602C(ewram17850[a].unk4, ewram17850[a].unk8, ewram17850[a].unkC, &ewram17850[a].unk10, sp8, 8);
- r0 = GetMonData(&gPlayerParty[gBattlePartyID[a]], MON_DATA_LEVEL);
+ r0 = GetMonData(&gPlayerParty[gBattlerPartyIndexes[a]], MON_DATA_LEVEL);
if (r0 == 100)
{
for (i = 0; i < 8; i++)
@@ -3046,9 +3410,9 @@ u8 GetHPBarLevel(s16 hp, s16 maxhp)
else
{
u8 fraction = GetScaledHPFraction(hp, maxhp, 48);
- if (fraction > 24)
+ if (fraction >= 25)
result = 3;
- else if (fraction > 9)
+ else if (fraction >= 10)
result = 2;
else if (fraction > 0)
result = 1;