From 99bb244284e54b535d1acfbecff9a956fba80da1 Mon Sep 17 00:00:00 2001 From: Felix Dumbeck Date: Thu, 22 Jan 2026 12:31:06 +0100 Subject: [PATCH 1/4] clarify usage of replace command option --- psptool/__main__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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() From fe9eb1cd0f00732b541a1c222bf65d429c5cac3a Mon Sep 17 00:00:00 2001 From: Felix Dumbeck Date: Thu, 22 Jan 2026 12:32:22 +0100 Subject: [PATCH 2/4] calculate correct offset relative from directory start --- psptool/directory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psptool/directory.py b/psptool/directory.py index 91dd4bc..5cc0b54 100644 --- a/psptool/directory.py +++ b/psptool/directory.py @@ -192,7 +192,7 @@ def update_entry_fields(self, file: File, type_, size, offset): # 2. Update fields entry.type = type_ entry.size = size - entry.offset = offset + entry.offset = offset - self.get_address() # todo: allow updating the address_mode which consists of two bytes right here # 3. Update checksum From cfab1a2fe6c548c2b430bda3b651699d8ad26f3f Mon Sep 17 00:00:00 2001 From: Felix Dumbeck Date: Thu, 22 Jan 2026 12:36:15 +0100 Subject: [PATCH 3/4] buffer_size doesnt have to be 0x10 aligned --- psptool/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psptool/file.py b/psptool/file.py index 1da231a..5c2a929 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: From 897bf9fe6ab5d4cd14268c7e2678015684021a48 Mon Sep 17 00:00:00 2001 From: Felix Dumbeck Date: Tue, 27 Jan 2026 20:20:39 +0100 Subject: [PATCH 4/4] directory.update_entry_fields(): follow address_mode --- psptool/directory.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/psptool/directory.py b/psptool/directory.py index 5cc0b54..57e12c5 100644 --- a/psptool/directory.py +++ b/psptool/directory.py @@ -187,12 +187,15 @@ 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_ entry.size = size - entry.offset = offset - self.get_address() + entry.offset = offset # todo: allow updating the address_mode which consists of two bytes right here # 3. Update checksum