Skip to content

Commit 9bd5bdb

Browse files
authored
Add cross-page links to the "Accessing VRAM" warning box (#572)
1 parent 664a947 commit 9bd5bdb

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

src/Accessing_VRAM_and_OAM.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@
33

44
:::warning Warning
55

6-
When the PPU is drawing the screen it is directly reading
7-
from Video Memory (VRAM) and from the Object Attribute Memory (OAM).
8-
During these periods the Game Boy CPU may not access VRAM and OAM.
9-
That means that any attempts to write to VRAM or OAM are ignored (data
10-
remains unchanged). And any attempts to read from VRAM or OAM will return
11-
undefined data (typically $FF).
12-
13-
For this reason the program should verify if VRAM/OAM is accessible
14-
before actually reading or writing to it. This is usually done by
15-
reading the Mode bits from the STAT Register (FF41). When doing this (as
16-
described in the examples below) you should take care that no interrupts
17-
occur between the wait loops and the following memory access - the
18-
memory is guaranteed to be accessible only for a few cycles just
19-
after the wait loops have completed.
6+
When the PPU is [drawing the screen](<#Rendering overview>), it is often directly reading from Video Memory (VRAM) and from the Object Attribute Memory (OAM).
7+
During these periods, the Game Boy CPU cannot access VRAM and OAM.
8+
9+
That means that any attempts to write to VRAM or OAM are ignored (data remains unchanged).
10+
And any attempts to read from VRAM or OAM will return undefined data (typically $FF).
11+
12+
For this reason the program should verify if VRAM/OAM is accessible before actually reading or writing to it.
13+
This is usually done by reading the Mode bits from [the STAT Register](<#FF41 — STAT: LCD status>).
14+
When doing this (as described in the examples below) you should take care that **no interrupts occur between the wait loops and the following memory access**;
15+
the memory is guaranteed to be accessible only for a few cycles (less than Mode 2's length) just after a wait loop exits.
2016

2117
:::
2218

@@ -66,8 +62,7 @@ During those modes, OAM can be accessed directly or by doing a DMA
6662
transfer (FF46). Outside those modes, DMA out-prioritizes the PPU in
6763
accessing OAM, and the PPU will read $FF from OAM during that time.
6864

69-
A typical
70-
procedure that waits for accessibility of OAM would be:
65+
A typical procedure that waits for accessibility of OAM would be:
7166

7267
```rgbasm
7368
ld hl, $FF41 ; STAT Register

0 commit comments

Comments
 (0)