Skip to content

Commit 15009a4

Browse files
committed
Overhaul "Pixel FIFO" article into "Rendering Internals"
Also avoid describing SameBoy internals, instead relying on it when otherwise corroborated, or on schematics and/or test ROMs when possible. Restructure the article to describe behavior more than components, especially in a way that is more friendly to someone not knowing what all the components are about. Add a diagram, too, and move the mode timing diagram to the STAT article, where it belongs just as well, but where it will be more visible and thus more useful.
1 parent 35aecc3 commit 15009a4

File tree

9 files changed

+608
-289
lines changed

9 files changed

+608
-289
lines changed

custom/style.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ html {
2121

2222
body {
2323
font-family: "Inter";
24-
/* Enable some font features for Inter (https://rsms.me/inter/#features/calt) */
24+
/* Enable some font features for Inter (https://rsms.me/inter/#features) */
2525
font-feature-settings: "ss01", /* Alternate (Open) digits */ "ss02",
26-
/* Disambiguation gliphs */ "case";
26+
/* Disambiguation glyphs */ "case", /* No contextual alternatives (e.g. 3x9 → 3×9) */ "calt" 0;
2727
/* Case alternates */
2828
letter-spacing: -0.005em;
2929
/* equals -0.5% */
@@ -100,6 +100,13 @@ code {
100100
margin: 25px 0px 25px 0px;
101101
}
102102

103+
/* Classes for custom table styling */
104+
105+
table.compact th {
106+
padding: 3px 5px;
107+
}
108+
109+
103110
/* Global CSS variables */
104111

105112
:root {

src/Power_Up_Sequence.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ It is speculated that this may be debug remnants.
106106

107107
The boot ROM is responsible for the automatic colorization of monochrome-only games when run on a GBC.
108108

109-
When in DMG compatibility mode, the [CGB palettes](<#LCD Color Palettes (CGB only)>) are still being used: the background uses BG palette 0 (likely because the entire [attribute map](<#BG Map Attributes (CGB Mode only)>) is set to all zeros), and objects use OBJ palette 0 or 1 depending on bit 4 of [their attribute](<#Byte 3 — Attributes/Flags>).
109+
When in DMG compatibility mode, the [CGB palettes](<#LCD Color Palettes (CGB only)>) are still being used: the background uses BG palette 0 (likely because the entire [attribute map](<#BG Map attributes (CGB Mode only)>) is set to all zeros), and objects use OBJ palette 0 or 1 depending on bit 4 of [their attribute](<#Byte 3 — Attributes/Flags>).
110110
[`BGP`, `OBP0`, and `OBP1`](<#LCD Monochrome Palettes>) actually index into the CGB palettes instead of the DMG's shades of grey.
111111

112112
The boot ROM picks a compatibility palette using an ID computed using the following algorithm:

src/Rendering_Internals.md

Lines changed: 408 additions & 0 deletions
Large diffs are not rendered by default.

src/STAT.md

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

33
::: tip TERMINOLOGY
44

5-
A *dot* is the shortest period over which the PPU can output one pixel: is it equivalent to 1 T-state on DMG or on CGB single-speed mode or 2 T-states on CGB double-speed mode. On each dot during mode 3, either the PPU outputs a pixel or the fetcher is stalling the [FIFOs](<#Pixel FIFO>).
5+
A *dot* is the shortest period over which the PPU can output one pixel: is it equivalent to 1 T-state on DMG or on CGB single-speed mode or 2 T-states on CGB double-speed mode. On each dot during mode 3, either the PPU outputs a pixel or the fetcher is stalling the [FIFOs](<#Rendering Internals>).
66

77
:::
88

@@ -49,12 +49,7 @@ every 456 dots. Scanlines 144 through 153 are mode 1.
4949

5050
The following sequence is typical when the display is enabled:
5151

52-
```
53-
Mode 2 2_____2_____2_____2_____2_____2___________________2____
54-
Mode 3 _33____33____33____33____33____33__________________3___
55-
Mode 0 ___000___000___000___000___000___000________________000
56-
Mode 1 ____________________________________11111111111111_____
57-
```
52+
{{#include imgs/ppu_modes_timing.svg:2:}}
5853

5954
When the PPU is accessing some video-related memory, that memory is inaccessible
6055
to the CPU: writes are ignored, and reads return garbage values (usually $FF).
@@ -70,11 +65,11 @@ Mode | Action | Duration
7065
0 | Nothing (HBlank) | 85 to 208 dots, depending on previous mode 3 duration | VRAM, OAM, CGB palettes
7166
1 | Nothing (VBlank) | 4560 dots (10 scanlines) | VRAM, OAM, CGB palettes
7267

73-
## Properties of STAT modes
68+
## STAT modes
7469

7570
Unlike most game consoles, the Game Boy can pause the dot clock briefly,
7671
making Mode 3 longer and Mode 0 shorter. It routinely takes a 6 to 11 dot
77-
break to fetch an OBJ's tile between background tile pattern fetches.
72+
break to fetch an OBJ's tile between background tile fetches.
7873
On DMG and GBC in DMG mode, mid-scanline writes to [`BGP`](<#FF47 — BGP (Non-CGB Mode only): BG palette data>)
7974
allow observing this behavior, as the delay from drawing an OBJ shifts the
8075
write's effect to the left by that many dots.

src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
- [LCD Status Registers](./STAT.md)
2525
- [Scrolling](./Scrolling.md)
2626
- [Palettes](./Palettes.md)
27-
- [Pixel FIFO](./pixel_fifo.md)
27+
- [Rendering internals](./Rendering_Internals.md)
2828
- [Audio](./Audio.md)
2929
- [Audio Registers](./Audio_Registers.md)
3030
- [Audio Details](./Audio_details.md)

src/Scrolling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ scanline.
3333

3434
### Scrolling
3535

36-
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).
36+
The scroll registers are re-read on each [tile fetch](<#Get tile ID>), except for the low 3 bits of SCX, which are only read at the beginning of the scanline (for the initial shifting of pixels).
3737

3838
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.
3939

src/Tile_Maps.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ The Game Boy contains two 32×32 tile maps in VRAM at
55
the memory areas `$9800-$9BFF` and `$9C00-$9FFF`. Any of these maps can be used to
66
display the Background or the Window.
77

8-
## Tile Indexes
8+
## Tile indices
99

10-
Each tile map contains the 1-byte indexes of the
11-
tiles to be displayed.
10+
Each tile map contains the 1-byte indices of the tiles to be displayed.
1211

1312
Tiles are obtained from the Tile Data Table using either of the two
1413
addressing modes (described in [VRAM Tile Data](<#VRAM Tile Data>)), which
@@ -17,7 +16,7 @@ can be selected via [the LCDC register](<#FF40 — LCDC: LCD control>).
1716
Since one tile has 8×8 pixels, each map holds a 256×256 pixels picture.
1817
Only 160×144 of those pixels are displayed on the LCD at any given time.
1918

20-
## BG Map Attributes (CGB Mode only)
19+
## BG Map attributes (CGB Mode only)
2120

2221
In CGB Mode, an additional map of 32×32 bytes is stored in VRAM Bank 1
2322
(each byte defines attributes for the corresponding tile-number map

src/imgs/ppu_overview.svg

Lines changed: 181 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)