The palette consists of 64 lines, one for each value of $3Fxx. Each line is 3 hex bytes, case insensitive, separated by a space ($20), terminated by a UNIX newline ($0A) or CP/M newline ($0D $0A). A full 64-entry palette file is thus 576 bytes (UNIX) or 640 bytes (CP/M).
The above translated into Python (untested):
Code:
#!/usr/bin/env python3
# By Damian Yerrick; license: WTFPL
with open("bisqwit.pal", "rb") as infp:
p = infp.read(192)
p = bytearray(p) # for compatibility with old Python where str is bytes
with open("bisqwit.ines.pal", "w") as outfp:
outfp.writelines("%02X %02X %02X\n" % (p[i], p[i + 1], p[i + 2]) for i in range(0, 192, 3))