diff options
Diffstat (limited to 'src/battle')
-rw-r--r-- | src/battle/battle_2.c | 25 | ||||
-rw-r--r-- | src/battle/battle_3.c | 10 | ||||
-rw-r--r-- | src/battle/battle_4.c | 338 | ||||
-rw-r--r-- | src/battle/battle_7.c | 8 | ||||
-rw-r--r-- | src/battle/battle_transition.c | 2 |
5 files changed, 98 insertions, 285 deletions
diff --git a/src/battle/battle_2.c b/src/battle/battle_2.c index 095482305..6d406c5e5 100644 --- a/src/battle/battle_2.c +++ b/src/battle/battle_2.c @@ -31,13 +31,6 @@ #include "battle_move_effects.h" #include "ewram.h" -struct UnknownStruct6 -{ - u16 unk0[0xA0]; - u8 fillerA0[0x640]; - u16 unk780[0xA0]; -}; - struct UnknownStruct7 { u8 unk0; @@ -123,8 +116,6 @@ extern void (*gBattleMainFunc)(void); extern u8 gLeveledUpInBattle; extern void (*gBattleBankFunc[])(void); extern u8 gHealthboxIDs[]; -extern struct UnknownStruct6 gUnknown_03004DE0; -//extern u16 gUnknown_03004DE0[][0xA0]; // possibly? extern u16 gBattleTypeFlags; extern s8 gBattleTerrain; // I'm not sure if this is supposed to be s8 or u8. Regardless, it must have the same type as the return value of BattleSetup_GetTerrain. extern u8 gReservedSpritePaletteCount; @@ -175,14 +166,14 @@ void InitBattle(void) for (i = 0; i < 80; i++) { - gUnknown_03004DE0.unk0[i] = 0xF0; - gUnknown_03004DE0.unk780[i] = 0xF0; + gUnknown_03004DE0[0][i] = 0xF0; + gUnknown_03004DE0[1][i] = 0xF0; } for (i = 80; i < 160; i++) { asm(""::"r"(i)); // Needed to stop the compiler from optimizing out the loop counter - gUnknown_03004DE0.unk0[i] = 0xFF10; - gUnknown_03004DE0.unk780[i] = 0xFF10; + gUnknown_03004DE0[0][i] = 0xFF10; + gUnknown_03004DE0[1][i] = 0xFF10; } //sub_80895F8(gUnknown_081F9674.unk0, gUnknown_081F9674.unk4, gUnknown_081F9674.unk8); sub_80895F8(gUnknown_081F9674); @@ -1153,14 +1144,14 @@ void c2_8011A1C(void) for (i = 0; i < 80; i++) { - gUnknown_03004DE0.unk0[i] = 0xF0; - gUnknown_03004DE0.unk780[i] = 0xF0; + gUnknown_03004DE0[0][i] = 0xF0; + gUnknown_03004DE0[1][i] = 0xF0; } for (i = 80; i < 160; i++) { asm(""::"r"(i)); // Needed to stop the compiler from optimizing out the loop counter - gUnknown_03004DE0.unk0[i] = 0xFF10; - gUnknown_03004DE0.unk780[i] = 0xFF10; + gUnknown_03004DE0[0][i] = 0xFF10; + gUnknown_03004DE0[1][i] = 0xFF10; } SetUpWindowConfig(&gWindowConfig_81E6C58); ResetPaletteFade(); diff --git a/src/battle/battle_3.c b/src/battle/battle_3.c index f37111af5..958ee0b55 100644 --- a/src/battle/battle_3.c +++ b/src/battle/battle_3.c @@ -546,7 +546,7 @@ u8 UpdateTurnCounters(void) else gBattlescriptCurrInstr = gUnknown_081D8F7D; - BATTLE_STRUCT->animArg1 = 0xC; + BATTLE_STRUCT->animArg1 = B_ANIM_SANDSTORM_CONTINUES; gBattleCommunication[MULTISTRING_CHOOSER] = 0; b_call_bc_move_exec(gBattlescriptCurrInstr); effect++; @@ -580,7 +580,7 @@ u8 UpdateTurnCounters(void) else gBattlescriptCurrInstr = gUnknown_081D8F7D; - BATTLE_STRUCT->animArg1 = 0xD; + BATTLE_STRUCT->animArg1 = B_ANIM_HAIL_CONTINUES; gBattleCommunication[MULTISTRING_CHOOSER] = 1; b_call_bc_move_exec(gBattlescriptCurrInstr); effect++; @@ -1505,7 +1505,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (!(gBattleWeather & WEATHER_RAIN_ANY)) { gBattleWeather = (WEATHER_RAIN_TEMPORARY | WEATHER_RAIN_PERMANENT); - BATTLE_STRUCT->animArg1 = 0xA; + BATTLE_STRUCT->animArg1 = B_ANIM_RAIN_CONTINUES; BATTLE_STRUCT->scriptingActive = bank; effect++; } @@ -1514,7 +1514,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (!(gBattleWeather & WEATHER_SANDSTORM_ANY)) { gBattleWeather = (WEATHER_SANDSTORM_PERMANENT | WEATHER_SANDSTORM_TEMPORARY); - BATTLE_STRUCT->animArg1 = 0xC; + BATTLE_STRUCT->animArg1 = B_ANIM_SANDSTORM_CONTINUES; BATTLE_STRUCT->scriptingActive = bank; effect++; } @@ -1523,7 +1523,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (!(gBattleWeather & WEATHER_SUN_ANY)) { gBattleWeather = (WEATHER_SUN_PERMANENT | WEATHER_SUN_TEMPORARY); - BATTLE_STRUCT->animArg1 = 0xB; + BATTLE_STRUCT->animArg1 = B_ANIM_SUN_CONTINUES; BATTLE_STRUCT->scriptingActive = bank; effect++; } diff --git a/src/battle/battle_4.c b/src/battle/battle_4.c index cff81396d..73530c486 100644 --- a/src/battle/battle_4.c +++ b/src/battle/battle_4.c @@ -221,6 +221,16 @@ extern u8 gUnknown_081D8C65[]; extern u8 gUnknown_081D9156[]; extern u8 gUnknown_081D9468[]; +// read via orr +#define BSScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24) +#define BSScriptRead16(ptr) ((ptr)[0] | ((ptr)[1] << 8)) +#define BSScriptReadPtr(ptr) ((void *)BSScriptRead32(ptr)) + +// read via add +#define BS2ScriptRead32(ptr) ((ptr)[0] + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24)) +#define BS2ScriptRead16(ptr) ((ptr)[0] + ((ptr)[1] << 8)) +#define BS2ScriptReadPtr(ptr) ((void *)BS2ScriptRead32(ptr)) + #define TargetProtectAffected ((gProtectStructs[gBankTarget].protected && gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED)) //array entries for battle communication @@ -7327,276 +7337,88 @@ static void atk44(void) ewram16060(gBankAttacker) = 1; } -#ifdef NONMATCHING static void atk45_playanimation(void) { - #define ANIMATION_ID T2_READ_8(gBattlescriptCurrInstr + 2) - #define ARGUMENT (u16*) T2_READ_PTR(gBattlescriptCurrInstr + 3) - gActiveBank = GetBattleBank(T2_READ_8(gBattlescriptCurrInstr + 1)); + const u16* argumentPtr; + + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + argumentPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 3); - if ( ANIMATION_ID == 1 || ANIMATION_ID == 0x11 || ANIMATION_ID == 2) { - EmitBattleAnimation(0, ANIMATION_ID, *argument); + if (gBattlescriptCurrInstr[2] == B_ANIM_STATS_CHANGE + || gBattlescriptCurrInstr[2] == B_ANIM_SNATCH_MOVE + || gBattlescriptCurrInstr[2] == B_ANIM_SUBSTITUTE_FADE) + { + EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 7; - } else if (gHitMarker & HITMARKER_NO_ANIMATIONS) { + } + else if (gHitMarker & HITMARKER_NO_ANIMATIONS) + { b_movescr_stack_push(gBattlescriptCurrInstr + 7); gBattlescriptCurrInstr = BattleScript_Pausex20; - } else { - if (((ANIMATION_ID - 10) > 3 && gStatuses3[gActiveBank] & (STATUS3_SEMI_INVULNERABLE))) { - gBattlescriptCurrInstr += 7; - } else { - EmitBattleAnimation(0, ANIMATION_ID, *argument); - MarkBufferBankForExecution(gActiveBank); - gBattlescriptCurrInstr += 7; - } + } + else if (gBattlescriptCurrInstr[2] == B_ANIM_RAIN_CONTINUES + || gBattlescriptCurrInstr[2] == B_ANIM_SUN_CONTINUES + || gBattlescriptCurrInstr[2] == B_ANIM_SANDSTORM_CONTINUES + || gBattlescriptCurrInstr[2] == B_ANIM_HAIL_CONTINUES) + { + EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr += 7; + } + else if (gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) + { + gBattlescriptCurrInstr += 7; + } + else + { + EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr += 7; } } -#else -__attribute__((naked)) -static void atk45_playanimation(void) +static void atk46_playanimation2(void) // animation Id is stored in the first pointer { - asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - ldr r5, _08021444 @ =gBattlescriptCurrInstr\n\ - ldr r0, [r5]\n\ - ldrb r0, [r0, 0x1]\n\ - bl GetBattleBank\n\ - ldr r6, _08021448 @ =gActiveBank\n\ - strb r0, [r6]\n\ - ldr r2, [r5]\n\ - ldrb r1, [r2, 0x3]\n\ - ldrb r0, [r2, 0x4]\n\ - lsls r0, 8\n\ - adds r1, r0\n\ - ldrb r0, [r2, 0x5]\n\ - lsls r0, 16\n\ - adds r1, r0\n\ - ldrb r0, [r2, 0x6]\n\ - lsls r0, 24\n\ - adds r3, r1, r0\n\ - ldrb r4, [r2, 0x2]\n\ - adds r0, r4, 0\n\ - cmp r0, 0x1\n\ - beq _08021426\n\ - cmp r0, 0x11\n\ - beq _08021426\n\ - cmp r0, 0x2\n\ - bne _0802144C\n\ -_08021426:\n\ - ldr r4, _08021444 @ =gBattlescriptCurrInstr\n\ - ldr r0, [r4]\n\ - ldrb r1, [r0, 0x2]\n\ - ldrh r2, [r3]\n\ - movs r0, 0\n\ - bl EmitBattleAnimation\n\ - ldr r0, _08021448 @ =gActiveBank\n\ - ldrb r0, [r0]\n\ - bl MarkBufferBankForExecution\n\ - ldr r0, [r4]\n\ - adds r0, 0x7\n\ - str r0, [r4]\n\ - b _080214AE\n\ - .align 2, 0\n\ -_08021444: .4byte gBattlescriptCurrInstr\n\ -_08021448: .4byte gActiveBank\n\ -_0802144C:\n\ - ldr r0, _08021464 @ =gHitMarker\n\ - ldr r0, [r0]\n\ - movs r1, 0x80\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _0802146C\n\ - adds r0, r2, 0x7\n\ - bl b_movescr_stack_push\n\ - ldr r0, _08021468 @ =BattleScript_Pausex20\n\ - b _080214AC\n\ - .align 2, 0\n\ -_08021464: .4byte gHitMarker\n\ -_08021468: .4byte BattleScript_Pausex20\n\ -_0802146C:\n\ - adds r0, r4, 0\n\ - subs r0, 0xA\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x3\n\ - bls _08021498\n\ - ldr r1, _08021490 @ =gStatuses3\n\ - ldrb r0, [r6]\n\ - lsls r0, 2\n\ - adds r0, r1\n\ - ldr r0, [r0]\n\ - ldr r1, _08021494 @ =0x000400c0\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _08021498\n\ - adds r0, r2, 0x7\n\ - b _080214AC\n\ - .align 2, 0\n\ -_08021490: .4byte gStatuses3\n\ -_08021494: .4byte 0x000400c0\n\ -_08021498:\n\ - ldrb r1, [r2, 0x2]\n\ - ldrh r2, [r3]\n\ - movs r0, 0\n\ - bl EmitBattleAnimation\n\ - ldrb r0, [r6]\n\ - bl MarkBufferBankForExecution\n\ - ldr r0, [r5]\n\ - adds r0, 0x7\n\ -_080214AC:\n\ - str r0, [r5]\n\ -_080214AE:\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided"); -} -#endif // NONMATCHING + const u16* argumentPtr; + const u8* animationIdPtr; -#ifdef NONMATCHING -static void atk46_playanimation2(void) -{ - u8 arg1; - u8* arg2; - u16* arg3; - u32 something; - - arg1 = T2_READ_8(gBattlescriptCurrInstr + 1); - gActiveBank = GetBattleBank(arg1); - arg2 = T2_READ_PTR(gBattlescriptCurrInstr + 2); - arg3 = T2_READ_PTR(gBattlescriptCurrInstr + 6); - - if (*arg2 == 1 || *arg2 == 0x11 || *arg2 == 2) - { - EmitBattleAnimation(0, *arg2, *arg3); - MarkBufferBankForExecution(gActiveBank); - gBattlescriptCurrInstr += 10; - return; - } - if ((gHitMarker & 0x80)) - { - something = (u32)(gBattlescriptCurrInstr + 10); - } - else - { - u8 yeah = *arg2 - 10; - if (yeah < 4 || (gStatuses3[gActiveBank] & 0x000400C0) == 0) - { - EmitBattleAnimation(0, *arg2, *arg3); - MarkBufferBankForExecution(gActiveBank); - } - something = (u32)(gBattlescriptCurrInstr + 10); - } - gBattlescriptCurrInstr = (u8*)something; -} -#else -__attribute__((naked)) -static void atk46_playanimation2(void) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - ldr r6, _0802151C @ =gBattlescriptCurrInstr\n\ - ldr r0, [r6]\n\ - ldrb r0, [r0, 0x1]\n\ - bl GetBattleBank\n\ - ldr r7, _08021520 @ =gActiveBank\n\ - strb r0, [r7]\n\ - ldr r2, [r6]\n\ - ldrb r1, [r2, 0x2]\n\ - ldrb r0, [r2, 0x3]\n\ - lsls r0, 8\n\ - adds r1, r0\n\ - ldrb r0, [r2, 0x4]\n\ - lsls r0, 16\n\ - adds r1, r0\n\ - ldrb r0, [r2, 0x5]\n\ - lsls r0, 24\n\ - adds r3, r1, r0\n\ - ldrb r1, [r2, 0x6]\n\ - ldrb r0, [r2, 0x7]\n\ - lsls r0, 8\n\ - adds r1, r0\n\ - ldrb r0, [r2, 0x8]\n\ - lsls r0, 16\n\ - adds r1, r0\n\ - ldrb r0, [r2, 0x9]\n\ - lsls r0, 24\n\ - adds r4, r1, r0\n\ - ldrb r5, [r3]\n\ - adds r0, r5, 0\n\ - cmp r0, 0x1\n\ - beq _080214FE\n\ - cmp r0, 0x11\n\ - beq _080214FE\n\ - cmp r0, 0x2\n\ - bne _08021524\n\ -_080214FE:\n\ - ldrb r1, [r3]\n\ - ldrh r2, [r4]\n\ - movs r0, 0\n\ - bl EmitBattleAnimation\n\ - ldr r0, _08021520 @ =gActiveBank\n\ - ldrb r0, [r0]\n\ - bl MarkBufferBankForExecution\n\ - ldr r1, _0802151C @ =gBattlescriptCurrInstr\n\ - ldr r0, [r1]\n\ - adds r0, 0xA\n\ - str r0, [r1]\n\ - b _0802157A\n\ - .align 2, 0\n\ -_0802151C: .4byte gBattlescriptCurrInstr\n\ -_08021520: .4byte gActiveBank\n\ -_08021524:\n\ - ldr r0, _08021534 @ =gHitMarker\n\ - ldr r0, [r0]\n\ - movs r1, 0x80\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _08021538\n\ - adds r0, r2, 0\n\ - b _08021576\n\ - .align 2, 0\n\ -_08021534: .4byte gHitMarker\n\ -_08021538:\n\ - adds r0, r5, 0\n\ - subs r0, 0xA\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x3\n\ - bls _08021564\n\ - ldr r1, _0802155C @ =gStatuses3\n\ - ldrb r0, [r7]\n\ - lsls r0, 2\n\ - adds r0, r1\n\ - ldr r0, [r0]\n\ - ldr r1, _08021560 @ =0x000400c0\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _08021564\n\ - adds r0, r2, 0\n\ - b _08021576\n\ - .align 2, 0\n\ -_0802155C: .4byte gStatuses3\n\ -_08021560: .4byte 0x000400c0\n\ -_08021564:\n\ - ldrb r1, [r3]\n\ - ldrh r2, [r4]\n\ - movs r0, 0\n\ - bl EmitBattleAnimation\n\ - ldrb r0, [r7]\n\ - bl MarkBufferBankForExecution\n\ - ldr r0, [r6]\n\ -_08021576:\n\ - adds r0, 0xA\n\ - str r0, [r6]\n\ -_0802157A:\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided "); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + animationIdPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 2); + argumentPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 6); + + if (*animationIdPtr == B_ANIM_STATS_CHANGE + || *animationIdPtr == B_ANIM_SNATCH_MOVE + || *animationIdPtr == B_ANIM_SUBSTITUTE_FADE) + { + EmitBattleAnimation(0, *animationIdPtr, *argumentPtr); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr += 10; + } + else if (gHitMarker & HITMARKER_NO_ANIMATIONS) + { + gBattlescriptCurrInstr += 10; + } + else if (*animationIdPtr == B_ANIM_RAIN_CONTINUES + || *animationIdPtr == B_ANIM_SUN_CONTINUES + || *animationIdPtr == B_ANIM_SANDSTORM_CONTINUES + || *animationIdPtr == B_ANIM_HAIL_CONTINUES) + { + EmitBattleAnimation(0, *animationIdPtr, *argumentPtr); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr += 10; + } + else if (gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) + { + gBattlescriptCurrInstr += 10; + } + else + { + EmitBattleAnimation(0, *animationIdPtr, *argumentPtr); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr += 10; + } } -#endif // NONMATCHING static void atk47_setgraphicalstatchangevalues(void) { @@ -17089,7 +16911,7 @@ static void atkE6_castform_change_animation(void) gActiveBank = BATTLE_STRUCT->scriptingActive; if (gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE) BATTLE_STRUCT->castformToChangeInto |= 0x80; - EmitBattleAnimation(0, 0, BATTLE_STRUCT->castformToChangeInto); + EmitBattleAnimation(0, B_ANIM_CASTFORM_CHANGE, BATTLE_STRUCT->castformToChangeInto); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr++; } diff --git a/src/battle/battle_7.c b/src/battle/battle_7.c index 8766b5b77..0728b4b71 100644 --- a/src/battle/battle_7.c +++ b/src/battle/battle_7.c @@ -43,8 +43,8 @@ extern u8 gBattleAnimBankAttacker; extern u8 gBattleAnimBankTarget; extern void (*gAnimScriptCallback)(void); extern u8 gAnimScriptActive; -extern const u8 *const gBattleAnims_Unknown1[]; -extern const u8 *const gBattleAnims_Unknown2[]; +extern const u8 *const gBattleAnims_General[]; +extern const u8 *const gBattleAnims_Special[]; extern const struct CompressedSpriteSheet gTrainerFrontPicTable[]; extern const struct MonCoords gTrainerFrontPicCoords[]; extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[]; @@ -177,7 +177,7 @@ bool8 move_anim_start_t3(u8 a, u8 b, u8 c, u8 d, u16 e) gBattleAnimBankAttacker = b; gBattleAnimBankTarget = c; ewram17840.unk0 = e; - DoMoveAnim(gBattleAnims_Unknown1, d, 0); + DoMoveAnim(gBattleAnims_General, d, 0); taskId = CreateTask(sub_80315E8, 10); gTasks[taskId].data[0] = a; ewram17810[gTasks[taskId].data[0]].unk0_5 = 1; @@ -216,7 +216,7 @@ void move_anim_start_t4(u8 a, u8 b, u8 c, u8 d) gBattleAnimBankAttacker = b; gBattleAnimBankTarget = c; - DoMoveAnim(gBattleAnims_Unknown2, d, 0); + DoMoveAnim(gBattleAnims_Special, d, 0); taskId = CreateTask(sub_80316CC, 10); gTasks[taskId].data[0] = a; ewram17810[gTasks[taskId].data[0]].unk0_6 = 1; diff --git a/src/battle/battle_transition.c b/src/battle/battle_transition.c index 2bde7299b..7f6c114f6 100644 --- a/src/battle/battle_transition.c +++ b/src/battle/battle_transition.c @@ -13,12 +13,12 @@ #include "trainer.h" #include "field_camera.h" #include "ewram.h" +#include "unknown_task.h" void sub_807DE10(void); void dp12_8087EA4(void); extern u16 gUnknown_03005560[]; -extern u16 gUnknown_03004DE0[][0x3C0]; extern const struct OamData gFieldOamData_32x32; |