Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import struct
- TPLData = open(raw_input("Path to TPL? "), "rb").read()
- BRFNTData = open(raw_input("Path to BRFNT? "), "rb").read()
- FormatType = int(raw_input("Image Format Type? "))
- OutData = open(raw_input("Output File Name? "), "wb")
- BRFNTHeader = BRFNTData[0x00:0x60]
- CWDHData = BRFNTData[BRFNTData.find("CWDH"):len(BRFNTData)]
- RAWTPLData = TPLData[0x80:len(TPLData)]
- CMAPosChange = BRFNTData.find("CMAP") - BRFNTData.find("CWDH")
- OutData.write(BRFNTHeader)
- OutData.write(RAWTPLData)
- CWDHPos = OutData.tell()
- OutData.write(CWDHData)
- BRFNTSize = OutData.tell()
- OutData.seek(0x08, 0)
- OutData.write(struct.pack('>L', BRFNTSize)) # Current BRFNT Size
- OutData.seek(0x24, 0)
- OutData.write(struct.pack('>L', CWDHPos + 8)) # CWDH Position
- OutData.write(struct.pack('>L', CWDHPos + CMAPosChange + 8)) #CMAP Position
- OutData.seek(0x3C, 0)
- OutData.write(struct.pack('>L', len(RAWTPLData) / 2)) # Size of one image
- OutData.seek(0x42, 0)
- OutData.write(struct.pack('>H', FormatType))
- OutData.close()
- raw_input("Done! Press enter to exit.")
Advertisement
Add Comment
Please, Sign In to add comment