Skip to content

Commit 305284c

Browse files
committed
First big wave of style enforcements and typo fixes (#414)
1 parent b006ea1 commit 305284c

12 files changed

+43
-47
lines changed

src/CGB_Registers.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ a changed bit is noted in the chapter about the Serial/Link port.
1010

1111
When using any CGB registers (including those in the Video/Link
1212
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
13+
the cartridge header. Typically, use a value of 80h for games which
1414
support both CGB and monochrome Game Boy systems, and C0h 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

20-
CGB hardware can be detected by examing the CPU accumulator (A-register)
20+
CGB hardware can be detected by examining the CPU accumulator (A-register)
2121
directly after startup. A value of 11h indicates CGB (or GBA) hardware,
2222
if so, CGB functions can be used (if unlocked, see above). When A=11h,
2323
you may also examine Bit 0 of the CPUs B-Register to separate between
@@ -124,7 +124,7 @@ has a different purpose.
124124

125125
#### FF4F - VBK - CGB Mode Only - VRAM Bank (R/W)
126126

127-
This register can be written to to change VRAM banks. Only bit 0
127+
This register can be written to change VRAM banks. Only bit 0
128128
matters, all other bits are ignored.
129129

130130
#### VRAM bank 1
@@ -149,7 +149,7 @@ Double Speed Mode and Normal Speed Mode. The actual speed switch is
149149
performed by executing a `stop` instruction after Bit 0 has been set. After
150150
that, Bit 0 will be cleared automatically, and the Game Boy will operate
151151
at the "other" speed. The recommended speed switching procedure in
152-
pseudo code would be:
152+
pseudocode would be:
153153

154154
```
155155
IF KEY1_BIT7 != DESIRED_SPEED THEN
@@ -182,7 +182,7 @@ executed. During this time, the CPU is in a strange state. `DIV` does not tick,
182182
*some* audio events are not processed. Additionally, VRAM/OAM/... locking is "frozen", yielding
183183
different results depending on the [STAT mode](<#FF41 - STAT (LCD Status) (R/W)>) it's started in:
184184

185-
- HBlank / VBlank (Mode 0 / Mode 1): The PPU cannot access any videomemory, and produces black pixels
185+
- 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

@@ -274,4 +274,3 @@ This register is read-only. The low nibble is a copy of sound channel
274274
### FF77 - PCM34 - PCM amplitudes 3 & 4 (Read Only)
275275

276276
Same, but with channels 3 and 4.
277-

src/Four_Player_Adapter.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Byte | Value | Description
3737

3838
3 "STAT" bytes are sent indicating the current connection status of the other
3939
Game Boys. Each byte is usually the same, however, sometimes the status can
40-
change mid-way through a ping, typically on STAT2 or STAT3. Each STAT byte
40+
change midway through a ping, typically on STAT2 or STAT3. Each STAT byte
4141
looks like such:
4242

4343
Bit | Name
@@ -74,7 +74,7 @@ Packet | Description
7474

7575
It's possible to have situations where some players are connected but others
7676
are not; the gaps don't matter. For example, Player 1 and Player 4 can be
77-
connected, while Player 2 and Player 3 can be disconnected (or non-existant,
77+
connected, while Player 2 and Player 3 can be disconnected (or non-existent,
7878
same thing); most games do not care so long as Player 1 is active, as that
7979
Game Boy acts as master and orchestrates the multiplayer session from a
8080
software point of view. Because of the way the DMG-07 hardcodes player IDs
@@ -99,7 +99,7 @@ STAT3 <--> (SIZE) = Packet Size
9999
```
100100

101101
The new clock rate is only applied when entering the transmission phase; the
102-
ping phase runs at a constant 2048 bits-per-second. The formula for the ne
102+
ping phase runs at a constant 2048 bits-per-second. The formula for the new
103103
clock rate is as follows:
104104

105105
```

src/GBC_Approval_Process.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
Game Boy Color hardware applies automatic colorization to monochrome
44
games, with one 4-color palette for backgrounds and two 3-color
5-
palettes for sprites. Because of past underuse of Super Game Boy
5+
palettes for sprites. Because of past under utilization of Super Game Boy
66
features even in first-party games (as explained in an article by
77
Christine Love), Nintendo required Game Boy Color games to appear
8-
more colorful than this automatic colorization. Thus Nintendo
8+
more colorful than this automatic colorization. Thus, Nintendo
99
required publishers to keep Nintendo in the loop at three points in
1010
development. The Mario Club division evaluated games on whether
1111
color was being used appropriately. Some things Mario Club looked at

src/Gameboy_Camera.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ U1 | MAC-GBD Nintendo 9807 SA | I/O, memory control. |
1818
U2 | GBD-PCAX-0 F M538011-E - 08 8145507 | 1MB ROM |
1919
U3 | 52CV1000SF85LL SHARP JAPAN 9805 5 0A | 128KB RAM |
2020

21-
The U1 is the only one connected to the GB cartridge pins (besides some of the address pins of the ROM IC). The U2 and U3 (ROM and RAM) are connected to U1. The M64282FP "retina" chip is in a separate PCB, and is connected to the U1.
21+
The U1 is the only one connected to the GB cartridge pins (besides some address pins of the ROM IC). The U2 and U3 (ROM and RAM) are connected to U1. The M64282FP "retina" chip is in a separate PCB, and is connected to the U1.
2222
The M64282FP handles most of the configuration of the capturing process. The U1 transforms the commands from the Game Boy CPU into the correct signals needed for the M64282FP. The detailed timings are described below.
2323
It is a good idea to have the datasheet of the M64282FP, but it is very poorly explained, so this document will try to explain everything about it (except from limits like voltage or signal timings). There are datasheets of similar sensors (M64283FP and M64285FP) that can be very useful to understand some things about the sensor of the GB Camera.
2424

@@ -54,7 +54,7 @@ Writing a value in range for 00h-0Fh maps the corresponding external RAM Bank to
5454

5555
::: tip NOTE
5656

57-
Unlike most games, the GB Camera RAM can only be written when PHI pin = '1'. It's an enable signal for the RAM chip. Most cartridge readers and writers can't handle PHI pin so they can't restore a saved backup. It isn't needed to change ROM banks.
57+
Unlike most games, the GB Camera RAM can only be written when PHI pin = '1'. It's an enable signal for the RAM chip. Most cartridge readers and writers can't handle PHI pin, so they can't restore a saved backup. It isn't needed to change ROM banks.
5858

5959
:::
6060

@@ -82,15 +82,15 @@ This register is mapped to register 1 of M64282FP. It controls the output gain a
8282

8383
### Register A002, A003
8484

85-
This registers are mapped to registers 2 and 3 of M64282FP. They control the exposure time. Register 2 is the MSB, register 3 is the LSB.
85+
These registers are mapped to registers 2 and 3 of M64282FP. They control the exposure time. Register 2 is the MSB, register 3 is the LSB.
8686

8787
```
8888
u16 exposure_steps = [A003] | ([A002]<<8);
8989
```
9090

9191
### Register A004
9292

93-
This register is mapped to register 7 of M64282FP. It sets the output voltage reference, the edge enhancement ratio and it can invert the image.
93+
This register is mapped to register 7 of M64282FP. It sets the output voltage reference, the edge enhancement ratio, and it can invert the image.
9494

9595
### Register A005
9696

@@ -174,7 +174,7 @@ Those registers form a 4×4 matrix with 3 bytes per element. They handle ditheri
174174

175175
## Sample code for emulators
176176

177-
The following code is used to convert a greyscale image to the Game Boy Camera format. GB_CameraTakePicture() should be called when bit 0 of A000 register is st to '1'. The emulator should wait CAM_CLOCKS_LEFT until the bit 0 is cleared. The gain and level control are not needed to emulate the Game Boy Camera because webcams do that automatically. In fact, trying to emulate that will probably break the image. The code is not very clean because it has been extracted from [GiiBiiAdvance](https://github.com/AntonioND/giibiiadvance), but it seems to handle all used configurations of edge handling.
177+
The following code is used to convert a greyscale image to the Game Boy Camera format. `GB_CameraTakePicture()` should be called when bit 0 of A000 register is st to '1'. The emulator should wait CAM_CLOCKS_LEFT until the bit 0 is cleared. The gain and level control are not needed to emulate the Game Boy Camera because webcams do that automatically. In fact, trying to emulate that will probably break the image. The code is not very clean because it has been extracted from [GiiBiiAdvance](https://github.com/AntonioND/giibiiadvance), but it seems to handle all used configurations of edge handling.
178178

179179
Note that the actual Game Boy Camera sensor is affected by infrared so the emulation can't be perfect anyway. A good way of converting a RGB image into grayscale is to do:
180180

src/Gameboy_Printer.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ byte.
8282

8383
#### Status byte
8484

85-
A nonzero value for the higher nibble indicates something went wrong.
85+
A non-zero value for the higher nibble indicates something went wrong.
8686

8787
Bit \# | Name | Description
8888
-------|---------------------|---------------
@@ -133,4 +133,3 @@ Some sort of RLE? The GB Camera doesn't use it.
133133

134134
([Details and pictures](http://furrtek.free.fr/?a=gbprinter&i=2), need
135135
to be copied here)
136-

src/IR.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
The Game Boy Color came with an infrared port on the very top of the handheld. Previously, where IR communications had to be done with special cartridges (like the HuC-1 variants), the Game Boy itself now had the hardware built-in. Unfortunately, the feature was never popular outside of a few games and accessories. The IR port essentially sends out signals and is also capable of receiving them, allowing for fast, wireless, line-of-sight transmission.
66

77
- GBC comes with one IR port. Capable of sending and receiving an IR signal (two separate diodes).
8-
- Turning on the IR light does drain battery, hence not recommended to leave it on when not in use
8+
- Turning on the IR light does drain battery, hence not recommended leaving it on when not in use
99
- IR port can communicate with non-GBC devices, e.g. anything that sends an IR signal (TV remotes, Wiimotes, household lamps, etc)
1010

1111
## Communication Types
@@ -19,9 +19,9 @@ While a number of games may use similar formats for their IR communications, the
1919

2020
## Communication Protocol
2121

22-
Again, there is no set or established infrared protocol that games must follow. Many games vary in their approach. For example, the 2nd Generation Pokemon games use the GBC's hardware timers, while others have hardcoded values that count cycles to check timing. The simplest form is a barebones communication protocol, i.e. something like a binary Morse code where a "0" is a long ON-OFF pulse and "1" is a short ON-OFF pulse or vice versa. Properly done, data could have been short, compact, and easily converted into bytes in RAM. Sakura Taisen GB seems to follow this model in its communications with the Pocket Sakura. Not all games do this, however, and appear to be doing who knows that, opting instead for customized and specialized communications unique to each title. To illustrate this idea, it would be possible to use a table of given lengths of IR ON-OFF pulses so that individual bytes could be sent all at once instead of in a binary, bit-by-bit manner. A number of games try to send a few pulses when pressing input like the A button and wait for another GBC to echo that in response, but after the handshake, most of the IR pulses are impossible to understand without disassembling the code.
22+
Again, there is no set or established infrared protocol that games must follow. Many games vary in their approach. For example, the 2nd Generation Pokemon games use the GBC's hardware timers, while others have hardcoded values that count cycles to check timing. The simplest form is a bare-bones communication protocol, i.e. something like a binary Morse code where a "0" is a long ON-OFF pulse and "1" is a short ON-OFF pulse or vice versa. Properly done, data could have been short, compact, and easily converted into bytes in RAM. Sakura Taisen GB seems to follow this model in its communications with the Pocket Sakura. Not all games do this, however, and appear to be doing who knows that, opting instead for customized and specialized communications unique to each title. To illustrate this idea, it would be possible to use a table of given lengths of IR ON-OFF pulses so that individual bytes could be sent all at once instead of in a binary, bit-by-bit manner. A number of games try to send a few pulses when pressing input like the A button and wait for another GBC to echo that in response, but after the handshake, most of the IR pulses are impossible to understand without disassembling the code.
2323

24-
One thing to note is that 4 games in particular do share somewhat similar IR protocols, at least in regards to the initial handshake between 2 GBCs. They are Pokemon TCG 1 & 2 and Bombermax Red & Blue, all from the "2-Player Init" category above. Typically, IR capable GBC games will continually wait for an IR signal on both sides, i.e. the "1-Player Init" category. When one player presses certain input, that GBC takes the initiative and sends out a few IR pulses. That is to say, for most IR games, it only takes *just one* player to start the entire process.
24+
One thing to note is that 4 games in particular do share somewhat similar IR protocols, at least regarding the initial handshake between 2 GBCs. They are Pokemon TCG 1 & 2 and Bombermax Red & Blue, all from the "2-Player Init" category above. Typically, IR capable GBC games will continually wait for an IR signal on both sides, i.e. the "1-Player Init" category. When one player presses certain input, that GBC takes the initiative and sends out a few IR pulses. That is to say, for most IR games, it only takes *just one* player to start the entire process.
2525

2626
The handshake for the 4 games previously mentioned, however, requires *both* players to input at almost the same time. One has to be slightly faster or slower than the other. Each side continually sends a few IR pulses, then reads the sensor to see if anything was received. If so, the GBCs begin to sync. The idea is that one side should be sending while the other is checking, and then the handshake completes. This is why one side needs to be faster or slower to input; if they are sending IR signals at the same time, they don't see anything when reading the sensor. As a result, both GBCs cannot input at exactly the same time. Practically speaking, this is unlikely to happen under normal circumstances, since most humans can't synchronize their actions down to a handful of microseconds, so the handshake will normally succeed.
2727

@@ -46,7 +46,7 @@ The IR sensor in the GBC adapts to the current level of IR light. That is to say
4646

4747
Signal fade time is dependent on length and has an inverse relationship with the distance between a GBC and the IR light. The closer a GBC is to the IR source, the longer the fade time. The farther away a GBC is to the IR source, the shorter the fade time. One possible explanation for everything is that the IR signal is weaker on the receiving end, so the signal is prone to get "lost" to surrounding noise. The GBC IR sensor is probably good at sending IR signals (evidenced by the Mission Impossible cheat to turn a GBC into a TV remote) but not so good at picking up signals (evidenced by Chee Chai Aliens plastic add-on to enhance IR reception).
4848

49-
At about 3.0 to 3.5 inches (7.62 to 8.89cm) signal fade time appears to be around 3ms. Optimal distance seems to be 2.5 to 4.0 inches (6.35 to 10.16cm) to maintain a fade time close to 3ms and avoid potential miscommunication. One oddity of note is that putting two GBCs very close together (physically touching) produced unusually short fade times, far shorter than 3ms. There may be some sort of interference at that range.
49+
At about 3.0 to 3.5 inches (7.62 to 8.89 cm) signal fade time appears to be around 3ms. Optimal distance seems to be 2.5 to 4.0 inches (6.35 to 10.16 cm) to maintain a fade time close to 3ms and avoid potential miscommunication. One oddity of note is that putting two GBCs very close together (physically touching) produced unusually short fade times, far shorter than 3ms. There may be some sort of interference at that range.
5050

5151
## Obscure Behavior
5252

@@ -62,4 +62,4 @@ Writing 0x00 to RP, followed by 0xC0 will trigger these results listed above. On
6262

6363
The downside to this method is that when detecting a bright IR source, the sensor quickly adjusts to this new level, and the next attempt at writing 0x00 followed by 0xC0 to RP will result in readings of dark or ambient (typically dark though). Essentially the bright result only appears briefly when transitioning from lower levels of light, then it "disappears" thanks to the short time it takes for IR signal fade. Designing a game mechanic (darkness and light) around this quirk is still possible, although it would require careful thought and planning to properly work around the observed limitations.
6464

65-
One suggested method: once the Bright setting is detected, switch to writing only 0xC0 to RP so that the IR sensor works normally. If IR light stops being detected, switch to alternating 0x00 and 0xC0 writes as described above to determine Dark or Ambient settings. Whether it's practical or not to do this in a game remains theoretical at this point.
65+
One suggested method: once the Bright setting is detected, switch to writing only 0xC0 to RP so that the IR sensor works normally. If IR light stops being detected, switch to alternating 0x00 and 0xC0 writes as described above to determine Dark or Ambient settings. Whether it's practical or not to do this in a game remains theoretical at this point.

src/Interrupts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RETI ; Enables interrupts and returns (same as the instruction sequence EI, RE
1919
<INT> ; Disables interrupts and calls interrupt vector
2020
```
2121

22-
where \<INT\> means the operation which is automatically executed by the
22+
Where \<INT\> means the operation which is automatically executed by the
2323
CPU when it executes an interrupt.
2424

2525
The effect of `ei` is delayed by one instruction. This means that `ei`

src/Joypad_Input.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ and only the value from the last read is actually used).
2727

2828
## Usage in SGB software
2929

30-
Beside for normal joypad input, SGB games mis-use the joypad register to
30+
Beside for normal joypad input, SGB games misuse the joypad register to
3131
output SGB command packets to the SNES, also, SGB programs may read out
3232
gamepad states from up to four different joypads which can be connected
3333
to the SNES. See SGB description for details.

0 commit comments

Comments
 (0)