Skip to content

Instantly share code, notes, and snippets.

@bbayles
Created January 8, 2024 11:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbayles/19dbd537d1f912847a52daf6701edd09 to your computer and use it in GitHub Desktop.
Save bbayles/19dbd537d1f912847a52daf6701edd09 to your computer and use it in GitHub Desktop.
Compare memory snapshots
from pathlib import Path
all_befores = [
'C:/Games/Mednafen/before_1.bin',
'C:/Games/Mednafen/before_2.bin',
# ...
]
all_afters = [
'C:/Games/Mednafen/after_1.bin',
'C:/Games/Mednafen/after_2.bin',
# ...
]
before_data = [Path(x).read_bytes() for x in all_befores]
after_data = [Path(x).read_bytes() for x in all_afters]
size = len(before_data[0])
for i in range(size):
before_byte = before_data[0][i]
after_byte = after_data[0][i]
if before_byte == after_byte:
continue
if not all(data[i] == before_byte for data in before_data):
continue
if not all(data[i] == after_byte for data in after_data):
continue
print(
format(i, '08x'),
format(before_byte, '02x'),
format(after_byte, '02x'),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment