summaryrefslogtreecommitdiff
path: root/source/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/main.cpp')
-rw-r--r--source/main.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/source/main.cpp b/source/main.cpp
new file mode 100644
index 0000000..ec6be22
--- /dev/null
+++ b/source/main.cpp
@@ -0,0 +1,57 @@
+#include "types.hpp"
+#include "util.hpp"
+#include "input.hpp"
+
+ScreenEntry *bg0_map = screenblock_mem[28];
+
+void bad_vsync() {
+ while (*REG_VCOUNT >= 160);
+ while (*REG_VCOUNT < 160);
+}
+
+int main() {
+ auto bg_flags = BGControlFlags()
+ .set_charblock_base(0)
+ .set_screenblock_base(0)
+ .set_size(BGControlSize::Regular_64x64);
+
+ set_bg_control(0, bg_flags);
+ set_bg_offsets(0, 0, 0);
+
+ const Tile4 tiles[2] = {
+ {{0x11111111, 0x01111111, 0x01111111, 0x01111111, 0x01111111, 0x01111111, 0x01111111, 0x00000001}},
+ {{0x00000000, 0x00100100, 0x01100110, 0x00011000, 0x00011000, 0x01100110, 0x00100100, 0x00000000}},
+ };
+
+ set_tile(0, 0, tiles[0]);
+ set_tile(0, 1, tiles[1]);
+
+ set_bg_palette(0, 1, Color::from_rgb(31, 0, 0));
+ set_bg_palette(1, 1, Color::from_rgb(31, 0, 0));
+ set_bg_palette(2, 1, Color::from_rgb(31, 0, 0));
+ set_bg_palette(3, 1, Color::from_rgb(31, 0, 0));
+
+ ScreenEntry *screen_entry_ptr = bg0_map;
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 32*32; j++) {
+ *screen_entry_ptr++ = ScreenEntry().set_palette_bank(i);
+ }
+ }
+
+ set_display_control(Mode0, BG0);
+
+ s16 x = 0, y = 0;
+ while (1) {
+ bad_vsync();
+ keyflags_poll();
+
+ if (key_is_down(Key::Left)) x -= 1;
+ if (key_is_down(Key::Right)) x += 1;
+ if (key_is_down(Key::Up)) y -= 1;
+ if (key_is_down(Key::Down)) y += 1;
+
+ set_bg_offsets(0, x, y);
+ }
+
+ return 0;
+}