mirror of
https://github.com/pret/pokeruby.git
synced 2024-12-11 14:54:06 +00:00
start decompiling battle_3 git sucks
This commit is contained in:
parent
bb0cad7c07
commit
5513395999
@ -262,7 +262,7 @@ _08012538:
|
||||
.4byte _08012968
|
||||
.4byte _0801292C
|
||||
_0801256C:
|
||||
bl sub_8015C90
|
||||
bl AreAllMovesUnusable
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _080125D0
|
||||
|
750
asm/battle_3.s
750
asm/battle_3.s
@ -6,747 +6,7 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start b_movescr_stack_push
|
||||
b_movescr_stack_push: @ 801582C
|
||||
push {r4,lr}
|
||||
ldr r4, _08015848 @ =0x02017110
|
||||
adds r3, r4, 0
|
||||
adds r3, 0x20
|
||||
ldrb r1, [r3]
|
||||
adds r2, r1, 0x1
|
||||
strb r2, [r3]
|
||||
lsls r1, 24
|
||||
lsrs r1, 22
|
||||
adds r1, r4
|
||||
str r0, [r1]
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_08015848: .4byte 0x02017110
|
||||
thumb_func_end b_movescr_stack_push
|
||||
|
||||
thumb_func_start b_movescr_stack_push_cursor
|
||||
b_movescr_stack_push_cursor: @ 801584C
|
||||
ldr r3, _08015868 @ =0x02017110
|
||||
adds r2, r3, 0
|
||||
adds r2, 0x20
|
||||
ldrb r0, [r2]
|
||||
adds r1, r0, 0x1
|
||||
strb r1, [r2]
|
||||
lsls r0, 24
|
||||
lsrs r0, 22
|
||||
adds r0, r3
|
||||
ldr r1, _0801586C @ =gBattlescriptCurrInstr
|
||||
ldr r1, [r1]
|
||||
str r1, [r0]
|
||||
bx lr
|
||||
.align 2, 0
|
||||
_08015868: .4byte 0x02017110
|
||||
_0801586C: .4byte gBattlescriptCurrInstr
|
||||
thumb_func_end b_movescr_stack_push_cursor
|
||||
|
||||
thumb_func_start b_movescr_stack_pop_cursor
|
||||
b_movescr_stack_pop_cursor: @ 8015870
|
||||
ldr r3, _0801588C @ =gBattlescriptCurrInstr
|
||||
ldr r2, _08015890 @ =0x02017110
|
||||
adds r1, r2, 0
|
||||
adds r1, 0x20
|
||||
ldrb r0, [r1]
|
||||
subs r0, 0x1
|
||||
strb r0, [r1]
|
||||
lsls r0, 24
|
||||
lsrs r0, 22
|
||||
adds r0, r2
|
||||
ldr r0, [r0]
|
||||
str r0, [r3]
|
||||
bx lr
|
||||
.align 2, 0
|
||||
_0801588C: .4byte gBattlescriptCurrInstr
|
||||
_08015890: .4byte 0x02017110
|
||||
thumb_func_end b_movescr_stack_pop_cursor
|
||||
|
||||
thumb_func_start sub_8015894
|
||||
sub_8015894: @ 8015894
|
||||
push {r4-r7,lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
movs r6, 0
|
||||
ldr r2, _080159AC @ =gBattleMons
|
||||
ldr r1, _080159B0 @ =gBattleBufferB
|
||||
ldr r5, _080159B4 @ =gActiveBank
|
||||
ldrb r3, [r5]
|
||||
lsls r0, r3, 9
|
||||
adds r1, 0x2
|
||||
adds r0, r1
|
||||
ldrb r0, [r0]
|
||||
lsls r0, 1
|
||||
movs r1, 0x58
|
||||
muls r1, r3
|
||||
adds r0, r1
|
||||
adds r2, 0xC
|
||||
adds r0, r2
|
||||
ldrh r4, [r0]
|
||||
lsls r0, r3, 1
|
||||
ldr r2, _080159B8 @ =0x020160e8
|
||||
adds r0, r2
|
||||
mov r8, r0
|
||||
ldr r1, _080159BC @ =gDisableStructs
|
||||
lsls r0, r3, 3
|
||||
subs r0, r3
|
||||
lsls r0, 2
|
||||
adds r0, r1
|
||||
ldrh r0, [r0, 0x4]
|
||||
cmp r0, r4
|
||||
bne _080158EE
|
||||
cmp r4, 0
|
||||
beq _080158EE
|
||||
adds r0, r2, 0
|
||||
subs r0, 0xE5
|
||||
strb r3, [r0]
|
||||
ldr r0, _080159C0 @ =gCurrentMove
|
||||
strh r4, [r0]
|
||||
ldr r1, _080159C4 @ =gUnknown_02024C1C
|
||||
ldrb r0, [r5]
|
||||
lsls r0, 2
|
||||
adds r0, r1
|
||||
ldr r1, _080159C8 @ =gUnknown_081D9144
|
||||
str r1, [r0]
|
||||
movs r6, 0x1
|
||||
_080158EE:
|
||||
ldr r1, _080159CC @ =gLastUsedMove
|
||||
ldr r5, _080159B4 @ =gActiveBank
|
||||
ldrb r2, [r5]
|
||||
lsls r0, r2, 1
|
||||
adds r0, r1
|
||||
ldrh r0, [r0]
|
||||
cmp r4, r0
|
||||
bne _0801592A
|
||||
cmp r4, 0xA5
|
||||
beq _0801592A
|
||||
ldr r1, _080159AC @ =gBattleMons
|
||||
movs r0, 0x58
|
||||
muls r0, r2
|
||||
adds r1, 0x50
|
||||
adds r0, r1
|
||||
ldr r0, [r0]
|
||||
cmp r0, 0
|
||||
bge _0801592A
|
||||
adds r0, r2, 0
|
||||
bl CancelMultiTurnMoves
|
||||
ldr r1, _080159C4 @ =gUnknown_02024C1C
|
||||
ldrb r0, [r5]
|
||||
lsls r0, 2
|
||||
adds r0, r1
|
||||
ldr r1, _080159D0 @ =gUnknown_081D937C
|
||||
str r1, [r0]
|
||||
adds r0, r6, 0x1
|
||||
lsls r0, 24
|
||||
lsrs r6, r0, 24
|
||||
_0801592A:
|
||||
ldr r2, _080159BC @ =gDisableStructs
|
||||
ldr r3, _080159B4 @ =gActiveBank
|
||||
ldrb r1, [r3]
|
||||
lsls r0, r1, 3
|
||||
subs r0, r1
|
||||
lsls r0, 2
|
||||
adds r0, r2
|
||||
ldrb r0, [r0, 0x13]
|
||||
lsls r0, 28
|
||||
cmp r0, 0
|
||||
beq _08015966
|
||||
ldr r0, _080159D4 @ =gBattleMoves
|
||||
lsls r1, r4, 1
|
||||
adds r1, r4
|
||||
lsls r1, 2
|
||||
adds r1, r0
|
||||
ldrb r0, [r1, 0x1]
|
||||
cmp r0, 0
|
||||
bne _08015966
|
||||
ldr r0, _080159C0 @ =gCurrentMove
|
||||
strh r4, [r0]
|
||||
ldr r1, _080159C4 @ =gUnknown_02024C1C
|
||||
ldrb r0, [r3]
|
||||
lsls r0, 2
|
||||
adds r0, r1
|
||||
ldr r1, _080159D8 @ =gUnknown_081D938B
|
||||
str r1, [r0]
|
||||
adds r0, r6, 0x1
|
||||
lsls r0, 24
|
||||
lsrs r6, r0, 24
|
||||
_08015966:
|
||||
ldr r5, _080159B4 @ =gActiveBank
|
||||
ldrb r0, [r5]
|
||||
adds r1, r4, 0
|
||||
bl sub_8015D5C
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _0801598C
|
||||
ldr r0, _080159C0 @ =gCurrentMove
|
||||
strh r4, [r0]
|
||||
ldr r1, _080159C4 @ =gUnknown_02024C1C
|
||||
ldrb r0, [r5]
|
||||
lsls r0, 2
|
||||
adds r0, r1
|
||||
ldr r1, _080159DC @ =gUnknown_081D9464
|
||||
str r1, [r0]
|
||||
adds r0, r6, 0x1
|
||||
lsls r0, 24
|
||||
lsrs r6, r0, 24
|
||||
_0801598C:
|
||||
ldr r1, _080159AC @ =gBattleMons
|
||||
ldrb r2, [r5]
|
||||
movs r0, 0x58
|
||||
muls r0, r2
|
||||
adds r1, r0, r1
|
||||
ldrh r0, [r1, 0x2E]
|
||||
cmp r0, 0xAF
|
||||
bne _080159E4
|
||||
ldr r1, _080159E0 @ =gEnigmaBerries
|
||||
lsls r0, r2, 3
|
||||
subs r0, r2
|
||||
lsls r0, 2
|
||||
adds r0, r1
|
||||
ldrb r3, [r0, 0x7]
|
||||
b _080159EE
|
||||
.align 2, 0
|
||||
_080159AC: .4byte gBattleMons
|
||||
_080159B0: .4byte gBattleBufferB
|
||||
_080159B4: .4byte gActiveBank
|
||||
_080159B8: .4byte 0x020160e8
|
||||
_080159BC: .4byte gDisableStructs
|
||||
_080159C0: .4byte gCurrentMove
|
||||
_080159C4: .4byte gUnknown_02024C1C
|
||||
_080159C8: .4byte gUnknown_081D9144
|
||||
_080159CC: .4byte gLastUsedMove
|
||||
_080159D0: .4byte gUnknown_081D937C
|
||||
_080159D4: .4byte gBattleMoves
|
||||
_080159D8: .4byte gUnknown_081D938B
|
||||
_080159DC: .4byte gUnknown_081D9464
|
||||
_080159E0: .4byte gEnigmaBerries
|
||||
_080159E4:
|
||||
ldrh r0, [r1, 0x2E]
|
||||
bl ItemId_GetHoldEffect
|
||||
lsls r0, 24
|
||||
lsrs r3, r0, 24
|
||||
_080159EE:
|
||||
ldr r2, _08015A70 @ =gStringBank
|
||||
ldr r1, _08015A74 @ =gActiveBank
|
||||
ldrb r0, [r1]
|
||||
strb r0, [r2]
|
||||
ldr r7, _08015A78 @ =gBattleMons
|
||||
adds r5, r1, 0
|
||||
cmp r3, 0x1D
|
||||
bne _08015A36
|
||||
mov r0, r8
|
||||
ldrh r2, [r0]
|
||||
adds r1, r2, 0
|
||||
cmp r1, 0
|
||||
beq _08015A36
|
||||
ldr r0, _08015A7C @ =0x0000ffff
|
||||
cmp r1, r0
|
||||
beq _08015A36
|
||||
cmp r1, r4
|
||||
beq _08015A36
|
||||
ldr r0, _08015A80 @ =gCurrentMove
|
||||
strh r2, [r0]
|
||||
ldr r2, _08015A84 @ =gLastUsedItem
|
||||
ldrb r1, [r5]
|
||||
movs r0, 0x58
|
||||
muls r0, r1
|
||||
adds r0, r7
|
||||
ldrh r0, [r0, 0x2E]
|
||||
strh r0, [r2]
|
||||
ldr r1, _08015A88 @ =gUnknown_02024C1C
|
||||
ldrb r0, [r5]
|
||||
lsls r0, 2
|
||||
adds r0, r1
|
||||
ldr r1, _08015A8C @ =gUnknown_081D9AC2
|
||||
str r1, [r0]
|
||||
adds r0, r6, 0x1
|
||||
lsls r0, 24
|
||||
lsrs r6, r0, 24
|
||||
_08015A36:
|
||||
ldr r0, _08015A90 @ =gBattleBufferB
|
||||
ldrb r2, [r5]
|
||||
lsls r1, r2, 9
|
||||
adds r0, 0x2
|
||||
adds r1, r0
|
||||
movs r0, 0x58
|
||||
muls r0, r2
|
||||
ldrb r1, [r1]
|
||||
adds r0, r1
|
||||
adds r1, r7, 0
|
||||
adds r1, 0x24
|
||||
adds r0, r1
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0
|
||||
bne _08015A64
|
||||
ldr r1, _08015A88 @ =gUnknown_02024C1C
|
||||
lsls r0, r2, 2
|
||||
adds r0, r1
|
||||
ldr r1, _08015A94 @ =gUnknown_081D9369
|
||||
str r1, [r0]
|
||||
adds r0, r6, 0x1
|
||||
lsls r0, 24
|
||||
lsrs r6, r0, 24
|
||||
_08015A64:
|
||||
adds r0, r6, 0
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.align 2, 0
|
||||
_08015A70: .4byte gStringBank
|
||||
_08015A74: .4byte gActiveBank
|
||||
_08015A78: .4byte gBattleMons
|
||||
_08015A7C: .4byte 0x0000ffff
|
||||
_08015A80: .4byte gCurrentMove
|
||||
_08015A84: .4byte gLastUsedItem
|
||||
_08015A88: .4byte gUnknown_02024C1C
|
||||
_08015A8C: .4byte gUnknown_081D9AC2
|
||||
_08015A90: .4byte gBattleBufferB
|
||||
_08015A94: .4byte gUnknown_081D9369
|
||||
thumb_func_end sub_8015894
|
||||
|
||||
thumb_func_start sub_8015A98
|
||||
sub_8015A98: @ 8015A98
|
||||
push {r4-r7,lr}
|
||||
mov r7, r10
|
||||
mov r6, r9
|
||||
mov r5, r8
|
||||
push {r5-r7}
|
||||
sub sp, 0x1C
|
||||
lsls r0, 24
|
||||
lsrs r7, r0, 24
|
||||
lsls r1, 24
|
||||
lsrs r4, r1, 24
|
||||
lsls r2, 24
|
||||
lsrs r3, r2, 24
|
||||
lsls r1, r7, 1
|
||||
ldr r0, _08015AD8 @ =0x020160e8
|
||||
adds r1, r0
|
||||
str r1, [sp, 0x4]
|
||||
ldr r1, _08015ADC @ =gBattleMons
|
||||
movs r0, 0x58
|
||||
muls r0, r7
|
||||
adds r1, r0, r1
|
||||
ldrh r0, [r1, 0x2E]
|
||||
cmp r0, 0xAF
|
||||
bne _08015AE4
|
||||
ldr r2, _08015AE0 @ =gEnigmaBerries
|
||||
lsls r1, r7, 3
|
||||
subs r0, r1, r7
|
||||
lsls r0, 2
|
||||
adds r0, r2
|
||||
ldrb r0, [r0, 0x7]
|
||||
str r0, [sp]
|
||||
b _08015AF6
|
||||
.align 2, 0
|
||||
_08015AD8: .4byte 0x020160e8
|
||||
_08015ADC: .4byte gBattleMons
|
||||
_08015AE0: .4byte gEnigmaBerries
|
||||
_08015AE4:
|
||||
ldrh r0, [r1, 0x2E]
|
||||
str r3, [sp, 0x14]
|
||||
bl ItemId_GetHoldEffect
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
str r0, [sp]
|
||||
lsls r1, r7, 3
|
||||
ldr r3, [sp, 0x14]
|
||||
_08015AF6:
|
||||
ldr r0, _08015C70 @ =gStringBank
|
||||
strb r7, [r0]
|
||||
movs r0, 0
|
||||
mov r9, r0
|
||||
lsls r2, r7, 1
|
||||
str r2, [sp, 0xC]
|
||||
ldr r5, _08015C74 @ =gDisableStructs
|
||||
mov r12, r5
|
||||
ldr r0, _08015C78 @ =gBattleMons
|
||||
movs r2, 0x58
|
||||
adds r6, r7, 0
|
||||
muls r6, r2
|
||||
str r6, [sp, 0x8]
|
||||
ldr r2, _08015C7C @ =gUnknown_02024A8C
|
||||
adds r5, r6, r2
|
||||
movs r6, 0
|
||||
str r6, [sp, 0x10]
|
||||
mov r10, r0
|
||||
subs r0, r1, r7
|
||||
lsls r0, 2
|
||||
mov r8, r0
|
||||
ldr r6, _08015C80 @ =gBitTable
|
||||
_08015B22:
|
||||
ldrh r0, [r5]
|
||||
cmp r0, 0
|
||||
bne _08015B38
|
||||
movs r0, 0x1
|
||||
ands r0, r3
|
||||
cmp r0, 0
|
||||
beq _08015B38
|
||||
ldr r0, [r6]
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 24
|
||||
lsrs r4, r0, 24
|
||||
_08015B38:
|
||||
ldr r0, [sp, 0x8]
|
||||
add r0, r9
|
||||
mov r1, r10
|
||||
adds r1, 0x24
|
||||
adds r0, r1
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0
|
||||
bne _08015B58
|
||||
movs r0, 0x2
|
||||
ands r0, r3
|
||||
cmp r0, 0
|
||||
beq _08015B58
|
||||
ldr r0, [r6]
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 24
|
||||
lsrs r4, r0, 24
|
||||
_08015B58:
|
||||
mov r1, r8
|
||||
add r1, r12
|
||||
ldrh r0, [r5]
|
||||
ldrh r1, [r1, 0x4]
|
||||
cmp r0, r1
|
||||
bne _08015B74
|
||||
movs r0, 0x4
|
||||
ands r0, r3
|
||||
cmp r0, 0
|
||||
beq _08015B74
|
||||
ldr r0, [r6]
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 24
|
||||
lsrs r4, r0, 24
|
||||
_08015B74:
|
||||
movs r0, 0x58
|
||||
adds r2, r7, 0
|
||||
muls r2, r0
|
||||
ldr r1, [sp, 0x10]
|
||||
adds r0, r1, r2
|
||||
ldr r1, _08015C7C @ =gUnknown_02024A8C
|
||||
adds r0, r1
|
||||
mov r12, r0
|
||||
ldr r1, _08015C84 @ =gLastUsedMove
|
||||
ldr r0, [sp, 0xC]
|
||||
adds r1, r0, r1
|
||||
str r1, [sp, 0x18]
|
||||
mov r1, r12
|
||||
ldrh r1, [r1]
|
||||
mov r12, r1
|
||||
ldr r0, [sp, 0x18]
|
||||
ldrh r0, [r0]
|
||||
cmp r12, r0
|
||||
bne _08015BB6
|
||||
movs r0, 0x8
|
||||
ands r0, r3
|
||||
cmp r0, 0
|
||||
beq _08015BB6
|
||||
mov r0, r10
|
||||
adds r0, 0x50
|
||||
adds r0, r2, r0
|
||||
ldr r0, [r0]
|
||||
cmp r0, 0
|
||||
bge _08015BB6
|
||||
ldr r0, [r6]
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 24
|
||||
lsrs r4, r0, 24
|
||||
_08015BB6:
|
||||
ldr r0, _08015C74 @ =gDisableStructs
|
||||
add r0, r8
|
||||
ldrb r0, [r0, 0x13]
|
||||
lsls r0, 28
|
||||
cmp r0, 0
|
||||
beq _08015BE4
|
||||
movs r0, 0x10
|
||||
ands r0, r3
|
||||
cmp r0, 0
|
||||
beq _08015BE4
|
||||
ldr r2, _08015C88 @ =gBattleMoves
|
||||
ldrh r1, [r5]
|
||||
lsls r0, r1, 1
|
||||
adds r0, r1
|
||||
lsls r0, 2
|
||||
adds r0, r2
|
||||
ldrb r0, [r0, 0x1]
|
||||
cmp r0, 0
|
||||
bne _08015BE4
|
||||
ldr r0, [r6]
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 24
|
||||
lsrs r4, r0, 24
|
||||
_08015BE4:
|
||||
ldrh r1, [r5]
|
||||
adds r0, r7, 0
|
||||
str r3, [sp, 0x14]
|
||||
bl sub_8015D5C
|
||||
lsls r0, 24
|
||||
ldr r3, [sp, 0x14]
|
||||
cmp r0, 0
|
||||
beq _08015C06
|
||||
movs r0, 0x20
|
||||
ands r0, r3
|
||||
cmp r0, 0
|
||||
beq _08015C06
|
||||
ldr r0, [r6]
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 24
|
||||
lsrs r4, r0, 24
|
||||
_08015C06:
|
||||
ldr r1, _08015C74 @ =gDisableStructs
|
||||
mov r0, r8
|
||||
adds r2, r0, r1
|
||||
ldrb r0, [r2, 0xE]
|
||||
lsls r0, 28
|
||||
mov r12, r1
|
||||
cmp r0, 0
|
||||
beq _08015C26
|
||||
ldrh r0, [r2, 0x6]
|
||||
ldrh r1, [r5]
|
||||
cmp r0, r1
|
||||
beq _08015C26
|
||||
ldr r0, [r6]
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 24
|
||||
lsrs r4, r0, 24
|
||||
_08015C26:
|
||||
ldr r2, [sp]
|
||||
cmp r2, 0x1D
|
||||
bne _08015C48
|
||||
ldr r0, [sp, 0x4]
|
||||
ldrh r1, [r0]
|
||||
cmp r1, 0
|
||||
beq _08015C48
|
||||
ldr r0, _08015C8C @ =0x0000ffff
|
||||
cmp r1, r0
|
||||
beq _08015C48
|
||||
ldrh r2, [r5]
|
||||
cmp r1, r2
|
||||
beq _08015C48
|
||||
ldr r0, [r6]
|
||||
orrs r4, r0
|
||||
lsls r0, r4, 24
|
||||
lsrs r4, r0, 24
|
||||
_08015C48:
|
||||
adds r6, 0x4
|
||||
adds r5, 0x2
|
||||
ldr r0, [sp, 0x10]
|
||||
adds r0, 0x2
|
||||
str r0, [sp, 0x10]
|
||||
movs r1, 0x1
|
||||
add r9, r1
|
||||
mov r2, r9
|
||||
cmp r2, 0x3
|
||||
bgt _08015C5E
|
||||
b _08015B22
|
||||
_08015C5E:
|
||||
adds r0, r4, 0
|
||||
add sp, 0x1C
|
||||
pop {r3-r5}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
mov r10, r5
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.align 2, 0
|
||||
_08015C70: .4byte gStringBank
|
||||
_08015C74: .4byte gDisableStructs
|
||||
_08015C78: .4byte gBattleMons
|
||||
_08015C7C: .4byte gUnknown_02024A8C
|
||||
_08015C80: .4byte gBitTable
|
||||
_08015C84: .4byte gLastUsedMove
|
||||
_08015C88: .4byte gBattleMoves
|
||||
_08015C8C: .4byte 0x0000ffff
|
||||
thumb_func_end sub_8015A98
|
||||
|
||||
thumb_func_start sub_8015C90
|
||||
sub_8015C90: @ 8015C90
|
||||
push {r4-r6,lr}
|
||||
ldr r5, _08015CFC @ =gActiveBank
|
||||
ldrb r0, [r5]
|
||||
movs r1, 0
|
||||
movs r2, 0xFF
|
||||
bl sub_8015A98
|
||||
lsls r0, 24
|
||||
lsrs r6, r0, 24
|
||||
cmp r6, 0xF
|
||||
bne _08015D38
|
||||
ldr r0, _08015D00 @ =gProtectStructs
|
||||
ldrb r1, [r5]
|
||||
lsls r1, 4
|
||||
adds r1, r0
|
||||
ldrb r0, [r1]
|
||||
movs r2, 0x4
|
||||
orrs r0, r2
|
||||
strb r0, [r1]
|
||||
ldr r1, _08015D04 @ =gUnknown_02024C1C
|
||||
ldrb r0, [r5]
|
||||
lsls r0, 2
|
||||
adds r0, r1
|
||||
ldr r1, _08015D08 @ =gUnknown_081D9365
|
||||
str r1, [r0]
|
||||
ldr r0, _08015D0C @ =gBattleTypeFlags
|
||||
ldrh r1, [r0]
|
||||
movs r0, 0x1
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _08015D14
|
||||
ldrb r0, [r5]
|
||||
bl GetBankIdentity
|
||||
adds r4, r0, 0
|
||||
bl Random
|
||||
movs r1, 0x1
|
||||
eors r4, r1
|
||||
movs r1, 0x2
|
||||
ands r1, r0
|
||||
orrs r4, r1
|
||||
lsls r4, 24
|
||||
lsrs r4, 24
|
||||
adds r0, r4, 0
|
||||
bl GetBankByPlayerAI
|
||||
ldr r2, _08015D10 @ =gBattleBufferB
|
||||
ldrb r1, [r5]
|
||||
lsls r1, 9
|
||||
adds r2, 0x3
|
||||
adds r1, r2
|
||||
b _08015D48
|
||||
.align 2, 0
|
||||
_08015CFC: .4byte gActiveBank
|
||||
_08015D00: .4byte gProtectStructs
|
||||
_08015D04: .4byte gUnknown_02024C1C
|
||||
_08015D08: .4byte gUnknown_081D9365
|
||||
_08015D0C: .4byte gBattleTypeFlags
|
||||
_08015D10: .4byte gBattleBufferB
|
||||
_08015D14:
|
||||
ldrb r0, [r5]
|
||||
bl GetBankIdentity
|
||||
movs r1, 0x1
|
||||
eors r0, r1
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
bl GetBankByPlayerAI
|
||||
ldr r2, _08015D34 @ =gBattleBufferB
|
||||
ldrb r1, [r5]
|
||||
lsls r1, 9
|
||||
adds r2, 0x3
|
||||
adds r1, r2
|
||||
b _08015D48
|
||||
.align 2, 0
|
||||
_08015D34: .4byte gBattleBufferB
|
||||
_08015D38:
|
||||
ldr r0, _08015D58 @ =gProtectStructs
|
||||
ldrb r1, [r5]
|
||||
lsls r1, 4
|
||||
adds r1, r0
|
||||
ldrb r2, [r1]
|
||||
movs r0, 0x5
|
||||
negs r0, r0
|
||||
ands r0, r2
|
||||
_08015D48:
|
||||
strb r0, [r1]
|
||||
movs r0, 0
|
||||
cmp r6, 0xF
|
||||
bne _08015D52
|
||||
movs r0, 0x1
|
||||
_08015D52:
|
||||
pop {r4-r6}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.align 2, 0
|
||||
_08015D58: .4byte gProtectStructs
|
||||
thumb_func_end sub_8015C90
|
||||
|
||||
thumb_func_start sub_8015D5C
|
||||
sub_8015D5C: @ 8015D5C
|
||||
push {r4-r7,lr}
|
||||
mov r7, r9
|
||||
mov r6, r8
|
||||
push {r6,r7}
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
lsls r1, 16
|
||||
lsrs r5, r1, 16
|
||||
movs r6, 0
|
||||
bl GetBankSide
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
mov r9, r0
|
||||
movs r4, 0
|
||||
ldr r0, _08015DF0 @ =gNoOfAllBanks
|
||||
ldrb r0, [r0]
|
||||
cmp r6, r0
|
||||
bge _08015DE0
|
||||
ldr r7, _08015DF4 @ =gUnknown_02024A8C
|
||||
mov r8, r7
|
||||
_08015D86:
|
||||
lsls r0, r4, 24
|
||||
lsrs r0, 24
|
||||
bl GetBankSide
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
adds r3, r4, 0x1
|
||||
cmp r9, r0
|
||||
beq _08015DD6
|
||||
ldr r1, _08015DF8 @ =gStatuses3
|
||||
lsls r0, r4, 2
|
||||
adds r0, r1
|
||||
ldr r0, [r0]
|
||||
movs r1, 0x80
|
||||
lsls r1, 6
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _08015DD6
|
||||
movs r2, 0
|
||||
movs r0, 0x58
|
||||
adds r1, r4, 0
|
||||
muls r1, r0
|
||||
adds r0, r1, r7
|
||||
ldrh r0, [r0]
|
||||
cmp r5, r0
|
||||
beq _08015DCC
|
||||
mov r4, r8
|
||||
adds r0, r1, r4
|
||||
_08015DBE:
|
||||
adds r0, 0x2
|
||||
adds r2, 0x1
|
||||
cmp r2, 0x3
|
||||
bgt _08015DD6
|
||||
ldrh r1, [r0]
|
||||
cmp r5, r1
|
||||
bne _08015DBE
|
||||
_08015DCC:
|
||||
cmp r2, 0x3
|
||||
bgt _08015DD6
|
||||
adds r0, r6, 0x1
|
||||
lsls r0, 24
|
||||
lsrs r6, r0, 24
|
||||
_08015DD6:
|
||||
adds r4, r3, 0
|
||||
ldr r0, _08015DF0 @ =gNoOfAllBanks
|
||||
ldrb r0, [r0]
|
||||
cmp r4, r0
|
||||
blt _08015D86
|
||||
_08015DE0:
|
||||
adds r0, r6, 0
|
||||
pop {r3,r4}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.align 2, 0
|
||||
_08015DF0: .4byte gNoOfAllBanks
|
||||
_08015DF4: .4byte gUnknown_02024A8C
|
||||
_08015DF8: .4byte gStatuses3
|
||||
thumb_func_end sub_8015D5C
|
||||
|
||||
|
||||
thumb_func_start UpdateTurnCounters
|
||||
UpdateTurnCounters: @ 8015DFC
|
||||
push {r4-r7,lr}
|
||||
@ -1331,7 +591,7 @@ _08016288:
|
||||
beq _080162CA
|
||||
ldr r0, _08016314 @ =gBankTarget
|
||||
strb r2, [r0]
|
||||
ldr r0, _08016318 @ =gUnknown_081D939A
|
||||
ldr r0, _08016318 @ =BattleScript_WishComesTrue
|
||||
bl b_call_bc_move_exec
|
||||
mov r0, r9
|
||||
adds r0, 0x1
|
||||
@ -1375,7 +635,7 @@ _08016308: .4byte gUnknown_02024DDC
|
||||
_0801630C: .4byte gTurnOrder
|
||||
_08016310: .4byte gBattleMons
|
||||
_08016314: .4byte gBankTarget
|
||||
_08016318: .4byte gUnknown_081D939A
|
||||
_08016318: .4byte BattleScript_WishComesTrue
|
||||
_0801631C: .4byte 0x02000000
|
||||
_08016320: .4byte 0x0001600e
|
||||
_08016324:
|
||||
@ -4404,7 +3664,7 @@ _08017C1C:
|
||||
ldrb r0, [r4]
|
||||
ldr r1, _08017C50 @ =gCurrentMove
|
||||
ldrh r1, [r1]
|
||||
bl sub_8015D5C
|
||||
bl IsImprisoned
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _08017C30
|
||||
@ -11802,7 +11062,7 @@ _0801BA4C:
|
||||
ldrb r1, [r0]
|
||||
adds r0, r3, 0
|
||||
movs r2, 0xFF
|
||||
bl sub_8015A98
|
||||
bl CheckMoveLimitations
|
||||
lsls r0, 24
|
||||
lsrs r4, r0, 24
|
||||
cmp r4, 0xF
|
||||
|
@ -3401,7 +3401,7 @@ gUnknown_081D9139:: @ 81D9139
|
||||
waitmessage 64
|
||||
jump BattleScript_EndTurn
|
||||
|
||||
gUnknown_081D9144:: @ 81D9144
|
||||
BattleScript_MoveSelectionDisabledMove:: @ 81D9144
|
||||
printstring2 BATTLE_TEXT_MoveIsDisabled
|
||||
atk44
|
||||
|
||||
@ -3593,11 +3593,11 @@ BattleScript_1D934B: @ 81D934B
|
||||
setbyte 0x2024c68, 0
|
||||
end2
|
||||
|
||||
gUnknown_081D9365:: @ 81D9365
|
||||
BattleScript_NoMovesLeft:: @ 81D9365
|
||||
printstring2 BATTLE_TEXT_NoMovesLeft
|
||||
atk44
|
||||
|
||||
gUnknown_081D9369:: @ 81D9369
|
||||
BattleScript_MoveSelectionNoPP:: @ 81D9369
|
||||
printstring2 BATTLE_TEXT_NoPP1
|
||||
atk44
|
||||
|
||||
@ -3608,14 +3608,14 @@ BattleScript_NoPPForMove:: @ 81D936D
|
||||
waitmessage 64
|
||||
jump BattleScript_EndTurn
|
||||
|
||||
gUnknown_081D937C:: @ 81D937C
|
||||
BattleScript_MoveSelectionTormented:: @ 81D937C
|
||||
printstring2 BATTLE_TEXT_TormentNoUse
|
||||
atk44
|
||||
printstring BATTLE_TEXT_TormentNoUse
|
||||
waitmessage 64
|
||||
jump BattleScript_EndTurn
|
||||
|
||||
gUnknown_081D938B:: @ 81D938B
|
||||
BattleScript_MoveSelectionTaunted:: @ 81D938B
|
||||
printstring2 BATTLE_TEXT_TauntNoUse
|
||||
atk44
|
||||
|
||||
@ -3624,7 +3624,7 @@ gUnknown_081D938F:: @ 81D938F
|
||||
waitmessage 64
|
||||
jump BattleScript_EndTurn
|
||||
|
||||
gUnknown_081D939A:: @ 81D939A
|
||||
BattleScript_WishComesTrue:: @ 81D939A
|
||||
atkd4 1, BattleScript_1D93C1
|
||||
playanimation TARGET, 22, 0x0
|
||||
printstring BATTLE_TEXT_WishTrue
|
||||
@ -3691,7 +3691,7 @@ gUnknown_081D9459:: @ 81D9459
|
||||
waitmessage 64
|
||||
jump BattleScript_EndTurn
|
||||
|
||||
gUnknown_081D9464:: @ 81D9464
|
||||
BattleScript_MoveSelectionImprisoned:: @ 81D9464
|
||||
printstring2 BATTLE_TEXT_SealedNoUse
|
||||
atk44
|
||||
|
||||
@ -4425,7 +4425,7 @@ gUnknown_081D9AA7:: @ 81D9AA7
|
||||
datahpupdate USER
|
||||
return
|
||||
|
||||
gUnknown_081D9AC2:: @ 81D9AC2
|
||||
BattleScript_MoveSelectionChoiceBanded:: @ 81D9AC2
|
||||
printstring2 BATTLE_TEXT_ChoiceBand
|
||||
atk44
|
||||
|
||||
|
112
include/battle.h
112
include/battle.h
@ -179,7 +179,7 @@ struct BattleStruct /* 0x2000000 */
|
||||
/*0x16008*/ u8 wrappedMove2[4];
|
||||
/*0x1600C*/ u8 cmd49StateTracker;
|
||||
/*0x1600D*/ u8 unk1600D;
|
||||
/*0x1600E*/ u8 unk1600E;
|
||||
/*0x1600E*/ u8 turncountersTracker;
|
||||
/*0x1600F*/ u8 cmd23StateTracker;
|
||||
/*0x16010*/ u8 moveTarget[4];
|
||||
/*0x16014*/ u8 unk16014;
|
||||
@ -327,7 +327,84 @@ struct BattleStruct /* 0x2000000 */
|
||||
/*0x160CA*/ u8 synchroniseEffect;
|
||||
/*0x160CB*/ u8 linkPlayerIndex;
|
||||
/*0x160CC*/ u16 usedHeldItems[4];
|
||||
u8 filler2[0x72E];
|
||||
/*0x160D4*/ u8 unk160D4;
|
||||
/*0x160D5*/ u8 unk160D5;
|
||||
/*0x160D6*/ u8 unk160D6;
|
||||
/*0x160D7*/ u8 unk160D7;
|
||||
/*0x160D8*/ u8 unk160D8;
|
||||
/*0x160D9*/ u8 unk160D9;
|
||||
/*0x160DA*/ u8 unk160DA;
|
||||
/*0x160DB*/ u8 unk160DB;
|
||||
/*0x160DC*/ u8 unk160DC;
|
||||
/*0x160DD*/ u8 unk160DD;
|
||||
/*0x160DE*/ u8 unk160DE;
|
||||
/*0x160DF*/ u8 unk160DF;
|
||||
/*0x160E0*/ u8 unk160E0;
|
||||
/*0x160E1*/ u8 unk160E1;
|
||||
/*0x160E2*/ u8 unk160E2;
|
||||
/*0x160E3*/ u8 unk160E3;
|
||||
/*0x160E4*/ u8 unk160E4;
|
||||
/*0x160E5*/ u8 unk160E5;
|
||||
/*0x160E6*/ u8 unk160E6;
|
||||
/*0x160E7*/ u8 unk160E7;
|
||||
/*0x160E8*/ u8 unk160E8;
|
||||
/*0x160E9*/ u8 unk160E9;
|
||||
/*0x160EA*/ u8 unk160EA;
|
||||
/*0x160EB*/ u8 unk160EB;
|
||||
/*0x160EC*/ u8 unk160EC;
|
||||
/*0x160ED*/ u8 unk160ED;
|
||||
/*0x160EE*/ u8 unk160EE;
|
||||
/*0x160EF*/ u8 unk160EF;
|
||||
/*0x160F0*/ u8 unk160F0;
|
||||
/*0x160F1*/ u8 unk160F1;
|
||||
/*0x160F2*/ u8 unk160F2;
|
||||
/*0x160F3*/ u8 unk160F3;
|
||||
/*0x160F4*/ u8 unk160F4;
|
||||
/*0x160F5*/ u8 unk160F5;
|
||||
/*0x160F6*/ u8 unk160F6;
|
||||
/*0x160F7*/ u8 unk160F7;
|
||||
/*0x160F8*/ u8 unk160F8;
|
||||
/*0x160F9*/ u8 unk160F9;
|
||||
/*0x160FA*/ u8 unk160FA;
|
||||
/*0x160FB*/ u8 unk160FB;
|
||||
/*0x160FC*/ u8 turnSideTracker;
|
||||
/*0x160FD*/ u8 unk160FD;
|
||||
/*0x160FE*/ u8 unk160FE;
|
||||
/*0x160FF*/ u8 unk160FF;
|
||||
/*0x16100*/ u8 unk16100;
|
||||
/*0x16101*/ u8 unk16101;
|
||||
/*0x16102*/ u8 unk16102;
|
||||
/*0x16103*/ u8 unk16103;
|
||||
/*0x16104*/ u8 unk16104;
|
||||
/*0x16105*/ u8 unk16105;
|
||||
/*0x16106*/ u8 unk16106;
|
||||
/*0x16107*/ u8 unk16107;
|
||||
/*0x16108*/ u8 unk16108;
|
||||
/*0x16109*/ u8 unk16109;
|
||||
/*0x1610A*/ u8 unk1610A;
|
||||
/*0x1610B*/ u8 unk1610B;
|
||||
/*0x1610C*/ u8 unk1610C;
|
||||
/*0x1610D*/ u8 unk1610D;
|
||||
/*0x1610E*/ u8 unk1610E;
|
||||
/*0x1610F*/ u8 unk1610F;
|
||||
/*0x16110*/ u8 unk16110;
|
||||
/*0x16111*/ u8 unk16111;
|
||||
/*0x16112*/ u8 unk16112;
|
||||
/*0x16113*/ u8 unk16113;
|
||||
/*0x16114*/ u8 unk16114;
|
||||
/*0x16115*/ u8 unk16115;
|
||||
/*0x16116*/ u8 unk16116;
|
||||
/*0x16117*/ u8 unk16117;
|
||||
/*0x16118*/ u8 unk16118;
|
||||
/*0x16119*/ u8 unk16119;
|
||||
/*0x1611A*/ u8 unk1611A;
|
||||
/*0x1611B*/ u8 unk1611B;
|
||||
/*0x1611C*/ u8 unk1611C;
|
||||
/*0x1611D*/ u8 unk1611D;
|
||||
/*0x1611E*/ u8 unk1611E;
|
||||
/*0x1611F*/ u8 unk1611F;
|
||||
|
||||
//u8 filler2[0x72E];
|
||||
/* 0x16A00 */ struct UnkBattleStruct1 unk_2016A00_2;
|
||||
};
|
||||
|
||||
@ -532,15 +609,16 @@ extern struct Struct20238C8 gUnknown_020238C8;
|
||||
// TODO: move ewram to global.h
|
||||
extern u8 ewram[];
|
||||
|
||||
#define BATTLE_STRUCT ((struct BattleStruct *) (ewram + 0x00000))
|
||||
#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(ewram + 0x16800))
|
||||
#define UNK_2016A00_STRUCT ((struct UnkBattleStruct1 *) (ewram + 0x16A00))
|
||||
#define AI_STACK ((struct AI_Stack *) (ewram + 0x16C00))
|
||||
#define AI_ARRAY_160CC ((struct SmallItemStruct *) (ewram + 0x160CC))
|
||||
#define B_FUNCTION_STACK ((struct funcStack *) (ewram + 0x17140))
|
||||
#define ewram17800 ((struct Struct2017800 *) (ewram + 0x17800))
|
||||
#define ewram17810 ((struct Struct2017810 *) (ewram + 0x17810))
|
||||
#define ewram17840 (*(struct Struct2017840 *) (ewram + 0x17840))
|
||||
#define BATTLE_STRUCT ((struct BattleStruct *) (ewram + 0x00000))
|
||||
#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(ewram + 0x16800))
|
||||
#define UNK_2016A00_STRUCT ((struct UnkBattleStruct1 *) (ewram + 0x16A00))
|
||||
#define AI_STACK ((struct AI_Stack *) (ewram + 0x16C00))
|
||||
#define AI_ARRAY_160CC ((struct SmallItemStruct *) (ewram + 0x160CC))
|
||||
#define B_BATTLESCRIPTS_STACK ((struct scriptsStack *) (ewram + 0x17110))
|
||||
#define B_FUNCTION_STACK ((struct funcStack *) (ewram + 0x17140))
|
||||
#define ewram17800 ((struct Struct2017800 *) (ewram + 0x17800))
|
||||
#define ewram17810 ((struct Struct2017810 *) (ewram + 0x17810))
|
||||
#define ewram17840 (*(struct Struct2017840 *) (ewram + 0x17840))
|
||||
|
||||
struct funcStack
|
||||
{
|
||||
@ -548,6 +626,12 @@ struct funcStack
|
||||
u8 size;
|
||||
};
|
||||
|
||||
struct scriptsStack
|
||||
{
|
||||
u8* ptr[8];
|
||||
u8 size;
|
||||
};
|
||||
|
||||
extern u8 gBattleTextBuff1[];
|
||||
|
||||
//function declarations of buffer emits
|
||||
@ -650,14 +734,14 @@ void TurnValuesCleanUp(u8);
|
||||
void SpecialStatusesClear(void);
|
||||
void sub_80138F0(void);
|
||||
void sub_80155A4();
|
||||
void CancelMultiTurnMoves(u8);
|
||||
void CancelMultiTurnMoves(u8 bank);
|
||||
void PrepareStringBattle();
|
||||
void sub_80156DC();
|
||||
void sub_80157C4(u8 index);
|
||||
|
||||
// asm/battle_3.o
|
||||
u8 sub_8015A98(u8, u8, u8);
|
||||
u8 UpdateTurnCounters();
|
||||
u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check);
|
||||
u8 UpdateTurnCounters(void);
|
||||
u8 TurnBasedEffects();
|
||||
u8 sub_80170DC();
|
||||
u8 sub_80173A4();
|
||||
|
@ -53,6 +53,7 @@ SECTIONS {
|
||||
asm/battle_1.o(.text_800DC24);
|
||||
src/battle_2.o(.text);
|
||||
asm/battle_2.o(.text);
|
||||
src/battle_3.o(.text);
|
||||
asm/battle_3.o(.text);
|
||||
src/battle_4.o(.text);
|
||||
asm/battle_5.o(.text);
|
||||
|
450
src/battle_3.c
Normal file
450
src/battle_3.c
Normal file
@ -0,0 +1,450 @@
|
||||
#include "global.h"
|
||||
#include "abilities.h"
|
||||
#include "battle.h"
|
||||
#include "moves.h"
|
||||
#include "item.h"
|
||||
#include "items.h"
|
||||
#include "hold_effects.h"
|
||||
#include "species.h"
|
||||
#include "pokemon.h"
|
||||
#include "data2.h"
|
||||
#include "rng.h"
|
||||
#include "text.h"
|
||||
|
||||
extern u8* gBattlescriptCurrInstr;
|
||||
extern u8 gActiveBank;
|
||||
extern u8 gBattleBufferB[4][0x200];
|
||||
extern u8* gUnknown_02024C1C[4]; //battlescript location when you try to use a move you're not allowed to
|
||||
extern u16 gLastUsedMove[4];
|
||||
extern struct BattlePokemon gBattleMons[4];
|
||||
extern struct BattleEnigmaBerry gEnigmaBerries[4];
|
||||
extern u8 gStringBank;
|
||||
extern u16 gLastUsedItem;
|
||||
extern u16 gCurrentMove;
|
||||
extern const u32 gBitTable[];
|
||||
extern u16 gBattleTypeFlags;
|
||||
extern u8 gNoOfAllBanks;
|
||||
extern u32 gStatuses3[4];
|
||||
extern u8 gBankAttacker;
|
||||
extern u8 gBankTarget;
|
||||
extern u8 gTurnOrder[4];
|
||||
extern u16 gSideAffecting[2];
|
||||
extern u16 gBattleWeather;
|
||||
extern void (*gBattleMainFunc)(void);
|
||||
extern u8 gAbsentBankFlags;
|
||||
extern u8 gBattleCommunication[];
|
||||
|
||||
u8 IsImprisoned(u8 bank, u16 move);
|
||||
u8 GetBankByPlayerAI(u8 ID);
|
||||
u8 GetBankIdentity(u8 bank);
|
||||
u8 GetBankSide(u8 bank);
|
||||
void b_call_bc_move_exec(u8* BS_ptr);
|
||||
|
||||
extern u8 BattleScript_MoveSelectionDisabledMove[];
|
||||
extern u8 BattleScript_MoveSelectionTormented[];
|
||||
extern u8 BattleScript_MoveSelectionTaunted[];
|
||||
extern u8 BattleScript_MoveSelectionImprisoned[];
|
||||
extern u8 BattleScript_MoveSelectionChoiceBanded[];
|
||||
extern u8 BattleScript_MoveSelectionNoPP[];
|
||||
extern u8 BattleScript_NoMovesLeft[];
|
||||
extern u8 BattleScript_WishComesTrue[];
|
||||
extern u8 gUnknown_081D9030[];
|
||||
extern u8 gUnknown_081D8F62[];
|
||||
extern u8 gUnknown_081D8FFF[];
|
||||
extern u8 gUnknown_081D8F7D[];
|
||||
extern u8 gUnknown_081D9016[];
|
||||
extern u8 gUnknown_081D9008[];
|
||||
extern u8 gUnknown_081D9041[];
|
||||
|
||||
#define CHOICED_MOVE(bank)(((u16*)(&ewram[bank * 2 + 0x160e8])))
|
||||
|
||||
//array entries for battle communication
|
||||
#define MOVE_EFFECT_BYTE 0x3
|
||||
#define MULTISTRING_CHOOSER 0x5
|
||||
#define MSG_DISPLAY 0x7
|
||||
|
||||
void b_movescr_stack_push(u8* BS_ptr)
|
||||
{
|
||||
B_BATTLESCRIPTS_STACK->ptr[B_BATTLESCRIPTS_STACK->size++] = BS_ptr;
|
||||
}
|
||||
|
||||
void b_movescr_stack_push_cursor(void)
|
||||
{
|
||||
B_BATTLESCRIPTS_STACK->ptr[B_BATTLESCRIPTS_STACK->size++] = gBattlescriptCurrInstr;
|
||||
}
|
||||
|
||||
void b_movescr_stack_pop_cursor(void)
|
||||
{
|
||||
gBattlescriptCurrInstr = B_BATTLESCRIPTS_STACK->ptr[--B_BATTLESCRIPTS_STACK->size];
|
||||
}
|
||||
|
||||
u8 sub_8015894(void) //msg can't select a move
|
||||
{
|
||||
u8 limitations = 0;
|
||||
u16 move = gBattleMons[gActiveBank].moves[gBattleBufferB[gActiveBank][2]];
|
||||
u8 holdEffect;
|
||||
u16* choicedMove = CHOICED_MOVE(gActiveBank);
|
||||
if (gDisableStructs[gActiveBank].disabledMove == move && move)
|
||||
{
|
||||
BATTLE_STRUCT->scriptingActive = gActiveBank;
|
||||
gCurrentMove = move;
|
||||
gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionDisabledMove;
|
||||
limitations++;
|
||||
}
|
||||
if (move == gLastUsedMove[gActiveBank] && move != MOVE_STRUGGLE && gBattleMons[gActiveBank].status2 & STATUS2_TORMENT)
|
||||
{
|
||||
CancelMultiTurnMoves(gActiveBank);
|
||||
gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionTormented;
|
||||
limitations++;
|
||||
}
|
||||
if (gDisableStructs[gActiveBank].tauntTimer1 && gBattleMoves[move].power == 0)
|
||||
{
|
||||
gCurrentMove = move;
|
||||
gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionTaunted;
|
||||
limitations++;
|
||||
}
|
||||
if (IsImprisoned(gActiveBank, move))
|
||||
{
|
||||
gCurrentMove = move;
|
||||
gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionImprisoned;
|
||||
limitations++;
|
||||
}
|
||||
if (gBattleMons[gActiveBank].item == ITEM_ENIGMA_BERRY)
|
||||
holdEffect = gEnigmaBerries[gActiveBank].holdEffect;
|
||||
else
|
||||
holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBank].item);
|
||||
gStringBank = gActiveBank;
|
||||
if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != move)
|
||||
{
|
||||
gCurrentMove = *choicedMove;
|
||||
gLastUsedItem = gBattleMons[gActiveBank].item;
|
||||
gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionChoiceBanded;
|
||||
limitations++;
|
||||
}
|
||||
if (gBattleMons[gActiveBank].pp[gBattleBufferB[gActiveBank][2]] == 0)
|
||||
{
|
||||
gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionNoPP;
|
||||
limitations++;
|
||||
}
|
||||
return limitations;
|
||||
}
|
||||
|
||||
#define MOVE_LIMITATION_ZEROMOVE (1 << 0)
|
||||
#define MOVE_LIMITATION_PP (1 << 1)
|
||||
#define MOVE_LIMITATION_DISABLED (1 << 2)
|
||||
#define MOVE_LIMITATION_TORMENTED (1 << 3)
|
||||
#define MOVE_LIMITATION_TAUNT (1 << 4)
|
||||
#define MOVE_LIMITATION_IMPRISION (1 << 5)
|
||||
|
||||
u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check)
|
||||
{
|
||||
u8 holdEffect;
|
||||
u16* choicedMove = CHOICED_MOVE(bank);
|
||||
s32 i;
|
||||
if (gBattleMons[bank].item == ITEM_ENIGMA_BERRY)
|
||||
holdEffect = gEnigmaBerries[bank].holdEffect;
|
||||
else
|
||||
holdEffect = ItemId_GetHoldEffect(gBattleMons[bank].item);
|
||||
gStringBank = bank;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (gBattleMons[bank].moves[i] == 0 && check & MOVE_LIMITATION_ZEROMOVE)
|
||||
unusableMoves |= gBitTable[i];
|
||||
if (gBattleMons[bank].pp[i] == 0 && check & MOVE_LIMITATION_PP)
|
||||
unusableMoves |= gBitTable[i];
|
||||
if (gBattleMons[bank].moves[i] == gDisableStructs[bank].disabledMove && check & MOVE_LIMITATION_DISABLED)
|
||||
unusableMoves |= gBitTable[i];
|
||||
if (gBattleMons[bank].moves[i] == gLastUsedMove[bank] && check & MOVE_LIMITATION_TORMENTED && gBattleMons[bank].status2 & STATUS2_TORMENT)
|
||||
unusableMoves |= gBitTable[i];
|
||||
if (gDisableStructs[bank].tauntTimer1 && check & MOVE_LIMITATION_TAUNT && gBattleMoves[gBattleMons[bank].moves[i]].power == 0)
|
||||
unusableMoves |= gBitTable[i];
|
||||
if (IsImprisoned(bank, gBattleMons[bank].moves[i]) && check & MOVE_LIMITATION_IMPRISION)
|
||||
unusableMoves |= gBitTable[i];
|
||||
if (gDisableStructs[bank].encoreTimer1 && gDisableStructs[bank].encoredMove != gBattleMons[bank].moves[i])
|
||||
unusableMoves |= gBitTable[i];
|
||||
if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != gBattleMons[bank].moves[i])
|
||||
unusableMoves |= gBitTable[i];
|
||||
}
|
||||
return unusableMoves;
|
||||
}
|
||||
|
||||
bool8 AreAllMovesUnusable(void)
|
||||
{
|
||||
u8 unusable;
|
||||
unusable = CheckMoveLimitations(gActiveBank, 0, 0xFF);
|
||||
if (unusable == 0xF) //all moves are unusable
|
||||
{
|
||||
gProtectStructs[gActiveBank].onlyStruggle = 1;
|
||||
gUnknown_02024C1C[gActiveBank] = BattleScript_NoMovesLeft;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
gBattleBufferB[gActiveBank][3] = GetBankByPlayerAI((GetBankIdentity(gActiveBank) ^ 1) | (Random() & 2));
|
||||
else
|
||||
gBattleBufferB[gActiveBank][3] = GetBankByPlayerAI(GetBankIdentity(gActiveBank) ^ 1);
|
||||
}
|
||||
else
|
||||
gProtectStructs[gActiveBank].onlyStruggle = 0;
|
||||
return (unusable == 0xF);
|
||||
}
|
||||
|
||||
u8 IsImprisoned(u8 bank, u16 move)
|
||||
{
|
||||
u8 imprisionedMoves = 0;
|
||||
u8 bankSide = GetBankSide(bank);
|
||||
s32 i;
|
||||
for (i = 0; i < gNoOfAllBanks; i++)
|
||||
{
|
||||
if (bankSide != GetBankSide(i) && gStatuses3[i] & STATUS3_IMPRISIONED)
|
||||
{
|
||||
s32 j;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
if (move == gBattleMons[i].moves[j])
|
||||
break;
|
||||
}
|
||||
if (j < 4)
|
||||
imprisionedMoves++;
|
||||
}
|
||||
}
|
||||
return imprisionedMoves;
|
||||
}
|
||||
/*
|
||||
u8 UpdateTurnCounters(void)
|
||||
{
|
||||
u8 effect = 0;
|
||||
s32 i;
|
||||
for (gBankAttacker = 0; gBankAttacker < gNoOfAllBanks && gAbsentBankFlags & gBitTable[gBankAttacker]; gBankAttacker++) {}
|
||||
for (gBankTarget = 0; gBankTarget < gNoOfAllBanks && gAbsentBankFlags & gBitTable[gBankTarget]; gBankTarget++) {}
|
||||
do
|
||||
{
|
||||
switch (BATTLE_STRUCT->turncountersTracker)
|
||||
{
|
||||
case 0:
|
||||
for (i = 0; i < gNoOfAllBanks; i++)
|
||||
{
|
||||
gTurnOrder[i] = i;
|
||||
}
|
||||
for (i = 0; i < gNoOfAllBanks - 1; i++)
|
||||
{
|
||||
s32 j;
|
||||
for (j = i + 1; j < gNoOfAllBanks; j++)
|
||||
{
|
||||
if (b_first_side(gTurnOrder[i], gTurnOrder[j], 0))
|
||||
sub_8012FBC(i, j);
|
||||
}
|
||||
}
|
||||
BATTLE_STRUCT->turncountersTracker++;
|
||||
BATTLE_STRUCT->turnSideTracker = 0;
|
||||
case 1:
|
||||
while (BATTLE_STRUCT->turnSideTracker < 2)
|
||||
{
|
||||
gBankAttacker = BATTLE_STRUCT->turnSideTracker;
|
||||
gActiveBank = BATTLE_STRUCT->turnSideTracker;
|
||||
if (gSideAffecting[BATTLE_STRUCT->turnSideTracker] & SIDE_STATUS_REFLECT)
|
||||
{
|
||||
if (--gSideTimer[BATTLE_STRUCT->turnSideTracker].reflectTimer == 0)
|
||||
{
|
||||
gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_REFLECT;
|
||||
b_call_bc_move_exec(gUnknown_081D9030);
|
||||
gBattleTextBuff1[0] = 0xFD;
|
||||
gBattleTextBuff1[1] = 2;
|
||||
gBattleTextBuff1[2] = MOVE_REFLECT;
|
||||
gBattleTextBuff1[3] = MOVE_REFLECT >> 8;
|
||||
gBattleTextBuff1[4] = EOS;
|
||||
effect++;
|
||||
}
|
||||
}
|
||||
BATTLE_STRUCT->turnSideTracker++;
|
||||
if (effect)
|
||||
break;
|
||||
}
|
||||
if (!effect)
|
||||
{
|
||||
BATTLE_STRUCT->turncountersTracker++;
|
||||
BATTLE_STRUCT->turnSideTracker = 0;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
while (BATTLE_STRUCT->turnSideTracker < 2)
|
||||
{
|
||||
gBankAttacker = BATTLE_STRUCT->turnSideTracker;
|
||||
gActiveBank = BATTLE_STRUCT->turnSideTracker;
|
||||
if (gSideAffecting[BATTLE_STRUCT->turnSideTracker] & SIDE_STATUS_LIGHTSCREEN)
|
||||
{
|
||||
if (--gSideTimer[BATTLE_STRUCT->turnSideTracker].lightscreenTimer == 0)
|
||||
{
|
||||
gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_LIGHTSCREEN;
|
||||
b_call_bc_move_exec(gUnknown_081D9030);
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = BATTLE_STRUCT->turnSideTracker;
|
||||
gBattleTextBuff1[0] = 0xFD;
|
||||
gBattleTextBuff1[1] = 2;
|
||||
gBattleTextBuff1[2] = MOVE_LIGHT_SCREEN;
|
||||
gBattleTextBuff1[3] = MOVE_LIGHT_SCREEN >> 8;
|
||||
gBattleTextBuff1[4] = EOS;
|
||||
effect++;
|
||||
}
|
||||
}
|
||||
BATTLE_STRUCT->turnSideTracker++;
|
||||
if (effect)
|
||||
break;
|
||||
}
|
||||
if (!effect)
|
||||
{
|
||||
BATTLE_STRUCT->turncountersTracker++;
|
||||
BATTLE_STRUCT->turnSideTracker = 0;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
while (BATTLE_STRUCT->turnSideTracker < 2)
|
||||
{
|
||||
gBankAttacker = BATTLE_STRUCT->turnSideTracker;
|
||||
gActiveBank = BATTLE_STRUCT->turnSideTracker;
|
||||
if (gSideTimer[BATTLE_STRUCT->turnSideTracker].mistTimer && --gSideTimer[BATTLE_STRUCT->turnSideTracker].mistTimer == 0)
|
||||
{
|
||||
gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_MIST;
|
||||
b_call_bc_move_exec(gUnknown_081D9030);
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = BATTLE_STRUCT->turnSideTracker;
|
||||
gBattleTextBuff1[0] = 0xFD;
|
||||
gBattleTextBuff1[1] = 2;
|
||||
gBattleTextBuff1[2] = MOVE_MIST;
|
||||
gBattleTextBuff1[3] = MOVE_MIST >> 8;
|
||||
gBattleTextBuff1[4] = EOS;
|
||||
effect++;
|
||||
}
|
||||
BATTLE_STRUCT->turnSideTracker++;
|
||||
if (effect)
|
||||
break;
|
||||
}
|
||||
if (!effect)
|
||||
{
|
||||
BATTLE_STRUCT->turncountersTracker++;
|
||||
BATTLE_STRUCT->turnSideTracker = 0;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
while (BATTLE_STRUCT->turnSideTracker < 2)
|
||||
{
|
||||
gBankAttacker = BATTLE_STRUCT->turnSideTracker;
|
||||
gActiveBank = BATTLE_STRUCT->turnSideTracker;
|
||||
if (gSideAffecting[BATTLE_STRUCT->turnSideTracker] & SIDE_STATUS_SAFEGUARD)
|
||||
{
|
||||
if (--gSideTimer[BATTLE_STRUCT->turnSideTracker].safeguardTimer == 0)
|
||||
{
|
||||
gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_SAFEGUARD;
|
||||
b_call_bc_move_exec(gUnknown_081D9041);
|
||||
effect++;
|
||||
}
|
||||
}
|
||||
BATTLE_STRUCT->turnSideTracker++;
|
||||
if (effect)
|
||||
break;
|
||||
}
|
||||
if (!effect)
|
||||
{
|
||||
BATTLE_STRUCT->turncountersTracker++;
|
||||
BATTLE_STRUCT->turnSideTracker = 0;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
while (BATTLE_STRUCT->turnSideTracker < gNoOfAllBanks)
|
||||
{
|
||||
gActiveBank = gTurnOrder[BATTLE_STRUCT->turnSideTracker];
|
||||
if (gWishFutureKnock.wishCounter[BATTLE_STRUCT->turnSideTracker] && --gWishFutureKnock.wishCounter[BATTLE_STRUCT->turnSideTracker] == 0 && gBattleMons[BATTLE_STRUCT->turnSideTracker].hp)
|
||||
{
|
||||
gBankTarget = BATTLE_STRUCT->turnSideTracker;
|
||||
b_call_bc_move_exec(BattleScript_WishComesTrue);
|
||||
effect++;
|
||||
}
|
||||
BATTLE_STRUCT->turnSideTracker++;
|
||||
if (effect)
|
||||
break;
|
||||
}
|
||||
if (!effect)
|
||||
{
|
||||
BATTLE_STRUCT->turncountersTracker++;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (gBattleWeather & WEATHER_RAIN_ANY)
|
||||
{
|
||||
if (!(gBattleWeather & WEATHER_RAIN_PERMANENT))
|
||||
{
|
||||
if (--gWishFutureKnock.weatherDuration == 0)
|
||||
{
|
||||
gBattleWeather &= ~WEATHER_RAIN_TEMPORARY;
|
||||
gBattleWeather &= ~WEATHER_RAIN_DOWNPOUR;
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
|
||||
}
|
||||
else if (gBattleWeather & WEATHER_RAIN_DOWNPOUR)
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
|
||||
else
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
|
||||
}
|
||||
else if (gBattleWeather & WEATHER_RAIN_DOWNPOUR)
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
|
||||
else
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
|
||||
b_call_bc_move_exec(gUnknown_081D8F62);
|
||||
effect++;
|
||||
}
|
||||
BATTLE_STRUCT->turncountersTracker++;
|
||||
break;
|
||||
case 7:
|
||||
if (gBattleWeather & WEATHER_SANDSTORM_ANY)
|
||||
{
|
||||
if (!(gBattleWeather & WEATHER_SANDSTORM_PERMANENT) && --gWishFutureKnock.weatherDuration == 0)
|
||||
{
|
||||
gBattleWeather &= ~WEATHER_SANDSTORM_TEMPORARY;
|
||||
gBattlescriptCurrInstr = gUnknown_081D8FFF;
|
||||
}
|
||||
else
|
||||
gBattlescriptCurrInstr = gUnknown_081D8F7D;
|
||||
}
|
||||
BATTLE_STRUCT->animArg1 = 0xD;
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
|
||||
b_call_bc_move_exec(gBattlescriptCurrInstr);
|
||||
effect++;
|
||||
BATTLE_STRUCT->turncountersTracker++;
|
||||
break;
|
||||
case 8:
|
||||
if (gBattleWeather & WEATHER_SUN_ANY)
|
||||
{
|
||||
if (!(gBattleWeather & WEATHER_SUN_PERMANENT) && --gWishFutureKnock.weatherDuration == 0)
|
||||
{
|
||||
gBattleWeather &= ~WEATHER_SUN_TEMPORARY;
|
||||
gBattlescriptCurrInstr = gUnknown_081D9016;
|
||||
}
|
||||
else
|
||||
gBattlescriptCurrInstr = gUnknown_081D9008;
|
||||
}
|
||||
BATTLE_STRUCT->animArg1 = 0xD;
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
|
||||
b_call_bc_move_exec(gBattlescriptCurrInstr);
|
||||
effect++;
|
||||
BATTLE_STRUCT->turncountersTracker++;
|
||||
break;
|
||||
case 9:
|
||||
if (gBattleWeather & WEATHER_HAIL)
|
||||
{
|
||||
if (--gWishFutureKnock.weatherDuration == 0)
|
||||
{
|
||||
gBattleWeather &= ~WEATHER_HAIL;
|
||||
gBattlescriptCurrInstr = gUnknown_081D8FFF;
|
||||
}
|
||||
else
|
||||
gBattlescriptCurrInstr = gUnknown_081D8F7D;
|
||||
}
|
||||
BATTLE_STRUCT->animArg1 = 0xD;
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
|
||||
b_call_bc_move_exec(gBattlescriptCurrInstr);
|
||||
effect++;
|
||||
BATTLE_STRUCT->turncountersTracker++;
|
||||
break;
|
||||
case 10:
|
||||
effect++;
|
||||
break;
|
||||
}
|
||||
} while (!effect);
|
||||
return (gBattleMainFunc != BattleTurnPassed);
|
||||
}
|
||||
|
||||
*/
|
@ -159,7 +159,7 @@ u8 CalculatePlayerPartyCount(void);
|
||||
u16 Sqrt(u32 num);
|
||||
u8 sub_809070C(u16 nationalNum, u32 TiD, u32 PiD); //task prepare poke dex display
|
||||
void sub_814A880(u8 a1, u8 a2);
|
||||
u8 sub_8015A98(u8 bank, u8 unusable_moves, u8 flags); //choose move limitations
|
||||
u8 CheckMoveLimitations(u8 bank, u8 unusable_moves, u8 flags); //choose move limitations
|
||||
void sub_801529C(u8 bank);
|
||||
bool8 IsLinkDoubleBattle(void);
|
||||
void sub_8094B6C(u8 bank, u8 partyID, u8 r2);
|
||||
@ -5217,7 +5217,7 @@ static void atk15_seteffectwithchancetarget(void)
|
||||
else
|
||||
gBattlescriptCurrInstr++;
|
||||
gBattleCommunication[MOVE_EFFECT_BYTE] = 0;
|
||||
BATTLE_STRUCT->filler2[0x3E] = 0; //TODO: to fix this later
|
||||
BATTLE_STRUCT->unk16112 = 0;
|
||||
}
|
||||
|
||||
static void atk16_seteffectprimary(void)
|
||||
@ -5240,7 +5240,7 @@ static void atk18_status_effect_clear(void)
|
||||
|
||||
gBattleCommunication[MOVE_EFFECT_BYTE] = 0;
|
||||
gBattlescriptCurrInstr += 2;
|
||||
BATTLE_STRUCT->filler2[0x3E] = 0; //TODO: to fix this later
|
||||
BATTLE_STRUCT->unk16112 = 0;
|
||||
}
|
||||
|
||||
//Fuck this, Maybe later
|
||||
@ -15582,7 +15582,7 @@ static void atkA9_sleeptalk_choose_move(void)
|
||||
|| gBattleMons[gBankAttacker].moves[i] == MOVE_UPROAR || IsTwoTurnsMove(gBattleMons[gBankAttacker].moves[i]))
|
||||
unusable_moves |= gBitTable[i];
|
||||
}
|
||||
unusable_moves = sub_8015A98(gBankAttacker, unusable_moves, 0xFD);
|
||||
unusable_moves = CheckMoveLimitations(gBankAttacker, unusable_moves, 0xFD);
|
||||
if (unusable_moves == 0xF) //all 4 moves cannot be chosen
|
||||
gBattlescriptCurrInstr += 5;
|
||||
else //at least one move can be chosen
|
||||
|
@ -301,7 +301,7 @@ void BattleAI_SetupAIData(void)
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
AI_THINKING_STRUCT->score[i] = 100;
|
||||
|
||||
r7 = sub_8015A98(gActiveBank, 0, 0xFF);
|
||||
r7 = CheckMoveLimitations(gActiveBank, 0, 0xFF);
|
||||
|
||||
// probably sets up the moves to consider and ignores non-valid moves such as NO_MOVE or glitch moves.
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user