Updating extract_Story_Pointer to receive bytecode parameter

This commit is contained in:
Stewie
2022-07-14 13:13:05 -04:00
committed by fortiersteven
parent 5c9281a54b
commit 63fe258aa4
3 changed files with 10 additions and 4 deletions

View File

@@ -34,6 +34,9 @@ class ToolsTOPX(ToolsTales):
self.all_original = '../Data/{}/Disc/Original/PSP_GAME/USRDIR/all.dat'.format(self.repo_name)
self.all_new = '../Data/{}/Disc/New/PSP_GAME/USRDIR/all.dat'.format(self.repo_name) #File is all.dat
self.story_struct_byte_code = b'\x18\x00\x0C\x04'
self.story_string_byte_code = b'\x00\x00\x82\x02'
self.make_dirs()
#############################
#
@@ -142,7 +145,10 @@ class ToolsTOPX(ToolsTales):
#File size
fsize = tss.getbuffer().nbytes
tss.seek(pointer_block, 0) #Go the the start of the pointer section
pointers_offset, texts_offset = self.extract_Story_Pointers(tss, strings_offset, fsize)
#Struct
pointers_offset, texts_offset = self.extract_Story_Pointers(tss, strings_offset, fsize, self.story_string_byte_code)
text_list = [self.bytes_to_text(tss, ele)[0] for ele in texts_offset]

View File

@@ -125,7 +125,7 @@ class ToolsTOR(ToolsTales):
#File size
fsize = theirsce.getbuffer().nbytes
theirsce.seek(pointer_block, 0) #Go the the start of the pointer section
pointers_offset, texts_offset = self.extract_Story_Pointers(theirsce, strings_offset, fsize)
pointers_offset, texts_offset = self.extract_Story_Pointers(theirsce, strings_offset, fsize, self.story_byte_code)
text_list = [self.bytes_to_text(theirsce, ele)[0] for ele in texts_offset]

View File

@@ -241,7 +241,7 @@ class ToolsTales:
HW.pack_into(out, cmds, c)
return bytes(out)
def extract_Story_Pointers(self, theirsce, strings_offset, fsize):
def extract_Story_Pointers(self, theirsce, strings_offset, fsize, bytecode):
pointers_offset = []
@@ -250,7 +250,7 @@ class ToolsTales:
previous_addr = 0
while theirsce.tell() < strings_offset:
b = theirsce.read(1)
if b == self.story_byte_code:
if b == bytecode:
addr = struct.unpack("<H", theirsce.read(2))[0]
current_pos = theirsce.tell()