// SPDX-License-Identifier: MIT // OAM order against priority (Tonc §24 "The object-priority bug"; GBATEK §LCD OBJ - OAM // Attributes "Priority"): obj0 at priority 1 overlapping obj1 at priority 0, with BG0 at // priority 0 between them; then the same with the numbers in line with the priorities. #include "scene.h" int main(void) { DISPCNT = 0x0080; palette_fill(0, 256, 18); palette_fill(256, 256, 19); for (int t = 0; t < 32; t++) tile4(t * 32, t); map_text(16, 1, 32, 2); BGCNT(0) = 16 << 8 | 0; for (int t = 0; t < 256; t++) { // solid tiles: obj0's colour 1, obj1's colour 2 (palette banks 0 and 1) volatile u16 *q = (volatile u16 *)(0x06010000 + t * 32); for (int i = 0; i < 16; i++) q[i] = t < 128 ? 0x1111 : 0x2222; } obj_clear(); obj_set(0, 20, 20 | 3 << 14, 0 | 1 << 10); // obj0: priority 1 (under BG0) obj_set(1, 50, 50 | 3 << 14, 128 | 0 << 10); // obj1: priority 0 (over BG0) obj_set(2, 80, 130 | 3 << 14, 0 | 0 << 10); // obj2: priority 0 obj_set(3, 100, 160 | 3 << 14, 128 | 1 << 10); // obj3: priority 1 PAL16[0] = rgb(0, 0, 0); DISPCNT = 0x0100 | 0x1000 | 0x0040; forever(); }