Skip to content

Commit cb2d310

Browse files
tobiasvlavivaceISSOtm
authored
Make hexadecimal numbers follow the style guide (#473)
* Make hexadecimal numbers follow the style guide * Add link to joypad register --------- Co-authored-by: Antonio Vivace <[email protected]> Co-authored-by: Eldred Habert <[email protected]>
1 parent 4814bb2 commit cb2d310

17 files changed

+86
-87
lines changed

src/CGB_Registers.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ a changed bit is noted in the chapter about the Serial/Link port.
99
## Unlocking CGB functions
1010

1111
When using any CGB registers (including those in the Video/Link
12-
chapters), you must first unlock CGB features by changing byte 0143h in
13-
the cartridge header. Typically, use a value of 80h for games which
14-
support both CGB and monochrome Game Boy systems, and C0h for games which work
12+
chapters), you must first unlock CGB features by changing byte 0143 in
13+
the cartridge header. Typically, use a value of $80 for games which
14+
support both CGB and monochrome Game Boy systems, and $C0 for games which work
1515
on CGBs only. Otherwise, the CGB will operate in monochrome "Non CGB"
1616
compatibility mode.
1717

1818
## Detecting CGB (and GBA) functions
1919

2020
CGB hardware can be detected by examining the CPU accumulator (A-register)
21-
directly after startup. A value of 11h indicates CGB (or GBA) hardware,
22-
if so, CGB functions can be used (if unlocked, see above). When A=11h,
21+
directly after startup. A value of $11 indicates CGB (or GBA) hardware,
22+
if so, CGB functions can be used (if unlocked, see above). When A=$11,
2323
you may also examine Bit 0 of the CPUs B-Register to separate between
2424
CGB (bit cleared) and GBA (bit set), by that detection it is possible to
2525
use "repaired" color palette data matching for GBA displays.
@@ -54,8 +54,8 @@ bits of the address are ignored (treated as zero), the upper 3 bits are
5454
ignored either (destination is always in VRAM).
5555

5656
Writing to this register starts the transfer, the lower 7 bits of which
57-
specify the Transfer Length (divided by 10h, minus 1), that is, lengths of
58-
10h-800h bytes can be defined by the values 00h-7Fh. The upper bit
57+
specify the Transfer Length (divided by $10, minus 1), that is, lengths of
58+
$10-$800 bytes can be defined by the values $00-$7F. The upper bit
5959
indicates the Transfer Mode:
6060

6161
##### Bit 7 = 0 — General-Purpose DMA
@@ -67,11 +67,11 @@ blindly attempts to copy the data, even if the LCD controller is
6767
currently accessing VRAM. So General Purpose DMA should be used only if
6868
the Display is disabled, or during VBlank, or (for rather short blocks)
6969
during HBlank. The execution of the program continues when the transfer
70-
has been completed, and FF55 then contains a value of FFh.
70+
has been completed, and FF55 then contains a value of $FF.
7171

7272
##### Bit 7 = 1 — HBlank DMA
7373

74-
The HBlank DMA transfers 10h bytes of
74+
The HBlank DMA transfers $10 bytes of
7575
data during each HBlank, that is, at LY=0-143, no data is transferred during
7676
VBlank (LY=144-153), but the transfer will then continue at LY=00. The
7777
execution of the program is halted during the separate transfers, but
@@ -81,8 +81,8 @@ block. Note that the program should not change the Destination VRAM bank
8181
bankable memory) until the transfer has completed! (The transfer should
8282
be paused as described below while the banks are switched)
8383

84-
Reading from Register FF55 returns the remaining length (divided by 10h,
85-
minus 1), a value of 0FFh indicates that the transfer has completed. It
84+
Reading from Register FF55 returns the remaining length (divided by $10,
85+
minus 1), a value of $FF indicates that the transfer has completed. It
8686
is also possible to terminate an active HBlank transfer by writing zero
8787
to Bit 7 of FF55. In that case reading from FF55 will return how many
8888
\$10 "blocks" remained (minus 1) in the lower 7 bits, but Bit 7 will
@@ -194,7 +194,7 @@ 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
195195
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
197-
register to 00h to reduce battery power consumption again.
197+
register to $00 to reduce battery power consumption again.
198198

199199
```
200200
Bit 0: Write Data (0=LED Off, 1=LED On) (Read/Write)
@@ -239,7 +239,7 @@ C000-CFFF, Bank 1-7 can be selected into the address space at D000-DFFF.
239239
Bit 0-2 Select WRAM Bank (Read/Write)
240240
```
241241

242-
Writing a value of 01h-07h will select Bank 1-7, writing a value of 00h
242+
Writing a value of $01-$07 will select Bank 1-7, writing a value of $00
243243
will select Bank 1 too.
244244

245245
## Undocumented registers

src/Gameboy_Camera.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ This area may contain any ROM bank (0 included). The initial mapped bank is 01.
3838

3939
### A000-BFFF - CAM Registers (Read/Write)
4040

41-
Depending on the current RAM Bank Number, this memory space is used to access the cartridge RAM or the CAM registers. RAM can only be read if the capture unit is not working, it returns 00h otherwise.
41+
Depending on the current RAM Bank Number, this memory space is used to access the cartridge RAM or the CAM registers. RAM can only be read if the capture unit is not working, it returns $00 otherwise.
4242

4343
### 0000-1FFF - RAM Enable (Write Only)
4444

45-
A value of 0Ah will enable writing to RAM, 00h will disable it. Reading from RAM or registers is always enabled. Writing to registers is always enabled. Disabled on reset.
45+
A value of $0A will enable writing to RAM, $00 will disable it. Reading from RAM or registers is always enabled. Writing to registers is always enabled. Disabled on reset.
4646

4747
### 2000-3FFF - ROM Bank Number (Write Only)
4848

49-
Writing a value of 00-3Fh selects the corresponding ROM Bank for area 4000-7FFF.
49+
Writing a value of $00-$3F selects the corresponding ROM Bank for area 4000-7FFF.
5050

5151
### 4000-5FFF - RAM Bank Number/CAM Registers Select (Write Only)
5252

53-
Writing a value in range for 00h-0Fh maps the corresponding external RAM Bank to memory at A000-BFFF. Writing any value with bit 4 set to '1' will select CAM registers. Usually bank 10h is used to select the registers. All registers are mirrored every 80h bytes. RAM bank 0 selected on reset.
53+
Writing a value in range for $00-$0F maps the corresponding external RAM Bank to memory at A000-BFFF. Writing any value with bit 4 set to '1' will select CAM registers. Usually bank $10 is used to select the registers. All registers are mirrored every $80 bytes. RAM bank 0 selected on reset.
5454

5555
::: tip NOTE
5656

@@ -60,20 +60,20 @@ Unlike most games, the GB Camera RAM can only be written when PHI pin = '1'. It'
6060

6161
## I/O Registers
6262

63-
The Game Boy Camera I/O registers are mapped to all banks with bit 4 set to '1'. The GB Camera ROM usually changes to bank 16 (10h) to use the registers.
63+
The Game Boy Camera I/O registers are mapped to all banks with bit 4 set to '1'. The GB Camera ROM usually changes to bank 16 ($10) to use the registers.
6464

6565
There are 3 groups of registers:
6666
- The first group is composed by the trigger register A000. This register starts the capture process and returns the current status (working/capture finished).
6767
- The second group is composed by registers A001-A005, used to configure most parameters of the M64282FP sensor.
6868
- The third group is composed by 48 registers that form a 4×4 matrix. Each element of the matrix is formed by 3 bytes. This matrix is used by the controller for contrast and dithering.
6969

70-
All registers are write-only, except the register A000. The others return 00h when read. The initial values of all registers on reset is 00h.
70+
All registers are write-only, except the register A000. The others return $00 when read. The initial values of all registers on reset is $00.
7171

7272
### Register A000
7373

7474
The lower 3 bits of this register can be read and write. The other bits return '0'. Writing any value with bit 0 set to '1' will start the capturing process. Any write with bit 0 set to '0' is a normal write and won't trigger the capture. The value of bits 1 and 2 affects the value written to registers 4, 5 and 6 of the M64282FP, which are used in 1-D filtering mode (effects described in following chapters).
7575
Bit 0 of this register is also used to verify if the capturing process is finished. It returns '1' when the hardware is working and '0' if the capturing process is over.
76-
When the capture process is active all RAM banks will return 00h when read (and writes are ignored), but the register A000 can still be read to know when the transfer is finished.
76+
When the capture process is active all RAM banks will return $00 when read (and writes are ignored), but the register A000 can still be read to know when the transfer is finished.
7777
The capturing process can be stopped by writing a '0' to bit 0. When a '1' is written again it will continue the previous capture process with the old capture parameters, even if the registers are changed in between. If the process is stopped RAM can be read again.
7878

7979
### Register A001

src/MBC1.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ External RAM is often battery-backed, allowing for the storage of game data whil
4141

4242
## Registers
4343

44-
All of the MBC1 registers default to 00h on power-up, which for the "ROM Bank Number" register is _treated as_ 01h.
44+
All of the MBC1 registers default to $00 on power-up, which for the "ROM Bank Number" register is _treated as_ $01.
4545

4646
### 0000–1FFF — RAM Enable (Write Only)
4747

@@ -82,7 +82,7 @@ effective bank number:
8282

8383
[^MBC1M_banking]: MBC1M has a different formula, see below
8484

85-
These additional two bits are ignored for the bank 00→01 translation. This causes a problem — attempting to access banks 20h, 40h, and 60h only set bits in the upper 2-bit register, with the lower 5-bit register set to 00. As a result, any
85+
These additional two bits are ignored for the bank 00→01 translation. This causes a problem — attempting to access banks $20, $40, and $60 only set bits in the upper 2-bit register, with the lower 5-bit register set to 00. As a result, any
8686
attempt to address these ROM Banks will select Bank $21, $41 and $61
8787
instead. The only way to access banks $20, $40 or $60 at all is to enter mode 1,
8888
which remaps the 0000–3FFF range. This has its own problems for game

src/MBC3.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Contains the first 16 KiB of the ROM.
1515

1616
### 4000-7FFF - ROM Bank 01-7F (Read Only)
1717

18-
Same as for MBC1, except that accessing banks 20h, 40h, and 60h is
18+
Same as for MBC1, except that accessing banks $20, $40, and $60 is
1919
supported now.
2020

2121
### A000-BFFF - RAM Bank 00-03, if any (Read/Write)
@@ -34,42 +34,42 @@ single RTC Register.
3434

3535
### 0000-1FFF - RAM and Timer Enable (Write Only)
3636

37-
Mostly the same as for MBC1, a value of 0Ah will enable reading and
38-
writing to external RAM - and to the RTC Registers! A value of 00h will
37+
Mostly the same as for MBC1, a value of $0A will enable reading and
38+
writing to external RAM - and to the RTC Registers! A value of $00 will
3939
disable either.
4040

4141
### 2000-3FFF - ROM Bank Number (Write Only)
4242

4343
Same as for MBC1, except that the whole 7 bits of the ROM Bank Number
4444
are written directly to this address. As for the MBC1, writing a value
45-
of 00h will select Bank 01h instead. All other values 01-7Fh select the
45+
of $00 will select Bank $01 instead. All other values $01-$7F select the
4646
corresponding ROM Banks.
4747

4848
### 4000-5FFF - RAM Bank Number - or - RTC Register Select (Write Only)
4949

50-
As for the MBC1s RAM Banking Mode, writing a value in range for 00h-03h
50+
As for the MBC1s RAM Banking Mode, writing a value in range for $00-$03
5151
maps the corresponding external RAM Bank (if any) into memory at
52-
A000-BFFF. When writing a value of 08h-0Ch, this will map the
52+
A000-BFFF. When writing a value of $08-$0C, this will map the
5353
corresponding RTC register into memory at A000-BFFF. That register could
5454
then be read/written by accessing any address in that area, typically
5555
that is done by using address A000.
5656

5757
### 6000-7FFF - Latch Clock Data (Write Only)
5858

59-
When writing 00h, and then 01h to this register, the current time
59+
When writing $00, and then $01 to this register, the current time
6060
becomes latched into the RTC registers. The latched data will not change
61-
until it becomes latched again, by repeating the write 00h-\>01h
61+
until it becomes latched again, by repeating the write $00-\>$01
6262
procedure. This provides a way to read the RTC registers while the
6363
clock keeps ticking.
6464

6565
### The Clock Counter Registers
6666

6767
```
68-
08h RTC S Seconds 0-59 (0-3Bh)
69-
09h RTC M Minutes 0-59 (0-3Bh)
70-
0Ah RTC H Hours 0-23 (0-17h)
71-
0Bh RTC DL Lower 8 bits of Day Counter (0-FFh)
72-
0Ch RTC DH Upper 1 bit of Day Counter, Carry Bit, Halt Flag
68+
$08 RTC S Seconds 0-59 ($00-$3B)
69+
$09 RTC M Minutes 0-59 ($00-$3B)
70+
$0A RTC H Hours 0-23 ($00-$17)
71+
$0B RTC DL Lower 8 bits of Day Counter ($00-$FF)
72+
$0C RTC DH Upper 1 bit of Day Counter, Carry Bit, Halt Flag
7373
Bit 0 Most significant bit of Day Counter (Bit 8)
7474
Bit 6 Halt (0=Active, 1=Stop Timer)
7575
Bit 7 Day Counter Carry Bit (1=Counter Overflow)
@@ -81,7 +81,7 @@ Registers.
8181
### The Day Counter
8282

8383
The total 9 bits of the Day Counter allow counting days in range from
84-
0-511 (0-1FFh). The Day Counter Carry Bit becomes set when this value
84+
0-511 ($000-$1FF). The Day Counter Carry Bit becomes set when this value
8585
overflows. In that case the Carry Bit remains set until the program does
8686
reset it. Note that you can store an offset to the Day Counter in
8787
battery RAM. For example, every time you read a non-zero Day Counter,

src/MBC6.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Bank A.
4141

4242
### 0000-03FF — RAM Enable (Write Only)
4343

44-
Mostly the same as for MBC1, a value of 0Ah will enable reading and
45-
writing to external RAM. A value of 00h will disable it.
44+
Mostly the same as for MBC1, a value of $0A will enable reading and
45+
writing to external RAM. A value of $00 will disable it.
4646

4747
### 0400-07FF — RAM Bank A Number (Write Only)
4848

src/MBC7.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ Same as for MBC5. (Bank 0 mapping needs confirmation)
2323
### A000-AFFF - RAM Registers (Read/Write)
2424

2525
Must be enabled via 0000 and 4000 region writes (see respective
26-
sections), otherwise reads read FFh and writes do nothing. Registers are
26+
sections), otherwise reads read $FF and writes do nothing. Registers are
2727
addressed through bits 4-7 of the address. Bits 0-3 and 8-11 are
2828
ignored.
2929

3030
Accelerometer data must be latched before reading. Data is 16-bit and
3131
centered at the value 81D0. Earth\'s gravity affects the value by
32-
roughly 70h, with larger acceleration providing a larger range. Maximum
32+
roughly $70, with larger acceleration providing a larger range. Maximum
3333
range is unknown.
3434

3535
### Ax0x/Ax1x - Latch Accelerometer (Write Only)
3636

37-
Write 55h to Ax0x to erase the latched data (reset back to 8000) then
38-
AAh to Ax1x to latch the accelerometer and update the addressable
39-
registers. Reads return FFh. Other writes do not appear to do anything
37+
Write $55 to Ax0x to erase the latched data (reset back to 8000) then
38+
$AA to Ax1x to latch the accelerometer and update the addressable
39+
registers. Reads return $FF. Other writes do not appear to do anything
4040
(Partially unconfirmed). Note that you cannot re-latch the accelerometer
4141
value without first erasing it; attempts to do so yield no change.
4242

@@ -54,7 +54,7 @@ high byte. Reads 8000 before first latching.
5454

5555
### Ax6x/Ax7x - Unknown
5656

57-
Ax6x always reads 00h and Ax7x always reads FFh. Possibly reserved for Z
57+
Ax6x always reads $00 and Ax7x always reads $FF. Possibly reserved for Z
5858
axis, which does not exist on this accelerometer.
5959

6060
### Ax8x - EEPROM (Read/Write)
@@ -74,11 +74,11 @@ manually clocking CLK. All commands must be preceded by a 1 bit, and
7474
existing games precede the 1 bit with a 0 bit (though this is not
7575
necessary):
7676

77-
- Write 00h (lower CS)
78-
- Write 80h (raise CS)
79-
- Write C0h (shift in 0 bit)
80-
- Write 82h (lower CS, raise DI)
81-
- Write C2h (shift in 1 bit)
77+
- Write $00 (lower CS)
78+
- Write $80 (raise CS)
79+
- Write $C0 (shift in 0 bit)
80+
- Write $82 (lower CS, raise DI)
81+
- Write $C2 (shift in 1 bit)
8282
- Write command
8383

8484
The following commands exist, each 10 bits (excluding data shifted in or
@@ -108,16 +108,16 @@ Datasheet:
108108

109109
### Ax9x-AxFx - Unused
110110

111-
Reads out FFh.
111+
Reads out $FF.
112112

113113
### B000-BFFF - Unknown
114114

115-
Only seems to read out FFh.
115+
Only seems to read out $FF.
116116

117117
### 0000-1FFF - RAM Enable 1 (Write Only)
118118

119-
Mostly the same as for MBC1, a value of 0Ah will enable reading and
120-
writing to RAM registers. A value of 00h will disable it. Please note
119+
Mostly the same as for MBC1, a value of $0A will enable reading and
120+
writing to RAM registers. A value of $00 will disable it. Please note
121121
that the RAM must second be enabled in the second RAM enable section as
122122
well (4000-5FFF)
123123

@@ -127,7 +127,7 @@ The ROM bank number goes here.
127127

128128
### 4000-5FFF - RAM Enable 2 (Write Only)
129129

130-
Writing 40h to this region enables access to the RAM registers. Writing
130+
Writing $40 to this region enables access to the RAM registers. Writing
131131
any other value appears to disable access to RAM, but this is not fully
132132
tested. Please note that the RAM must first be enabled in the first RAM
133133
enable section as well (0000-1FFF)

src/MMM01.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Bits: X 6 5 4 3 2 1 0
160160

161161
#### Bits 0-3: RAM Enable
162162

163-
As per MBC1, writing $Ah to the lower 4 bits enables the external RAM, and any other value disables it.
163+
As per MBC1, writing $A to the lower 4 bits enables the external RAM, and any other value disables it.
164164
The external RAM is automatically disabled when the Game Boy is powered off or the cartridge is removed.
165165

166166
#### Bits 4-5: RAM Bank Mask

src/Reducing_Power_Consumption.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ buttons you want to terminate the STOP on).
8989
## Disabling the Sound Controller
9090

9191
If your program doesn't use sound at all (or during some periods) then
92-
write 00h to register FF26 to save 16% or more on GB power consumption.
93-
Sound can be turned back on by writing 80h to the same register, all
92+
write $00 to register FF26 to save 16% or more on GB power consumption.
93+
Sound can be turned back on by writing $80 to the same register, all
9494
sound registers must be then re-initialized. When the Game Boy is turned
9595
on, sound is enabled by default, and must be turned off manually when
9696
not used.

src/SGB_Color_Palettes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ relationship between Game Boy colors 0-3 and SNES colors 0-3.
5353
### Using Game Boy BGP/OBP Registers
5454

5555
A direct translation of GB color 0-3 into SNES color 0-3 may be produced
56-
by setting BGP/OBPx registers to a value of 0E4h each. However, in case
56+
by setting BGP/OBPx registers to a value of $0E4 each. However, in case
5757
that your program uses black background for example, then you may
5858
internally assign background as "White" at the Game Boy side by BGP/OBP
5959
registers (which is then interpreted as SNES color 0, which is shared

src/SGB_Command_Attribute.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ more rectangular screen regions.
88
```
99
Byte Content
1010
0 Command*8+Length (length=1..7)
11-
1 Number of Data Sets (01h..12h)
11+
1 Number of Data Sets ($01..$12)
1212
2-7 Data Set #1
1313
Byte 0 - Control Code (0-7)
1414
Bit 0 - Change Colors inside of surrounded area (1=Yes)
@@ -43,7 +43,7 @@ character lines.
4343
```
4444
Byte Content
4545
0 Command*8+Length (length=1..7)
46-
1 Number of Data Sets (01h..6Eh) (one byte each)
46+
1 Number of Data Sets ($01..$6E) (one byte each)
4747
2 Data Set #1
4848
Bit 0-4 - Line Number (X- or Y-coordinate, depending on bit 7)
4949
Bit 5-6 - Palette Number (0-3)
@@ -135,7 +135,7 @@ Used to transfer attributes from Attribute File (ATF) to Game Boy window.
135135
```
136136
Byte Content
137137
0 Command*8+Length (fixed length=1)
138-
1 Attribute File Number (00-2Ch), Bit 6=Cancel Mask
138+
1 Attribute File Number ($00-$2C), Bit 6=Cancel Mask
139139
2-F Not used (zero)
140140
```
141141

0 commit comments

Comments
 (0)