Skip to content

Commit dd63995

Browse files
committed
gcipack: Add file info data to file and align main data to 512 bytes
1 parent 3ec8f15 commit dd63995

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ttyd-tools/gcipack/gcipack.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@
4747
struct.pack_into("32s", commentBuffer, 0x00, sys.argv[3].encode())
4848
struct.pack_into("32s", commentBuffer, 0x20, sys.argv[4].encode())
4949

50+
# File info
51+
fileInfoBuffer = ctypes.create_string_buffer(0x200 - 0x40)
52+
struct.pack_into(">L", fileInfoBuffer, 0, len(inputBuffer))
53+
54+
5055
# Pad to block boundary
51-
paddingLength = blockCount * 0x2000 - (len(bannerBuffer) + len(iconBuffer) + len(commentBuffer) + len(inputBuffer))
56+
paddingLength = blockCount * 0x2000 - (len(bannerBuffer) + len(iconBuffer) + len(commentBuffer) + len(fileInfoBuffer) + len(inputBuffer))
5257
paddingBuffer = ctypes.create_string_buffer(paddingLength)
5358

5459
outputFilename = os.path.splitext(os.path.splitext(inputFilename)[0])[0] + ".gci"
@@ -57,6 +62,7 @@
5762
outputFile.write(bytearray(bannerBuffer))
5863
outputFile.write(bytearray(iconBuffer))
5964
outputFile.write(bytearray(commentBuffer))
65+
outputFile.write(bytearray(fileInfoBuffer))
6066
outputFile.write(bytearray(inputBuffer))
6167
outputFile.write(bytearray(paddingBuffer))
6268
outputFile.close()

0 commit comments

Comments
 (0)