summaryrefslogtreecommitdiff
path: root/src/object/litArea.c
blob: 80332d9a11ce7ad49aa377a96cdcf4d4647eacca (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
/**
 * @file litArea.c
 * @ingroup Objects
 *
 * @brief Lit Area object
 */
#include "entity.h"
#include "flags.h"
#include "room.h"
#include "screen.h"

typedef struct {
    /*0x00*/ Entity base;
    /*0x68*/ u16 unk_68;
    /*0x6a*/ u16 unk_6a;
    /*0x6c*/ u8 unused1[26];
    /*0x86*/ u16 flag;
} LitAreaEntity;

void LitArea(LitAreaEntity* this) {
    if (super->action == 0) {
        if (this->flag != 0 && CheckFlags(this->flag) == 0) {
            return;
        }
        super->spriteSettings.draw = 1;
        super->action = 1;
        super->spriteRendering.alphaBlend = 2;
        super->spriteRendering.b0 = 3;
        super->frameIndex = 3;
        super->flags |= ENT_PERSIST;
        super->subtimer = gRoomControls.room;
        super->timer = 2;
        this->unk_68 = -2;
        this->unk_6a = 0x80;
        SetAffineInfo(super, 0x80, 0x80, 0);
    } else {
        if (--super->timer == 0) {
            super->timer = 2;
            this->unk_6a += this->unk_68;
            if (this->unk_6a < 0x78) {
                this->unk_68 = 1;
            }
            if (this->unk_6a > 0x88) {
                this->unk_68 = -1;
            }
            SetAffineInfo(super, this->unk_6a, this->unk_6a, 0);
        }
    }
    gScreen.lcd.displayControl |= DISPCNT_OBJWIN_ON;
    gScreen.controls.windowOutsideControl = (gScreen.controls.windowOutsideControl & 0xff) | WINOUT_WINOBJ_BG0 |
                                            WINOUT_WINOBJ_BG1 | WINOUT_WINOBJ_BG2 | WINOUT_WINOBJ_OBJ |
                                            WINOUT_WINOBJ_CLR;
    if ((gRoomControls.room != super->subtimer) && (gRoomControls.reload_flags == 0)) {
        DeleteThisEntity();
    }
}