Decompile map_obj_lock

This commit is contained in:
KDSKardabox 2018-04-03 16:22:31 +05:30
parent b74b576418
commit 3948614bff
4 changed files with 191 additions and 475 deletions

View File

@ -1,474 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start walkrun_is_standing_still
walkrun_is_standing_still: @ 8098388
push {lr}
ldr r0, =gPlayerAvatar
ldrb r0, [r0, 0x3]
cmp r0, 0x1
beq _0809839C
movs r0, 0x1
b _0809839E
.pool
_0809839C:
movs r0, 0
_0809839E:
pop {r1}
bx r1
thumb_func_end walkrun_is_standing_still
thumb_func_start sub_80983A4
sub_80983A4: @ 80983A4
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
bl walkrun_is_standing_still
lsls r0, 24
cmp r0, 0
beq _080983BE
bl sub_808B864
adds r0, r4, 0
bl DestroyTask
_080983BE:
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_80983A4
thumb_func_start sub_80983C4
sub_80983C4: @ 80983C4
push {lr}
ldr r0, =sub_80983A4
bl FuncIsActiveTask
lsls r0, 24
cmp r0, 0
bne _080983E0
bl sub_808BCF4
movs r0, 0x1
b _080983E2
.pool
_080983E0:
movs r0, 0
_080983E2:
pop {r1}
bx r1
thumb_func_end sub_80983C4
thumb_func_start ScriptFreezeMapObjects
ScriptFreezeMapObjects: @ 80983E8
push {lr}
bl FreezeMapObjects
ldr r0, =sub_80983A4
movs r1, 0x50
bl CreateTask
pop {r0}
bx r0
.pool
thumb_func_end ScriptFreezeMapObjects
thumb_func_start sub_8098400
sub_8098400: @ 8098400
push {r4-r6,lr}
lsls r0, 24
lsrs r6, r0, 24
lsls r0, r6, 2
adds r0, r6
lsls r0, 3
ldr r1, =gTasks
adds r5, r0, r1
movs r1, 0x8
ldrsh r0, [r5, r1]
cmp r0, 0
bne _0809842A
bl walkrun_is_standing_still
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x1
bne _0809842A
bl sub_808B864
strh r4, [r5, 0x8]
_0809842A:
movs r1, 0xA
ldrsh r0, [r5, r1]
cmp r0, 0
bne _08098452
ldr r2, =gMapObjects
ldr r0, =gSelectedMapObject
ldrb r1, [r0]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
adds r1, r0, r2
ldrb r0, [r1]
lsls r0, 30
cmp r0, 0
blt _08098452
adds r0, r1, 0
bl FreezeMapObject
movs r0, 0x1
strh r0, [r5, 0xA]
_08098452:
movs r1, 0x8
ldrsh r0, [r5, r1]
cmp r0, 0
beq _08098468
movs r1, 0xA
ldrsh r0, [r5, r1]
cmp r0, 0
beq _08098468
adds r0, r6, 0
bl DestroyTask
_08098468:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_8098400
thumb_func_start sub_809847C
sub_809847C: @ 809847C
push {lr}
ldr r0, =sub_8098400
bl FuncIsActiveTask
lsls r0, 24
cmp r0, 0
bne _08098498
bl sub_808BCF4
movs r0, 0x1
b _0809849A
.pool
_08098498:
movs r0, 0
_0809849A:
pop {r1}
bx r1
thumb_func_end sub_809847C
thumb_func_start LockSelectedMapObject
LockSelectedMapObject: @ 80984A0
push {r4,r5,lr}
ldr r4, =gSelectedMapObject
ldrb r0, [r4]
bl FreezeMapObjectsExceptOne
ldr r0, =sub_8098400
movs r1, 0x50
bl CreateTask
lsls r0, 24
lsrs r5, r0, 24
ldr r2, =gMapObjects
ldrb r1, [r4]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
adds r1, r0, r2
ldrb r0, [r1]
lsls r0, 30
cmp r0, 0
blt _080984DE
adds r0, r1, 0
bl FreezeMapObject
ldr r0, =gTasks
lsls r1, r5, 2
adds r1, r5
lsls r1, 3
adds r1, r0
movs r0, 0x1
strh r0, [r1, 0xA]
_080984DE:
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end LockSelectedMapObject
thumb_func_start sub_80984F4
sub_80984F4: @ 80984F4
push {lr}
movs r0, 0xFF
movs r1, 0
movs r2, 0
bl GetFieldObjectIdByLocalIdAndMap
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
ldr r1, =gMapObjects
adds r0, r1
bl FieldObjectClearAnimIfSpecialAnimFinished
bl sub_80D338C
bl UnfreezeMapObjects
pop {r0}
bx r0
.pool
thumb_func_end sub_80984F4
thumb_func_start sub_8098524
sub_8098524: @ 8098524
push {r4,lr}
ldr r4, =gMapObjects
ldr r0, =gSelectedMapObject
ldrb r1, [r0]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
adds r1, r0, r4
ldrb r0, [r1]
lsls r0, 31
cmp r0, 0
beq _08098542
adds r0, r1, 0
bl FieldObjectClearAnimIfSpecialAnimFinished
_08098542:
movs r0, 0xFF
movs r1, 0
movs r2, 0
bl GetFieldObjectIdByLocalIdAndMap
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
adds r0, r4
bl FieldObjectClearAnimIfSpecialAnimFinished
bl sub_80D338C
bl UnfreezeMapObjects
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8098524
thumb_func_start sub_8098574
sub_8098574: @ 8098574
push {lr}
ldr r0, =gSelectedMapObject
ldrb r1, [r0]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
ldr r1, =gMapObjects
adds r0, r1
ldr r1, =gSpecialVar_Facing
ldrb r1, [r1]
bl FieldObjectFaceOppositeDirection
pop {r0}
bx r0
.pool
thumb_func_end sub_8098574
thumb_func_start sub_809859C
sub_809859C: @ 809859C
push {lr}
ldr r0, =gSelectedMapObject
ldrb r1, [r0]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
ldr r1, =gMapObjects
adds r0, r1
bl FieldObjectClearAnimIfSpecialAnimActive
pop {r0}
bx r0
.pool
thumb_func_end sub_809859C
thumb_func_start sub_80985BC
sub_80985BC: @ 80985BC
push {r4-r7,lr}
lsls r0, 24
lsrs r6, r0, 24
lsls r0, r6, 2
adds r0, r6
lsls r0, 3
ldr r1, =gTasks
adds r5, r0, r1
ldrb r7, [r5, 0xC]
movs r1, 0x8
ldrsh r0, [r5, r1]
cmp r0, 0
bne _080985E8
bl walkrun_is_standing_still
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x1
bne _080985E8
bl sub_808B864
strh r4, [r5, 0x8]
_080985E8:
movs r1, 0xA
ldrsh r0, [r5, r1]
cmp r0, 0
bne _0809860C
ldr r0, =gMapObjects
lsls r1, r7, 3
adds r1, r7
lsls r1, 2
adds r1, r0
ldrb r0, [r1]
lsls r0, 30
cmp r0, 0
blt _0809860C
adds r0, r1, 0
bl FreezeMapObject
movs r0, 0x1
strh r0, [r5, 0xA]
_0809860C:
movs r1, 0x8
ldrsh r0, [r5, r1]
cmp r0, 0
beq _08098622
movs r1, 0xA
ldrsh r0, [r5, r1]
cmp r0, 0
beq _08098622
adds r0, r6, 0
bl DestroyTask
_08098622:
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_80985BC
thumb_func_start sub_8098630
sub_8098630: @ 8098630
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
movs r0, 0
bl GetChosenApproachingTrainerMapObjectId
lsls r0, 24
lsrs r4, r0, 24
ldr r0, =gNoOfApproachingTrainers
ldrb r0, [r0]
cmp r0, 0x2
bne _080986E0
movs r0, 0x1
bl GetChosenApproachingTrainerMapObjectId
lsls r0, 24
lsrs r0, 24
adds r5, r0, 0
adds r0, r4, 0
adds r1, r5, 0
bl sub_8098074
ldr r7, =sub_80985BC
adds r0, r7, 0
movs r1, 0x50
bl CreateTask
lsls r0, 24
lsrs r2, r0, 24
ldr r0, =gTasks
mov r9, r0
lsls r0, r2, 2
adds r0, r2
lsls r0, 3
mov r1, r9
adds r6, r0, r1
strh r4, [r6, 0xC]
ldr r2, =gMapObjects
mov r8, r2
lsls r0, r4, 3
adds r0, r4
lsls r0, 2
adds r1, r0, r2
ldrb r0, [r1]
lsls r0, 30
cmp r0, 0
blt _0809869A
adds r0, r1, 0
bl FreezeMapObject
movs r0, 0x1
strh r0, [r6, 0xA]
_0809869A:
adds r0, r7, 0
movs r1, 0x51
bl CreateTask
lsls r0, 24
lsrs r2, r0, 24
lsls r0, r2, 2
adds r0, r2
lsls r0, 3
mov r1, r9
adds r4, r0, r1
strh r5, [r4, 0xC]
lsls r0, r5, 3
adds r0, r5
lsls r0, 2
mov r2, r8
adds r1, r0, r2
ldrb r0, [r1]
lsls r0, 30
cmp r0, 0
blt _0809871A
adds r0, r1, 0
bl FreezeMapObject
movs r0, 0x1
strh r0, [r4, 0xA]
b _0809871A
.pool
_080986E0:
adds r0, r4, 0
bl FreezeMapObjectsExceptOne
ldr r0, =sub_80985BC
movs r1, 0x50
bl CreateTask
lsls r0, 24
lsrs r2, r0, 24
ldr r1, =gTasks
lsls r0, r2, 2
adds r0, r2
lsls r0, 3
adds r5, r0, r1
strh r4, [r5, 0xC]
ldr r1, =gMapObjects
lsls r0, r4, 3
adds r0, r4
lsls r0, 2
adds r1, r0, r1
ldrb r0, [r1]
lsls r0, 30
cmp r0, 0
blt _0809871A
adds r0, r1, 0
bl FreezeMapObject
movs r0, 0x1
strh r0, [r5, 0xA]
_0809871A:
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_8098630
thumb_func_start sub_8098734
sub_8098734: @ 8098734
push {lr}
ldr r0, =sub_80985BC
bl FuncIsActiveTask
lsls r0, 24
cmp r0, 0
bne _08098750
bl sub_808BCF4
movs r0, 0x1
b _08098752
.pool
_08098750:
movs r0, 0
_08098752:
pop {r1}
bx r1
thumb_func_end sub_8098734
.align 2, 0 @ Don't pad with nop.

View File

@ -27,6 +27,9 @@ void sub_8098044(u8);
void UnfreezeMapObjects(void); void UnfreezeMapObjects(void);
void FreezeMapObjectsExceptOne(u8 mapObjectId); void FreezeMapObjectsExceptOne(u8 mapObjectId);
void sub_8097B78(u8, u8); void sub_8097B78(u8, u8);
void sub_8098074(u8 var1, u8 var2);
void FreezeMapObjects(void); void FreezeMapObjects(void);
bool8 FreezeMapObject(struct MapObject *mapObject);
#endif //GUARD_FIELD_MAP_OBJ_HELPERS_H #endif //GUARD_FIELD_MAP_OBJ_HELPERS_H

View File

@ -96,7 +96,7 @@ SECTIONS {
asm/field_ground_effect.o(.text); asm/field_ground_effect.o(.text);
src/field_map_obj_helpers.o(.text); src/field_map_obj_helpers.o(.text);
src/field_message_box.o(.text); src/field_message_box.o(.text);
asm/map_obj_lock.o(.text); src/map_obj_lock.o(.text);
src/text_window.o(.text); src/text_window.o(.text);
src/script.o(.text); src/script.o(.text);
src/scrcmd.o(.text); src/scrcmd.o(.text);

187
src/map_obj_lock.c Normal file
View File

@ -0,0 +1,187 @@
#include "global.h"
#include "event_data.h"
#include "field_map_obj.h"
#include "field_map_obj_helpers.h"
#include "field_player_avatar.h"
#include "map_obj_lock.h"
#include "script_movement.h"
#include "task.h"
#include "trainer_see.h"
bool8 walkrun_is_standing_still(void)
{
if (gPlayerAvatar.tileTransitionState == T_TILE_TRANSITION)
return FALSE;
else
return TRUE;
}
static void sub_80983A4(u8 taskId)
{
if (walkrun_is_standing_still())
{
sub_808B864();
DestroyTask(taskId);
}
}
bool8 sub_80983C4(void)
{
if (FuncIsActiveTask(sub_80983A4))
{
return FALSE;
}
else
{
sub_808BCF4();
return TRUE;
}
}
void ScriptFreezeMapObjects(void)
{
FreezeMapObjects();
CreateTask(sub_80983A4, 80);
}
static void sub_8098400(u8 taskId)
{
struct Task *task = &gTasks[taskId];
if (!task->data[0] && walkrun_is_standing_still() == TRUE)
{
sub_808B864();
task->data[0] = 1;
}
if (!task->data[1] && !gMapObjects[gSelectedMapObject].mapobj_bit_1)
{
FreezeMapObject(&gMapObjects[gSelectedMapObject]);
task->data[1] = 1;
}
if (task->data[0] && task->data[1])
DestroyTask(taskId);
}
bool8 sub_809847C(void)
{
if (FuncIsActiveTask(sub_8098400))
{
return FALSE;
}
else
{
sub_808BCF4();
return TRUE;
}
}
void LockSelectedMapObject(void)
{
u8 taskId;
FreezeMapObjectsExceptOne(gSelectedMapObject);
taskId = CreateTask(sub_8098400, 80);
if (!gMapObjects[gSelectedMapObject].mapobj_bit_1)
{
FreezeMapObject(&gMapObjects[gSelectedMapObject]);
gTasks[taskId].data[1] = 1;
}
}
void sub_80984F4(void)
{
u8 objectId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0);
FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[objectId]);
sub_80D338C();
UnfreezeMapObjects();
}
void sub_8098524(void)
{
u8 objectId;
if (gMapObjects[gSelectedMapObject].active)
FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[gSelectedMapObject]);
objectId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0);
FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[objectId]);
sub_80D338C();
UnfreezeMapObjects();
}
void sub_8098574(void)
{
FieldObjectFaceOppositeDirection(&gMapObjects[gSelectedMapObject], gSpecialVar_Facing);
}
void sub_809859C(void)
{
FieldObjectClearAnimIfSpecialAnimActive(&gMapObjects[gSelectedMapObject]);
}
static void sub_80985BC(u8 taskId)
{
struct Task *task = &gTasks[taskId];
u8 mapObjectId = task->data[2];
if (!task->data[0] && walkrun_is_standing_still() == TRUE)
{
sub_808B864();
task->data[0] = 1;
}
if (!task->data[1] && !gMapObjects[mapObjectId].mapobj_bit_1)
{
FreezeMapObject(&gMapObjects[mapObjectId]);
task->data[1] = 1;
}
if (task->data[0] && task->data[1])
DestroyTask(taskId);
}
void sub_8098630(void)
{
u8 mapObjectIdArray0, mapObjectIdArray1, taskId;
mapObjectIdArray0 = GetChosenApproachingTrainerMapObjectId(0);
if(gNoOfApproachingTrainers == 2)
{
mapObjectIdArray1 = GetChosenApproachingTrainerMapObjectId(1);
sub_8098074(mapObjectIdArray0, mapObjectIdArray1);
taskId = CreateTask(sub_80985BC, 80);
gTasks[taskId].data[2] = mapObjectIdArray0;
if(!gMapObjects[mapObjectIdArray0].mapobj_bit_1)
{
FreezeMapObject(&gMapObjects[mapObjectIdArray0]);
gTasks[taskId].data[1] = 1;
}
taskId = CreateTask(sub_80985BC, 81);
gTasks[taskId].data[2] = mapObjectIdArray1;
if(!gMapObjects[mapObjectIdArray1].mapobj_bit_1)
{
FreezeMapObject(&gMapObjects[mapObjectIdArray1]);
gTasks[taskId].data[1] = 1;
}
}
else
{
FreezeMapObjectsExceptOne(mapObjectIdArray0);
taskId = CreateTask(sub_80985BC, 80);
gTasks[taskId].data[2] = mapObjectIdArray0;
if(!gMapObjects[mapObjectIdArray0].mapobj_bit_1)
{
FreezeMapObject(&gMapObjects[mapObjectIdArray0]);
gTasks[taskId].data[1] = 1;
}
}
}
bool8 sub_8098734(void)
{
if (FuncIsActiveTask(sub_80985BC))
{
return FALSE;
}
else
{
sub_808BCF4();
return TRUE;
}
}