#include "types.hpp" #include "util.hpp" #include "input.hpp" void bad_vsync() { while (*REG_VCOUNT >= 160); while (*REG_VCOUNT < 160); } int main() { auto bg_flags = BGControlFlags() .set_charblock_base(0) .set_screenblock_base(28) .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( 0, 31, 0)); set_bg_palette(2, 1, Color::from_rgb( 0, 0, 31)); set_bg_palette(3, 1, Color::from_rgb(16, 16, 16)); for (int i = 0; i < 4; i++) { for (int j = 0; j < 32*32; j++) { auto screen_entry = ScreenEntry() .set_tile_index(i % 2) .set_palette_bank(i); set_screen_entry(28+i, j, screen_entry); } } 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; }