|
32 | 32 | assetTablePointers = [0] * SNXROM['assetTableLengthWords']
|
33 | 33 | for i in range(SNXROM['assetTableLengthWords']):
|
34 | 34 | assetTablePointers[i] = struct.unpack('I', storyfile.read(4))[0]
|
35 |
| -print("Asset table pointers:", [hex(i) for i in assetTablePointers]) |
| 35 | +#print("Asset table pointers:", [hex(i) for i in assetTablePointers]) |
36 | 36 |
|
37 |
| -SNXROM['audioOffset'] = assetTablePointers[-1] |
38 |
| - |
39 |
| -# verify audio offset |
40 |
| -print("Looking for audio at", hex(SNXROM['audioOffset'])) |
41 |
| -storyfile.seek(SNXROM['audioOffset']) |
42 |
| -if "AU" != storyfile.read(2).decode('utf-8'): |
43 |
| - raise RuntimeError("Didn't find AU at beginning of audio") |
44 |
| -print("Found beginning of audio") |
45 |
| -""" |
46 |
| -SNXROM['metaOffset'] = struct.unpack('I', storyfile.read(4))[0] |
47 |
| -SNXROM['leftEyeOffset'] = struct.unpack('I', storyfile.read(4))[0] |
48 |
| -SNXROM['rightEyeOffset'] = struct.unpack('I', storyfile.read(4))[0] |
49 | 37 |
|
50 | 38 |
|
51 |
| -print("Metadata offset: %d bytes, address 0x%0X" % (SNXROM['metaOffset'], SNXROM['metaOffset'])) |
52 |
| -print("Left Eye offset: %d bytes, address 0x%0X" % (SNXROM['leftEyeOffset'], SNXROM['leftEyeOffset'])) |
53 |
| -print("Right Eye offset: %d bytes, address 0x%0X" % (SNXROM['rightEyeOffset'], SNXROM['rightEyeOffset'])) |
54 |
| -print("Audio data offset: %d bytes, address 0x%0X" % (SNXROM['audioOffset'], SNXROM['audioOffset'])) |
55 |
| -
|
56 |
| -print(storyfile.tell()) |
57 |
| -
|
58 | 39 | # Go to the metadata table
|
| 40 | +SNXROM['metaOffset'] = assetTablePointers[0] |
59 | 41 | storyfile.seek(SNXROM['metaOffset'])
|
60 | 42 |
|
61 | 43 | if 0x0000 != struct.unpack('h', storyfile.read(2))[0]:
|
|
73 | 55 |
|
74 | 56 | SNXROM['ROMfilesize'] = struct.unpack('i', storyfile.read(4))[0]
|
75 | 57 | print(SNXROM['ROMfilesize'])
|
| 58 | + |
| 59 | +############## |
| 60 | + |
| 61 | +SNXROM['audioOffset'] = assetTablePointers[-1] |
| 62 | + |
| 63 | +# verify audio offset |
| 64 | +print("Looking for audio at", hex(SNXROM['audioOffset'])) |
| 65 | +storyfile.seek(SNXROM['audioOffset']) |
| 66 | + |
| 67 | +if "AU" != storyfile.read(2).decode('utf-8'): |
| 68 | + raise RuntimeError("Didn't find AU at beginning of audio") |
| 69 | +print("Found beginning of audio") |
| 70 | +(samplerate, bitrate, channels, frame_count, file_len, mark_flag, silence_flag, \ |
| 71 | + mbf, pcs, rec, header_len) = \ |
| 72 | + struct.unpack('<HHHIIHHHHHH', storyfile.read(26)) |
| 73 | + |
| 74 | +print("Header Size (16b words):", hex(header_len)) |
| 75 | + |
| 76 | +print("Samplerate:", samplerate) |
| 77 | +print("Bitrate:", bitrate) |
| 78 | +print("Channels:", channels) |
| 79 | +print("Frame count:", frame_count) |
| 80 | +print("File len (16b words):", file_len) |
| 81 | +if (file_len * 2) / 80 != frame_count: |
| 82 | + print("Should be %d frames * 80 bytes per frame = %d total size" % (frame_count, file_len*2)) |
| 83 | +print("Mark flag:", mark_flag) |
| 84 | +print("Silence flag:", silence_flag) |
| 85 | +print("Header Size (16b words):", header_len) |
| 86 | + |
| 87 | +#print(storyfile.tell() - SNXROM['audioOffset']) |
| 88 | + |
| 89 | +# toss 0xFFFFFFFF |
| 90 | +storyfile.read(4) |
| 91 | + |
| 92 | +table_size = struct.unpack('<H', storyfile.read(2))[0] |
| 93 | +#print(table_size * 2) |
| 94 | +mark_entries = header_len*2 - (storyfile.tell() - SNXROM['audioOffset']) - 4 |
| 95 | +print("entries:", mark_entries) |
| 96 | + |
| 97 | +marktable = [] |
| 98 | +for i in range(mark_entries // 2): |
| 99 | + marktable.append(struct.unpack('<H', storyfile.read(2))[0]) |
| 100 | +totaltime = 0; |
| 101 | +for i in range(len(marktable) // 2): |
| 102 | + totaltime+=marktable[2*i+0] |
| 103 | + print(marktable[2*i+0], marktable[2*i+1]) |
| 104 | +print("total length of motion mark table (s):", totaltime / 1000.0) |
| 105 | + |
| 106 | +print("Actual audio data starts at", hex(SNXROM['audioOffset'] + header_len*2)) |
| 107 | +print("and ends at ", hex(SNXROM['audioOffset'] + header_len*2 + file_len*2)) |
| 108 | +""" |
| 109 | +
|
| 110 | +
|
| 111 | +
|
| 112 | +SNXROM['leftEyeOffset'] = struct.unpack('I', storyfile.read(4))[0] |
| 113 | +SNXROM['rightEyeOffset'] = struct.unpack('I', storyfile.read(4))[0] |
| 114 | +
|
| 115 | +
|
| 116 | +print("Metadata offset: %d bytes, address 0x%0X" % (SNXROM['metaOffset'], SNXROM['metaOffset'])) |
| 117 | +
|
| 118 | +print("Left Eye offset: %d bytes, address 0x%0X" % (SNXROM['leftEyeOffset'], SNXROM['leftEyeOffset'])) |
| 119 | +print("Right Eye offset: %d bytes, address 0x%0X" % (SNXROM['rightEyeOffset'], SNXROM['rightEyeOffset'])) |
| 120 | +print("Audio data offset: %d bytes, address 0x%0X" % (SNXROM['audioOffset'], SNXROM['audioOffset'])) |
| 121 | +
|
| 122 | +print(storyfile.tell()) |
| 123 | +
|
76 | 124 | """
|
0 commit comments