You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add this section at the Tile_Maps.md file
cause this place describe the BG Map attributes and they are
the new addition in CGB mode that cause this confusion
Copy file name to clipboardExpand all lines: src/Tile_Maps.md
+33-5
Original file line number
Diff line number
Diff line change
@@ -33,15 +33,43 @@ Bit 3 Tile VRAM Bank number (0=Bank 0, 1=Bank 1)
33
33
Bit 2-0 Background Palette number (BGP0-7)
34
34
```
35
35
36
-
When Bit 7 is set, the corresponding BG tile will have priority above
37
-
all OBJs (regardless of the priority bits in OAM memory). There's also
38
-
a Master Priority flag in LCDC register Bit 0 which overrides all other
39
-
priority bits when cleared.
40
-
41
36
Note that, if the map entry at `0:9800` is tile \$2A, the attribute at
42
37
`1:9800` doesn't define properties for ALL tiles \$2A on-screen, but only
43
38
the one at `0:9800`!
44
39
40
+
### BG-to-OBJ Priority in CGB Mode
41
+
42
+
In CGB Mode, the priority between the BG (and window) layer and the OBJ layer is declared in three different places:
43
+
1.[BG Map Attribute bit 7](#bg-map-attributes-cgb-mode-only) - BG-to-OAM Priority (CGB Mode)
44
+
2.[LCDC bit 0](LCDC.md#lcdc0--bg-and-window-enablepriority) - BG and Window Priority (CGB Mode)
45
+
3.[OAM Attributes bit 7](OAM.md#byte-3--attributesflags) - BG and Window over OBJ
46
+
47
+
We can infer the following rules from the table below:
48
+
* When the BG color is 0 the OBJ will always have priority (ignoring the flags)
49
+
* When LCDC bit 0 is clear OBJ will always have priority (ignoring the rest of the flags)
50
+
* In order to grant the BG priority (color 1-3) LCDC bit 0 must be set and if OAM attributes bit 7 is clear BG Map attributes bit 7 must be set to override it
51
+
52
+
::: tip NOTE
53
+
54
+
OAM Attributes bit 7 will grant OBJ priority when clear and not when set
55
+
56
+
:::
57
+
58
+
The following table visualize the relations between the 3 flags
59
+
60
+
LCDC bit 0 | OAM attr bit 7 | BG attr bit 7 | Priority
0 commit comments