Continue decompiling field_specials

This commit is contained in:
Diegoisawesome 2018-08-10 14:07:23 -07:00
parent 12ff59f9c1
commit 1e0f3ec433
5 changed files with 255 additions and 290 deletions

View File

@ -5,288 +5,6 @@
.text
thumb_func_start sub_813B21C
sub_813B21C: @ 813B21C
push {r4,r5,lr}
ldr r5, =0x000008d7
adds r0, r5, 0
bl FlagGet
lsls r0, 24
cmp r0, 0
bne _0813B258
bl StorageGetCurrentBox
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
ldr r0, =0x00004036
bl VarGet
lsls r0, 16
lsrs r0, 16
cmp r4, r0
beq _0813B258
adds r0, r5, 0
bl FlagSet
movs r0, 0x1
b _0813B25A
.pool
_0813B258:
movs r0, 0
_0813B25A:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_813B21C
thumb_func_start sub_813B260
sub_813B260: @ 813B260
push {r4-r7,lr}
ldr r0, =0x00004036
bl VarGet
lsls r0, 24
lsrs r0, 24
bl set_unknown_box_id
bl StorageGetCurrentBox
lsls r0, 24
lsrs r4, r0, 24
_0813B278:
movs r5, 0
lsls r6, r4, 24
lsls r7, r4, 16
_0813B27E:
lsls r1, r5, 24
lsrs r1, 24
lsrs r0, r6, 24
bl GetBoxedMonPtr
movs r1, 0xB
movs r2, 0
bl GetBoxMonData
cmp r0, 0
bne _0813B2C0
bl get_unknown_box_id
lsls r0, 16
lsrs r0, 16
cmp r0, r4
beq _0813B2A6
ldr r0, =0x000008d7
bl FlagClear
_0813B2A6:
ldr r0, =0x00004036
lsrs r1, r7, 16
bl VarSet
bl sub_813B21C
lsls r0, 24
lsrs r0, 24
b _0813B2DC
.pool
_0813B2C0:
adds r5, 0x1
cmp r5, 0x1D
ble _0813B27E
adds r4, 0x1
cmp r4, 0xE
bne _0813B2CE
movs r4, 0
_0813B2CE:
bl StorageGetCurrentBox
lsls r0, 24
lsrs r0, 24
cmp r4, r0
bne _0813B278
movs r0, 0
_0813B2DC:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_813B260
thumb_func_start sub_813B2E4
sub_813B2E4: @ 813B2E4
push {r4,lr}
bl Random
lsls r0, 16
lsrs r4, r0, 16
ldr r0, =0x00004038
movs r1, 0
bl VarSet
movs r0, 0xDF
lsls r0, 1
bl FlagGet
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
beq _0813B340
ldr r0, =0x000001bf
bl FlagGet
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _0813B330
ldr r0, =0x00004037
movs r1, 0x7
ands r4, r1
adds r1, r4, 0
adds r1, 0x9
bl VarSet
b _0813B36A
.pool
_0813B330:
movs r0, 0x1
ands r4, r0
cmp r4, 0
bne _0813B354
bl Random
lsls r0, 16
lsrs r4, r0, 16
_0813B340:
ldr r0, =0x00004037
movs r1, 0x7
ands r4, r1
adds r1, r4, 0x1
bl VarSet
b _0813B36A
.pool
_0813B354:
bl Random
lsls r0, 16
lsrs r4, r0, 16
ldr r0, =0x00004037
movs r1, 0x7
ands r4, r1
adds r1, r4, 0
adds r1, 0x9
bl VarSet
_0813B36A:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_813B2E4
thumb_func_start sub_813B374
sub_813B374: @ 813B374
push {r4,lr}
ldr r0, =0x00004037
bl VarGet
adds r4, r0, 0
lsls r4, 16
lsrs r4, 16
ldr r0, =gStringVar1
ldr r2, =gUnknown_085B3400
subs r1, r4, 0x1
adds r1, r2
ldrb r1, [r1]
movs r2, 0
bl GetMapName
cmp r4, 0x8
bls _0813B3A8
movs r0, 0x1
b _0813B3AA
.pool
_0813B3A8:
movs r0, 0
_0813B3AA:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_813B374
thumb_func_start sub_813B3B0
sub_813B3B0: @ 813B3B0
push {r4-r6,lr}
ldr r5, =0x00004038
adds r0, r5, 0
bl VarGet
lsls r0, 16
lsrs r4, r0, 16
ldr r0, =0x00004037
bl VarGet
lsls r0, 16
lsrs r6, r0, 16
cmp r6, 0
beq _0813B47C
adds r0, r4, 0x1
lsls r0, 16
lsrs r4, r0, 16
ldr r0, =0x000003e7
cmp r4, r0
bls _0813B474
adds r0, r5, 0
movs r1, 0
bl VarSet
ldr r0, =gSaveBlock1Ptr
ldr r1, [r0]
movs r0, 0x4
ldrsb r0, [r1, r0]
cmp r0, 0x18
bne _0813B414
movs r0, 0x5
ldrsb r0, [r1, r0]
cmp r0, 0x69
bgt _0813B414
cmp r0, 0x65
blt _0813B414
ldr r0, =0x00004039
movs r1, 0x1
b _0813B478
.pool
_0813B414:
ldr r0, =gSaveBlock1Ptr
ldr r2, [r0]
movs r1, 0x4
ldrsb r1, [r2, r1]
adds r3, r0, 0
cmp r1, 0
bne _0813B444
movs r0, 0x5
ldrsb r0, [r2, r0]
cmp r0, 0x34
beq _0813B436
cmp r0, 0x34
blt _0813B444
cmp r0, 0x38
bgt _0813B444
cmp r0, 0x36
blt _0813B444
_0813B436:
ldr r0, =0x00004039
movs r1, 0x1
b _0813B478
.pool
_0813B444:
ldr r3, [r3]
movs r2, 0x5
ldrsb r2, [r3, r2]
ldr r1, =gUnknown_085B3410
subs r0, r6, 0x1
adds r0, r1
ldrb r0, [r0]
cmp r2, r0
bne _0813B468
movs r0, 0x4
ldrsb r0, [r3, r0]
cmp r0, 0
bne _0813B468
movs r0, 0x1
b _0813B47E
.pool
_0813B468:
ldr r0, =0x00004037
movs r1, 0
b _0813B478
.pool
_0813B474:
adds r0, r5, 0
adds r1, r4, 0
_0813B478:
bl VarSet
_0813B47C:
movs r0, 0
_0813B47E:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_813B3B0
thumb_func_start sub_813B484
sub_813B484: @ 813B484
push {lr}

View File

@ -3,12 +3,6 @@
.section .rodata
gUnknown_085B3400:: @ 85B3400
.byte 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c
gUnknown_085B3410:: @ 85B3410
.byte 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c
gUnknown_085B3420:: @ 85B3420
.byte 0x02, 0x04, 0x01, 0x04, 0x04, 0x01, 0x05, 0x00, 0x01, 0x06, 0x03, 0x01, 0x08, 0x06, 0x01, 0x09, 0x0d, 0x01, 0x0a, 0x07, 0x01, 0x0b, 0x07, 0x01, 0x0c, 0x04, 0x01, 0x0e, 0x05, 0x01, 0x0f, 0x04
.byte 0x01, 0x1a, 0x37, 0x01

View File

@ -3,7 +3,7 @@
u8 GetLeadMonIndex(void);
u8 sub_813B260(void);
u8 get_unknown_box_id(void);
u16 get_unknown_box_id(void);
bool8 InMultiBattleRoom(void);
#endif // GUARD_FIELD_SPECIALS_H

View File

@ -10,5 +10,6 @@ void SetBoxMonNickFromAnyBox(u8, u8, u8 *);
void CompactPartySlots(void);
u32 GetBoxMonDataFromAnyBox(u8 boxId, u8 monPosition, u32 request);
bool8 CheckFreePokemonStorageSpace(void);
u8 StorageGetCurrentBox(void);
#endif // GUARD_POKEMON_STORAGE_SYSTEM_H

View File

@ -3584,7 +3584,259 @@ void set_unknown_box_id(u8 id)
gUnknown_0203AB6F = id;
}
u8 get_unknown_box_id(void)
u16 get_unknown_box_id(void)
{
return gUnknown_0203AB6F;
}
bool32 sub_813B21C(void)
{
if (FlagGet(FLAG_SYS_STORAGE_UNKNOWN_FLAG) == FALSE)
{
if (StorageGetCurrentBox() != VarGet(VAR_STORAGE_UNKNOWN))
{
FlagSet(FLAG_SYS_STORAGE_UNKNOWN_FLAG);
return TRUE;
}
}
return FALSE;
}
bool8 sub_813B260(void)
{
int box;
int i;
set_unknown_box_id(VarGet(VAR_STORAGE_UNKNOWN));
box = StorageGetCurrentBox();
do
{
for (i = 0; i < IN_BOX_COUNT; i++)
{
if (GetBoxMonData(GetBoxedMonPtr(box, i), MON_DATA_SPECIES, 0) == 0)
{
if (get_unknown_box_id() != box)
{
FlagClear(FLAG_SYS_STORAGE_UNKNOWN_FLAG);
}
VarSet(VAR_STORAGE_UNKNOWN, box);
return sub_813B21C();
}
}
if (++box == TOTAL_BOXES_COUNT)
{
box = 0;
}
} while (box != StorageGetCurrentBox());
return FALSE;
}
void sub_813B2E4(void)
{
u16 randomValue = Random();
VarSet(VAR_0x4038, 0);
if (FlagGet(FLAG_0x1BE) == TRUE)
{
VarSet(VAR_0x4037, (randomValue & 7) + 1);
}
else if (FlagGet(FLAG_0x1BF) == TRUE)
{
VarSet(VAR_0x4037, (randomValue & 7) + 9);
}
else if ((randomValue & 1) == 0)
{
randomValue = Random();
VarSet(VAR_0x4037, (randomValue & 7) + 1);
}
else
{
randomValue = Random();
VarSet(VAR_0x4037, (randomValue & 7) + 9);
}
}
const u8 gUnknown_085B3400[] = { 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c };
bool32 sub_813B374(void)
{
u16 var = VarGet(VAR_0x4037);
GetMapName(gStringVar1, gUnknown_085B3400[var - 1], 0);
if (var < 9)
{
return FALSE;
}
else
{
return TRUE;
}
}
const u8 gUnknown_085B3410[] = { 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c };
// last parts of switch statements insist on merging
#ifdef NONMATCHING
bool32 sub_813B3B0(void)
{
u16 var1 = VarGet(VAR_0x4038);
u16 var2 = VarGet(VAR_0x4037);
if (var2 != 0)
{
if (++var1 > 999)
{
VarSet(VAR_0x4038, 0);
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(UNDERWATER_MARINE_CAVE))
{
switch (gSaveBlock1Ptr->location.mapNum)
{
case MAP_NUM(UNDERWATER_MARINE_CAVE):
case MAP_NUM(MARINE_CAVE_ENTRANCE):
case MAP_NUM(MARINE_CAVE_END):
case MAP_NUM(TERRA_CAVE_ENTRANCE):
case MAP_NUM(TERRA_CAVE_END):
VarSet(VAR_0x4039, 1);
return FALSE;
default:
break;
}
}
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(UNDERWATER3))
{
switch (gSaveBlock1Ptr->location.mapNum)
{
case MAP_NUM(UNDERWATER3):
case MAP_NUM(UNDERWATER5):
case MAP_NUM(UNDERWATER6):
case MAP_NUM(UNDERWATER7):
VarSet(VAR_0x4039, 1);
return FALSE;
default:
break;
}
}
if (gSaveBlock1Ptr->location.mapNum == gUnknown_085B3410[var2 - 1] &&
gSaveBlock1Ptr->location.mapGroup == 0)
{
return TRUE;
}
else
{
VarSet(VAR_0x4037, 0);
return FALSE;
}
}
else
{
VarSet(VAR_0x4038, var1);
return FALSE;
}
}
else
{
return FALSE;
}
}
#else
NAKED
bool32 sub_813B3B0(void)
{
asm_unified("push {r4-r6,lr}\n\
ldr r5, =0x00004038\n\
adds r0, r5, 0\n\
bl VarGet\n\
lsls r0, 16\n\
lsrs r4, r0, 16\n\
ldr r0, =0x00004037\n\
bl VarGet\n\
lsls r0, 16\n\
lsrs r6, r0, 16\n\
cmp r6, 0\n\
beq _0813B47C\n\
adds r0, r4, 0x1\n\
lsls r0, 16\n\
lsrs r4, r0, 16\n\
ldr r0, =0x000003e7\n\
cmp r4, r0\n\
bls _0813B474\n\
adds r0, r5, 0\n\
movs r1, 0\n\
bl VarSet\n\
ldr r0, =gSaveBlock1Ptr\n\
ldr r1, [r0]\n\
movs r0, 0x4\n\
ldrsb r0, [r1, r0]\n\
cmp r0, 0x18\n\
bne _0813B414\n\
movs r0, 0x5\n\
ldrsb r0, [r1, r0]\n\
cmp r0, 0x69\n\
bgt _0813B414\n\
cmp r0, 0x65\n\
blt _0813B414\n\
ldr r0, =0x00004039\n\
movs r1, 0x1\n\
b _0813B478\n\
.pool\n\
_0813B414:\n\
ldr r0, =gSaveBlock1Ptr\n\
ldr r2, [r0]\n\
movs r1, 0x4\n\
ldrsb r1, [r2, r1]\n\
adds r3, r0, 0\n\
cmp r1, 0\n\
bne _0813B444\n\
movs r0, 0x5\n\
ldrsb r0, [r2, r0]\n\
cmp r0, 0x34\n\
beq _0813B436\n\
cmp r0, 0x34\n\
blt _0813B444\n\
cmp r0, 0x38\n\
bgt _0813B444\n\
cmp r0, 0x36\n\
blt _0813B444\n\
_0813B436:\n\
ldr r0, =0x00004039\n\
movs r1, 0x1\n\
b _0813B478\n\
.pool\n\
_0813B444:\n\
ldr r3, [r3]\n\
movs r2, 0x5\n\
ldrsb r2, [r3, r2]\n\
ldr r1, =gUnknown_085B3410\n\
subs r0, r6, 0x1\n\
adds r0, r1\n\
ldrb r0, [r0]\n\
cmp r2, r0\n\
bne _0813B468\n\
movs r0, 0x4\n\
ldrsb r0, [r3, r0]\n\
cmp r0, 0\n\
bne _0813B468\n\
movs r0, 0x1\n\
b _0813B47E\n\
.pool\n\
_0813B468:\n\
ldr r0, =0x00004037\n\
movs r1, 0\n\
b _0813B478\n\
.pool\n\
_0813B474:\n\
adds r0, r5, 0\n\
adds r1, r4, 0\n\
_0813B478:\n\
bl VarSet\n\
_0813B47C:\n\
movs r0, 0\n\
_0813B47E:\n\
pop {r4-r6}\n\
pop {r1}\n\
bx r1");
}
#endif // NONMATCHING