pmd-red/asm/code_8077274.s
2022-11-11 16:49:48 -08:00

505 lines
7.9 KiB
ArmAsm

#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_8078968
sub_8078968:
push {r4-r7,lr}
mov r7, r8
push {r7}
adds r6, r0, 0
adds r4, r1, 0
ldr r5, [r4, 0x70]
adds r0, r4, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _08078A4A
adds r0, r6, 0
adds r1, r4, 0
movs r2, 0x1
bl HasSafeguardStatus
lsls r0, 24
cmp r0, 0
bne _08078A4A
movs r3, 0
ldr r0, _080789E8
mov r8, r0
movs r1, 0x1
mov r12, r1
movs r0, 0x8C
lsls r0, 1
adds r2, r5, r0
movs r7, 0x10
_080789A2:
ldrb r1, [r2]
mov r0, r12
ands r0, r1
cmp r0, 0
beq _080789B4
adds r0, r7, 0
ands r0, r1
cmp r0, 0
bne _080789BC
_080789B4:
adds r2, 0x8
adds r3, 0x1
cmp r3, 0x3
ble _080789A2
_080789BC:
cmp r3, 0x4
bne _080789F0
movs r1, 0x9C
lsls r1, 1
adds r0, r5, r1
ldrb r1, [r0]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _080789F0
mov r0, r8
adds r1, r4, 0
movs r2, 0
bl SetMessageArgument
ldr r0, _080789EC
ldr r2, [r0]
adds r0, r6, 0
adds r1, r4, 0
bl sub_80522F4
b _08078A4A
.align 2, 0
_080789E8: .4byte gAvailablePokemonNames
_080789EC: .4byte gUnknown_80FBBD4
_080789F0:
mov r0, r8
adds r1, r4, 0
movs r2, 0
bl SetMessageArgument
adds r1, r5, 0
adds r1, 0xBC
ldrb r0, [r1]
cmp r0, 0x6
beq _08078A38
movs r0, 0x6
strb r0, [r1]
ldr r1, _08078A30
adds r0, r4, 0
movs r2, 0x1
bl CalculateStatusTurns
adds r0, 0x1
adds r1, r5, 0
adds r1, 0xBD
strb r0, [r1]
adds r0, r4, 0
bl nullsub_83
ldr r0, _08078A34
ldr r2, [r0]
adds r0, r6, 0
adds r1, r4, 0
bl sub_80522F4
b _08078A44
.align 2, 0
_08078A30: .4byte gUnknown_80F4EF4
_08078A34: .4byte gUnknown_80FBB94
_08078A38:
ldr r0, _08078A54
ldr r2, [r0]
adds r0, r6, 0
adds r1, r4, 0
bl sub_80522F4
_08078A44:
adds r0, r4, 0
bl DungeonEntityUpdateStatusSprites
_08078A4A:
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08078A54: .4byte gUnknown_80FBBB8
thumb_func_end sub_8078968
thumb_func_start sub_8078A58
sub_8078A58:
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0x14
mov r8, r0
adds r6, r1, 0
adds r7, r2, 0
adds r5, r3, 0
adds r0, r6, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _08078B4A
ldr r4, [r6, 0x70]
cmp r5, 0
beq _08078AE0
mov r0, sp
adds r1, r5, 0
bl sub_80943A0
ldr r2, [sp]
movs r0, 0xA0
lsls r0, 1
adds r5, r4, r0
ldr r7, [r5]
add r0, sp, 0x4
adds r1, r7, 0
bl sub_80942C0
ldr r2, [sp, 0x4]
str r2, [r5]
movs r0, 0x9E
lsls r0, 1
adds r4, r0
ldr r1, [r4]
add r0, sp, 0x8
bl sub_8094318
ldr r0, [sp, 0x8]
str r0, [r4]
ldr r0, _08078AD0
adds r1, r6, 0
movs r2, 0
bl SetMessageArgument
adds r0, r7, 0
bl RoundUpFixedPoint
adds r4, r0, 0
ldr r0, [r5]
bl RoundUpFixedPoint
cmp r4, r0
beq _08078AD8
adds r0, r6, 0
bl sub_8041D9C
ldr r0, _08078AD4
b _08078B22
.align 2, 0
_08078AD0: .4byte gAvailablePokemonNames
_08078AD4: .4byte gUnknown_80FBD9C
_08078AD8:
ldr r0, _08078ADC
b _08078B22
.align 2, 0
_08078ADC: .4byte gUnknown_80FBE3C
_08078AE0:
add r0, sp, 0xC
adds r1, r7, 0
bl sub_80943A0
ldr r2, [sp, 0xC]
movs r0, 0x9E
lsls r0, 1
adds r4, r0
ldr r7, [r4]
add r0, sp, 0x10
adds r1, r7, 0
bl sub_80942C0
ldr r0, [sp, 0x10]
str r0, [r4]
ldr r0, _08078B30
adds r1, r6, 0
movs r2, 0
bl SetMessageArgument
adds r0, r7, 0
bl RoundUpFixedPoint
adds r5, r0, 0
ldr r0, [r4]
bl RoundUpFixedPoint
cmp r5, r0
beq _08078B38
adds r0, r6, 0
bl nullsub_84
ldr r0, _08078B34
_08078B22:
ldr r2, [r0]
mov r0, r8
adds r1, r6, 0
bl sub_80522F4
b _08078B44
.align 2, 0
_08078B30: .4byte gAvailablePokemonNames
_08078B34: .4byte gUnknown_80FBD78
_08078B38:
ldr r0, _08078B58
ldr r2, [r0]
mov r0, r8
adds r1, r6, 0
bl sub_80522F4
_08078B44:
adds r0, r6, 0
bl DungeonEntityUpdateStatusSprites
_08078B4A:
add sp, 0x14
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08078B58: .4byte gUnknown_80FBE40
thumb_func_end sub_8078A58
thumb_func_start sub_8078B5C
sub_8078B5C:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x28
mov r9, r0
adds r6, r1, 0
mov r10, r2
str r3, [sp, 0x1C]
ldr r0, [sp, 0x48]
lsls r0, 24
lsrs r0, 24
mov r8, r0
adds r0, r6, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
bne _08078B86
b _08078D78
_08078B86:
ldr r7, [r6, 0x70]
ldrb r0, [r7, 0x7]
cmp r0, 0
bne _08078BB8
adds r0, r6, 0
movs r1, 0x1B
bl HasItem
lsls r0, 24
cmp r0, 0
beq _08078BB8
mov r0, r8
cmp r0, 0
bne _08078BA4
b _08078D78
_08078BA4:
ldr r0, _08078BB4
ldr r2, [r0]
mov r0, r9
adds r1, r6, 0
bl sub_80522F4
b _08078D78
.align 2, 0
_08078BB4: .4byte gUnknown_80FBEA0
_08078BB8:
movs r5, 0
ldr r1, [sp, 0x1C]
cmp r1, 0
beq _08078BE8
movs r1, 0x9E
lsls r1, 1
adds r0, r7, r1
ldr r0, [r0]
bl RoundUpFixedPoint
adds r4, r0, 0
movs r1, 0xA0
lsls r1, 1
adds r0, r7, r1
ldr r0, [r0]
bl RoundUpFixedPoint
cmp r4, r0
blt _08078BE0
movs r5, 0x1
_08078BE0:
ldr r0, _08078C8C
cmp r10, r0
bne _08078BE8
movs r5, 0x1
_08078BE8:
cmp r5, 0
beq _08078CC0
movs r0, 0xA0
lsls r0, 1
adds r5, r7, r0
ldr r1, [r5]
str r1, [sp, 0x20]
subs r0, 0x4
adds r0, r7
mov r10, r0
ldr r0, [r0]
bl RoundUpFixedPoint
adds r4, r0, 0
ldr r0, [r5]
bl RoundUpFixedPoint
movs r1, 0
str r1, [sp, 0x24]
cmp r4, r0
bne _08078C16
movs r0, 0x1
str r0, [sp, 0x24]
_08078C16:
mov r0, sp
ldr r1, [sp, 0x1C]
bl sub_80943A0
ldr r2, [sp]
ldr r1, [r5]
add r0, sp, 0x4
bl sub_8094268
ldr r4, [sp, 0x4]
str r4, [r5]
add r0, sp, 0x8
movs r1, 0xC8
bl sub_80943A0
ldr r2, [sp, 0x8]
add r0, sp, 0xC
adds r1, r4, 0
bl sub_8094318
ldr r0, [sp, 0xC]
str r0, [r5]
mov r1, r10
str r0, [r1]
ldr r0, [sp, 0x24]
cmp r0, 0
bne _08078C5E
mov r1, r8
cmp r1, 0
beq _08078C5E
ldr r0, _08078C90
ldr r2, [r0]
mov r0, r9
adds r1, r6, 0
bl sub_80522F4
_08078C5E:
ldr r0, [sp, 0x20]
bl RoundUpFixedPoint
adds r4, r0, 0
movs r1, 0xA0
lsls r1, 1
adds r0, r7, r1
ldr r0, [r0]
bl RoundUpFixedPoint
cmp r4, r0
bne _08078C9C
ldr r0, _08078C94
adds r1, r6, 0
movs r2, 0
bl SetMessageArgument
mov r0, r8
cmp r0, 0
beq _08078D72
ldr r0, _08078C98
b _08078D4E
.align 2, 0
_08078C8C: .4byte 0x000003e7
_08078C90: .4byte gUnknown_80FBE64
_08078C94: .4byte gAvailablePokemonNames
_08078C98: .4byte gUnknown_80FBDF0
_08078C9C:
adds r0, r6, 0
bl sub_8041DB0
ldr r0, _08078CB8
adds r1, r6, 0
movs r2, 0
bl SetMessageArgument
mov r1, r8
cmp r1, 0
beq _08078D72
ldr r0, _08078CBC
b _08078D4E
.align 2, 0
_08078CB8: .4byte gAvailablePokemonNames
_08078CBC: .4byte gUnknown_80FBDC4
_08078CC0:
movs r0, 0x9E
lsls r0, 1
adds r5, r7, r0
ldr r4, [r5]
add r0, sp, 0x10
mov r1, r10
bl sub_80943A0
ldr r2, [sp, 0x10]
ldr r1, [r5]
add r0, sp, 0x14
bl sub_8094268
ldr r1, [sp, 0x14]
str r1, [r5]
movs r0, 0xA0
lsls r0, 1
adds r7, r0
ldr r2, [r7]
add r0, sp, 0x18
bl sub_8094318
ldr r0, [sp, 0x18]
str r0, [r5]
ldr r0, _08078D28
cmp r10, r0
bne _08078CFA
ldr r0, [r7]
str r0, [r5]
_08078CFA:
adds r0, r6, 0
bl nullsub_85
ldr r0, _08078D2C
adds r1, r6, 0
movs r2, 0
bl SetMessageArgument
adds r0, r4, 0
bl RoundUpFixedPoint
adds r4, r0, 0
ldr r0, [r5]
bl RoundUpFixedPoint
cmp r4, r0
bne _08078D34
mov r1, r8
cmp r1, 0
beq _08078D72
ldr r0, _08078D30
b _08078D4E
.align 2, 0
_08078D28: .4byte 0x000003e7
_08078D2C: .4byte gAvailablePokemonNames
_08078D30: .4byte gUnknown_80FBE14
_08078D34:
ldr r0, [r5]
bl RoundUpFixedPoint
adds r4, r0, 0
ldr r0, [r7]
bl RoundUpFixedPoint
cmp r4, r0
blt _08078D60
mov r0, r8
cmp r0, 0
beq _08078D72
ldr r0, _08078D5C
_08078D4E:
ldr r2, [r0]
mov r0, r9
adds r1, r6, 0
bl sub_80522F4
b _08078D72
.align 2, 0
_08078D5C: .4byte gUnknown_80FBE64
_08078D60:
mov r1, r8
cmp r1, 0
beq _08078D72
ldr r0, _08078D88
ldr r2, [r0]
mov r0, r9
adds r1, r6, 0
bl sub_80522F4
_08078D72:
adds r0, r6, 0
bl DungeonEntityUpdateStatusSprites
_08078D78:
add sp, 0x28
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08078D88: .4byte gUnknown_80FBE84
thumb_func_end sub_8078B5C
.align 2,0