Merge pull request #94 from AnonymousRandomPerson/master

Dungeon movement decomp
This commit is contained in:
Seth Barberee
2022-01-31 15:57:02 -08:00
committed by GitHub
28 changed files with 2791 additions and 2821 deletions

File diff suppressed because it is too large Load Diff

1329
asm/code_8044210.s Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
.syntax unified
.text
thumb_func_start GetMapEntity
GetMapEntity:
push {r4,r5,lr}
@@ -292,7 +292,7 @@ _080497F8: .4byte 0x00003a0e
_080497FC: .4byte gDungeonFileArchive
_08049800: .4byte gUnknown_202F18C
_08049804: .4byte gUnknown_202EE8C
_08049808: .4byte gUnknown_202F314
_08049808: .4byte gWalkableTileToCrossableTerrain
_0804980C: .4byte gDungeonWaterType
_08049810:
strb r6, [r2, 0x4]

View File

@@ -12949,7 +12949,7 @@ _0805E0C2:
mov r0, r10
adds r1, r5, 0
str r3, [sp, 0x20]
bl CanMoveForward2
bl CanMoveInDirection
lsls r0, 24
ldr r3, [sp, 0x20]
cmp r0, 0
@@ -14878,7 +14878,7 @@ _0805EFF6:
bne _0805F008
mov r0, r8
adds r1, r4, 0
bl CanMoveForward2
bl CanMoveInDirection
lsls r0, 24
cmp r0, 0
beq _0805F014

View File

@@ -211,989 +211,4 @@ _08070322:
bx r1
thumb_func_end sub_80701A4
thumb_func_start GetCrossableTerrain
GetCrossableTerrain:
push {lr}
lsls r0, 16
asrs r0, 16
bl GetWalkableTiles
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0x3
bhi _0807033E
adds r0, r1, 0
b _08070344
_0807033E:
ldr r0, _08070348
adds r0, r1, r0
ldrb r0, [r0]
_08070344:
pop {r1}
bx r1
.align 2, 0
_08070348: .4byte gUnknown_202F314
thumb_func_end GetCrossableTerrain
thumb_func_start sub_807034C
sub_807034C:
push {r4,lr}
adds r4, r1, 0
lsls r0, 16
asrs r2, r0, 16
ldr r0, [r4, 0x10]
cmp r0, 0
bne _08070398
ldrh r1, [r4]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _08070398
adds r0, r2, 0
bl GetCrossableTerrain
lsls r0, 24
lsrs r2, r0, 24
ldrh r0, [r4]
movs r1, 0x3
ands r1, r0
cmp r2, 0x1
beq _08070388
cmp r2, 0x1
bgt _08070382
cmp r2, 0
beq _0807038C
b _08070390
_08070382:
cmp r2, 0x2
beq _08070394
b _08070390
_08070388:
cmp r1, 0x2
beq _08070390
_0807038C:
cmp r1, 0x1
bne _08070398
_08070390:
movs r0, 0
b _0807039A
_08070394:
cmp r1, 0
bne _08070390
_08070398:
movs r0, 0x1
_0807039A:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_807034C
thumb_func_start sub_80703A0
sub_80703A0:
push {r4-r7,lr}
adds r6, r0, 0
adds r4, r1, 0
ldr r7, [r6, 0x70]
movs r1, 0
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
cmp r0, 0
blt _08070456
movs r2, 0x2
ldrsh r1, [r4, r2]
cmp r1, 0
blt _08070456
cmp r0, 0x37
bgt _08070456
cmp r1, 0x1F
bgt _08070456
ldr r0, [r5, 0x10]
cmp r0, 0
bne _08070456
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _08070456
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08070400
adds r0, r7, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _0807044E
adds r0, r6, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _0807044E
_08070400:
movs r1, 0x2
ldrsh r0, [r7, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r4, r0, 24
ldrh r0, [r5]
movs r5, 0x3
ands r5, r0
adds r0, r6, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070422
movs r4, 0x2
_08070422:
adds r0, r6, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070432
movs r4, 0x3
_08070432:
cmp r4, 0x1
beq _08070446
cmp r4, 0x1
bgt _08070440
cmp r4, 0
beq _0807044A
b _0807044E
_08070440:
cmp r4, 0x2
beq _08070452
b _0807044E
_08070446:
cmp r5, 0x2
beq _0807044E
_0807044A:
cmp r5, 0x1
bne _08070456
_0807044E:
movs r0, 0
b _08070458
_08070452:
cmp r5, 0
bne _0807044E
_08070456:
movs r0, 0x1
_08070458:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80703A0
thumb_func_start CanCrossWalls
CanCrossWalls:
push {r4,lr}
adds r1, r0, 0
ldr r0, [r1, 0x70]
adds r4, r0, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08070492
adds r0, r1, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _08070492
movs r1, 0x2
ldrsh r0, [r4, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r0, 24
cmp r0, 0x3
beq _08070492
movs r0, 0
b _08070494
_08070492:
movs r0, 0x1
_08070494:
pop {r4}
pop {r1}
bx r1
thumb_func_end CanCrossWalls
thumb_func_start sub_807049C
sub_807049C:
push {r4-r7,lr}
adds r6, r0, 0
adds r4, r1, 0
ldr r7, [r6, 0x70]
movs r1, 0
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
cmp r0, 0
blt _0807055A
movs r2, 0x2
ldrsh r1, [r4, r2]
cmp r1, 0
blt _0807055A
cmp r0, 0x37
bgt _0807055A
cmp r1, 0x1F
bgt _0807055A
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _0807055A
ldr r0, [r5, 0x10]
cmp r0, 0
beq _080704E2
bl GetEntityType
cmp r0, 0x1
bne _0807055A
_080704E2:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08070504
adds r0, r7, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08070552
adds r0, r6, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _08070552
_08070504:
movs r1, 0x2
ldrsh r0, [r7, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r4, r0, 24
ldrh r0, [r5]
movs r5, 0x3
ands r5, r0
adds r0, r6, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070526
movs r4, 0x2
_08070526:
adds r0, r6, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070536
movs r4, 0x3
_08070536:
cmp r4, 0x1
beq _0807054A
cmp r4, 0x1
bgt _08070544
cmp r4, 0
beq _0807054E
b _08070552
_08070544:
cmp r4, 0x2
beq _08070556
b _08070552
_0807054A:
cmp r5, 0x2
beq _08070552
_0807054E:
cmp r5, 0x1
bne _0807055A
_08070552:
movs r0, 0
b _0807055C
_08070556:
cmp r5, 0
bne _08070552
_0807055A:
movs r0, 0x1
_0807055C:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_807049C
thumb_func_start sub_8070564
sub_8070564:
push {r4-r6,lr}
adds r4, r1, 0
ldr r6, [r0, 0x70]
movs r1, 0
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
cmp r0, 0
blt _080705E6
movs r2, 0x2
ldrsh r1, [r4, r2]
cmp r1, 0
blt _080705E6
cmp r0, 0x37
bgt _080705E6
cmp r1, 0x1F
bgt _080705E6
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _080705E6
ldr r0, [r5, 0x10]
cmp r0, 0
beq _080705A8
bl GetEntityType
cmp r0, 0x1
bne _080705E6
_080705A8:
movs r1, 0x2
ldrsh r0, [r6, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r2, r0, 24
adds r3, r2, 0
ldrh r0, [r5]
movs r1, 0x3
ands r1, r0
adds r0, r1, 0
cmp r2, 0x1
beq _080705DE
cmp r2, 0x1
bgt _080705CC
cmp r2, 0
beq _080705D8
b _080705D4
_080705CC:
cmp r3, 0x3
bgt _080705D4
cmp r1, 0
beq _080705E6
_080705D4:
movs r0, 0
b _080705E8
_080705D8:
cmp r1, 0x1
bne _080705E6
b _080705D4
_080705DE:
cmp r1, 0x2
beq _080705D4
cmp r0, 0x1
beq _080705D4
_080705E6:
movs r0, 0x1
_080705E8:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_8070564
thumb_func_start sub_80705F0
sub_80705F0:
push {r4-r7,lr}
adds r6, r0, 0
adds r4, r1, 0
ldr r7, [r6, 0x70]
movs r1, 0
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
cmp r0, 0
blt _0807069A
movs r2, 0x2
ldrsh r1, [r4, r2]
cmp r1, 0
blt _0807069A
cmp r0, 0x37
bgt _0807069A
cmp r1, 0x1F
bgt _0807069A
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _0807069A
ldr r0, [r5, 0x10]
cmp r0, 0
beq _08070636
bl GetEntityType
cmp r0, 0x1
bne _0807069A
_08070636:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08070658
adds r0, r7, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08070696
adds r0, r6, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _08070696
_08070658:
movs r1, 0x2
ldrsh r0, [r7, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r4, r0, 24
ldrh r0, [r5]
movs r5, 0x3
ands r5, r0
adds r0, r6, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807067A
movs r4, 0x2
_0807067A:
adds r0, r6, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807068A
movs r4, 0x3
_0807068A:
cmp r4, 0
blt _08070696
cmp r4, 0x2
bgt _08070696
cmp r5, 0
beq _0807069A
_08070696:
movs r0, 0
b _0807069C
_0807069A:
movs r0, 0x1
_0807069C:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80705F0
thumb_func_start sub_80706A4
sub_80706A4:
push {r4-r7,lr}
adds r7, r0, 0
adds r4, r1, 0
ldr r6, [r7, 0x70]
movs r1, 0
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
cmp r0, 0
blt _0807076A
movs r2, 0x2
ldrsh r1, [r4, r2]
cmp r1, 0
blt _0807076A
cmp r0, 0x37
bgt _0807076A
cmp r1, 0x1F
bgt _0807076A
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _0807076A
ldr r0, [r5, 0x10]
cmp r0, 0
beq _080706F2
bl GetEntityType
cmp r0, 0x1
bne _0807076A
ldr r0, [r5, 0x10]
ldr r0, [r0, 0x70]
cmp r0, r6
bne _0807076A
_080706F2:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08070714
adds r0, r6, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08070762
adds r0, r7, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _08070762
_08070714:
movs r1, 0x2
ldrsh r0, [r6, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r4, r0, 24
ldrh r0, [r5]
movs r5, 0x3
ands r5, r0
adds r0, r7, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070736
movs r4, 0x2
_08070736:
adds r0, r7, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070746
movs r4, 0x3
_08070746:
cmp r4, 0x1
beq _0807075A
cmp r4, 0x1
bgt _08070754
cmp r4, 0
beq _0807075E
b _08070762
_08070754:
cmp r4, 0x2
beq _08070766
b _08070762
_0807075A:
cmp r5, 0x2
beq _08070762
_0807075E:
cmp r5, 0x1
bne _0807076A
_08070762:
movs r0, 0
b _0807076C
_08070766:
cmp r5, 0
bne _08070762
_0807076A:
movs r0, 0x1
_0807076C:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80706A4
thumb_func_start GetMovementSpeed
GetMovementSpeed:
push {r4-r6,lr}
adds r6, r0, 0
ldr r5, [r6, 0x70]
movs r4, 0
movs r0, 0x84
lsls r0, 1
adds r1, r5, r0
movs r2, 0x4
_08070784:
ldrb r0, [r1, 0x5]
cmp r0, 0
beq _0807078C
subs r4, 0x1
_0807078C:
ldrb r0, [r1]
cmp r0, 0
beq _08070794
adds r4, 0x1
_08070794:
adds r1, 0x1
subs r2, 0x1
cmp r2, 0
bge _08070784
adds r0, r5, 0
adds r0, 0xAC
ldrb r0, [r0]
cmp r0, 0x4
bne _080707A8
subs r4, 0x1
_080707A8:
movs r1, 0x2
ldrsh r0, [r5, r1]
bl GetMoveSpeed
adds r4, r0
adds r0, r6, 0
movs r1, 0x6
bl HasType
lsls r0, 24
cmp r0, 0
beq _080707D0
adds r0, r6, 0
bl GetWeather
lsls r0, 24
lsrs r0, 24
cmp r0, 0x7
bne _080707D0
adds r4, 0x1
_080707D0:
movs r0, 0x4
ldrsh r1, [r5, r0]
ldr r0, _0807081C
cmp r1, r0
bne _080707DC
adds r4, 0x1
_080707DC:
movs r0, 0x2
ldrsh r1, [r5, r0]
movs r0, 0xBE
lsls r0, 1
cmp r1, r0
bne _080707FE
ldrb r0, [r5, 0x6]
cmp r0, 0
beq _080707FE
ldr r0, _08070820
ldr r0, [r0]
ldr r1, _08070824
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
beq _080707FE
adds r4, 0x1
_080707FE:
cmp r4, 0
bge _08070804
movs r4, 0
_08070804:
cmp r4, 0x4
ble _0807080A
movs r4, 0x4
_0807080A:
movs r1, 0x82
lsls r1, 1
adds r0, r5, r1
str r4, [r0]
adds r0, r4, 0
pop {r4-r6}
pop {r1}
bx r1
.align 2, 0
_0807081C: .4byte 0x000001a3
_08070820: .4byte gDungeonGlobalData
_08070824: .4byte 0x0000066e
thumb_func_end GetMovementSpeed
thumb_func_start sub_8070828
sub_8070828:
push {r4-r6,lr}
adds r4, r0, 0
lsls r1, 24
lsrs r6, r1, 24
movs r5, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
bne _08070840
movs r0, 0
b _080708AE
_08070840:
adds r0, r4, 0
movs r1, 0x1B
bl HasAbility
lsls r0, 24
cmp r0, 0
beq _0807085E
adds r0, r4, 0
bl GetWeather
lsls r0, 24
lsrs r0, 24
cmp r0, 0x4
bne _0807085E
movs r5, 0x1
_0807085E:
adds r0, r4, 0
movs r1, 0x4A
bl HasAbility
lsls r0, 24
cmp r0, 0
beq _0807087C
adds r0, r4, 0
bl GetWeather
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _0807087C
movs r5, 0x1
_0807087C:
cmp r6, 0
beq _080708A0
ldr r0, [r4, 0x70]
movs r1, 0x40
adds r2, r5, 0
bl SetVisualFlags
lsls r0, 24
cmp r0, 0
beq _080708A0
adds r0, r4, 0
bl sub_80429B4
ldr r0, _080708A8
ldr r1, [r0]
adds r0, r4, 0
bl SendMessage
_080708A0:
cmp r5, 0
bne _080708AC
movs r0, 0x1
b _080708AE
.align 2, 0
_080708A8: .4byte gUnknown_80FEE80
_080708AC:
movs r0, 0x2
_080708AE:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_8070828
thumb_func_start SetMessageArgument_2
SetMessageArgument_2:
push {r4,r5,lr}
adds r3, r0, 0
adds r4, r2, 0
ldr r0, _080708E8
ldr r2, [r0]
ldr r5, _080708EC
adds r0, r2, r5
ldrb r0, [r0]
cmp r0, 0
bne _080708DC
adds r5, 0x6
adds r0, r2, r5
ldrb r0, [r0]
cmp r0, 0
bne _080708DC
adds r0, r1, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x1
bne _080708F4
_080708DC:
ldrb r0, [r1, 0x6]
cmp r0, 0
beq _080708F4
ldr r0, _080708F0
b _08070900
.align 2, 0
_080708E8: .4byte gDungeonGlobalData
_080708EC: .4byte 0x0001820a
_080708F0: .4byte gUnknown_80F8988
_080708F4:
adds r0, r1, 0
adds r0, 0xC8
ldrb r0, [r0]
cmp r0, 0x2
bne _08070910
ldr r0, _0807090C
_08070900:
ldr r1, [r0]
adds r0, r3, 0
bl strcpy
b _0807095A
.align 2, 0
_0807090C: .4byte gUnknown_80F8968
_08070910:
ldrb r0, [r1, 0x6]
cmp r0, 0
beq _08070942
adds r0, r1, 0
adds r0, 0x40
ldrb r0, [r0]
cmp r0, 0x4A
beq _0807092A
adds r0, r1, 0
adds r0, 0xA4
ldrb r0, [r0]
cmp r0, 0x1
bne _08070936
_0807092A:
movs r0, 0x4
ldrsh r1, [r1, r0]
adds r0, r3, 0
bl CopyYellowSpeciesNametoBuffer
b _0807095A
_08070936:
movs r5, 0x4
ldrsh r1, [r1, r5]
adds r0, r3, 0
bl CopyCyanSpeciesNametoBuffer
b _0807095A
_08070942:
ldr r2, _08070960
ldrb r1, [r1, 0xA]
movs r0, 0x64
muls r0, r1
ldr r1, _08070964
adds r0, r1
ldr r1, [r2]
adds r1, r0
adds r0, r3, 0
adds r2, r4, 0
bl sub_808D9DC
_0807095A:
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_08070960: .4byte gRecruitedPokemonRef
_08070964: .4byte 0x00008df8
thumb_func_end SetMessageArgument_2
thumb_func_start sub_8070968
sub_8070968:
push {r4,lr}
adds r4, r0, 0
adds r3, r2, 0
adds r0, r1, 0
adds r0, 0xC8
ldrb r0, [r0]
cmp r0, 0x2
bne _08070990
ldr r1, _08070988
adds r2, 0x30
ldr r0, _0807098C
ldr r3, [r0]
adds r0, r4, 0
bl ExpandPlaceholdersBuffer
b _080709BA
.align 2, 0
_08070988: .4byte gUnknown_8106FA4
_0807098C: .4byte gUnknown_80F8974
_08070990:
ldrb r0, [r1, 0x6]
cmp r0, 0
beq _080709A2
movs r0, 0x4
ldrsh r1, [r1, r0]
adds r0, r4, 0
bl CopyCyanSpeciesNametoBuffer
b _080709BA
_080709A2:
ldr r2, _080709C0
ldrb r1, [r1, 0xA]
movs r0, 0x64
muls r0, r1
ldr r1, _080709C4
adds r0, r1
ldr r1, [r2]
adds r1, r0
adds r0, r4, 0
adds r2, r3, 0
bl sub_808D9DC
_080709BA:
pop {r4}
pop {r0}
bx r0
.align 2, 0
_080709C0: .4byte gRecruitedPokemonRef
_080709C4: .4byte 0x00008df8
thumb_func_end sub_8070968
thumb_func_start sub_80709C8
sub_80709C8:
push {r4,lr}
adds r3, r0, 0
ldr r0, _080709F8
ldr r2, [r0]
ldr r4, _080709FC
adds r0, r2, r4
ldrb r0, [r0]
cmp r0, 0
bne _080709EE
adds r4, 0x6
adds r0, r2, r4
ldrb r0, [r0]
cmp r0, 0
bne _080709EE
adds r0, r1, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x1
bne _08070A04
_080709EE:
ldrb r0, [r1, 0x6]
cmp r0, 0
beq _08070A04
ldr r0, _08070A00
b _08070A10
.align 2, 0
_080709F8: .4byte gDungeonGlobalData
_080709FC: .4byte 0x0001820a
_08070A00: .4byte gUnknown_80F8994
_08070A04:
adds r0, r1, 0
adds r0, 0xC8
ldrb r0, [r0]
cmp r0, 0x2
bne _08070A20
ldr r0, _08070A1C
_08070A10:
ldr r1, [r0]
adds r0, r3, 0
bl strcpy
b _08070A48
.align 2, 0
_08070A1C: .4byte gUnknown_80F8974
_08070A20:
ldrb r0, [r1, 0x6]
cmp r0, 0
beq _08070A32
movs r0, 0x4
ldrsh r1, [r1, r0]
adds r0, r3, 0
bl CopySpeciesNametoBuffer
b _08070A48
_08070A32:
ldr r2, _08070A50
ldrb r1, [r1, 0xA]
movs r0, 0x64
muls r0, r1
ldr r1, _08070A54
adds r0, r1
ldr r1, [r2]
adds r1, r0
adds r0, r3, 0
bl sub_808DA0C
_08070A48:
pop {r4}
pop {r0}
bx r0
.align 2, 0
_08070A50: .4byte gRecruitedPokemonRef
_08070A54: .4byte 0x00008df8
thumb_func_end sub_80709C8
.align 2, 0

970
asm/code_807034C.s Normal file
View File

@@ -0,0 +1,970 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_807034C
sub_807034C:
push {r4,lr}
adds r4, r1, 0
lsls r0, 16
asrs r2, r0, 16
ldr r0, [r4, 0x10]
cmp r0, 0
bne _08070398
ldrh r1, [r4]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _08070398
adds r0, r2, 0
bl GetCrossableTerrain
lsls r0, 24
lsrs r2, r0, 24
ldrh r0, [r4]
movs r1, 0x3
ands r1, r0
cmp r2, 0x1
beq _08070388
cmp r2, 0x1
bgt _08070382
cmp r2, 0
beq _0807038C
b _08070390
_08070382:
cmp r2, 0x2
beq _08070394
b _08070390
_08070388:
cmp r1, 0x2
beq _08070390
_0807038C:
cmp r1, 0x1
bne _08070398
_08070390:
movs r0, 0
b _0807039A
_08070394:
cmp r1, 0
bne _08070390
_08070398:
movs r0, 0x1
_0807039A:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_807034C
thumb_func_start sub_80703A0
sub_80703A0:
push {r4-r7,lr}
adds r6, r0, 0
adds r4, r1, 0
ldr r7, [r6, 0x70]
movs r1, 0
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
cmp r0, 0
blt _08070456
movs r2, 0x2
ldrsh r1, [r4, r2]
cmp r1, 0
blt _08070456
cmp r0, 0x37
bgt _08070456
cmp r1, 0x1F
bgt _08070456
ldr r0, [r5, 0x10]
cmp r0, 0
bne _08070456
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _08070456
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08070400
adds r0, r7, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _0807044E
adds r0, r6, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _0807044E
_08070400:
movs r1, 0x2
ldrsh r0, [r7, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r4, r0, 24
ldrh r0, [r5]
movs r5, 0x3
ands r5, r0
adds r0, r6, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070422
movs r4, 0x2
_08070422:
adds r0, r6, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070432
movs r4, 0x3
_08070432:
cmp r4, 0x1
beq _08070446
cmp r4, 0x1
bgt _08070440
cmp r4, 0
beq _0807044A
b _0807044E
_08070440:
cmp r4, 0x2
beq _08070452
b _0807044E
_08070446:
cmp r5, 0x2
beq _0807044E
_0807044A:
cmp r5, 0x1
bne _08070456
_0807044E:
movs r0, 0
b _08070458
_08070452:
cmp r5, 0
bne _0807044E
_08070456:
movs r0, 0x1
_08070458:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80703A0
thumb_func_start CanCrossWalls
CanCrossWalls:
push {r4,lr}
adds r1, r0, 0
ldr r0, [r1, 0x70]
adds r4, r0, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08070492
adds r0, r1, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _08070492
movs r1, 0x2
ldrsh r0, [r4, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r0, 24
cmp r0, 0x3
beq _08070492
movs r0, 0
b _08070494
_08070492:
movs r0, 0x1
_08070494:
pop {r4}
pop {r1}
bx r1
thumb_func_end CanCrossWalls
thumb_func_start sub_807049C
sub_807049C:
push {r4-r7,lr}
adds r6, r0, 0
adds r4, r1, 0
ldr r7, [r6, 0x70]
movs r1, 0
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
cmp r0, 0
blt _0807055A
movs r2, 0x2
ldrsh r1, [r4, r2]
cmp r1, 0
blt _0807055A
cmp r0, 0x37
bgt _0807055A
cmp r1, 0x1F
bgt _0807055A
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _0807055A
ldr r0, [r5, 0x10]
cmp r0, 0
beq _080704E2
bl GetEntityType
cmp r0, 0x1
bne _0807055A
_080704E2:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08070504
adds r0, r7, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08070552
adds r0, r6, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _08070552
_08070504:
movs r1, 0x2
ldrsh r0, [r7, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r4, r0, 24
ldrh r0, [r5]
movs r5, 0x3
ands r5, r0
adds r0, r6, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070526
movs r4, 0x2
_08070526:
adds r0, r6, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070536
movs r4, 0x3
_08070536:
cmp r4, 0x1
beq _0807054A
cmp r4, 0x1
bgt _08070544
cmp r4, 0
beq _0807054E
b _08070552
_08070544:
cmp r4, 0x2
beq _08070556
b _08070552
_0807054A:
cmp r5, 0x2
beq _08070552
_0807054E:
cmp r5, 0x1
bne _0807055A
_08070552:
movs r0, 0
b _0807055C
_08070556:
cmp r5, 0
bne _08070552
_0807055A:
movs r0, 0x1
_0807055C:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_807049C
thumb_func_start sub_8070564
sub_8070564:
push {r4-r6,lr}
adds r4, r1, 0
ldr r6, [r0, 0x70]
movs r1, 0
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
cmp r0, 0
blt _080705E6
movs r2, 0x2
ldrsh r1, [r4, r2]
cmp r1, 0
blt _080705E6
cmp r0, 0x37
bgt _080705E6
cmp r1, 0x1F
bgt _080705E6
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _080705E6
ldr r0, [r5, 0x10]
cmp r0, 0
beq _080705A8
bl GetEntityType
cmp r0, 0x1
bne _080705E6
_080705A8:
movs r1, 0x2
ldrsh r0, [r6, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r2, r0, 24
adds r3, r2, 0
ldrh r0, [r5]
movs r1, 0x3
ands r1, r0
adds r0, r1, 0
cmp r2, 0x1
beq _080705DE
cmp r2, 0x1
bgt _080705CC
cmp r2, 0
beq _080705D8
b _080705D4
_080705CC:
cmp r3, 0x3
bgt _080705D4
cmp r1, 0
beq _080705E6
_080705D4:
movs r0, 0
b _080705E8
_080705D8:
cmp r1, 0x1
bne _080705E6
b _080705D4
_080705DE:
cmp r1, 0x2
beq _080705D4
cmp r0, 0x1
beq _080705D4
_080705E6:
movs r0, 0x1
_080705E8:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_8070564
thumb_func_start sub_80705F0
sub_80705F0:
push {r4-r7,lr}
adds r6, r0, 0
adds r4, r1, 0
ldr r7, [r6, 0x70]
movs r1, 0
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
cmp r0, 0
blt _0807069A
movs r2, 0x2
ldrsh r1, [r4, r2]
cmp r1, 0
blt _0807069A
cmp r0, 0x37
bgt _0807069A
cmp r1, 0x1F
bgt _0807069A
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _0807069A
ldr r0, [r5, 0x10]
cmp r0, 0
beq _08070636
bl GetEntityType
cmp r0, 0x1
bne _0807069A
_08070636:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08070658
adds r0, r7, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08070696
adds r0, r6, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _08070696
_08070658:
movs r1, 0x2
ldrsh r0, [r7, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r4, r0, 24
ldrh r0, [r5]
movs r5, 0x3
ands r5, r0
adds r0, r6, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807067A
movs r4, 0x2
_0807067A:
adds r0, r6, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807068A
movs r4, 0x3
_0807068A:
cmp r4, 0
blt _08070696
cmp r4, 0x2
bgt _08070696
cmp r5, 0
beq _0807069A
_08070696:
movs r0, 0
b _0807069C
_0807069A:
movs r0, 0x1
_0807069C:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80705F0
thumb_func_start sub_80706A4
sub_80706A4:
push {r4-r7,lr}
adds r7, r0, 0
adds r4, r1, 0
ldr r6, [r7, 0x70]
movs r1, 0
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
cmp r0, 0
blt _0807076A
movs r2, 0x2
ldrsh r1, [r4, r2]
cmp r1, 0
blt _0807076A
cmp r0, 0x37
bgt _0807076A
cmp r1, 0x1F
bgt _0807076A
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _0807076A
ldr r0, [r5, 0x10]
cmp r0, 0
beq _080706F2
bl GetEntityType
cmp r0, 0x1
bne _0807076A
ldr r0, [r5, 0x10]
ldr r0, [r0, 0x70]
cmp r0, r6
bne _0807076A
_080706F2:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08070714
adds r0, r6, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08070762
adds r0, r7, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _08070762
_08070714:
movs r1, 0x2
ldrsh r0, [r6, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r4, r0, 24
ldrh r0, [r5]
movs r5, 0x3
ands r5, r0
adds r0, r7, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070736
movs r4, 0x2
_08070736:
adds r0, r7, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070746
movs r4, 0x3
_08070746:
cmp r4, 0x1
beq _0807075A
cmp r4, 0x1
bgt _08070754
cmp r4, 0
beq _0807075E
b _08070762
_08070754:
cmp r4, 0x2
beq _08070766
b _08070762
_0807075A:
cmp r5, 0x2
beq _08070762
_0807075E:
cmp r5, 0x1
bne _0807076A
_08070762:
movs r0, 0
b _0807076C
_08070766:
cmp r5, 0
bne _08070762
_0807076A:
movs r0, 0x1
_0807076C:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80706A4
thumb_func_start GetMovementSpeed
GetMovementSpeed:
push {r4-r6,lr}
adds r6, r0, 0
ldr r5, [r6, 0x70]
movs r4, 0
movs r0, 0x84
lsls r0, 1
adds r1, r5, r0
movs r2, 0x4
_08070784:
ldrb r0, [r1, 0x5]
cmp r0, 0
beq _0807078C
subs r4, 0x1
_0807078C:
ldrb r0, [r1]
cmp r0, 0
beq _08070794
adds r4, 0x1
_08070794:
adds r1, 0x1
subs r2, 0x1
cmp r2, 0
bge _08070784
adds r0, r5, 0
adds r0, 0xAC
ldrb r0, [r0]
cmp r0, 0x4
bne _080707A8
subs r4, 0x1
_080707A8:
movs r1, 0x2
ldrsh r0, [r5, r1]
bl GetMoveSpeed
adds r4, r0
adds r0, r6, 0
movs r1, 0x6
bl HasType
lsls r0, 24
cmp r0, 0
beq _080707D0
adds r0, r6, 0
bl GetWeather
lsls r0, 24
lsrs r0, 24
cmp r0, 0x7
bne _080707D0
adds r4, 0x1
_080707D0:
movs r0, 0x4
ldrsh r1, [r5, r0]
ldr r0, _0807081C
cmp r1, r0
bne _080707DC
adds r4, 0x1
_080707DC:
movs r0, 0x2
ldrsh r1, [r5, r0]
movs r0, 0xBE
lsls r0, 1
cmp r1, r0
bne _080707FE
ldrb r0, [r5, 0x6]
cmp r0, 0
beq _080707FE
ldr r0, _08070820
ldr r0, [r0]
ldr r1, _08070824
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
beq _080707FE
adds r4, 0x1
_080707FE:
cmp r4, 0
bge _08070804
movs r4, 0
_08070804:
cmp r4, 0x4
ble _0807080A
movs r4, 0x4
_0807080A:
movs r1, 0x82
lsls r1, 1
adds r0, r5, r1
str r4, [r0]
adds r0, r4, 0
pop {r4-r6}
pop {r1}
bx r1
.align 2, 0
_0807081C: .4byte 0x000001a3
_08070820: .4byte gDungeonGlobalData
_08070824: .4byte 0x0000066e
thumb_func_end GetMovementSpeed
thumb_func_start sub_8070828
sub_8070828:
push {r4-r6,lr}
adds r4, r0, 0
lsls r1, 24
lsrs r6, r1, 24
movs r5, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
bne _08070840
movs r0, 0
b _080708AE
_08070840:
adds r0, r4, 0
movs r1, 0x1B
bl HasAbility
lsls r0, 24
cmp r0, 0
beq _0807085E
adds r0, r4, 0
bl GetWeather
lsls r0, 24
lsrs r0, 24
cmp r0, 0x4
bne _0807085E
movs r5, 0x1
_0807085E:
adds r0, r4, 0
movs r1, 0x4A
bl HasAbility
lsls r0, 24
cmp r0, 0
beq _0807087C
adds r0, r4, 0
bl GetWeather
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _0807087C
movs r5, 0x1
_0807087C:
cmp r6, 0
beq _080708A0
ldr r0, [r4, 0x70]
movs r1, 0x40
adds r2, r5, 0
bl SetVisualFlags
lsls r0, 24
cmp r0, 0
beq _080708A0
adds r0, r4, 0
bl sub_80429B4
ldr r0, _080708A8
ldr r1, [r0]
adds r0, r4, 0
bl SendMessage
_080708A0:
cmp r5, 0
bne _080708AC
movs r0, 0x1
b _080708AE
.align 2, 0
_080708A8: .4byte gUnknown_80FEE80
_080708AC:
movs r0, 0x2
_080708AE:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_8070828
thumb_func_start SetMessageArgument_2
SetMessageArgument_2:
push {r4,r5,lr}
adds r3, r0, 0
adds r4, r2, 0
ldr r0, _080708E8
ldr r2, [r0]
ldr r5, _080708EC
adds r0, r2, r5
ldrb r0, [r0]
cmp r0, 0
bne _080708DC
adds r5, 0x6
adds r0, r2, r5
ldrb r0, [r0]
cmp r0, 0
bne _080708DC
adds r0, r1, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x1
bne _080708F4
_080708DC:
ldrb r0, [r1, 0x6]
cmp r0, 0
beq _080708F4
ldr r0, _080708F0
b _08070900
.align 2, 0
_080708E8: .4byte gDungeonGlobalData
_080708EC: .4byte 0x0001820a
_080708F0: .4byte gUnknown_80F8988
_080708F4:
adds r0, r1, 0
adds r0, 0xC8
ldrb r0, [r0]
cmp r0, 0x2
bne _08070910
ldr r0, _0807090C
_08070900:
ldr r1, [r0]
adds r0, r3, 0
bl strcpy
b _0807095A
.align 2, 0
_0807090C: .4byte gUnknown_80F8968
_08070910:
ldrb r0, [r1, 0x6]
cmp r0, 0
beq _08070942
adds r0, r1, 0
adds r0, 0x40
ldrb r0, [r0]
cmp r0, 0x4A
beq _0807092A
adds r0, r1, 0
adds r0, 0xA4
ldrb r0, [r0]
cmp r0, 0x1
bne _08070936
_0807092A:
movs r0, 0x4
ldrsh r1, [r1, r0]
adds r0, r3, 0
bl CopyYellowSpeciesNametoBuffer
b _0807095A
_08070936:
movs r5, 0x4
ldrsh r1, [r1, r5]
adds r0, r3, 0
bl CopyCyanSpeciesNametoBuffer
b _0807095A
_08070942:
ldr r2, _08070960
ldrb r1, [r1, 0xA]
movs r0, 0x64
muls r0, r1
ldr r1, _08070964
adds r0, r1
ldr r1, [r2]
adds r1, r0
adds r0, r3, 0
adds r2, r4, 0
bl sub_808D9DC
_0807095A:
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_08070960: .4byte gRecruitedPokemonRef
_08070964: .4byte 0x00008df8
thumb_func_end SetMessageArgument_2
thumb_func_start sub_8070968
sub_8070968:
push {r4,lr}
adds r4, r0, 0
adds r3, r2, 0
adds r0, r1, 0
adds r0, 0xC8
ldrb r0, [r0]
cmp r0, 0x2
bne _08070990
ldr r1, _08070988
adds r2, 0x30
ldr r0, _0807098C
ldr r3, [r0]
adds r0, r4, 0
bl ExpandPlaceholdersBuffer
b _080709BA
.align 2, 0
_08070988: .4byte gUnknown_8106FA4
_0807098C: .4byte gUnknown_80F8974
_08070990:
ldrb r0, [r1, 0x6]
cmp r0, 0
beq _080709A2
movs r0, 0x4
ldrsh r1, [r1, r0]
adds r0, r4, 0
bl CopyCyanSpeciesNametoBuffer
b _080709BA
_080709A2:
ldr r2, _080709C0
ldrb r1, [r1, 0xA]
movs r0, 0x64
muls r0, r1
ldr r1, _080709C4
adds r0, r1
ldr r1, [r2]
adds r1, r0
adds r0, r4, 0
adds r2, r3, 0
bl sub_808D9DC
_080709BA:
pop {r4}
pop {r0}
bx r0
.align 2, 0
_080709C0: .4byte gRecruitedPokemonRef
_080709C4: .4byte 0x00008df8
thumb_func_end sub_8070968
thumb_func_start sub_80709C8
sub_80709C8:
push {r4,lr}
adds r3, r0, 0
ldr r0, _080709F8
ldr r2, [r0]
ldr r4, _080709FC
adds r0, r2, r4
ldrb r0, [r0]
cmp r0, 0
bne _080709EE
adds r4, 0x6
adds r0, r2, r4
ldrb r0, [r0]
cmp r0, 0
bne _080709EE
adds r0, r1, 0
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x1
bne _08070A04
_080709EE:
ldrb r0, [r1, 0x6]
cmp r0, 0
beq _08070A04
ldr r0, _08070A00
b _08070A10
.align 2, 0
_080709F8: .4byte gDungeonGlobalData
_080709FC: .4byte 0x0001820a
_08070A00: .4byte gUnknown_80F8994
_08070A04:
adds r0, r1, 0
adds r0, 0xC8
ldrb r0, [r0]
cmp r0, 0x2
bne _08070A20
ldr r0, _08070A1C
_08070A10:
ldr r1, [r0]
adds r0, r3, 0
bl strcpy
b _08070A48
.align 2, 0
_08070A1C: .4byte gUnknown_80F8974
_08070A20:
ldrb r0, [r1, 0x6]
cmp r0, 0
beq _08070A32
movs r0, 0x4
ldrsh r1, [r1, r0]
adds r0, r3, 0
bl CopySpeciesNametoBuffer
b _08070A48
_08070A32:
ldr r2, _08070A50
ldrb r1, [r1, 0xA]
movs r0, 0x64
muls r0, r1
ldr r1, _08070A54
adds r0, r1
ldr r1, [r2]
adds r1, r0
adds r0, r3, 0
bl sub_808DA0C
_08070A48:
pop {r4}
pop {r0}
bx r0
.align 2, 0
_08070A50: .4byte gRecruitedPokemonRef
_08070A54: .4byte 0x00008df8
thumb_func_end sub_80709C8
.align 2, 0

View File

@@ -1,115 +1,10 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start CanMoveForward2
CanMoveForward2:
push {r4-r6,lr}
adds r4, r0, 0
adds r6, r1, 0
ldr r0, [r4, 0x70]
movs r1, 0x2
ldrsh r0, [r0, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r5, r0, 24
movs r2, 0x4
ldrsh r0, [r4, r2]
ldr r1, _08070DD8
lsls r2, r6, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x6
ldrsh r1, [r4, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
adds r2, r0, 0
ldrh r1, [r2]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _08070E34
ldr r0, [r2, 0x10]
cmp r0, 0
bne _08070E34
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08070E04
ldr r0, [r4, 0x70]
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08070DD2
adds r0, r4, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
beq _08070DDC
_08070DD2:
movs r5, 0x3
b _08070E04
.align 2, 0
_08070DD8: .4byte gAdjacentTileOffsets
_08070DDC:
adds r0, r4, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
bne _08070E02
adds r0, r4, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070E04
movs r0, 0x1
ands r0, r6
movs r5, 0x3
cmp r0, 0
beq _08070E04
_08070E02:
movs r5, 0x2
_08070E04:
movs r1, 0x4
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r2, r0, 0
adds r1, r2, 0
adds r1, 0xA
adds r1, r5
ldr r2, _08070E30
movs r0, 0x7
ands r0, r6
adds r0, r2
ldrb r1, [r1]
ldrb r0, [r0]
ands r0, r1
cmp r0, 0
beq _08070E34
movs r0, 0x1
b _08070E36
.align 2, 0
_08070E30: .4byte gDirectionBitMasks
_08070E34:
movs r0, 0
_08070E36:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end CanMoveForward2
.syntax unified
.text
thumb_func_start sub_8070E3C
sub_8070E3C:
push {r4-r7,lr}

View File

@@ -2652,7 +2652,7 @@ _08072F84:
bne _08072FCC
adds r0, r4, 0
adds r1, r3, 0
bl CanMoveForward2
bl CanMoveInDirection
lsls r0, 24
cmp r0, 0
bne _08072FCC

View File

@@ -9080,7 +9080,7 @@
.byte 0xf6, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0xdb, 0x26, 0x08
changeTileSet 0xDE
.byte 0x0c, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
playMusic MUS_IN_THE_DEPTHS_OF_PIT
playMusic MUS_IN_THE_DEPTHS_OF_THE_PIT
.byte 0x22, 0x01, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
waitFlag 3
fadeMusicOut 0x78

View File

@@ -362,38 +362,3 @@ gUnknown_8106F7C: @ 8106F7C
.global gUnknown_8106FA4
gUnknown_8106FA4: @ 8106FA4
.string "{COLOR_2}%c%s{END_COLOR_TEXT_2}\0"
.global gDirectionBitMasks
gDirectionBitMasks: @ 8106FAD
@ replacing .incbin "baserom.gba", 0x00106fad, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gUnknown_8106FB5
gUnknown_8106FB5: @ 8106FB5
@ replacing .incbin "baserom.gba", 0x00106fb5, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gUnknown_8106FBD
gUnknown_8106FBD: @ 8106FBD
@ replacing .incbin "baserom.gba", 0x00106fbd, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gUnknown_8106FC5
gUnknown_8106FC5: @ 8106FC5
@ replacing .incbin "baserom.gba", 0x00106fc5, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gUnknown_8106FCD
gUnknown_8106FCD: @ 8106FCD
@ replacing .incbin "baserom.gba", 0x00106fcd, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gDirectionBitMasks_2
gDirectionBitMasks_2: @ 8106FD5
@ replacing .incbin "baserom.gba", 0x00106fd5, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gDirectionBitMasks_3
gDirectionBitMasks_3: @ 8106FDD
@ replacing .incbin "baserom.gba", 0x00106fdd, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80

31
data/data_8106FB5.s Normal file
View File

@@ -0,0 +1,31 @@
.section .rodata
.global gUnknown_8106FB5
gUnknown_8106FB5: @ 8106FB5
@ replacing .incbin "baserom.gba", 0x00106fb5, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gUnknown_8106FBD
gUnknown_8106FBD: @ 8106FBD
@ replacing .incbin "baserom.gba", 0x00106fbd, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gUnknown_8106FC5
gUnknown_8106FC5: @ 8106FC5
@ replacing .incbin "baserom.gba", 0x00106fc5, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gUnknown_8106FCD
gUnknown_8106FCD: @ 8106FCD
@ replacing .incbin "baserom.gba", 0x00106fcd, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gDirectionBitMasks_2
gDirectionBitMasks_2: @ 8106FD5
@ replacing .incbin "baserom.gba", 0x00106fd5, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gDirectionBitMasks_3
gDirectionBitMasks_3: @ 8106FDD
@ replacing .incbin "baserom.gba", 0x00106fdd, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80

View File

@@ -27,7 +27,7 @@
floatingText InterviewBegin_826E108
closeTextBox
StartSceneRunCall 0
playMusic MUS_WELCOME_TO_WORLD_POKEMON
playMusic MUS_WELCOME_TO_THE_WORLD_OF_POKEMON
.byte 0x22, 0x01, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x3c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
fadeMusicOut 0x1E

View File

@@ -1,51 +1,51 @@
#ifndef GUARD_CONSTANTS_BG_MUSIC_H
#define GUARD_CONSTANTS_BG_MUSIC_H
#define GUARD_CONSTANTS_BG_MUSIC_H
#define MUS_TEAM_BASE 1
#define MUS_RESCUE_TEAM_BASE 1
#define MUS_FRIEND_AREA_SWAMP 2
#define MUS_FRIEND_AREA_CAVES 3
#define MUS_DREAM 4
#define MUS_BENEVOLENT_SPIRT 5
#define MUS_BENEVOLENT_SPIRIT 5
#define MUS_LEGEND_OF_NINETALES 6
#define MUS_POKEMON_SQUARE 7
#define MUS_LOADING_SCREEN 8
#define MUS_FILE_SELECT 8
#define MUS_RISING_FEAR 9
#define MUS_THERES_TROUBLE 10
#define MUS_DECISIVE_BATTLE 11
#define MUS_WELCOME_TO_WORLD_POKEMON 12
#define MUS_BURIED_RELIC 13
#define MUS_BOSS_BATTLE 11
#define MUS_WELCOME_TO_THE_WORLD_OF_POKEMON 12
#define MUS_A_NEW_ADVENTURE 13 // Plays in Buried Relic and Southern Cavern
#define MUS_THUNDERWAVE_CAVE 14
#define MUS_SINISTER_WOODS 15
#define MUS_FRIEND_AREA_POND 16
#define MUS_KECLEON_SHOP 17
#define MUS_STOP_THIEF 18
#define MUS_WORLD_CALAMITY 19 // GIANT_STAR_APPROACHING
#define MUS_GRAND_CANYON 20
#define MUS_GREAT_CANYON 20
#define MUS_STORMY_SEA 21
#define MUS_SKY_TOWER 22
#define MUS_SKY_TOWER_SUMMIT 23
#define MUS_RUN_AWAY 24
#define MUS_THE_ESCAPE 24
#define MUS_MT_BLAZE 25
#define MUS_SKY_TOWER_END 26
#define MUS_RAYQUAZAS_DOMAIN 26
#define MUS_FRIEND_AREA_STRATOS_LOOKOUT 27
#define MUS_FRIEND_AREA_RAINBOW_PEAK 28
#define MUS_GENGAR_DREAM 29
#define MUS_DREAM_EATER 29
#define MUS_FRIEND_AREA_DEEPSEA_CURRENT 30
#define MUS_FRIEND_AREA_SEAFLOOR_CAVE 31
#define MUS_LAST_BATTLE 32
#define MUS_BATTLE_WITH_RAYQUAZA 32
#define MUS_MT_BLAZE_PEAK 33
#define MUS_FRIEND_AREA_VOLCANIC_PIT 34
#define MUS_FRIEND_AREA_CRYPTIC_CAVE 35
#define MUS_THROUGH_THE_LAND_OF_ICE_AND_SNOW 36
#define MUS_GENGAR_DARK_WORLD 37
#define MUS_MT_BLAZE_END 38
#define MUS_ESCAPE_THROUGH_THE_SNOW 36
#define MUS_THE_OTHER_SIDE 37
#define MUS_THE_MOUNTAIN_OF_FIRE 38
#define MUS_FROSTY_GROTTO 39
#define MUS_INTRO 40
#define MUS_AFTER_THE_BATTLE 41
#define MUS_NEVER_FORGET 42
#define MUS_AFTERMATH 41
#define MUS_FAREWELL 42
#define MUS_TITLE_SCREEN 43
#define MUS_CREDITS 44
#define MUS_EPILOGUE 45
#define MUS_TIME_OF_REUNION 45
#define MUS_OPENING_TITLE 46
#define MUS_DUNGEON_FAIL 51
#define MUS_DUNGEON_COMPLETE 52
@@ -53,7 +53,7 @@
// 53 - 99 are blank/empty slots for BG Music
#define MUS_FRIEND_AREA_UNUSED_1 100
#define MUS_MEETING_WITH_PARTNER 101
#define MUS_HEARTWARMING 101
#define MUS_LAPIS_CAVE 102
#define MUS_A_SUCCESSFUL_RESCUE 103
#define MUS_FROSTY_FOREST 104
@@ -66,7 +66,7 @@
#define MUS_MT_THUNDER 111
#define MUS_FRIEND_AREA_LAB 112
#define MUS_SILENT_CHASM 113
#define MUS_IN_THE_DEPTHS_OF_PIT 114
#define MUS_IN_THE_DEPTHS_OF_THE_PIT 114
#define MUS_MT_FREEZE 115
#define MUS_FRIEND_AREA_WILDS 116
#define MUS_FRIEND_AREA_LEGENDARY_ISLAND 117

View File

@@ -0,0 +1,9 @@
#ifndef GUARD_DUNGEON_AI_MOVEMENT_H
#define GUARD_DUNGEON_AI_MOVEMENT_H
#include "dungeon_entity.h"
// 0x75990
void DecideAction(struct DungeonEntity *pokemon);
#endif

View File

@@ -7,5 +7,7 @@
bool8 CannotUseItems(struct DungeonEntity *pokemon);
// 0x70CD0
bool8 CannotAct(struct DungeonEntity *pokemon);
// 0x70D6C
bool8 CanMoveInDirection(struct DungeonEntity *pokemon, u32 facingDir);
#endif

7
include/dungeon_engine.h Normal file
View File

@@ -0,0 +1,7 @@
#ifndef GUARD_DUNGEON_ENGINE_H
#define GUARD_DUNGEON_ENGINE_H
// 0x441E8
bool8 IsFixedDungeon();
#endif

View File

@@ -1,9 +1,7 @@
#ifndef GUARD_DUNGEON_MOVEMENT_H
#define GUARD_DUNGEON_MOVEMENT_H
#include "dungeon_entity.h"
// 0x75990
void DecideAction(struct DungeonEntity *pokemon);
// 0x70328
u8 GetCrossableTerrain(s16 species);
#endif

View File

@@ -7,38 +7,6 @@
#define MAX_ROOM_COUNT 24 // Empirical max, not sure if the code supports any more.
#define CORRIDOR_ROOM_INDEX 0xFF
struct MapTile
{
// Uses the TileType bit flags.
/* 0x0 */ u16 tileType;
u8 fill2[0x4 - 0x2];
u16 unk4;
u16 unk6;
u8 unk8;
/* 0x9 */ u8 roomIndex;
// Bitwise flags for whether Pokémon can move to an adjacent tile. Bits correspond to directions in direction.h.
// Different sets of flags are used for Pokémon that can cross special terrain.
/* 0xA */ u8 canMoveAdjacent;
/* 0xB */ u8 canMoveAdjacentLiquid;
/* 0xC */ u8 canMoveAdjacentCrevice;
/* 0xD */ u8 canMoveAdjacentWall;
u8 fillE[0x10 - 0xE];
/* 0x10 */ struct DungeonEntity *pokemon; // Pokémon on the tile.
/* 0x14 */ struct DungeonEntity *mapObject; // Item or trap on the tile.
};
struct MapRoom
{
u8 fill0[0x2 - 0x0];
// All coordinates are inclusive.
// These are not aligned properly to use the Position struct.
/* 0x2 */ s16 startX;
/* 0x4 */ s16 startY;
/* 0x6 */ s16 endX;
/* 0x8 */ s16 endY;
u8 fillA[0x1A - 0xA];
};
enum TileType
{
TILE_TYPE_FLOOR = 1 << 0,
@@ -57,6 +25,36 @@ enum CrossableTerrain
CROSSABLE_TERRAIN_LIQUID = 1,
CROSSABLE_TERRAIN_CREVICE = 2,
CROSSABLE_TERRAIN_WALL = 3,
NUM_CROSSABLE_TERRAIN
};
struct MapTile
{
// Uses the TileType bit flags.
/* 0x0 */ u16 tileType;
u8 fill2[0x4 - 0x2];
u16 unk4;
u16 unk6;
u8 unk8;
/* 0x9 */ u8 roomIndex;
// Bitwise flags for whether Pokémon can move to an adjacent tile. Bits correspond to directions in direction.h.
// Different sets of flags are used for Pokémon that can cross special terrain, corresponding to Cthe rossableTerrain enum.
/* 0xA */ u8 canMoveAdjacent[NUM_CROSSABLE_TERRAIN];
u8 fillE[0x10 - 0xE];
/* 0x10 */ struct DungeonEntity *pokemon; // Pokémon on the tile.
/* 0x14 */ struct DungeonEntity *mapObject; // Item or trap on the tile.
};
struct MapRoom
{
u8 fill0[0x2 - 0x0];
// All coordinates are inclusive.
// These are not aligned properly to use the Position struct.
/* 0x2 */ s16 startX;
/* 0x4 */ s16 startY;
/* 0x6 */ s16 endX;
/* 0x8 */ s16 endY;
u8 fillA[0x1A - 0xA];
};
#endif

View File

@@ -186,6 +186,8 @@ SECTIONS {
asm/code_8041AD0.o(.text);
src/code_80428A0.o(.text);
asm/code_80428A0.o(.text);
src/dungeon_engine.o(.text);
asm/code_8044210.o(.text);
src/dungeon_action.o(.text);
asm/code_8044CC8.o(.text);
src/dungeon_util.o(.text);
@@ -209,12 +211,14 @@ SECTIONS {
asm/code_806CD90.o(.text);
src/status_checks.o(.text);
asm/code_80701A4.o(.text);
src/dungeon_movement.o(.text);
asm/code_807034C.o(.text);
src/status_checks_1.o(.text);
asm/code_8070B48.o(.text);
src/dungeon_capabilities.o(.text);
asm/code_8070BC0.o(.text);
src/dungeon_capabilities_1.o(.text);
asm/code_8070D04.o(.text);
asm/code_8070E3C.o(.text);
src/dungeon_ai.o(.text);
asm/code_8071518.o(.text);
src/dungeon_ai_1.o(.text);
@@ -225,7 +229,7 @@ SECTIONS {
asm/code_80718D8.o(.text);
src/dungeon_ai_items.o(.text);
asm/code_8073CF0.o(.text);
src/dungeon_movement.o(.text);
src/dungeon_ai_movement.o(.text);
asm/code_8075BA4.o(.text);
src/dungeon_ai_attack.o(.text);
asm/code_807CABC.o(.text);
@@ -400,6 +404,8 @@ SECTIONS {
data/data_80F59C8.o(.rodata);
src/charge_move.o(.rodata);
data/data_8106A4C.o(.rodata);
src/dungeon_capabilities_1.o(.rodata);
data/data_8106FB5.o(.rodata);
src/dungeon_ai_1.o(.rodata);
data/data_8107010.o(.rodata);
src/friend_area.o(.rodata);

View File

@@ -138,7 +138,7 @@ void GameLoop(void)
FinishReadSavePak();
}
tmp3 = 1;
StartNewBGM(MUS_LOADING_SCREEN);
StartNewBGM(MUS_FILE_SELECT);
flag = TRUE;
sub_80095CC(0, 20);
InitMainMenu();

287
src/dungeon_ai_movement.c Normal file
View File

@@ -0,0 +1,287 @@
#include "global.h"
#include "dungeon_ai_movement.h"
#include "constants/dungeon_action.h"
#include "constants/direction.h"
#include "constants/iq_skill.h"
#include "constants/status.h"
#include "constants/targeting.h"
#include "code_80521D0.h"
#include "dungeon_action.h"
#include "dungeon_ai_items.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_global_data.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "dungeon_util_1.h"
#include "dungeon_visibility.h"
#include "map.h"
#include "pokemon.h"
#include "status_checks.h"
extern char gAvailablePokemonNames[];
extern char *gPtrCouldntBeUsedMessage;
extern char *gPtrItsaMonsterHouseMessage;
extern void SendImmobilizeEndMessage(struct DungeonEntity*, struct DungeonEntity*);
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
extern void ResetAction(u16*);
extern void DecideAttack(struct DungeonEntity*);
extern void MoveIfPossible(struct DungeonEntity*, bool8);
extern u8 sub_8044B28(void);
extern void sub_807AB38(struct DungeonEntity *, u32);
extern void sub_8041888(u32);
extern u8 sub_803F428(s16 *);
extern void sub_803E708(u32, u32);
extern struct DungeonEntity *GetLeaderEntity();
extern void TargetTileInFront(struct DungeonEntity *);
u32 sub_8075818(struct DungeonEntity *entity)
{
struct MapTile *tile;
struct DungeonEntityData *entityData;
struct DungeonEntity *subEntity;
struct ItemSlot *item;
u8 *trapData; // TODO: turn into struct when more research is done..
u8 r1;
entityData = entity->entityData;
if(EntityExists(entity))
{
tile = GetMapEntityForDungeonEntity(entity);
if(HasIQSkill(entity, IQ_SKILL_SUPER_MOBILE))
if(!(tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
return 1;
subEntity = tile->mapObject;
if(subEntity != NULL)
{
switch(GetEntityType(subEntity))
{
case ENTITY_NONE:
case ENTITY_POKEMON:
case 4:
case 5:
break;
case ENTITY_TRAP:
trapData = (u8*) GetTrapData(subEntity);
r1 = 0;
if(trapData[1] == 0)
{
if(!subEntity->visible || entityData->isEnemy)
goto flag_check;
else
goto error;
}
else if(trapData[1] == 1)
{
if(!entityData->isEnemy)
goto flag_check;
else
goto error;
}
else if(trapData[1] == 2)
{
if(!entityData->isEnemy)
r1 = 1;
}
flag_check:
if(r1 == 0)
break;
else
goto error;
case ENTITY_ITEM:
if(!entityData->isLeader)
{
if(!(entityData->heldItem.itemFlags & ITEM_FLAG_EXISTS))
{
if(!(tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
{
if(entityData->isEnemy)
break;
else
{
item = GetItemData(subEntity);
if(!(item->itemFlags & ITEM_FLAG_FOR_SALE))
{
return 1;
}
}
}
else
{
item = GetItemData(subEntity);
if(!(item->itemFlags & ITEM_FLAG_FOR_SALE))
{
error:
return 1;
}
}
}
}
break;
}
}
}
return 0;
}
void sub_8075900(struct DungeonEntity *pokemon, u8 r1)
{
if(EntityExists(pokemon))
{
if(!pokemon->entityData->isEnemy)
{
if(!sub_8044B28())
{
if(!gDungeonGlobalData->monsterHouseActive)
{
if((GetMapEntityForDungeonEntity(pokemon)->tileType & TILE_TYPE_MONSTER_HOUSE))
{
// It's a monster house!
SendMessage(GetLeaderEntity(), gPtrItsaMonsterHouseMessage);
gDungeonGlobalData->unk672 = 1;
sub_807AB38(pokemon, r1);
sub_8041888(0);
if(sub_803F428(&pokemon->posWorld.x) != 0)
sub_803E708(0x78, 0x39);
}
}
}
}
}
}
void DecideAction(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if (pokemonData->flags & MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED)
{
if (pokemonData->immobilizeStatus == IMMOBILIZE_STATUS_PETRIFIED)
{
SendImmobilizeEndMessage(pokemon, pokemon);
}
}
else
{
pokemonData->targetingDecoy = TARGETING_DECOY_NONE;
if (pokemonData->clientType == CLIENT_TYPE_NONE || IsMovingClient(pokemon))
{
if (pokemonData->clientType != CLIENT_TYPE_CLIENT && pokemonData->useHeldItem)
{
if (CannotUseItems(pokemon))
{
pokemonData->useHeldItem = FALSE;
SetMessageArgument(gAvailablePokemonNames, pokemon, 0);
SendMessage(pokemon, gPtrCouldntBeUsedMessage);
return;
}
DecideUseItem(pokemon);
if (pokemonData->action.action != DUNGEON_ACTION_NONE)
{
return;
}
}
if (!HasStatusAffectingActions(pokemon))
{
if (gDungeonGlobalData->decoyActive)
{
s32 i;
struct DungeonEntity *target;
for (i = 0; i < DUNGEON_MAX_POKEMON; i++)
{
target = gDungeonGlobalData->allPokemon[i];
if (EntityExists(target) &&
target->entityData->waitingStatus == WAITING_STATUS_DECOY &&
CanSee(pokemon, target))
{
bool8 enemyDecoy = target->entityData->enemyDecoy;
u8 targetingDecoy = TARGETING_DECOY_TEAM;
if (enemyDecoy)
{
targetingDecoy = TARGETING_DECOY_WILD;
}
pokemonData->targetingDecoy = targetingDecoy;
break;
}
}
}
ResetAction(&pokemonData->action.action);
if (pokemonData->clientType == CLIENT_TYPE_CLIENT)
{
SetWalkAction(&pokemonData->action, pokemonData->entityID);
pokemonData->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS);
pokemonData->targetPosition.x = pokemon->posWorld.x;
pokemonData->targetPosition.y = pokemon->posWorld.y - 1;
}
else
{
DecideUseItem(pokemon);
if (pokemonData->action.action == DUNGEON_ACTION_NONE)
{
if (!HasIQSkill(pokemon, IQ_SKILL_DEDICATED_TRAVELER))
{
DecideAttack(pokemon);
if (pokemonData->action.action != DUNGEON_ACTION_NONE)
{
return;
}
if (pokemonData->volatileStatus == VOLATILE_STATUS_CONFUSED)
{
SetWalkAction(&pokemonData->action, pokemonData->entityID);
}
else
{
if (!GetIsMoving(pokemonData->entityID))
{
return;
}
MoveIfPossible(pokemon, TRUE);
}
}
else
{
if (pokemonData->volatileStatus == VOLATILE_STATUS_CONFUSED)
{
SetWalkAction(&pokemonData->action, pokemonData->entityID);
}
else
{
if (GetIsMoving(pokemonData->entityID))
{
MoveIfPossible(pokemon, TRUE);
}
if (pokemonData->action.action > DUNGEON_ACTION_WAIT)
{
return;
}
DecideAttack(pokemon);
if (pokemonData->action.action <= DUNGEON_ACTION_WAIT)
{
return;
}
pokemonData->notAdjacentToTarget = FALSE;
pokemonData->movingIntoTarget = FALSE;
pokemonData->waiting = FALSE;
}
}
}
}
}
}
}
}
void sub_8075BA4(struct DungeonEntity *param_1,char param_2)
{
struct DungeonEntityData * iVar2 = param_1->entityData;
if ((param_2 != '\0') && (iVar2->volatileStatus == VOLATILE_STATUS_COWERING)) {
iVar2->action.facingDir = (iVar2->action.facingDir + 4) & DIRECTION_MASK;
TargetTileInFront(param_1);
}
else if (iVar2->volatileStatus == VOLATILE_STATUS_CONFUSED) {
iVar2->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS);
TargetTileInFront(param_1);
}
}

View File

@@ -2,10 +2,20 @@
#include "dungeon_capabilities_1.h"
#include "constants/dungeon.h"
#include "constants/iq_skill.h"
#include "constants/status.h"
#include "charge_move.h"
#include "dungeon_ai.h"
#include "dungeon_capabilities.h"
#include "dungeon_engine.h"
#include "dungeon_items.h"
#include "dungeon_map_access.h"
#include "dungeon_movement.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_util.h"
#include "map.h"
const u8 gDirectionBitMasks[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
static inline bool8 JoinLocationCannotUseItems(struct DungeonEntityData *pokemonData)
{
@@ -75,3 +85,43 @@ bool8 CannotAttack(struct DungeonEntity *pokemon, bool8 skipSleep)
}
return TRUE;
}
bool8 CanMoveInDirection(struct DungeonEntity *pokemon, u32 facingDir)
{
u8 crossableTerrain = GetCrossableTerrain(pokemon->entityData->entityID);
struct MapTile *currentMapTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x,
pokemon->posWorld.y + gAdjacentTileOffsets[facingDir].y);
if (currentMapTile->tileType & TILE_TYPE_MAP_EDGE || currentMapTile->pokemon != NULL)
{
return FALSE;
}
if (!IsFixedDungeon())
{
if (pokemon->entityData->transformStatus == TRANSFORM_STATUS_MOBILE || HasItem(pokemon, ITEM_ID_MOBILE_SCARF))
{
crossableTerrain = CROSSABLE_TERRAIN_WALL;
}
else if (HasIQSkill(pokemon, IQ_SKILL_ALL_TERRAIN_HIKER))
{
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
}
else if (HasIQSkill(pokemon, IQ_SKILL_SUPER_MOBILE))
{
if (facingDir & 1)
{
// Super Mobile can't break walls diagonally.
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
}
else
{
crossableTerrain = CROSSABLE_TERRAIN_WALL;
}
}
}
currentMapTile = GetMapTileAtPosition(pokemon->posWorld.x, pokemon->posWorld.y);
if (!(currentMapTile->canMoveAdjacent[crossableTerrain] & gDirectionBitMasks[facingDir & DIRECTION_MASK]))
{
return FALSE;
}
return TRUE;
}

13
src/dungeon_engine.c Normal file
View File

@@ -0,0 +1,13 @@
#include "global.h"
#include "dungeon_engine.h"
#include "constants/dungeon.h"
#include "dungeon_global_data.h"
bool8 IsFixedDungeon()
{
if (gDungeonGlobalData->tileset > DUNGEON_OUT_ON_RESCUE)
{
return TRUE;
}
return FALSE;
}

View File

@@ -1,287 +1,26 @@
#include "global.h"
#include "dungeon_movement.h"
#include "constants/dungeon_action.h"
#include "constants/direction.h"
#include "constants/iq_skill.h"
#include "constants/status.h"
#include "constants/targeting.h"
#include "code_80521D0.h"
#include "dungeon_action.h"
#include "dungeon_ai_items.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_global_data.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "dungeon_util_1.h"
#include "dungeon_visibility.h"
#include "map.h"
#include "pokemon.h"
#include "status_checks.h"
extern char gAvailablePokemonNames[];
extern char *gPtrCouldntBeUsedMessage;
extern char *gPtrItsaMonsterHouseMessage;
extern u8 gWalkableTileToCrossableTerrain[8];
extern void SendImmobilizeEndMessage(struct DungeonEntity*, struct DungeonEntity*);
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
extern void ResetAction(u16*);
extern void DecideAttack(struct DungeonEntity*);
extern void MoveIfPossible(struct DungeonEntity*, bool8);
extern u8 sub_8044B28(void);
extern void sub_807AB38(struct DungeonEntity *, u32);
extern void sub_8041888(u32);
extern u8 sub_803F428(s16 *);
extern void sub_803E708(u32, u32);
extern struct DungeonEntity *GetLeaderEntity();
extern void TargetTileInFront(struct DungeonEntity *);
u32 sub_8075818(struct DungeonEntity *entity)
u8 GetCrossableTerrain(s16 species)
{
struct MapTile *tile;
struct DungeonEntityData *entityData;
struct DungeonEntity *subEntity;
struct ItemSlot *item;
u8 *trapData; // TODO: turn into struct when more research is done..
u8 r1;
entityData = entity->entityData;
if(EntityExists(entity))
u8 walkableTiles = GetWalkableTiles(species);
if (walkableTiles >= NUM_CROSSABLE_TERRAIN)
{
tile = GetMapEntityForDungeonEntity(entity);
if(HasIQSkill(entity, IQ_SKILL_SUPER_MOBILE))
if(!(tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
return 1;
subEntity = tile->mapObject;
if(subEntity != NULL)
{
switch(GetEntityType(subEntity))
{
case ENTITY_NONE:
case ENTITY_POKEMON:
case 4:
case 5:
break;
case ENTITY_TRAP:
trapData = (u8*) GetTrapData(subEntity);
r1 = 0;
if(trapData[1] == 0)
{
if(!subEntity->visible || entityData->isEnemy)
goto flag_check;
else
goto error;
}
else if(trapData[1] == 1)
{
if(!entityData->isEnemy)
goto flag_check;
else
goto error;
}
else if(trapData[1] == 2)
{
if(!entityData->isEnemy)
r1 = 1;
}
flag_check:
if(r1 == 0)
break;
else
goto error;
case ENTITY_ITEM:
if(!entityData->isLeader)
{
if(!(entityData->heldItem.itemFlags & ITEM_FLAG_EXISTS))
{
if(!(tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
{
if(entityData->isEnemy)
break;
else
{
item = GetItemData(subEntity);
if(!(item->itemFlags & ITEM_FLAG_FOR_SALE))
{
return 1;
}
}
}
else
{
item = GetItemData(subEntity);
if(!(item->itemFlags & ITEM_FLAG_FOR_SALE))
{
error:
return 1;
}
}
}
}
break;
}
}
}
return 0;
}
void sub_8075900(struct DungeonEntity *pokemon, u8 r1)
{
if(EntityExists(pokemon))
{
if(!pokemon->entityData->isEnemy)
{
if(!sub_8044B28())
{
if(!gDungeonGlobalData->monsterHouseActive)
{
if((GetMapEntityForDungeonEntity(pokemon)->tileType & TILE_TYPE_MONSTER_HOUSE))
{
// It's a monster house!
SendMessage(GetLeaderEntity(), gPtrItsaMonsterHouseMessage);
gDungeonGlobalData->unk672 = 1;
sub_807AB38(pokemon, r1);
sub_8041888(0);
if(sub_803F428(&pokemon->posWorld.x) != 0)
sub_803E708(0x78, 0x39);
}
}
}
}
}
}
void DecideAction(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if (pokemonData->flags & MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED)
{
if (pokemonData->immobilizeStatus == IMMOBILIZE_STATUS_PETRIFIED)
{
SendImmobilizeEndMessage(pokemon, pokemon);
}
// Pokémon that can cross water or lava have a walkable tile value of 4 (WALKABLE_TILE_LAVA) or 5 (WALKABLE_TILE_WATER), respectively.
// Indices 4 and 5 in this array are assigned either CROSSABLE_TERRAIN_REGULAR or CROSSABLE_TERRAIN_LIQUID
// depending on whether the dungeon's liquid is water or lava.
// For example, a lava dungeon like Mt. Blaze would have these values:
// gWalkableTileToCrossableTerrain[WALKABLE_TILE_LAVA]: CROSSABLE_TERRAIN_LIQUID
// gWalkableTileToCrossableTerrain[WALKABLE_TILE_WATER]: CROSSABLE_TERRAIN_REGULAR
// This means a Fire-type can cross the dungeon's liquid, while a Water-type cannot.
return gWalkableTileToCrossableTerrain[walkableTiles];
}
else
{
pokemonData->targetingDecoy = TARGETING_DECOY_NONE;
if (pokemonData->clientType == CLIENT_TYPE_NONE || IsMovingClient(pokemon))
{
if (pokemonData->clientType != CLIENT_TYPE_CLIENT && pokemonData->useHeldItem)
{
if (CannotUseItems(pokemon))
{
pokemonData->useHeldItem = FALSE;
SetMessageArgument(gAvailablePokemonNames, pokemon, 0);
SendMessage(pokemon, gPtrCouldntBeUsedMessage);
return;
}
DecideUseItem(pokemon);
if (pokemonData->action.action != DUNGEON_ACTION_NONE)
{
return;
}
}
if (!HasStatusAffectingActions(pokemon))
{
if (gDungeonGlobalData->decoyActive)
{
s32 i;
struct DungeonEntity *target;
for (i = 0; i < DUNGEON_MAX_POKEMON; i++)
{
target = gDungeonGlobalData->allPokemon[i];
if (EntityExists(target) &&
target->entityData->waitingStatus == WAITING_STATUS_DECOY &&
CanSee(pokemon, target))
{
bool8 enemyDecoy = target->entityData->enemyDecoy;
u8 targetingDecoy = TARGETING_DECOY_TEAM;
if (enemyDecoy)
{
targetingDecoy = TARGETING_DECOY_WILD;
}
pokemonData->targetingDecoy = targetingDecoy;
break;
}
}
}
ResetAction(&pokemonData->action.action);
if (pokemonData->clientType == CLIENT_TYPE_CLIENT)
{
SetWalkAction(&pokemonData->action, pokemonData->entityID);
pokemonData->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS);
pokemonData->targetPosition.x = pokemon->posWorld.x;
pokemonData->targetPosition.y = pokemon->posWorld.y - 1;
}
else
{
DecideUseItem(pokemon);
if (pokemonData->action.action == DUNGEON_ACTION_NONE)
{
if (!HasIQSkill(pokemon, IQ_SKILL_DEDICATED_TRAVELER))
{
DecideAttack(pokemon);
if (pokemonData->action.action != DUNGEON_ACTION_NONE)
{
return;
}
if (pokemonData->volatileStatus == VOLATILE_STATUS_CONFUSED)
{
SetWalkAction(&pokemonData->action, pokemonData->entityID);
}
else
{
if (!GetIsMoving(pokemonData->entityID))
{
return;
}
MoveIfPossible(pokemon, TRUE);
}
}
else
{
if (pokemonData->volatileStatus == VOLATILE_STATUS_CONFUSED)
{
SetWalkAction(&pokemonData->action, pokemonData->entityID);
}
else
{
if (GetIsMoving(pokemonData->entityID))
{
MoveIfPossible(pokemon, TRUE);
}
if (pokemonData->action.action > DUNGEON_ACTION_WAIT)
{
return;
}
DecideAttack(pokemon);
if (pokemonData->action.action <= DUNGEON_ACTION_WAIT)
{
return;
}
pokemonData->notAdjacentToTarget = FALSE;
pokemonData->movingIntoTarget = FALSE;
pokemonData->waiting = FALSE;
}
}
}
}
}
}
return walkableTiles;
}
}
void sub_8075BA4(struct DungeonEntity *param_1,char param_2)
{
struct DungeonEntityData * iVar2 = param_1->entityData;
if ((param_2 != '\0') && (iVar2->volatileStatus == VOLATILE_STATUS_COWERING)) {
iVar2->action.facingDir = (iVar2->action.facingDir + 4) & DIRECTION_MASK;
TargetTileInFront(param_1);
}
else if (iVar2->volatileStatus == VOLATILE_STATUS_CONFUSED) {
iVar2->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS);
TargetTileInFront(param_1);
}
}

View File

@@ -3,7 +3,7 @@
#include "dungeon_map_access.h"
const struct Position gAdjacentTileOffsets[NUM_DIRECTIONS] = {
const struct Position gAdjacentTileOffsets[] = {
{0, 1},
{1, 1},
{1, 0},

View File

@@ -132,7 +132,7 @@ extern void sub_808F468(struct PokemonStruct *, u8 *, u32);
bool8 LuminousCave_HasOnly1Member(void);
enum
enum
{
LUMINOUS_CAVE_ENTRY,
LUMINOUS_CAVE_ASK_EVOLVE,
@@ -284,7 +284,7 @@ void sub_8024804(void)
void UpdateLuminousCaveDialogue(void)
{
char *monName;
switch(gUnknown_203B2B0->state) {
case LUMINOUS_CAVE_ENTRY:
if (LuminousCave_HasOnly1Member()) {
@@ -306,7 +306,7 @@ void UpdateLuminousCaveDialogue(void)
break;
case LUMINOUS_CAVE_SHALL_RETURN:
gUnknown_203B2B0->fallbackState = 4;
xxx_call_fade_in_new_bgm(MUS_LOADING_SCREEN,0x3c);
xxx_call_fade_in_new_bgm(MUS_FILE_SELECT,0x3c);
sub_80141B4(gLuminousCaveYeShallReturn,0,0,0x305);
break;

View File

@@ -6,6 +6,7 @@
#include "constants/status.h"
#include "code_80521D0.h"
#include "dungeon_action.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_random.h"
extern char *gPtrFrozenMessage;
@@ -17,7 +18,6 @@ extern char *gPtrInfatuatedMessage;
extern char gAvailablePokemonNames[];
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
extern bool8 CanMoveForward2(struct DungeonEntity*, u8);
extern void DecideAttack(struct DungeonEntity*);
bool8 HasStatusAffectingActions(struct DungeonEntity *pokemon)
@@ -74,7 +74,7 @@ bool8 HasStatusAffectingActions(struct DungeonEntity *pokemon)
}
if (pokemonData->eyesightStatus == EYESIGHT_STATUS_BLINKER)
{
if (!CanMoveForward2(pokemon, pokemonData->action.facingDir))
if (!CanMoveInDirection(pokemon, pokemonData->action.facingDir))
{
if (DungeonRandomCapped(2) != 0)
{

View File

@@ -831,7 +831,7 @@ gUnknown_202F30C = .; /* 202F30C */
gUnknown_202F310 = .; /* 202F310 */
. += 0x4;
gUnknown_202F314 = .; /* 202F314 */
gWalkableTileToCrossableTerrain = .; /* 202F314 */
. += 0x8;
gUnknown_202F31C = .; /* 202F31C */