pokeemerald/asm/battle_pyramid.s
2018-11-17 15:30:34 +01:00

2422 lines
36 KiB
ArmAsm

.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_81A9834
sub_81A9834: @ 81A9834
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x18
movs r0, 0
str r0, [sp]
_081A9844:
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r2, [sp]
lsls r1, r2, 1
ldr r5, =0x00000caa
adds r0, r5
adds r0, r1
ldrh r0, [r0]
subs r5, r0, 0x1
movs r0, 0
str r0, [sp, 0x4]
movs r2, 0x64
adds r1, r5, 0
muls r1, r2
str r1, [sp, 0x8]
movs r0, 0x8E
lsls r0, 2
adds r6, r1, r0
movs r1, 0
str r1, [sp, 0x10]
_081A986C:
ldr r2, =gSaveBlock1Ptr
ldr r0, [r2]
adds r0, r6
movs r1, 0xB
movs r2, 0
bl GetMonData
adds r4, r0, 0
ldr r3, =gPlayerParty
ldr r1, [sp, 0x10]
adds r0, r1, r3
movs r1, 0xB
movs r2, 0
str r3, [sp, 0x14]
bl GetMonData
ldr r3, [sp, 0x14]
cmp r4, r0
bne _081A993C
movs r6, 0
adds r2, r5, 0x1
str r2, [sp, 0xC]
movs r1, 0x64
adds r0, r5, 0
muls r0, r1
movs r5, 0x8E
lsls r5, 2
adds r5, r0
mov r9, r5
ldr r7, [sp, 0x4]
muls r7, r1
mov r10, r3
_081A98AC:
movs r5, 0
adds r0, r6, 0x1
mov r8, r0
b _081A98C6
.pool
_081A98C4:
adds r5, 0x1
_081A98C6:
cmp r5, 0x3
bgt _081A98EE
ldr r1, =gSaveBlock1Ptr
ldr r0, [r1]
add r0, r9
adds r1, r5, 0
adds r1, 0xD
movs r2, 0
bl GetMonData
adds r4, r0, 0
adds r1, r6, 0
adds r1, 0xD
mov r2, r10
adds r0, r7, r2
movs r2, 0
bl GetMonData
cmp r4, r0
bne _081A98C4
_081A98EE:
cmp r5, 0x4
bne _081A9900
lsls r2, r6, 24
lsrs r2, 24
mov r5, r10
adds r0, r7, r5
movs r1, 0xA6
bl SetMonMoveSlot
_081A9900:
mov r6, r8
cmp r6, 0x3
ble _081A98AC
ldr r1, =gSaveBlock1Ptr
ldr r0, [r1]
ldr r2, [sp, 0x8]
adds r0, r2
movs r5, 0x8E
lsls r5, 2
adds r0, r5
ldr r1, =gPlayerParty
ldr r2, [sp, 0x10]
adds r1, r2, r1
movs r2, 0x64
bl memcpy
ldr r0, =gUnknown_0203CEF8
ldr r5, [sp, 0x4]
adds r0, r5, r0
mov r1, sp
ldrb r1, [r1, 0xC]
strb r1, [r0]
b _081A994C
.pool
_081A993C:
ldr r2, [sp, 0x10]
adds r2, 0x64
str r2, [sp, 0x10]
ldr r0, [sp, 0x4]
adds r0, 0x1
str r0, [sp, 0x4]
cmp r0, 0x2
ble _081A986C
_081A994C:
ldr r1, [sp]
adds r1, 0x1
str r1, [sp]
cmp r1, 0x2
bgt _081A9958
b _081A9844
_081A9958:
movs r2, 0
str r2, [sp]
ldr r4, =gSaveBlock2Ptr
ldr r3, =0x00000caa
ldr r2, =gUnknown_0203CEF8
_081A9962:
ldr r1, [r4]
ldr r5, [sp]
lsls r0, r5, 1
adds r1, r3
adds r1, r0
adds r0, r5, r2
ldrb r0, [r0]
strh r0, [r1]
adds r5, 0x1
str r5, [sp]
cmp r5, 0x2
ble _081A9962
add sp, 0x18
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81A9834
thumb_func_start sub_81A9998
sub_81A9998: @ 81A9998
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
mov r10, r0
lsls r1, 24
lsrs r6, r1, 24
lsls r2, 24
lsrs r7, r2, 24
movs r4, 0
ldr r0, =gUnknown_03005DC0
ldr r5, [r0, 0x8]
ldr r1, [r0]
lsls r0, r1, 3
subs r0, r1
lsls r0, 1
adds r0, 0xE
adds r5, r0
movs r3, 0
ldr r0, =0x000003ff
mov r8, r0
ldr r1, =0x0000028e
mov r12, r1
ldr r0, =gEventObjects
mov r9, r0
_081A99CC:
movs r2, 0
_081A99CE:
lsls r0, r2, 1
adds r0, r5
ldrh r1, [r0]
mov r0, r8
ands r0, r1
cmp r0, r12
bne _081A9A8A
adds r2, 0x7
ldr r0, =gSelectedEventObject
ldrb r1, [r0]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
add r0, r9
movs r5, 0xC
ldrsh r1, [r0, r5]
subs r2, r1
adds r1, r3, 0x7
movs r3, 0xE
ldrsh r0, [r0, r3]
subs r3, r1, r0
cmp r2, r6
bge _081A9A0E
negs r0, r6
cmp r2, r0
ble _081A9A0E
cmp r3, r6
bge _081A9A0E
cmp r3, r0
ble _081A9A0E
cmp r7, 0
bne _081A9A84
_081A9A0E:
cmp r2, 0
ble _081A9A34
cmp r3, 0
ble _081A9A34
movs r4, 0x3
cmp r2, r3
blt _081A9A7C
movs r4, 0x2
b _081A9A7C
.pool
_081A9A34:
cmp r2, 0
bge _081A9A46
cmp r3, 0
bge _081A9A46
movs r4, 0x1
cmp r2, r3
ble _081A9A7C
movs r4, 0
b _081A9A7C
_081A9A46:
cmp r2, 0
bne _081A9A54
movs r4, 0
cmp r3, 0
ble _081A9A7C
movs r4, 0x3
b _081A9A7C
_081A9A54:
cmp r3, 0
bne _081A9A62
movs r4, 0x1
cmp r2, 0
ble _081A9A7C
movs r4, 0x2
b _081A9A7C
_081A9A62:
cmp r2, 0
bge _081A9A72
adds r0, r2, r3
movs r4, 0x1
cmp r0, 0
ble _081A9A7C
movs r4, 0x3
b _081A9A7C
_081A9A72:
adds r0, r2, r3
mvns r0, r0
asrs r4, r0, 31
movs r0, 0x2
ands r4, r0
_081A9A7C:
movs r0, 0
mov r5, r10
str r0, [r5]
b _081A9A98
_081A9A84:
mov r0, r10
str r7, [r0]
b _081A9A98
_081A9A8A:
adds r2, 0x1
cmp r2, 0x1F
ble _081A99CE
adds r5, 0x5E
adds r3, 0x1
cmp r3, 0x1F
ble _081A99CC
_081A9A98:
adds r0, r4, 0
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_81A9998
thumb_func_start sub_81A9AA8
sub_81A9AA8: @ 81A9AA8
lsls r0, 24
ldr r1, =gSaveBlock2Ptr
ldr r1, [r1]
lsrs r0, 23
adds r1, r0
ldr r0, =0x00000cb2
adds r1, r0
ldrh r0, [r1]
bx lr
.pool
thumb_func_end sub_81A9AA8
thumb_func_start GetBattlePyramidTrainerFlag
GetBattlePyramidTrainerFlag: @ 81A9AC4
push {r4,lr}
lsls r0, 24
lsrs r0, 24
ldr r1, =gSaveBlock2Ptr
ldr r2, [r1]
ldr r1, =0x00000e2a
adds r2, r1
ldr r4, =gBitTable
ldr r3, =gEventObjects
lsls r1, r0, 3
adds r1, r0
lsls r1, 2
adds r1, r3
ldrb r0, [r1, 0x8]
subs r0, 0x1
lsls r0, 2
adds r0, r4
ldr r0, [r0]
ldrb r1, [r2]
ands r0, r1
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end GetBattlePyramidTrainerFlag
thumb_func_start sub_81A9B04
sub_81A9B04: @ 81A9B04
push {lr}
ldr r0, =gTrainerBattleOpponent_A
ldrh r0, [r0]
bl sub_81A9B44
ldr r0, =gBattleTypeFlags
ldr r0, [r0]
movs r1, 0x80
lsls r1, 8
ands r0, r1
cmp r0, 0
beq _081A9B2E
movs r0, 0x1
bl GetChosenApproachingTrainerEventObjectId
ldr r1, =gSelectedEventObject
strb r0, [r1]
ldr r0, =gTrainerBattleOpponent_B
ldrh r0, [r0]
bl sub_81A9B44
_081A9B2E:
pop {r0}
bx r0
.pool
thumb_func_end sub_81A9B04
thumb_func_start sub_81A9B44
sub_81A9B44: @ 81A9B44
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
lsls r0, 16
lsrs r5, r0, 16
movs r3, 0
ldr r0, =gEventObjects
mov r12, r0
ldr r6, =gSelectedEventObject
ldr r1, =gSaveBlock1Ptr
mov r10, r1
ldr r7, =gSaveBlock2Ptr
mov r9, r7
ldr r0, =0x00000cb4
mov r8, r0
ldr r4, =gBitTable
_081A9B68:
mov r1, r9
ldr r2, [r1]
lsls r0, r3, 1
mov r7, r8
adds r1, r2, r7
adds r1, r0
ldrh r0, [r1]
cmp r0, r5
bne _081A9B86
ldr r1, =0x00000e2a
adds r0, r2, r1
ldr r1, [r4]
ldrb r2, [r0]
orrs r1, r2
strb r1, [r0]
_081A9B86:
adds r4, 0x4
adds r3, 0x1
cmp r3, 0x7
ble _081A9B68
ldrb r1, [r6]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
add r0, r12
movs r3, 0x2
strb r3, [r0, 0x6]
mov r7, r10
ldr r2, [r7]
ldr r0, =gSpecialVar_LastTalked
ldrh r1, [r0]
subs r1, 0x1
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r2, r0
ldr r1, =0x00000c79
adds r2, r1
strb r3, [r2]
ldrb r1, [r6]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
add r0, r12
ldrh r1, [r0, 0x10]
strh r1, [r0, 0xC]
ldrb r1, [r6]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
add r0, r12
ldrh r1, [r0, 0x12]
strh r1, [r0, 0xE]
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81A9B44
thumb_func_start GenerateBattlePyramidWildMon
GenerateBattlePyramidWildMon: @ 81A9C04
push {r4-r6,lr}
sub sp, 0x14
ldr r0, =gSaveBlock2Ptr
ldr r1, [r0]
ldr r2, =0x00000ca9
adds r0, r1, r2
ldrb r0, [r0]
lsls r0, 30
lsrs r5, r0, 30
lsls r0, r5, 1
ldr r2, =0x00000e1a
adds r1, r2
adds r1, r0
ldrh r0, [r1]
movs r1, 0x7
bl __udivsi3
lsls r0, 16
lsrs r0, 16
movs r1, 0x14
bl __umodsi3
lsls r0, 16
lsrs r0, 16
cmp r0, 0x13
bls _081A9C3A
movs r0, 0x13
_081A9C3A:
cmp r5, 0
beq _081A9C54
ldr r1, =gBattlePyramidOpenLevelWildMonPointers
b _081A9C56
.pool
_081A9C54:
ldr r1, =gBattlePyramidLevel50WildMonPointers
_081A9C56:
lsls r0, 2
adds r0, r1
ldr r6, [r0]
ldr r4, =gEnemyParty
adds r0, r4, 0
movs r1, 0xB
movs r2, 0
bl GetMonData
subs r0, 0x1
str r0, [sp, 0x10]
lsls r2, r0, 1
adds r2, r0
lsls r2, 2
adds r2, r6, r2
adds r0, r4, 0
movs r1, 0xB
bl SetMonData
ldr r1, [sp, 0x10]
lsls r0, r1, 1
adds r0, r1
lsls r0, 2
adds r0, r6
ldrh r1, [r0]
mov r0, sp
bl GetSpeciesName
adds r0, r4, 0
movs r1, 0x2
mov r2, sp
bl SetMonData
cmp r5, 0
beq _081A9CD4
bl SetFacilityPtrsGetLevel
lsls r0, 24
lsrs r5, r0, 24
ldr r1, [sp, 0x10]
lsls r0, r1, 1
adds r0, r1
lsls r0, 2
adds r0, r6
ldrb r0, [r0, 0x2]
subs r5, r0
bl Random
lsls r0, 16
lsrs r0, 16
movs r1, 0xB
bl __umodsi3
lsls r0, 16
lsrs r0, 16
subs r0, 0x5
adds r5, r0
b _081A9CF6
.pool
_081A9CD4:
bl Random
ldr r2, [sp, 0x10]
lsls r1, r2, 1
adds r1, r2
lsls r1, 2
adds r1, r6
ldrb r4, [r1, 0x2]
lsls r0, 16
lsrs r0, 16
movs r1, 0xB
bl __umodsi3
lsls r0, 16
lsrs r0, 16
subs r0, 0x5
adds r5, r4, r0
_081A9CF6:
ldr r4, =gEnemyParty
ldr r2, =gBaseStats
ldr r1, [sp, 0x10]
lsls r0, r1, 1
adds r0, r1
lsls r0, 2
adds r0, r6
ldrh r1, [r0]
lsls r0, r1, 3
subs r0, r1
lsls r0, 2
adds r0, r2
ldrb r1, [r0, 0x13]
movs r0, 0xCA
lsls r0, 1
adds r2, r1, 0
muls r2, r0
lsls r0, r5, 2
ldr r1, =gExperienceTables
adds r0, r1
adds r2, r0
adds r0, r4, 0
movs r1, 0x19
bl SetMonData
ldr r1, [sp, 0x10]
lsls r0, r1, 1
adds r0, r1
lsls r0, 2
adds r0, r6
ldrb r1, [r0, 0x3]
cmp r1, 0
blt _081A9D4C
cmp r1, 0x1
bgt _081A9D4C
adds r2, r0, 0x3
b _081A9D7C
.pool
_081A9D4C:
ldr r2, =gBaseStats
ldr r1, [sp, 0x10]
lsls r0, r1, 1
adds r0, r1
lsls r0, 2
adds r0, r6
ldrh r1, [r0]
lsls r0, r1, 3
subs r0, r1
lsls r0, 2
adds r0, r2
ldrb r0, [r0, 0x17]
cmp r0, 0
beq _081A9D90
ldr r4, =gEnemyParty
adds r0, r4, 0
movs r1, 0
movs r2, 0
bl GetMonData
movs r1, 0x1
ands r1, r0
str r1, [sp, 0xC]
add r2, sp, 0xC
_081A9D7C:
adds r0, r4, 0
movs r1, 0x2E
bl SetMonData
b _081A9D9C
.pool
_081A9D90:
str r0, [sp, 0xC]
ldr r0, =gEnemyParty
add r2, sp, 0xC
movs r1, 0x2E
bl SetMonData
_081A9D9C:
movs r0, 0
str r0, [sp, 0xC]
movs r2, 0
lsls r4, r5, 1
_081A9DA4:
ldr r1, [sp, 0x10]
lsls r0, r1, 1
adds r0, r1
lsls r0, 2
adds r0, r6
lsls r1, r2, 1
adds r0, 0x4
adds r0, r1
ldrh r1, [r0]
lsls r2, 24
lsrs r2, 24
ldr r0, =gEnemyParty
bl SetMonMoveSlot
ldr r0, [sp, 0xC]
adds r0, 0x1
str r0, [sp, 0xC]
adds r2, r0, 0
cmp r2, 0x3
ble _081A9DA4
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r1, =0x00000e1a
adds r0, r1
adds r0, r4
ldrh r0, [r0]
cmp r0, 0x8B
bls _081A9E0C
bl Random
lsls r0, 16
lsrs r0, 16
movs r1, 0x11
bl __umodsi3
lsls r0, 16
lsrs r0, 16
adds r0, 0xF
str r0, [sp, 0x10]
movs r0, 0
str r0, [sp, 0xC]
_081A9DF6:
adds r1, r0, 0
adds r1, 0x27
ldr r0, =gEnemyParty
add r2, sp, 0x10
bl SetMonData
ldr r0, [sp, 0xC]
adds r0, 0x1
str r0, [sp, 0xC]
cmp r0, 0x5
ble _081A9DF6
_081A9E0C:
ldr r0, =gEnemyParty
bl CalculateMonStats
add sp, 0x14
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end GenerateBattlePyramidWildMon
thumb_func_start sub_81A9E28
sub_81A9E28: @ 81A9E28
push {lr}
bl sub_81AA9E4
lsls r0, 24
ldr r1, =gUnknown_08613650
lsrs r0, 20
adds r0, r1
ldrb r0, [r0, 0x4]
pop {r1}
bx r1
.pool
thumb_func_end sub_81A9E28
thumb_func_start InBattlePyramid
InBattlePyramid: @ 81A9E40
push {lr}
ldr r0, =gMapHeader
ldrh r1, [r0, 0x12]
ldr r0, =0x00000169
cmp r1, r0
bne _081A9E58
movs r0, 0x1
b _081A9E66
.pool
_081A9E58:
movs r0, 0xBD
lsls r0, 1
cmp r1, r0
beq _081A9E64
movs r0, 0
b _081A9E66
_081A9E64:
movs r0, 0x2
_081A9E66:
pop {r1}
bx r1
thumb_func_end InBattlePyramid
thumb_func_start sub_81A9E6C
sub_81A9E6C: @ 81A9E6C
push {lr}
movs r2, 0
ldr r0, =gMapHeader
ldrh r1, [r0, 0x12]
ldr r0, =0x00000169
cmp r1, r0
beq _081A9E80
adds r0, 0x11
cmp r1, r0
bne _081A9E82
_081A9E80:
movs r2, 0x1
_081A9E82:
adds r0, r2, 0
pop {r1}
bx r1
.pool
thumb_func_end sub_81A9E6C
thumb_func_start sub_81A9E90
sub_81A9E90: @ 81A9E90
push {lr}
bl InBattlePyramid
lsls r0, 24
cmp r0, 0
beq _081A9EB8
bl sub_81A9834
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r1, =0x00000ca8
adds r0, r1
movs r1, 0x2
strb r1, [r0]
ldr r0, =0x0000400e
movs r1, 0
bl VarSet
bl LoadPlayerParty
_081A9EB8:
pop {r0}
bx r0
.pool
thumb_func_end sub_81A9E90
thumb_func_start sub_81A9EC8
sub_81A9EC8: @ 81A9EC8
push {lr}
bl InBattlePyramid
lsls r0, 24
cmp r0, 0
beq _081A9ED8
bl DoSoftReset
_081A9ED8:
pop {r0}
bx r0
thumb_func_end sub_81A9EC8
thumb_func_start sub_81A9EDC
sub_81A9EDC: @ 81A9EDC
push {lr}
lsls r0, 16
lsrs r0, 16
ldr r2, =gFacilityTrainers
movs r1, 0x34
muls r1, r0
ldr r0, [r2]
adds r0, r1
adds r0, 0xC
bl FrontierSpeechToString
pop {r0}
bx r0
.pool
thumb_func_end sub_81A9EDC
thumb_func_start sub_81A9EFC
sub_81A9EFC: @ 81A9EFC
push {lr}
lsls r0, 16
lsrs r0, 16
ldr r2, =gFacilityTrainers
movs r1, 0x34
muls r1, r0
ldr r0, [r2]
adds r0, r1
adds r0, 0x18
bl FrontierSpeechToString
pop {r0}
bx r0
.pool
thumb_func_end sub_81A9EFC
thumb_func_start sub_81A9F1C
sub_81A9F1C: @ 81A9F1C
push {lr}
lsls r0, 16
lsrs r0, 16
ldr r2, =gFacilityTrainers
movs r1, 0x34
muls r1, r0
ldr r0, [r2]
adds r0, r1
adds r0, 0x24
bl FrontierSpeechToString
pop {r0}
bx r0
.pool
thumb_func_end sub_81A9F1C
thumb_func_start GetTrainerEncounterMusicIdInBattlePyramind
GetTrainerEncounterMusicIdInBattlePyramind: @ 81A9F3C
push {r4,lr}
lsls r0, 16
lsrs r0, 16
movs r4, 0
ldr r3, =gFacilityClassToTrainerClass
ldr r1, =gFacilityTrainers
ldr r2, [r1]
movs r1, 0x34
muls r0, r1
adds r0, r2
ldrb r0, [r0]
adds r0, r3
ldrb r2, [r0]
ldr r1, =gUnknown_08613B44
_081A9F58:
ldrb r0, [r1]
cmp r0, r2
bne _081A9F70
ldrb r0, [r1, 0x1]
b _081A9F7A
.pool
_081A9F70:
adds r1, 0x4
adds r4, 0x1
cmp r4, 0x35
bls _081A9F58
movs r0, 0
_081A9F7A:
pop {r4}
pop {r1}
bx r1
thumb_func_end GetTrainerEncounterMusicIdInBattlePyramind
thumb_func_start sub_81A9F80
sub_81A9F80: @ 81A9F80
push {lr}
ldr r0, =BattleFrontier_BattlePyramidEmptySquare_EventScript_252C88
bl ScriptContext1_SetupScript
pop {r0}
bx r0
.pool
thumb_func_end sub_81A9F80
thumb_func_start sub_81A9F90
sub_81A9F90: @ 81A9F90
push {r4-r7,lr}
mov r7, r8
push {r7}
lsls r0, 24
lsrs r5, r0, 24
ldr r0, =gSaveBlock2Ptr
ldr r4, [r0]
ldr r1, =0x00000ca9
adds r0, r4, r1
ldrb r1, [r0]
lsls r1, 30
lsrs r1, 29
ldr r2, =0x00000e1a
adds r0, r4, r2
adds r0, r1
ldrh r0, [r0]
movs r1, 0x7
bl __udivsi3
lsls r0, 16
lsrs r0, 16
ldr r1, =0x00000cb2
adds r4, r1
ldrh r1, [r4]
cmp r1, 0x7
bne _081AA020
adds r0, 0x1
lsls r7, r0, 24
lsls r1, 24
mov r8, r1
_081A9FCC:
lsrs r0, r7, 24
mov r2, r8
lsrs r1, r2, 24
bl sub_8162548
lsls r0, 16
lsrs r3, r0, 16
movs r2, 0
cmp r2, r5
bge _081AA004
ldr r1, =gSaveBlock2Ptr
ldr r0, [r1]
ldr r4, =0x00000cb4
adds r0, r4
ldrh r0, [r0]
cmp r0, r3
beq _081AA004
adds r6, r1, 0
_081A9FF0:
adds r2, 0x1
cmp r2, r5
bge _081AA004
ldr r0, [r6]
lsls r1, r2, 1
adds r0, r4
adds r0, r1
ldrh r0, [r0]
cmp r0, r3
bne _081A9FF0
_081AA004:
cmp r2, r5
bne _081A9FCC
b _081AA062
.pool
_081AA020:
lsls r1, 24
mov r8, r1
lsls r7, r0, 24
_081AA026:
lsrs r0, r7, 24
mov r2, r8
lsrs r1, r2, 24
bl sub_8162548
lsls r0, 16
lsrs r3, r0, 16
movs r2, 0
cmp r2, r5
bge _081AA05E
ldr r1, =gSaveBlock2Ptr
ldr r0, [r1]
ldr r4, =0x00000cb4
adds r0, r4
ldrh r0, [r0]
cmp r0, r3
beq _081AA05E
adds r6, r1, 0
_081AA04A:
adds r2, 0x1
cmp r2, r5
bge _081AA05E
ldr r0, [r6]
lsls r1, r2, 1
adds r0, r4
adds r0, r1
ldrh r0, [r0]
cmp r0, r3
bne _081AA04A
_081AA05E:
cmp r2, r5
bne _081AA026
_081AA062:
adds r0, r3, 0
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
.pool
thumb_func_end sub_81A9F90
thumb_func_start sub_81AA078
sub_81AA078: @ 81AA078
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x1C
str r0, [sp, 0x4]
lsls r1, 24
lsrs r1, 24
str r1, [sp, 0x8]
movs r0, 0x10
bl AllocZeroed
str r0, [sp, 0xC]
bl sub_81AA96C
mov r4, sp
adds r4, 0x1
mov r0, sp
adds r1, r4, 0
bl sub_81AA33C
movs r7, 0
_081AA0A6:
ldr r1, [sp, 0xC]
adds r0, r1, r7
ldrb r0, [r0]
ldr r2, =0x00000169
adds r0, r2
lsls r0, 2
ldr r1, =gMapLayouts
adds r0, r1
ldr r6, [r0]
ldr r2, [r6, 0xC]
mov r10, r2
ldr r0, [sp, 0x4]
ldr r1, =gUnknown_03005DC0
str r0, [r1, 0x8]
ldr r0, [r6]
lsls r0, 2
adds r2, r0, 0
adds r2, 0xF
str r2, [r1]
ldr r0, [r6, 0x4]
lsls r0, 2
adds r0, 0xE
str r0, [r1, 0x4]
ldr r0, [sp, 0x4]
mov r9, r0
adds r1, r7, 0
cmp r7, 0
bge _081AA0E0
adds r1, r7, 0x3
_081AA0E0:
asrs r1, 2
ldr r4, [r6, 0x4]
adds r0, r1, 0
muls r0, r4
adds r0, 0x7
muls r2, r0
lsls r1, 2
subs r1, r7, r1
ldr r3, [r6]
adds r0, r1, 0
muls r0, r3
adds r0, 0x7
adds r2, r0
lsls r2, 1
add r9, r2
movs r1, 0
mov r8, r1
adds r2, r7, 0x1
str r2, [sp, 0x10]
cmp r8, r4
bge _081AA1B6
_081AA10A:
movs r0, 0
mov r12, r0
mov r1, r8
adds r1, 0x1
str r1, [sp, 0x14]
cmp r12, r3
bge _081AA1A2
ldr r2, =gSaveBlock1Ptr
str r2, [sp, 0x18]
mov r4, r9
mov r5, r10
_081AA120:
ldrh r1, [r5]
ldr r0, =0x000003ff
ands r0, r1
ldr r2, =0x0000028e
cmp r0, r2
bne _081AA194
mov r0, sp
ldrb r0, [r0, 0x1]
cmp r7, r0
beq _081AA194
mov r0, sp
ldrb r0, [r0]
cmp r7, r0
bne _081AA164
ldr r1, [sp, 0x8]
cmp r1, 0
bne _081AA164
ldr r2, [sp, 0x18]
ldr r3, [r2]
adds r2, r7, 0
cmp r7, 0
bge _081AA14E
adds r2, r7, 0x3
_081AA14E:
asrs r2, 2
lsls r1, r2, 2
subs r1, r7, r1
ldr r0, [r6]
muls r0, r1
add r0, r12
strh r0, [r3]
ldr r0, [r6, 0x4]
muls r0, r2
add r0, r8
strh r0, [r3, 0x2]
_081AA164:
ldrh r0, [r5]
movs r1, 0xFC
lsls r1, 8
ands r1, r0
ldr r2, =0x0000028d
adds r0, r2, 0
orrs r1, r0
strh r1, [r4]
ldr r3, [r6]
b _081AA196
.pool
_081AA194:
strh r1, [r4]
_081AA196:
adds r4, 0x2
adds r5, 0x2
movs r0, 0x1
add r12, r0
cmp r12, r3
blt _081AA120
_081AA1A2:
lsls r0, r3, 3
adds r0, 0x1E
add r9, r0
lsls r0, r3, 1
add r10, r0
ldr r1, [sp, 0x14]
mov r8, r1
ldr r0, [r6, 0x4]
cmp r8, r0
blt _081AA10A
_081AA1B6:
ldr r7, [sp, 0x10]
cmp r7, 0xF
bgt _081AA1BE
b _081AA0A6
_081AA1BE:
bl mapheader_run_script_with_tag_x1
ldr r0, [sp, 0xC]
bl Free
add sp, 0x1C
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_81AA078
thumb_func_start sub_81AA1D8
sub_81AA1D8: @ 81AA1D8
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0x8
movs r5, 0
mov r6, sp
adds r6, 0x1
add r0, sp, 0x4
mov r8, r0
ldr r4, =gSaveBlock2Ptr
ldr r3, =0x00000cb4
ldr r0, =0x0000ffff
adds r2, r0, 0
_081AA1F2:
ldr r0, [r4]
lsls r1, r5, 1
adds r0, r3
adds r0, r1
ldrh r1, [r0]
orrs r1, r2
strh r1, [r0]
adds r5, 0x1
cmp r5, 0x7
ble _081AA1F2
bl sub_81AA9E4
lsls r0, 24
lsrs r7, r0, 24
mov r0, sp
adds r1, r6, 0
bl sub_81AA33C
movs r0, 0
str r0, [sp, 0x4]
ldr r0, =gSaveBlock1Ptr
ldr r1, [r0]
movs r0, 0xC7
lsls r0, 4
adds r1, r0
ldr r2, =0x05000180
mov r0, r8
bl CpuSet
movs r5, 0
_081AA22E:
cmp r5, 0
bne _081AA254
ldr r1, =gUnknown_08613650
lsls r0, r7, 4
adds r0, r1
ldrb r0, [r0, 0x3]
b _081AA25C
.pool
_081AA254:
ldr r1, =gUnknown_08613650
lsls r0, r7, 4
adds r0, r1
ldrb r0, [r0, 0x2]
_081AA25C:
cmp r0, 0x4
bhi _081AA2E4
lsls r0, 2
ldr r1, =_081AA274
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_081AA274:
.4byte _081AA288
.4byte _081AA292
.4byte _081AA2A2
.4byte _081AA2B0
.4byte _081AA2CC
_081AA288:
lsls r0, r5, 24
lsrs r0, 24
bl sub_81AA398
b _081AA2E4
_081AA292:
lsls r0, r5, 24
lsrs r4, r0, 24
mov r0, sp
ldrb r1, [r0]
adds r0, r4, 0
bl sub_81AA4D8
b _081AA2BE
_081AA2A2:
lsls r0, r5, 24
lsrs r4, r0, 24
ldrb r1, [r6]
adds r0, r4, 0
bl sub_81AA4D8
b _081AA2BE
_081AA2B0:
lsls r0, r5, 24
lsrs r4, r0, 24
mov r0, sp
ldrb r1, [r0]
adds r0, r4, 0
bl sub_81AA648
_081AA2BE:
lsls r0, 24
cmp r0, 0
beq _081AA2E4
adds r0, r4, 0
bl sub_81AA398
b _081AA2E4
_081AA2CC:
lsls r0, r5, 24
lsrs r4, r0, 24
ldrb r1, [r6]
adds r0, r4, 0
bl sub_81AA648
lsls r0, 24
cmp r0, 0
beq _081AA2E4
adds r0, r4, 0
bl sub_81AA398
_081AA2E4:
adds r5, 0x1
cmp r5, 0x1
ble _081AA22E
add sp, 0x8
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_81AA1D8
thumb_func_start sub_81AA2F8
sub_81AA2F8: @ 81AA2F8
push {r4,r5,lr}
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r5, =BattleFrontier_BattlePyramidEmptySquare_EventScript_252C4F
ldr r4, =BattleFrontier_BattlePyramidEmptySquare_EventScript_252C6A
movs r2, 0xC8
lsls r2, 4
adds r1, r0, r2
movs r3, 0xC7
lsls r3, 4
adds r2, r0, r3
movs r3, 0x3F
_081AA310:
ldrb r0, [r2, 0x1]
cmp r0, 0x3B
beq _081AA328
str r5, [r1]
b _081AA32A
.pool
_081AA328:
str r4, [r1]
_081AA32A:
adds r1, 0x18
adds r2, 0x18
subs r3, 0x1
cmp r3, 0
bge _081AA310
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_81AA2F8
thumb_func_start sub_81AA33C
sub_81AA33C: @ 81AA33C
push {r4-r7,lr}
adds r4, r0, 0
adds r6, r1, 0
ldr r5, =gSaveBlock2Ptr
ldr r1, [r5]
ldr r2, =0x00000e28
adds r0, r1, r2
ldrh r2, [r0]
movs r3, 0xF
ands r2, r3
strb r2, [r4]
ldr r7, =0x00000e22
adds r1, r7
ldrh r0, [r1]
ands r0, r3
strb r0, [r6]
cmp r2, r0
bne _081AA386
ldr r1, [r5]
ldr r2, =0x00000e28
adds r0, r1, r2
ldrh r2, [r0]
adds r3, r2, 0x1
adds r0, r3, 0
asrs r0, 4
lsls r0, 4
subs r0, r3, r0
strb r0, [r4]
adds r0, r1, r7
ldrh r1, [r0]
adds r2, r1, 0
adds r2, 0xF
adds r0, r2, 0
asrs r0, 4
lsls r0, 4
subs r0, r2, r0
strb r0, [r6]
_081AA386:
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81AA33C
thumb_func_start sub_81AA398
sub_81AA398: @ 81AA398
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0xC
lsls r0, 24
lsrs r0, 24
str r0, [sp]
movs r5, 0
bl sub_81AA9E4
lsls r0, 24
lsrs r6, r0, 24
movs r0, 0x10
bl AllocZeroed
str r0, [sp, 0x8]
bl sub_81AA96C
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r1, =0x00000e26
adds r0, r1
ldrh r4, [r0]
movs r0, 0xF
ands r4, r0
ldr r0, [sp]
cmp r0, 0
bne _081AA3F0
ldr r1, =gUnknown_08613650
lsls r0, r6, 4
adds r0, r1
ldrb r0, [r0, 0x1]
mov r10, r0
movs r1, 0
str r1, [sp, 0x4]
b _081AA3FE
.pool
_081AA3F0:
ldr r1, =gUnknown_08613650
lsls r0, r6, 4
adds r0, r1
ldrb r1, [r0]
mov r10, r1
ldrb r0, [r0, 0x1]
str r0, [sp, 0x4]
_081AA3FE:
movs r0, 0
mov r8, r0
cmp r8, r10
bge _081AA4C0
_081AA406:
movs r1, 0x1
add r1, r8
mov r9, r1
b _081AA42E
.pool
_081AA414:
lsls r2, r4, 24
lsrs r2, 24
ldr r3, [sp, 0x4]
add r3, r8
lsls r3, 24
lsrs r3, 24
ldr r0, [sp]
ldr r1, [sp, 0x8]
bl sub_81AA760
lsls r0, 24
cmp r0, 0
beq _081AA4B6
_081AA42E:
ldr r0, =gBitTable
mov r12, r0
ldr r6, =gSaveBlock2Ptr
ldr r7, =0x00000e28
movs r3, 0x2
lsls r0, r4, 2
mov r1, r12
adds r2, r0, r1
_081AA43E:
movs r0, 0x1
ands r0, r5
cmp r0, 0
beq _081AA464
ldr r0, [r6]
adds r0, r7
ldrh r1, [r0]
ldr r0, [r2]
ands r0, r1
cmp r0, 0
bne _081AA474
b _081AA472
.pool
_081AA464:
ldr r0, [r6]
adds r0, r7
ldrh r1, [r0]
ldr r0, [r2]
ands r0, r1
cmp r0, 0
beq _081AA474
_081AA472:
orrs r5, r3
_081AA474:
adds r2, 0x4
adds r4, 0x1
cmp r4, 0xF
ble _081AA480
mov r2, r12
movs r4, 0
_081AA480:
ldr r0, [r6]
ldr r1, =0x00000e26
adds r0, r1
ldrh r1, [r0]
movs r0, 0xF
ands r1, r0
cmp r4, r1
bne _081AA4A6
movs r1, 0x1
adds r0, r5, 0
ands r0, r1
cmp r0, 0
beq _081AA4A4
movs r0, 0x6
orrs r5, r0
b _081AA4A6
.pool
_081AA4A4:
orrs r5, r1
_081AA4A6:
adds r0, r5, 0
ands r0, r3
cmp r0, 0
beq _081AA43E
movs r0, 0x4
ands r0, r5
cmp r0, 0
beq _081AA414
_081AA4B6:
movs r0, 0x1
ands r5, r0
mov r8, r9
cmp r8, r10
blt _081AA406
_081AA4C0:
ldr r0, [sp, 0x8]
bl Free
add sp, 0xC
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_81AA398
thumb_func_start sub_81AA4D8
sub_81AA4D8: @ 81AA4D8
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x20
lsls r0, 24
lsrs r0, 24
str r0, [sp]
lsls r1, 24
lsrs r1, 24
str r1, [sp, 0x4]
movs r6, 0
movs r7, 0
movs r0, 0
str r0, [sp, 0xC]
bl sub_81AA9E4
lsls r0, 24
lsrs r4, r0, 24
movs r0, 0x10
bl AllocZeroed
str r0, [sp, 0x14]
bl sub_81AA96C
ldr r1, [sp]
cmp r1, 0
bne _081AA524
ldr r1, =gUnknown_08613650
lsls r0, r4, 4
adds r0, r1
ldrb r0, [r0, 0x1]
str r0, [sp, 0x10]
movs r0, 0
b _081AA530
.pool
_081AA524:
ldr r1, =gUnknown_08613650
lsls r0, r4, 4
adds r0, r1
ldrb r2, [r0]
str r2, [sp, 0x10]
ldrb r0, [r0, 0x1]
_081AA530:
movs r3, 0
str r3, [sp, 0x8]
ldr r1, [sp, 0x10]
asrs r1, 31
str r1, [sp, 0x18]
ldr r2, [sp, 0x10]
cmp r3, r2
bge _081AA622
str r0, [sp, 0x1C]
adds r3, r0, 0
lsls r3, 24
mov r9, r3
_081AA548:
cmp r7, 0
bne _081AA56E
mov r0, r9
lsrs r3, r0, 24
ldr r0, [sp]
ldr r1, [sp, 0x14]
ldr r2, [sp, 0x4]
bl sub_81AA760
lsls r0, 24
cmp r0, 0
beq _081AA568
movs r7, 0x1
b _081AA56E
.pool
_081AA568:
ldr r1, [sp, 0xC]
adds r1, 0x1
str r1, [sp, 0xC]
_081AA56E:
movs r0, 0x1
ands r0, r7
cmp r0, 0
beq _081AA600
ldr r2, =gUnknown_08613F46
mov r8, r2
ldr r3, [sp, 0x4]
lsls r4, r3, 2
adds r0, r6, r4
add r0, r8
ldrb r2, [r0]
mov r0, r9
lsrs r3, r0, 24
ldr r0, [sp]
ldr r1, [sp, 0x14]
bl sub_81AA760
lsls r0, 24
ldr r1, [sp, 0x1C]
mov r10, r1
adds r5, r4, 0
cmp r0, 0
beq _081AA5E8
ldr r4, [sp, 0xC]
adds r4, 0x1
b _081AA5C2
.pool
_081AA5A8:
adds r0, r6, r5
adds r0, r2
ldrb r2, [r0]
mov r0, r10
lsls r3, r0, 24
lsrs r3, 24
ldr r0, [sp]
ldr r1, [sp, 0x14]
bl sub_81AA760
lsls r0, 24
cmp r0, 0
beq _081AA5E0
_081AA5C2:
adds r6, 0x1
ldr r0, =gUnknown_08613F46
adds r1, r6, r5
adds r1, r0
ldrb r1, [r1]
adds r2, r0, 0
cmp r1, 0xFF
beq _081AA5D6
cmp r6, 0x3
ble _081AA5D8
_081AA5D6:
movs r6, 0
_081AA5D8:
adds r7, 0x2
asrs r0, r7, 1
cmp r0, 0x4
bne _081AA5A8
_081AA5E0:
str r4, [sp, 0xC]
b _081AA600
.pool
_081AA5E8:
adds r6, 0x1
adds r0, r6, r4
add r0, r8
ldrb r0, [r0]
cmp r0, 0xFF
beq _081AA5F8
cmp r6, 0x3
ble _081AA5FA
_081AA5F8:
movs r6, 0
_081AA5FA:
ldr r1, [sp, 0xC]
adds r1, 0x1
str r1, [sp, 0xC]
_081AA600:
asrs r0, r7, 1
cmp r0, 0x4
beq _081AA622
movs r0, 0x1
ands r7, r0
ldr r2, [sp, 0x1C]
adds r2, 0x1
str r2, [sp, 0x1C]
movs r3, 0x80
lsls r3, 17
add r9, r3
ldr r0, [sp, 0x8]
adds r0, 0x1
str r0, [sp, 0x8]
ldr r1, [sp, 0x10]
cmp r0, r1
blt _081AA548
_081AA622:
movs r1, 0
ldr r2, [sp, 0x10]
ldr r3, [sp, 0x18]
subs r0, r2, r3
asrs r0, 1
ldr r2, [sp, 0xC]
cmp r0, r2
ble _081AA634
movs r1, 0x1
_081AA634:
adds r0, r1, 0
add sp, 0x20
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_81AA4D8
thumb_func_start sub_81AA648
sub_81AA648: @ 81AA648
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x10
lsls r0, 24
lsrs r0, 24
str r0, [sp]
lsls r1, 24
lsrs r6, r1, 24
movs r4, 0
movs r7, 0
movs r0, 0
mov r8, r0
bl sub_81AA9E4
lsls r0, 24
lsrs r5, r0, 24
movs r0, 0x10
bl AllocZeroed
str r0, [sp, 0x8]
bl sub_81AA96C
ldr r1, [sp]
cmp r1, 0
bne _081AA694
ldr r1, =gUnknown_08613650
lsls r0, r5, 4
adds r0, r1
ldrb r0, [r0, 0x1]
mov r10, r0
movs r0, 0
b _081AA6A0
.pool
_081AA694:
ldr r1, =gUnknown_08613650
lsls r0, r5, 4
adds r0, r1
ldrb r2, [r0]
mov r10, r2
ldrb r0, [r0, 0x1]
_081AA6A0:
movs r3, 0
str r3, [sp, 0x4]
mov r1, r10
asrs r1, 31
str r1, [sp, 0xC]
cmp r3, r10
bge _081AA73E
ldr r2, =gUnknown_08613F46
mov r9, r2
lsls r5, r6, 2
lsls r6, r0, 24
_081AA6B6:
adds r0, r4, r5
add r0, r9
ldrb r2, [r0]
lsrs r3, r6, 24
ldr r0, [sp]
ldr r1, [sp, 0x8]
bl sub_81AA760
lsls r0, 24
cmp r0, 0
beq _081AA714
adds r7, 0x1
b _081AA6EE
.pool
_081AA6D8:
adds r0, r4, r5
adds r0, r1
ldrb r2, [r0]
lsrs r3, r6, 24
ldr r0, [sp]
ldr r1, [sp, 0x8]
bl sub_81AA760
lsls r0, 24
cmp r0, 0
beq _081AA728
_081AA6EE:
adds r4, 0x1
adds r0, r4, r5
add r0, r9
ldrb r0, [r0]
ldr r1, =gUnknown_08613F46
cmp r0, 0xFF
beq _081AA700
cmp r4, 0x3
ble _081AA702
_081AA700:
movs r4, 0
_081AA702:
movs r3, 0x1
add r8, r3
mov r0, r8
cmp r0, 0x4
bne _081AA6D8
b _081AA728
.pool
_081AA714:
adds r4, 0x1
adds r0, r4, r5
add r0, r9
ldrb r0, [r0]
cmp r0, 0xFF
beq _081AA724
cmp r4, 0x3
ble _081AA726
_081AA724:
movs r4, 0
_081AA726:
adds r7, 0x1
_081AA728:
mov r1, r8
cmp r1, 0x4
beq _081AA73E
movs r2, 0x80
lsls r2, 17
adds r6, r2
ldr r3, [sp, 0x4]
adds r3, 0x1
str r3, [sp, 0x4]
cmp r3, r10
blt _081AA6B6
_081AA73E:
movs r1, 0
mov r2, r10
ldr r3, [sp, 0xC]
subs r0, r2, r3
asrs r0, 1
cmp r0, r7
ble _081AA74E
movs r1, 0x1
_081AA74E:
adds r0, r1, 0
add sp, 0x10
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_81AA648
thumb_func_start sub_81AA760
sub_81AA760: @ 81AA760
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x8
mov r10, r1
lsls r0, 24
lsrs r0, 24
mov r9, r0
lsls r2, 24
lsrs r2, 24
mov r8, r2
lsls r3, 24
lsrs r7, r3, 24
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r1, =0x00000e22
adds r0, r1
ldrh r1, [r0]
movs r0, 0x1
ands r0, r1
cmp r0, 0
beq _081AA7D0
movs r6, 0x7
_081AA792:
movs r4, 0x7
lsls r5, r6, 24
_081AA796:
lsls r1, r4, 24
lsrs r1, 24
mov r0, r8
str r0, [sp]
str r7, [sp, 0x4]
mov r0, r9
lsrs r2, r5, 24
mov r3, r10
bl sub_81AA810
lsls r0, 24
cmp r0, 0
beq _081AA7CC
subs r4, 0x1
cmp r4, 0
bge _081AA796
subs r6, 0x1
movs r1, 0x1
negs r1, r1
cmp r6, r1
bgt _081AA792
b _081AA7FC
.pool
_081AA7CC:
movs r0, 0
b _081AA7FE
_081AA7D0:
movs r6, 0
_081AA7D2:
movs r4, 0
lsls r5, r6, 24
_081AA7D6:
lsls r1, r4, 24
lsrs r1, 24
mov r0, r8
str r0, [sp]
str r7, [sp, 0x4]
mov r0, r9
lsrs r2, r5, 24
mov r3, r10
bl sub_81AA810
lsls r0, 24
cmp r0, 0
beq _081AA7CC
adds r4, 0x1
cmp r4, 0x7
ble _081AA7D6
adds r6, 0x1
cmp r6, 0x7
ble _081AA7D2
_081AA7FC:
movs r0, 0x1
_081AA7FE:
add sp, 0x8
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_81AA760
thumb_func_start sub_81AA810
sub_81AA810: @ 81AA810
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x14
ldr r4, [sp, 0x34]
ldr r5, [sp, 0x38]
lsls r0, 24
lsrs r0, 24
str r0, [sp]
lsls r1, 24
lsrs r1, 24
str r1, [sp, 0x4]
lsls r2, 24
lsrs r2, 24
mov r8, r2
lsls r4, 24
lsrs r4, 24
mov r10, r4
lsls r5, 24
lsrs r6, r5, 24
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
movs r1, 0xC7
lsls r1, 4
adds r1, r0, r1
str r1, [sp, 0x8]
add r3, r10
ldrb r1, [r3]
adds r1, 0x2C
movs r0, 0x19
bl Overworld_GetMapHeaderByGroupAndId
adds r5, r0, 0
movs r7, 0
ldr r1, [r5, 0x4]
ldrb r2, [r1]
cmp r7, r2
bge _081AA95A
movs r0, 0x3
ands r0, r4
lsls r0, 3
str r0, [sp, 0xC]
_081AA868:
ldr r1, [r1, 0x4]
lsls r2, r7, 1
adds r0, r2, r7
lsls r0, 3
adds r3, r0, r1
movs r4, 0x4
ldrsh r0, [r3, r4]
ldr r1, [r5, 0x4]
mov r12, r1
mov r9, r2
ldr r2, [sp, 0x4]
cmp r0, r2
bne _081AA950
movs r4, 0x6
ldrsh r0, [r3, r4]
cmp r0, r8
bne _081AA950
ldr r0, [sp]
cmp r0, 0
bne _081AA896
ldrb r0, [r3, 0x1]
cmp r0, 0x3B
bne _081AA8A2
_081AA896:
ldr r1, [sp]
cmp r1, 0x1
bne _081AA950
ldrb r0, [r3, 0x1]
cmp r0, 0x3B
bne _081AA950
_081AA8A2:
movs r3, 0
ldr r2, [r5, 0x4]
mov r12, r2
cmp r3, r6
bge _081AA8DC
ldr r4, [sp, 0x4]
ldr r0, [sp, 0xC]
adds r4, r0
str r4, [sp, 0x10]
mov r1, r10
lsrs r0, r1, 2
lsls r0, 3
mov r2, r8
adds r1, r2, r0
ldr r2, [sp, 0x8]
adds r2, 0x4
_081AA8C2:
movs r4, 0
ldrsh r0, [r2, r4]
ldr r4, [sp, 0x10]
cmp r0, r4
bne _081AA8D4
movs r4, 0x2
ldrsh r0, [r2, r4]
cmp r0, r1
beq _081AA8DC
_081AA8D4:
adds r2, 0x18
adds r3, 0x1
cmp r3, r6
blt _081AA8C2
_081AA8DC:
cmp r3, r6
bne _081AA950
lsls r0, r6, 1
mov r8, r0
adds r0, r6
lsls r0, 3
ldr r1, [sp, 0x8]
adds r5, r0, r1
mov r3, r12
ldr r2, [r3, 0x4]
mov r4, r9
adds r1, r4, r7
lsls r1, 3
adds r0, r5, 0
adds r1, r2
ldm r1!, {r2-r4}
stm r0!, {r2-r4}
ldm r1!, {r2-r4}
stm r0!, {r2-r4}
ldrh r0, [r5, 0x4]
ldr r1, [sp, 0xC]
adds r0, r1
strh r0, [r5, 0x4]
mov r2, r10
lsrs r0, r2, 2
lsls r0, 3
ldrh r3, [r5, 0x6]
adds r0, r3
strh r0, [r5, 0x6]
adds r0, r6, 0x1
strb r0, [r5]
ldrb r0, [r5, 0x1]
cmp r0, 0x3B
beq _081AA940
adds r0, r6, 0
bl sub_81A9F90
lsls r0, 16
lsrs r7, r0, 16
adds r4, r7, 0
adds r0, r4, 0
bl GetBattleFacilityTrainerGfxId
strb r0, [r5, 0x1]
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r1, =0x00000cb4
adds r0, r1
add r0, r8
strh r4, [r0]
_081AA940:
movs r0, 0
b _081AA95C
.pool
_081AA950:
adds r7, 0x1
mov r1, r12
ldrb r2, [r1]
cmp r7, r2
blt _081AA868
_081AA95A:
movs r0, 0x1
_081AA95C:
add sp, 0x14
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_81AA810
thumb_func_start sub_81AA96C
sub_81AA96C: @ 81AA96C
push {r4-r7,lr}
adds r6, r0, 0
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r2, =0x00000e22
adds r1, r0, r2
ldrh r4, [r1]
ldr r1, =0x00000e24
adds r0, r1
ldrh r0, [r0]
lsls r0, 16
orrs r4, r0
bl sub_81AA9E4
lsls r0, 24
lsrs r5, r0, 24
movs r3, 0
ldr r2, =gUnknown_08613650+0x5
mov r12, r2
movs r7, 0x7
_081AA994:
adds r2, r6, r3
adds r0, r4, 0
ands r0, r7
lsls r1, r5, 4
adds r0, r1
add r0, r12
ldrb r0, [r0]
strb r0, [r2]
asrs r4, 3
cmp r3, 0x7
bne _081AA9C0
ldr r0, =gSaveBlock2Ptr
ldr r1, [r0]
ldr r2, =0x00000e26
adds r0, r1, r2
ldrh r4, [r0]
ldr r0, =0x00000e28
adds r1, r0
ldrh r0, [r1]
lsls r0, 16
orrs r4, r0
asrs r4, 8
_081AA9C0:
adds r3, 0x1
cmp r3, 0xF
ble _081AA994
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81AA96C
thumb_func_start sub_81AA9E4
sub_81AA9E4: @ 81AA9E4
push {r4,lr}
ldr r0, =gSaveBlock2Ptr
ldr r4, [r0]
ldr r1, =0x00000e28
adds r0, r4, r1
ldrh r0, [r0]
movs r1, 0x64
bl __umodsi3
lsls r0, 16
lsrs r3, r0, 16
ldr r0, =0x00000cb2
adds r4, r0
ldrh r0, [r4]
ldr r1, =gUnknown_08613794
adds r0, r1
ldrb r2, [r0]
cmp r2, 0x21
bhi _081AAA38
ldr r1, =gUnknown_08613750
lsls r0, r2, 1
adds r0, r1
_081AAA10:
ldrb r1, [r0]
cmp r3, r1
bge _081AAA30
ldrb r0, [r0, 0x1]
b _081AAA3A
.pool
_081AAA30:
adds r0, 0x2
adds r2, 0x1
cmp r2, 0x21
bls _081AAA10
_081AAA38:
movs r0, 0
_081AAA3A:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_81AA9E4
thumb_func_start sub_81AAA40
sub_81AAA40: @ 81AAA40
push {lr}
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
movs r1, 0xC7
lsls r1, 4
adds r2, r0, r1
movs r1, 0
movs r3, 0xC7
lsls r3, 4
adds r0, r3
b _081AAA6E
.pool
_081AAA5C:
adds r0, r1, 0x1
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0xF
bhi _081AAA74
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r2
_081AAA6E:
ldrb r0, [r0]
cmp r0, 0
bne _081AAA5C
_081AAA74:
adds r0, r1, 0
pop {r1}
bx r1
thumb_func_end sub_81AAA40
thumb_func_start sub_81AAA7C
sub_81AAA7C: @ 81AAA7C
push {r4-r7,lr}
mov r7, r8
push {r7}
lsls r0, 24
lsrs r0, 24
movs r3, 0
ldr r1, =gSaveBlock2Ptr
mov r8, r1
lsls r1, r0, 2
adds r1, r0
movs r0, 0
mov r12, r0
lsls r4, r1, 1
ldr r7, =0x00000e2c
movs r6, 0
ldr r5, =0x00000e54
lsls r2, r1, 2
_081AAA9E:
mov r1, r8
ldr r0, [r1]
adds r1, r0, r7
adds r1, r2
strh r6, [r1]
adds r1, r3, r4
adds r0, r5
adds r0, r1
mov r1, r12
strb r1, [r0]
adds r2, 0x2
adds r3, 0x1
cmp r3, 0x9
ble _081AAA9E
movs r0, 0x15
movs r1, 0x1
bl AddPyramidBagItem
movs r0, 0x22
movs r1, 0x1
bl AddPyramidBagItem
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81AAA7C
thumb_func_start GetBattlePyramidPickupItemId
GetBattlePyramidPickupItemId: @ 81AAAE0
push {r4-r6,lr}
ldr r0, =gSaveBlock2Ptr
ldr r1, [r0]
ldr r2, =0x00000ca9
adds r0, r1, r2
ldrb r0, [r0]
lsls r0, 30
lsrs r6, r0, 30
lsls r0, r6, 1
ldr r2, =0x00000e1a
adds r1, r2
adds r1, r0
ldrh r0, [r1]
movs r1, 0x7
bl __udivsi3
lsls r0, 16
lsrs r4, r0, 16
cmp r4, 0x13
ble _081AAB0A
movs r4, 0x13
_081AAB0A:
bl Random
lsls r0, 16
lsrs r0, 16
movs r1, 0x64
bl __umodsi3
lsls r0, 16
lsrs r2, r0, 16
movs r1, 0
ldr r3, =gUnknown_08613F86
ldrb r0, [r3]
lsls r5, r4, 2
cmp r0, r2
bgt _081AAB36
_081AAB28:
adds r1, 0x1
cmp r1, 0x9
bhi _081AAB3A
adds r0, r1, r3
ldrb r0, [r0]
cmp r0, r2
ble _081AAB28
_081AAB36:
cmp r1, 0x9
bls _081AAB3C
_081AAB3A:
movs r1, 0x9
_081AAB3C:
cmp r6, 0
bne _081AAB58
ldr r2, =sPickupItemsLvl50
b _081AAB5A
.pool
_081AAB58:
ldr r2, =sPickupItemsLvlOpen
_081AAB5A:
lsls r1, 1
adds r0, r5, r4
lsls r0, 2
adds r1, r0
adds r1, r2
ldrh r0, [r1]
pop {r4-r6}
pop {r1}
bx r1
.pool
thumb_func_end GetBattlePyramidPickupItemId
.align 2, 0 @ Don't pad with nop.