-- Leo's gemini proxy

-- Connecting to vigrey.com:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; charset=UTF-8; lang=en

2bpp Graphics Format


Palette


The Game Boy palette consists of 4 slots for color data at memory address 0xFF47. The slots are as follows


7  bit  0
---- ----
3322 1100
|||| ||||
|||| ||++- Slot Index 0
|||| ++--- Slot Index 1
||++------ Slot Index 2
++-------- Slot Index 3

The four possible colors that can fit in each slot are:


0 (0b00) - White

1 (0b01) - Light Gray

2 (0b10) - Dark Gray

3 (0b11) - Black


Any of the 4 colors can go into any of the 4 palette slots. As an example, a palette with the order slot index 0 = White, slot index 1 = Light Gray, slot index 2 = Dark Gray, and slot index 4 = Black would require writing the following byte to memory address 0xFF47:


0b11100100 = 0xE4

Inverting the previous example, so having the order be slot index 0 = Black, slot index 1 = Dark Gray, slot index 2 = Light Gray, and slot index 3 = White, would require the following byte to be written to memory address 0xFF47:


0b00011011 = 0x1B

A monochrome version, which converts anything that isn't black to white, of the first palette example, so having the order be slot index 0 = white, slot index 1 = white, slot index 2 = white, slot index 3 = black, would require the following byte to be written to memory address 0xFF47:


0b11000000 = 0xC0


Tiles


Each Game Boy tile is an 8x8 pixel graphic with only 2 bits of palette slot index data per pixel. Because there are 2 bits per pixel, there are 8 rows each of 16 bits of palette slot index data per tile, totalling 128 bits (16 bytes) of palette slot index data per tile.


A Game Boy tile is represented below as palette slot index numbers in an 8 by 8 grid:


2 0 0 0 0 0 0 0
2 3 2 2 2 2 2 1
2 3 1 3 3 3 0 1
2 3 1 0 1 2 0 1
2 3 1 2 3 2 0 1
2 3 0 0 0 2 0 1
2 1 1 1 1 1 0 1
3 3 3 3 3 3 3 1

Each row of indexes is represented by first taking the 8 least significant bits of the row, then taking the 8 most significant bytes of the row, this is shown below for the previous tile example:


2 0 0 0 0 0 0 0 = 0b00000000 0b10000000 = 0x00 0x80
2 3 2 2 2 2 2 1 = 0b01000001 0b11111110 = 0x41 0xFE
2 3 1 3 3 3 0 1 = 0b01111101 0b11011100 = 0x7D 0xDC
2 3 1 0 1 2 0 1 = 0b01101001 0b11000100 = 0x69 0xC4
2 3 1 2 3 2 0 1 = 0b01101001 0b11011100 = 0x69 0xDC
2 3 0 0 0 2 0 1 = 0b01000001 0b11000100 = 0x41 0xC4
2 1 1 1 1 1 0 1 = 0b01111101 0b10000000 = 0x7D 0x80
3 3 3 3 3 3 3 1 = 0b11111111 0b11111110 = 0xFF 0xFE

The tile example would be represented in graphical memory on the Game Boy as the following:


00 80 41 FE 7D DC 69 C4 69 DC 41 C4 7D 80 FF FE

-- Response ended

-- Page fetched on Mon May 20 21:18:42 2024