Skip to content

Commit b99d50b

Browse files
authored
Fixes ppu_modes_timing.svg to more properly reflect the description b… (#355)
* Fixes ppu_modes_timing.svg to more properly reflect the description box above. Also added extra detail in the description box found under Rendering -> Pixel FIFO to more accurately explain what is meant by a 'dot'. * experimental * manually changed fifo timing svg * Fixed svg by manually formatting it. Also added a more accurate explanation of the meaning behind a dot. * Removed reference to T-cycles. Clarified that cycles refer to "dots" rather than T-cycles. Fixed spelling of "hblank" to "HBlank". * removed cycle alias for dot in fifo md file.
1 parent 301d2b6 commit b99d50b

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

src/imgs/ppu_modes_timing.svg

Lines changed: 5 additions & 9 deletions
Loading

src/pixel_fifo.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
::: tip TERMINOLOGY
44

5-
All references to a cycle are meant as T-cycles (4.19 MHz) and cycle
6-
counts are doubled on CGB in double speed mode. When it is stated that a
7-
certain action *lengthens mode 3* it means that mode 0 (hblank) is
5+
All references to a dot are meant as dots (4.19 MHz). Dots remain the same regardless of
6+
CGB double speed.
7+
When it is stated that a certain action *lengthens mode 3* it means that mode 0 (HBlank) is
88
shortened to make up for the additional time in mode 3, as shown in the following diagram.
99

1010
:::
@@ -37,8 +37,8 @@ Each pixel in the FIFO has four properties:
3737

3838
The fetcher fetches a row of 8 background or window pixels and queues
3939
them up to be mixed with sprite pixels. The pixel fetcher has 5 steps.
40-
The first four steps take 2 cycles each and the fifth step is attempted
41-
every cycle until it succeeds. The order of the steps are as follows:
40+
The first four steps take 2 dots each and the fifth step is attempted
41+
every dot until it succeeds. The order of the steps are as follows:
4242

4343
- Get tile
4444
- Get tile data low
@@ -75,7 +75,7 @@ VRAM. However, if the PPU's access to VRAM is [blocked](<#VRAM Access>)
7575
then the value for the tile is read as $FF.
7676

7777
CGB can access both tile index and the attributes in the same clock
78-
cycle.
78+
dot.
7979

8080
### Get Tile Data Low
8181

@@ -143,7 +143,7 @@ are cleared.
143143

144144
When rendering the window the background FIFO is cleared and the fetcher
145145
is reset to step 1. When WX is 0 and the SCX & 7 > 0 mode 3 is shortened
146-
by 1 cycle.
146+
by 1 dot.
147147

148148
When the window has already started rendering there is a bug that occurs
149149
when WX is changed mid-scanline. When the value of WX changes after the
@@ -160,26 +160,26 @@ met then sprite fetching is [aborted](<#Sprite Fetch Abortion>).
160160

161161
At this point the [fetcher](<#FIFO Pixel Fetcher>) is advanced one step
162162
until it's at step 5 or until the background FIFO is not empty. Advancing
163-
the fetcher one step here lengthens mode 3 by 1 cycle. This process may
163+
the fetcher one step here lengthens mode 3 by 1 dot. This process may
164164
be [aborted](<#Sprite Fetch Abortion>) after the fetcher has advanced a
165165
step.
166166

167167
When SCX & 7 > 0 and there is a sprite at X coordinate 0 of the current
168-
scanline then mode 3 is lengthened. The amount of cycles this lengthens
168+
scanline then mode 3 is lengthened. The amount of dots this lengthens
169169
mode 3 by is whatever the lower 3 bits of SCX are. After this penalty is
170170
applied object fetching may be aborted. Note that the timing of the
171171
penalty is not confirmed. It may happen before or after waiting for the
172172
fetcher. More research needs to be done.
173173

174174
After checking for sprites at X coordinate 0 the fetcher is advanced two
175-
steps. The first advancement lengthens mode 3 by 1 cycle and the second
176-
advancement lengthens mode 3 by 3 cycles. After each fetcher advancement
175+
steps. The first advancement lengthens mode 3 by 1 dot and the second
176+
advancement lengthens mode 3 by 3 dots. After each fetcher advancement
177177
there is a chance for a sprite fetch abortion to occur.
178178

179179
The lower address for the row of pixels of the target object tile is now
180-
retrieved and lengthens mode 3 by 1 cycle. Once the address is retrieved
180+
retrieved and lengthens mode 3 by 1 dot. Once the address is retrieved
181181
this is the last chance for sprite fetch abortion to occur. Exiting
182-
object fetch lengthens mode 3 by 1 cycle. The upper address for the
182+
object fetch lengthens mode 3 by 1 dot. The upper address for the
183183
target object tile is now retrieved and does not shorten mode 3.
184184

185185
At this point [VRAM Access](<#VRAM Access>) is checked for the lower and
@@ -195,7 +195,7 @@ is replaced with the target object's properties.
195195
Now it's time to [render a pixel](<#Pixel Rendering>)! The same process
196196
described in Sprite Fetch Abortion is performed: a pixel is rendered and
197197
the fetcher is advanced one step. This advancement lengthens mode 3 by 1
198-
cycle if the X coordinate of the current scanline is not 160. If the X
198+
dot if the X coordinate of the current scanline is not 160. If the X
199199
coordinate is 160 the PPU stops processing sprites (because they won't be
200200
visible).
201201

@@ -245,12 +245,12 @@ blocked and a black pixel pushed to the LCD when rendering pixels:
245245
- First HBlank of the frame
246246
- When searching OAM and index 37 is reached
247247
- After switching from mode 2 (oam search) to mode 3 (pixel transfer)
248-
- When entering HBlank (mode 0) and not in double speed mode, blocked 2 cycles later no matter what
248+
- When entering HBlank (mode 0) and not in double speed mode, blocked 2 dots later no matter what
249249

250250
At various times during PPU operation read access to the CGB palette is
251251
restored and pixels are pushed to the LCD normally when rendering pixels:
252252
- At the end of mode 2 (oam search)
253-
- For only 2 cycles when entering HBlank (mode 0) and in double speed mode
253+
- For only 2 dots when entering HBlank (mode 0) and in double speed mode
254254

255255
::: tip Note
256256

@@ -263,9 +263,9 @@ PPU's access to CGB palettes is always restored upon leaving STOP mode.
263263

264264
Sprite fetching may be aborted if LCDC.1 is disabled while the PPU is
265265
fetching an object from OAM. This abortion lengthens mode 3 by the amount
266-
of cycles the previous instruction took plus the residual cycles left for
266+
of dots the previous instruction took plus the residual dots left for
267267
the PPU to process. When OAM fetching is aborted a pixel is [rendered](<#Pixel Rendering>),
268268
the [fetcher](<#FIFO Pixel Fetcher>) is advanced one step. This advancement
269-
lengthens mode 3 by 1 cycle if the current pixel is not 160. If the
269+
lengthens mode 3 by 1 dot if the current pixel is not 160. If the
270270
current pixel is 160 the PPU stops processing sprites because they won't
271271
be visible.

0 commit comments

Comments
 (0)