16 lines
381 B
Python
16 lines
381 B
Python
# 2bpp.py - functions for the gameboy 2bpp graphics format.
|
|
|
|
def decode_tile(tile):
|
|
d = []
|
|
for i in range(0,16,2):
|
|
d.append(decode_line(tile[i], tile[i+1]))
|
|
return d
|
|
|
|
def decode_line(b1, b2):
|
|
line = []
|
|
for i in range(8):
|
|
hi_bit = (b2 >> (7-i)) & 1;
|
|
lo_bit = (b1 >> (7-i)) & 1;
|
|
line.append((hi_bit << 1) | lo_bit)
|
|
return line
|