up to x50

This commit is contained in:
DizzyEggg 2017-09-24 00:29:52 +02:00
parent 7bb0fcf182
commit 898d0b20ad
10 changed files with 422 additions and 1162 deletions

View File

@ -6678,8 +6678,8 @@ _0803A1E4:
.pool
thumb_func_end sub_8039F40
thumb_func_start sub_803A284
sub_803A284: @ 803A284
thumb_func_start SwitchInClearStructs
SwitchInClearStructs: @ 803A284
push {r4-r7,lr}
mov r7, r10
mov r6, r9
@ -7254,7 +7254,7 @@ _0803A6B4:
pop {r0}
bx r0
.pool
thumb_func_end sub_803A284
thumb_func_end SwitchInClearStructs
thumb_func_start UndoEffectsAfterFainting
UndoEffectsAfterFainting: @ 803A75C
@ -7806,7 +7806,7 @@ _0803ABD4:
movs r0, 0
movs r1, 0
movs r2, 0
bl dp01_build_cmdbuf_x00_a_b_0
bl EmitGetAttributes
ldrb r0, [r4]
bl MarkBufferBankForExecution
ldrb r0, [r5]
@ -8947,7 +8947,7 @@ _0803B5B2:
ldrb r1, [r0]
movs r0, 0
movs r2, 0
bl dp01_build_cmdbuf_x05_a_b_c
bl EmitSwitchInAnim
ldrb r0, [r4]
bl MarkBufferBankForExecution
_0803B5D4:
@ -10488,7 +10488,7 @@ _0803C374:
str r0, [sp]
movs r0, 0
movs r2, 0x6
bl dp01_build_cmdbuf_x16_a_b_c_ptr_d_e_f
bl EmitChoosePokemon
b _0803C42E
.pool
_0803C3B0:
@ -10531,7 +10531,7 @@ _0803C3EE:
movs r1, 0
_0803C400:
movs r3, 0
bl dp01_build_cmdbuf_x16_a_b_c_ptr_d_e_f
bl EmitChoosePokemon
b _0803C42E
.pool
_0803C410:
@ -10548,7 +10548,7 @@ _0803C410:
movs r1, 0
movs r2, 0x6
movs r3, 0
bl dp01_build_cmdbuf_x16_a_b_c_ptr_d_e_f
bl EmitChoosePokemon
_0803C42E:
ldr r0, =gActiveBank
ldrb r0, [r0]
@ -11287,14 +11287,14 @@ _0803CB3C:
movs r0, 0
movs r1, 0
adds r2, r4, 0
bl sub_8034464
bl EmitLinkStandbyMsg
b _0803CB66
.pool
_0803CB5C:
movs r0, 0
movs r1, 0x1
adds r2, r4, 0
bl sub_8034464
bl EmitLinkStandbyMsg
_0803CB66:
ldr r4, =gActiveBank
_0803CB68:

File diff suppressed because it is too large Load Diff

View File

@ -1155,7 +1155,7 @@ _0806C6AE:
movs r0, 0
movs r1, 0
movs r2, 0
bl dp01_build_cmdbuf_x00_a_b_0
bl EmitGetAttributes
ldrb r0, [r4]
bl MarkBufferBankForExecution
strb r5, [r4]

View File

@ -2134,8 +2134,8 @@ _0803389C:
.pool
thumb_func_end sub_803375C
thumb_func_start dp01_build_cmdbuf_x00_a_b_0
dp01_build_cmdbuf_x00_a_b_0: @ 80338B4
thumb_func_start EmitGetAttributes
EmitGetAttributes: @ 80338B4
push {r4,lr}
adds r4, r1, 0
lsls r0, 24
@ -2152,7 +2152,7 @@ dp01_build_cmdbuf_x00_a_b_0: @ 80338B4
pop {r0}
bx r0
.pool
thumb_func_end dp01_build_cmdbuf_x00_a_b_0
thumb_func_end EmitGetAttributes
thumb_func_start dp01_build_cmdbuf_x01_a_b_0
dp01_build_cmdbuf_x01_a_b_0: @ 80338D8
@ -2264,8 +2264,8 @@ dp01_build_cmdbuf_x04_4_4_4: @ 8033980
.pool
thumb_func_end dp01_build_cmdbuf_x04_4_4_4
thumb_func_start dp01_build_cmdbuf_x05_a_b_c
dp01_build_cmdbuf_x05_a_b_c: @ 80339A0
thumb_func_start EmitSwitchInAnim
EmitSwitchInAnim: @ 80339A0
push {r4,lr}
adds r4, r1, 0
lsls r0, 24
@ -2282,10 +2282,10 @@ dp01_build_cmdbuf_x05_a_b_c: @ 80339A0
pop {r0}
bx r0
.pool
thumb_func_end dp01_build_cmdbuf_x05_a_b_c
thumb_func_end EmitSwitchInAnim
thumb_func_start dp01_build_cmdbuf_x06_a
dp01_build_cmdbuf_x06_a: @ 80339C4
thumb_func_start EmitReturnPokeToBall
EmitReturnPokeToBall: @ 80339C4
push {lr}
adds r3, r1, 0
lsls r0, 24
@ -2299,7 +2299,7 @@ dp01_build_cmdbuf_x06_a: @ 80339C4
pop {r0}
bx r0
.pool
thumb_func_end dp01_build_cmdbuf_x06_a
thumb_func_end EmitReturnPokeToBall
thumb_func_start dp01_build_cmdbuf_x07_7_7_7
dp01_build_cmdbuf_x07_7_7_7: @ 80339E4
@ -2888,8 +2888,8 @@ _08033E7E:
.pool
thumb_func_end sub_8033E6C
thumb_func_start dp01_build_cmdbuf_x16_a_b_c_ptr_d_e_f
dp01_build_cmdbuf_x16_a_b_c_ptr_d_e_f: @ 8033EA0
thumb_func_start EmitChoosePokemon
EmitChoosePokemon: @ 8033EA0
push {r4-r6,lr}
ldr r6, [sp, 0x10]
lsls r0, 24
@ -2918,7 +2918,7 @@ _08033EBA:
pop {r0}
bx r0
.pool
thumb_func_end dp01_build_cmdbuf_x16_a_b_c_ptr_d_e_f
thumb_func_end EmitChoosePokemon
thumb_func_start dp01_build_cmdbuf_x17_17_17_17
dp01_build_cmdbuf_x17_17_17_17: @ 8033EDC
@ -3684,8 +3684,8 @@ EmitBattleAnimation: @ 8034438
.pool
thumb_func_end EmitBattleAnimation
thumb_func_start sub_8034464
sub_8034464: @ 8034464
thumb_func_start EmitLinkStandbyMsg
EmitLinkStandbyMsg: @ 8034464
push {r4,r5,lr}
lsls r0, 24
lsrs r5, r0, 24
@ -3716,7 +3716,7 @@ _08034490:
pop {r0}
bx r0
.pool
thumb_func_end sub_8034464
thumb_func_end EmitLinkStandbyMsg
thumb_func_start dp01_build_cmdbuf_x38_a
dp01_build_cmdbuf_x38_a: @ 80344A8

View File

@ -561,23 +561,9 @@ struct BattleStruct
u8 field_52;
u8 sentInPokes;
u8 field_54[4];
u8 field_58;
u8 field_59;
u8 field_5A;
u8 field_5B;
u8 field_58[4];
u8 field_5C[4];
u8 field_60;
u8 field_61;
u8 field_62;
u8 field_63;
u8 field_64;
u8 field_65;
u8 field_66;
u8 field_67;
u8 field_68;
u8 field_69;
u8 field_6A;
u8 field_6B;
u8 field_60[4][3];
u8 field_6C;
u8 field_6D;
u8 field_6E;
@ -792,6 +778,8 @@ extern struct BattleStruct* gBattleStruct;
#define ATK48_BIT_x4 0x4
#define ATK48_LOWER_FAIL_CHECK 0x8
#define ATK4F_DONT_CHECK_STATUSES 0x80
#define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8
#define GET_STAT_BUFF_VALUE(n)((n & 0xF0) >> 4) // 0x10, 0x20, 0x40
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit
@ -840,6 +828,7 @@ void PrepareStringBattle(u16 stringId, u8 bank);
u8 GetBattleBank(u8 caseId);
void UndoEffectsAfterFainting(void);
bool8 HasMoveFailed(u8 bank);
void SwitchInClearStructs(void);
// battle_3
void BattleScriptPush(const u8* bsPtr);

View File

@ -11,6 +11,10 @@ void EmitFaintAnimation(u8 bufferId);
void EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints);
void EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument);
void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible);
void EmitReturnPokeToBall(u8 bufferId, u8 arg1);
void EmitGetAttributes(u8 bufferId, u8 arg1, u8 arg2);
void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit);
void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, const u8* arg4);
void MarkBufferBankForExecution(u8 bank);

View File

@ -623,6 +623,9 @@ bool8 IsShinyOtIdPersonality(u32 otId, u32 personality);
void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies);
bool8 IsTradedMon(struct Pokemon *mon);
void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality);
s32 sub_806D864(u16 a1);
bool16 sub_806D82C(u8 id);
#include "sprite.h"

View File

@ -188,8 +188,6 @@ extern void SetMoveEffect(bool8 primary, u8 certainArg);
extern bool8 UproarWakeUpCheck(u8 bank);
extern void sub_803F9EC();
extern bool8 sub_80423F4(u8 bank, u8, u8);
extern u8 sub_806D864(u8);
extern u8 sub_806D82C(u8);
extern u8 weather_get_current(void);
extern void sub_803E08C(void);
extern void bc_move_exec_returning(void);

View File

@ -17,6 +17,7 @@
#include "songs.h"
#include "text.h"
#include "sound.h"
#include "pokedex.h"
// variables
@ -94,6 +95,7 @@ extern const u8* const gBattleScriptsForMoveEffects[];
// functions
extern void sub_81A5718(u8 bank); // battle frontier 2
extern void sub_81A56B4(void); // battle frontier 2
// BattleScripts
extern const u8 BattleScript_MoveEnd[];
@ -4912,3 +4914,369 @@ void atk49_moveend(void)
gBattlescriptCurrInstr += 3;
}
void atk4A_typecalc2(void)
{
u8 flags = 0;
s32 i = 0;
u8 moveType = gBattleMoves[gCurrentMove].type;
if (gBattleMons[gBankTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND)
{
gLastUsedAbility = gBattleMons[gBankTarget].ability;
gBattleMoveFlags |= (MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED);
gUnknown_02024250[gBankTarget] = 0;
gBattleCommunication[6] = moveType;
RecordAbilityBattle(gBankTarget, gLastUsedAbility);
}
else
{
while (gTypeEffectiveness[i]!= TYPE_ENDTABLE)
{
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
{
if (gBattleMons[gBankTarget].status2 & STATUS2_FORESIGHT)
{
break;
}
else
{
i += 3;
continue;
}
}
if (gTypeEffectiveness[i] == moveType)
{
// check type1
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1)
{
if (gTypeEffectiveness[i + 2] == 0)
{
gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED;
break;
}
if (gTypeEffectiveness[i + 2] == 5)
{
flags |= MOVESTATUS_NOTVERYEFFECTIVE;
}
if (gTypeEffectiveness[i + 2] == 20)
{
flags |= MOVESTATUS_SUPEREFFECTIVE;
}
}
// check type2
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2)
{
if (gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
&& gTypeEffectiveness[i + 2] == 0)
{
gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED;
break;
}
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2
&& gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
&& gTypeEffectiveness[i + 2] == 5)
{
flags |= MOVESTATUS_NOTVERYEFFECTIVE;
}
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2
&& gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
&& gTypeEffectiveness[i + 2] == 20)
{
flags |= MOVESTATUS_SUPEREFFECTIVE;
}
}
}
i += 3;
}
}
if (gBattleMons[gBankTarget].ability == ABILITY_WONDER_GUARD
&& !(flags & MOVESTATUS_NOEFFECT)
&& AttacksThisTurn(gBankAttacker, gCurrentMove) == 2
&& (!(flags & MOVESTATUS_SUPEREFFECTIVE) || ((flags & (MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE)) == (MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE)))
&& gBattleMoves[gCurrentMove].power)
{
gLastUsedAbility = ABILITY_WONDER_GUARD;
gBattleMoveFlags |= MOVESTATUS_MISSED;
gUnknown_02024250[gBankTarget] = 0;
gBattleCommunication[6] = 3;
RecordAbilityBattle(gBankTarget, gLastUsedAbility);
}
if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED)
gProtectStructs[gBankAttacker].notEffective = 1;
gBattlescriptCurrInstr++;
}
void atk4B_return_atk_to_ball(void)
{
gActiveBank = gBankAttacker;
if (!(gHitMarker & HITMARKER_FAINTED(gActiveBank)))
{
EmitReturnPokeToBall(0, 0);
MarkBufferBankForExecution(gActiveBank);
}
gBattlescriptCurrInstr++;
}
void atk4C_copy_poke_data(void)
{
if (gBattleExecBuffer)
return;
gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
gBattlePartyID[gActiveBank] = *(gBattleStruct->field_5C + gActiveBank);
EmitGetAttributes(0, 0, gBitTable[gBattlePartyID[gActiveBank]]);
MarkBufferBankForExecution(gActiveBank);
gBattlescriptCurrInstr += 2;
}
void atk4D_switch_data_update(void)
{
struct BattlePokemon oldData;
s32 i;
u8 *monData;
if (gBattleExecBuffer)
return;
gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
oldData = gBattleMons[gActiveBank];
monData = (u8*)(&gBattleMons[gActiveBank]);
for (i = 0; i < sizeof(struct BattlePokemon); i++)
{
monData[i] = gBattleBufferB[gActiveBank][4 + i];
}
gBattleMons[gActiveBank].type1 = gBaseStats[gBattleMons[gActiveBank].species].type1;
gBattleMons[gActiveBank].type2 = gBaseStats[gBattleMons[gActiveBank].species].type2;
gBattleMons[gActiveBank].ability = GetAbilityBySpecies(gBattleMons[gActiveBank].species, gBattleMons[gActiveBank].altAbility);
// check knocked off item
i = GetBankSide(gActiveBank);
if (gWishFutureKnock.knockedOffPokes[i] & gBitTable[gBattlePartyID[gActiveBank]])
{
gBattleMons[gActiveBank].item = 0;
}
if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS)
{
for (i = 0; i < 8; i++)
{
gBattleMons[gActiveBank].statStages[i] = oldData.statStages[i];
}
gBattleMons[gActiveBank].status2 = oldData.status2;
}
SwitchInClearStructs();
if (gBattleTypeFlags & BATTLE_TYPE_PALACE && gBattleMons[gActiveBank].maxHP / 2 >= gBattleMons[gActiveBank].hp
&& gBattleMons[gActiveBank].hp != 0 && !(gBattleMons[gActiveBank].status1 & STATUS_SLEEP))
{
gBattleStruct->field_92 |= gBitTable[gActiveBank];
}
gBattleScripting.bank = gActiveBank;
gBattleTextBuff1[0] = PLACEHOLDER_BEGIN;
gBattleTextBuff1[1] = 7;
gBattleTextBuff1[2] = gActiveBank;
gBattleTextBuff1[3] = gBattlePartyID[gActiveBank];
gBattleTextBuff1[4] = EOS;
gBattlescriptCurrInstr += 2;
}
void atk4E_switchin_anim(void)
{
if (gBattleExecBuffer)
return;
gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
if (GetBankSide(gActiveBank) == SIDE_OPPONENT
&& !(gBattleTypeFlags & (BATTLE_TYPE_LINK
| BATTLE_TYPE_EREADER_TRAINER
| BATTLE_TYPE_x2000000
| BATTLE_TYPE_x4000000
| BATTLE_TYPE_FRONTIER)))
HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBank].species), FLAG_SET_SEEN, gBattleMons[gActiveBank].personality);
gAbsentBankFlags &= ~(gBitTable[gActiveBank]);
EmitSwitchInAnim(0, gBattlePartyID[gActiveBank], gBattlescriptCurrInstr[2]);
MarkBufferBankForExecution(gActiveBank);
gBattlescriptCurrInstr += 3;
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
sub_81A56B4();
}
void atk4F_jump_if_cannot_switch(void)
{
s32 val = 0;
s32 compareVar = 0;
struct Pokemon *party = NULL;
s32 r7 = 0;
gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1] & ~(ATK4F_DONT_CHECK_STATUSES));
if (!(gBattlescriptCurrInstr[1] & ATK4F_DONT_CHECK_STATUSES)
&& ((gBattleMons[gActiveBank].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION))
|| (gStatuses3[gActiveBank] & STATUS3_ROOTED)))
{
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
}
else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
{
#ifndef NONMATCHING
asm("":::"r5");
#endif // NONMATCHING
if (GetBankSide(gActiveBank) == SIDE_OPPONENT)
party = gEnemyParty;
else
party = gPlayerParty;
val = 0;
if (2 & gActiveBank)
val = 3;
for (compareVar = val + 3; val < compareVar; val++)
{
if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[val], MON_DATA_IS_EGG)
&& GetMonData(&party[val], MON_DATA_HP) != 0
&& gBattlePartyID[gActiveBank] != val)
break;
}
if (val == compareVar)
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
}
else if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
if (gBattleTypeFlags & BATTLE_TYPE_x800000)
{
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
{
party = gPlayerParty;
val = 0;
if (sub_806D82C(sub_806D864(gActiveBank)) == TRUE)
val = 3;
}
else
{
party = gEnemyParty;
if (gActiveBank == 1)
val = 0;
else
val = 3;
}
}
else
{
if (GetBankSide(gActiveBank) == SIDE_OPPONENT)
party = gEnemyParty;
else
party = gPlayerParty;
val = 0;
if (sub_806D82C(sub_806D864(gActiveBank)) == TRUE)
val = 3;
}
for (compareVar = val + 3; val < compareVar; val++)
{
if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[val], MON_DATA_IS_EGG)
&& GetMonData(&party[val], MON_DATA_HP) != 0
&& gBattlePartyID[gActiveBank] != val)
break;
}
if (val == compareVar)
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
}
else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && GetBankSide(gActiveBank) == SIDE_OPPONENT)
{
party = gEnemyParty;
val = 0;
if (gActiveBank == 3)
val = 3;
for (compareVar = val + 3; val < compareVar; val++)
{
if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[val], MON_DATA_IS_EGG)
&& GetMonData(&party[val], MON_DATA_HP) != 0
&& gBattlePartyID[gActiveBank] != val)
break;
}
if (val == compareVar)
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
}
else
{
if (GetBankSide(gActiveBank) == SIDE_OPPONENT)
{
r7 = GetBankByPlayerAI(1);
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
compareVar = GetBankByPlayerAI(3);
else
compareVar = r7;
party = gEnemyParty;
}
else
{
r7 = GetBankByPlayerAI(0);
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
compareVar = GetBankByPlayerAI(2);
else
compareVar = r7;
party = gPlayerParty;
}
for (val = 0; val < 6; val++)
{
if (GetMonData(&party[val], MON_DATA_HP) != 0
&& GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[val], MON_DATA_IS_EGG)
&& val != gBattlePartyID[r7] && val != gBattlePartyID[compareVar])
break;
}
if (val == 6)
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
}
}
void sub_804CF10(u8 arg0)
{
*(gBattleStruct->field_58 + gActiveBank) = gBattlePartyID[gActiveBank];
*(gBattleStruct->field_5C + gActiveBank) = 6;
gBattleStruct->field_93 &= ~(gBitTable[gActiveBank]);
EmitChoosePokemon(0, 1, arg0, 0, gBattleStruct->field_60[gActiveBank]);
MarkBufferBankForExecution(gActiveBank);
}

View File

@ -601,9 +601,9 @@ bool8 sub_806D7EC(void)
return retVal;
}
bool8 sub_806D82C(u8 id)
bool16 sub_806D82C(u8 id)
{
bool8 retVal = FALSE;
bool16 retVal = FALSE;
switch (gLinkPlayers[id].lp_field_18)
{
case 0: