[WIP} Start decomp Ground Shake

This commit is contained in:
KDSKardabox 2018-02-16 15:21:27 +05:30
parent e2932a38de
commit e518a40508
4 changed files with 109 additions and 190 deletions

View File

@ -5,196 +5,6 @@
.text
thumb_func_start sub_81BE66C
sub_81BE66C: @ 81BE66C
push {lr}
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldrh r1, [r0, 0x4]
movs r0, 0xD0
lsls r0, 5
cmp r1, r0
bne _081BE690
movs r0, 0xA7
lsls r0, 1
bl FlagGet
lsls r0, 24
lsrs r0, 24
b _081BE692
.pool
_081BE690:
movs r0, 0
_081BE692:
pop {r1}
bx r1
thumb_func_end sub_81BE66C
thumb_func_start sub_81BE698
sub_81BE698: @ 81BE698
push {lr}
ldr r0, =gUnknown_0203CF18
ldr r0, [r0]
adds r0, 0x4
bl sub_8151E50
pop {r0}
bx r0
.pool
thumb_func_end sub_81BE698
thumb_func_start sub_81BE6AC
sub_81BE6AC: @ 81BE6AC
ldr r1, =gUnknown_0203CF18
movs r0, 0
str r0, [r1]
bx lr
.pool
thumb_func_end sub_81BE6AC
thumb_func_start sub_81BE6B8
sub_81BE6B8: @ 81BE6B8
push {r4,lr}
ldr r4, =gUnknown_0203CF18
ldr r0, [r4]
cmp r0, 0
beq _081BE6CC
movs r0, 0
str r0, [r4]
b _081BE718
.pool
_081BE6CC:
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldrh r1, [r0, 0x4]
movs r0, 0xD0
lsls r0, 5
cmp r1, r0
bne _081BE718
movs r0, 0xA7
lsls r0, 1
bl FlagGet
lsls r0, 24
cmp r0, 0
beq _081BE718
movs r0, 0xC8
bl AllocZeroed
str r0, [r4]
adds r0, 0x4
bl sub_8151B3C
ldr r0, [r4]
adds r0, 0x4
ldr r1, =gUnknown_08617E18
bl sub_8151B68
ldr r0, [r4]
adds r0, 0x4
movs r1, 0x1
movs r2, 0x1
bl sub_8151CA8
ldr r0, =sub_81BE698
movs r1, 0xFF
bl CreateTask
ldr r1, [r4]
strb r0, [r1]
_081BE718:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81BE6B8
thumb_func_start sub_81BE72C
sub_81BE72C: @ 81BE72C
push {r4,lr}
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldrh r1, [r0, 0x4]
movs r0, 0xD0
lsls r0, 5
cmp r1, r0
bne _081BE788
movs r0, 0xA7
lsls r0, 1
bl FlagGet
lsls r0, 24
cmp r0, 0
beq _081BE788
ldr r4, =gUnknown_0203CF18
ldr r0, [r4]
cmp r0, 0
beq _081BE788
ldr r0, =sub_81BE698
bl FuncIsActiveTask
lsls r0, 24
cmp r0, 0
beq _081BE766
ldr r0, [r4]
ldrb r0, [r0]
bl DestroyTask
_081BE766:
ldr r0, [r4]
adds r0, 0x4
movs r1, 0x1
movs r2, 0x1
bl sub_8151D28
ldr r0, [r4]
adds r0, 0x4
movs r1, 0x1
movs r2, 0x1
bl sub_8151C50
ldr r0, [r4]
bl Free
movs r0, 0
str r0, [r4]
_081BE788:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81BE72C
thumb_func_start sub_81BE79C
sub_81BE79C: @ 81BE79C
push {r4,lr}
ldr r0, =0x000040cb
bl VarGet
lsls r0, 16
cmp r0, 0
beq _081BE7B8
movs r0, 0xA7
lsls r0, 1
bl FlagClear
b _081BE7EE
.pool
_081BE7B8:
bl Random
lsls r0, 16
lsrs r4, r0, 16
movs r0, 0x1
ands r4, r0
movs r0, 0x9D
bl FlagGet
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _081BE7D4
movs r4, 0x1
_081BE7D4:
cmp r4, 0
beq _081BE7E6
movs r0, 0xA7
lsls r0, 1
bl FlagSet
bl sub_81BE6B8
b _081BE7EE
_081BE7E6:
movs r0, 0xA7
lsls r0, 1
bl FlagClear
_081BE7EE:
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_81BE79C
thumb_func_start sub_81BE7F4
sub_81BE7F4: @ 81BE7F4
push {lr}

View File

@ -1,7 +1,30 @@
#ifndef GUARD_FLDEFF_GROUNDSHAKE_H
#define GUARD_FLDEFF_GROUNDSHAKE_H
struct InnerStruct203CF18
{
u8 filler[0xC4];
};
struct Struct203CF18 {
u8 taskId;
struct InnerStruct203CF18 unk4;
}; //size = 0xC8
void sub_8151B68(struct InnerStruct203CF18 *, const u8*);
void sub_8151B3C(struct InnerStruct203CF18 *);
void sub_8151CA8(struct InnerStruct203CF18 *, u8, u8);
void sub_8151C50(struct InnerStruct203CF18 *, u8, u8);
void sub_8151D28(struct InnerStruct203CF18 *, u8, u8);
void sub_8151E50(struct InnerStruct203CF18 *);
void sub_81BE6B8(void);
void sub_81BE72C(void);
extern struct Struct203CF18 *gUnknown_0203CF18;
extern const u8 gUnknown_08617E18[];
#endif // GUARD_FLDEFF_GROUNDSHAKE_H

View File

@ -258,6 +258,7 @@ SECTIONS {
src/multiboot.o(.text);
src/unk_81BAD84.o(.text);
src/battle_controller_player_partner.o(.text);
src/fldeff_groundshake.o(.text);
asm/fldeff_groundshake.o(.text);
asm/fossil_specials.o(.text);
src/berry_fix_program.o(.text);

85
src/fldeff_groundshake.c Normal file
View File

@ -0,0 +1,85 @@
#include "global.h"
#include "constants/flags.h"
#include "constants/songs.h"
#include "event_data.h"
#include "fldeff_groundshake.h"
#include "malloc.h"
#include "menu.h"
#include "party_menu.h"
#include "pokemon.h"
#include "random.h"
#include "sound.h"
#include "sprite.h"
#include "string_util.h"
#include "strings.h"
#include "task.h"
bool8 sub_81BE66C(void)
{
if (!(gSaveBlock1Ptr->location.mapGroup == 0x0 && gSaveBlock1Ptr->location.mapNum == 0x1A))
return 0;
return FlagGet(FLAG_0x14E);
}
void sub_81BE698(u8 taskId)
{
sub_8151E50(&(gUnknown_0203CF18->unk4));
}
void sub_81BE6AC(void)
{
gUnknown_0203CF18 = NULL;
}
void sub_81BE6B8(void)
{
if(gUnknown_0203CF18 != NULL)
{
gUnknown_0203CF18 = NULL;
return;
}
if(!(gSaveBlock1Ptr->location.mapGroup == 0x0 && gSaveBlock1Ptr->location.mapNum == 0x1A) || !FlagGet(FLAG_0x14E))
return;
gUnknown_0203CF18 = (struct Struct203CF18 *)AllocZeroed(sizeof(struct Struct203CF18));
sub_8151B3C(&(gUnknown_0203CF18->unk4));
sub_8151B68(&(gUnknown_0203CF18->unk4), gUnknown_08617E18);
sub_8151CA8(&(gUnknown_0203CF18->unk4), 1, 1);
gUnknown_0203CF18->taskId = CreateTask(sub_81BE698, 0xFF);
}
void sub_81BE72C(void)
{
if(!(gSaveBlock1Ptr->location.mapGroup == 0x0 && gSaveBlock1Ptr->location.mapNum == 0x1A) || !FlagGet(FLAG_0x14E) || gUnknown_0203CF18 == NULL)
return;
if(FuncIsActiveTask(sub_81BE698))
DestroyTask(gUnknown_0203CF18->taskId);
sub_8151D28(&(gUnknown_0203CF18->unk4), 1, 1);
sub_8151C50(&(gUnknown_0203CF18->unk4), 1, 1);
Free(gUnknown_0203CF18);
gUnknown_0203CF18 = NULL;
}
void sub_81BE79C(void)
{
u16 rand;
bool8 chance;
if(VarGet(VAR_0x40CB) != 0)
{
FlagClear(FLAG_0x14E);
return;
}
rand = Random();
chance = rand & 1;
if(FlagGet(FLAG_0x09D) == TRUE)
chance = TRUE;
if(chance)
{
FlagSet(FLAG_0x14E);
sub_81BE6B8();
return;
}
FlagClear(FLAG_0x14E);
}