diff --git a/bindiff.py b/bindiff.py new file mode 100644 index 0000000..ff713be --- /dev/null +++ b/bindiff.py @@ -0,0 +1,42 @@ +#!/usr/bin/python3 -i +''' +Read in a bunch of small binary files, determine what parts of them are common, do something with all the differences. +Intended to separate SPC engine data from song data +''' + +import sys +import traceback + + +def main(filenames): + common = [] + uniques = [] + common_str = [] + + try: + files = [open(f, 'rb') for f in filenames] + data = [f.read() for f in files] + except BaseException as e: + traceback.print_exc() + finally: + for file in files: + file.close() + + for vals in zip(*data): + u = set(vals) + uniques.append(len(u)) + if len(u) == 1: + common_str.append(vals[0]) + else: + if len(common_str)>7: + common.append('x'+''.join(['{:02x}'.format(b) for b in common_str])+'\n') + common_str = [] + with open('uniques.bin', 'wb') as out: + out.write(bytes(uniques)) + with open('common.txt', 'w') as out: + out.writelines(common) + print(common) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/ff5reader.py b/ff5reader.py index fd8940a..9630b98 100755 --- a/ff5reader.py +++ b/ff5reader.py @@ -136,6 +136,7 @@ class FF5Reader(QMainWindow): print('Generating Strings') zone_names = make_string_img_list(0x107000, 2, 0x100, start_str=0x270000, start_jp_str=0x107200, indirect=True, large=True) + menu_strings = make_string_img_list(0xF987, 2, 139, start_str=0x270000, start_jp_str=0x0000, indirect=True) items = make_string_img_list(0x111380, 9, 256) magics = make_string_img_list(0x111C80, 6, 87) more_magics = make_string_img_list(0x111E8A, 9, 73) @@ -344,6 +345,7 @@ class FF5Reader(QMainWindow): structs_tab.addTab(make_table(const.npc_layer_headers, npc_layers, True), 'NPC Layers') structs_tab.addTab(make_table(enemy_sprite_headers, enemy_sprite_data, True), 'Enemy Sprites') + strings_tab.addTab(make_table(imglist_headers, menu_strings, row_labels=False), 'Menu Strings') strings_tab.addTab(make_table(imglist_headers, items, row_labels=False), 'Items') strings_tab.addTab(make_table(imglist_headers, magics+more_magics, row_labels=False), 'Magics') #strings_tab.addTab(make_table(imglist_headers, more_magics, row_labels=False), 'More Magics') diff --git a/includes/qthelpers.py b/includes/qthelpers.py index bf25951..4481418 100644 --- a/includes/qthelpers.py +++ b/includes/qthelpers.py @@ -96,7 +96,7 @@ class Label(QLabel): elif isinstance(content, list) and isinstance(content[0], QPixmap): self.pixmaps = [c.scaled(c.size() * scale) for c in content[:-1]] self.setPixmap(self.pixmaps[0]) - self.timer.start(content[-1]*1000/60) + self.timer.start(content[-1]*1000//60) else: if strip: content = content.strip()