decompile more of field_map_obj_helpers.c

This commit is contained in:
ProjectRevoTPP 2018-01-29 15:49:28 -05:00
parent 3eaaa59c04
commit 42bfa15ae0
2 changed files with 167 additions and 382 deletions

View File

@ -5,375 +5,6 @@
.text
thumb_func_start sub_8097BB4
sub_8097BB4: @ 8097BB4
push {r4,r5,lr}
lsls r0, 24
lsrs r0, 24
lsls r1, 24
lsrs r5, r1, 24
bl sub_8097B2C
adds r1, r0, 0
cmp r1, 0x40
beq _08097C3E
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
ldr r1, =gSprites
adds r4, r0, r1
adds r0, r5, 0
bl GetFieldObjectGraphicsInfo
ldrh r3, [r4, 0x4]
lsls r3, 22
ldr r1, [r0, 0x10]
ldr r2, [r1, 0x4]
ldr r1, [r1]
str r1, [r4]
str r2, [r4, 0x4]
lsrs r3, 22
ldrh r2, [r4, 0x4]
ldr r1, =0xfffffc00
ands r1, r2
orrs r1, r3
strh r1, [r4, 0x4]
ldrb r2, [r0, 0xC]
lsls r2, 28
lsrs r2, 24
ldrb r3, [r4, 0x5]
movs r1, 0xF
ands r1, r3
orrs r1, r2
strb r1, [r4, 0x5]
ldr r1, [r0, 0x1C]
str r1, [r4, 0xC]
ldr r1, [r0, 0x14]
cmp r1, 0
bne _08097C20
str r1, [r4, 0x18]
adds r0, r4, 0
adds r0, 0x42
strb r1, [r0]
b _08097C36
.pool
_08097C20:
adds r0, r4, 0
bl SetSubspriteTables
adds r2, r4, 0
adds r2, 0x42
ldrb r0, [r2]
movs r1, 0x3F
ands r1, r0
movs r0, 0x80
orrs r1, r0
strb r1, [r2]
_08097C36:
adds r0, r4, 0
movs r1, 0
bl StartSpriteAnim
_08097C3E:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_8097BB4
thumb_func_start sub_8097C44
sub_8097C44: @ 8097C44
push {r4,lr}
adds r4, r1, 0
lsls r0, 24
lsrs r0, 24
bl sub_8097B2C
lsls r0, 24
lsrs r2, r0, 24
adds r3, r2, 0
cmp r2, 0x40
beq _08097C80
cmp r4, 0
beq _08097C74
ldr r0, =gSprites
lsls r1, r2, 4
adds r1, r2
lsls r1, 2
adds r1, r0
movs r0, 0x1
strh r0, [r1, 0x32]
b _08097C80
.pool
_08097C74:
ldr r1, =gSprites
lsls r0, r3, 4
adds r0, r3
lsls r0, 2
adds r0, r1
strh r4, [r0, 0x32]
_08097C80:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8097C44
thumb_func_start sub_8097C8C
sub_8097C8C: @ 8097C8C
push {lr}
lsls r0, 24
lsrs r0, 24
bl sub_8097B2C
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x40
bne _08097CA2
movs r0, 0
b _08097CBA
_08097CA2:
movs r3, 0
ldr r0, =gSprites
lsls r1, r2, 4
adds r1, r2
lsls r1, 2
adds r1, r0
movs r2, 0x32
ldrsh r0, [r1, r2]
cmp r0, 0x1
bne _08097CB8
movs r3, 0x1
_08097CB8:
adds r0, r3, 0
_08097CBA:
pop {r1}
bx r1
.pool
thumb_func_end sub_8097C8C
thumb_func_start sub_8097CC4
sub_8097CC4: @ 8097CC4
push {r4,lr}
lsls r0, 24
lsrs r0, 24
lsls r1, 24
lsrs r4, r1, 24
bl sub_8097B2C
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x40
beq _08097CEA
ldr r0, =gSprites
lsls r1, r2, 4
adds r1, r2
lsls r1, 2
adds r1, r0
movs r0, 0
strh r4, [r1, 0x34]
strh r0, [r1, 0x36]
_08097CEA:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8097CC4
thumb_func_start sub_8097CF4
sub_8097CF4: @ 8097CF4
push {lr}
adds r2, r0, 0
movs r1, 0x36
ldrsh r0, [r2, r1]
cmp r0, 0
beq _08097D06
cmp r0, 0x1
beq _08097D0E
b _08097D2C
_08097D06:
strh r0, [r2, 0x26]
ldrh r0, [r2, 0x36]
adds r0, 0x1
strh r0, [r2, 0x36]
_08097D0E:
ldrh r0, [r2, 0x26]
subs r0, 0x8
movs r3, 0
strh r0, [r2, 0x26]
lsls r0, 16
asrs r0, 16
movs r1, 0xA0
negs r1, r1
cmp r0, r1
bne _08097D2C
strh r3, [r2, 0x26]
movs r0, 0x1
strh r0, [r2, 0x32]
strh r3, [r2, 0x34]
strh r3, [r2, 0x36]
_08097D2C:
pop {r0}
bx r0
thumb_func_end sub_8097CF4
thumb_func_start sub_8097D30
sub_8097D30: @ 8097D30
push {lr}
adds r1, r0, 0
movs r2, 0x36
ldrsh r0, [r1, r2]
cmp r0, 0
beq _08097D42
cmp r0, 0x1
beq _08097D4C
b _08097D5E
_08097D42:
ldr r0, =0x0000ff60
strh r0, [r1, 0x26]
ldrh r0, [r1, 0x36]
adds r0, 0x1
strh r0, [r1, 0x36]
_08097D4C:
ldrh r0, [r1, 0x26]
adds r0, 0x8
strh r0, [r1, 0x26]
lsls r0, 16
asrs r0, 16
cmp r0, 0
bne _08097D5E
strh r0, [r1, 0x34]
strh r0, [r1, 0x36]
_08097D5E:
pop {r0}
bx r0
.pool
thumb_func_end sub_8097D30
thumb_func_start sub_8097D68
sub_8097D68: @ 8097D68
push {lr}
adds r1, r0, 0
movs r2, 0x34
ldrsh r0, [r1, r2]
cmp r0, 0x1
beq _08097D84
cmp r0, 0x1
bgt _08097D7E
cmp r0, 0
beq _08097D98
b _08097D94
_08097D7E:
cmp r0, 0x2
beq _08097D8C
b _08097D94
_08097D84:
adds r0, r1, 0
bl sub_8097D30
b _08097D98
_08097D8C:
adds r0, r1, 0
bl sub_8097CF4
b _08097D98
_08097D94:
movs r0, 0
strh r0, [r1, 0x34]
_08097D98:
pop {r0}
bx r0
thumb_func_end sub_8097D68
thumb_func_start sub_8097D9C
sub_8097D9C: @ 8097D9C
push {lr}
lsls r0, 24
lsrs r0, 24
bl sub_8097B2C
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x40
beq _08097DC0
ldr r0, =gSprites
lsls r1, r2, 4
adds r1, r2
lsls r1, 2
adds r1, r0
movs r2, 0x34
ldrsh r0, [r1, r2]
cmp r0, 0
bne _08097DC8
_08097DC0:
movs r0, 0
b _08097DCA
.pool
_08097DC8:
movs r0, 0x1
_08097DCA:
pop {r1}
bx r1
thumb_func_end sub_8097D9C
thumb_func_start oe_exec_and_other_stuff
oe_exec_and_other_stuff: @ 8097DD0
push {r4,lr}
adds r4, r0, 0
adds r0, r1, 0
lsls r4, 24
lsrs r4, 24
ldr r1, =gFieldEffectArguments
adds r2, r1, 0x4
adds r3, r1, 0
adds r3, 0x8
bl FieldObjectGetLocalIdAndMap
adds r0, r4, 0
bl FieldEffectStart
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end oe_exec_and_other_stuff
thumb_func_start DoShadowFieldEffect
DoShadowFieldEffect: @ 8097DF8
push {lr}
adds r1, r0, 0
ldrb r2, [r1, 0x2]
lsls r0, r2, 25
cmp r0, 0
blt _08097E10
movs r0, 0x40
orrs r0, r2
strb r0, [r1, 0x2]
movs r0, 0x3
bl oe_exec_and_other_stuff
_08097E10:
pop {r0}
bx r0
thumb_func_end DoShadowFieldEffect
thumb_func_start DoRippleFieldEffect
@ void DoRippleFieldEffect(struct npc_state *fieldObject, struct obj *object)
DoRippleFieldEffect: @ 8097E14
push {r4,lr}
adds r4, r1, 0
ldrb r0, [r0, 0x5]
bl GetFieldObjectGraphicsInfo
ldr r2, =gFieldEffectArguments
movs r3, 0x20
ldrsh r1, [r4, r3]
str r1, [r2]
movs r3, 0x22
ldrsh r1, [r4, r3]
ldrh r0, [r0, 0xA]
lsls r0, 16
asrs r0, 17
adds r1, r0
subs r1, 0x2
str r1, [r2, 0x4]
movs r0, 0x97
str r0, [r2, 0x8]
movs r0, 0x3
str r0, [r2, 0xC]
movs r0, 0x5
bl FieldEffectStart
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end DoRippleFieldEffect
thumb_func_start sub_8097E50
sub_8097E50: @ 8097E50
push {r4-r7,lr}

View File

@ -1,15 +1,22 @@
#include "global.h"
#include "field_ground_effect.h"
#include "field_map_obj.h"
#include "field_effect.h"
extern void sub_8097D68(struct Sprite *sprite);
typedef void (*SpriteStepFunc)(struct Sprite *sprite, u8 dir);
extern const s8 gUnknown_0850E7BA[];
extern const s8 gUnknown_0850E772[];
extern const struct Coords16 gUnknown_0850DB7C[4];
extern s16 gUnknown_0850E768[];
extern SpriteStepFunc *const gUnknown_0850E754[];
extern const struct Coords16 gUnknown_0850DB7C[4];
extern const s8 gUnknown_0850E772[];
extern const s8 gUnknown_0850E7BA[];
extern const s8 *const gUnknown_0850E834[];
extern s16 gUnknown_0850E840[];
extern u8 gUnknown_0850E846[];
extern s16 gUnknown_0850E84A[];
extern u8 gUnknown_0850E850[];
bool8 FreezeMapObject(struct MapObject *mapObject)
{
@ -192,10 +199,6 @@ bool8 sub_8097758(struct Sprite *sprite)
return result;
}
extern const s8 *const gUnknown_0850E834[];
extern s16 gUnknown_0850E840[];
extern u8 gUnknown_0850E846[];
s16 sub_8097820(s16 a1, u8 a2)
{
return gUnknown_0850E834[a2][a1];
@ -238,9 +241,6 @@ u8 sub_809785C(struct Sprite *sprite)
return v2;
}
extern s16 gUnknown_0850E84A[];
extern u8 gUnknown_0850E850[];
u8 sub_80978E4(struct Sprite *sprite)
{
s16 v5[3];
@ -328,8 +328,6 @@ void sub_80979D4(struct Sprite *sprite, bool8 invisible)
sprite->invisible = 1;
}
extern void sub_8097D68(struct Sprite *sprite);
void sub_8097AC8(struct Sprite *sprite)
{
sub_8097D68(sprite);
@ -369,3 +367,159 @@ void sub_8097B78(u8 var1, u8 var2)
if(spriteId != MAX_SPRITES)
StartSpriteAnim(&gSprites[spriteId], FieldObjectDirectionToImageAnimId(var2));
}
void sub_8097BB4(u8 var1, u8 var2)
{
int spriteId = sub_8097B2C(var1);
if(spriteId != MAX_SPRITES)
{
struct Sprite *sprite = &gSprites[spriteId];
const struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(var2);
u16 tileNum = sprite->oam.tileNum;
sprite->oam = *gfxInfo->oam;
sprite->oam.tileNum = tileNum;
sprite->oam.paletteNum = gfxInfo->paletteSlot;
sprite->images = gfxInfo->images;
if(gfxInfo->subspriteTables == NULL)
{
sprite->subspriteTables = NULL;
sprite->subspriteTableNum = 0;
sprite->subspriteMode = 0;
}
else
{
SetSubspriteTables(sprite, gfxInfo->subspriteTables);
sprite->subspriteMode = 2;
}
StartSpriteAnim(sprite, 0);
}
}
void sub_8097C44(u8 var, bool32 var2)
{
u8 spriteId = sub_8097B2C(var);
if(spriteId == MAX_SPRITES)
return;
if(var2)
gSprites[spriteId].data[2] = 1;
else
gSprites[spriteId].data[2] = 0;
}
bool32 sub_8097C8C(u8 var)
{
u8 spriteId = sub_8097B2C(var);
if(spriteId == MAX_SPRITES)
return FALSE;
return (gSprites[spriteId].data[2] == TRUE);
}
void sub_8097CC4(u8 var1, u8 var2)
{
u8 spriteId = sub_8097B2C(var1);
if(spriteId != MAX_SPRITES)
{
gSprites[spriteId].data[3] = var2;
gSprites[spriteId].data[4] = 0;
}
}
void sub_8097CF4(struct Sprite *sprite)
{
switch(sprite->data[4])
{
case 0:
sprite->pos2.y = 0;
sprite->data[4]++;
case 1:
sprite->pos2.y -= 8;
if(sprite->pos2.y == -160)
{
sprite->pos2.y = 0;
sprite->data[2] = 1;
sprite->data[3] = 0;
sprite->data[4] = 0;
}
}
}
void sub_8097D30(struct Sprite *sprite)
{
switch(sprite->data[4])
{
case 0:
sprite->pos2.y = -160;
sprite->data[4]++;
case 1:
sprite->pos2.y += 8;
if(sprite->pos2.y == 0)
{
sprite->data[3] = 0;
sprite->data[4] = 0;
}
}
}
void sub_8097D68(struct Sprite *sprite)
{
switch(sprite->data[3])
{
case 1:
sub_8097D30(sprite);
break;
case 2:
sub_8097CF4(sprite);
break;
case 0:
break;
default:
sprite->data[3] = 0;
break;
}
}
bool32 sub_8097D9C(u8 var)
{
u8 spriteId = sub_8097B2C(var);
if(spriteId == MAX_SPRITES)
return FALSE;
if(gSprites[spriteId].data[3] != FALSE)
return TRUE;
return FALSE;
}
u32 oe_exec_and_other_stuff(u8 fieldEffectId, struct MapObject *mapObject)
{
FieldObjectGetLocalIdAndMap(mapObject, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]);
return FieldEffectStart(fieldEffectId);
}
void DoShadowFieldEffect(struct MapObject *mapObject)
{
if (!mapObject->mapobj_bit_22)
{
mapObject->mapobj_bit_22 = 1;
oe_exec_and_other_stuff(FLDEFF_SHADOW, mapObject);
}
}
void DoRippleFieldEffect(struct MapObject *mapObject, struct Sprite *sprite)
{
const struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId);
gFieldEffectArguments[0] = sprite->pos1.x;
gFieldEffectArguments[1] = sprite->pos1.y + (gfxInfo->height >> 1) - 2;
gFieldEffectArguments[2] = 151;
gFieldEffectArguments[3] = 3;
FieldEffectStart(FLDEFF_RIPPLE);
}