decomp few more trap funcs and fix some names

This commit is contained in:
Seth Barberee 2024-01-06 10:23:18 -08:00
parent 5b9a0c743b
commit 3635d87b57
8 changed files with 91 additions and 175 deletions

View File

@ -4665,7 +4665,7 @@ _08054CFE:
adds r1, r5, 0
mov r2, r8
mov r3, r9
bl sub_805C3DC
bl TrapperOrbAction
b _080554BA
_08054D0C:
adds r0, r7, 0
@ -4800,7 +4800,7 @@ _08054E0C:
adds r1, r5, 0
mov r2, r8
mov r3, r9
bl TrapperOrbAction
bl SpikesMoveAction
b _080554BA
_08054E1A:
adds r0, r7, 0

View File

@ -5,165 +5,6 @@
.text
thumb_func_start sub_807FCD4
sub_807FCD4:
push {r4-r7,lr}
mov r7, r8
push {r7}
adds r7, r0, 0
lsls r1, 24
lsrs r5, r1, 24
lsls r2, 24
lsrs r2, 24
mov r8, r2
movs r1, 0
ldrsh r0, [r7, r1]
movs r2, 0x2
ldrsh r1, [r7, r2]
bl GetTileSafe
adds r6, r0, 0
cmp r5, 0x13
bls _0807FD12
movs r4, 0
b _0807FCFE
_0807FCFC:
adds r4, 0x1
_0807FCFE:
cmp r4, 0x1D
bgt _0807FD0C
bl sub_803D6FC
adds r5, r0, 0
cmp r5, 0x11
beq _0807FCFC
_0807FD0C:
cmp r4, 0x1E
bne _0807FD12
movs r5, 0x10
_0807FD12:
ldrh r1, [r6]
movs r0, 0x80
lsls r0, 2
ands r0, r1
cmp r0, 0
bne _0807FD6E
ldrb r0, [r6, 0x9]
cmp r0, 0xFF
beq _0807FD6E
movs r0, 0x8
ands r0, r1
cmp r0, 0
bne _0807FD6E
movs r0, 0x20
ands r0, r1
cmp r0, 0
bne _0807FD6E
movs r4, 0x3
ands r4, r1
cmp r4, 0x1
bne _0807FD6E
ldr r0, [r6, 0x14]
cmp r0, 0
beq _0807FD60
bl GetEntityType
cmp r0, 0x2
bne _0807FD6E
ldr r0, [r6, 0x14]
bl GetTrapData
strb r5, [r0]
ldr r0, [r6, 0x14]
bl GetTrapData
mov r1, r8
strb r1, [r0, 0x1]
ldr r0, [r6, 0x14]
b _0807FD74
_0807FD60:
adds r0, r5, 0
adds r1, r7, 0
mov r2, r8
bl sub_8045684
cmp r0, 0
bne _0807FD72
_0807FD6E:
movs r0, 0
b _0807FD7A
_0807FD72:
str r0, [r6, 0x14]
_0807FD74:
adds r0, 0x20
strb r4, [r0]
movs r0, 0x1
_0807FD7A:
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_807FCD4
thumb_func_start sub_807FD84
sub_807FD84:
push {r4-r6,lr}
adds r6, r0, 0
movs r5, 0
ldr r4, _0807FD9C
ldr r0, [r4]
ldr r2, _0807FDA0
adds r1, r0, r2
ldrb r0, [r1]
cmp r0, 0
bne _0807FDA4
movs r0, 0
b _0807FDF6
.align 2, 0
_0807FD9C: .4byte gDungeon
_0807FDA0: .4byte 0x00013570
_0807FDA4:
strb r5, [r1]
ldr r2, [r4]
ldr r3, _0807FDD8
adds r0, r2, r3
adds r3, 0x4
adds r1, r2, r3
ldrb r1, [r1]
adds r3, 0x1
adds r2, r3
ldrb r2, [r2]
bl sub_807FCD4
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0
beq _0807FDE0
ldr r1, [r4]
ldr r0, _0807FDD8
adds r1, r0
ldr r0, _0807FDDC
ldr r2, [r0]
adds r0, r6, 0
bl sub_8052364
b _0807FDF0
.align 2, 0
_0807FDD8: .4byte 0x00013574
_0807FDDC: .4byte gUnknown_80FC5F8
_0807FDE0:
ldr r1, [r4]
ldr r2, _0807FDFC
adds r1, r2
ldr r0, _0807FE00
ldr r2, [r0]
adds r0, r6, 0
bl sub_8052364
_0807FDF0:
bl sub_8049ED4
adds r0, r5, 0
_0807FDF6:
pop {r4-r6}
pop {r1}
bx r1
.align 2, 0
_0807FDFC: .4byte 0x00013574
_0807FE00: .4byte gUnknown_80FC5FC
thumb_func_end sub_807FD84
thumb_func_start sub_807FE04
sub_807FE04:
push {r4,r5,lr}

View File

@ -22,7 +22,8 @@ enum TrapID
TRAP_CHESTNUT_TRAP,
TRAP_WONDER_TILE,
TRAP_POKEMON_TRAP,
TRAP_SPIKE_TRAP
TRAP_SPIKE_TRAP,
NUM_TRAPS
};
#endif // GUARD_CONSTANTS_TRAP_H
#endif // GUARD_CONSTANTS_TRAP_H

View File

@ -187,9 +187,8 @@ typedef struct Dungeon
u8 fill1356D[0x13570 - 0x1356D];
/* 0x13570 */ u8 unk13570;
u8 fill13571[0x13574 - 0x13571];
/* 0x13574 */ u16 unk13574;
/* 0x13576 */ u16 unk13576;
/* 0x13578 */ u8 unk13578;
/* 0x13574 */ Position trapPos;
/* 0x13578 */ u8 trapID;
/* 0x13579 */ u8 unk13579;
u8 fill1357A[0x1357C - 0x1357A];
/* 0x1357C */ Entity *teamPokemon[MAX_TEAM_MEMBERS];

View File

@ -4,5 +4,6 @@
#include "structs/str_position.h"
bool8 CanLayTrap(Position *pos);
bool8 LayTrap(Position *pos, u8 trapID, u8 param_3);
#endif

View File

@ -1,11 +1,11 @@
#include "global.h"
#include "structs/str_dungeon.h"
void sub_807FC3C(Position *pos, u32 param_2, u32 param_3)
void sub_807FC3C(Position *pos, u32 trapID, u32 param_3)
{
gDungeon->unk13574 = pos->x;
gDungeon->unk13576 = pos->y;
gDungeon->unk13578 = param_2;
gDungeon->trapPos.x = pos->x;
gDungeon->trapPos.y = pos->y;
gDungeon->trapID = trapID;
gDungeon->unk13579 = param_3;
gDungeon->unk13570 = 1;
}

View File

@ -86,7 +86,6 @@ extern void SqueezedStatusTarget(Entity *, Entity *, s32, bool32);
extern void sub_806F324(Entity *, s32, u32, u32);
extern bool8 sub_805755C(Entity* pokemon,u16 moveID);
extern void sub_80783C4(Entity *, Entity *, u32);
extern bool8 sub_807FCD4(Position *, u32, u8);
extern void sub_807CD9C(Entity *, Entity *, u8 direction);
@ -309,7 +308,7 @@ bool8 sub_805B214(Entity * pokemon,Entity * target,Move *move, s32 param_4)
return TRUE;
}
bool8 TrapperOrbAction(Entity * pokemon, Entity * target)
bool8 SpikesMoveAction(Entity * pokemon, Entity * target)
{
bool8 trapLaid;
u8 uVar2;
@ -322,7 +321,7 @@ bool8 TrapperOrbAction(Entity * pokemon, Entity * target)
if (isNotTeamMember) {
uVar2 = 2;
}
if (sub_807FCD4(&pokemon->pos,0x13,uVar2) != 0) {
if (LayTrap(&pokemon->pos,TRAP_SPIKE_TRAP,uVar2) != 0) {
trapLaid = TRUE;
}
else
@ -1214,11 +1213,11 @@ bool8 FillInOrbAction(Entity *pokemon,Entity *target)
}
}
bool8 sub_805C3DC(Entity *pokemon, Entity *target)
bool8 TrapperOrbAction(Entity *pokemon, Entity *target)
{
u32 var;
var = (target->info->isNotTeamMember ? 2 : 1);
sub_807FC3C(&target->pos, 0x14, var);
sub_807FC3C(&target->pos, NUM_TRAPS, var);
return TRUE;
}

View File

@ -1,10 +1,20 @@
#include "global.h"
#include "constants/trap.h"
#include "structs/str_dungeon.h"
#include "trap.h"
#include "dungeon_map_access.h"
#include "dungeon_util.h"
#include "structs/map.h"
extern u8 *gUnknown_80FC5FC[];
extern u8 *gUnknown_80FC5F8[];
void sub_8052364(Entity *, Position *, u8 *);
void sub_8049ED4(void);
u8 sub_803D6FC(void);
Entity *sub_8045684(u8, Position *, u8);
bool8 CanLayTrap(Position *pos)
{
struct Tile *tile = GetTileSafe(pos->x, pos->y);
@ -25,3 +35,68 @@ bool8 CanLayTrap(Position *pos)
}
return TRUE;
}
bool8 LayTrap(Position *pos, u8 trapID, u8 param_3)
{
Tile *tile;
Entity *entity;
int counter;
u16 terrainType;
tile = GetTileSafe(pos->x, pos->y);
if (TRAP_SPIKE_TRAP < trapID) {
counter = 0;
while ((counter < 0x1e && (trapID = sub_803D6FC(), trapID == TRAP_WONDER_TILE))) {
counter++;
}
if (counter == 0x1e) {
trapID = TRAP_CHESTNUT_TRAP;
}
}
terrainType = tile->terrainType;
if ((terrainType & TERRAIN_TYPE_STAIRS) != 0) goto _0807FD6E;
if (tile->room == CORRIDOR_ROOM) goto _0807FD6E;
if ((terrainType & TERRAIN_TYPE_NATURAL_JUNCTION) != 0) goto _0807FD6E;
if ((terrainType & TERRAIN_TYPE_SHOP) != 0) goto _0807FD6E;
if (((terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) != TERRAIN_TYPE_NORMAL)) goto _0807FD6E;
if (tile->object != NULL) {
if (GetEntityType(tile->object) != ENTITY_TRAP) goto _0807FD6E;
GetTrapData(tile->object)->id = trapID;
GetTrapData(tile->object)->unk1 = param_3;
tile->object->isVisible = TRUE;
}
else {
entity = sub_8045684(trapID,pos,param_3);
if (entity == NULL)
_0807FD6E:
return FALSE;
else
{
tile->object = entity;
tile->object->isVisible = TRUE;
}
}
return TRUE;
}
bool8 sub_807FD84(Entity *entity)
{
bool8 flag;
flag = FALSE;
if (gDungeon->unk13570 == 0) {
return FALSE;
}
else {
gDungeon->unk13570 = 0;
flag = LayTrap(&gDungeon->trapPos,gDungeon->trapID,gDungeon->unk13579);
if (flag) {
sub_8052364(entity,&gDungeon->trapPos,*gUnknown_80FC5F8); // A trap was laid!
}
else {
sub_8052364(entity,&gDungeon->trapPos,*gUnknown_80FC5FC); // A trap can't be laid here.
}
sub_8049ED4();
}
return flag;
}