Example #1
0
 def save_entries(entries, base_offset, prefix):
     entry_names = []
     offsets = []
     text_writer = BinaryIO()
     for entry in entries:
         if entry[:-1] == prefix:
             entry_names.append(entry[-1])
     for i in range(len(entry_names)):
         text_writer.writeUInt32(0)
     for entry in entry_names:
         offsets.append(text_writer.tell() + base_offset)
         text_writer.writeString(entry)
     with text_writer.seek(0):
         text_writer.write(array.array('I', offsets).tostring())
     return len(entry_names), text_writer
Example #2
0
 def save(self):
     """Save necessary information. NDSTool cleans up the rest"""
     writer = BinaryIO('\x00' * 0x200)
     writer.write(self.name)
     with writer.seek(0xC):
         writer.write(self.code)
     with writer.seek(0x10):
         writer.write('01')  # Nintendo
     with writer.seek(0x60):
         writer.writeUInt32(0x7f7fff)
         writer.writeUInt32(0x7f1fff)
         writer.writeUInt32(0)
         writer.writeUInt32(0)
         writer.writeUInt32(0x051E)
     with writer.seek(0xA0):
         writer.write(self.base_code)
     writer.seek(0x200)
     return writer