summaryrefslogtreecommitdiff
path: root/mm/src/code/z_prenmi.c
blob: e1282db6bc1a588a1395cdb19f4e330a34d073a0 (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
#include "global.h"
#include "z_prenmi.h"

void PreNMI_Stop(PreNMIState* this) {
    STOP_GAMESTATE(&this->state);
    SET_NEXT_GAMESTATE(&this->state, NULL, 0);
}

void PreNMI_Update(PreNMIState* this) {
    if (this->timer == 0) {
        ViConfig_UpdateVi(true);
        PreNMI_Stop(this);
    } else {
        this->timer--;
    }
}

void PreNMI_Draw(PreNMIState* this) {
    GraphicsContext* gfxCtx = this->state.gfxCtx;

    func_8012CF0C(gfxCtx, true, true, 0, 0, 0);

    OPEN_DISPS(gfxCtx);

    Gfx_SetupDL36_Opa(gfxCtx);

    gDPSetFillColor(POLY_OPA_DISP++, (GPACK_RGBA5551(255, 255, 255, 1) << 16) | GPACK_RGBA5551(255, 255, 255, 1));
    gDPFillRectangle(POLY_OPA_DISP++, 0, this->timer + 100, SCREEN_WIDTH - 1, this->timer + 100);

    CLOSE_DISPS(gfxCtx);
}

void PreNMI_Main(GameState* thisx) {
    PreNMIState* this = (PreNMIState*)thisx;

    PreNMI_Update(this);
    PreNMI_Draw(this);

    this->state.unk_A3 = 1;
}

void PreNMI_Destroy(GameState* thisx) {
}

void PreNMI_Init(GameState* thisx) {
    PreNMIState* this = (PreNMIState*)thisx;

    this->state.main = PreNMI_Main;
    this->state.destroy = PreNMI_Destroy;
    this->timer = 30;
    this->unk_A8 = 10;

    GameState_SetFramerateDivisor(&this->state, 1);
}