summaryrefslogtreecommitdiff
path: root/src/fldeff_emotion.c
blob: efe4ef6832ea2db9761dda87dfbe65493858890c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "global.h"
#include "asm.h"
#include "sprite.h"
#include "asm_fieldmap.h"
#include "field_effect.h"

extern u32 gUnknown_0202FF84[];

extern struct SpriteTemplate gSpriteTemplate_839B510;
extern struct SpriteTemplate gSpriteTemplate_839B528;

u8 FldEff_ExclamationMarkIcon1(void)
{
    u8 spriteId = CreateSpriteAtEnd(&gSpriteTemplate_839B510, 0, 0, 0x53);

    if (spriteId != 64)
        sub_8084894(&gSprites[spriteId], 0, 0);
    
    return 0;
}

u8 FldEff_ExclamationMarkIcon2(void)
{
    u8 spriteId = CreateSpriteAtEnd(&gSpriteTemplate_839B510, 0, 0, 0x52);

    if (spriteId != 64)
        sub_8084894(&gSprites[spriteId], 33, 1);
    
    return 0;
}

u8 FldEff_HeartIcon(void)
{
    u8 spriteId = CreateSpriteAtEnd(&gSpriteTemplate_839B528, 0, 0, 0x52);

    if (spriteId != 64)
        sub_8084894(&gSprites[spriteId], 46, 0);
    
    return 0;
}

void sub_8084894(struct Sprite *sprite, u16 a2, u8 a3)
{
    sprite->oam.priority = 1;
    sprite->coordOffsetEnabled = 1;
    
    sprite->data0 = gUnknown_0202FF84[0];
    sprite->data1 = gUnknown_0202FF84[1];
    sprite->data2 = gUnknown_0202FF84[2];
    sprite->data3 = -5;
    sprite->data7 = a2;
    
    StartSpriteAnim(sprite, a3);
}

void objc_exclamation_mark_probably(struct Sprite *sprite)
{
    u8 mapObjId;

    if (TryGetFieldObjectIdByLocalIdAndMap(sprite->data0, sprite->data1, sprite->data2, &mapObjId)
     || sprite->animEnded)
    {
        FieldEffectStop(sprite, (u8)sprite->data7);
    }
    else
    {
        struct Sprite *mapObjSprite = &gSprites[gMapObjects[mapObjId].spriteId];
        sprite->data4 += sprite->data3;
        sprite->pos1.x = mapObjSprite->pos1.x;
        sprite->pos1.y = mapObjSprite->pos1.y - 16;
        sprite->pos2.x = mapObjSprite->pos2.x;
        sprite->pos2.y = mapObjSprite->pos2.y + sprite->data4;
        if (sprite->data4)
            sprite->data3++;
        else
            sprite->data3 = 0;
    }
}