Skip to content

Commit

Permalink
Overhaul "Pixel FIFO" article into "Rendering Internals"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ISSOtm committed Mar 6, 2024
1 parent acd54eb commit fe13a13
Show file tree
Hide file tree
Showing 9 changed files with 605 additions and 270 deletions.
11 changes: 9 additions & 2 deletions custom/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ html {

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

/* Classes for custom table styling */

table.compact th {
padding: 3px 5px;
}


/* Global CSS variables */

:root {
Expand Down
2 changes: 1 addition & 1 deletion src/Power_Up_Sequence.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ It is speculated that this may be debug remnants.

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

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>).
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>).
[`BGP`, `OBP0`, and `OBP1`](<#LCD Monochrome Palettes>) actually index into the CGB palettes instead of the DMG's shades of grey.

The boot ROM picks a compatibility palette using an ID computed using the following algorithm:
Expand Down
408 changes: 408 additions & 0 deletions src/Rendering_Internals.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/STAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

:::tip TERMINOLOGY

A *dot* is the shortest period over which the PPU can output one pixel: is it equivalent to 1 T-cycle on DMG or on CGB Single Speed mode or 2 T-cycles 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>).
A *dot* is the shortest period over which the PPU can output one pixel: is it equivalent to 1 T-cycle on DMG or on CGB Single Speed mode or 2 T-cycles 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>).

:::

Expand Down
2 changes: 1 addition & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
- [Scrolling](./Scrolling.md)
- [Palettes](./Palettes.md)
- [Rendering](./Rendering.md)
- [Pixel FIFO](./pixel_fifo.md)
- [Rendering internals](./Rendering_Internals.md)
- [Audio](./Audio.md)
- [Audio Registers](./Audio_Registers.md)
- [Audio Details](./Audio_details.md)
Expand Down
2 changes: 1 addition & 1 deletion src/Scrolling.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ scanline.

### Scrolling

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).
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).

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.

Expand Down
7 changes: 3 additions & 4 deletions src/Tile_Maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ The Game Boy contains two 32×32 tile maps in VRAM at
the memory areas `$9800-$9BFF` and `$9C00-$9FFF`. Any of these maps can be used to
display the Background or the Window.

## Tile Indexes
## Tile indices

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

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

## BG Map Attributes (CGB Mode only)
## BG Map attributes (CGB Mode only)

In CGB Mode, an additional map of 32×32 bytes is stored in VRAM Bank 1
(each byte defines attributes for the corresponding tile-number map
Expand Down
181 changes: 181 additions & 0 deletions src/imgs/src/ppu_overview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit fe13a13

Please sign in to comment.