mirror of
https://github.com/pmret/papermario.git
synced 2024-11-18 08:52:40 +01:00
20 lines
447 B
Python
20 lines
447 B
Python
|
#! /usr/bin/python3
|
||
|
|
||
|
from pathlib import Path
|
||
|
from sys import argv
|
||
|
import re
|
||
|
import struct
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
infile, outfile, cname = argv[1:]
|
||
|
|
||
|
with open(outfile, "w") as f:
|
||
|
f.write(f"unsigned short {cname}[] = {{ ")
|
||
|
|
||
|
with open(infile, "rb") as i:
|
||
|
while (short := i.read(2)):
|
||
|
color = struct.unpack('>H', short)[0]
|
||
|
f.write(f'0x{color:04X}, ')
|
||
|
|
||
|
f.write(f"}};\n")
|