Skip to content

Commit 0093d30

Browse files
sfieraISSOtm
andauthored
Add SVG explanation of 2bpp format (#405)
* Add SVG explanation of 2bpp format * Put hex/binary tile data in backticks * Use <figure> for example tile data image * Copy-edit tile data explanation * Remove explicit `align="center"` Co-authored-by: Eldred Habert <[email protected]> Co-authored-by: Eldred Habert <[email protected]>
1 parent 6f45e8a commit 0093d30

File tree

2 files changed

+302
-12
lines changed

2 files changed

+302
-12
lines changed

src/Tile_Data.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,24 @@ Byte 2-3 Second Line
7474
etc.
7575
```
7676

77-
For each line, the first byte specifies the least significant bit of the
78-
color ID of each pixel, and the second byte specifies the most significant bit.
79-
In both bytes, bit 7 represents the leftmost pixel, and
80-
bit 0 the rightmost. For example: let's say you have \$57 \$36 (in
81-
this order in memory), which in binary are 01010111 and 00110110.
82-
To obtain the color ID for the leftmost pixel,
83-
you take bit 7 of both bytes: 0, and 0. Thus the index is binary 00 = 0. For
84-
the second pixel, repeat with bit 6: 1, and 0. Thus the index is binary 01 =
85-
1 (remember to flip the order of the bits!). If you repeat the
86-
operation you'll find that the IDs for the eight pixels are 0 1 2 3 0 3
87-
3 1.
77+
For each line, the first byte specifies the least significant bit of the color
78+
ID of each pixel, and the second byte specifies the most significant bit. In
79+
both bytes, bit 7 represents the leftmost pixel, and bit 0 the rightmost. For
80+
example, the tile data `$3C $7E $42 $42 $42 $42 $42 $42 $7E $5E $7E $0A $7C $56
81+
$38 $7C` appears as follows:
8882

89-
A more visual explanation can be found
83+
<figure>
84+
{{#include imgs/sprite.svg:2:}}
85+
<figcaption>Sample tile data</figcaption>
86+
</figure>
87+
88+
For the first row, the values `$3C $7E` are `00111100` and `01111110` in
89+
binary. The leftmost bits are 0 and 0, thus the color ID is binary `00`, or 0.
90+
The next bits are 0 and 1, thus the color ID is binary `10`, or 2 (remember to
91+
flip the order of the bits!). The full eight-pixel row evaluates to 0 2 3 3 3 3
92+
2 0.
93+
94+
A tool for viewing tiles can be found
9095
[here](https://www.huderlem.com/demos/gameboy2bpp.html).
9196

9297
So, each pixel has a color ID of 0 to 3. The color

src/imgs/sprite.svg

Lines changed: 285 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)