summaryrefslogtreecommitdiff
path: root/source/main.cpp
diff options
context:
space:
mode:
authorDaniel Hader <[email protected]>2026-08-28 21:27:29 -0500
committerDaniel Hader <[email protected]>2026-08-28 21:27:29 -0500
commit0f383adcdc02cad8dfb435ce73c1fe1c0c4b5bd6 (patch)
tree917569ca76e2160595f071c0c07834e3244ff6cd /source/main.cpp
parent77e153f99cb279c1deb5b257fb54c7fdbdd4bc19 (diff)
sprite proof of concept and improved display control bit flaggingHEADmain
Diffstat (limited to 'source/main.cpp')
-rw-r--r--source/main.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/source/main.cpp b/source/main.cpp
index 21d1c26..116094c 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -8,6 +8,7 @@ void bad_vsync() {
}
int main() {
+ // background control
auto bg_flags = BGControlFlags()
.set_charblock_base(0)
.set_screenblock_base(28)
@@ -16,6 +17,7 @@ int main() {
set_bg_control(0, bg_flags);
set_bg_offsets(0, 0, 0);
+ // background tiles
const Tile4 tiles[2] = {
{{0x11111111, 0x01111111, 0x01111111, 0x01111111, 0x01111111, 0x01111111, 0x01111111, 0x00000001}},
{{0x00000000, 0x00100100, 0x01100110, 0x00011000, 0x00011000, 0x01100110, 0x00100100, 0x00000000}},
@@ -24,11 +26,13 @@ int main() {
set_tile(0, 0, tiles[0]);
set_tile(0, 1, tiles[1]);
+ // background tiles
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));
+ // background screen entries
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 32*32; j++) {
auto screen_entry = ScreenEntry()
@@ -38,7 +42,30 @@ int main() {
}
}
- set_display_control(Mode0, BG0);
+ // object palettes
+ set_obj_palette(0, 1, Color::from_rgb(0, 0, 0));
+ set_obj_palette(0, 2, Color::from_rgb(31, 31, 0));
+
+ // object attributes
+ auto obj_attr = ObjectAttributes()
+ .set_size(ObjectAttributes::Size_16x16)
+ .set_tile_index(0)
+ .set_palette_bank(0)
+ .set_x(50).set_y(50);
+
+ set_obj_attributes(0, obj_attr);
+
+ Tile4 obj_tile = {0x01230123, 0x01230123, 0x01230123, 0x01230123, 0x01230123, 0x01230123, 0x01230123, 0x01230123};
+ for (u32 i = 0; i < 4; i++) {
+ set_tile(4, i, obj_tile);
+ }
+
+ auto display_control_flags = DisplayControlFlags()
+ .set_mode(0)
+ .enable_layer(BG0)
+ .enable_layer(Obj)
+ .set_1d_object_mapping(1);
+ set_display_control(display_control_flags);
s16 x = 0, y = 0;
while (1) {