Advertisement
ErnstHot

Extract and plot data from Vice C64 snapshots

Aug 15th, 2023 (edited)
1,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. ###############################################################################
  2. ###  Extract and plot data from Vice C64 snapshots                          ###
  3. ###############################################################################
  4.  
  5. import matplotlib.pyplot as plt
  6.  
  7. Filename            = "../vice-snapshot.vsf"
  8. DataIndex           = 0x1000
  9. NumberOfEntries     = 128
  10. WordLengthInBytes   = 2
  11. DataSizeInBytes     = NumberOfEntries * WordLengthInBytes
  12. IsSigned            = True
  13.  
  14. with open(Filename, 'rb') as f:
  15.     viceSnapshot = f.read()
  16.  
  17. # Extract data from dump
  18. C64MEMStringIndex = viceSnapshot.find(b'C64MEM')
  19. RAMDumpIndex = C64MEMStringIndex + 26
  20. RAMDump = viceSnapshot[RAMDumpIndex:RAMDumpIndex + pow(2, 16)]
  21. data = RAMDump[DataIndex:DataIndex + DataSizeInBytes]
  22.  
  23. # Extract integers from data
  24. data = [int.from_bytes(data[i : i + WordLengthInBytes], byteorder = 'little', signed = IsSigned)\
  25.     for i in range(0, len(data), WordLengthInBytes)]
  26.  
  27. plt.plot(data)
  28. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement