From 28da80e19af3270b827e98c2e7c69c0199d14d05 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 20 Sep 2017 12:56:45 +0200 Subject: [PATCH] battle 4 up to SetMoveEffect --- asm/battle_2.s | 6 +- asm/battle_4.s | 1004 +--------------------------------- asm/rom3.s | 12 +- data/battle_message.s | 2 +- data/battle_scripts_1.s | 8 +- include/battle.h | 1 + include/battle_controllers.h | 2 + include/songs.h | 4 +- src/battle_4.c | 401 +++++++++++++- sym_ewram.txt | 4 +- 10 files changed, 410 insertions(+), 1034 deletions(-) diff --git a/asm/battle_2.s b/asm/battle_2.s index debf0eb03..7567daa4b 100644 --- a/asm/battle_2.s +++ b/asm/battle_2.s @@ -6510,7 +6510,7 @@ _0803A0AE: ldr r0, [r0, 0xC] adds r0, 0x20 strb r2, [r0] - ldr r5, =gUnknown_0202432C + ldr r5, =gPauseCounterBattle ldr r6, =gBattleMoveDamage ldr r7, =gUnknown_020243FC ldr r0, =gUnknown_03005D54 @@ -14058,14 +14058,14 @@ _0803E480: cmp r0, 0x1F bne _0803E4CE adds r0, r2, 0 - bl sub_8048728 + bl BankGetTurnOrder lsls r0, 24 lsrs r0, 24 ldr r3, [sp] cmp r0, r3 bcs _0803E4CE ldrb r0, [r4] - bl sub_8048728 + bl BankGetTurnOrder lsls r0, 24 lsrs r0, 24 str r0, [sp] diff --git a/asm/battle_4.s b/asm/battle_4.s index e1c02a2fb..149462091 100644 --- a/asm/battle_4.s +++ b/asm/battle_4.s @@ -5,998 +5,6 @@ .text - thumb_func_start atk0C_datahpupdate -atk0C_datahpupdate: @ 8047EC4 - push {r4-r7,lr} - sub sp, 0x4 - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - beq _08047ED2 - b _080482A2 -_08047ED2: - ldr r0, =gBattleStruct - ldr r0, [r0] - ldrb r1, [r0, 0x13] - cmp r1, 0 - beq _08047EF4 - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - bne _08047EF4 - movs r6, 0x3F - ands r6, r1 - b _08047F04 - .pool -_08047EF4: - ldr r2, =gBattleMoves - ldr r0, =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r6, [r0, 0x2] -_08047F04: - ldr r0, =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _08047F12 - b _08048274 -_08047F12: - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r7, =gActiveBank - strb r0, [r7] - ldr r1, =gBattleMons - ldrb r2, [r7] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - beq _08048028 - ldr r0, =gDisableStructs - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - adds r4, r1, r0 - ldrb r1, [r4, 0xA] - mov r12, r0 - cmp r1, 0 - beq _08048028 - ldr r0, =gHitMarker - ldr r3, [r0] - movs r0, 0x80 - lsls r0, 1 - ands r3, r0 - cmp r3, 0 - bne _08048028 - adds r5, r1, 0 - ldr r6, =gBattleMoveDamage - ldr r4, [r6] - cmp r5, r4 - blt _08047FBC - ldr r0, =gSpecialStatuses - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 2 - adds r0, 0x4 - adds r1, r0 - ldr r0, [r1] - cmp r0, 0 - bne _08047F76 - str r4, [r1] -_08047F76: - ldrb r0, [r7] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - add r1, r12 - ldr r2, [r6] - ldrb r0, [r1, 0xA] - subs r0, r2 - strb r0, [r1, 0xA] - ldr r1, =gUnknown_020241F4 - ldr r0, [r6] - str r0, [r1] - b _08047FEC - .pool -_08047FBC: - ldr r0, =gSpecialStatuses - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 2 - adds r0, 0x4 - adds r1, r0 - ldr r0, [r1] - cmp r0, 0 - bne _08047FD0 - str r5, [r1] -_08047FD0: - ldr r2, =gUnknown_020241F4 - ldrb r1, [r7] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - ldrb r0, [r0, 0xA] - str r0, [r2] - ldrb r1, [r7] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - strb r3, [r0, 0xA] -_08047FEC: - ldr r0, =gActiveBank - ldrb r1, [r0] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - ldrb r0, [r0, 0xA] - cmp r0, 0 - beq _08048000 - b _0804829A -_08048000: - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x2 - str r0, [r4] - bl b_movescr_stack_push_cursor - ldr r0, =gUnknown_082DB6FB - str r0, [r4] - b _080482A2 - .pool -_08048028: - ldr r0, =gHitMarker - ldr r2, [r0] - ldr r1, =0xfffffeff - ands r2, r1 - str r2, [r0] - ldr r1, =gBattleMoveDamage - ldr r5, [r1] - mov r12, r0 - adds r7, r1, 0 - cmp r5, 0 - bge _0804807C - ldr r4, =gBattleMons - ldr r2, =gActiveBank - ldrb r0, [r2] - movs r3, 0x58 - adds r1, r0, 0 - muls r1, r3 - adds r1, r4 - ldrh r0, [r1, 0x28] - subs r0, r5 - strh r0, [r1, 0x28] - ldrb r0, [r2] - muls r0, r3 - adds r1, r0, r4 - ldrh r3, [r1, 0x2C] - ldrh r0, [r1, 0x28] - adds r5, r2, 0 - cmp r0, r3 - bhi _08048064 - b _0804823A -_08048064: - strh r3, [r1, 0x28] - b _0804823A - .pool -_0804807C: - movs r0, 0x20 - ands r0, r2 - cmp r0, 0 - beq _08048098 - movs r0, 0x21 - negs r0, r0 - ands r2, r0 - mov r0, r12 - str r2, [r0] - ldr r5, =gActiveBank - b _080480E0 - .pool -_08048098: - ldr r0, =gTakenDmg - ldr r2, =gActiveBank - ldrb r1, [r2] - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] - adds r0, r5 - str r0, [r1] - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - adds r5, r2, 0 - cmp r0, 0 - bne _080480D4 - ldr r1, =gTakenDmgBanks - ldrb r0, [r5] - adds r0, r1 - ldr r1, =gBankAttacker - b _080480DC - .pool -_080480D4: - ldr r1, =gTakenDmgBanks - ldrb r0, [r5] - adds r0, r1 - ldr r1, =gBankTarget -_080480DC: - ldrb r1, [r1] - strb r1, [r0] -_080480E0: - ldr r4, =gBattleMons - ldrb r0, [r5] - movs r3, 0x58 - muls r0, r3 - adds r2, r0, r4 - ldrh r0, [r2, 0x28] - ldr r1, [r7] - cmp r0, r1 - ble _08048110 - subs r0, r1 - strh r0, [r2, 0x28] - ldr r0, =gUnknown_020241F4 - str r1, [r0] - adds r7, r0, 0 - b _08048120 - .pool -_08048110: - ldr r2, =gUnknown_020241F4 - str r0, [r2] - ldrb r0, [r5] - muls r0, r3 - adds r0, r4 - movs r1, 0 - strh r1, [r0, 0x28] - adds r7, r2, 0 -_08048120: - ldr r2, =gSpecialStatuses - ldrb r1, [r5] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r1, r2, 0x4 - adds r3, r0, r1 - ldr r0, [r3] - adds r4, r2, 0 - cmp r0, 0 - bne _08048148 - mov r1, r12 - ldr r0, [r1] - movs r1, 0x80 - lsls r1, 13 - ands r0, r1 - cmp r0, 0 - bne _08048148 - ldr r0, [r7] - str r0, [r3] -_08048148: - cmp r6, 0x8 - bhi _080481D0 - mov r1, r12 - ldr r0, [r1] - movs r1, 0x80 - lsls r1, 13 - ands r0, r1 - cmp r0, 0 - bne _080481CC - ldr r0, =gCurrentMove - ldrh r0, [r0] - cmp r0, 0xDC - beq _080481CC - ldr r3, =gProtectStructs - ldrb r0, [r5] - lsls r0, 4 - adds r1, r3, 0x4 - adds r0, r1 - ldr r2, [r7] - str r2, [r0] - ldrb r1, [r5] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r1, r4, 0 - adds r1, 0x8 - adds r0, r1 - str r2, [r0] - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - cmp r0, 0 - bne _080481AC - ldrb r0, [r5] - lsls r0, 4 - adds r0, r3 - ldr r2, =gBankAttacker - b _080481B4 - .pool -_080481AC: - ldrb r0, [r5] - lsls r0, 4 - adds r0, r3 - ldr r2, =gBankTarget -_080481B4: - ldrb r1, [r2] - strb r1, [r0, 0xC] - ldrb r1, [r5] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r2] - strb r1, [r0, 0x10] - b _0804823A - .pool -_080481CC: - cmp r6, 0x8 - bls _0804823A -_080481D0: - mov r1, r12 - ldr r0, [r1] - movs r1, 0x80 - lsls r1, 13 - ands r0, r1 - cmp r0, 0 - bne _0804823A - ldr r3, =gProtectStructs - ldrb r0, [r5] - lsls r0, 4 - adds r1, r3, 0 - adds r1, 0x8 - adds r0, r1 - ldr r2, [r7] - str r2, [r0] - ldrb r1, [r5] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r1, r4, 0 - adds r1, 0xC - adds r0, r1 - str r2, [r0] - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - cmp r0, 0 - bne _08048220 - ldrb r0, [r5] - lsls r0, 4 - adds r0, r3 - ldr r2, =gBankAttacker - b _08048228 - .pool -_08048220: - ldrb r0, [r5] - lsls r0, 4 - adds r0, r3 - ldr r2, =gBankTarget -_08048228: - ldrb r1, [r2] - strb r1, [r0, 0xD] - ldrb r1, [r5] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r2] - strb r1, [r0, 0x11] -_0804823A: - mov r1, r12 - ldr r0, [r1] - ldr r1, =0xffefffff - ands r0, r1 - mov r1, r12 - str r0, [r1] - ldrb r1, [r5] - movs r0, 0x58 - muls r0, r1 - ldr r1, =gBattleMons + 0x28 - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x2A - movs r2, 0 - movs r3, 0x2 - bl EmitSetAttributes - ldrb r0, [r5] - bl MarkBufferBankForExecution - b _0804829A - .pool -_08048274: - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r1, =gActiveBank - strb r0, [r1] - ldr r2, =gSpecialStatuses - ldrb r1, [r1] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r2, 0x4 - adds r1, r0, r2 - ldr r0, [r1] - cmp r0, 0 - bne _0804829A - ldr r0, =0x0000ffff - str r0, [r1] -_0804829A: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] -_080482A2: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk0C_datahpupdate - - thumb_func_start atk0D_critmessage -atk0D_critmessage: @ 80482BC - push {lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _080482F2 - ldr r0, =gCritMultiplier - ldrb r0, [r0] - cmp r0, 0x2 - bne _080482EA - ldr r0, =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - bne _080482EA - ldr r0, =gBankAttacker - ldrb r1, [r0] - movs r0, 0xD9 - bl PrepareStringBattle - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x7] -_080482EA: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] -_080482F2: - pop {r0} - bx r0 - .pool - thumb_func_end atk0D_critmessage - - thumb_func_start atk0E_effectiveness_sound -atk0E_effectiveness_sound: @ 8048310 - push {r4,lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _080483D0 - ldr r4, =gActiveBank - ldr r0, =gBankTarget - ldrb r0, [r0] - strb r0, [r4] - ldr r1, =gBattleMoveFlags - ldrb r2, [r1] - movs r0, 0x1 - ands r0, r2 - cmp r0, 0 - bne _080483C8 - movs r0, 0xFE - ands r0, r2 - cmp r0, 0x10 - beq _08048382 - cmp r0, 0x10 - bgt _0804835E - cmp r0, 0x4 - beq _08048372 - cmp r0, 0x4 - bgt _08048358 - cmp r0, 0x2 - beq _0804836C - b _08048382 - .pool -_08048358: - cmp r0, 0x8 - beq _080483C8 - b _08048382 -_0804835E: - cmp r0, 0x40 - beq _08048382 - cmp r0, 0x40 - bgt _08048382 - cmp r0, 0x20 - beq _080483C8 - b _08048382 -_0804836C: - movs r0, 0 - movs r1, 0xE - b _08048376 -_08048372: - movs r0, 0 - movs r1, 0xC -_08048376: - bl dp01_build_cmdbuf_x2B_aa_0 - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _080483C8 -_08048382: - ldrb r1, [r1] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08048392 - movs r0, 0 - movs r1, 0xE - b _0804839E -_08048392: - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _080483B0 - movs r0, 0 - movs r1, 0xC -_0804839E: - bl dp01_build_cmdbuf_x2B_aa_0 - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - b _080483C8 - .pool -_080483B0: - movs r0, 0x28 - ands r0, r1 - cmp r0, 0 - bne _080483C8 - movs r0, 0 - movs r1, 0xD - bl dp01_build_cmdbuf_x2B_aa_0 - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution -_080483C8: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] -_080483D0: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atk0E_effectiveness_sound - - thumb_func_start atk0F_resultmessage -atk0F_resultmessage: @ 80483E0 - push {r4-r7,lr} - movs r3, 0 - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - beq _080483EE - b _08048580 -_080483EE: - ldr r1, =gBattleMoveFlags - ldrb r2, [r1] - movs r4, 0x1 - adds r0, r4, 0 - ands r0, r2 - adds r6, r1, 0 - ldr r7, =gBattleCommunication - cmp r0, 0 - beq _0804842C - movs r0, 0x8 - ands r0, r2 - cmp r0, 0 - beq _0804840E - ldrb r0, [r7, 0x6] - cmp r0, 0x2 - bls _0804842C -_0804840E: - ldr r1, =gUnknown_085CC834 - ldrb r0, [r7, 0x6] - lsls r0, 1 - adds r0, r1 - ldrh r3, [r0] - strb r4, [r7, 0x7] - b _0804856A - .pool -_0804842C: - movs r0, 0x1 - strb r0, [r7, 0x7] - ldrb r5, [r6] - movs r0, 0xFE - ands r0, r5 - cmp r0, 0x10 - beq _08048470 - cmp r0, 0x10 - bgt _08048452 - cmp r0, 0x4 - beq _0804846C - cmp r0, 0x4 - bgt _0804844C - cmp r0, 0x2 - beq _08048468 - b _080484B8 -_0804844C: - cmp r0, 0x8 - beq _080484C4 - b _080484B8 -_08048452: - cmp r0, 0x40 - beq _08048474 - cmp r0, 0x40 - bgt _08048462 - cmp r0, 0x20 - bne _08048460 - b _08048564 -_08048460: - b _080484B8 -_08048462: - cmp r0, 0x80 - beq _08048478 - b _080484B8 -_08048468: - movs r3, 0xDE - b _0804856E -_0804846C: - movs r3, 0xDD - b _0804856E -_08048470: - movs r3, 0xDA - b _0804856E -_08048474: - movs r3, 0x99 - b _0804856E -_08048478: - ldr r4, =gLastUsedItem - ldr r2, =gBattleMons - ldr r3, =gBankTarget - ldrb r1, [r3] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r0, [r0, 0x2E] - strh r0, [r4] - ldr r1, =gStringBank - ldrb r0, [r3] - strb r0, [r1] - movs r0, 0x3F - ands r0, r5 - strb r0, [r6] - bl b_movescr_stack_push_cursor - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB816 - b _0804857E - .pool -_080484B8: - adds r2, r6, 0 - ldrb r5, [r2] - movs r0, 0x8 - ands r0, r5 - cmp r0, 0 - beq _080484C8 -_080484C4: - movs r3, 0x1B - b _0804856E -_080484C8: - movs r0, 0x10 - ands r0, r5 - cmp r0, 0 - beq _080484F0 - movs r0, 0xEF - ands r0, r5 - movs r1, 0xFD - ands r0, r1 - movs r1, 0xFB - ands r0, r1 - strb r0, [r2] - bl b_movescr_stack_push_cursor - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB1CE - b _0804857E - .pool -_080484F0: - movs r0, 0x40 - ands r0, r5 - cmp r0, 0 - beq _08048510 - movs r0, 0x3F - ands r0, r5 - strb r0, [r2] - bl b_movescr_stack_push_cursor - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB1C7 - b _0804857E - .pool -_08048510: - movs r0, 0x80 - ands r0, r5 - cmp r0, 0 - beq _08048558 - ldr r4, =gLastUsedItem - ldr r2, =gBattleMons - ldr r3, =gBankTarget - ldrb r1, [r3] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r0, [r0, 0x2E] - strh r0, [r4] - ldr r1, =gStringBank - ldrb r0, [r3] - strb r0, [r1] - movs r0, 0x3F - ands r0, r5 - strb r0, [r6] - bl b_movescr_stack_push_cursor - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB816 - b _0804857E - .pool -_08048558: - movs r0, 0x20 - ands r0, r5 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _08048568 -_08048564: - movs r3, 0xE5 - b _0804856E -_08048568: - strb r0, [r7, 0x7] -_0804856A: - cmp r3, 0 - beq _08048578 -_0804856E: - adds r0, r3, 0 - ldr r1, =gBankAttacker - ldrb r1, [r1] - bl PrepareStringBattle -_08048578: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 -_0804857E: - str r0, [r1] -_08048580: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk0F_resultmessage - - thumb_func_start atk10_printstring -atk10_printstring: @ 8048590 - push {r4,lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _080485BA - ldr r4, =gBattlescriptCurrInstr - ldr r1, [r4] - ldrb r0, [r1, 0x1] - ldrb r1, [r1, 0x2] - lsls r1, 8 - orrs r0, r1 - ldr r1, =gBankAttacker - ldrb r1, [r1] - bl PrepareStringBattle - ldr r0, [r4] - adds r0, 0x3 - str r0, [r4] - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x7] -_080485BA: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atk10_printstring - - thumb_func_start atk11_printstring_playeronly -atk11_printstring_playeronly: @ 80485D0 - push {r4,r5,lr} - ldr r5, =gActiveBank - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r5] - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r1, [r0, 0x1] - ldrb r0, [r0, 0x2] - lsls r0, 8 - orrs r1, r0 - movs r0, 0 - bl dp01_build_cmdbuf_x11_TODO - ldrb r0, [r5] - bl MarkBufferBankForExecution - ldr r0, [r4] - adds r0, 0x3 - str r0, [r4] - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x7] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk11_printstring_playeronly - - thumb_func_start atk12_waitmessage -atk12_waitmessage: @ 8048614 - push {r4-r6,lr} - ldr r0, =gBattleExecBuffer - ldr r4, [r0] - cmp r4, 0 - bne _08048662 - ldr r6, =gBattleCommunication - ldrb r0, [r6, 0x7] - cmp r0, 0 - bne _0804863C - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x3 - str r0, [r1] - b _08048662 - .pool -_0804863C: - ldr r5, =gBattlescriptCurrInstr - ldr r2, [r5] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldr r3, =gUnknown_0202432C - ldrh r0, [r3] - adds r0, 0x1 - strh r0, [r3] - lsls r0, 16 - lsrs r0, 16 - cmp r0, r1 - bcc _08048662 - movs r1, 0 - strh r4, [r3] - adds r0, r2, 0x3 - str r0, [r5] - strb r1, [r6, 0x7] -_08048662: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atk12_waitmessage - - thumb_func_start atk13_printfromtable -atk13_printfromtable: @ 8048670 - push {r4,r5,lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _080486AE - ldr r4, =gBattlescriptCurrInstr - ldr r2, [r4] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - ldr r5, =gBattleCommunication - ldrb r0, [r5, 0x5] - lsls r0, 1 - adds r1, r0 - ldrh r0, [r1] - ldr r1, =gBankAttacker - ldrb r1, [r1] - bl PrepareStringBattle - ldr r0, [r4] - adds r0, 0x5 - str r0, [r4] - movs r0, 0x1 - strb r0, [r5, 0x7] -_080486AE: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk13_printfromtable - - thumb_func_start atk14_printfromtable_playeronly -atk14_printfromtable_playeronly: @ 80486C4 - push {r4-r6,lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0804870E - ldr r5, =gBattlescriptCurrInstr - ldr r2, [r5] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - ldr r6, =gBattleCommunication - ldrb r0, [r6, 0x5] - lsls r0, 1 - adds r1, r0 - ldr r4, =gActiveBank - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r4] - ldrh r1, [r1] - movs r0, 0 - bl dp01_build_cmdbuf_x11_TODO - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r0, [r5] - adds r0, 0x5 - str r0, [r5] - movs r0, 0x1 - strb r0, [r6, 0x7] -_0804870E: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atk14_printfromtable_playeronly - - thumb_func_start sub_8048728 -sub_8048728: @ 8048728 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - movs r1, 0 - ldr r0, =gNoOfAllBanks - ldrb r3, [r0] - cmp r1, r3 - bge _0804874E - ldr r4, =gTurnOrder - ldrb r0, [r4] - cmp r0, r2 - beq _0804874E -_08048740: - adds r1, 0x1 - cmp r1, r3 - bge _0804874E - adds r0, r1, r4 - ldrb r0, [r0] - cmp r0, r2 - bne _08048740 -_0804874E: - lsls r0, r1, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8048728 thumb_func_start SetMoveEffect SetMoveEffect: @ 8048760 @@ -2078,7 +1086,7 @@ _080490F0: .pool _08049114: adds r0, r2, 0 - bl sub_8048728 + bl BankGetTurnOrder ldr r1, =gUnknown_02024082 lsls r0, 24 lsrs r0, 24 @@ -2348,7 +1356,7 @@ _08049362: .pool _08049390: ldr r1, =gBattleMoveDamage - ldr r0, =gUnknown_020241F4 + ldr r0, =gHpDealt ldr r0, [r0] cmp r0, 0 bge _0804939C @@ -2831,7 +1839,7 @@ _08049808: .pool _08049820: ldr r4, =gBattleMoveDamage - ldr r0, =gUnknown_020241F4 + ldr r0, =gHpDealt ldr r0, [r0] movs r1, 0x3 bl __divsi3 @@ -6325,7 +5333,7 @@ atk39_pause: @ 804B5A0 ldrb r0, [r2, 0x2] lsls r0, 8 orrs r1, r0 - ldr r3, =gUnknown_0202432C + ldr r3, =gPauseCounterBattle ldrh r0, [r3] adds r0, 0x1 strh r0, [r3] @@ -10938,7 +9946,7 @@ atk54_effectiveness_sound: @ 804DDD8 lsls r0, 8 orrs r1, r0 movs r0, 0 - bl dp01_build_cmdbuf_x2B_aa_0 + bl EmitEffectivenessSound ldrb r0, [r5] bl MarkBufferBankForExecution ldr r0, [r4] @@ -15935,7 +14943,7 @@ _080509D0: atk88_negativedamage: @ 80509E8 push {lr} ldr r2, =gBattleMoveDamage - ldr r0, =gUnknown_020241F4 + ldr r0, =gHpDealt ldr r0, [r0] lsrs r1, r0, 31 adds r0, r1 diff --git a/asm/rom3.s b/asm/rom3.s index d039db7f2..f6b6f2d03 100644 --- a/asm/rom3.s +++ b/asm/rom3.s @@ -2687,8 +2687,8 @@ _08033C88: .pool thumb_func_end dp01_build_cmdbuf_x10_TODO - thumb_func_start dp01_build_cmdbuf_x11_TODO -dp01_build_cmdbuf_x11_TODO: @ 8033CFC + thumb_func_start EmitPrintStringPlayerOnly +EmitPrintStringPlayerOnly: @ 8033CFC push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -2784,7 +2784,7 @@ _08033D7C: pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x11_TODO + thumb_func_end EmitPrintStringPlayerOnly thumb_func_start dp01_build_cmdbuf_x12_a_bb dp01_build_cmdbuf_x12_a_bb: @ 8033DE4 @@ -3467,8 +3467,8 @@ dp01_build_cmdbuf_x2A_2A_2A_2A: @ 80342B4 .pool thumb_func_end dp01_build_cmdbuf_x2A_2A_2A_2A - thumb_func_start dp01_build_cmdbuf_x2B_aa_0 -dp01_build_cmdbuf_x2B_aa_0: @ 80342D4 + thumb_func_start EmitEffectivenessSound +EmitEffectivenessSound: @ 80342D4 push {r4,lr} lsls r0, 24 lsrs r0, 24 @@ -3489,7 +3489,7 @@ dp01_build_cmdbuf_x2B_aa_0: @ 80342D4 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x2B_aa_0 + thumb_func_end EmitEffectivenessSound thumb_func_start sub_8034300 sub_8034300: @ 8034300 diff --git a/data/battle_message.s b/data/battle_message.s index 93a921b5e..df6380640 100644 --- a/data/battle_message.s +++ b/data/battle_message.s @@ -596,7 +596,7 @@ gUnknown_085CC23E:: @ 85CC23E gUnknown_085CC270:: @ 85CC270 .incbin "baserom.gba", 0x5cc270, 0x5c4 -gUnknown_085CC834:: @ 85CC834 +gMissStringIds:: @ 85CC834 .incbin "baserom.gba", 0x5cc834, 0x14e gUnknown_085CC982:: @ 85CC982 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index aab0de4e3..23ef731d1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -246,10 +246,10 @@ BattleScript_MagicCoatBounce:: @ 82DB194 BattleScript_SnatchedMove:: @ 82DB1AC .incbin "baserom.gba", 0x2db1ac, 0x1b -gUnknown_082DB1C7:: @ 82DB1C7 +BattleScript_EnduredMsg:: @ 82DB1C7 .incbin "baserom.gba", 0x2db1c7, 0x7 -gUnknown_082DB1CE:: @ 82DB1CE +BattleScript_OneHitKOMsg:: @ 82DB1CE .incbin "baserom.gba", 0x2db1ce, 0x7 gUnknown_082DB1D5:: @ 82DB1D5 @@ -450,7 +450,7 @@ gUnknown_082DB6D9:: @ 82DB6D9 gUnknown_082DB6F0:: @ 82DB6F0 .incbin "baserom.gba", 0x2db6f0, 0xb -gUnknown_082DB6FB:: @ 82DB6FB +BattleScript_SubstituteFade:: @ 82DB6FB .incbin "baserom.gba", 0x2db6fb, 0xb BattleScript_BerryCurePrlzEnd2:: @ 82DB706 @@ -516,7 +516,7 @@ BattleScript_ItemHealHP_Ret:: @ 82DB7F7 gUnknown_082DB812:: @ 82DB812 .incbin "baserom.gba", 0x2db812, 0x4 -gUnknown_082DB816:: @ 82DB816 +BattleScript_HangedOnMsg:: @ 82DB816 .incbin "baserom.gba", 0x2db816, 0xe BattleScript_BerryConfuseHealEnd2:: @ 82DB824 diff --git a/include/battle.h b/include/battle.h index f9615b889..6550a66d3 100644 --- a/include/battle.h +++ b/include/battle.h @@ -729,6 +729,7 @@ u8 IsPokeDisobedient(void); void AI_CalcDmg(u8 bankAtk, u8 bankDef); u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef); u8 AI_TypeCalc(u16 move, u16 species, u8 ability); +u8 BankGetTurnOrder(u8 bank); // rom_80A5C6C u8 GetBankSide(u8 bank); diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 5723cf9da..b23649192 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -5,6 +5,8 @@ void EmitSetAttributes(u8 bufferId, u8 request, u8 c, u8 bytes, void *data); void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct* disableStructPtr, u8 multihit); void EmitHealthBarUpdate(u8 bufferId, u16 hpValue); +void EmitEffectivenessSound(u8 bufferId, u16 songId); +void EmitPrintStringPlayerOnly(u8 bufferId, u16 stringId); void MarkBufferBankForExecution(u8 bank); diff --git a/include/songs.h b/include/songs.h index afd26d683..028c163d6 100644 --- a/include/songs.h +++ b/include/songs.h @@ -15,8 +15,8 @@ enum /*0x09*/ SE_KAIDAN, /*0x0A*/ SE_DANSA, /*0x0B*/ SE_JITENSYA, - /*0x0C*/ SE_KOUKA_L, - /*0x0D*/ SE_KOUKA_M, + /*0x0C*/ SE_KOUKA_L, // Goggle told me Kouka means 'effectiveness' which makes sense, because + /*0x0D*/ SE_KOUKA_M, // those three sounds play whenever you use a move /*0x0E*/ SE_KOUKA_H, /*0x0F*/ SE_BOWA2, /*0x10*/ SE_POKE_DEAD, diff --git a/src/battle_4.c b/src/battle_4.c index be7f712c6..5d867289b 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -14,6 +14,7 @@ #include "rng.h" #include "battle_controllers.h" #include "species.h" +#include "songs.h" // variables @@ -58,7 +59,7 @@ extern u8 gStringBank; extern u16 gDynamicBasePower; extern u16 gLastUsedItem; extern u16 gBattleMovePower; -extern s32 gHP_dealt; +extern s32 gHpDealt; extern s32 gTakenDmg[BATTLE_BANKS_COUNT]; extern u8 gTakenDmgBanks[BATTLE_BANKS_COUNT]; extern u8 gSentPokesToOpponent[2]; @@ -75,7 +76,7 @@ extern u8 gCurrentMoveTurn; extern u8 gBattleBufferB[4][0x200]; extern const struct BattleMove gBattleMoves[]; -extern const u16 gMissStrings[]; +extern const u16 gMissStringIds[]; extern const u8 gTrainerMoney[]; extern const u8 gTypeEffectiveness[]; extern const struct BaseStats gBaseStats[]; @@ -1630,31 +1631,395 @@ void atk0A_waitanimation(void) void atk0B_healthbarupdate(void) { - register s16 healthValue asm("r1"); + if (gBattleExecBuffer) + return; + + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + { + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + + if (gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE && gDisableStructs[gActiveBank].substituteHP && !(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE)) + { + PrepareStringBattle(0x80, gActiveBank); + } + else + { + s16 healthValue; + + s32 currDmg = gBattleMoveDamage; + s32 maxPossibleDmgValue = 10000; // not present in R/S, ensures that huge damage values don't change sign + + if (currDmg <= maxPossibleDmgValue) + healthValue = currDmg; + else + healthValue = maxPossibleDmgValue; + + EmitHealthBarUpdate(0, healthValue); + MarkBufferBankForExecution(gActiveBank); + + if (GetBankSide(gActiveBank) == SIDE_PLAYER && gBattleMoveDamage > 0) + gBattleResults.unk5_0 = 1; + } + } + + gBattlescriptCurrInstr += 2; +} + +void atk0C_datahpupdate(void) +{ + u32 moveType; if (gBattleExecBuffer) return; - if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) - goto END; - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + if (gBattleStruct->dynamicMoveType == 0) + moveType = gBattleMoves[gCurrentMove].type; + else if (!(gBattleStruct->dynamicMoveType & 0x40)) + moveType = gBattleStruct->dynamicMoveType & 0x3F; + else + moveType = gBattleMoves[gCurrentMove].type; - if (gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE && gDisableStructs[gActiveBank].substituteHP && !(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE)) + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) { - PrepareStringBattle(0x80, gActiveBank); - goto END; + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + if (gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE && gDisableStructs[gActiveBank].substituteHP && !(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE)) + { + if (gDisableStructs[gActiveBank].substituteHP >= gBattleMoveDamage) + { + if (gSpecialStatuses[gActiveBank].moveturnLostHP == 0) + gSpecialStatuses[gActiveBank].moveturnLostHP = gBattleMoveDamage; + gDisableStructs[gActiveBank].substituteHP -= gBattleMoveDamage; + gHpDealt = gBattleMoveDamage; + } + else + { + if (gSpecialStatuses[gActiveBank].moveturnLostHP == 0) + gSpecialStatuses[gActiveBank].moveturnLostHP = gDisableStructs[gActiveBank].substituteHP; + gHpDealt = gDisableStructs[gActiveBank].substituteHP; + gDisableStructs[gActiveBank].substituteHP = 0; + } + // check substitute fading + if (gDisableStructs[gActiveBank].substituteHP == 0) + { + gBattlescriptCurrInstr += 2; + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = BattleScript_SubstituteFade; + return; + } + } + else + { + gHitMarker &= ~(HITMARKER_IGNORE_SUBSTITUTE); + if (gBattleMoveDamage < 0) // hp goes up + { + gBattleMons[gActiveBank].hp -= gBattleMoveDamage; + if (gBattleMons[gActiveBank].hp > gBattleMons[gActiveBank].maxHP) + gBattleMons[gActiveBank].hp = gBattleMons[gActiveBank].maxHP; + + } + else // hp goes down + { + if (gHitMarker & HITMARKER_x20) + { + gHitMarker &= ~(HITMARKER_x20); + } + else + { + gTakenDmg[gActiveBank] += gBattleMoveDamage; + if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_TARGET) + gTakenDmgBanks[gActiveBank] = gBankAttacker; + else + gTakenDmgBanks[gActiveBank] = gBankTarget; + } + + if (gBattleMons[gActiveBank].hp > gBattleMoveDamage) + { + gBattleMons[gActiveBank].hp -= gBattleMoveDamage; + gHpDealt = gBattleMoveDamage; + } + else + { + gHpDealt = gBattleMons[gActiveBank].hp; + gBattleMons[gActiveBank].hp = 0; + } + + if (!gSpecialStatuses[gActiveBank].moveturnLostHP && !(gHitMarker & HITMARKER_x100000)) + gSpecialStatuses[gActiveBank].moveturnLostHP = gHpDealt; + + if (moveType <= 8 && !(gHitMarker & HITMARKER_x100000) && gCurrentMove != MOVE_PAIN_SPLIT) + { + gProtectStructs[gActiveBank].physicalDmg = gHpDealt; + gSpecialStatuses[gActiveBank].moveturnLostHP_physical = gHpDealt; + if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_TARGET) + { + gProtectStructs[gActiveBank].physicalBank = gBankAttacker; + gSpecialStatuses[gActiveBank].moveturnPhysicalBank = gBankAttacker; + } + else + { + gProtectStructs[gActiveBank].physicalBank = gBankTarget; + gSpecialStatuses[gActiveBank].moveturnPhysicalBank = gBankTarget; + } + } + else if (moveType > 8 && !(gHitMarker & HITMARKER_x100000)) + { + gProtectStructs[gActiveBank].specialDmg = gHpDealt; + gSpecialStatuses[gActiveBank].moveturnLostHP_special = gHpDealt; + if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_TARGET) + { + gProtectStructs[gActiveBank].specialBank = gBankAttacker; + gSpecialStatuses[gActiveBank].moveturnSpecialBank = gBankAttacker; + } + else + { + gProtectStructs[gActiveBank].specialBank = gBankTarget; + gSpecialStatuses[gActiveBank].moveturnSpecialBank = gBankTarget; + } + } + } + gHitMarker &= ~(HITMARKER_x100000); + EmitSetAttributes(0, REQUEST_HP_BATTLE, 0, 2, &gBattleMons[gActiveBank].hp); + MarkBufferBankForExecution(gActiveBank); + } + } + else + { + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + if (gSpecialStatuses[gActiveBank].moveturnLostHP == 0) + gSpecialStatuses[gActiveBank].moveturnLostHP = 0xFFFF; + } + gBattlescriptCurrInstr += 2; +} + +void atk0D_critmessage(void) +{ + if (gBattleExecBuffer == 0) + { + if (gCritMultiplier == 2 && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + { + PrepareStringBattle(0xD9, gBankAttacker); + gBattleCommunication[MSG_DISPLAY] = 1; + } + gBattlescriptCurrInstr++; + } +} + +void atk0E_effectiveness_sound(void) +{ + if (gBattleExecBuffer) + return; + + gActiveBank = gBankTarget; + if (!(gBattleMoveFlags & MOVESTATUS_MISSED)) + { + switch (gBattleMoveFlags & (u8)(~(MOVESTATUS_MISSED))) + { + case MOVESTATUS_SUPEREFFECTIVE: + EmitEffectivenessSound(0, SE_KOUKA_H); + MarkBufferBankForExecution(gActiveBank); + break; + case MOVESTATUS_NOTVERYEFFECTIVE: + EmitEffectivenessSound(0, SE_KOUKA_L); + MarkBufferBankForExecution(gActiveBank); + break; + case MOVESTATUS_NOTAFFECTED: + case MOVESTATUS_FAILED: + // no sound + break; + case MOVESTATUS_ENDURED: + case MOVESTATUS_ONEHITKO: + case MOVESTATUS_HUNGON: + default: + if (gBattleMoveFlags & MOVESTATUS_SUPEREFFECTIVE) + { + EmitEffectivenessSound(0, SE_KOUKA_H); + MarkBufferBankForExecution(gActiveBank); + } + else if (gBattleMoveFlags & MOVESTATUS_NOTVERYEFFECTIVE) + { + EmitEffectivenessSound(0, SE_KOUKA_L); + MarkBufferBankForExecution(gActiveBank); + } + else if (!(gBattleMoveFlags & (MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED))) + { + EmitEffectivenessSound(0, SE_KOUKA_M); + MarkBufferBankForExecution(gActiveBank); + } + break; + } + } + gBattlescriptCurrInstr++; +} + +void atk0F_resultmessage(void) +{ + u32 stringId = 0; + + if (gBattleExecBuffer) + return; + + if (gBattleMoveFlags & MOVESTATUS_MISSED && (!(gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) || gBattleCommunication[6] > 2)) + { + stringId = gMissStringIds[gBattleCommunication[6]]; + gBattleCommunication[MSG_DISPLAY] = 1; + } + else + { + gBattleCommunication[MSG_DISPLAY] = 1; + switch (gBattleMoveFlags & (u8)(~(MOVESTATUS_MISSED))) + { + case MOVESTATUS_SUPEREFFECTIVE: + stringId = 0xDE; + break; + case MOVESTATUS_NOTVERYEFFECTIVE: + stringId = 0xDD; + break; + case MOVESTATUS_ONEHITKO: + stringId = 0xDA; + break; + case MOVESTATUS_ENDURED: + stringId = 0x99; + break; + case MOVESTATUS_FAILED: + stringId = 0xE5; + break; + case MOVESTATUS_NOTAFFECTED: + stringId = 0x1B; + break; + case MOVESTATUS_HUNGON: + gLastUsedItem = gBattleMons[gBankTarget].item; + gStringBank = gBankTarget; + gBattleMoveFlags &= ~(MOVESTATUS_ENDURED | MOVESTATUS_HUNGON); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = BattleScript_HangedOnMsg; + return; + default: + if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) + { + stringId = 0x1B; + } + else if (gBattleMoveFlags & MOVESTATUS_ONEHITKO) + { + gBattleMoveFlags &= ~(MOVESTATUS_ONEHITKO); + gBattleMoveFlags &= ~(MOVESTATUS_SUPEREFFECTIVE); + gBattleMoveFlags &= ~(MOVESTATUS_NOTVERYEFFECTIVE); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = BattleScript_OneHitKOMsg; + return; + } + else if (gBattleMoveFlags & MOVESTATUS_ENDURED) + { + gBattleMoveFlags &= ~(MOVESTATUS_ENDURED | MOVESTATUS_HUNGON); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = BattleScript_EnduredMsg; + return; + } + else if (gBattleMoveFlags & MOVESTATUS_HUNGON) + { + gLastUsedItem = gBattleMons[gBankTarget].item; + gStringBank = gBankTarget; + gBattleMoveFlags &= ~(MOVESTATUS_ENDURED | MOVESTATUS_HUNGON); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = BattleScript_HangedOnMsg; + return; + } + else if (gBattleMoveFlags & MOVESTATUS_FAILED) + { + stringId = 0xE5; + } + else + { + gBattleCommunication[MSG_DISPLAY] = 0; + } + } } - healthValue = 10000; - if (healthValue <= gBattleMoveDamage) - healthValue = gBattleMoveDamage; + if (stringId) + PrepareStringBattle(stringId, gBankAttacker); - EmitHealthBarUpdate(0, healthValue); + gBattlescriptCurrInstr++; +} + +void atk10_printstring(void) +{ + if (gBattleExecBuffer == 0) + { + u16 var = BS2ScriptRead16(gBattlescriptCurrInstr + 1); + PrepareStringBattle(var, gBankAttacker); + gBattlescriptCurrInstr += 3; + gBattleCommunication[MSG_DISPLAY] = 1; + } +} + +void atk11_printstring_playeronly(void) +{ + gActiveBank = gBankAttacker; + + EmitPrintStringPlayerOnly(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1)); MarkBufferBankForExecution(gActiveBank); - if (GetBankSide(gActiveBank) == SIDE_PLAYER && gBattleMoveDamage > 0) - gBattleResults.unk5_0 = 1; - - END: - gBattlescriptCurrInstr += 2; + gBattlescriptCurrInstr += 3; + gBattleCommunication[MSG_DISPLAY] = 1; +} + +void atk12_waitmessage(void) +{ + if (gBattleExecBuffer == 0) + { + if (!gBattleCommunication[MSG_DISPLAY]) + { + gBattlescriptCurrInstr += 3; + } + else + { + u16 toWait = BS2ScriptRead16(gBattlescriptCurrInstr + 1); + if (++gPauseCounterBattle >= toWait) + { + gPauseCounterBattle = 0; + gBattlescriptCurrInstr += 3; + gBattleCommunication[MSG_DISPLAY] = 0; + } + } + } +} + +void atk13_printfromtable(void) +{ + if (gBattleExecBuffer == 0) + { + u16 *ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + ptr += gBattleCommunication[MULTISTRING_CHOOSER]; + + PrepareStringBattle(*(u16*)ptr, gBankAttacker); + + gBattlescriptCurrInstr += 5; + gBattleCommunication[MSG_DISPLAY] = 1; + } +} + +void atk14_printfromtable_playeronly(void) +{ + if (gBattleExecBuffer == 0) + { + u16 *ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + ptr += gBattleCommunication[MULTISTRING_CHOOSER]; + + gActiveBank = gBankAttacker; + EmitPrintStringPlayerOnly(0, *(u16*)ptr); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 5; + gBattleCommunication[MSG_DISPLAY] = 1; + } +} + +u8 BankGetTurnOrder(u8 bank) +{ + s32 i; + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gTurnOrder[i] == bank) + break; + } + return i; } diff --git a/sym_ewram.txt b/sym_ewram.txt index 8eb395b0f..fe6ccdcbd 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -343,7 +343,7 @@ gRandomMove: @ 20241EE gBattleMoveDamage: @ 20241F0 .space 0x4 -gUnknown_020241F4: @ 20241F4 +gHpDealt: @ 20241F4 .space 0x4 gTakenDmg: @ 20241F8 @@ -442,7 +442,7 @@ gStatuses3: @ 20242AC gDisableStructs: @ 20242BC .space 0x70 -gUnknown_0202432C: @ 202432C +gPauseCounterBattle: @ 202432C .space 0x2 gUnknown_0202432E: @ 202432E