# Compiles images in this folder into an assembly file
from PIL import Image
import glob

files = glob.glob('*.png')

for file in files:
    img = Image.open(file)
    pixels = img.load()

    data = ''

    # size should be 8x14
    for y in range(0, 14):
        val = 0

        for x in range(0, 8):
            val <<= 1

            if pixels[x, y] == (255, 255, 255, 255):
                val |= 1
            
        data += hex(val) + ','
    
    data = data.rsplit(',', 1)[0]

    f = open('asm/' + file.rsplit('.')[0] + '.asm', 'w')

    f.write('; This file was generated by compile.py from ' + file)
    f.write('\n\tdb ' + data + '\n')

    f.close()