diff --git a/psptool/__main__.py b/psptool/__main__.py index 03e61a6..827f161 100755 --- a/psptool/__main__.py +++ b/psptool/__main__.py @@ -123,7 +123,8 @@ def main(): '-r idx: specifies rom_index (default: 0)', '-d idx: specifies directory_index', '-e idx: specifies file_index', - '-s file: specifies subfile (i.e. the new file contents)', + '-s file: specifies substitution file (i.e. the new file contents)', + '(optional to allow plain re-signs)', '-o file: specifies outfile', '-p file: specifies file-stub (e.g. \'keys/id\') for the re-signing keys', '-a pass: specifies password for the re-signing keys' @@ -239,7 +240,7 @@ def main(): if args.directory_index is not None and args.file_index is not None and args.outfile is not None: file = psp.blob.roms[args.rom_index].directories[args.directory_index].files[args.file_index] - # Substituting an file is actually optional to allow plain re-signs + # Substituting a file is actually optional to allow plain re-signs if args.subfile is not None: with open(args.subfile, 'rb') as f: sub_binary = f.read() diff --git a/psptool/directory.py b/psptool/directory.py index ed05023..609fe7f 100644 --- a/psptool/directory.py +++ b/psptool/directory.py @@ -212,7 +212,10 @@ def update_entry_fields(self, file: File, type_, size, offset): if my_entry.type == file.type: entry = my_entry break - assert(entry is not None) + assert (entry is not None) + + if entry.address_mode == 2 or entry.address_mode == 3: + offset -= self.buffer_offset # 2. Update fields entry.type = type_ diff --git a/psptool/file.py b/psptool/file.py index b366f74..1baf87c 100644 --- a/psptool/file.py +++ b/psptool/file.py @@ -389,7 +389,7 @@ def move_buffer(self, new_address, size): current_address = self.get_address() move_offset = new_address - current_address self.buffer_offset += move_offset - self.buffer_size = int(ceil(size / self.ENTRY_ALIGNMENT)) * self.ENTRY_ALIGNMENT + self.buffer_size = size # update all directories' headers that point to this entry for directory in self.references: