From 19344c50d505fbcb0c59f92a9033de43dfcd122b Mon Sep 17 00:00:00 2001 From: Yavin7 Date: Thu, 18 Sep 2025 22:53:57 -0600 Subject: [PATCH] Added a notes file Updated header parsing, and replaced the endian with little instead of big, because the files are def little endian --- main.py | 24 +++++++++++++----------- notes.txt | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 notes.txt diff --git a/main.py b/main.py index 606c9ab..eb85a65 100644 --- a/main.py +++ b/main.py @@ -12,7 +12,7 @@ class BZZCompressor: # read the input file try: with open(f"{input_file_path}/{input_file}", "rb") as infile: - temp = bitarray(endian="big") + temp = bitarray(endian="little") temp.fromfile(infile) data = temp.tobytes() @@ -30,13 +30,9 @@ class BZZCompressor: ############################################################################## # This is always 1, 0, 0, 0. so I'm just having fun - bzz_version = f"v{data[0]}.{data[1]}.{data[2]}.{data[3]}" - game_id = "".join([str(int(bin(item)[2:], 2)) for item in data[4:8]]) - - num_files = 0 - - for item in data[8:12]: - num_files += int(bin(item)[2:].zfill(8), 2) + bzz_version = int.from_bytes(data[0:4], "little") + game_id = int.from_bytes(data[4:8], "little") + num_files = int.from_bytes(data[8:12], "little") print(f"BZZ Version: {bzz_version}") print(f"Game ID: {game_id}") @@ -48,9 +44,15 @@ class BZZCompressor: tmp = (i) * 12 files.append( { - "pt_a": data[12 + tmp : 12 + tmp + 4], - "pt_b": data[12 + tmp + 4 : 12 + tmp + 8], - "pt_c": data[12 + tmp + 8 : 12 + tmp + 12], + "pt_a": hex( + int.from_bytes(data[12 + tmp : 12 + tmp + 4], "little") + ), + "pt_b": hex( + int.from_bytes(data[12 + tmp + 4 : 12 + tmp + 8], "little") + ), + "pt_c": hex( + int.from_bytes(data[12 + tmp + 8 : 12 + tmp + 12], "little") + ), } ) diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..544c4ad --- /dev/null +++ b/notes.txt @@ -0,0 +1,50 @@ +Conclusions based on the data below: +1. It looks like the Part A is the file's type +2. It looks like Part C - Part B is 1 more than the length of the 0-padding between files + note: I don't know why they didn't just write the file's size here, it would've saved on space +3. PS1 developers were madlads + + +Header: +Header Data Start: 0x00 +Header Data End: 0x2F +0 Padding Start: 0x30 +0 Padding End: 0x7FB +Checksum Start: 0x7FC +Checksum End: 0x7FF + +File 1: +Part A: 0x1 +Part B: 0x8fc +Part C: 0x1000 +C - B = 0x704 + +Data Start: 0x800 +Data End: 0x10F9 +0 Padding Start: 0x10FA +0 Padding End: 0x17FF +End - Start = 0x705 + +File 2: +Part A: 0x3 +Part B: 0xE240 +Part C: 0xE800 +C - B = 0x5C0 + +Data Start: 0x1800 +Data End: 0xFA3F +0 Padding Start: 0xFA40 +0 Padding End: 0xFFFF +0 Padding End - Start = 0x5BF + +File 3: +Part A: 0x4 +Part B: 0xD450 +Part C: 0xD800 +C - B = 0x3B0 + +Data Start: 0x10000 +Data End: 0x1D44F +0 Padding Start: 0x1D450 +0 Padding End: 0x1D7FF +End - Start = 3AF \ No newline at end of file