aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
blob: e694057d8a50886452abbcb0378ca9b1a26ae34f (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
/*
Copyright (c) 2021 Bad Diode

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/

#include "gba/gba.h"

#include "filesystem.c"
#include "renderer.c"
#include "sequencer.c"

#define PROF_ENABLE 0
#include "profiling.c"

//
// Config parameters.
//

int main(void) {
    // Adjust system wait times.
    SYSTEM_WAIT = SYSTEM_WAIT_CARTRIDGE;

    // Initialize filesystem.
    fs_init();

    // Initialize renderer.
    renderer_init();

    // Register interrupts.
    irq_init();
    irs_set(IRQ_VBLANK, irs_stub);

    // Initialize sequencer.
    sequencer_init();

    // Main loop.
    while (true) {
        poll_keys();
        bios_vblank_wait();
        FRAME_START();
        PROF(handle_sequencer_input(), input_cycles);
        PROF_SHOW();
        PROF(flip_buffer(), flip_cycles);
        FRAME_END();
    }

    return 0;
}