Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###############################################################################
- ### Extract and plot data from Vice C64 snapshots ###
- ###############################################################################
- import matplotlib.pyplot as plt
- Filename = "../vice-snapshot.vsf"
- DataIndex = 0x1000
- NumberOfEntries = 128
- WordLengthInBytes = 2
- DataSizeInBytes = NumberOfEntries * WordLengthInBytes
- IsSigned = True
- with open(Filename, 'rb') as f:
- viceSnapshot = f.read()
- # Extract data from dump
- C64MEMStringIndex = viceSnapshot.find(b'C64MEM')
- RAMDumpIndex = C64MEMStringIndex + 26
- RAMDump = viceSnapshot[RAMDumpIndex:RAMDumpIndex + pow(2, 16)]
- data = RAMDump[DataIndex:DataIndex + DataSizeInBytes]
- # Extract integers from data
- data = [int.from_bytes(data[i : i + WordLengthInBytes], byteorder = 'little', signed = IsSigned)\
- for i in range(0, len(data), WordLengthInBytes)]
- plt.plot(data)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement