Skip to content

Commit 9e5f731

Browse files
ISSOtmavivace
authored andcommitted
Apply new section name style
1 parent ac4661c commit 9e5f731

37 files changed

+396
-406
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Multiple registers must be handled as a memory range, and the `REG_NAME` and `De
130130

131131
Examples:
132132
- 0104–0133 — Nintendo Logo
133-
- FF51–FF52 — HDMA1, HDMA2 (CGB Mode Only): New DMA Source (High, Low) \[write-only\]
133+
- FF51–FF52 — HDMA1, HDMA2 (CGB Mode only): New DMA Source (High, Low) \[write-only\]
134134

135135
It also follows that descriptions should not use commas outside of acting as separators for the aforementioned lists.
136136

src/CGB_Registers.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CGB Registers
22

33
This chapter describes only Game Boy Color (GBC or CGB) registers that didn't
4-
fit into normal categories - most CGB registers are described in the
4+
fit into normal categories most CGB registers are described in the
55
chapter about Video Display (Color Palettes, VRAM Bank, VRAM DMA
66
Transfers, and changed meaning of Bit 0 of LCDC Control register). Also,
77
a changed bit is noted in the chapter about the Serial/Link port.
@@ -28,7 +28,7 @@ use "repaired" color palette data matching for GBA displays.
2828

2929
### LCD VRAM DMA Transfers
3030

31-
#### FF51 - HDMA1 (New DMA Source, High) (W), FF52 - HDMA2 (New DMA Source, Low) (W) - CGB Mode Only
31+
#### FF51–FF52 — HDMA1, HDMA2 (CGB Mode only): VRAM DMA source (high, low) \[write-only\]
3232

3333
These two registers specify the address at which the transfer will read
3434
data from. Normally, this should be either in ROM, SRAM or WRAM, thus
@@ -38,13 +38,13 @@ address in VRAM will cause garbage to be copied.
3838

3939
The four lower bits of this address will be ignored and treated as 0.
4040

41-
#### FF53 - HDMA3 (New DMA Destination, High) (W), FF54 - HDMA4 (New DMA Destination, Low) (W) - CGB Mode Only
41+
#### FF53–FF54 — HDMA3, HDMA4 (CGB Mode only): VRAM DMA destination (high, low) \[write-only\]
4242

4343
These two registers specify the address within 8000-9FF0 to which the
4444
data will be copied. Only bits 12-4 are respected; others are ignored.
4545
The four lower bits of this address will be ignored and treated as 0.
4646

47-
#### FF55 - HDMA5 (New DMA Length/Mode/Start) (W) - CGB Mode Only
47+
#### FF55 HDMA5 (CGB Mode only): VRAM DMA length/mode/start
4848

4949
These registers are used to initiate a DMA transfer from ROM or RAM to
5050
VRAM. The Source Start Address may be located at 0000-7FF0 or A000-DFF0,
@@ -58,7 +58,7 @@ specify the Transfer Length (divided by 10h, minus 1), that is, lengths of
5858
10h-800h bytes can be defined by the values 00h-7Fh. The upper bit
5959
indicates the Transfer Mode:
6060

61-
##### Bit 7 = 0 - General Purpose DMA
61+
##### Bit 7 = 0 General-Purpose DMA
6262

6363
When using this transfer method,
6464
all data is transferred at once. The execution of the program is halted
@@ -69,7 +69,7 @@ the Display is disabled, or during VBlank, or (for rather short blocks)
6969
during HBlank. The execution of the program continues when the transfer
7070
has been completed, and FF55 then contains a value of FFh.
7171

72-
##### Bit 7 = 1 - HBlank DMA
72+
##### Bit 7 = 1 HBlank DMA
7373

7474
The HBlank DMA transfers 10h bytes of
7575
data during each HBlank, that is, at LY=0-143, no data is transferred during
@@ -122,7 +122,7 @@ Speed Mode).
122122
The CGB has twice the VRAM of the DMG, but it is banked and either bank
123123
has a different purpose.
124124

125-
#### FF4F - VBK - CGB Mode Only - VRAM Bank (R/W)
125+
#### FF4F VBK (CGB Mode only): VRAM bank
126126

127127
This register can be written to change VRAM banks. Only bit 0
128128
matters, all other bits are ignored.
@@ -137,7 +137,7 @@ corresponding Tile Maps.
137137
Reading from this register will return the number of the currently
138138
loaded VRAM bank in bit 0, and all other bits will be set to 1.
139139

140-
### FF4D - KEY1 - CGB Mode Only - Prepare Speed Switch
140+
### FF4D KEY1 (CGB Mode only): Prepare speed switch
141141

142142
```
143143
Bit 7: Current Speed (0=Normal, 1=Double) (Read Only)
@@ -180,19 +180,19 @@ And the following will keep operating as usual:
180180
The CPU stops for 2050 cycles (= 8200 clocks) after the `stop` instruction is
181181
executed. During this time, the CPU is in a strange state. `DIV` does not tick, so
182182
*some* audio events are not processed. Additionally, VRAM/OAM/... locking is "frozen", yielding
183-
different results depending on the [STAT mode](<#FF41 - STAT (LCD Status) (R/W)>) it's started in:
183+
different results depending on the [STAT mode](<#FF41 STAT: LCD status>) it's started in:
184184

185185
- HBlank / VBlank (Mode 0 / Mode 1): The PPU cannot access any video memory, and produces black pixels
186186
- OAM scan (Mode 2): The PPU can access VRAM just fine, but not OAM, leading to rendering background, but not sprites
187187
- Rendering (Mode 3): The PPU can access everything correctly, and so rendering is not affected
188188

189189
TODO: confirm whether interrupts can occur (just the joypad one?) during the pause, and consequences if so
190190

191-
### FF56 - RP - CGB Mode Only - Infrared Communications Port
191+
### FF56 RP (CGB Mode only): Infrared communications port
192192

193193
This register allows to input and output data through the CGBs built-in
194194
Infrared Port. When reading data, bit 6 and 7 must be set (and obviously
195-
Bit 0 must be cleared - if you don't want to receive your own Game Boy's
195+
Bit 0 must be cleared if you don't want to receive your own Game Boy's
196196
IR signal). After sending or receiving data you should reset the
197197
register to 00h to reduce battery power consumption again.
198198

@@ -210,7 +210,7 @@ ON/OFF pulses (length 10us ON, 17.5us OFF each) instead of a permanent
210210
880us LED ON signal. Even though being generally CGB compatible, the GBA
211211
does not include an infra-red port.
212212

213-
### FF6C - OPRI - CGB Mode Only - Object Priority Mode
213+
### FF6C OPRI (CGB Mode only): Object priority mode
214214

215215
This register serves as a flag for which object priority mode to use. While
216216
the DMG prioritizes objects by x-coordinate, the CGB prioritizes them by
@@ -229,7 +229,7 @@ It is not known if triggering a PSM NMI, which remaps the boot ROM, has an effec
229229
Bit 0: OBJ Priority Mode (0=OAM Priority, 1=Coordinate Priority) (Read/Write)
230230
```
231231

232-
### FF70 - SVBK - CGB Mode Only - WRAM Bank
232+
### FF70 SVBK (CGB Mode only): WRAM bank
233233

234234
In CGB Mode 32 KBytes internal RAM are available. This memory is divided
235235
into 8 banks of 4 KBytes each. Bank 0 is always available in memory at
@@ -249,28 +249,27 @@ unknown (if any). It isn't recommended to use them in your software,
249249
but you could, for example, use them to check if you are running on an
250250
emulator or on DMG hardware.
251251

252-
### FF72 - Bits 0-7 (Read/Write), FF73 - Bits 0-7 (Read/Write)
252+
### FF72–FF73 — Bits 07 (CGB Mode only)
253253

254-
Both of these registers are fully read/write. Their initial value is
255-
$00.
254+
Both of these registers are fully read/write.
255+
Their initial value is $00.
256256

257-
### FF74 - Bits 0-7 (Read/Write) - CGB Mode Only
257+
### FF74 Bits 07 (CGB Mode only)
258258

259-
In CGB mode, this register is fully readable and writable. Its initial
260-
value is $00.
259+
In CGB mode, this register is fully readable and writable.
260+
Its initial value is $00.
261261

262262
Otherwise, this register is read-only, and locked at value $FF.
263263

264-
### FF75 - Bits 4-6 (Read/Write)
264+
### FF75 Bits 46 (CGB Mode only)
265265

266-
Only bits 4, 5 and 6 of this register are read/write enabled. Their
267-
initial value is 0.
266+
Only bits 4, 5 and 6 of this register are read/write enabled.
267+
Their initial value is 0.
268268

269-
### FF76 - PCM12 - PCM amplitudes 1 & 2 (Read Only)
269+
### FF76 PCM12 (CGB Mode only): PCM amplitudes 1 & 2 \[read-only\]
270270

271-
This register is read-only. The low nibble is a copy of sound channel
272-
\#1's PCM amplitude, the high nibble a copy of sound channel \#2's.
271+
The low nibble is a copy of sound channel \#1's PCM amplitude, the high nibble a copy of sound channel \#2's.
273272

274-
### FF77 - PCM34 - PCM amplitudes 3 & 4 (Read Only)
273+
### FF77 PCM34 (CGB Mode only): PCM amplitudes 3 & 4 \[read-only\]
275274

276275
Same, but with channels 3 and 4.

src/Interrupt_Sources.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Interrupt Sources
22

3-
## INT 40 - VBlank Interrupt
3+
## INT $40 VBlank interrupt
44

5-
This interrupt is requested every time the Game Boy enters VBlank ([Mode 1](<#FF41 - STAT (LCD Status) (R/W)>)).
5+
This interrupt is requested every time the Game Boy enters VBlank ([Mode 1](<#FF41 STAT: LCD status>)).
66

77
The VBlank interrupt occurs ca. 59.7 times a second on a handheld Game
88
Boy (DMG or CGB) or Game Boy Player and ca. 61.1 times a second on a
@@ -11,10 +11,10 @@ VBlank period (LY=144). During this period video hardware is not using
1111
VRAM so it may be freely accessed. This period lasts approximately 1.1
1212
milliseconds.
1313

14-
## INT 48 - STAT Interrupt
14+
## INT $48 STAT interrupt
1515

1616
There are various sources which can trigger this interrupt to occur as
17-
described in [STAT register (\$FF41)](<#FF41 - STAT (LCD Status) (R/W)>).
17+
described in [STAT register (\$FF41)](<#FF41 STAT: LCD status>).
1818

1919
The various STAT interrupt sources (modes 0-2 and LYC=LY) have their
2020
state (inactive=low and active=high) logically ORed into a shared
@@ -30,7 +30,7 @@ If a STAT interrupt source logically ORs the interrupt line high while
3030
there will be no low-to-high transition and so no interrupt will occur.
3131
This phenomenon is known as "STAT blocking" ([test ROM example](https://github.com/Gekkio/mooneye-gb/blob/2d52008228557f9e713545e702d5b7aa233d09bb/tests/acceptance/ppu/stat_irq_blocking.s#L21-L22)).
3232

33-
As mentioned in the description of the [STAT register](<#FF41 - STAT (LCD Status) (R/W)>),
33+
As mentioned in the description of the [STAT register](<#FF41 STAT: LCD status>),
3434
the PPU cycles through the different modes in a fixed order. So for
3535
example, if interrupts are enabled for two consecutive modes such as
3636
Mode 0 and Mode 1, then no interrupt will trigger for Mode 1 (since
@@ -50,14 +50,14 @@ the handler disable sprites. This can be used if you use the window for
5050
a text box (at the bottom of the screen), and you want sprites to be
5151
hidden by the text box.
5252

53-
## INT 50 - Timer Interrupt
53+
## INT $50 Timer interrupt
5454

55-
Every time that the timer overflows (that is, when [TIMA](<#FF05 - TIMA - Timer counter (R/W)>) exceeds $FF),
55+
Every time that the timer overflows (that is, when [TIMA](<#FF05 TIMA: Timer counter>) exceeds $FF),
5656
an interrupt is requested by setting bit 2 in the IF register
5757
($FF0F). As soon as that interrupt is enabled, the CPU will execute it by
5858
calling the timer interrupt vector at $0050.
5959

60-
## INT 58 - Serial Interrupt
60+
## INT $58 Serial interrupt
6161

6262
**XXXXXX\...**
6363

@@ -96,15 +96,15 @@ port and a byte to be shifted into \$FF01:
9696
The Game Boy does not support wake-on-LAN. Completion of an externally
9797
clocked serial transfer does not exit STOP mode.
9898

99-
## INT 60 - Joypad Interrupt
99+
## INT $60 Joypad interrupt
100100

101-
The Joypad interrupt is requested when any of [`P1`](<#FF00 - P1/JOYP - Joypad (R/W)>) bits 0-3 change
101+
The Joypad interrupt is requested when any of [`P1`](<#FF00 P1/JOYP: Joypad>) bits 0-3 change
102102
from High to Low. This happens when a button is
103103
pressed (provided that the action/direction buttons are enabled by
104104
bit 5/4, respectively), however, due to switch bounce, one or more High to Low
105105
transitions are usually produced when pressing a button.
106106

107-
### Using the Joypad Interrupt
107+
### Using the joypad interrupt
108108

109109
This interrupt is useful to identify button presses if we have only selected
110110
either action (bit 5) or direction (bit 4), but not both.

src/Interrupts.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Interrupts
22

3-
## IME - Interrupt Master Enable Flag (Write Only)
3+
## IME: Interrupt master enable flag \[write only\]
44

55
```
66
0 - Disable all interrupts
@@ -26,7 +26,7 @@ The effect of `ei` is delayed by one instruction. This means that `ei`
2626
followed immediately by `di` does not allow any interrupts between them.
2727
This interacts with the [`halt` bug](<#halt bug>) in an interesting way.
2828

29-
## FFFF - IE - Interrupt Enable (R/W)
29+
## FFFF IE: Interrupt enable
3030

3131
```
3232
Bit 0: VBlank Interrupt Enable (INT $40) (1=Enable)
@@ -36,7 +36,7 @@ Bit 3: Serial Interrupt Enable (INT $58) (1=Enable)
3636
Bit 4: Joypad Interrupt Enable (INT $60) (1=Enable)
3737
```
3838

39-
## FF0F - IF - Interrupt Flag (R/W)
39+
## FF0F IF: Interrupt flag
4040

4141
```
4242
Bit 0: VBlank Interrupt Request (INT $40) (1=Request)
@@ -66,7 +66,7 @@ unless/until IME and IE allow it.
6666
1. The IF bit corresponding to this interrupt and the IME flag are reset by the CPU.
6767
The former "acknowledges" the interrupt, while the latter prevents any further interrupts
6868
from being handled until the program re-enables them, typically by using the `reti` instruction.
69-
2. The corresponding interrupt handler (see the IE and IF register descriptions [above](<#FFFF - IE - Interrupt Enable (R/W)>)) is
69+
2. The corresponding interrupt handler (see the IE and IF register descriptions [above](<#FFFF IE: Interrupt enable>)) is
7070
called by the CPU. This is a regular call, exactly like what would be performed by a `call <address>` instruction (the current PC is pushed onto the stack
7171
and then set to the address of the interrupt handler).
7272

src/Joypad_Input.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Joypad Input
22

3-
## FF00 - P1/JOYP - Joypad (R/W)
3+
## FF00 P1/JOYP: Joypad
44

55
The eight Game Boy action/direction buttons are arranged as a 2x4
66
matrix. Select either action or direction buttons by writing to this

src/LCDC.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# LCD Control
22

3-
## FF40 - LCDC (LCD Control) (R/W)
3+
## FF40 LCDC: LCD control
44

55
**LCDC** is the main **LCD C**ontrol register. Its bits toggle what
66
elements are displayed on the screen, and how.
@@ -16,7 +16,7 @@ Bit | Name | Usage notes
1616
1 | OBJ enable | 0=Off, 1=On
1717
0 | BG and Window enable/priority | 0=Off, 1=On
1818

19-
### LCDC.7 - LCD enable
19+
### LCDC.7 LCD enable
2020

2121
This bit controls whether the LCD is on and the PPU is active. Setting
2222
it to 0 turns both off, which grants immediate and full access to VRAM,
@@ -42,25 +42,25 @@ picture sticks to the screen. (TODO: research this more.)
4242
When re-enabling the LCD, the PPU will immediately start drawing again,
4343
but the screen will stay blank during the first frame.
4444

45-
### LCDC.6 - Window tile map area
45+
### LCDC.6 Window tile map area
4646

4747
This bit controls which background map the Window uses for rendering.
4848
When it's reset, the \$9800 tilemap is used, otherwise it's the \$9C00
4949
one.
5050

51-
### LCDC.5 - Window enable
51+
### LCDC.5 Window enable
5252

5353
This bit controls whether the window shall be displayed or not.
54-
This bit is overridden on DMG by [bit 0](<#LCDC.0 - BG and Window enable/priority>)
54+
This bit is overridden on DMG by [bit 0](<#LCDC.0 BG and Window enable/priority>)
5555
if that bit is reset.
5656

5757
Changing the value of this register mid-frame triggers a more complex behaviour:
58-
[see further below](<#FF4A - WY (Window Y Position) (R/W), FF4B - WX (Window X Position + 7) (R/W)>).
58+
[see further below](<#FF4A–FF4B — WY, WX: Window Y position, X position plus 7>).
5959

6060
Note that on CGB models, setting this bit to 0 then back to 1 mid-frame
6161
may cause the second write to be ignored. (TODO: test this.)
6262

63-
### LCDC.4 - BG and Window tile data area
63+
### LCDC.4 BG and Window tile data area
6464

6565
This bit controls which [addressing
6666
mode](<#VRAM Tile Data>) the BG and Window use to
@@ -69,21 +69,21 @@ pick tiles.
6969
Sprites aren't affected by this, and will always use \$8000 addressing
7070
mode.
7171

72-
### LCDC.3 - BG tile map area
72+
### LCDC.3 BG tile map area
7373

74-
This bit works similarly to [LCDC bit 6](<#LCDC.6 - Window tile map area>):
74+
This bit works similarly to [LCDC bit 6](<#LCDC.6 Window tile map area>):
7575
if the bit is reset, the BG uses tilemap $9800, otherwise tilemap $9C00.
7676

7777

78-
### LCDC.2 - OBJ size
78+
### LCDC.2 OBJ size
7979

8080
This bit controls the sprite size (1 tile or 2 stacked vertically).
8181

8282
Be cautious when changing this mid-frame from 8x8 to 8x16: "remnants"
8383
of the sprites intended for 8x8 could "leak" into the 8x16 zone and
8484
cause artifacts.
8585

86-
### LCDC.1 - OBJ enable
86+
### LCDC.1 OBJ enable
8787

8888
This bit toggles whether sprites are displayed or not.
8989

@@ -93,18 +93,18 @@ displayed on top of a status bar or text box.
9393
(Note: toggling mid-scanline might have funky results on DMG?
9494
Investigation needed.)
9595

96-
### LCDC.0 - BG and Window enable/priority
96+
### LCDC.0 BG and Window enable/priority
9797

9898
LCDC.0 has different meanings depending on Game Boy type and Mode:
9999

100-
#### Non-CGB Mode (DMG, SGB and CGB in compatibility mode): BG and Window Display
100+
#### Non-CGB Mode (DMG, SGB and CGB in compatibility mode): BG and Window display
101101

102102
When Bit 0 is cleared, both background and window become blank (white),
103-
and the [Window Display Bit](<#LCDC.5 - Window enable>)
103+
and the [Window Display Bit](<#LCDC.5 Window enable>)
104104
is ignored in that case. Only Sprites may still be displayed (if enabled
105105
in Bit 1).
106106

107-
#### CGB Mode: BG and Window Master Priority
107+
#### CGB Mode: BG and Window master priority
108108

109109
When Bit 0 is cleared, the background and window lose their priority -
110110
the sprites will be always displayed on top of background and window,

src/M161.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ Since 4th output pin will be high, the signal cannot become low anymore, thus pr
1919

2020
## Memory
2121

22-
### 0000-7FFF - ROM Bank $00-$07 (Read Only)
22+
### 0000-7FFF ROM Bank $00-$07 \[read only\]
2323

2424
This area contains a 32 KiB bank of ROM.
2525
On startup, this will contain the first 32 KiB of ROM (bank 0).
2626

2727
## Registers
2828

29-
### 0000-7FFF - ROM Bank Number (Write Only)
29+
### 0000-7FFF ROM Bank Number \[write only\]
3030

3131
This 3-bit register (range $00-$07) selects the ROM bank number for the $0000-$7FFF region.
3232
Like other mappers, the high bits are discarded.
@@ -36,7 +36,7 @@ Only 1 bankswitch is allowed per session, once any write to this register occurs
3636
## Operation Notes
3737

3838
Because the full 32 KiB range is switched over, caution should be taken, as the entire ROM range will change.
39-
It may be best to have the bankswitch code placed right before $0100, so as to fall through to [the game's init sequence](<#0100-0103 - Entry Point>).
39+
It may be best to have the bankswitch code placed right before $0100, so as to fall through to [the game's init sequence](<#0100-0103 Entry point>).
4040

4141
### References
4242

0 commit comments

Comments
 (0)