pmd-red/asm/dungeon_2.s
2024-10-31 14:04:53 +01:00

601 lines
9.2 KiB
ArmAsm

#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_809034C
sub_809034C:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0xF8
adds r7, r2, 0
ldr r2, [sp, 0x118]
lsls r0, 24
lsrs r0, 24
mov r9, r0
lsls r1, 16
asrs r1, 16
str r1, [sp, 0xE0]
lsls r3, 24
lsrs r3, 24
str r3, [sp, 0xE4]
lsls r2, 24
lsrs r2, 24
str r2, [sp, 0xE8]
bl GetNumberOfFilledInventorySlots
str r0, [sp, 0xEC]
movs r5, 0
movs r0, 0
str r0, [sp, 0xF4]
mov r8, r0
add r4, sp, 0xC8
movs r0, 0xA
strb r0, [r4]
add r1, sp, 0xF4
ldrb r1, [r1]
strb r1, [r4, 0x1]
ldr r1, _0809040C
adds r0, r7, 0
bl strcpy
movs r2, 0
str r2, [sp, 0xF0]
movs r3, 0
ldr r0, _08090410
ldr r6, [r0]
movs r4, 0x1
_080903A2:
movs r0, 0x58
muls r0, r3
adds r2, r6, r0
ldrh r1, [r2]
adds r0, r4, 0
ands r0, r1
cmp r0, 0
beq _080903D0
lsrs r0, r1, 1
ands r0, r4
cmp r0, 0
beq _080903D0
adds r0, r2, 0
adds r0, 0x28
ldrb r0, [r0]
cmp r0, 0
beq _080903CA
ldr r0, [sp, 0xF0]
adds r0, 0x1
str r0, [sp, 0xF0]
_080903CA:
adds r5, 0x1
cmp r5, 0x4
beq _080903DA
_080903D0:
adds r3, 0x1
movs r0, 0xCE
lsls r0, 1
cmp r3, r0
ble _080903A2
_080903DA:
ldr r0, _08090414
mov r2, r9
lsls r1, r2, 4
adds r0, r1, r0
ldrb r0, [r0, 0x5]
mov r9, r1
ldr r1, [sp, 0xE4]
cmp r1, 0
bne _080903F2
cmp r0, 0x3
ble _080903F2
movs r0, 0x3
_080903F2:
cmp r5, r0
ble _0809043C
cmp r0, 0x1
bne _0809041C
ldr r0, _08090418
ldr r0, [r0]
mov r1, sp
add r2, sp, 0xC8
movs r3, 0
bl FormatString
b _08090430
.align 2, 0
_0809040C: .4byte gUnknown_8108F40
_08090410: .4byte gRecruitedPokemonRef
_08090414: .4byte gDungeons
_08090418: .4byte gUnknown_8115A2C
_0809041C:
ldr r1, _08090464
subs r0, r5, r0
str r0, [r1]
ldr r0, _08090468
ldr r0, [r0]
mov r1, sp
add r2, sp, 0xC8
movs r3, 0
bl FormatString
_08090430:
adds r0, r7, 0
mov r1, sp
bl sub_8090888
movs r2, 0x1
mov r8, r2
_0809043C:
ldr r0, _0809046C
mov r2, r9
adds r1, r2, r0
ldrb r0, [r1, 0x4]
cmp r0, 0
beq _0809048E
ldr r1, [sp, 0xEC]
cmp r0, r1
bge _0809048E
ldr r1, _08090464
str r0, [r1]
ldr r2, [sp, 0xEC]
subs r0, r2, r0
str r0, [r1, 0x4]
mov r0, r8
cmp r0, 0
bne _08090474
ldr r0, _08090470
b _08090476
.align 2, 0
_08090464: .4byte gFormatArgs
_08090468: .4byte gUnknown_81159DC
_0809046C: .4byte gDungeons
_08090470: .4byte gUnknown_8115A80
_08090474:
ldr r0, _080904AC
_08090476:
ldr r0, [r0]
mov r1, sp
add r2, sp, 0xC8
movs r3, 0
bl FormatString
adds r0, r7, 0
mov r1, sp
bl sub_8090888
movs r1, 0x1
mov r8, r1
_0809048E:
ldr r2, [sp, 0xE0]
cmp r2, 0
beq _0809054E
ldr r0, _080904B0
adds r1, r2, 0
bl CopyCyanMonsterNametoBuffer
cmp r5, 0x3
ble _080904D2
mov r0, r8
cmp r0, 0
bne _080904B8
ldr r0, _080904B4
b _080904BA
.align 2, 0
_080904AC: .4byte gUnknown_8115ADC
_080904B0: .4byte gFormatBuffer_Monsters
_080904B4: .4byte gUnknown_8115B3C
_080904B8:
ldr r0, _08090528
_080904BA:
ldr r0, [r0]
mov r1, sp
add r2, sp, 0xC8
movs r3, 0
bl FormatString
adds r0, r7, 0
mov r1, sp
bl sub_8090888
movs r1, 0x1
mov r8, r1
_080904D2:
ldr r0, [sp, 0xE0]
bl GetBodySize
lsls r0, 24
lsrs r5, r0, 24
movs r4, 0
ldr r2, _0809052C
mov r10, r2
movs r6, 0x1
_080904E4:
movs r0, 0x58
adds r1, r4, 0
muls r1, r0
mov r2, r10
ldr r0, [r2]
adds r2, r0, r1
ldrh r1, [r2]
adds r0, r6, 0
ands r0, r1
cmp r0, 0
beq _08090510
lsrs r0, r1, 1
ands r0, r6
cmp r0, 0
beq _08090510
movs r1, 0x8
ldrsh r0, [r2, r1]
bl GetBodySize
lsls r0, 24
lsrs r0, 24
adds r5, r0
_08090510:
adds r4, 0x1
movs r0, 0xCE
lsls r0, 1
cmp r4, r0
ble _080904E4
cmp r5, 0x6
ble _0809054E
mov r2, r8
cmp r2, 0
bne _08090534
ldr r0, _08090530
b _08090536
.align 2, 0
_08090528: .4byte gUnknown_8115BA4
_0809052C: .4byte gRecruitedPokemonRef
_08090530: .4byte gUnknown_8115BF4
_08090534:
ldr r0, _080905D0
_08090536:
ldr r0, [r0]
mov r1, sp
add r2, sp, 0xC8
movs r3, 0
bl FormatString
adds r0, r7, 0
mov r1, sp
bl sub_8090888
movs r0, 0x1
mov r8, r0
_0809054E:
ldr r1, [sp, 0xE4]
cmp r1, 0
beq _08090602
add r5, sp, 0xCC
ldr r1, _080905D4
adds r0, r5, 0
movs r2, 0x8
bl memcpy
add r4, sp, 0xD4
ldr r1, _080905D8
adds r0, r4, 0
movs r2, 0x4
bl memcpy
movs r6, 0
mov r10, r4
ldr r0, _080905DC
add r0, r9
ldrb r5, [r0, 0xB]
add r4, sp, 0xCC
_08090578:
adds r0, r5, 0
asrs r0, r6
movs r1, 0x1
ands r0, r1
cmp r0, 0
beq _0809059E
ldrh r0, [r4]
bl sub_8090820
lsls r0, 24
cmp r0, 0
bne _0809059E
mov r2, r10
adds r0, r2, r6
ldrb r0, [r0]
bl GetItemPossessionCount
cmp r0, 0
beq _080905A6
_0809059E:
adds r4, 0x2
adds r6, 0x1
cmp r6, 0x3
ble _08090578
_080905A6:
cmp r6, 0x3
bgt _08090602
add r4, sp, 0xD8
lsls r0, r6, 1
add r0, sp
adds r0, 0xCC
ldrh r1, [r0]
adds r0, r4, 0
bl InitPokemonMove
ldr r0, _080905E0
adds r1, r4, 0
movs r2, 0
bl sub_80928C0
mov r0, r8
cmp r0, 0
bne _080905E8
ldr r0, _080905E4
b _080905EA
.align 2, 0
_080905D0: .4byte gUnknown_8115C4C
_080905D4: .4byte gUnknown_8108F42
_080905D8: .4byte gUnknown_8108F4A
_080905DC: .4byte gDungeons
_080905E0: .4byte gFormatBuffer_Items
_080905E4: .4byte gUnknown_8115CB8
_080905E8:
ldr r0, _080906A0
_080905EA:
ldr r0, [r0]
mov r1, sp
add r2, sp, 0xC8
movs r3, 0
bl FormatString
adds r0, r7, 0
mov r1, sp
bl sub_8090888
movs r1, 0x1
mov r8, r1
_08090602:
ldr r0, _080906A4
add r0, r9
ldrb r1, [r0, 0xB]
movs r0, 0x10
ands r0, r1
cmp r0, 0
beq _080906CE
ldr r5, _080906A8
ldr r2, [sp, 0xE0]
cmp r2, 0
beq _0809063A
adds r0, r2, 0
movs r1, 0
bl GetPokemonType
lsls r0, 24
lsrs r0, 24
cmp r0, 0x3
beq _08090638
ldr r0, [sp, 0xE0]
movs r1, 0x1
bl GetPokemonType
lsls r0, 24
lsrs r0, 24
cmp r0, 0x3
bne _0809063A
_08090638:
movs r5, 0
_0809063A:
ldr r0, _080906A8
cmp r5, r0
bne _080906CE
movs r5, 0
movs r6, 0x1
_08090644:
ldr r2, _080906AC
movs r0, 0x58
adds r1, r5, 0
muls r1, r0
ldr r0, [r2]
adds r4, r0, r1
ldrh r1, [r4]
adds r0, r6, 0
ands r0, r1
cmp r0, 0
beq _08090686
lsrs r0, r1, 1
ands r0, r6
cmp r0, 0
beq _08090686
movs r1, 0x8
ldrsh r0, [r4, r1]
movs r1, 0
bl GetPokemonType
lsls r0, 24
lsrs r0, 24
cmp r0, 0x3
beq _08090690
movs r2, 0x8
ldrsh r0, [r4, r2]
movs r1, 0x1
bl GetPokemonType
lsls r0, 24
lsrs r0, 24
cmp r0, 0x3
beq _08090690
_08090686:
adds r5, 0x1
movs r0, 0xCE
lsls r0, 1
cmp r5, r0
ble _08090644
_08090690:
ldr r0, _080906A8
cmp r5, r0
bne _080906CE
mov r0, r8
cmp r0, 0
bne _080906B4
ldr r0, _080906B0
b _080906B6
.align 2, 0
_080906A0: .4byte gUnknown_8115D14
_080906A4: .4byte gDungeons
_080906A8: .4byte 0x0000019d
_080906AC: .4byte gRecruitedPokemonRef
_080906B0: .4byte gUnknown_8115D5C
_080906B4:
ldr r0, _080906D8
_080906B6:
ldr r0, [r0]
mov r1, sp
add r2, sp, 0xC8
movs r3, 0
bl FormatString
adds r0, r7, 0
mov r1, sp
bl sub_8090888
movs r1, 0x1
mov r8, r1
_080906CE:
mov r2, r8
cmp r2, 0
beq _080906DC
movs r0, 0x1
b _0809080E
.align 2, 0
_080906D8: .4byte gUnknown_8115D94
_080906DC:
ldr r0, _080907EC
add r0, r9
ldrb r0, [r0, 0xA]
cmp r0, 0
beq _080906EC
ldr r0, [sp, 0xE8]
cmp r0, 0
beq _0809071A
_080906EC:
ldr r1, [sp, 0xF4]
cmp r1, 0
bne _08090708
ldr r0, _080907F0
ldr r1, [r0]
adds r0, r7, 0
bl strcpy
adds r0, r7, 0
add r1, sp, 0xC8
bl strcat
movs r2, 0x1
str r2, [sp, 0xF4]
_08090708:
ldr r0, _080907F4
ldr r1, [r0]
adds r0, r7, 0
bl strcat
adds r0, r7, 0
add r1, sp, 0xC8
bl strcat
_0809071A:
ldr r0, _080907EC
add r0, r9
ldrb r0, [r0, 0x6]
cmp r0, 0
beq _08090752
ldr r0, [sp, 0xF4]
cmp r0, 0
bne _08090740
ldr r0, _080907F0
ldr r1, [r0]
adds r0, r7, 0
bl strcpy
adds r0, r7, 0
add r1, sp, 0xC8
bl strcat
movs r1, 0x1
str r1, [sp, 0xF4]
_08090740:
ldr r0, _080907F8
ldr r1, [r0]
adds r0, r7, 0
bl strcat
adds r0, r7, 0
add r1, sp, 0xC8
bl strcat
_08090752:
ldr r0, _080907EC
add r0, r9
ldrb r0, [r0, 0x4]
cmp r0, 0
bne _08090792
ldr r2, [sp, 0xEC]
ldr r0, [sp, 0xF0]
cmn r2, r0
beq _08090792
ldr r1, [sp, 0xF4]
cmp r1, 0
bne _08090780
ldr r0, _080907F0
ldr r1, [r0]
adds r0, r7, 0
bl strcpy
adds r0, r7, 0
add r1, sp, 0xC8
bl strcat
movs r2, 0x1
str r2, [sp, 0xF4]
_08090780:
ldr r0, _080907FC
ldr r1, [r0]
adds r0, r7, 0
bl strcat
adds r0, r7, 0
add r1, sp, 0xC8
bl strcat
_08090792:
ldr r0, _080907EC
add r0, r9
ldrb r0, [r0, 0x7]
cmp r0, 0
bne _080907DA
ldr r0, _08090800
ldr r0, [r0]
movs r1, 0x98
lsls r1, 2
adds r0, r1
ldr r0, [r0]
cmp r0, 0
beq _080907DA
ldr r2, [sp, 0xF4]
cmp r2, 0
bne _080907C8
ldr r0, _080907F0
ldr r1, [r0]
adds r0, r7, 0
bl strcpy
adds r0, r7, 0
add r1, sp, 0xC8
bl strcat
movs r0, 0x1
str r0, [sp, 0xF4]
_080907C8:
ldr r0, _08090804
ldr r1, [r0]
adds r0, r7, 0
bl strcat
adds r0, r7, 0
add r1, sp, 0xC8
bl strcat
_080907DA:
ldr r1, [sp, 0xF4]
cmp r1, 0
bne _0809080C
ldr r1, _08090808
adds r0, r7, 0
bl sprintfStatic
movs r0, 0
b _0809080E
.align 2, 0
_080907EC: .4byte gDungeons
_080907F0: .4byte gUnknown_8115DD4
_080907F4: .4byte gUnknown_8115E00
_080907F8: .4byte gUnknown_8115E28
_080907FC: .4byte gUnknown_8115E54
_08090800: .4byte gTeamInventoryRef
_08090804: .4byte gUnknown_8115E80
_08090808: .4byte gUnknown_8108F50
_0809080C:
movs r0, 0x2
_0809080E:
add sp, 0xF8
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_809034C
.align 2,0