mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-01 13:25:46 -04:00
Merge 0dffa0776d
into 1791ff4dca
This commit is contained in:
commit
9efc7922ae
7 changed files with 21 additions and 21 deletions
|
@ -31,8 +31,8 @@ def main():
|
||||||
# three lumps needed - see bootstrap/README.txt
|
# three lumps needed - see bootstrap/README.txt
|
||||||
lumps = [
|
lumps = [
|
||||||
(b"PLAYPAL", read()),
|
(b"PLAYPAL", read()),
|
||||||
(b"TEXTURE1", struct.pack("i", 0)), # empty texture1
|
(b"TEXTURE1", struct.pack("<i", 0)), # empty texture1
|
||||||
(b"PNAMES", struct.pack("i8s", 1, b"")),
|
(b"PNAMES", struct.pack("<i8s", 1, b"")),
|
||||||
] # single pname
|
] # single pname
|
||||||
|
|
||||||
# calculate wad directory (lump offsets etc.)
|
# calculate wad directory (lump offsets etc.)
|
||||||
|
@ -43,7 +43,7 @@ def main():
|
||||||
pos += len(data)
|
pos += len(data)
|
||||||
|
|
||||||
# write wad header
|
# write wad header
|
||||||
write(struct.pack("4sii", b"IWAD", len(waddir), pos))
|
write(struct.pack("<4sii", b"IWAD", len(waddir), pos))
|
||||||
|
|
||||||
# write lump contents
|
# write lump contents
|
||||||
for name, data in lumps:
|
for name, data in lumps:
|
||||||
|
@ -51,7 +51,7 @@ def main():
|
||||||
|
|
||||||
# write wad directory
|
# write wad directory
|
||||||
for i in waddir:
|
for i in waddir:
|
||||||
write(struct.pack("ii8s", *i))
|
write(struct.pack("<ii8s", *i))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -49,7 +49,7 @@ def read_palette(filename):
|
||||||
for i in range(256):
|
for i in range(256):
|
||||||
data = f.read(3)
|
data = f.read(3)
|
||||||
|
|
||||||
color = struct.unpack("BBB", data)
|
color = struct.unpack("<BBB", data)
|
||||||
colors.append(color)
|
colors.append(color)
|
||||||
|
|
||||||
return colors
|
return colors
|
||||||
|
@ -159,7 +159,7 @@ def solid_color_list(color):
|
||||||
def output_colormap(colormap):
|
def output_colormap(colormap):
|
||||||
"""Output the given palette to stdout."""
|
"""Output the given palette to stdout."""
|
||||||
for c in colormap:
|
for c in colormap:
|
||||||
x = struct.pack("B", c)
|
x = struct.pack("<B", c)
|
||||||
os.write(sys.stdout.fileno(), x)
|
os.write(sys.stdout.fileno(), x)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class BitReader:
|
||||||
"Reached end of decompress stream "
|
"Reached end of decompress stream "
|
||||||
+ "(%i bytes)" % len(self.data)
|
+ "(%i bytes)" % len(self.data)
|
||||||
)
|
)
|
||||||
result, = struct.unpack("B", self.data[self.index : self.index + 1])
|
result, = struct.unpack("<B", self.data[self.index : self.index + 1])
|
||||||
self.index += 1
|
self.index += 1
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ def decompress(data, data_len):
|
||||||
|
|
||||||
# print "len: %i" % len(result)
|
# print "len: %i" % len(result)
|
||||||
|
|
||||||
return struct.pack("%iB" % len(result), *result)
|
return struct.pack("<%iB" % len(result), *result)
|
||||||
|
|
||||||
|
|
||||||
FIELDS = [
|
FIELDS = [
|
||||||
|
@ -187,13 +187,13 @@ def decode_type_9(data):
|
||||||
|
|
||||||
for i in range(len(FIELDS)):
|
for i in range(len(FIELDS)):
|
||||||
instr_data[FIELDS[i]], = struct.unpack(
|
instr_data[FIELDS[i]], = struct.unpack(
|
||||||
"B", decompressed_data[i : i + 1]
|
"<B", decompressed_data[i : i + 1]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Decode instrument name
|
# Decode instrument name
|
||||||
|
|
||||||
ps = decompressed_data[14:]
|
ps = decompressed_data[14:]
|
||||||
instr_name, = struct.unpack("%ip" % len(ps), ps)
|
instr_name, = struct.unpack("<%ip" % len(ps), ps)
|
||||||
instr_data["name"] = instr_name.decode("ascii")
|
instr_data["name"] = instr_name.decode("ascii")
|
||||||
|
|
||||||
return instr_data
|
return instr_data
|
||||||
|
|
|
@ -97,14 +97,14 @@ def encode_instrument_names(instruments):
|
||||||
|
|
||||||
for instrument in instruments:
|
for instrument in instruments:
|
||||||
instr_name = instrument.voice1["name"].encode("ascii")
|
instr_name = instrument.voice1["name"].encode("ascii")
|
||||||
result.append(struct.pack("32s", instr_name))
|
result.append(struct.pack("<32s", instr_name))
|
||||||
|
|
||||||
return b"".join(result)
|
return b"".join(result)
|
||||||
|
|
||||||
|
|
||||||
def write(filename, instruments):
|
def write(filename, instruments):
|
||||||
header = struct.pack(
|
header = struct.pack(
|
||||||
"%is" % len(GENMIDI_HEADER), GENMIDI_HEADER.encode("ascii")
|
"<%is" % len(GENMIDI_HEADER), GENMIDI_HEADER.encode("ascii")
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(filename, "wb") as f:
|
with open(filename, "wb") as f:
|
||||||
|
|
|
@ -28,7 +28,7 @@ def read(filename):
|
||||||
with open(filename, "rb") as f:
|
with open(filename, "rb") as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
|
||||||
header, name = struct.unpack("4s32s", data[0:36])
|
header, name = struct.unpack("<4s32s", data[0:36])
|
||||||
header = header.decode("ascii")
|
header = header.decode("ascii")
|
||||||
|
|
||||||
if header != HEADER_VALUE:
|
if header != HEADER_VALUE:
|
||||||
|
@ -38,20 +38,20 @@ def read(filename):
|
||||||
result = {"name": name.decode("ascii").rstrip("\0").rstrip()}
|
result = {"name": name.decode("ascii").rstrip("\0").rstrip()}
|
||||||
|
|
||||||
for i in range(len(FIELDS)):
|
for i in range(len(FIELDS)):
|
||||||
result[FIELDS[i]], = struct.unpack("B", instr_data[i : i + 1])
|
result[FIELDS[i]], = struct.unpack("<B", instr_data[i : i + 1])
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def write(filename, data):
|
def write(filename, data):
|
||||||
with open(filename, "wb") as f:
|
with open(filename, "wb") as f:
|
||||||
f.write(struct.pack("4s", HEADER_VALUE.encode("ascii")))
|
f.write(struct.pack("<4s", HEADER_VALUE.encode("ascii")))
|
||||||
f.write(struct.pack("32s", data["name"].encode("ascii")))
|
f.write(struct.pack("<32s", data["name"].encode("ascii")))
|
||||||
|
|
||||||
for field in FIELDS:
|
for field in FIELDS:
|
||||||
f.write(struct.pack("B", data[field]))
|
f.write(struct.pack("<B", data[field]))
|
||||||
for x in range(16 - len(FIELDS)):
|
for x in range(16 - len(FIELDS)):
|
||||||
f.write(struct.pack("B", 0))
|
f.write(struct.pack("<B", 0))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -83,7 +83,7 @@ def read_palette(filename):
|
||||||
|
|
||||||
for i in range(256):
|
for i in range(256):
|
||||||
data = f.read(3)
|
data = f.read(3)
|
||||||
color = struct.unpack("BBB", data)
|
color = struct.unpack("<BBB", data)
|
||||||
|
|
||||||
colors.append(color)
|
colors.append(color)
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ def output_palette(pal):
|
||||||
for color in palette:
|
for color in palette:
|
||||||
color = tuple(map(clamp_pixval, color))
|
color = tuple(map(clamp_pixval, color))
|
||||||
|
|
||||||
encoded = struct.pack("BBB", *color)
|
encoded = struct.pack("<BBB", *color)
|
||||||
os.write(sys.stdout.fileno(), encoded)
|
os.write(sys.stdout.fileno(), encoded)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ def write_pnames_lump(pnames, filename):
|
||||||
with open(filename, "wb") as out:
|
with open(filename, "wb") as out:
|
||||||
out.write(struct.pack("<l", len(pnames)))
|
out.write(struct.pack("<l", len(pnames)))
|
||||||
for pname in pnames:
|
for pname in pnames:
|
||||||
out.write(struct.pack("8s", pname.encode("ascii")))
|
out.write(struct.pack("<8s", pname.encode("ascii")))
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue