-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.cpp
90 lines (67 loc) · 1.99 KB
/
main.cpp
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
79
80
81
82
83
84
85
86
87
88
89
#include <libgba-cpp/arch/display/layers.h>
#include <libgba-cpp/arch/display/effects.h>
#include <libgba-cpp/arch/display/window.h>
#include "sample_tiles.h"
#include "sample_map.h"
using namespace gba::display;
using namespace gba::display::map;
using namespace resources::maps;
using namespace test;
void copy_palette() {
for (auto i = 0u; i < sample_palette.size(); ++i) {
bg_palette()[i + 1] = sample_palette[i];
}
}
void copy_tiles() {
for (auto i = 0u; i < sample_tiles.size(); ++i) {
tileset()[i + 1] = sample_tiles[i];
}
}
void gen_map() {
for (auto i = 0u; i < layer0.size(); ++i) {
auto x = i % 8;
auto y = i / 8;
tilemap()[x + 32 * y] = layer0[i];
}
for (auto i = 0u; i < layer1.size(); ++i) {
tilemap()[i + 3 + 32 * 3 + 0x400] = layer1[i];
}
}
int main() {
layer_visible(Layer::BG0);
layer_visible(Layer::BG1);
set_window_visible(Window::WIN0);
set_window_visible(Window::WIN1);
bg_control(Layer::BG0).screen_base_block(1);
bg_control(Layer::BG1).screen_base_block(2);
bg_control(Layer::BG3).priority(BGPriority::LOWEST);
bg_control(Layer::BG2).priority(BGPriority::LOW);
bg_control(Layer::BG1).priority(BGPriority::HIGH);
bg_control(Layer::BG0).priority(BGPriority::HIGHEST);
bg_ox(Layer::BG0) = -64;
bg_oy(Layer::BG0) = -16;
bg_ox(Layer::BG1) = 16;
bg_oy(Layer::BG1) = -16;
auto& window_control = gba::display::window_control();
auto& window0 = gba::display::window0();
auto& window1 = gba::display::window1();
window_control.window0_enable(Layer::BG0);
window_control.window1_enable(Layer::BG1);
copy_palette();
copy_tiles();
gen_map();
window0.left = 80;
window0.right = 120;
window0.top = 4;
window0.bottom = 120;
window1.left = 0;
window1.right = 140;
window1.top = 0;
window1.bottom = 45;
auto i = 0;
while (true) {
vsync();
bg_ox(Layer::BG1) = -i;
++i;
}
}