gbdev / rgbds

Rednex Game Boy Development System - An assembly toolchain for the Nintendo Game Boy and Game Boy Color
https://rgbds.gbdev.io
MIT License
1.35k stars 172 forks source link

[Feature request] Support arbitrary logos in the fixed header #1398

Closed Rangi42 closed 5 months ago

Rangi42 commented 5 months ago

RGBFIX can fill in the Nintendo logo in the header with its usual 48 bytes. However, some alternative consoles use a different logo, such as the Analogue Pocket. Without hard-coding these third-parties' logos (which could be taken as endorsing them), we can still let the user supply an arbitrary logo from a file.

Logo files could just be 48-byte binary blobs. But, we could also allow 48x8-px (6x1-tile) 1bpp input, and convert that to the weird header logo encoding.

Nintendo:

██░░░██░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░░░░░░
███░░██░██░░░░░░░░██░░░░░░░░░░░░░░░░░░░██░░░░░░░
███░░██░░░░░░░░░░████░░░░░░░░░░░░░░░░░░██░░░░░░░
██░█░██░██░██░██░░██░░████░░██░██░░░█████░░████░
██░█░██░██░███░██░██░██░░██░███░██░██░░██░██░░██
██░░███░██░██░░██░██░██████░██░░██░██░░██░██░░██
██░░███░██░██░░██░██░██░░░░░██░░██░██░░██░██░░██
██░░░██░██░██░░██░██░░█████░██░░██░░█████░░████░

Analogue:

░░░░██░░░░░░░█░░░░░░░░░░░░░█░░░░░░░░░░░░░░░░░░░░
░░░████░░░░░░█░░░░░░░░░░░░░█░░░░░░░░░░░░░░░░░░░░
░░░████░░░░░█░█░░███░░░██░░█░░██░░░███░█░░█░░██░
░░░░████░░░░█░█░░█░░█░░░░█░█░█░░█░█░░█░█░░█░█░░█
░██░████░░░░███░░█░░█░░███░█░█░░█░█░░█░█░░█░████
████░████░░█░░░█░█░░█░█░░█░█░█░░█░░███░█░░█░█░░░
████░████░░█░░░█░█░░█░░███░█░░██░░█░░█░░███░░██░
░██░░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░
Rangi42 commented 5 months ago

Nintendo logo:

Input (1bpp):

c6 e6 e6 d6 d6 ce ce c6 c0 c0 00 db dd d9 d9 d9
00 30 78 33 b6 b7 b6 b3 00 00 00 cd 6e ec 0c ec
01 01 01 8f d9 d9 d9 cf 80 80 80 9e b3 b3 b3 9e

Output (bin):

ce ed 66 66 cc 0d 00 0b 03 73 00 83 00 0c 00 0d
00 08 11 1f 88 89 00 0e dc cc 6e e6 dd dd d9 99
bb bb 67 63 6e 0e ec cc dd dc 99 9f bb b9 33 3e

Analogue logo:

Input (1bpp):

0c 1e 1e 0f 6f f7 f7 63 04 04 0a 0a 0e 91 91 00
00 00 71 48 49 4a 49 00 10 10 93 54 d4 54 d3 00
00 00 1d a5 a5 9d 24 18 00 00 26 29 2f 28 e6 00

Output (bin):

01 10 ce ef 00 00 44 aa 00 74 00 18 11 95 00 34
00 1a 00 d5 00 22 00 69 6f f6 f7 73 09 90 e1 10
44 40 9a 90 d5 d0 44 30 a9 21 5d 48 22 e0 f8 60
Rangi42 commented 5 months ago
def convert(bpp):
    N = 48
    assert len(bpp) == N
    def highs(j):
        return (bpp[j * 2] & 0xF0) | ((bpp[j * 2 + 1] & 0xF0) >> 4)
    def lows(j):
        return ((bpp[j * 2] & 0x0F) << 4) | (bpp[j * 2 + 1] & 0x0F)
    out = [-1] * N
    W = N // 2
    for i in range(0, W, 4):
        out[i +  0] = highs(i + 0)
        out[i +  1] = highs(i + 1)
        out[i +  2] = lows(i + 0)
        out[i +  3] = lows(i + 1)
        out[W + i + 0] = highs(i + 2)
        out[W + i + 1] = highs(i + 3)
        out[W + i + 2] = lows(i + 2)
        out[W + i + 3] = lows(i + 3)
    return out