Skip to content

Commit 273a4db

Browse files
authored
Document community register aliases and recently identified registers (#606)
1 parent 0890edd commit 273a4db

10 files changed

+30
-26
lines changed

src/Audio.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The SGB2 rectifies this issue.
5454
All interfaces to the APU use **durations** instead of frequencies, which may be confusing as signal theory and music are more typically based on the latter.
5555
Thus, durations will be expressed from their frequencies: for example, a "256 Hz tick" means "1 ∕ 256th of a second".
5656

57-
The length of APU ticks is not affected by [CGB double speed](<#FF4D — KEY1 (CGB Mode only): Prepare speed switch>), so the APU works just the same regardless of CPU speed.
57+
The length of APU ticks is not affected by [CGB double speed](<#FF4D — KEY1/SPD (CGB Mode only): Prepare speed switch>), so the APU works just the same regardless of CPU speed.
5858

5959
:::warning Terminology
6060

src/Audio_Registers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ As a rule of thumb, for any `x` in `1`, `2`, `3`, `4`:
1212

1313
...but there are some exceptions.
1414

15-
One of the pitfalls of the `NRxy` naming convention is that the register's purpose is not immediately clear from its name, so some alternative names have been proposed, [such as `AUDENA` for `NR52`](https://github.com/gbdev/hardware.inc/blob/05f5a9b6c7172abe1d7488080c1c050284c09226/hardware.inc#L415).
15+
One of the pitfalls of the `NRxy` naming convention is that the register's purpose is not immediately clear from its name, so some alternative `AUD*` names have been proposed, [such as `AUDENA` for `NR52`](https://github.com/gbdev/hardware.inc/blob/8d4432e5796bffe2e13c438013285c5f11c37b99/hardware.inc#L910).
1616

1717
## Global control registers
1818

src/Audio_details.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Same, but with channels 3 and 4.
8484

8585
### DIV-APU
8686

87-
A "DIV-APU" counter is increased every time `DIV`'s bit 4 (5 in [double-speed mode](<#FF4D — KEY1 (CGB Mode only): Prepare speed switch>)) goes from 1 to 0, therefore at a frequency of 512 Hz (regardless of whether double-speed is active).
87+
A "DIV-APU" counter is increased every time `DIV`'s bit 4 (5 in [double-speed mode](<#FF4D — KEY1/SPD (CGB Mode only): Prepare speed switch>)) goes from 1 to 0, therefore at a frequency of 512 Hz (regardless of whether double-speed is active).
8888
Thus, the counter can be made to increase faster by writing to `DIV` while its relevant bit is set (which clears `DIV`, and triggers the falling edge).
8989

9090
The following events occur every <var>N</var> DIV-APU ticks:

src/CGB_Registers.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ use "repaired" color palette data matching for GBA displays.
2828

2929
### LCD VRAM DMA Transfers
3030

31+
One of the pitfalls of the `HDMAx` naming convention is that the register's purpose is not immediately clear from its name, so some alternative `VDMA_*` names have been proposed, [such as `VDMA_LEN` for `HDMA5`](https://github.com/gbdev/hardware.inc/blob/8d4432e5796bffe2e13c438013285c5f11c37b99/hardware.inc#L919).
32+
3133
#### FF51–FF52 — HDMA1, HDMA2 (CGB Mode only): VRAM DMA source (high, low) \[write-only\]
3234

3335
These two registers specify the address at which the transfer will read
@@ -142,7 +144,7 @@ corresponding Tile Maps.
142144
Reading from this register will return the number of the currently
143145
loaded VRAM bank in bit 0, and all other bits will be set to 1.
144146

145-
### FF4D — KEY1 (CGB Mode only): Prepare speed switch
147+
### FF4D — KEY1/SPD (CGB Mode only): Prepare speed switch
146148

147149
{{#bits 8 >
148150
"KEY1" 7:"Current speed" 0:"Switch armed"
@@ -219,7 +221,7 @@ ON/OFF pulses (length 10us ON, 17.5us OFF each) instead of a permanent
219221
880us LED ON signal. Even though being generally CGB compatible, the GBA
220222
does not include an infra-red port.
221223

222-
### FF4C — KEY0 (CGB Mode only): CPU mode select
224+
### FF4C — KEY0/SYS (CGB Mode only): CPU mode select
223225

224226
This GBC-only register (which is not officially documented) is written only by the CGB boot ROM,
225227
as it gets locked after the bootrom finish execution (by a write to the [BANK register](<#Monochrome models (DMG0, DMG, MGB)>)).
@@ -251,7 +253,7 @@ This register serves as a flag for which object priority mode to use. While
251253
the DMG prioritizes objects by x-coordinate, the CGB prioritizes them by
252254
location in OAM. This flag is set by the CGB bios after checking the game's CGB compatibility.
253255

254-
OPRI has an effect if a [PGB](<#PGB mode>) value (`0xX8`, `0xXC`) is written to [KEY0](<#FF4C — KEY0 (CGB Mode only): CPU mode select>) but STOP hasn't been executed yet, and the write takes effect instantly.
256+
OPRI has an effect if a [PGB](<#PGB mode>) value (`0xX8`, `0xXC`) is written to [KEY0](<#FF4C — KEY0/SYS (CGB Mode only): CPU mode select>) but STOP hasn't been executed yet, and the write takes effect instantly.
255257

256258
:::warning TO BE VERIFIED
257259

@@ -266,7 +268,7 @@ It is not known if triggering a PSM NMI, which remaps the boot ROM, has an effec
266268

267269
- **Priority mode** (*Read/Write*): `0` = CGB-style priority, `1` = DMG-style priority
268270

269-
### FF70 — SVBK (CGB Mode only): WRAM bank
271+
### FF70 — SVBK/WBK (CGB Mode only): WRAM bank
270272

271273
In CGB Mode, 32 KiB of internal RAM are available.
272274
This memory is divided into 8 banks of 4 KiB each.

src/Hardware_Reg_List.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ $FF48 | [OBP0] | OBJ palette 0 data
4545
$FF49 | [OBP1] | OBJ palette 1 data | R/W | DMG
4646
$FF4A | [WY] | Window Y position | R/W | All
4747
$FF4B | [WX] | Window X position plus 7 | R/W | All
48-
$FF4D | [KEY1] | Prepare speed switch | Mixed | CGB
48+
$FF4C | [KEY0/SYS] | CPU mode select | Mixed | CGB
49+
$FF4D | [KEY1/SPD] | Prepare speed switch | Mixed | CGB
4950
$FF4F | [VBK] | VRAM bank | R/W | CGB
51+
$FF50 | [BANK] | Boot ROM mapping control | W | All
5052
$FF51 | [HDMA1] | VRAM DMA source high | W | CGB
5153
$FF52 | [HDMA2] | VRAM DMA source low | W | CGB
5254
$FF53 | [HDMA3] | VRAM DMA destination high | W | CGB
@@ -58,7 +60,7 @@ $FF69 | [BCPD/BGPD] | Background color palette data / Background palette da
5860
$FF6A | [OCPS/OBPI] | OBJ color palette specification / OBJ palette index | R/W | CGB
5961
$FF6B | [OCPD/OBPD] | OBJ color palette data / OBJ palette data | R/W | CGB
6062
$FF6C | [OPRI] | Object priority mode | R/W | CGB
61-
$FF70 | [SVBK] | WRAM bank | R/W | CGB
63+
$FF70 | [SVBK/WBK] | WRAM bank | R/W | CGB
6264
$FF76 | [PCM12] | Audio digital outputs 1 & 2 | R | CGB
6365
$FF77 | [PCM34] | Audio digital outputs 3 & 4 | R | CGB
6466
$FFFF | [IE] | Interrupt enable | R/W | All
@@ -105,8 +107,10 @@ $FFFF | [IE] | Interrupt enable
105107
[OBP1]: <#FF48–FF49 — OBP0, OBP1 (Non-CGB Mode only): OBJ palette 0, 1 data>
106108
[WY]: <#FF4A–FF4B — WY, WX: Window Y position, X position plus 7>
107109
[WX]: <#FF4A–FF4B — WY, WX: Window Y position, X position plus 7>
108-
[KEY1]: <#FF4D — KEY1 (CGB Mode only): Prepare speed switch>
110+
[KEY0/SYS]: <#FF4C — KEY0/SYS (CGB Mode only): CPU mode select>
111+
[KEY1/SPD]: <#FF4D — KEY1/SPD (CGB Mode only): Prepare speed switch>
109112
[VBK]: <#FF4F — VBK (CGB Mode only): VRAM bank>
113+
[BANK]: <#Power-Up Sequence>
110114
[HDMA1]: <#FF51–FF52 — HDMA1, HDMA2 (CGB Mode only): VRAM DMA source (high, low) \[write-only\]>
111115
[HDMA2]: <#FF51–FF52 — HDMA1, HDMA2 (CGB Mode only): VRAM DMA source (high, low) \[write-only\]>
112116
[HDMA3]: <#FF53–FF54 — HDMA3, HDMA4 (CGB Mode only): VRAM DMA destination (high, low) \[write-only\]>
@@ -118,7 +122,7 @@ $FFFF | [IE] | Interrupt enable
118122
[OCPS/OBPI]: <#FF6A–FF6B — OCPS/OBPI, OCPD/OBPD (CGB Mode only): OBJ color palette specification / OBJ palette index, OBJ color palette data / OBJ palette data>
119123
[OCPD/OBPD]: <#FF6A–FF6B — OCPS/OBPI, OCPD/OBPD (CGB Mode only): OBJ color palette specification / OBJ palette index, OBJ color palette data / OBJ palette data>
120124
[OPRI]: <#FF6C — OPRI (CGB Mode only): Object priority mode>
121-
[SVBK]: <#FF70 — SVBK (CGB Mode only): WRAM bank>
125+
[SVBK]: <#FF70 — SVBK/WBK (CGB Mode only): WRAM bank>
122126
[PCM12]: <#FF76 — PCM12 (CGB Mode only): Digital outputs 1 & 2 \[read-only\]>
123127
[PCM34]: <#FF77 — PCM34 (CGB Mode only): Digital outputs 3 & 4 \[read-only\]>
124128
[IE]: <#FFFF — IE: Interrupt enable>

src/Memory_Map.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ $FF10 | $FF26 | DMG | [Audio](<#Audio Registers>)
3131
$FF30 | $FF3F | DMG | [Wave pattern](<#FF30–FF3F — Wave pattern RAM>)
3232
$FF40 | $FF4B | DMG | LCD [Control](<#FF40 — LCDC: LCD control>), [Status](<#FF41 — STAT: LCD status>), [Position, Scrolling](<#LCD Position and Scrolling>), and [Palettes](<#Palettes>)
3333
$FF4F | | CGB | [VRAM Bank Select](<#FF4F — VBK (CGB Mode only): VRAM bank>)
34-
$FF50 | | DMG | Set to non-zero to disable boot ROM
34+
$FF50 | | DMG | [Boot ROM mapping control](<#Power-Up Sequence>)
3535
$FF51 | $FF55 | CGB | [VRAM DMA](<#LCD VRAM DMA Transfers>)
3636
$FF68 | $FF6B | CGB | [BG / OBJ Palettes](<#LCD Color Palettes (CGB only)>)
37-
$FF70 | | CGB | [WRAM Bank Select](<#FF70 — SVBK (CGB Mode only): WRAM bank>)
37+
$FF70 | | CGB | [WRAM Bank Select](<#FF70 — SVBK/WBK (CGB Mode only): WRAM bank>)
3838

3939
## VRAM memory map
4040

src/Power_Up_Sequence.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ Then, like the monochrome boot ROMs, the header logo is checked *from the buffer
8686
For unknown reasons, however, only the first half of the logo is checked, despite the full logo being present in the HRAM buffer.
8787

8888
Finally, the boot ROM fades all BG palettes to white, and sets the hardware to compatibility mode.
89-
If [the CGB compatibility byte](<#0143 — CGB flag>) indicates CGB compatibility, the byte is written directly to [`KEY0`](<#FF4C — KEY0 (CGB Mode only): CPU mode select>), potentially [enabling "PGB mode"](<#PGB mode>);
90-
otherwise, $04 is written to [`KEY0`](<#FF4C — KEY0 (CGB Mode only): CPU mode select>) (enabling DMG compatibility mode in the CPU),
89+
If [the CGB compatibility byte](<#0143 — CGB flag>) indicates CGB compatibility, the byte is written directly to [`KEY0`](<#FF4C — KEY0/SYS (CGB Mode only): CPU mode select>), potentially [enabling "PGB mode"](<#PGB mode>);
90+
otherwise, $04 is written to [`KEY0`](<#FF4C — KEY0/SYS (CGB Mode only): CPU mode select>) (enabling DMG compatibility mode in the CPU),
9191
$01 is written to [`OPRI`](<#FF6C — OPRI (CGB Mode only): Object priority mode>) (enabling [DMG OBJ priority](<#Object Priority and Conflicts>)), and the [compatibility palettes](<#Compatibility palettes>) are written.
9292
Additionally, the DMG logo tilemap is written [if the compatibility requests it](<#Compatibility palettes>).
9393

@@ -314,8 +314,10 @@ Name | Address | DMG0 | DMG / MGB | SGB / SGB2 | CGB / AGB
314314
[`OBP1`] | $FF49 | ??[^obp] | ??[^obp] | ??[^obp] | ??[^obp]
315315
[`WY`] | $FF4A | $00 | $00 | $00 | $00
316316
[`WX`] | $FF4B | $00 | $00 | $00 | $00
317+
[`KEY0`] | $FF4C | --- | --- | --- | ??[^unk]
317318
[`KEY1`] | $FF4D | --- | --- | --- | $7E[^cgb_only]
318319
[`VBK`] | $FF4F | --- | --- | --- | $FE[^cgb_only]
320+
[`BANK`] | $FF50 | --- | --- | --- | ---
319321
[`HDMA1`] | $FF51 | --- | --- | --- | $FF[^cgb_only]
320322
[`HDMA2`] | $FF52 | --- | --- | --- | $FF[^cgb_only]
321323
[`HDMA3`] | $FF53 | --- | --- | --- | $FF[^cgb_only]
@@ -390,8 +392,10 @@ The table above was obtained from Mooneye-GB tests [`acceptance/boot_hwio-dmg0`]
390392
[`OBP1`]: <#FF48–FF49 — OBP0, OBP1 (Non-CGB Mode only): OBJ palette 0, 1 data>
391393
[`WY`]: <#FF4A–FF4B — WY, WX: Window Y position, X position plus 7>
392394
[`WX`]: <#FF4A–FF4B — WY, WX: Window Y position, X position plus 7>
393-
[`KEY1`]: <#FF4D — KEY1 (CGB Mode only): Prepare speed switch>
395+
[`KEY0`]: <#FF4C — KEY0/SYS (CGB Mode only): CPU mode select>
396+
[`KEY1`]: <#FF4D — KEY1/SPD (CGB Mode only): Prepare speed switch>
394397
[`VBK`]: <#FF4F — VBK (CGB Mode only): VRAM bank>
398+
[`BANK`]: <#Power-Up Sequence>
395399
[`HDMA1`]: <#FF51–FF52 — HDMA1, HDMA2 (CGB Mode only): VRAM DMA source (high, low) \[write-only\]>
396400
[`HDMA2`]: <#FF51–FF52 — HDMA1, HDMA2 (CGB Mode only): VRAM DMA source (high, low) \[write-only\]>
397401
[`HDMA3`]: <#FF53–FF54 — HDMA3, HDMA4 (CGB Mode only): VRAM DMA destination (high, low) \[write-only\]>
@@ -403,11 +407,5 @@ The table above was obtained from Mooneye-GB tests [`acceptance/boot_hwio-dmg0`]
403407
[`OCPS`]: <#FF6A–FF6B — OCPS/OBPI, OCPD/OBPD (CGB Mode only): OBJ color palette specification / OBJ palette index, OBJ color palette data / OBJ palette data>
404408
[`OCPD`]: <#FF6A–FF6B — OCPS/OBPI, OCPD/OBPD (CGB Mode only): OBJ color palette specification / OBJ palette index, OBJ color palette data / OBJ palette data>
405409
[`OPRI`]: <#FF6C — OPRI (CGB Mode only): Object priority mode>
406-
[`SVBK`]: <#FF70 — SVBK (CGB Mode only): WRAM bank>
407-
[FF72]: <#FF72–FF73 — Bits 0–7 (CGB Mode only)>
408-
[FF73]: <#FF72–FF73 — Bits 0–7 (CGB Mode only)>
409-
[FF74]: <#FF74 — Bits 0-7 (CGB Mode only)>
410-
[FF75]: <#FF75 — Bits 0-6>
411-
[`PCM12`]: <#FF76 — PCM12: PCM amplitudes 1 & 2 \[read-only\]>
412-
[`PCM34`]: <#FF77 — PCM34: PCM amplitudes 3 & 4 \[read-only\]>
410+
[`SVBK`]: <#FF70 — SVBK/WBK (CGB Mode only): WRAM bank>
413411
[`IE`]: <#FFFF — IE: Interrupt enable>

src/Rendering.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The main implication of this rendering process is the existence of **raster effe
99
The most famous raster effect is modifying the [scrolling registers](<#LCD Position and Scrolling>) between scanlines to create a ["wavy" effect](https://gbdev.io/guides/deadcscroll#effects).
1010

1111
A "**dot**" = one 2<sup>22</sup> Hz (≅ 4.194 MHz) time unit.
12-
Dots remain the same regardless of whether the CPU is in [Double Speed mode](<#FF4D — KEY1 (CGB Mode only): Prepare speed switch>), so there are 4 dots per Single Speed M-cycle, and 2 per Double Speed M-cycle.
12+
Dots remain the same regardless of whether the CPU is in [Double Speed mode](<#FF4D — KEY1/SPD (CGB Mode only): Prepare speed switch>), so there are 4 dots per Single Speed M-cycle, and 2 per Double Speed M-cycle.
1313

1414
:::tip NOTE
1515

src/The_Cartridge_Header.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Value | Meaning
5656
`$80` | The game supports CGB enhancements, but is backwards compatible with monochrome Game Boys
5757
`$C0` | The game works on CGB only (the hardware ignores bit 6, so this really functions the same as `$80`)
5858

59-
Setting bit 7 will trigger a write of this register value to [KEY0 register](<#FF4C — KEY0 (CGB Mode only): CPU mode select>) which sets the CPU mode.
59+
Setting bit 7 will trigger a write of this register value to [KEY0 register](<#FF4C — KEY0/SYS (CGB Mode only): CPU mode select>) which sets the CPU mode.
6060

6161
## 0144–0145 — New licensee code
6262

src/Timer_and_Divider_Registers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This register is incremented at a rate of 16384Hz (\~16779Hz on SGB).
1515
Writing any value to this register resets it to $00.
1616
Additionally, this register is reset when executing the `stop` instruction, and
1717
only begins ticking again once `stop` mode ends. This also occurs during a
18-
[speed switch](<#FF4D — KEY1 (CGB Mode only): Prepare speed switch>).
18+
[speed switch](<#FF4D — KEY1/SPD (CGB Mode only): Prepare speed switch>).
1919
(TODO: how is it affected by the wait after a speed switch?)
2020

2121
Note: The divider is affected by CGB double speed mode, and will

0 commit comments

Comments
 (0)