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
88shortened 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
3838The fetcher fetches a row of 8 background or window pixels and queues
3939them 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>)
7575then the value for the tile is read as $FF.
7676
7777CGB 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
144144When rendering the window the background FIFO is cleared and the fetcher
145145is 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
148148When the window has already started rendering there is a bug that occurs
149149when 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
161161At this point the [ fetcher] ( < #FIFO Pixel Fetcher > ) is advanced one step
162162until 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
164164be [ aborted] ( < #Sprite Fetch Abortion > ) after the fetcher has advanced a
165165step.
166166
167167When 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
169169mode 3 by is whatever the lower 3 bits of SCX are. After this penalty is
170170applied object fetching may be aborted. Note that the timing of the
171171penalty is not confirmed. It may happen before or after waiting for the
172172fetcher. More research needs to be done.
173173
174174After 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
177177there is a chance for a sprite fetch abortion to occur.
178178
179179The 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
181181this 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
183183target object tile is now retrieved and does not shorten mode 3.
184184
185185At this point [ VRAM Access] ( < #VRAM Access > ) is checked for the lower and
@@ -195,7 +195,7 @@ is replaced with the target object's properties.
195195Now it's time to [ render a pixel] ( < #Pixel Rendering > ) ! The same process
196196described in Sprite Fetch Abortion is performed: a pixel is rendered and
197197the 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
199199coordinate is 160 the PPU stops processing sprites (because they won't be
200200visible).
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
250250At various times during PPU operation read access to the CGB palette is
251251restored 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
264264Sprite fetching may be aborted if LCDC.1 is disabled while the PPU is
265265fetching 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
267267the PPU to process. When OAM fetching is aborted a pixel is [ rendered] ( < #Pixel Rendering > ) ,
268268the [ 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
270270current pixel is 160 the PPU stops processing sprites because they won't
271271be visible.
0 commit comments