sub_80EA3E4

This commit is contained in:
PikalaxALT 2017-10-26 23:35:41 -04:00
parent afcb30ccb0
commit fbfcce3f35
4 changed files with 159 additions and 489 deletions

View File

@ -5,495 +5,6 @@
.text
thumb_func_start sub_80EA3E4
sub_80EA3E4: @ 80EA3E4
push {r4-r6,lr}
sub sp, 0x4
lsls r0, 24
lsrs r0, 24
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
ldr r0, =gTasks + 0x8
adds r5, r1, r0
movs r1, 0x2
ldrsh r0, [r5, r1]
cmp r0, 0x1
beq _080EA448
cmp r0, 0x1
bgt _080EA40C
cmp r0, 0
beq _080EA414
b _080EA820
.pool
_080EA40C:
cmp r0, 0x2
bne _080EA412
b _080EA810
_080EA412:
b _080EA820
_080EA414:
ldr r0, =0x00004054
bl VarGet
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
beq _080EA434
ldr r1, =gUnknown_0203A01D
movs r0, 0x1
strb r0, [r1]
b _080EA438
.pool
_080EA434:
ldr r0, =gUnknown_0203A01D
strb r1, [r0]
_080EA438:
adds r0, r5, 0x4
adds r1, r5, 0x6
bl PlayerGetDestCoords
b _080EA81C
.pool
_080EA448:
mov r4, sp
adds r4, 0x2
mov r0, sp
adds r1, r4, 0
bl PlayerGetDestCoords
mov r0, sp
ldrh r2, [r0]
movs r3, 0
ldrsh r1, [r0, r3]
movs r3, 0x4
ldrsh r0, [r5, r3]
adds r6, r4, 0
cmp r1, r0
bne _080EA474
movs r0, 0
ldrsh r1, [r6, r0]
movs r3, 0x6
ldrsh r0, [r5, r3]
cmp r1, r0
bne _080EA474
b _080EA820
_080EA474:
strh r2, [r5, 0x4]
ldrh r0, [r6]
strh r0, [r5, 0x6]
ldr r4, =0x000040ec
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
adds r1, 0x1
lsls r1, 16
lsrs r1, 16
adds r0, r4, 0
bl VarSet
mov r0, sp
movs r1, 0
ldrsh r0, [r0, r1]
movs r2, 0
ldrsh r1, [r6, r2]
bl MapGridGetMetatileBehaviorAt
lsls r0, 24
lsrs r5, r0, 24
mov r0, sp
movs r3, 0
ldrsh r0, [r0, r3]
movs r2, 0
ldrsh r1, [r6, r2]
bl MapGridGetMetatileIdAt
lsls r0, 16
lsrs r4, r0, 16
movs r0, 0x8D
lsls r0, 2
cmp r4, r0
beq _080EA4C2
adds r0, 0x8
cmp r4, r0
bne _080EA4E8
_080EA4C2:
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
beq _080EA4CC
b _080EA820
_080EA4CC:
ldr r4, =0x000040ef
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r0, 0x20
b _080EA7FA
.pool
_080EA4E8:
ldr r3, =0xfffffd48
adds r0, r4, r3
lsls r0, 16
lsrs r0, 16
cmp r0, 0x2
bls _080EA51A
movs r0, 0xB0
lsls r0, 2
cmp r4, r0
beq _080EA51A
adds r0, 0x1
cmp r4, r0
beq _080EA51A
adds r0, 0x1
cmp r4, r0
beq _080EA51A
adds r0, 0x6
cmp r4, r0
beq _080EA51A
adds r0, 0x1
cmp r4, r0
beq _080EA51A
adds r0, 0x1
cmp r4, r0
bne _080EA540
_080EA51A:
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
beq _080EA524
b _080EA820
_080EA524:
ldr r4, =0x000040ee
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r0, 0x1
b _080EA7FA
.pool
_080EA540:
ldr r0, =0x00000239
cmp r4, r0
beq _080EA558
adds r0, 0x8
cmp r4, r0
beq _080EA558
adds r0, 0x10
cmp r4, r0
beq _080EA558
adds r0, 0x8
cmp r4, r0
bne _080EA57C
_080EA558:
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
beq _080EA562
b _080EA820
_080EA562:
ldr r4, =0x000040ee
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r0, 0x4
b _080EA7FA
.pool
_080EA57C:
cmp r5, 0x34
bne _080EA586
ldr r0, =0x0000026d
cmp r4, r0
beq _080EA59E
_080EA586:
cmp r5, 0x35
bne _080EA5CC
mov r0, sp
movs r1, 0
ldrsh r0, [r0, r1]
movs r2, 0
ldrsh r1, [r6, r2]
bl MapGridGetMetatileIdAt
ldr r1, =0x0000026a
cmp r0, r1
bne _080EA5CC
_080EA59E:
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
beq _080EA5A8
b _080EA820
_080EA5A8:
ldr r4, =0x000040ef
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r3, 0x80
lsls r3, 2
adds r0, r3, 0
b _080EA7FA
.pool
_080EA5CC:
cmp r5, 0xC1
bne _080EA618
ldr r0, =0x0000023d
cmp r4, r0
bne _080EA618
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
beq _080EA5E0
b _080EA820
_080EA5E0:
ldr r4, =0x000040ef
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r2, 0x80
lsls r2, 5
adds r0, r2, 0
eors r1, r0
lsls r1, 16
lsrs r1, 16
adds r0, r4, 0
bl VarSet
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r3, 0x80
lsls r3, 6
adds r0, r3, 0
b _080EA7FA
.pool
_080EA618:
cmp r5, 0x47
bne _080EA668
ldr r0, =0x0000023e
cmp r4, r0
bne _080EA668
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
beq _080EA62C
b _080EA820
_080EA62C:
ldr r4, =0x000040ef
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r2, 0x80
lsls r2, 5
adds r0, r2, 0
orrs r1, r0
lsls r1, 16
lsrs r1, 16
adds r0, r4, 0
bl VarSet
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r3, 0x80
lsls r3, 6
adds r0, r3, 0
eors r1, r0
b _080EA7FC
.pool
_080EA668:
adds r0, r5, 0
bl MetatileBehavior_IsSecretBaseGlitterMat
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _080EA698
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
beq _080EA680
b _080EA820
_080EA680:
ldr r4, =0x000040ef
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r0, 0x80
b _080EA7FA
.pool
_080EA698:
adds r0, r5, 0
bl MetatileBehavior_IsSecretBaseBalloon
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _080EA72C
mov r0, sp
movs r1, 0
ldrsh r0, [r0, r1]
movs r2, 0
ldrsh r1, [r6, r2]
bl MapGridGetMetatileIdAt
lsls r0, 16
asrs r0, 16
mov r1, sp
movs r3, 0
ldrsh r1, [r1, r3]
movs r3, 0
ldrsh r2, [r6, r3]
bl sub_80FA5E4
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
beq _080EA6D0
b _080EA820
_080EA6D0:
mov r0, sp
movs r1, 0
ldrsh r0, [r0, r1]
movs r2, 0
ldrsh r1, [r6, r2]
bl MapGridGetMetatileIdAt
adds r1, r0, 0
movs r0, 0xCE
lsls r0, 2
cmp r1, r0
beq _080EA70C
cmp r1, r0
bgt _080EA6FC
movs r0, 0x8A
lsls r0, 2
cmp r1, r0
beq _080EA714
b _080EA820
.pool
_080EA6FC:
movs r0, 0xCF
lsls r0, 2
cmp r1, r0
beq _080EA70C
adds r0, 0x4
cmp r1, r0
beq _080EA70C
b _080EA820
_080EA70C:
ldr r4, =0x000040ee
b _080EA7F0
.pool
_080EA714:
ldr r4, =0x000040ee
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r3, 0x80
lsls r3, 1
adds r0, r3, 0
b _080EA7FA
.pool
_080EA72C:
adds r0, r5, 0
bl MetatileBehavior_IsMB_BE
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _080EA778
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
bne _080EA75E
ldr r4, =0x000040ef
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r2, 0x80
lsls r2, 3
adds r0, r2, 0
orrs r1, r0
lsls r1, 16
lsrs r1, 16
adds r0, r4, 0
bl VarSet
_080EA75E:
mov r0, sp
movs r3, 0
ldrsh r0, [r0, r3]
movs r2, 0
ldrsh r1, [r6, r2]
bl sub_80FA794
b _080EA820
.pool
_080EA778:
adds r0, r5, 0
bl MetatileBehavior_IsSecretBaseSoundMat
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _080EA7A8
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
bne _080EA820
ldr r4, =0x000040ee
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r3, 0x80
lsls r3, 8
adds r0, r3, 0
b _080EA7FA
.pool
_080EA7A8:
adds r0, r5, 0
bl MetatileBehavior_IsSecretBaseJumpMat
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _080EA7D8
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
bne _080EA820
ldr r4, =0x000040ef
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r2, 0x80
lsls r2, 7
adds r0, r2, 0
b _080EA7FA
.pool
_080EA7D8:
adds r0, r5, 0
bl MetatileBehavior_IsSecretBaseSpinMat
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _080EA820
ldr r0, =gUnknown_0203A01D
ldrb r0, [r0]
cmp r0, 0x1
bne _080EA820
ldr r4, =0x000040ef
_080EA7F0:
adds r0, r4, 0
bl VarGet
adds r1, r0, 0
movs r0, 0x2
_080EA7FA:
orrs r1, r0
_080EA7FC:
lsls r1, 16
lsrs r1, 16
adds r0, r4, 0
bl VarSet
b _080EA820
.pool
_080EA810:
ldrb r0, [r5, 0x8]
bl FieldEffectActiveListContains
lsls r0, 24
cmp r0, 0
bne _080EA820
_080EA81C:
movs r0, 0x1
strh r0, [r5, 0x2]
_080EA820:
add sp, 0x4
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end sub_80EA3E4
thumb_func_start sub_80EA828
sub_80EA828: @ 80EA828
push {r4-r7,lr}

13
include/fldeff_80F9BCC.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef GUARD_FLDEFF_80F9BCC_H
#define GUARD_FLDEFF_80F9BCC_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
void sub_80FA5E4(s16 id, s16 x, s16 y);
void sub_80FA794(s16 x, s16 y);
#endif //GUARD_FLDEFF_80F9BCC_H

View File

@ -63,6 +63,10 @@
#define VAR_DAILY_PLANTED_BERRIES 0x40E9
#define VAR_DAILY_PICKED_BERRIES 0x40EA
#define VAR_DAILY_ROULETTE 0x40EB
#define VAR_0x40EC 0x40EC
#define VAR_0x40ED 0x40ED
#define VAR_0x40EE 0x40EE
#define VAR_0x40EF 0x40EF
#define VAR_DAILY_BP 0x40F1
#endif // GUARD_VARS_H

View File

@ -20,6 +20,8 @@
#include "field_screen.h"
#include "field_weather.h"
#include "field_map_obj.h"
#include "field_effect.h"
#include "fldeff_80F9BCC.h"
#include "metatile_behavior.h"
#include "map_name_popup.h"
#include "text.h"
@ -1287,3 +1289,143 @@ void sub_80EA354(void)
gSpecialVar_0x8004 = sub_80EA20C(sbId);
gScriptResult = gSaveBlock1Ptr->secretBases[sbId].sbr_field_1_5;
}
void sub_80EA3E4(u8 taskId)
{
s16 x;
s16 y;
u8 behavior;
u16 tileId;
s16 *data;
data = gTasks[taskId].data;
switch (data[1])
{
case 0:
if (VarGet(VAR_0x4054) != 0)
{
gUnknown_0203A01D = TRUE;
}
else
{
gUnknown_0203A01D = FALSE;
}
PlayerGetDestCoords(&data[2], &data[3]);
data[1] = 1;
break;
case 1:
PlayerGetDestCoords(&x, &y);
if (x != data[2] || y != data[3])
{
data[2] = x;
data[3] = y;
VarSet(VAR_0x40EC, VarGet(VAR_0x40EC) + 1);
behavior = MapGridGetMetatileBehaviorAt(x, y);
tileId = MapGridGetMetatileIdAt(x, y);
if (tileId == 0x234 || tileId == 0x23C)
{
if (gUnknown_0203A01D == TRUE)
{
VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x20);
}
}
else if (tileId == 0x2b8 || tileId == 0x2b9 || tileId == 0x2ba || tileId == 0x2c0 || tileId == 0x2c1 || tileId == 0x2c2 || tileId == 0x2c8 || tileId == 0x2c9 || tileId == 0x2ca)
{
if (gUnknown_0203A01D == TRUE)
{
VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x01);
}
}
else if (tileId == 0x239 || tileId == 0x241 || tileId == 0x251 || tileId == 0x259)
{
if (gUnknown_0203A01D == TRUE)
{
VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x04);
}
}
else if ((behavior == 0x34 && tileId == 0x26d) || (behavior == 0x35 && MapGridGetMetatileIdAt(x, y) == 0x26a))
{
if (gUnknown_0203A01D == TRUE)
{
VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x200);
}
}
else if (behavior == 0xc1 && tileId == 0x23d)
{
if (gUnknown_0203A01D == TRUE)
{
VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) ^ 0x1000);
VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x2000);
}
}
else if (behavior == 0x47 && tileId == 0x23e)
{
if (gUnknown_0203A01D == TRUE)
{
VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x1000);
VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) ^ 0x2000);
}
}
else if (MetatileBehavior_IsSecretBaseGlitterMat(behavior) == TRUE)
{
if (gUnknown_0203A01D == TRUE)
{
VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x80);
}
}
else if (MetatileBehavior_IsSecretBaseBalloon(behavior) == TRUE)
{
sub_80FA5E4(MapGridGetMetatileIdAt(x, y), x, y);
if (gUnknown_0203A01D == TRUE)
{
switch ((int)MapGridGetMetatileIdAt(x, y))
{
case 0x338:
case 0x33c:
case 0x340:
VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x02);
break;
case 0x228:
VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x100);
break;
}
}
}
else if (MetatileBehavior_IsMB_BE(behavior) == TRUE)
{
if (gUnknown_0203A01D == TRUE)
{
VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x400);
}
sub_80FA794(x, y);
}
else if (MetatileBehavior_IsSecretBaseSoundMat(behavior) == TRUE){
if (gUnknown_0203A01D == TRUE) {
VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x8000);
}
}
else if (MetatileBehavior_IsSecretBaseJumpMat(behavior) == TRUE)
{
if (gUnknown_0203A01D == TRUE)
{
VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x4000);
}
}
else if (MetatileBehavior_IsSecretBaseSpinMat(behavior) == TRUE)
{
if (gUnknown_0203A01D == TRUE)
{
VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x02);
}
}
}
break;
case 2:
if (!FieldEffectActiveListContains(data[4]))
{
data[1] = 1;
}
break;
}
}