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
These registers can be accessed even during Mode 3, but modifications may not take
5
4
effect immediately (see further below).
@@ -22,46 +21,8 @@ Example from the homebrew game *Mindy's Hike*:
22
21
23
22
</figure>
24
23
25
-
## FF4A–FF4B — WY, WX: Window Y position, X position plus 7
26
-
27
-
These two registers specify the on-screen coordinates of [the Window](#Window)'s top-left pixel.
28
-
29
-
The Window is visible (if enabled) when both coordinates are in the ranges
30
-
WX=0..166, WY=0..143 respectively. Values WX=7, WY=0 place the Window at the
31
-
top left of the screen, completely covering the background.
32
-
33
-
:::warning Warning
34
-
35
-
WX values 0 and 166 are unreliable due to hardware bugs.
36
-
37
-
If WX is set to 0, the window will "stutter" horizontally when SCX changes
38
-
(depending on SCX % 8).
39
-
40
-
If WX is set to 166, the window will span the entirety of the following
41
-
scanline.
42
-
43
-
:::
44
-
45
24
## Mid-frame behavior
46
25
47
-
### Scrolling
48
-
49
26
The scroll registers are re-read on each [tile fetch](<#Get Tile>), except for the low 3 bits of SCX, which are only read at the beginning of the scanline (for the initial shifting of pixels).
50
27
51
28
All models before the CGB-D read the Y coordinate once for each bitplane (so a very precisely timed SCY write allows "desyncing" them), but CGB-D and later use the same Y coordinate for both no matter what.
52
-
53
-
### Window
54
-
55
-
While the Window should work as just mentioned, writing to WX, WY etc. mid-frame shows a more articulated behavior.
56
-
57
-
For the window to be displayed on a scanline, the following conditions must be met:
58
-
59
-
-**WY condition was triggered**: i.e. at some point in this frame the value of WY was equal to LY (checked at the start of Mode 2 only)
60
-
-**WX condition was triggered**: i.e. the current X coordinate being rendered + 7 was equal to WX
61
-
- Window enable bit in LCDC is set
62
-
63
-
If the WY condition has already been triggered and at the start of a row the window enable bit was set,
64
-
then resetting that bit before the WX condition gets triggered on that row yields a nice window glitch pixel where the window would have been activated.
65
-
66
-
The way the Window selects which line of its tilemap to render may be surprising: the Y position is selected by an internal counter, which is reset to 0 during VBlank and **only** incremented when the Window starts being rendered on a given scanline.
67
-
In particular, this means that hiding the Window mid-frame in any way (via either `WX` or `LCDC`, usually to display a status bar at the top *and* bottom of the screen) will also inhibit incrementing that Y-position counter.
## FF4A–FF4B — WY, WX: Window Y position, X position plus 7
4
+
5
+
These two registers specify the on-screen coordinates of [the Window](#Window)'s top-left pixel.
6
+
7
+
The Window is visible (if enabled) when both coordinates are in the ranges
8
+
WX=0..166, WY=0..143 respectively. Values WX=7, WY=0 place the Window at the
9
+
top left of the screen, completely covering the background.
10
+
11
+
:::warning Warning
12
+
13
+
WX values 0 and 166 are unreliable due to hardware bugs.
14
+
15
+
If WX is set to 0, the window will "stutter" horizontally when SCX changes
16
+
(depending on SCX % 8).
17
+
18
+
If WX is set to 166, the window will span the entirety of the following
19
+
scanline.
20
+
21
+
:::
22
+
23
+
## Window mid-frame behavior
24
+
25
+
While the Window should work as just mentioned, writing to WX, WY etc. mid-frame shows a more articulated behavior.
26
+
27
+
For the window to be displayed on a scanline, the following conditions must be met:
28
+
29
+
-**WY condition was triggered**: i.e. at some point in this frame the value of WY was equal to LY (checked at the start of Mode 2 only)
30
+
-**WX condition was triggered**: i.e. the current X coordinate being rendered + 7 was equal to WX
31
+
- Window enable bit in LCDC is set
32
+
33
+
If the WY condition has already been triggered and at the start of a row the window enable bit was set,
34
+
then resetting that bit before the WX condition gets triggered on that row yields a nice window glitch pixel where the window would have been activated.
35
+
36
+
The way the Window selects which line of its tilemap to render may be surprising: the Y position is selected by an internal counter, which is reset to 0 during VBlank and **only** incremented when the Window starts being rendered on a given scanline.
37
+
In particular, this means that hiding the Window mid-frame in any way (via either `WX` or `LCDC`, usually to display a status bar at the top *and* bottom of the screen) will also inhibit incrementing that Y-position counter.
0 commit comments