Skip to content

Commit 0fbd0ec

Browse files
pinobatchavivaceISSOtm
authored
Border uses palettes 4-6 only (#440)
SGB firmware in Mesen-S updates palette 7 during menu navigation and fades palettes 4, 5, and 6 during border updates. This means a border cannot safely use palette 7. Also clarify the meaning of letterboxing, and document the tile format. Co-authored-by: Antonio Vivace <[email protected]> Co-authored-by: Eldred Habert <[email protected]>
1 parent ae89342 commit 0fbd0ec

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/SGB_Command_Border.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ tiles 00h-7Fh, and once for tiles 80h-FFh). Note: The BG/OBJ Bit seems
2929
to have no effect and writes to the same VRAM addresses for both BG and
3030
OBJ ???
3131

32-
TODO: explain tile format
32+
Each tile is stored in 4-bit-per-pixel format consisting of bit planes 0 and 1 interleaved by row, followed by bit planes 2 and 3 interleaved by row.
33+
In effect, each tile consists of two Game Boy tiles, the first to determine bits 0 and 1 (choosing among color 0, 1, 2, or 3 within a 4-color subpalette), and the second to determine bits 2 and 3 (choosing among colors 0-3, 4-7, 8-11, or 12-15).
3334

3435
## SGB Command $14 — PCT_TRN
3536

@@ -48,16 +49,16 @@ The map data is sent by VRAM-Transfer (4 KBytes).
4849
```
4950
000-6FF BG Map 32x28 Entries of 16 bits each (1792 bytes)
5051
700-7FF Not used, don't care
51-
800-87F BG Palette Data (Palettes 4-7, each 16 colors of 16 bits each)
52-
880-FFF Not used, don't care
52+
800-85F BG Palette Data (Palettes 4-6, 16 little-endian RGB555 colors each)
53+
860-FFF Not used, don't care
5354
```
5455

5556
Each BG Map Entry consists of a 16-bit value as such:
5657
`VH01 PP00 NNNN NNNN```
5758

5859
```
5960
Bit 0-9 - Character Number (use only 00h-FFh, upper 2 bits zero)
60-
Bit 10-12 - Palette Number (use only 4-7, officially use only 4-6)
61+
Bit 10-12 - Palette Number (use only 4-6)
6162
Bit 13 - BG Priority (use only 0)
6263
Bit 14 - X-Flip (0=Normal, 1=Mirror horizontally)
6364
Bit 15 - Y-Flip (0=Normal, 1=Mirror vertically)
@@ -70,16 +71,21 @@ window to be displayed inside. Non-transparent border data will cover
7071
the Game Boy window (for example, *Mario's Picross* does this, as does
7172
*WildSnake* to a lesser extent).
7273

74+
A border designed for a modern (post-2006) widescreen television may use the center 256×176 pixels and leave the top and bottom 24 lines blank.
75+
Using letterbox allows more tile variety in the portion of the border that a widescreen TV's zoom mode does not cut off.
76+
7377
All borders repeat tiles. Assuming that the blank space for the GB
74-
screen is a single tile, as is the letterbox in a widescreen border, a
78+
screen is a blank tile, and the letterbox (if any) is a solid tile, a
7579
border defining all unique tiles would have to define this many tiles:
7680

77-
- (256\*224-160\*144)/64+1 = 537 tiles in fullscreen border
78-
- (256\*176-160\*144)/64+2 = 346 tiles in widescreen border
81+
- (256\*224-160\*144)/64+1 = 537 tiles in full-screen border
82+
- (256\*176-160\*144)/64+2 = 346 tiles in letterboxed border
83+
84+
Because the CHR RAM allocated by SGB for border holds only 256 tiles, a full-screen border must repeat at least 281 tiles and a letterboxed border at least 90.
7985

80-
But the CHR RAM allocated by SGB for border holds only 256 tiles. This
81-
means a fullscreen border must repeat at least 281 tiles and a
82-
widescreen border at least 90.
86+
The Super NES supports 8 background palettes.
87+
The SGB system software (when run in a LLE such as Mesen-S) has been observed to use background palette 0 for the GB screen, palettes 1, 2, 3, and 7 for the menus, and palettes 4, 5, and 6 for the border.
88+
Thus a border can use three 15-color palettes.
8389

8490
## SGB Command $18 — OBJ_TRN
8591

0 commit comments

Comments
 (0)