label and document battle windows

This commit is contained in:
DizzyEggg 2018-06-17 16:48:58 +02:00
parent f807eb1f2d
commit caa36b530a
55 changed files with 1361 additions and 845 deletions

View File

@ -20646,29 +20646,29 @@ _081A5328:
ldr r4, =gDisplayedStringBattle ldr r4, =gDisplayedStringBattle
adds r0, r4, 0 adds r0, r4, 0
movs r1, 0xF movs r1, 0xF
bl BattleHandleAddTextPrinter bl BattlePutTextOnWindow
ldr r0, =gText_Vs ldr r0, =gText_Vs
movs r1, 0x10 movs r1, 0x10
bl BattleHandleAddTextPrinter bl BattlePutTextOnWindow
ldr r0, =gText_OpponentMon1Name ldr r0, =gText_OpponentMon1Name
bl BattleStringExpandPlaceholdersToDisplayedString bl BattleStringExpandPlaceholdersToDisplayedString
adds r0, r4, 0 adds r0, r4, 0
movs r1, 0x11 movs r1, 0x11
bl BattleHandleAddTextPrinter bl BattlePutTextOnWindow
ldr r0, =gText_Mind ldr r0, =gText_Mind
movs r1, 0x12 movs r1, 0x12
bl BattleHandleAddTextPrinter bl BattlePutTextOnWindow
ldr r0, =gText_Skill ldr r0, =gText_Skill
movs r1, 0x13 movs r1, 0x13
bl BattleHandleAddTextPrinter bl BattlePutTextOnWindow
ldr r0, =gText_Body ldr r0, =gText_Body
movs r1, 0x14 movs r1, 0x14
bl BattleHandleAddTextPrinter bl BattlePutTextOnWindow
ldr r0, =gText_Judgement ldr r0, =gText_Judgement
bl BattleStringExpandPlaceholdersToDisplayedString bl BattleStringExpandPlaceholdersToDisplayedString
adds r0, r4, 0 adds r0, r4, 0
movs r1, 0x15 movs r1, 0x15
bl BattleHandleAddTextPrinter bl BattlePutTextOnWindow
b _081A553E b _081A553E
.pool .pool
_081A53B4: _081A53B4:
@ -20752,7 +20752,7 @@ _081A5464:
bl BattleStringExpandPlaceholdersToDisplayedString bl BattleStringExpandPlaceholdersToDisplayedString
ldr r0, =gDisplayedStringBattle ldr r0, =gDisplayedStringBattle
movs r1, 0x15 movs r1, 0x15
bl BattleHandleAddTextPrinter bl BattlePutTextOnWindow
ldrb r0, [r5] ldrb r0, [r5]
adds r0, 0x1 adds r0, 0x1
strb r0, [r5] strb r0, [r5]

View File

@ -5988,7 +5988,7 @@ sub_811D0BC: @ 811D0BC
movs r0, 0x1 movs r0, 0x1
movs r1, 0x1 movs r1, 0x1
movs r2, 0xE0 movs r2, 0xE0
bl sub_809882C bl LoadSav2WindowGfx
movs r0, 0x1 movs r0, 0x1
movs r1, 0x1 movs r1, 0x1
movs r2, 0xE movs r2, 0xE

View File

@ -4396,7 +4396,7 @@ _081B23E8:
movs r0, 0 movs r0, 0
movs r1, 0x4F movs r1, 0x4F
movs r2, 0xD0 movs r2, 0xD0
bl sub_809882C bl LoadSav2WindowGfx
bl GetOverworldTextboxPalettePtr bl GetOverworldTextboxPalettePtr
movs r1, 0xE0 movs r1, 0xE0
movs r2, 0x20 movs r2, 0x20

View File

@ -1837,7 +1837,7 @@ _080C805E:
movs r0, 0x1 movs r0, 0x1
movs r1, 0xB movs r1, 0xB
movs r2, 0xE0 movs r2, 0xE0
bl sub_809882C bl LoadSav2WindowGfx
b _080C8198 b _080C8198
.pool .pool
_080C808C: _080C808C:
@ -6712,7 +6712,7 @@ sub_80CAC1C: @ 80CAC1C
movs r0, 0x1 movs r0, 0x1
movs r1, 0x2 movs r1, 0x2
movs r2, 0xD0 movs r2, 0xD0
bl sub_809882C bl LoadSav2WindowGfx
movs r0, 0x20 movs r0, 0x20
str r0, [sp] str r0, [sp]
movs r0, 0x14 movs r0, 0x14

View File

@ -5293,11 +5293,11 @@ sub_81C6BD8: @ 81C6BD8
movs r0, 0 movs r0, 0
movs r1, 0x1 movs r1, 0x1
movs r2, 0xE0 movs r2, 0xE0
bl sub_809882C bl LoadSav2WindowGfx
movs r0, 0 movs r0, 0
movs r1, 0xA movs r1, 0xA
movs r2, 0xD0 movs r2, 0xD0
bl copy_textbox_border_tile_patterns_to_vram bl LoadMessageBoxGfx
ldr r0, =gUnknown_0860F074 ldr r0, =gUnknown_0860F074
movs r1, 0xF0 movs r1, 0xF0
movs r2, 0x20 movs r2, 0x20

View File

@ -10101,7 +10101,7 @@ sub_81CC09C: @ 81CC09C
ldrb r0, [r4, 0x14] ldrb r0, [r4, 0x14]
movs r1, 0x1 movs r1, 0x1
movs r2, 0x40 movs r2, 0x40
bl sub_809882C bl LoadSav2WindowGfx
ldrb r0, [r4, 0x14] ldrb r0, [r4, 0x14]
movs r1, 0x1 movs r1, 0x1
movs r2, 0x4 movs r2, 0x4
@ -11351,7 +11351,7 @@ sub_81CCA1C: @ 81CCA1C
lsrs r0, 24 lsrs r0, 24
movs r1, 0x42 movs r1, 0x42
movs r2, 0x40 movs r2, 0x40
bl box_border_load_tiles_and_pal bl LoadSav2WindowGfx_
ldrb r0, [r5, 0x8] ldrb r0, [r5, 0x8]
movs r1, 0x42 movs r1, 0x42
movs r2, 0x4 movs r2, 0x4
@ -22282,7 +22282,7 @@ sub_81D2824: @ 81D2824
movs r0, 0 movs r0, 0
movs r1, 0x1 movs r1, 0x1
movs r2, 0xE0 movs r2, 0xE0
bl sub_809882C bl LoadSav2WindowGfx
ldr r0, =gUnknown_0860F074 ldr r0, =gUnknown_0860F074
movs r1, 0xF0 movs r1, 0xF0
movs r2, 0x20 movs r2, 0x20

View File

@ -10972,11 +10972,11 @@ _08018574:
movs r0, 0 movs r0, 0
movs r1, 0xA movs r1, 0xA
movs r2, 0xE0 movs r2, 0xE0
bl sub_809882C bl LoadSav2WindowGfx
movs r0, 0 movs r0, 0
movs r1, 0x1 movs r1, 0x1
movs r2, 0xF0 movs r2, 0xF0
bl box_border_load_tiles_and_pal bl LoadSav2WindowGfx_
movs r4, 0x20 movs r4, 0x20
str r4, [sp] str r4, [sp]
str r4, [sp, 0x4] str r4, [sp, 0x4]
@ -15907,11 +15907,11 @@ _0801AD8C:
movs r0, 0 movs r0, 0
movs r1, 0x1 movs r1, 0x1
movs r2, 0xD0 movs r2, 0xD0
bl sub_809882C bl LoadSav2WindowGfx
movs r0, 0 movs r0, 0
movs r1, 0x1 movs r1, 0x1
movs r2, 0xD0 movs r2, 0xD0
bl box_border_load_tiles_and_pal bl LoadSav2WindowGfx_
bl sub_819789C bl sub_819789C
ldr r0, =sub_801AC40 ldr r0, =sub_801AC40
bl SetVBlankCallback bl SetVBlankCallback
@ -27081,11 +27081,11 @@ sub_8020740: @ 8020740
movs r0, 0x3 movs r0, 0x3
movs r1, 0x1 movs r1, 0x1
movs r2, 0xD0 movs r2, 0xD0
bl sub_809882C bl LoadSav2WindowGfx
movs r0, 0x3 movs r0, 0x3
movs r1, 0xA movs r1, 0xA
movs r2, 0x20 movs r2, 0x20
bl box_border_load_tiles_and_pal bl LoadSav2WindowGfx_
ldr r0, =gUnknown_0860F074 ldr r0, =gUnknown_0860F074
movs r1, 0xE0 movs r1, 0xE0
movs r2, 0x20 movs r2, 0x20
@ -30171,7 +30171,7 @@ _0802210C:
ldr r4, =0x0000021d ldr r4, =0x0000021d
adds r1, r4, 0 adds r1, r4, 0
movs r2, 0xD0 movs r2, 0xD0
bl box_border_load_tiles_and_pal bl LoadSav2WindowGfx_
ldrb r0, [r5] ldrb r0, [r5]
movs r1, 0 movs r1, 0
adds r2, r4, 0 adds r2, r4, 0
@ -30370,7 +30370,7 @@ _08022296:
ldr r4, =0x0000021d ldr r4, =0x0000021d
adds r1, r4, 0 adds r1, r4, 0
movs r2, 0xD0 movs r2, 0xD0
bl box_border_load_tiles_and_pal bl LoadSav2WindowGfx_
ldrb r0, [r6, 0x2] ldrb r0, [r6, 0x2]
movs r1, 0 movs r1, 0
adds r2, r4, 0 adds r2, r4, 0
@ -35221,7 +35221,7 @@ sub_80248B0: @ 80248B0
ldr r5, =0x0000021d ldr r5, =0x0000021d
adds r1, r5, 0 adds r1, r5, 0
movs r2, 0xD0 movs r2, 0xD0
bl box_border_load_tiles_and_pal bl LoadSav2WindowGfx_
ldrb r4, [r4] ldrb r4, [r4]
bl sub_80247BC bl sub_80247BC
adds r3, r0, 0 adds r3, r0, 0
@ -41645,7 +41645,7 @@ sub_8027BEC: @ 8027BEC
adds r0, r7, 0 adds r0, r7, 0
adds r1, r4, 0 adds r1, r4, 0
movs r2, 0xD0 movs r2, 0xD0
bl box_border_load_tiles_and_pal bl LoadSav2WindowGfx_
adds r0, r7, 0 adds r0, r7, 0
adds r1, r4, 0 adds r1, r4, 0
movs r2, 0xD movs r2, 0xD
@ -44214,7 +44214,7 @@ sub_802902C: @ 802902C
movs r0, 0 movs r0, 0
movs r1, 0xA movs r1, 0xA
movs r2, 0xB0 movs r2, 0xB0
bl box_border_load_tiles_and_pal bl LoadSav2WindowGfx_
pop {r0} pop {r0}
bx r0 bx r0
thumb_func_end sub_802902C thumb_func_end sub_802902C
@ -54638,7 +54638,7 @@ sub_802E500: @ 802E500
adds r0, r4, 0 adds r0, r4, 0
adds r1, r5, 0 adds r1, r5, 0
movs r2, 0xD0 movs r2, 0xD0
bl box_border_load_tiles_and_pal bl LoadSav2WindowGfx_
adds r0, r4, 0 adds r0, r4, 0
adds r1, r5, 0 adds r1, r5, 0
movs r2, 0xD movs r2, 0xD

View File

@ -1157,11 +1157,11 @@ BuyMenuInitWindows: @ 80E0468
movs r0, 0 movs r0, 0
movs r1, 0x1 movs r1, 0x1
movs r2, 0xD0 movs r2, 0xD0
bl sub_809882C bl LoadSav2WindowGfx
movs r0, 0 movs r0, 0
movs r1, 0xA movs r1, 0xA
movs r2, 0xE0 movs r2, 0xE0
bl copy_textbox_border_tile_patterns_to_vram bl LoadMessageBoxGfx
movs r0, 0 movs r0, 0
bl PutWindowTilemap bl PutWindowTilemap
movs r0, 0x1 movs r0, 0x1

View File

@ -634,12 +634,12 @@ sub_812AA48: @ 812AA48
lsls r1, 2 lsls r1, 2
movs r0, 0 movs r0, 0
movs r2, 0xF0 movs r2, 0xF0
bl copy_textbox_border_tile_patterns_to_vram bl LoadMessageBoxGfx
movs r1, 0x85 movs r1, 0x85
lsls r1, 2 lsls r1, 2
movs r0, 0 movs r0, 0
movs r2, 0xE0 movs r2, 0xE0
bl sub_809882C bl LoadSav2WindowGfx
movs r0, 0 movs r0, 0
bl PutWindowTilemap bl PutWindowTilemap
pop {r0} pop {r0}

View File

@ -241,11 +241,11 @@ _08077310:
movs r0, 0 movs r0, 0
movs r1, 0x14 movs r1, 0x14
movs r2, 0xC0 movs r2, 0xC0
bl box_border_load_tiles_and_pal bl LoadSav2WindowGfx_
movs r0, 0x2 movs r0, 0x2
movs r1, 0x1 movs r1, 0x1
movs r2, 0xE0 movs r2, 0xE0
bl sub_809882C bl LoadSav2WindowGfx
bl LoadMonIconPalettes bl LoadMonIconPalettes
ldr r2, =gUnknown_0203229C ldr r2, =gUnknown_0203229C
ldr r0, [r2] ldr r0, [r2]

View File

@ -4684,7 +4684,7 @@ gUnknown_0831AA00:: @ 831AA00
obj_tiles gUnknown_08D77B0C, 0x1000, 0x2710 obj_tiles gUnknown_08D77B0C, 0x1000, 0x2710
.align 2 .align 2
gUnknown_0831AA08:: @ 831AA08 gBattleBgTemplates:: @ 831AA08
.4byte 0x00000580, 0x000005c5, 0x000013e6, 0x000033ab .4byte 0x00000580, 0x000005c5, 0x000013e6, 0x000033ab
.align 2 .align 2
@ -4743,7 +4743,7 @@ gUnknown_0831AAE0:: @ 831AAE0
null_window_template null_window_template
.align 2 .align 2
gUnknown_0831ABA0:: @ 831ABA0 gBattleWindowTemplates:: @ 831ABA0
.4byte gUnknown_0831AA18 .4byte gUnknown_0831AA18
.4byte gUnknown_0831AAE0 .4byte gUnknown_0831AAE0

View File

@ -606,7 +606,7 @@ struct BattleScripting
u8 reshowMainState; u8 reshowMainState;
u8 reshowHelperState; u8 reshowHelperState;
u8 field_23; u8 field_23;
u8 field_24; u8 windowsType; // 0 - normal, 1 - battle arena
u8 multiplayerId; u8 multiplayerId;
}; };

View File

@ -1,13 +1,18 @@
#ifndef GUARD_BATTLE_AI_SCRIPT_COMMANDS_H #ifndef GUARD_BATTLE_AI_SCRIPT_COMMANDS_H
#define GUARD_BATTLE_AI_SCRIPT_COMMANDS_H #define GUARD_BATTLE_AI_SCRIPT_COMMANDS_H
// return values for BattleAI_ChooseMoveOrAction
// 0 - 3 are move idx
#define AI_CHOICE_FLEE 4
#define AI_CHOICE_WATCH 5
void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves); void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves);
void BattleAI_SetupAIData(u8 defaultScoreMoves); void BattleAI_SetupAIData(u8 defaultScoreMoves);
u8 BattleAI_ChooseMoveOrAction(void); u8 BattleAI_ChooseMoveOrAction(void);
void ClearBattlerMoveHistory(u8 bank); void ClearBattlerMoveHistory(u8 battlerId);
void RecordAbilityBattle(u8 bank, u8 abilityId); void RecordAbilityBattle(u8 battlerId, u8 abilityId);
void ClearBattlerAbilityHistory(u8 bank); void ClearBattlerAbilityHistory(u8 battlerId);
void RecordItemEffectBattle(u8 bank, u8 itemEffect); void RecordItemEffectBattle(u8 battlerId, u8 itemEffect);
void ClearBankItemEffectHistory(u8 bank); void ClearBattlerItemEffectHistory(u8 battlerId);
#endif // GUARD_BATTLE_AI_SCRIPT_COMMANDS_H #endif // GUARD_BATTLE_AI_SCRIPT_COMMANDS_H

View File

@ -1,13 +1,13 @@
#ifndef GUARD_BATTLE_BG_H #ifndef GUARD_BATTLE_BG_H
#define GUARD_BATTLE_BG_H #define GUARD_BATTLE_BG_H
void sub_8035658(void); void BattleInitBgsAndWindows(void);
void sub_80356D0(void); void sub_80356D0(void);
void ApplyPlayerChosenFrameToBattleMenu(void); void LoadBattleMenuWindowGfx(void);
void DrawMainBattleBackground(void); void DrawMainBattleBackground(void);
void LoadBattleTextboxAndBackground(void); void LoadBattleTextboxAndBackground(void);
void sub_8035D74(u8 taskId); void sub_8035D74(u8 taskId);
void LoadBattleEntryBackground(void); void DrawBattleEntryBackground(void);
bool8 LoadChosenBattleElement(u8 caseId); bool8 LoadChosenBattleElement(u8 caseId);
#endif // GUARD_BATTLE_BG_H #endif // GUARD_BATTLE_BG_H

View File

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

View File

@ -30,10 +30,14 @@
#define ABILITYEFFECT_CHECK_ON_FIELD 0x13 #define ABILITYEFFECT_CHECK_ON_FIELD 0x13
#define ABILITYEFFECT_SWITCH_IN_WEATHER 0xFF #define ABILITYEFFECT_SWITCH_IN_WEATHER 0xFF
#define ABILITY_ON_OPPOSING_FIELD(battlerId, abilityId)(AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, battlerId, abilityId, 0, 0))
#define ABILITY_ON_FIELD(abilityId)(AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, abilityId, 0, 0))
#define ABILITY_ON_FIELD2(abilityId)(AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, abilityId, 0, 0))
#define ITEMEFFECT_ON_SWITCH_IN 0x0 #define ITEMEFFECT_ON_SWITCH_IN 0x0
#define WEATHER_HAS_EFFECT ((!AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_CLOUD_NINE, 0, 0) && !AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_AIR_LOCK, 0, 0))) #define WEATHER_HAS_EFFECT ((!ABILITY_ON_FIELD(ABILITY_CLOUD_NINE) && !ABILITY_ON_FIELD(ABILITY_AIR_LOCK)))
#define WEATHER_HAS_EFFECT2 ((!AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_CLOUD_NINE, 0, 0) && !AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_AIR_LOCK, 0, 0))) #define WEATHER_HAS_EFFECT2 ((!ABILITY_ON_FIELD2(ABILITY_CLOUD_NINE) && !ABILITY_ON_FIELD2(ABILITY_AIR_LOCK)))
#define BS_GET_TARGET 0 #define BS_GET_TARGET 0
#define BS_GET_ATTACKER 1 #define BS_GET_ATTACKER 1

View File

@ -13,10 +13,10 @@ extern const u8 gTextWindowFrame1_Gfx[];
extern const u16 gTextWindowFrame1_Pal[]; extern const u16 gTextWindowFrame1_Pal[];
const struct TilesPal* GetWindowFrameTilesPal(u8 id); const struct TilesPal* GetWindowFrameTilesPal(u8 id);
void copy_textbox_border_tile_patterns_to_vram(u8 windowId, u16 destOffset, u8 palOffset); void LoadMessageBoxGfx(u8 windowId, u16 destOffset, u8 palOffset);
void sub_809882C(u8 windowId, u16 destOffset, u8 palOffset); void LoadSav2WindowGfx(u8 windowId, u16 destOffset, u8 palOffset);
void sub_80987D4(u8 windowId, u8 frameId, u16 destOffset, u8 palOffset); void LoadWindowGfx(u8 windowId, u8 frameId, u16 destOffset, u8 palOffset);
void box_border_load_tiles_and_pal(u8 windowId, u16 destOffset, u8 palOffset); void LoadSav2WindowGfx_(u8 windowId, u16 destOffset, u8 palOffset);
void sub_8098858(u8 windowId, u16 tileNum, u8 palNum); void sub_8098858(u8 windowId, u16 tileNum, u8 palNum);
void sub_80989E0(u8 windowId, u16 tileNum, u8 palNum); void sub_80989E0(u8 windowId, u16 tileNum, u8 palNum);
void rbox_fill_rectangle(u8 windowId); void rbox_fill_rectangle(u8 windowId);

File diff suppressed because it is too large Load Diff

View File

@ -19,18 +19,20 @@ static bool8 ShouldSwitchIfPerishSong(void)
if (gStatuses3[gActiveBattler] & STATUS3_PERISH_SONG if (gStatuses3[gActiveBattler] & STATUS3_PERISH_SONG
&& gDisableStructs[gActiveBattler].perishSongTimer1 == 0) && gDisableStructs[gActiveBattler].perishSongTimer1 == 0)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
else
return FALSE; {
return FALSE;
}
} }
static bool8 ShouldSwitchIfWonderGuard(void) static bool8 ShouldSwitchIfWonderGuard(void)
{ {
u8 opposingPosition; u8 opposingPosition;
u8 opposingBank; u8 opposingBattler;
u8 moveFlags; u8 moveFlags;
s32 i, j; s32 i, j;
s32 firstId; s32 firstId;
@ -46,22 +48,22 @@ static bool8 ShouldSwitchIfWonderGuard(void)
if (gBattleMons[GetBattlerAtPosition(opposingPosition)].ability != ABILITY_WONDER_GUARD) if (gBattleMons[GetBattlerAtPosition(opposingPosition)].ability != ABILITY_WONDER_GUARD)
return FALSE; return FALSE;
// check if pokemon has a super effective move // Check if Pokemon has a super effective move.
for (opposingBank = GetBattlerAtPosition(opposingPosition), i = 0; i < 4; i++) for (opposingBattler = GetBattlerAtPosition(opposingPosition), i = 0; i < 4; i++)
{ {
move = gBattleMons[gActiveBattler].moves[i]; move = gBattleMons[gActiveBattler].moves[i];
if (move == MOVE_NONE) if (move == MOVE_NONE)
continue; continue;
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability); moveFlags = AI_TypeCalc(move, gBattleMons[opposingBattler].species, gBattleMons[opposingBattler].ability);
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE) if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE)
return FALSE; return FALSE;
} }
// get party information // Get party information.
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{ {
if ((gActiveBattler & BIT_FLANK) == 0) if ((gActiveBattler & BIT_FLANK) == B_FLANK_LEFT)
firstId = 0, lastId = 3; firstId = 0, lastId = 3;
else else
firstId = 3, lastId = 6; firstId = 3, lastId = 6;
@ -76,7 +78,7 @@ static bool8 ShouldSwitchIfWonderGuard(void)
else else
party = gEnemyParty; party = gEnemyParty;
// find a pokemon in the party that has a super effective move // Find a Pokemon in the party that has a super effective move.
for (i = firstId; i < lastId; i++) for (i = firstId; i < lastId; i++)
{ {
if (GetMonData(&party[i], MON_DATA_HP) == 0) if (GetMonData(&party[i], MON_DATA_HP) == 0)
@ -88,19 +90,19 @@ static bool8 ShouldSwitchIfWonderGuard(void)
if (i == gBattlerPartyIndexes[gActiveBattler]) if (i == gBattlerPartyIndexes[gActiveBattler])
continue; continue;
GetMonData(&party[i], MON_DATA_SPECIES); // unused return value GetMonData(&party[i], MON_DATA_SPECIES); // Unused return value.
GetMonData(&party[i], MON_DATA_ALT_ABILITY); // unused return value GetMonData(&party[i], MON_DATA_ALT_ABILITY); // Unused return value.
for (opposingBank = GetBattlerAtPosition(opposingPosition), j = 0; j < 4; j++) for (opposingBattler = GetBattlerAtPosition(opposingPosition), j = 0; j < 4; j++)
{ {
move = GetMonData(&party[i], MON_DATA_MOVE1 + j); move = GetMonData(&party[i], MON_DATA_MOVE1 + j);
if (move == MOVE_NONE) if (move == MOVE_NONE)
continue; continue;
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability); moveFlags = AI_TypeCalc(move, gBattleMons[opposingBattler].species, gBattleMons[opposingBattler].ability);
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % 3 < 2) if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % 3 < 2)
{ {
// we found a mon // We found a mon.
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
@ -108,12 +110,12 @@ static bool8 ShouldSwitchIfWonderGuard(void)
} }
} }
return FALSE; // at this point there is not a single pokemon in the party that has a super effective move against a pokemon with wonder guard return FALSE; // There is not a single Pokemon in the party that has a super effective move against a mon with Wonder Guard.
} }
static bool8 FindMonThatAbsorbsOpponentsMove(void) static bool8 FindMonThatAbsorbsOpponentsMove(void)
{ {
u8 bankIn1, bankIn2; u8 battlerIn1, battlerIn2;
u8 absorbingTypeAbility; u8 absorbingTypeAbility;
s32 firstId; s32 firstId;
s32 lastId; // + 1 s32 lastId; // + 1
@ -131,16 +133,16 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
bankIn1 = gActiveBattler; battlerIn1 = gActiveBattler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))])
bankIn2 = gActiveBattler; battlerIn2 = gActiveBattler;
else else
bankIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)));
} }
else else
{ {
bankIn1 = gActiveBattler; battlerIn1 = gActiveBattler;
bankIn2 = gActiveBattler; battlerIn2 = gActiveBattler;
} }
if (gBattleMoves[gLastLandedMoves[gActiveBattler]].type == TYPE_FIRE) if (gBattleMoves[gLastLandedMoves[gActiveBattler]].type == TYPE_FIRE)
@ -157,7 +159,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{ {
if ((gActiveBattler & BIT_FLANK) == 0) if ((gActiveBattler & BIT_FLANK) == B_FLANK_LEFT)
firstId = 0, lastId = 3; firstId = 0, lastId = 3;
else else
firstId = 3, lastId = 6; firstId = 3, lastId = 6;
@ -183,13 +185,13 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
continue; continue;
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
continue; continue;
if (i == gBattlerPartyIndexes[bankIn1]) if (i == gBattlerPartyIndexes[battlerIn1])
continue; continue;
if (i == gBattlerPartyIndexes[bankIn2]) if (i == gBattlerPartyIndexes[battlerIn2])
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1)) if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2)) if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2))
continue; continue;
species = GetMonData(&party[i], MON_DATA_SPECIES); species = GetMonData(&party[i], MON_DATA_SPECIES);
@ -200,7 +202,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
if (absorbingTypeAbility == monAbility && Random() & 1) if (absorbingTypeAbility == monAbility && Random() & 1)
{ {
// we found a mon // we found a mon.
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
@ -221,13 +223,13 @@ static bool8 ShouldSwitchIfNaturalCure(void)
if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1) if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 && Random() & 1) else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 && Random() & 1)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
@ -236,9 +238,10 @@ static bool8 ShouldSwitchIfNaturalCure(void)
return TRUE; return TRUE;
if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 1)) if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 1))
return TRUE; return TRUE;
if (Random() & 1) if (Random() & 1)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
@ -249,15 +252,15 @@ static bool8 ShouldSwitchIfNaturalCure(void)
static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng) static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng)
{ {
u8 opposingPosition; u8 opposingPosition;
u8 opposingBank; u8 opposingBattler;
s32 i; s32 i;
u8 moveFlags; u8 moveFlags;
u16 move; u16 move;
opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler)); opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler));
opposingBank = GetBattlerAtPosition(opposingPosition); opposingBattler = GetBattlerAtPosition(opposingPosition);
if (!(gAbsentBattlerFlags & gBitTable[opposingBank])) if (!(gAbsentBattlerFlags & gBitTable[opposingBattler]))
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
@ -265,7 +268,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng)
if (move == MOVE_NONE) if (move == MOVE_NONE)
continue; continue;
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability); moveFlags = AI_TypeCalc(move, gBattleMons[opposingBattler].species, gBattleMons[opposingBattler].ability);
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE) if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE)
{ {
if (noRng) if (noRng)
@ -278,9 +281,9 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng)
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
return FALSE; return FALSE;
opposingBank = GetBattlerAtPosition(BATTLE_PARTNER(opposingPosition)); opposingBattler = GetBattlerAtPosition(BATTLE_PARTNER(opposingPosition));
if (!(gAbsentBattlerFlags & gBitTable[opposingBank])) if (!(gAbsentBattlerFlags & gBitTable[opposingBattler]))
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
@ -288,7 +291,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng)
if (move == MOVE_NONE) if (move == MOVE_NONE)
continue; continue;
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability); moveFlags = AI_TypeCalc(move, gBattleMons[opposingBattler].species, gBattleMons[opposingBattler].ability);
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE) if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE)
{ {
if (noRng) if (noRng)
@ -318,7 +321,7 @@ static bool8 AreStatsRaised(void)
static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
{ {
u8 bankIn1, bankIn2; u8 battlerIn1, battlerIn2;
s32 firstId; s32 firstId;
s32 lastId; // + 1 s32 lastId; // + 1
struct Pokemon *party; struct Pokemon *party;
@ -337,16 +340,16 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
bankIn1 = gActiveBattler; battlerIn1 = gActiveBattler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))])
bankIn2 = gActiveBattler; battlerIn2 = gActiveBattler;
else else
bankIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)));
} }
else else
{ {
bankIn1 = gActiveBattler; battlerIn1 = gActiveBattler;
bankIn2 = gActiveBattler; battlerIn2 = gActiveBattler;
} }
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
@ -377,13 +380,13 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
continue; continue;
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
continue; continue;
if (i == gBattlerPartyIndexes[bankIn1]) if (i == gBattlerPartyIndexes[battlerIn1])
continue; continue;
if (i == gBattlerPartyIndexes[bankIn2]) if (i == gBattlerPartyIndexes[battlerIn2])
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1)) if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2)) if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2))
continue; continue;
species = GetMonData(&party[i], MON_DATA_SPECIES); species = GetMonData(&party[i], MON_DATA_SPECIES);
@ -395,7 +398,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
moveFlags = AI_TypeCalc(gLastLandedMoves[gActiveBattler], species, monAbility); moveFlags = AI_TypeCalc(gLastLandedMoves[gActiveBattler], species, monAbility);
if (moveFlags & flags) if (moveFlags & flags)
{ {
bankIn1 = gLastHitBy[gActiveBattler]; battlerIn1 = gLastHitBy[gActiveBattler];
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
@ -403,7 +406,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
if (move == 0) if (move == 0)
continue; continue;
moveFlags = AI_TypeCalc(move, gBattleMons[bankIn1].species, gBattleMons[bankIn1].ability); moveFlags = AI_TypeCalc(move, gBattleMons[battlerIn1].species, gBattleMons[battlerIn1].ability);
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0) if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
@ -419,23 +422,23 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
static bool8 ShouldSwitch(void) static bool8 ShouldSwitch(void)
{ {
u8 bankIn1, bankIn2; u8 battlerIn1, battlerIn2;
u8 *activeBankPtr; // needed to match u8 *activeBattlerPtr; // Needed to match.
s32 firstId; s32 firstId;
s32 lastId; // + 1 s32 lastId; // + 1
struct Pokemon *party; struct Pokemon *party;
s32 i; s32 i;
s32 availableToSwitch; s32 availableToSwitch;
if (gBattleMons[*(activeBankPtr = &gActiveBattler)].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) if (gBattleMons[*(activeBattlerPtr = &gActiveBattler)].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION))
return FALSE; return FALSE;
if (gStatuses3[gActiveBattler] & STATUS3_ROOTED) if (gStatuses3[gActiveBattler] & STATUS3_ROOTED)
return FALSE; return FALSE;
if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_SHADOW_TAG, 0, 0)) if (ABILITY_ON_OPPOSING_FIELD(gActiveBattler, ABILITY_SHADOW_TAG))
return FALSE; return FALSE;
if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_ARENA_TRAP, 0, 0)) if (ABILITY_ON_OPPOSING_FIELD(gActiveBattler, ABILITY_ARENA_TRAP)) // Misses the flying type and Levitate check.
return FALSE; // misses the flying or levitate check return FALSE;
if (AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_MAGNET_PULL, 0, 0)) if (ABILITY_ON_FIELD2(ABILITY_MAGNET_PULL))
{ {
if (gBattleMons[gActiveBattler].type1 == TYPE_STEEL) if (gBattleMons[gActiveBattler].type1 == TYPE_STEEL)
return FALSE; return FALSE;
@ -448,21 +451,21 @@ static bool8 ShouldSwitch(void)
availableToSwitch = 0; availableToSwitch = 0;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
bankIn1 = *activeBankPtr; battlerIn1 = *activeBattlerPtr;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(GetBattlerPosition(*activeBankPtr) ^ BIT_FLANK)]) if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(GetBattlerPosition(*activeBattlerPtr) ^ BIT_FLANK)])
bankIn2 = *activeBankPtr; battlerIn2 = *activeBattlerPtr;
else else
bankIn2 = GetBattlerAtPosition(GetBattlerPosition(*activeBankPtr) ^ BIT_FLANK); battlerIn2 = GetBattlerAtPosition(GetBattlerPosition(*activeBattlerPtr) ^ BIT_FLANK);
} }
else else
{ {
bankIn1 = *activeBankPtr; battlerIn1 = *activeBattlerPtr;
bankIn2 = *activeBankPtr; battlerIn2 = *activeBattlerPtr;
} }
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{ {
if ((gActiveBattler & BIT_FLANK) == 0) if ((gActiveBattler & BIT_FLANK) == B_FLANK_LEFT)
firstId = 0, lastId = 3; firstId = 0, lastId = 3;
else else
firstId = 3, lastId = 6; firstId = 3, lastId = 6;
@ -485,13 +488,13 @@ static bool8 ShouldSwitch(void)
continue; continue;
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
continue; continue;
if (i == gBattlerPartyIndexes[bankIn1]) if (i == gBattlerPartyIndexes[battlerIn1])
continue; continue;
if (i == gBattlerPartyIndexes[bankIn2]) if (i == gBattlerPartyIndexes[battlerIn2])
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1)) if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2)) if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2))
continue; continue;
availableToSwitch++; availableToSwitch++;
@ -521,10 +524,10 @@ static bool8 ShouldSwitch(void)
void AI_TrySwitchOrUseItem(void) void AI_TrySwitchOrUseItem(void)
{ {
struct Pokemon *party; struct Pokemon *party;
u8 bankIn1, bankIn2; u8 battlerIn1, battlerIn2;
s32 firstId; s32 firstId;
s32 lastId; // + 1 s32 lastId; // + 1
u8 bankIdentity = GetBattlerPosition(gActiveBattler); u8 battlerIdentity = GetBattlerPosition(gActiveBattler);
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
party = gPlayerParty; party = gPlayerParty;
@ -535,25 +538,25 @@ void AI_TrySwitchOrUseItem(void)
{ {
if (ShouldSwitch()) if (ShouldSwitch())
{ {
if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) == 6) if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) == PARTY_SIZE)
{ {
s32 monToSwitchId = GetMostSuitableMonToSwitchInto(); s32 monToSwitchId = GetMostSuitableMonToSwitchInto();
if (monToSwitchId == 6) if (monToSwitchId == PARTY_SIZE)
{ {
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
{ {
bankIn1 = GetBattlerAtPosition(bankIdentity); battlerIn1 = GetBattlerAtPosition(battlerIdentity);
bankIn2 = bankIn1; battlerIn2 = battlerIn1;
} }
else else
{ {
bankIn1 = GetBattlerAtPosition(bankIdentity); battlerIn1 = GetBattlerAtPosition(battlerIdentity);
bankIn2 = GetBattlerAtPosition(bankIdentity ^ BIT_FLANK); battlerIn2 = GetBattlerAtPosition(battlerIdentity ^ BIT_FLANK);
} }
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{ {
if ((gActiveBattler & BIT_FLANK) == 0) if ((gActiveBattler & BIT_FLANK) == B_FLANK_LEFT)
firstId = 0, lastId = 3; firstId = 0, lastId = 3;
else else
firstId = 3, lastId = 6; firstId = 3, lastId = 6;
@ -567,13 +570,13 @@ void AI_TrySwitchOrUseItem(void)
{ {
if (GetMonData(&party[monToSwitchId], MON_DATA_HP) == 0) if (GetMonData(&party[monToSwitchId], MON_DATA_HP) == 0)
continue; continue;
if (monToSwitchId == gBattlerPartyIndexes[bankIn1]) if (monToSwitchId == gBattlerPartyIndexes[battlerIn1])
continue; continue;
if (monToSwitchId == gBattlerPartyIndexes[bankIn2]) if (monToSwitchId == gBattlerPartyIndexes[battlerIn2])
continue; continue;
if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + bankIn1)) if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
continue; continue;
if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + bankIn2)) if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + battlerIn2))
continue; continue;
break; break;
@ -608,10 +611,10 @@ static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8
} }
else if (TYPE_EFFECT_ATK_TYPE(i) == atkType) else if (TYPE_EFFECT_ATK_TYPE(i) == atkType)
{ {
// check type1 // Check type1.
if (TYPE_EFFECT_DEF_TYPE(i) == defType1) if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
*var = (*var * TYPE_EFFECT_MULTIPLIER(i)) / 10; *var = (*var * TYPE_EFFECT_MULTIPLIER(i)) / 10;
// check type2 // Check type2.
if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2) if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
*var = (*var * TYPE_EFFECT_MULTIPLIER(i)) / 10; *var = (*var * TYPE_EFFECT_MULTIPLIER(i)) / 10;
} }
@ -621,10 +624,10 @@ static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8
u8 GetMostSuitableMonToSwitchInto(void) u8 GetMostSuitableMonToSwitchInto(void)
{ {
u8 opposingBank; u8 opposingBattler;
u8 bestDmg; // note : should be changed to u32 for obvious reasons u8 bestDmg; // Note : should be changed to u32 for obvious reasons.
u8 bestMonId; u8 bestMonId;
u8 bankIn1, bankIn2; u8 battlerIn1, battlerIn2;
s32 firstId; s32 firstId;
s32 lastId; // + 1 s32 lastId; // + 1
struct Pokemon *party; struct Pokemon *party;
@ -632,34 +635,34 @@ u8 GetMostSuitableMonToSwitchInto(void)
u8 invalidMons; u8 invalidMons;
u16 move; u16 move;
if (*(gBattleStruct->monToSwitchIntoId + gActiveBattler) != 6) if (*(gBattleStruct->monToSwitchIntoId + gActiveBattler) != PARTY_SIZE)
return *(gBattleStruct->monToSwitchIntoId + gActiveBattler); return *(gBattleStruct->monToSwitchIntoId + gActiveBattler);
if (gBattleTypeFlags & BATTLE_TYPE_ARENA) if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
return gBattlerPartyIndexes[gActiveBattler] + 1; return gBattlerPartyIndexes[gActiveBattler] + 1;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
bankIn1 = gActiveBattler; battlerIn1 = gActiveBattler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)]) if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)])
bankIn2 = gActiveBattler; battlerIn2 = gActiveBattler;
else else
bankIn2 = GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK); battlerIn2 = GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK);
// UB: It considers the opponent only player's side even though it can battle alongside player; // UB: It considers the opponent only player's side even though it can battle alongside player.
opposingBank = Random() & BIT_FLANK; opposingBattler = Random() & BIT_FLANK;
if (gAbsentBattlerFlags & gBitTable[opposingBank]) if (gAbsentBattlerFlags & gBitTable[opposingBattler])
opposingBank ^= BIT_FLANK; opposingBattler ^= BIT_FLANK;
} }
else else
{ {
opposingBank = GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_SIDE); opposingBattler = GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_SIDE);
bankIn1 = gActiveBattler; battlerIn1 = gActiveBattler;
bankIn2 = gActiveBattler; battlerIn2 = gActiveBattler;
} }
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{ {
if ((gActiveBattler & BIT_FLANK) == 0) if ((gActiveBattler & BIT_FLANK) == B_FLANK_LEFT)
firstId = 0, lastId = 3; firstId = 0, lastId = 3;
else else
firstId = 3, lastId = 6; firstId = 3, lastId = 6;
@ -676,27 +679,27 @@ u8 GetMostSuitableMonToSwitchInto(void)
invalidMons = 0; invalidMons = 0;
while (invalidMons != 0x3F) // all mons are invalid while (invalidMons != 0x3F) // All mons are invalid.
{ {
bestDmg = 0; bestDmg = 0;
bestMonId = 6; bestMonId = 6;
// find the mon which type is the most suitable offensively // Find the mon whose type is the most suitable offensively.
for (i = firstId; i < lastId; i++) for (i = firstId; i < lastId; i++)
{ {
u16 species = GetMonData(&party[i], MON_DATA_SPECIES); u16 species = GetMonData(&party[i], MON_DATA_SPECIES);
if (species != SPECIES_NONE if (species != SPECIES_NONE
&& GetMonData(&party[i], MON_DATA_HP) != 0 && GetMonData(&party[i], MON_DATA_HP) != 0
&& !(gBitTable[i] & invalidMons) && !(gBitTable[i] & invalidMons)
&& gBattlerPartyIndexes[bankIn1] != i && gBattlerPartyIndexes[battlerIn1] != i
&& gBattlerPartyIndexes[bankIn2] != i && gBattlerPartyIndexes[battlerIn2] != i
&& i != *(gBattleStruct->monToSwitchIntoId + bankIn1) && i != *(gBattleStruct->monToSwitchIntoId + battlerIn1)
&& i != *(gBattleStruct->monToSwitchIntoId + bankIn2)) && i != *(gBattleStruct->monToSwitchIntoId + battlerIn2))
{ {
u8 type1 = gBaseStats[species].type1; u8 type1 = gBaseStats[species].type1;
u8 type2 = gBaseStats[species].type2; u8 type2 = gBaseStats[species].type2;
u8 typeDmg = 10; u8 typeDmg = 10;
ModulateByTypeEffectiveness(gBattleMons[opposingBank].type1, type1, type2, &typeDmg); ModulateByTypeEffectiveness(gBattleMons[opposingBattler].type1, type1, type2, &typeDmg);
ModulateByTypeEffectiveness(gBattleMons[opposingBank].type2, type1, type2, &typeDmg); ModulateByTypeEffectiveness(gBattleMons[opposingBattler].type2, type1, type2, &typeDmg);
if (bestDmg < typeDmg) if (bestDmg < typeDmg)
{ {
bestDmg = typeDmg; bestDmg = typeDmg;
@ -709,24 +712,24 @@ u8 GetMostSuitableMonToSwitchInto(void)
} }
} }
// ok, we know the mon has the right typing but does it have at least one super effective move? // Ok, we know the mon has the right typing but does it have at least one super effective move?
if (bestMonId != 6) if (bestMonId != PARTY_SIZE)
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
move = GetMonData(&party[bestMonId], MON_DATA_MOVE1 + i); move = GetMonData(&party[bestMonId], MON_DATA_MOVE1 + i);
if (move != MOVE_NONE && TypeCalc(move, gActiveBattler, opposingBank) & MOVE_RESULT_SUPER_EFFECTIVE) if (move != MOVE_NONE && TypeCalc(move, gActiveBattler, opposingBattler) & MOVE_RESULT_SUPER_EFFECTIVE)
break; break;
} }
if (i != 4) if (i != 4)
return bestMonId; // has both the typing and at least one super effective move return bestMonId; // Has both the typing and at least one super effective move.
invalidMons |= gBitTable[bestMonId]; // sorry buddy, we want something better invalidMons |= gBitTable[bestMonId]; // Sorry buddy, we want something better.
} }
else else
{ {
invalidMons = 0x3F; // no viable mon to switch invalidMons = 0x3F; // No viable mon to switch.
} }
} }
@ -738,20 +741,20 @@ u8 GetMostSuitableMonToSwitchInto(void)
bestDmg = 0; bestDmg = 0;
bestMonId = 6; bestMonId = 6;
// if we couldn't find the best mon in terms of typing, find the one that deals most damage // If we couldn't find the best mon in terms of typing, find the one that deals most damage.
for (i = firstId; i < lastId; i++) for (i = firstId; i < lastId; i++)
{ {
if ((u16)(GetMonData(&party[i], MON_DATA_SPECIES)) == SPECIES_NONE) if ((u16)(GetMonData(&party[i], MON_DATA_SPECIES)) == SPECIES_NONE)
continue; continue;
if (GetMonData(&party[i], MON_DATA_HP) == 0) if (GetMonData(&party[i], MON_DATA_HP) == 0)
continue; continue;
if (gBattlerPartyIndexes[bankIn1] == i) if (gBattlerPartyIndexes[battlerIn1] == i)
continue; continue;
if (gBattlerPartyIndexes[bankIn2] == i) if (gBattlerPartyIndexes[battlerIn2] == i)
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1)) if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2)) if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2))
continue; continue;
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
@ -760,8 +763,8 @@ u8 GetMostSuitableMonToSwitchInto(void)
gBattleMoveDamage = 0; gBattleMoveDamage = 0;
if (move != MOVE_NONE && gBattleMoves[move].power != 1) if (move != MOVE_NONE && gBattleMoves[move].power != 1)
{ {
AI_CalcDmg(gActiveBattler, opposingBank); AI_CalcDmg(gActiveBattler, opposingBattler);
TypeCalc(move, gActiveBattler, opposingBank); TypeCalc(move, gActiveBattler, opposingBattler);
} }
if (bestDmg < gBattleMoveDamage) if (bestDmg < gBattleMoveDamage)
{ {
@ -774,21 +777,21 @@ u8 GetMostSuitableMonToSwitchInto(void)
return bestMonId; return bestMonId;
} }
// TODO: use PokemonItemEffect struct instead of u8 once it's documented // TODO: use PokemonItemEffect struct instead of u8 once it's documented.
static u8 GetAI_ItemType(u8 itemId, const u8 *itemEffect) // NOTE: should take u16 as item Id argument static u8 GetAI_ItemType(u8 itemId, const u8 *itemEffect) // NOTE: should take u16 as item Id argument
{ {
if (itemId == ITEM_FULL_RESTORE) if (itemId == ITEM_FULL_RESTORE)
return AI_ITEM_FULL_RESTORE; return AI_ITEM_FULL_RESTORE;
if (itemEffect[4] & 4) else if (itemEffect[4] & 4)
return AI_ITEM_HEAL_HP; return AI_ITEM_HEAL_HP;
if (itemEffect[3] & 0x3F) else if (itemEffect[3] & 0x3F)
return AI_ITEM_CURE_CONDITION; return AI_ITEM_CURE_CONDITION;
if (itemEffect[0] & 0x3F || itemEffect[1] != 0 || itemEffect[2] != 0) else if (itemEffect[0] & 0x3F || itemEffect[1] != 0 || itemEffect[2] != 0)
return AI_ITEM_X_STAT; return AI_ITEM_X_STAT;
if (itemEffect[3] & 0x80) else if (itemEffect[3] & 0x80)
return AI_ITEM_GUARD_SPECS; return AI_ITEM_GUARD_SPECS;
else
return AI_ITEM_NOT_RECOGNIZABLE; return AI_ITEM_NOT_RECOGNIZABLE;
} }
static bool8 ShouldUseItem(void) static bool8 ShouldUseItem(void)
@ -806,7 +809,7 @@ static bool8 ShouldUseItem(void)
else else
party = gEnemyParty; party = gEnemyParty;
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (GetMonData(&party[i], MON_DATA_HP) != 0 if (GetMonData(&party[i], MON_DATA_HP) != 0
&& GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE
@ -821,7 +824,7 @@ static bool8 ShouldUseItem(void)
u16 item; u16 item;
const u8 *itemEffects; const u8 *itemEffects;
u8 paramOffset; u8 paramOffset;
u8 bankSide; u8 battlerSide;
if (i != 0 && validMons > (gBattleResources->battleHistory->itemsNo - i) + 1) if (i != 0 && validMons > (gBattleResources->battleHistory->itemsNo - i) + 1)
continue; continue;
@ -908,8 +911,8 @@ static bool8 ShouldUseItem(void)
shouldUse = TRUE; shouldUse = TRUE;
break; break;
case AI_ITEM_GUARD_SPECS: case AI_ITEM_GUARD_SPECS:
bankSide = GetBattlerSide(gActiveBattler); battlerSide = GetBattlerSide(gActiveBattler);
if (gDisableStructs[gActiveBattler].isFirstTurn != 0 && gSideTimers[bankSide].mistTimer == 0) if (gDisableStructs[gActiveBattler].isFirstTurn != 0 && gSideTimers[battlerSide].mistTimer == 0)
shouldUse = TRUE; shouldUse = TRUE;
break; break;
case AI_ITEM_NOT_RECOGNIZABLE: case AI_ITEM_NOT_RECOGNIZABLE:

View File

@ -120,7 +120,7 @@ EWRAM_DATA static u16 sSoundAnimFramesToWait = 0;
EWRAM_DATA static u8 sMonAnimTaskIdArray[2] = {0}; EWRAM_DATA static u8 sMonAnimTaskIdArray[2] = {0};
EWRAM_DATA u8 gAnimMoveTurn = 0; EWRAM_DATA u8 gAnimMoveTurn = 0;
EWRAM_DATA static u8 sAnimBackgroundFadeState = 0; EWRAM_DATA static u8 sAnimBackgroundFadeState = 0;
EWRAM_DATA static u16 sAnimMoveIndex = 0; // set but unused. EWRAM_DATA static u16 sAnimMoveIndex = 0; // Set but unused.
EWRAM_DATA u8 gBattleAnimAttacker = 0; EWRAM_DATA u8 gBattleAnimAttacker = 0;
EWRAM_DATA u8 gBattleAnimTarget = 0; EWRAM_DATA u8 gBattleAnimTarget = 0;
EWRAM_DATA u16 gAnimBattlerSpecies[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u16 gAnimBattlerSpecies[MAX_BATTLERS_COUNT] = {0};
@ -179,6 +179,7 @@ static void (* const sScriptCmdTable[])(void) =
ScriptCmd_stopsound ScriptCmd_stopsound
}; };
// code
void ClearBattleAnimationVars(void) void ClearBattleAnimationVars(void)
{ {
s32 i; s32 i;
@ -192,11 +193,11 @@ void ClearBattleAnimationVars(void)
gAnimMovePower = 0; gAnimMovePower = 0;
gAnimFriendship = 0; gAnimFriendship = 0;
// clear index array. // Clear index array.
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
sAnimSpriteIndexArray[i] |= 0xFFFF; sAnimSpriteIndexArray[i] |= 0xFFFF;
// clear anim args. // Clear anim args.
for (i = 0; i < ANIM_ARGS_COUNT; i++) for (i = 0; i < ANIM_ARGS_COUNT; i++)
gBattleAnimArgs[i] = 0; gBattleAnimArgs[i] = 0;
@ -459,7 +460,7 @@ static void ScriptCmd_delay(void)
gAnimScriptCallback = WaitAnimFrameCount; gAnimScriptCallback = WaitAnimFrameCount;
} }
// wait for visual tasks to finish. // Wait for visual tasks to finish.
static void ScriptCmd_waitforvisualfinish(void) static void ScriptCmd_waitforvisualfinish(void)
{ {
if (gAnimVisualTaskCount == 0) if (gAnimVisualTaskCount == 0)
@ -486,7 +487,7 @@ static void ScriptCmd_end(void)
s32 i; s32 i;
bool32 continuousAnim = FALSE; bool32 continuousAnim = FALSE;
// keep waiting as long as there is animations to be done. // Keep waiting as long as there are animations to be done.
if (gAnimVisualTaskCount != 0 || gAnimSoundTaskCount != 0 if (gAnimVisualTaskCount != 0 || gAnimSoundTaskCount != 0
|| sMonAnimTaskIdArray[0] != 0xFF || sMonAnimTaskIdArray[1] != 0xFF) || sMonAnimTaskIdArray[0] != 0xFF || sMonAnimTaskIdArray[1] != 0xFF)
{ {
@ -495,10 +496,10 @@ static void ScriptCmd_end(void)
return; return;
} }
// finish the sound effects. // Finish the sound effects.
if (IsSEPlaying()) if (IsSEPlaying())
{ {
if (++sSoundAnimFramesToWait <= 90) // wait 90 frames, then halt the sound effect. if (++sSoundAnimFramesToWait <= 90) // Wait 90 frames, then halt the sound effect.
{ {
gAnimFramesToWait = 1; gAnimFramesToWait = 1;
return; return;
@ -510,7 +511,7 @@ static void ScriptCmd_end(void)
} }
} }
// the SE has halted, so set the SE Frame Counter to 0 and continue. // The SE has halted, so set the SE Frame Counter to 0 and continue.
sSoundAnimFramesToWait = 0; sSoundAnimFramesToWait = 0;
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
@ -523,7 +524,7 @@ static void ScriptCmd_end(void)
} }
} }
if (!continuousAnim) // may have been used for debug? if (!continuousAnim) // May have been used for debug?
{ {
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256); m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256);
if (!IsContest()) if (!IsContest())
@ -592,12 +593,12 @@ static void ScriptCmd_monbg(void)
bool8 toBG_2; bool8 toBG_2;
u8 taskId; u8 taskId;
u8 battlerId; u8 battlerId;
u8 animBank; u8 animBattler;
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
animBank = sBattleAnimScriptPtr[0]; animBattler = sBattleAnimScriptPtr[0];
if (animBank & ANIM_TARGET) if (animBattler & ANIM_TARGET)
battlerId = gBattleAnimTarget; battlerId = gBattleAnimTarget;
else else
battlerId = gBattleAnimAttacker; battlerId = gBattleAnimAttacker;
@ -655,7 +656,7 @@ bool8 IsBattlerSpriteVisible(u8 battlerId)
if (!IsBattlerSpritePresent(battlerId)) if (!IsBattlerSpritePresent(battlerId))
return FALSE; return FALSE;
if (IsContest()) if (IsContest())
return TRUE; // this line wont ever be reached. return TRUE; // This line won't ever be reached.
if (!gBattleSpritesDataPtr->battlerData[battlerId].invisible || !gSprites[gBattlerSpriteIds[battlerId]].invisible) if (!gBattleSpritesDataPtr->battlerData[battlerId].invisible || !gSprites[gBattlerSpriteIds[battlerId]].invisible)
return TRUE; return TRUE;
@ -847,32 +848,32 @@ static void task_pA_ma0A_obj_to_bg_pal(u8 taskId)
static void ScriptCmd_clearmonbg(void) static void ScriptCmd_clearmonbg(void)
{ {
u8 animBankId; u8 animBattlerId;
u8 battlerId; u8 battlerId;
u8 taskId; u8 taskId;
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
animBankId = sBattleAnimScriptPtr[0]; animBattlerId = sBattleAnimScriptPtr[0];
if (animBankId == ANIM_ATTACKER) if (animBattlerId == ANIM_ATTACKER)
animBankId = ANIM_ATK_PARTNER; animBattlerId = ANIM_ATK_PARTNER;
else if (animBankId == ANIM_TARGET) else if (animBattlerId == ANIM_TARGET)
animBankId = ANIM_DEF_PARTNER; animBattlerId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER) if (animBattlerId == ANIM_ATTACKER || animBattlerId == ANIM_ATK_PARTNER)
battlerId = gBattleAnimAttacker; battlerId = gBattleAnimAttacker;
else else
battlerId = gBattleAnimTarget; battlerId = gBattleAnimTarget;
if (sMonAnimTaskIdArray[0] != 0xFF) if (sMonAnimTaskIdArray[0] != 0xFF)
gSprites[gBattlerSpriteIds[battlerId]].invisible = 0; gSprites[gBattlerSpriteIds[battlerId]].invisible = 0;
if (animBankId > 1 && sMonAnimTaskIdArray[1] != 0xFF) if (animBattlerId > 1 && sMonAnimTaskIdArray[1] != 0xFF)
gSprites[gBattlerSpriteIds[battlerId ^ BIT_FLANK]].invisible = 0; gSprites[gBattlerSpriteIds[battlerId ^ BIT_FLANK]].invisible = 0;
else else
animBankId = 0; animBattlerId = 0;
taskId = CreateTask(sub_80A4980, 5); taskId = CreateTask(sub_80A4980, 5);
gTasks[taskId].data[0] = animBankId; gTasks[taskId].data[0] = animBattlerId;
gTasks[taskId].data[2] = battlerId; gTasks[taskId].data[2] = battlerId;
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
@ -910,18 +911,18 @@ static void ScriptCmd_monbg_22(void)
{ {
bool8 toBG_2; bool8 toBG_2;
u8 battlerId; u8 battlerId;
u8 animBankId; u8 animBattlerId;
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
animBankId = sBattleAnimScriptPtr[0]; animBattlerId = sBattleAnimScriptPtr[0];
if (animBankId == ANIM_ATTACKER) if (animBattlerId == ANIM_ATTACKER)
animBankId = ANIM_ATK_PARTNER; animBattlerId = ANIM_ATK_PARTNER;
else if (animBankId == ANIM_TARGET) else if (animBattlerId == ANIM_TARGET)
animBankId = ANIM_DEF_PARTNER; animBattlerId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER) if (animBattlerId == ANIM_ATTACKER || animBattlerId == ANIM_ATK_PARTNER)
battlerId = gBattleAnimAttacker; battlerId = gBattleAnimAttacker;
else else
battlerId = gBattleAnimTarget; battlerId = gBattleAnimTarget;
@ -938,7 +939,7 @@ static void ScriptCmd_monbg_22(void)
} }
battlerId ^= BIT_FLANK; battlerId ^= BIT_FLANK;
if (animBankId > 1 && IsBattlerSpriteVisible(battlerId)) if (animBattlerId > 1 && IsBattlerSpriteVisible(battlerId))
{ {
u8 position = GetBattlerPosition(battlerId); u8 position = GetBattlerPosition(battlerId);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
@ -954,32 +955,32 @@ static void ScriptCmd_monbg_22(void)
static void ScriptCmd_clearmonbg_23(void) static void ScriptCmd_clearmonbg_23(void)
{ {
u8 animBankId; u8 animBattlerId;
u8 battlerId; u8 battlerId;
u8 taskId; u8 taskId;
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
animBankId = sBattleAnimScriptPtr[0]; animBattlerId = sBattleAnimScriptPtr[0];
if (animBankId == ANIM_ATTACKER) if (animBattlerId == ANIM_ATTACKER)
animBankId = ANIM_ATK_PARTNER; animBattlerId = ANIM_ATK_PARTNER;
else if (animBankId == ANIM_TARGET) else if (animBattlerId == ANIM_TARGET)
animBankId = ANIM_DEF_PARTNER; animBattlerId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER) if (animBattlerId == ANIM_ATTACKER || animBattlerId == ANIM_ATK_PARTNER)
battlerId = gBattleAnimAttacker; battlerId = gBattleAnimAttacker;
else else
battlerId = gBattleAnimTarget; battlerId = gBattleAnimTarget;
if (IsBattlerSpriteVisible(battlerId)) if (IsBattlerSpriteVisible(battlerId))
gSprites[gBattlerSpriteIds[battlerId]].invisible = 0; gSprites[gBattlerSpriteIds[battlerId]].invisible = 0;
if (animBankId > 1 && IsBattlerSpriteVisible(battlerId ^ BIT_FLANK)) if (animBattlerId > 1 && IsBattlerSpriteVisible(battlerId ^ BIT_FLANK))
gSprites[gBattlerSpriteIds[battlerId ^ BIT_FLANK]].invisible = 0; gSprites[gBattlerSpriteIds[battlerId ^ BIT_FLANK]].invisible = 0;
else else
animBankId = 0; animBattlerId = 0;
taskId = CreateTask(sub_80A4BB0, 5); taskId = CreateTask(sub_80A4BB0, 5);
gTasks[taskId].data[0] = animBankId; gTasks[taskId].data[0] = animBattlerId;
gTasks[taskId].data[2] = battlerId; gTasks[taskId].data[2] = battlerId;
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
@ -1419,18 +1420,18 @@ void Task_PanFromInitialToTarget(u8 taskId)
pan = currentPan + incrementPan; pan = currentPan + incrementPan;
gTasks[taskId].tCurrentPan = pan; gTasks[taskId].tCurrentPan = pan;
if (incrementPan == 0) // If we're not incrementing, just cancel the task immediately if (incrementPan == 0) // If we're not incrementing, just cancel the task immediately.
{ {
destroyTask = TRUE; destroyTask = TRUE;
} }
else if (initialPanning < targetPanning) // Panning increasing else if (initialPanning < targetPanning) // Panning increasing.
{ {
if (pan >= targetPanning) // Target reached if (pan >= targetPanning) // Target reached.
destroyTask = TRUE; destroyTask = TRUE;
} }
else // Panning decreasing else // Panning decreasing.
{ {
if (pan <= targetPanning) // Target reached if (pan <= targetPanning) // Target reached.
destroyTask = TRUE; destroyTask = TRUE;
} }
@ -1684,14 +1685,14 @@ static void ScriptCmd_jumpifcontest(void)
static void ScriptCmd_monbgprio_28(void) static void ScriptCmd_monbgprio_28(void)
{ {
u8 wantedBank; u8 wantedBattler;
u8 battlerId; u8 battlerId;
u8 battlerPosition; u8 battlerPosition;
wantedBank = sBattleAnimScriptPtr[1]; wantedBattler = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
if (wantedBank != ANIM_ATTACKER) if (wantedBattler != ANIM_ATTACKER)
battlerId = gBattleAnimTarget; battlerId = gBattleAnimTarget;
else else
battlerId = gBattleAnimAttacker; battlerId = gBattleAnimAttacker;
@ -1716,15 +1717,15 @@ static void ScriptCmd_monbgprio_29(void)
static void ScriptCmd_monbgprio_2A(void) static void ScriptCmd_monbgprio_2A(void)
{ {
u8 wantedBank; u8 wantedBattler;
u8 battlerPosition; u8 battlerPosition;
u8 battlerId; u8 battlerId;
wantedBank = sBattleAnimScriptPtr[1]; wantedBattler = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
if (GetBattlerSide(gBattleAnimAttacker) != GetBattlerSide(gBattleAnimTarget)) if (GetBattlerSide(gBattleAnimAttacker) != GetBattlerSide(gBattleAnimTarget))
{ {
if (wantedBank != ANIM_ATTACKER) if (wantedBattler != ANIM_ATTACKER)
battlerId = gBattleAnimTarget; battlerId = gBattleAnimTarget;
else else
battlerId = gBattleAnimAttacker; battlerId = gBattleAnimAttacker;
@ -1762,16 +1763,16 @@ static void ScriptCmd_visible(void)
static void ScriptCmd_doublebattle_2D(void) static void ScriptCmd_doublebattle_2D(void)
{ {
u8 wantedBank; u8 wantedBattler;
u8 r4; u8 r4;
u8 spriteId; u8 spriteId;
wantedBank = sBattleAnimScriptPtr[1]; wantedBattler = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
if (!IsContest() && IsDoubleBattle() if (!IsContest() && IsDoubleBattle()
&& GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
{ {
if (wantedBank == ANIM_ATTACKER) if (wantedBattler == ANIM_ATTACKER)
{ {
r4 = sub_80A8364(gBattleAnimAttacker); r4 = sub_80A8364(gBattleAnimAttacker);
spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER); spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER);
@ -1797,16 +1798,16 @@ static void ScriptCmd_doublebattle_2D(void)
static void ScriptCmd_doublebattle_2E(void) static void ScriptCmd_doublebattle_2E(void)
{ {
u8 wantedBank; u8 wantedBattler;
u8 r4; u8 r4;
u8 spriteId; u8 spriteId;
wantedBank = sBattleAnimScriptPtr[1]; wantedBattler = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
if (!IsContest() && IsDoubleBattle() if (!IsContest() && IsDoubleBattle()
&& GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
{ {
if (wantedBank == ANIM_ATTACKER) if (wantedBattler == ANIM_ATTACKER)
{ {
r4 = sub_80A8364(gBattleAnimAttacker); r4 = sub_80A8364(gBattleAnimAttacker);
spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER); spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER);

View File

@ -133,13 +133,13 @@ void sub_8158D8C(u8 taskId)
if (gBattleAnimArgs[0] == ANIM_ATTACKER) if (gBattleAnimArgs[0] == ANIM_ATTACKER)
species = gContestResources->field_18->field_0; species = gContestResources->field_18->field_0;
else else
DestroyAnimVisualTask(taskId); // UB: function should return upon destroying task DestroyAnimVisualTask(taskId); // UB: function should return upon destroying task.
} }
else else
{ {
u8 battlerId; u8 battlerId;
// get wanted battler // Get wanted battler.
if (gBattleAnimArgs[0] == ANIM_ATTACKER) if (gBattleAnimArgs[0] == ANIM_ATTACKER)
battlerId = gBattleAnimAttacker; battlerId = gBattleAnimAttacker;
else if (gBattleAnimArgs[0] == ANIM_TARGET) else if (gBattleAnimArgs[0] == ANIM_TARGET)
@ -149,7 +149,7 @@ void sub_8158D8C(u8 taskId)
else else
battlerId = BATTLE_PARTNER(gBattleAnimTarget); battlerId = BATTLE_PARTNER(gBattleAnimTarget);
// check if battler is visible // Check if battler is visible.
if ((gBattleAnimArgs[0] == ANIM_TARGET || gBattleAnimArgs[0] == ANIM_DEF_PARTNER) && !IsBattlerSpriteVisible(battlerId)) if ((gBattleAnimArgs[0] == ANIM_TARGET || gBattleAnimArgs[0] == ANIM_DEF_PARTNER) && !IsBattlerSpriteVisible(battlerId))
{ {
DestroyAnimVisualTask(taskId); DestroyAnimVisualTask(taskId);
@ -179,13 +179,13 @@ void sub_8158E9C(u8 taskId)
if (gBattleAnimArgs[0] == ANIM_ATTACKER) if (gBattleAnimArgs[0] == ANIM_ATTACKER)
species = gContestResources->field_18->field_0; species = gContestResources->field_18->field_0;
else else
DestroyAnimVisualTask(taskId); // UB: function should return upon destroying task DestroyAnimVisualTask(taskId); // UB: function should return upon destroying task.
} }
else else
{ {
u8 battlerId; u8 battlerId;
// get wanted battler // Get wanted battler.
if (gBattleAnimArgs[0] == ANIM_ATTACKER) if (gBattleAnimArgs[0] == ANIM_ATTACKER)
battlerId = gBattleAnimAttacker; battlerId = gBattleAnimAttacker;
else if (gBattleAnimArgs[0] == ANIM_TARGET) else if (gBattleAnimArgs[0] == ANIM_TARGET)
@ -195,7 +195,7 @@ void sub_8158E9C(u8 taskId)
else else
battlerId = BATTLE_PARTNER(gBattleAnimTarget); battlerId = BATTLE_PARTNER(gBattleAnimTarget);
// check if battler is visible // Check if battler is visible.
if ((gBattleAnimArgs[0] == ANIM_TARGET || gBattleAnimArgs[0] == ANIM_DEF_PARTNER) && !IsBattlerSpriteVisible(battlerId)) if ((gBattleAnimArgs[0] == ANIM_TARGET || gBattleAnimArgs[0] == ANIM_DEF_PARTNER) && !IsBattlerSpriteVisible(battlerId))
{ {
DestroyAnimVisualTask(taskId); DestroyAnimVisualTask(taskId);

View File

@ -31,8 +31,8 @@ struct BattleBackground
extern const struct SpriteTemplate gUnknown_0831A9D0; extern const struct SpriteTemplate gUnknown_0831A9D0;
extern const struct SpriteTemplate gUnknown_0831A9E8; extern const struct SpriteTemplate gUnknown_0831A9E8;
extern const struct CompressedSpriteSheet gUnknown_0831AA00; extern const struct CompressedSpriteSheet gUnknown_0831AA00;
extern const struct BgTemplate gUnknown_0831AA08[4]; extern const struct BgTemplate gBattleBgTemplates[4];
extern const struct WindowTemplate *gUnknown_0831ABA0[]; extern const struct WindowTemplate *const gBattleWindowTemplates[];
extern const struct BattleBackground gBattleTerrainTable[]; extern const struct BattleBackground gBattleTerrainTable[];
extern u16 gBattle_BG1_X; extern u16 gBattle_BG1_X;
@ -42,23 +42,23 @@ extern u16 gBattle_BG2_Y;
extern u8 GetCurrentMapBattleScene(void); extern u8 GetCurrentMapBattleScene(void);
void sub_8035658(void) void BattleInitBgsAndWindows(void)
{ {
ResetBgsAndClearDma3BusyFlags(0); ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_0831AA08, ARRAY_COUNT(gUnknown_0831AA08)); InitBgsFromTemplates(0, gBattleBgTemplates, ARRAY_COUNT(gBattleBgTemplates));
if (gBattleTypeFlags & BATTLE_TYPE_ARENA) if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
{ {
gBattleScripting.field_24 = 1; gBattleScripting.windowsType = 1;
SetBgTilemapBuffer(1, gUnknown_02023060); SetBgTilemapBuffer(1, gUnknown_02023060);
SetBgTilemapBuffer(2, gUnknown_02023060); SetBgTilemapBuffer(2, gUnknown_02023060);
} }
else else
{ {
gBattleScripting.field_24 = 0; gBattleScripting.windowsType = 0;
} }
InitWindows(gUnknown_0831ABA0[gBattleScripting.field_24]); InitWindows(gBattleWindowTemplates[gBattleScripting.windowsType]);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
} }
@ -66,23 +66,23 @@ void sub_80356D0(void)
{ {
DisableInterrupts(INTR_FLAG_HBLANK); DisableInterrupts(INTR_FLAG_HBLANK);
EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL); EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL);
sub_8035658(); BattleInitBgsAndWindows();
SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON | DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON | DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
} }
void ApplyPlayerChosenFrameToBattleMenu(void) void LoadBattleMenuWindowGfx(void)
{ {
sub_809882C(2, 0x12, 0x10); LoadSav2WindowGfx(2, 0x12, 0x10);
sub_809882C(2, 0x22, 0x10); LoadSav2WindowGfx(2, 0x22, 0x10);
LoadCompressedPalette(gUnknown_08D85600, 0x50, 0x20); LoadCompressedPalette(gUnknown_08D85600, 0x50, 0x20);
if (gBattleTypeFlags & BATTLE_TYPE_ARENA) if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
{ {
sub_81978B0(0x70); sub_81978B0(0x70);
copy_textbox_border_tile_patterns_to_vram(0, 0x30, 0x70); LoadMessageBoxGfx(0, 0x30, 0x70);
gPlttBufferUnfaded[0x76] = 0; gPlttBufferUnfaded[0x76] = 0;
CpuCopy16(&gPlttBufferUnfaded[0x76], &gPlttBufferFaded[0x76], 2); CpuCopy16(&gPlttBufferUnfaded[0x76], &gPlttBufferFaded[0x76], 2);
} }
@ -193,12 +193,12 @@ void LoadBattleTextboxAndBackground(void)
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0); CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40); LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40);
ApplyPlayerChosenFrameToBattleMenu(); LoadBattleMenuWindowGfx();
DrawMainBattleBackground(); DrawMainBattleBackground();
} }
static void sub_8035AE4(u8 taskId, u8 bank, u8 bgId, u8 destX, u8 destY) static void sub_8035AE4(u8 taskId, u8 battlerId, u8 bgId, u8 destX, u8 destY)
{ {
s32 i; s32 i;
u16 var = 0; u16 var = 0;
@ -208,7 +208,7 @@ static void sub_8035AE4(u8 taskId, u8 bank, u8 bgId, u8 destX, u8 destY)
{ {
if (gTasks[taskId].data[5] != 0) if (gTasks[taskId].data[5] != 0)
{ {
switch (bank) switch (battlerId)
{ {
case 0: case 0:
var = 0x3F & gTasks[taskId].data[3]; var = 0x3F & gTasks[taskId].data[3];
@ -226,7 +226,7 @@ static void sub_8035AE4(u8 taskId, u8 bank, u8 bgId, u8 destX, u8 destY)
} }
else else
{ {
switch (bank) switch (battlerId)
{ {
case 0: case 0:
var = 0x3F & gTasks[taskId].data[3]; var = 0x3F & gTasks[taskId].data[3];
@ -253,7 +253,7 @@ static void sub_8035AE4(u8 taskId, u8 bank, u8 bgId, u8 destX, u8 destY)
} }
else else
{ {
if (bank == gBattleScripting.multiplayerId) if (battlerId == gBattleScripting.multiplayerId)
var = gTasks[taskId].data[3]; var = gTasks[taskId].data[3];
else else
var = gTasks[taskId].data[4]; var = gTasks[taskId].data[4];
@ -272,7 +272,7 @@ static void sub_8035C4C(void)
{ {
if (gBattleOutcome == B_OUTCOME_DREW) if (gBattleOutcome == B_OUTCOME_DREW)
{ {
BattleHandleAddTextPrinter(gText_Draw, 0x15); BattlePutTextOnWindow(gText_Draw, 0x15);
} }
else if (gBattleTypeFlags & BATTLE_TYPE_MULTI) else if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{ {
@ -281,20 +281,20 @@ static void sub_8035C4C(void)
switch (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18) switch (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18)
{ {
case 0: case 0:
BattleHandleAddTextPrinter(gText_Win, 0x16); BattlePutTextOnWindow(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17); BattlePutTextOnWindow(gText_Loss, 0x17);
break; break;
case 1: case 1:
BattleHandleAddTextPrinter(gText_Win, 0x17); BattlePutTextOnWindow(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16); BattlePutTextOnWindow(gText_Loss, 0x16);
break; break;
case 2: case 2:
BattleHandleAddTextPrinter(gText_Win, 0x16); BattlePutTextOnWindow(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17); BattlePutTextOnWindow(gText_Loss, 0x17);
break; break;
case 3: case 3:
BattleHandleAddTextPrinter(gText_Win, 0x17); BattlePutTextOnWindow(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16); BattlePutTextOnWindow(gText_Loss, 0x16);
break; break;
} }
} }
@ -303,20 +303,20 @@ static void sub_8035C4C(void)
switch (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18) switch (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18)
{ {
case 0: case 0:
BattleHandleAddTextPrinter(gText_Win, 0x17); BattlePutTextOnWindow(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16); BattlePutTextOnWindow(gText_Loss, 0x16);
break; break;
case 1: case 1:
BattleHandleAddTextPrinter(gText_Win, 0x16); BattlePutTextOnWindow(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17); BattlePutTextOnWindow(gText_Loss, 0x17);
break; break;
case 2: case 2:
BattleHandleAddTextPrinter(gText_Win, 0x17); BattlePutTextOnWindow(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16); BattlePutTextOnWindow(gText_Loss, 0x16);
break; break;
case 3: case 3:
BattleHandleAddTextPrinter(gText_Win, 0x16); BattlePutTextOnWindow(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17); BattlePutTextOnWindow(gText_Loss, 0x17);
break; break;
} }
} }
@ -325,26 +325,26 @@ static void sub_8035C4C(void)
{ {
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 != 0) if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 != 0)
{ {
BattleHandleAddTextPrinter(gText_Win, 0x17); BattlePutTextOnWindow(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16); BattlePutTextOnWindow(gText_Loss, 0x16);
} }
else else
{ {
BattleHandleAddTextPrinter(gText_Win, 0x16); BattlePutTextOnWindow(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17); BattlePutTextOnWindow(gText_Loss, 0x17);
} }
} }
else else
{ {
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 != 0) if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 != 0)
{ {
BattleHandleAddTextPrinter(gText_Win, 0x16); BattlePutTextOnWindow(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17); BattlePutTextOnWindow(gText_Loss, 0x17);
} }
else else
{ {
BattleHandleAddTextPrinter(gText_Win, 0x17); BattlePutTextOnWindow(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16); BattlePutTextOnWindow(gText_Loss, 0x16);
} }
} }
} }
@ -368,19 +368,19 @@ void sub_8035D74(u8 taskId)
switch (linkPlayer->lp_field_18) switch (linkPlayer->lp_field_18)
{ {
case 0: case 0:
BattleHandleAddTextPrinter(name, 0x11); BattlePutTextOnWindow(name, 0x11);
sub_8035AE4(taskId, linkPlayer->lp_field_18, 1, 2, 4); sub_8035AE4(taskId, linkPlayer->lp_field_18, 1, 2, 4);
break; break;
case 1: case 1:
BattleHandleAddTextPrinter(name, 0x12); BattlePutTextOnWindow(name, 0x12);
sub_8035AE4(taskId, linkPlayer->lp_field_18, 2, 2, 4); sub_8035AE4(taskId, linkPlayer->lp_field_18, 2, 2, 4);
break; break;
case 2: case 2:
BattleHandleAddTextPrinter(name, 0x13); BattlePutTextOnWindow(name, 0x13);
sub_8035AE4(taskId, linkPlayer->lp_field_18, 1, 2, 8); sub_8035AE4(taskId, linkPlayer->lp_field_18, 1, 2, 8);
break; break;
case 3: case 3:
BattleHandleAddTextPrinter(name, 0x14); BattlePutTextOnWindow(name, 0x14);
sub_8035AE4(taskId, linkPlayer->lp_field_18, 2, 2, 8); sub_8035AE4(taskId, linkPlayer->lp_field_18, 2, 2, 8);
break; break;
} }
@ -396,10 +396,10 @@ void sub_8035D74(u8 taskId)
opponentId = playerId, playerId = opponentId_copy; opponentId = playerId, playerId = opponentId_copy;
name = gLinkPlayers[playerId].name; name = gLinkPlayers[playerId].name;
BattleHandleAddTextPrinter(name, 0xF); BattlePutTextOnWindow(name, 0xF);
name = gLinkPlayers[opponentId].name; name = gLinkPlayers[opponentId].name;
BattleHandleAddTextPrinter(name, 0x10); BattlePutTextOnWindow(name, 0x10);
sub_8035AE4(taskId, playerId, 1, 2, 7); sub_8035AE4(taskId, playerId, 1, 2, 7);
sub_8035AE4(taskId, opponentId, 2, 2, 7); sub_8035AE4(taskId, opponentId, 2, 2, 7);
@ -457,7 +457,7 @@ void sub_8035D74(u8 taskId)
} }
} }
void LoadBattleEntryBackground(void) void DrawBattleEntryBackground(void)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
@ -740,7 +740,7 @@ bool8 LoadChosenBattleElement(u8 caseId)
} }
break; break;
case 6: case 6:
ApplyPlayerChosenFrameToBattleMenu(); LoadBattleMenuWindowGfx();
break; break;
default: default:
ret = TRUE; ret = TRUE;

View File

@ -1475,7 +1475,7 @@ static void LinkOpponentHandlePrintString(void)
gBattle_BG0_Y = 0; gBattle_BG0_Y = 0;
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
BattleTv_SetDataBasedOnString(*stringId); BattleTv_SetDataBasedOnString(*stringId);
} }

View File

@ -1299,7 +1299,7 @@ static void LinkPartnerHandlePrintString(void)
gBattle_BG0_Y = 0; gBattle_BG0_Y = 0;
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
BattleTv_SetDataBasedOnString(*stringId); BattleTv_SetDataBasedOnString(*stringId);
} }

View File

@ -1511,7 +1511,7 @@ static void OpponentHandlePrintString(void)
gBattle_BG0_Y = 0; gBattle_BG0_Y = 0;
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
sub_81A57E4(gActiveBattler, *stringId); sub_81A57E4(gActiveBattler, *stringId);
} }

View File

@ -620,7 +620,7 @@ static void HandleInputChooseMove(void)
gMultiUsePlayerCursor = gMoveSelectionCursor[gActiveBattler] + 1; gMultiUsePlayerCursor = gMoveSelectionCursor[gActiveBattler] + 1;
MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27); MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27);
BattleHandleAddTextPrinter(gText_BattleSwitchWhich, 0xB); BattlePutTextOnWindow(gText_BattleSwitchWhich, 0xB);
gBattlerControllerFuncs[gActiveBattler] = HandleMoveSwitchting; gBattlerControllerFuncs[gActiveBattler] = HandleMoveSwitchting;
} }
} }
@ -1458,7 +1458,7 @@ static void MoveSelectionDisplayMoveNames(void)
{ {
MoveSelectionDestroyCursorAt(i); MoveSelectionDestroyCursorAt(i);
StringCopy(gDisplayedStringBattle, gMoveNames[moveInfo->moves[i]]); StringCopy(gDisplayedStringBattle, gMoveNames[moveInfo->moves[i]]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, i + 3); BattlePutTextOnWindow(gDisplayedStringBattle, i + 3);
if (moveInfo->moves[i] != MOVE_NONE) if (moveInfo->moves[i] != MOVE_NONE)
gNumberOfMovesToChoose++; gNumberOfMovesToChoose++;
} }
@ -1467,7 +1467,7 @@ static void MoveSelectionDisplayMoveNames(void)
static void MoveSelectionDisplayPpString(void) static void MoveSelectionDisplayPpString(void)
{ {
StringCopy(gDisplayedStringBattle, gText_MoveInterfacePP); StringCopy(gDisplayedStringBattle, gText_MoveInterfacePP);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 7); BattlePutTextOnWindow(gDisplayedStringBattle, 7);
} }
static void MoveSelectionDisplayPpNumber(void) static void MoveSelectionDisplayPpNumber(void)
@ -1485,7 +1485,7 @@ static void MoveSelectionDisplayPpNumber(void)
txtPtr++; txtPtr++;
ConvertIntToDecimalStringN(txtPtr, moveInfo->maxPp[gMoveSelectionCursor[gActiveBattler]], STR_CONV_MODE_RIGHT_ALIGN, 2); ConvertIntToDecimalStringN(txtPtr, moveInfo->maxPp[gMoveSelectionCursor[gActiveBattler]], STR_CONV_MODE_RIGHT_ALIGN, 2);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 9); BattlePutTextOnWindow(gDisplayedStringBattle, 9);
} }
static void MoveSelectionDisplayMoveType(void) static void MoveSelectionDisplayMoveType(void)
@ -1502,7 +1502,7 @@ static void MoveSelectionDisplayMoveType(void)
txtPtr++; txtPtr++;
StringCopy(txtPtr, gTypeNames[gBattleMoves[moveInfo->moves[gMoveSelectionCursor[gActiveBattler]]].type]); StringCopy(txtPtr, gTypeNames[gBattleMoves[moveInfo->moves[gMoveSelectionCursor[gActiveBattler]]].type]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 10); BattlePutTextOnWindow(gDisplayedStringBattle, 10);
} }
static void MoveSelectionCreateCursorAt(u8 cursorPosition, u8 arg1) static void MoveSelectionCreateCursorAt(u8 cursorPosition, u8 arg1)
@ -1573,7 +1573,7 @@ static void PrintLinkStandbyMsg(void)
{ {
gBattle_BG0_X = 0; gBattle_BG0_X = 0;
gBattle_BG0_Y = 0; gBattle_BG0_Y = 0;
BattleHandleAddTextPrinter(gText_LinkStandby, 0); BattlePutTextOnWindow(gText_LinkStandby, 0);
} }
} }
@ -2536,7 +2536,7 @@ static void PlayerHandlePrintString(void)
gBattle_BG0_Y = 0; gBattle_BG0_Y = 0;
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2;
BattleTv_SetDataBasedOnString(*stringId); BattleTv_SetDataBasedOnString(*stringId);
sub_81A57E4(gActiveBattler, *stringId); sub_81A57E4(gActiveBattler, *stringId);
@ -2566,14 +2566,14 @@ static void PlayerHandleChooseAction(void)
gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3; gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3;
BattleTv_ClearExplosionFaintCause(); BattleTv_ClearExplosionFaintCause();
BattleHandleAddTextPrinter(gText_BattleMenu, 2); BattlePutTextOnWindow(gText_BattleMenu, 2);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
ActionSelectionDestroyCursorAt(i); ActionSelectionDestroyCursorAt(i);
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo); BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 1); BattlePutTextOnWindow(gDisplayedStringBattle, 1);
} }
static void PlayerHandleUnknownYesNoBox(void) static void PlayerHandleUnknownYesNoBox(void)
@ -2581,7 +2581,7 @@ static void PlayerHandleUnknownYesNoBox(void)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
{ {
HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0); HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0);
BattleHandleAddTextPrinter(gText_BattleYesNoChoice, 12); BattlePutTextOnWindow(gText_BattleYesNoChoice, 12);
gMultiUsePlayerCursor = 1; gMultiUsePlayerCursor = 1;
BattleCreateYesNoCursorAt(1); BattleCreateYesNoCursorAt(1);
gBattlerControllerFuncs[gActiveBattler] = PlayerHandleUnknownYesNoInput; gBattlerControllerFuncs[gActiveBattler] = PlayerHandleUnknownYesNoInput;

View File

@ -1492,7 +1492,7 @@ static void PlayerPartnerHandlePrintString(void)
gBattle_BG0_Y = 0; gBattle_BG0_Y = 0;
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2;
} }

View File

@ -1404,7 +1404,7 @@ static void RecordedOpponentHandlePrintString(void)
gBattle_BG0_Y = 0; gBattle_BG0_Y = 0;
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
} }

View File

@ -1409,7 +1409,7 @@ static void RecordedPlayerHandlePrintString(void)
gBattle_BG0_Y = 0; gBattle_BG0_Y = 0;
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
} }

View File

@ -427,7 +427,7 @@ static void SafariHandlePrintString(void)
gBattle_BG0_Y = 0; gBattle_BG0_Y = 0;
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
} }
@ -454,14 +454,14 @@ static void SafariHandleChooseAction(void)
s32 i; s32 i;
gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3; gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3;
BattleHandleAddTextPrinter(gText_SafariZoneMenu, 2); BattlePutTextOnWindow(gText_SafariZoneMenu, 2);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
ActionSelectionDestroyCursorAt(i); ActionSelectionDestroyCursorAt(i);
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo2); BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo2);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 1); BattlePutTextOnWindow(gDisplayedStringBattle, 1);
} }
static void SafariHandleUnknownYesNoBox(void) static void SafariHandleUnknownYesNoBox(void)

View File

@ -1179,7 +1179,7 @@ static void WallyHandlePrintString(void)
gBattle_BG0_Y = 0; gBattle_BG0_Y = 0;
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
} }
@ -1206,14 +1206,14 @@ static void WallyHandleChooseAction(void)
s32 i; s32 i;
gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3; gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3;
BattleHandleAddTextPrinter(gText_BattleMenu, 2); BattlePutTextOnWindow(gText_BattleMenu, 2);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
ActionSelectionDestroyCursorAt(i); ActionSelectionDestroyCursorAt(i);
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillWallyDo); BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillWallyDo);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 1); BattlePutTextOnWindow(gDisplayedStringBattle, 1);
} }
static void WallyHandleUnknownYesNoBox(void) static void WallyHandleUnknownYesNoBox(void)

View File

@ -82,8 +82,8 @@ extern struct MusicPlayerInfo gMPlayInfo_SE2;
extern u8 gUnknown_0203CF00[]; extern u8 gUnknown_0203CF00[];
extern const u16 gBattleTextboxPalette[]; // battle textbox palette extern const u16 gBattleTextboxPalette[]; // battle textbox palette
extern const struct BgTemplate gUnknown_0831AA08[]; extern const struct BgTemplate gBattleBgTemplates[];
extern const struct WindowTemplate * const gUnknown_0831ABA0[]; extern const struct WindowTemplate * const gBattleWindowTemplates[];
extern const u8 gUnknown_0831ACE0[]; extern const u8 gUnknown_0831ACE0[];
extern const u8 * const gBattleScriptsForMoveEffects[]; extern const u8 * const gBattleScriptsForMoveEffects[];
extern const u8 * const gBattlescriptsForBallThrow[]; extern const u8 * const gBattlescriptsForBallThrow[];
@ -652,7 +652,7 @@ static void CB2_InitBattleInternal(void)
LoadBattleTextboxAndBackground(); LoadBattleTextboxAndBackground();
ResetSpriteData(); ResetSpriteData();
ResetTasks(); ResetTasks();
LoadBattleEntryBackground(); DrawBattleEntryBackground();
FreeAllSpritePalettes(); FreeAllSpritePalettes();
gReservedSpritePaletteCount = 4; gReservedSpritePaletteCount = 4;
SetVBlankCallback(VBlankCB_Battle); SetVBlankCallback(VBlankCB_Battle);
@ -2210,10 +2210,10 @@ void sub_8038D64(void)
sub_80356D0(); sub_80356D0();
LoadCompressedPalette(gBattleTextboxPalette, 0, 64); LoadCompressedPalette(gBattleTextboxPalette, 0, 64);
ApplyPlayerChosenFrameToBattleMenu(); LoadBattleMenuWindowGfx();
ResetSpriteData(); ResetSpriteData();
ResetTasks(); ResetTasks();
LoadBattleEntryBackground(); DrawBattleEntryBackground();
SetGpuReg(REG_OFFSET_WINOUT, 0x37); SetGpuReg(REG_OFFSET_WINOUT, 0x37);
FreeAllSpritePalettes(); FreeAllSpritePalettes();
gReservedSpritePaletteCount = 4; gReservedSpritePaletteCount = 4;
@ -2327,7 +2327,7 @@ static void sub_8038F34(void)
if (sub_800A520() == TRUE) if (sub_800A520() == TRUE)
{ {
sub_800ADF8(); sub_800ADF8();
BattleHandleAddTextPrinter(gText_LinkStandby3, 0); BattlePutTextOnWindow(gText_LinkStandby3, 0);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -2363,25 +2363,25 @@ u32 sub_80391E0(u8 arrayId, u8 caseId)
switch (caseId) switch (caseId)
{ {
case 0: case 0:
ret = gUnknown_0831AA08[arrayId].bg; ret = gBattleBgTemplates[arrayId].bg;
break; break;
case 1: case 1:
ret = gUnknown_0831AA08[arrayId].charBaseIndex; ret = gBattleBgTemplates[arrayId].charBaseIndex;
break; break;
case 2: case 2:
ret = gUnknown_0831AA08[arrayId].mapBaseIndex; ret = gBattleBgTemplates[arrayId].mapBaseIndex;
break; break;
case 3: case 3:
ret = gUnknown_0831AA08[arrayId].screenSize; ret = gBattleBgTemplates[arrayId].screenSize;
break; break;
case 4: case 4:
ret = gUnknown_0831AA08[arrayId].paletteMode; ret = gBattleBgTemplates[arrayId].paletteMode;
break; break;
case 5: case 5:
ret = gUnknown_0831AA08[arrayId].priority; ret = gBattleBgTemplates[arrayId].priority;
break; break;
case 6: case 6:
ret = gUnknown_0831AA08[arrayId].baseTile; ret = gBattleBgTemplates[arrayId].baseTile;
break; break;
} }
@ -2406,7 +2406,7 @@ static void sub_80392A8(void)
gBattle_BG3_Y = 0; gBattle_BG3_Y = 0;
sub_80356D0(); sub_80356D0();
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ApplyPlayerChosenFrameToBattleMenu(); LoadBattleMenuWindowGfx();
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
LoadChosenBattleElement(i); LoadChosenBattleElement(i);
@ -2453,7 +2453,7 @@ static void sub_803939C(void)
case 3: case 3:
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {
BattleHandleAddTextPrinter(gText_RecordBattleToPass, 0); BattlePutTextOnWindow(gText_RecordBattleToPass, 0);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
break; break;
@ -2461,7 +2461,7 @@ static void sub_803939C(void)
if (!IsTextPrinterActive(0)) if (!IsTextPrinterActive(0))
{ {
HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0); HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0);
BattleHandleAddTextPrinter(gText_BattleYesNoChoice, 0xC); BattlePutTextOnWindow(gText_BattleYesNoChoice, 0xC);
gBattleCommunication[CURSOR_POSITION] = 1; gBattleCommunication[CURSOR_POSITION] = 1;
BattleCreateYesNoCursorAt(1); BattleCreateYesNoCursorAt(1);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
@ -2515,7 +2515,7 @@ static void sub_803939C(void)
if (gMain.field_439_x4) if (gMain.field_439_x4)
{ {
sub_800ADF8(); sub_800ADF8();
BattleHandleAddTextPrinter(gText_LinkStandby3, 0); BattlePutTextOnWindow(gText_LinkStandby3, 0);
} }
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
@ -2546,14 +2546,14 @@ static void sub_803939C(void)
{ {
PlaySE(SE_SAVE); PlaySE(SE_SAVE);
BattleStringExpandPlaceholdersToDisplayedString(gText_BattleRecordedOnPass); BattleStringExpandPlaceholdersToDisplayedString(gText_BattleRecordedOnPass);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gBattleCommunication[1] = 0x80; gBattleCommunication[1] = 0x80;
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
else else
{ {
BattleStringExpandPlaceholdersToDisplayedString(gText_BattleRecordCouldntBeSaved); BattleStringExpandPlaceholdersToDisplayedString(gText_BattleRecordCouldntBeSaved);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gBattleCommunication[1] = 0x80; gBattleCommunication[1] = 0x80;
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
@ -2564,7 +2564,7 @@ static void sub_803939C(void)
if (gMain.field_439_x4) if (gMain.field_439_x4)
{ {
sub_800ADF8(); sub_800ADF8();
BattleHandleAddTextPrinter(gText_LinkStandby3, 0); BattlePutTextOnWindow(gText_LinkStandby3, 0);
} }
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
} }
@ -2610,7 +2610,7 @@ static void TryCorrectShedinjaLanguage(struct Pokemon *mon)
u32 sub_80397C4(u32 setId, u32 tableId) u32 sub_80397C4(u32 setId, u32 tableId)
{ {
return gUnknown_0831ABA0[setId][tableId].width * 8; return gBattleWindowTemplates[setId][tableId].width * 8;
} }
#define sBattler data[0] #define sBattler data[0]
@ -3885,7 +3885,7 @@ static void TryDoEventsBeforeFirstTurn(void)
TurnValuesCleanUp(FALSE); TurnValuesCleanUp(FALSE);
SpecialStatusesClear(); SpecialStatusesClear();
*(&gBattleStruct->field_91) = gAbsentBattlerFlags; *(&gBattleStruct->field_91) = gAbsentBattlerFlags;
BattleHandleAddTextPrinter(gText_EmptyString3, 0); BattlePutTextOnWindow(gText_EmptyString3, 0);
gBattleMainFunc = HandleTurnActionSelectionState; gBattleMainFunc = HandleTurnActionSelectionState;
ResetSentPokesToOpponentValue(); ResetSentPokesToOpponentValue();
@ -3992,7 +3992,7 @@ void BattleTurnPassed(void)
*(gBattleStruct->monToSwitchIntoId + i) = 6; *(gBattleStruct->monToSwitchIntoId + i) = 6;
*(&gBattleStruct->field_91) = gAbsentBattlerFlags; *(&gBattleStruct->field_91) = gAbsentBattlerFlags;
BattleHandleAddTextPrinter(gText_EmptyString3, 0); BattlePutTextOnWindow(gText_EmptyString3, 0);
gBattleMainFunc = HandleTurnActionSelectionState; gBattleMainFunc = HandleTurnActionSelectionState;
gRandomTurnNumber = Random(); gRandomTurnNumber = Random();

View File

@ -17,6 +17,20 @@
#include "recorded_battle.h" #include "recorded_battle.h"
#include "international_string_util.h" #include "international_string_util.h"
struct BattleWindowText
{
u8 fillValue;
u8 fontId;
u8 x;
u8 y;
u8 letterSpacing;
u8 lineSpacing;
u8 speed;
u8 fgColor;
u8 bgColor;
u8 shadowColor;
};
extern u8 gBattlerAbilities[MAX_BATTLERS_COUNT]; extern u8 gBattlerAbilities[MAX_BATTLERS_COUNT];
extern u8 gUnknown_0203C7B4; extern u8 gUnknown_0203C7B4;
extern struct StringInfoBattle *gStringInfo; extern struct StringInfoBattle *gStringInfo;
@ -1351,67 +1365,590 @@ static const u16 sUnknownMoveTable[] =
static const u8 sDummyWeirdStatusString[] = {EOS, EOS, EOS, EOS, EOS, EOS, EOS, EOS, 0, 0}; static const u8 sDummyWeirdStatusString[] = {EOS, EOS, EOS, EOS, EOS, EOS, EOS, EOS, 0, 0};
static const u8 sUnknown_085CD42C[] = static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
{ {
0xFF, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0xF, 0x6, 0x0, 0x0, 0xFF, 0x1, { // 0
0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0xF, 0x6, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, .fillValue = 0xFF,
0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, .fontId = 1,
0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, .x = 0,
0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, .y = 1,
0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, .letterSpacing = 0,
0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xC, 0xE, 0xB, 0x0, 0x0, .lineSpacing = 0,
0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, .speed = 1,
0x1, 0x2, 0x1, 0x0, 0x0, 0x0, 0xC, 0xE, 0xB, 0x0, 0x0, 0xEE, 0x7, 0x0, .fgColor = 1,
0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, .bgColor = 15,
0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, .shadowColor = 6,
0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, },
0xE, 0xF, 0x0, 0x0, 0x0, 0x1, 0x20, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x2, { // 1
0x0, 0x0, 0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, .fillValue = 0xFF,
0x0, 0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, .fontId = 1,
0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, .x = 1,
0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, .y = 1,
0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0xFF, .letterSpacing = 0,
0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0x0, 0x1, 0xFF, 0x1, 0x0, .lineSpacing = 0,
0x0, 0x0, 0x1, 0x0, 0x6, 0x0, 0x0, 0x0, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, .speed = 0,
0x6, 0x0, 0x0, 0x0, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x6, 0x0, 0x0 .fgColor = 1,
.bgColor = 15,
.shadowColor = 6,
},
{ // 2
.fillValue = 0xEE,
.fontId = 1,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 3
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 4
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 5
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 6
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 7
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 12,
.bgColor = 14,
.shadowColor = 11,
},
{ // 8
.fillValue = 0xEE,
.fontId = 1,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 9
.fillValue = 0xEE,
.fontId = 1,
.x = 2,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 12,
.bgColor = 14,
.shadowColor = 11,
},
{ // 10
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 11
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 12
.fillValue = 0xEE,
.fontId = 1,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 13
.fillValue = 0xEE,
.fontId = 1,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 14
.fillValue = 0x0,
.fontId = 1,
.x = 32,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 1,
.bgColor = 0,
.shadowColor = 2,
},
{ // 15
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 16
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 17
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 18
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 19
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 20
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 21
.fillValue = 0x0,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 1,
.bgColor = 0,
.shadowColor = 6,
},
{ // 22
.fillValue = 0x0,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 1,
.bgColor = 0,
.shadowColor = 6,
},
{ // 23
.fillValue = 0x0,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 1,
.bgColor = 0,
.shadowColor = 6,
},
}; };
static const u8 sUnknown_085CD54C[] = static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
{ {
0xFF, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0xF, 0x6, 0x0, 0x0, 0xFF, 0x1, { // 0
0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0xF, 0x6, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, .fillValue = 0xFF,
0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, .fontId = 1,
0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, .x = 0,
0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, .y = 1,
0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, .letterSpacing = 0,
0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xC, 0xE, 0xB, 0x0, 0x0, .lineSpacing = 0,
0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, .speed = 1,
0x1, 0x2, 0x1, 0x0, 0x0, 0x0, 0xC, 0xE, 0xB, 0x0, 0x0, 0xEE, 0x7, 0x0, .fgColor = 1,
0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, .bgColor = 15,
0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, .shadowColor = 6,
0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, },
0xE, 0xF, 0x0, 0x0, 0x0, 0x1, 0x20, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x2, { // 1
0x0, 0x0, 0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0x1, 0xE, 0xF, 0x0, .fillValue = 0xFF,
0x0, 0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, .fontId = 1,
0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, .x = 1,
0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, .y = 1,
0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0xFF, .letterSpacing = 0,
0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0xFF, 0x1, .lineSpacing = 0,
0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0x11, 0x1, 0x0, 0x1, 0x0, 0x0, .speed = 0,
0x1, 0x2, 0x1, 0x3, 0x0, 0x0 .fgColor = 1,
.bgColor = 15,
.shadowColor = 6,
},
{ // 2
.fillValue = 0xEE,
.fontId = 1,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 3
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 4
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 5
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 6
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 7
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 12,
.bgColor = 14,
.shadowColor = 11,
},
{ // 8
.fillValue = 0xEE,
.fontId = 1,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 9
.fillValue = 0xEE,
.fontId = 1,
.x = 2,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 12,
.bgColor = 14,
.shadowColor = 11,
},
{ // 10
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 11
.fillValue = 0xEE,
.fontId = 7,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 12
.fillValue = 0xEE,
.fontId = 1,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 13
.fillValue = 0xEE,
.fontId = 1,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 14
.fillValue = 0x0,
.fontId = 1,
.x = 32,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 1,
.bgColor = 0,
.shadowColor = 2,
},
{ // 15
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 1,
.bgColor = 14,
.shadowColor = 15,
},
{ // 16
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 17
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 18
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 19
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 20
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 21
.fillValue = 0xEE,
.fontId = 1,
.x = -1,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = 13,
.bgColor = 14,
.shadowColor = 15,
},
{ // 22
.fillValue = 0x11,
.fontId = 1,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 1,
.fgColor = 2,
.bgColor = 1,
.shadowColor = 3,
},
}; };
static const u8 * const gUnknown_085CD660[] = static const struct BattleWindowText *const sBattleTextOnWindowsInfo[] =
{ {
sUnknown_085CD42C, sUnknown_085CD54C sTextOnWindowsInfo_Normal, sTextOnWindowsInfo_Arena
}; };
static const u8 sRecordedBattleTextSpeeds[] = {8, 4, 1, 0}; static const u8 sRecordedBattleTextSpeeds[] = {8, 4, 1, 0};
// code
void BufferStringBattle(u16 stringID) void BufferStringBattle(u16 stringID)
{ {
s32 i; s32 i;
const u8* stringPtr = NULL; const u8 *stringPtr = NULL;
gStringInfo = (struct StringInfoBattle*)(&gBattleBufferA[gActiveBattler][4]); gStringInfo = (struct StringInfoBattle*)(&gBattleBufferA[gActiveBattler][4]);
gLastUsedItem = gStringInfo->lastItem; gLastUsedItem = gStringInfo->lastItem;
@ -2395,47 +2932,46 @@ static void sub_814F950(u8* dst)
} }
} }
void BattleHandleAddTextPrinter(const u8 *text, u8 arg1) void BattlePutTextOnWindow(const u8 *text, u8 windowId)
{ {
const u8 *r8 = gUnknown_085CD660[gBattleScripting.field_24]; const struct BattleWindowText *textInfo = sBattleTextOnWindowsInfo[gBattleScripting.windowsType];
bool32 r9; bool32 toVram;
struct TextSubPrinter textSubPrinter; struct TextSubPrinter textSubPrinter;
u8 speed; u8 speed;
if (arg1 & 0x80) if (windowId & 0x80)
{ {
arg1 &= ~(0x80); windowId &= ~(0x80);
r9 = FALSE; toVram = FALSE;
} }
else else
{ {
FillWindowPixelBuffer(arg1, r8[12 * arg1]); FillWindowPixelBuffer(windowId, textInfo[windowId].fillValue);
r9 = TRUE; toVram = TRUE;
} }
textSubPrinter.current_text_offset = text; textSubPrinter.current_text_offset = text;
textSubPrinter.windowId = arg1; textSubPrinter.windowId = windowId;
textSubPrinter.fontId = r8[(12 * arg1) + 1]; textSubPrinter.fontId = textInfo[windowId].fontId;
textSubPrinter.x = r8[(12 * arg1) + 2]; textSubPrinter.x = textInfo[windowId].x;
textSubPrinter.y = r8[(12 * arg1) + 3]; textSubPrinter.y = textInfo[windowId].y;
textSubPrinter.currentX = textSubPrinter.x; textSubPrinter.currentX = textSubPrinter.x;
textSubPrinter.currentY = textSubPrinter.y; textSubPrinter.currentY = textSubPrinter.y;
textSubPrinter.letterSpacing = r8[(12 * arg1) + 4]; textSubPrinter.letterSpacing = textInfo[windowId].letterSpacing;
textSubPrinter.lineSpacing = r8[(12 * arg1) + 5]; textSubPrinter.lineSpacing = textInfo[windowId].lineSpacing;
textSubPrinter.fontColor_l = 0; textSubPrinter.fontColor_l = 0;
textSubPrinter.fgColor = r8[(12 * arg1) + 7]; textSubPrinter.fgColor = textInfo[windowId].fgColor;
textSubPrinter.bgColor = r8[(12 * arg1) + 8]; textSubPrinter.bgColor = textInfo[windowId].bgColor;
textSubPrinter.shadowColor = r8[(12 * arg1) + 9]; textSubPrinter.shadowColor = textInfo[windowId].shadowColor;
if (textSubPrinter.x == 0xFF) if (textSubPrinter.x == 0xFF)
{ {
s32 var2; u32 width = sub_80397C4(gBattleScripting.windowsType, windowId);
u32 var = sub_80397C4(gBattleScripting.field_24, arg1); s32 alignX = GetStringCenterAlignXOffsetWithLetterSpacing(textSubPrinter.fontId, textSubPrinter.current_text_offset, width, textSubPrinter.letterSpacing);
var2 = GetStringCenterAlignXOffsetWithLetterSpacing(textSubPrinter.fontId, textSubPrinter.current_text_offset, var, textSubPrinter.letterSpacing); textSubPrinter.x = textSubPrinter.currentX = alignX;
textSubPrinter.x = textSubPrinter.currentX = var2;
} }
if (arg1 == 0x16) if (windowId == 0x16)
gTextFlags.flag_1 = 0; gTextFlags.flag_1 = 0;
else else
gTextFlags.flag_1 = 1; gTextFlags.flag_1 = 1;
@ -2445,7 +2981,7 @@ void BattleHandleAddTextPrinter(const u8 *text, u8 arg1)
else else
gTextFlags.flag_2 = 0; gTextFlags.flag_2 = 0;
if (arg1 == 0 || arg1 == 0x16) if (windowId == 0 || windowId == 0x16)
{ {
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
speed = 1; speed = 1;
@ -2458,16 +2994,16 @@ void BattleHandleAddTextPrinter(const u8 *text, u8 arg1)
} }
else else
{ {
speed = r8[(12 * arg1) + 6]; speed = textInfo[windowId].speed;
gTextFlags.flag_0 = 0; gTextFlags.flag_0 = 0;
} }
AddTextPrinter(&textSubPrinter, speed, NULL); AddTextPrinter(&textSubPrinter, speed, NULL);
if (r9) if (toVram)
{ {
PutWindowTilemap(arg1); PutWindowTilemap(windowId);
CopyWindowToVram(arg1, 3); CopyWindowToVram(windowId, 3);
} }
} }

View File

@ -5687,7 +5687,7 @@ static void atk5A_yesnoboxlearnmove(void)
{ {
case 0: case 0:
HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0); HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0);
BattleHandleAddTextPrinter(gText_BattleYesNoChoice, 0xC); BattlePutTextOnWindow(gText_BattleYesNoChoice, 0xC);
gBattleScripting.learnMoveState++; gBattleScripting.learnMoveState++;
gBattleCommunication[CURSOR_POSITION] = 0; gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0); BattleCreateYesNoCursorAt(0);
@ -5804,7 +5804,7 @@ static void atk5B_yesnoboxstoplearningmove(void)
{ {
case 0: case 0:
HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0); HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0);
BattleHandleAddTextPrinter(gText_BattleYesNoChoice, 0xC); BattlePutTextOnWindow(gText_BattleYesNoChoice, 0xC);
gBattleScripting.learnMoveState++; gBattleScripting.learnMoveState++;
gBattleCommunication[CURSOR_POSITION] = 0; gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0); BattleCreateYesNoCursorAt(0);
@ -6100,7 +6100,7 @@ static void atk67_yesnobox(void)
{ {
case 0: case 0:
HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0); HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0);
BattleHandleAddTextPrinter(gText_BattleYesNoChoice, 0xC); BattlePutTextOnWindow(gText_BattleYesNoChoice, 0xC);
gBattleCommunication[0]++; gBattleCommunication[0]++;
gBattleCommunication[CURSOR_POSITION] = 0; gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0); BattleCreateYesNoCursorAt(0);
@ -6720,7 +6720,7 @@ static void atk76_various(void)
break; break;
case 16: case 16:
BattleStringExpandPlaceholdersToDisplayedString(gRefereeStringsTable[gBattlescriptCurrInstr[1]]); BattleStringExpandPlaceholdersToDisplayedString(gRefereeStringsTable[gBattlescriptCurrInstr[1]]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0x16); BattlePutTextOnWindow(gDisplayedStringBattle, 0x16);
break; break;
case 17: case 17:
if (IsTextPrinterActive(0x16)) if (IsTextPrinterActive(0x16))
@ -10406,7 +10406,7 @@ static void atkF3_trygivecaughtmonnick(void)
{ {
case 0: case 0:
HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0); HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0);
BattleHandleAddTextPrinter(gText_BattleYesNoChoice, 0xC); BattlePutTextOnWindow(gText_BattleYesNoChoice, 0xC);
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
gBattleCommunication[CURSOR_POSITION] = 0; gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0); BattleCreateYesNoCursorAt(0);

View File

@ -153,8 +153,8 @@ extern const u8 gText_234Players[];
extern void sub_800A418(void); extern void sub_800A418(void);
extern u8 sub_800A9D8(void); extern u8 sub_800A9D8(void);
extern void sub_809882C(u8, u16, u8); extern void LoadSav2WindowGfx(u8, u16, u8);
extern void copy_textbox_border_tile_patterns_to_vram(u8, u16, u8); extern void LoadMessageBoxGfx(u8, u16, u8);
extern void sub_81AABF0(void (*callback)(void)); extern void sub_81AABF0(void (*callback)(void));
extern void sub_800B4C0(void); extern void sub_800B4C0(void);
extern void ClearLinkCallback(void); extern void ClearLinkCallback(void);
@ -927,8 +927,8 @@ static void sub_807FAC8(void)
InitBgsFromTemplates(1, sBerryBlenderBgTemplates, ARRAY_COUNT(sBerryBlenderBgTemplates)); InitBgsFromTemplates(1, sBerryBlenderBgTemplates, ARRAY_COUNT(sBerryBlenderBgTemplates));
SetBgTilemapBuffer(1, sBerryBlenderData->tilemapBuffers[0]); SetBgTilemapBuffer(1, sBerryBlenderData->tilemapBuffers[0]);
SetBgTilemapBuffer(2, sBerryBlenderData->tilemapBuffers[1]); SetBgTilemapBuffer(2, sBerryBlenderData->tilemapBuffers[1]);
sub_809882C(0, 1, 0xD0); LoadSav2WindowGfx(0, 1, 0xD0);
copy_textbox_border_tile_patterns_to_vram(0, 0x14, 0xF0); LoadMessageBoxGfx(0, 0x14, 0xF0);
InitBerryBlenderWindows(); InitBerryBlenderWindows();
sBerryBlenderData->mainState++; sBerryBlenderData->mainState++;
@ -1331,8 +1331,8 @@ static void sub_8080588(void)
SetBgTilemapBuffer(1, sBerryBlenderData->tilemapBuffers[0]); SetBgTilemapBuffer(1, sBerryBlenderData->tilemapBuffers[0]);
SetBgTilemapBuffer(2, sBerryBlenderData->tilemapBuffers[1]); SetBgTilemapBuffer(2, sBerryBlenderData->tilemapBuffers[1]);
sub_809882C(0, 1, 0xD0); LoadSav2WindowGfx(0, 1, 0xD0);
copy_textbox_border_tile_patterns_to_vram(0, 0x14, 0xF0); LoadMessageBoxGfx(0, 0x14, 0xF0);
InitBerryBlenderWindows(); InitBerryBlenderWindows();
sBerryBlenderData->field_44 = 0; sBerryBlenderData->field_44 = 0;

View File

@ -202,6 +202,6 @@ static void InitClearSaveDataScreenWindows(void)
InitWindows(sClearSaveTextWindow); InitWindows(sClearSaveTextWindow);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
FillWindowPixelBuffer(0, 0); FillWindowPixelBuffer(0, 0);
sub_80987D4(0, 0, 2, 224); LoadWindowGfx(0, 0, 2, 224);
LoadPalette(gUnknown_0860F074, 0xF0, 0x20); LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
} }

View File

@ -655,7 +655,7 @@ static void CB2_EggHatch_1(void)
case 9: case 9:
if (!IsTextPrinterActive(sEggHatchData->windowId)) if (!IsTextPrinterActive(sEggHatchData->windowId))
{ {
sub_809882C(sEggHatchData->windowId, 0x140, 0xE0); LoadSav2WindowGfx(sEggHatchData->windowId, 0x140, 0xE0);
CreateYesNoMenu(&sYesNoWinTemplate, 0x140, 0xE, 0); CreateYesNoMenu(&sYesNoWinTemplate, 0x140, 0xE, 0);
sEggHatchData->CB2_state++; sEggHatchData->CB2_state++;
} }

View File

@ -635,7 +635,7 @@ static void Task_EvolutionScene(u8 taskID)
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {
StringExpandPlaceholders(gStringVar4, gText_PkmnIsEvolving); StringExpandPlaceholders(gStringVar4, gText_PkmnIsEvolving);
BattleHandleAddTextPrinter(gStringVar4, 0); BattlePutTextOnWindow(gStringVar4, 0);
gTasks[taskID].tState++; gTasks[taskID].tState++;
} }
break; break;
@ -731,7 +731,7 @@ static void Task_EvolutionScene(u8 taskID)
if (IsCryFinished()) if (IsCryFinished())
{ {
StringExpandPlaceholders(gStringVar4, gText_CongratsPkmnEvolved); StringExpandPlaceholders(gStringVar4, gText_CongratsPkmnEvolved);
BattleHandleAddTextPrinter(gStringVar4, 0); BattlePutTextOnWindow(gStringVar4, 0);
PlayBGM(MUS_FANFA5); PlayBGM(MUS_FANFA5);
gTasks[taskID].tState++; gTasks[taskID].tState++;
SetMonData(mon, MON_DATA_SPECIES, (void*)(&gTasks[taskID].tPostEvoSpecies)); SetMonData(mon, MON_DATA_SPECIES, (void*)(&gTasks[taskID].tPostEvoSpecies));
@ -818,7 +818,7 @@ static void Task_EvolutionScene(u8 taskID)
else // Fire Red leftover probably else // Fire Red leftover probably
StringExpandPlaceholders(gStringVar4, gText_PkmnStoppedEvolving); StringExpandPlaceholders(gStringVar4, gText_PkmnStoppedEvolving);
BattleHandleAddTextPrinter(gStringVar4, 0); BattlePutTextOnWindow(gStringVar4, 0);
gTasks[taskID].tEvoWasStopped = TRUE; gTasks[taskID].tEvoWasStopped = TRUE;
gTasks[taskID].tState = 15; gTasks[taskID].tState = 15;
} }
@ -829,7 +829,7 @@ static void Task_EvolutionScene(u8 taskID)
BufferMoveToLearnIntoBattleTextBuff2(); BufferMoveToLearnIntoBattleTextBuff2();
PlayFanfare(MUS_FANFA1); PlayFanfare(MUS_FANFA1);
BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_PKMNLEARNEDMOVE - BATTLESTRINGS_ID_ADDER]); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_PKMNLEARNEDMOVE - BATTLESTRINGS_ID_ADDER]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gTasks[taskID].tLearnsFirstMove = 0x40; // re-used as a counter gTasks[taskID].tLearnsFirstMove = 0x40; // re-used as a counter
gTasks[taskID].tState++; gTasks[taskID].tState++;
} }
@ -846,7 +846,7 @@ static void Task_EvolutionScene(u8 taskID)
{ {
BufferMoveToLearnIntoBattleTextBuff2(); BufferMoveToLearnIntoBattleTextBuff2();
BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_TRYTOLEARNMOVE1 - BATTLESTRINGS_ID_ADDER]); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_TRYTOLEARNMOVE1 - BATTLESTRINGS_ID_ADDER]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gTasks[taskID].tLearnMoveState++; gTasks[taskID].tLearnMoveState++;
} }
break; break;
@ -854,7 +854,7 @@ static void Task_EvolutionScene(u8 taskID)
if (!IsTextPrinterActive(0) && !IsSEPlaying()) if (!IsTextPrinterActive(0) && !IsSEPlaying())
{ {
BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_TRYTOLEARNMOVE2 - BATTLESTRINGS_ID_ADDER]); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_TRYTOLEARNMOVE2 - BATTLESTRINGS_ID_ADDER]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gTasks[taskID].tLearnMoveState++; gTasks[taskID].tLearnMoveState++;
} }
break; break;
@ -862,7 +862,7 @@ static void Task_EvolutionScene(u8 taskID)
if (!IsTextPrinterActive(0) && !IsSEPlaying()) if (!IsTextPrinterActive(0) && !IsSEPlaying())
{ {
BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_TRYTOLEARNMOVE3 - BATTLESTRINGS_ID_ADDER]); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_TRYTOLEARNMOVE3 - BATTLESTRINGS_ID_ADDER]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gTasks[taskID].tData7 = 5; gTasks[taskID].tData7 = 5;
gTasks[taskID].tData8 = 10; gTasks[taskID].tData8 = 10;
gTasks[taskID].tLearnMoveState++; gTasks[taskID].tLearnMoveState++;
@ -871,7 +871,7 @@ static void Task_EvolutionScene(u8 taskID)
if (!IsTextPrinterActive(0) && !IsSEPlaying()) if (!IsTextPrinterActive(0) && !IsSEPlaying())
{ {
HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0); HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0);
BattleHandleAddTextPrinter(gText_BattleYesNoChoice, 0xC); BattlePutTextOnWindow(gText_BattleYesNoChoice, 0xC);
gTasks[taskID].tLearnMoveState++; gTasks[taskID].tLearnMoveState++;
sEvoCursorPos = 0; sEvoCursorPos = 0;
BattleCreateYesNoCursorAt(0); BattleCreateYesNoCursorAt(0);
@ -939,7 +939,7 @@ static void Task_EvolutionScene(u8 taskID)
if (IsHMMove2(move)) if (IsHMMove2(move))
{ {
BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_HMMOVESCANTBEFORGOTTEN - BATTLESTRINGS_ID_ADDER]); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_HMMOVESCANTBEFORGOTTEN - BATTLESTRINGS_ID_ADDER]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gTasks[taskID].tLearnMoveState = 12; gTasks[taskID].tLearnMoveState = 12;
} }
else else
@ -955,14 +955,14 @@ static void Task_EvolutionScene(u8 taskID)
break; break;
case 7: case 7:
BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_123POOF - BATTLESTRINGS_ID_ADDER]); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_123POOF - BATTLESTRINGS_ID_ADDER]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gTasks[taskID].tLearnMoveState++; gTasks[taskID].tLearnMoveState++;
break; break;
case 8: case 8:
if (!IsTextPrinterActive(0) && !IsSEPlaying()) if (!IsTextPrinterActive(0) && !IsSEPlaying())
{ {
BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_PKMNFORGOTMOVE - BATTLESTRINGS_ID_ADDER]); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_PKMNFORGOTMOVE - BATTLESTRINGS_ID_ADDER]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gTasks[taskID].tLearnMoveState++; gTasks[taskID].tLearnMoveState++;
} }
break; break;
@ -970,20 +970,20 @@ static void Task_EvolutionScene(u8 taskID)
if (!IsTextPrinterActive(0) && !IsSEPlaying()) if (!IsTextPrinterActive(0) && !IsSEPlaying())
{ {
BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_ANDELLIPSIS - BATTLESTRINGS_ID_ADDER]); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_ANDELLIPSIS - BATTLESTRINGS_ID_ADDER]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gTasks[taskID].tState = 20; gTasks[taskID].tState = 20;
} }
break; break;
case 10: case 10:
BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_STOPLEARNINGMOVE - BATTLESTRINGS_ID_ADDER]); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_STOPLEARNINGMOVE - BATTLESTRINGS_ID_ADDER]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gTasks[taskID].tData7 = 11; gTasks[taskID].tData7 = 11;
gTasks[taskID].tData8 = 0; gTasks[taskID].tData8 = 0;
gTasks[taskID].tLearnMoveState = 3; gTasks[taskID].tLearnMoveState = 3;
break; break;
case 11: case 11:
BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_DIDNOTLEARNMOVE - BATTLESTRINGS_ID_ADDER]); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_DIDNOTLEARNMOVE - BATTLESTRINGS_ID_ADDER]);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattlePutTextOnWindow(gDisplayedStringBattle, 0);
gTasks[taskID].tState = 15; gTasks[taskID].tState = 15;
break; break;
case 12: case 12:
@ -1215,7 +1215,7 @@ static void Task_TradeEvolutionScene(u8 taskID)
case 3: case 3:
if (!IsTextPrinterActive(0) && !IsSEPlaying()) if (!IsTextPrinterActive(0) && !IsSEPlaying())
{ {
sub_809882C(0, 0xA8, 0xE0); LoadSav2WindowGfx(0, 0xA8, 0xE0);
CreateYesNoMenu(&gUnknown_0833900C, 0xA8, 0xE, 0); CreateYesNoMenu(&gUnknown_0833900C, 0xA8, 0xE, 0);
sEvoCursorPos = 0; sEvoCursorPos = 0;
gTasks[taskID].tLearnMoveState++; gTasks[taskID].tLearnMoveState++;

View File

@ -89,7 +89,7 @@ static void MCB2_InitRegionMapRegisters(void)
InitBgsFromTemplates(1, gUnknown_085E5068, 2); InitBgsFromTemplates(1, gUnknown_085E5068, 2);
InitWindows(gUnknown_085E5070); InitWindows(gUnknown_085E5070);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
sub_809882C(0, 0x27, 0xd0); LoadSav2WindowGfx(0, 0x27, 0xd0);
clear_scheduled_bg_copies_to_vram(); clear_scheduled_bg_copies_to_vram();
SetMainCallback2(MCB2_FieldUpdateRegionMap); SetMainCallback2(MCB2_FieldUpdateRegionMap);
SetVBlankCallback(VBCB_FieldUpdateRegionMap); SetVBlankCallback(VBCB_FieldUpdateRegionMap);

View File

@ -89,7 +89,7 @@ extern void sub_8197434(u8, u8);
extern u16 sub_818D97C(u8 playerGender, u8); extern u16 sub_818D97C(u8 playerGender, u8);
extern u16 sub_818D8AC(u16, u8, s16, s16, u8, u16); extern u16 sub_818D8AC(u16, u8, s16, s16, u8, u16);
extern const void* stdpal_get(u8); extern const void* stdpal_get(u8);
extern void sub_80987D4(u8, u8, u16, u8); extern void LoadWindowGfx(u8, u8, u16, u8);
extern u16 sub_818D820(u16); extern u16 sub_818D820(u16);
extern u16 sub_818D8F0(u16); extern u16 sub_818D8F0(u16);
extern u16 sub_818D7D8(u16 species, u32 trainerId, u32 personality, u8 arg3, s16 sp0, s16 sp1, u8 sp2, u16 sp3); extern u16 sub_818D7D8(u16 species, u32 trainerId, u32 personality, u8 arg3, s16 sp0, s16 sp1, u8 sp2, u16 sp3);
@ -725,7 +725,7 @@ static void sub_8173EE4(u8 taskId)
ShowBg(3); ShowBg(3);
gTasks[taskId].tPlayerSpriteID = sub_818D8AC(sub_818D97C(gSaveBlock2Ptr->playerGender, 1), 1, 120, 72, 6, 0xFFFF); gTasks[taskId].tPlayerSpriteID = sub_818D8AC(sub_818D97C(gSaveBlock2Ptr->playerGender, 1), 1, 120, 72, 6, 0xFFFF);
AddWindow(&sHof_WindowTemplate); AddWindow(&sHof_WindowTemplate);
sub_80987D4(1, gSaveBlock2Ptr->optionsWindowFrameType, 0x21D, 0xD0); LoadWindowGfx(1, gSaveBlock2Ptr->optionsWindowFrameType, 0x21D, 0xD0);
LoadPalette(stdpal_get(1), 0xE0, 0x20); LoadPalette(stdpal_get(1), 0xE0, 0x20);
gTasks[taskId].tFrameCount = 120; gTasks[taskId].tFrameCount = 120;
gTasks[taskId].func = Task_Hof_WaitAndPrintPlayerInfo; gTasks[taskId].func = Task_Hof_WaitAndPrintPlayerInfo;

View File

@ -2103,8 +2103,8 @@ void setup_bag_menu_textboxes(void)
InitWindows(gUnknown_08614174); InitWindows(gUnknown_08614174);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
sub_809882C(0, 1, -32); LoadSav2WindowGfx(0, 1, -32);
copy_textbox_border_tile_patterns_to_vram(0, 10, -48); LoadMessageBoxGfx(0, 10, -48);
sub_819A2BC(-64, 1); sub_819A2BC(-64, 1);
LoadPalette(&gUnknown_0860F074, 0xF0, 0x20); LoadPalette(&gUnknown_0860F074, 0xF0, 0x20);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)

View File

@ -337,7 +337,7 @@ s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenu
switch (arg2) switch (arg2)
{ {
case 2: case 2:
sub_809882C(gUnknown_0203CE84.field_5, tileNum, palNum); LoadSav2WindowGfx(gUnknown_0203CE84.field_5, tileNum, palNum);
case 1: case 1:
sub_8098858(gUnknown_0203CE84.field_5, tileNum, palNum / 16); sub_8098858(gUnknown_0203CE84.field_5, tileNum, palNum / 16);
break; break;

View File

@ -1038,7 +1038,7 @@ void task_new_game_prof_birch_speech_3(u8 taskId)
{ {
InitWindows(gUnknown_082FF080); InitWindows(gUnknown_082FF080);
LoadMainMenuWindowFrameTiles(0, 0xF3); LoadMainMenuWindowFrameTiles(0, 0xF3);
copy_textbox_border_tile_patterns_to_vram(0, 0xFC, 0xF0); LoadMessageBoxGfx(0, 0xFC, 0xF0);
unknown_rbox_to_vram(0, 1); unknown_rbox_to_vram(0, 1);
PutWindowTilemap(0); PutWindowTilemap(0);
CopyWindowToVram(0, 2); CopyWindowToVram(0, 2);
@ -1565,7 +1565,7 @@ void new_game_prof_birch_speech_part2_start(void)
SetMainCallback2(CB2_MainMenu); SetMainCallback2(CB2_MainMenu);
InitWindows(gUnknown_082FF080); InitWindows(gUnknown_082FF080);
LoadMainMenuWindowFrameTiles(0, 0xF3); LoadMainMenuWindowFrameTiles(0, 0xF3);
copy_textbox_border_tile_patterns_to_vram(0, 0xFC, 0xF0); LoadMessageBoxGfx(0, 0xFC, 0xF0);
PutWindowTilemap(0); PutWindowTilemap(0);
CopyWindowToVram(0, 3); CopyWindowToVram(0, 3);
} }

View File

@ -193,8 +193,8 @@ void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonP
void sub_81973A4(void) void sub_81973A4(void)
{ {
copy_textbox_border_tile_patterns_to_vram(0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10); LoadMessageBoxGfx(0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10);
sub_809882C(0, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM * 0x10); LoadSav2WindowGfx(0, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM * 0x10);
} }
void NewMenuHelpers_DrawDialogueFrame(u8 windowId, bool8 copyToVram) void NewMenuHelpers_DrawDialogueFrame(u8 windowId, bool8 copyToVram)
@ -412,7 +412,7 @@ void SetStandardWindowBorderStyle(u8 windowId, bool8 copyToVram)
void sub_819786C(u8 windowId, bool8 copyToVram) void sub_819786C(u8 windowId, bool8 copyToVram)
{ {
copy_textbox_border_tile_patterns_to_vram(windowId, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10); LoadMessageBoxGfx(windowId, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10);
sub_8197B1C(windowId, copyToVram, DLG_WINDOW_BASE_TILE_NUM, 0xF); sub_8197B1C(windowId, copyToVram, DLG_WINDOW_BASE_TILE_NUM, 0xF);
} }

View File

@ -77,7 +77,7 @@ void CB2_InitMysteryEventMenu(void)
FillWindowPixelBuffer(i, 0); FillWindowPixelBuffer(i, 0);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x1E, 0x14); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x1E, 0x14);
sub_809882C(0, 1u, 0xD0u); LoadSav2WindowGfx(0, 1u, 0xD0u);
sub_81978B0(0xE0); sub_81978B0(0xE0);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON);
SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDCNT, 0);

View File

@ -75,8 +75,8 @@ extern const u16 gUnknown_0860F074[];
extern void CB2_ReturnToField(void); extern void CB2_ReturnToField(void);
extern bool8 sub_81221EC(void); extern bool8 sub_81221EC(void);
extern void sub_809882C(u8, u16, u8); extern void LoadSav2WindowGfx(u8, u16, u8);
extern void copy_textbox_border_tile_patterns_to_vram(u8, u16, u8); extern void LoadMessageBoxGfx(u8, u16, u8);
extern void sub_80AF168(void); extern void sub_80AF168(void);
// this file's functions // this file's functions
@ -566,8 +566,8 @@ static void HandleInitWindows(void)
InitWindows(sWindowTemplatesForPokeblockMenu); InitWindows(sWindowTemplatesForPokeblockMenu);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
sub_809882C(0, 1, 0xE0); LoadSav2WindowGfx(0, 1, 0xE0);
copy_textbox_border_tile_patterns_to_vram(0, 0xA, 0xD0); LoadMessageBoxGfx(0, 0xA, 0xD0);
LoadPalette(gUnknown_0860F074, 0xF0, 0x20); LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
for (i = 0; i < ARRAY_COUNT(sWindowTemplatesForPokeblockMenu) - 1; i++) for (i = 0; i < ARRAY_COUNT(sWindowTemplatesForPokeblockMenu) - 1; i++)

View File

@ -59,7 +59,7 @@ extern const u16 gUnknown_0860F074[];
extern bool8 sub_81221EC(void); extern bool8 sub_81221EC(void);
extern void sub_806A068(u16, u8); extern void sub_806A068(u16, u8);
extern void sub_809882C(u8, u16, u8); extern void LoadSav2WindowGfx(u8, u16, u8);
// this file's functions // this file's functions
static void HandleInitBackgrounds(void); static void HandleInitBackgrounds(void);
@ -706,7 +706,7 @@ static void HandleInitWindows(void)
{ {
InitWindows(sWindowTemplates); InitWindows(sWindowTemplates);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
sub_809882C(0, 1, 0xE0); LoadSav2WindowGfx(0, 1, 0xE0);
LoadPalette(gUnknown_0860F074, 0xF0, 0x20); LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
FillWindowPixelBuffer(0, 0); FillWindowPixelBuffer(0, 0);
PutWindowTilemap(0); PutWindowTilemap(0);

View File

@ -1603,7 +1603,7 @@ void MCB2_FlyMap(void)
gMain.state++; gMain.state++;
break; break;
case 3: case 3:
sub_809882C(0, 0x65, 0xd0); LoadSav2WindowGfx(0, 0x65, 0xd0);
clear_scheduled_bg_copies_to_vram(); clear_scheduled_bg_copies_to_vram();
gMain.state++; gMain.state++;
break; break;

View File

@ -58,7 +58,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
{ {
case 0: case 0:
ScanlineEffect_Clear(); ScanlineEffect_Clear();
sub_8035658(); BattleInitBgsAndWindows();
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0);
ShowBg(0); ShowBg(0);

View File

@ -1517,7 +1517,7 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx)
winTemplate = sub_8198A50(0, xWindow, yWindow + 1, width, height, 0xF, 0x1); winTemplate = sub_8198A50(0, xWindow, yWindow + 1, width, height, 0xF, 0x1);
gUnknown_03000F30 = AddWindow(&winTemplate); gUnknown_03000F30 = AddWindow(&winTemplate);
sub_809882C(gUnknown_03000F30, 0x214, 0xE0); LoadSav2WindowGfx(gUnknown_03000F30, 0x214, 0xE0);
NewMenuHelpers_DrawStdWindowFrame(gUnknown_03000F30, 0); NewMenuHelpers_DrawStdWindowFrame(gUnknown_03000F30, 0);
PutWindowTilemap(gUnknown_03000F30); PutWindowTilemap(gUnknown_03000F30);
FillWindowPixelBuffer(gUnknown_03000F30, 0x11); FillWindowPixelBuffer(gUnknown_03000F30, 0x11);

View File

@ -1212,7 +1212,7 @@ static bool32 sub_80A03E4(u8 *par1)
ResetBgsAndClearDma3BusyFlags(0); ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sUnknown_085105A8, ARRAY_COUNT(sUnknown_085105A8)); InitBgsFromTemplates(0, sUnknown_085105A8, ARRAY_COUNT(sUnknown_085105A8));
InitWindows(sUnknown_085105AC); InitWindows(sUnknown_085105AC);
box_border_load_tiles_and_pal(0, 8, 224); LoadSav2WindowGfx_(0, 8, 224);
sub_81978B0(240); sub_81978B0(240);
break; break;
case 3: case 3:

View File

@ -46,7 +46,7 @@ extern const u8 gStarterChoose_LabelCoords[][2];
extern const u8 gUnknown_085B1E0C[]; extern const u8 gUnknown_085B1E0C[];
extern const u8 gUnknown_085B1E28[][2]; extern const u8 gUnknown_085B1E28[][2];
extern void sub_809882C(u8, u16, u8); extern void LoadSav2WindowGfx(u8, u16, u8);
extern void ScanlineEffect_Stop(void); extern void ScanlineEffect_Stop(void);
extern void clear_scheduled_bg_copies_to_vram(void); extern void clear_scheduled_bg_copies_to_vram(void);
extern void dp13_810BB8C(void); extern void dp13_810BB8C(void);
@ -126,7 +126,7 @@ void CB2_ChooseStarter(void)
InitWindows(gUnknown_085B1DCC); InitWindows(gUnknown_085B1DCC);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
sub_809882C(0, 0x2A8, 0xD0); LoadSav2WindowGfx(0, 0x2A8, 0xD0);
clear_scheduled_bg_copies_to_vram(); clear_scheduled_bg_copies_to_vram();
ScanlineEffect_Stop(); ScanlineEffect_Stop();
ResetTasks(); ResetTasks();

View File

@ -91,26 +91,26 @@ const struct TilesPal *GetWindowFrameTilesPal(u8 id)
return &sWindowFrames[id]; return &sWindowFrames[id];
} }
void copy_textbox_border_tile_patterns_to_vram(u8 windowId, u16 destOffset, u8 palOffset) void LoadMessageBoxGfx(u8 windowId, u16 destOffset, u8 palOffset)
{ {
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gMessageBox_Gfx, 0x1C0, destOffset); LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gMessageBox_Gfx, 0x1C0, destOffset);
LoadPalette(GetOverworldTextboxPalettePtr(), palOffset, 0x20); LoadPalette(GetOverworldTextboxPalettePtr(), palOffset, 0x20);
} }
void box_border_load_tiles_and_pal(u8 windowId, u16 destOffset, u8 palOffset) void LoadSav2WindowGfx_(u8 windowId, u16 destOffset, u8 palOffset)
{ {
sub_809882C(windowId, destOffset, palOffset); LoadSav2WindowGfx(windowId, destOffset, palOffset);
} }
void sub_80987D4(u8 windowId, u8 frameId, u16 destOffset, u8 palOffset) void LoadWindowGfx(u8 windowId, u8 frameId, u16 destOffset, u8 palOffset)
{ {
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), sWindowFrames[frameId].tiles, 0x120, destOffset); LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), sWindowFrames[frameId].tiles, 0x120, destOffset);
LoadPalette(sWindowFrames[frameId].pal, palOffset, 0x20); LoadPalette(sWindowFrames[frameId].pal, palOffset, 0x20);
} }
void sub_809882C(u8 windowId, u16 destOffset, u8 palOffset) void LoadSav2WindowGfx(u8 windowId, u16 destOffset, u8 palOffset)
{ {
sub_80987D4(windowId, gSaveBlock2Ptr->optionsWindowFrameType, destOffset, palOffset); LoadWindowGfx(windowId, gSaveBlock2Ptr->optionsWindowFrameType, destOffset, palOffset);
} }
void sub_8098858(u8 windowId, u16 tileNum, u8 palNum) void sub_8098858(u8 windowId, u16 tileNum, u8 palNum)

View File

@ -164,7 +164,7 @@ void sub_8166380(void)
InitBgsFromTemplates(0, gUnknown_085DFCCC, ARRAY_COUNT(gUnknown_085DFCCC)); InitBgsFromTemplates(0, gUnknown_085DFCCC, ARRAY_COUNT(gUnknown_085DFCCC));
InitWindows(gUnknown_085DFCDC); InitWindows(gUnknown_085DFCDC);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
sub_809882C(0, 0x97, 0xE0); LoadSav2WindowGfx(0, 0x97, 0xE0);
gUnknown_0203BC90->field_50++; gUnknown_0203BC90->field_50++;
break; break;
case 4: case 4:

View File

@ -576,7 +576,7 @@ static void LoadWallClockGraphics(void)
InitBgsFromTemplates(0, gUnknown_085B21FC, 3); InitBgsFromTemplates(0, gUnknown_085B21FC, 3);
InitWindows(gUnknown_085B21DC); InitWindows(gUnknown_085B21DC);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
sub_809882C(0, 0x250, 0xd0); LoadSav2WindowGfx(0, 0x250, 0xd0);
clear_scheduled_bg_copies_to_vram(); clear_scheduled_bg_copies_to_vram();
ScanlineEffect_Stop(); ScanlineEffect_Stop();
ResetTasks(); ResetTasks();