Clarify SGB multiplayer, handle count = 0

This commit is contained in:
Lior Halphon 2021-04-13 21:33:13 +03:00
parent 24915e41eb
commit 0af4f1fa4d
2 changed files with 20 additions and 20 deletions

View File

@ -174,7 +174,7 @@ The SGB block uses the `'SGB '` identifier, and is an optional block that is onl
The length of this block is 0x39 bytes and it follows the following structure:
| Offset | Content |
|--------|--------------------------------------------------------------------------------------------------|
|--------|--------------------------------------------------------------------------------------------------------------------------|
| 0x00 | The size of the border tile data (=0x2000, 32-bit integer) |
| 0x04 | The offset of the border tile data (SNES tile format, 32-bit integer) |
| 0x08 | The size of the border tilemap (=0x800, 32-bit integer) |
@ -189,7 +189,7 @@ The length of this block is 0x39 bytes and it follows the following structure:
| 0x2C | The offset of the attribute map (32-bit integer) |
| 0x30 | The size of the attribute files (=0xfd2, 32-bit integer) |
| 0x34 | The offset of the attribute files (32-bit integer) |
| 0x38 | Multiplayer status (1 byte); high nibble is player count, low nibble is current player (0-based) |
| 0x38 | Multiplayer status (1 byte); high nibble is player count (1, 2 or 4), low nibble is current player (Where Player 1 is 0) |
If only some of the size-offset pairs are available (for example, partial HLE SGB implementation), missing fields are allowed to have 0 as their size, and implementations are expected to fall back to a sane default.

View File

@ -1032,7 +1032,7 @@ done:
gb->sgb->player_count = sgb.multiplayer_state >> 4;
gb->sgb->current_player = sgb.multiplayer_state & 0xF;
if (gb->sgb->player_count > 4 || gb->sgb->player_count == 3) {
if (gb->sgb->player_count > 4 || gb->sgb->player_count == 3 || gb->sgb->player_count == 0) {
gb->sgb->player_count = 1;
gb->sgb->current_player = 0;
}