Advertisement
zeromega64twenty

SNES Rom Hex Viewer (WIP)

Aug 27th, 2023 (edited)
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | Gaming | 0 0
  1. def hex_viewer(file_path, chunk_size=16):
  2.     with open(file_path, "rb") as file:
  3.         offset = 0
  4.         while True:
  5.             chunk = file.read(chunk_size)
  6.             if not chunk:
  7.                 break
  8.            
  9.             hex_chunk = ' '.join(format(byte, '02X') for byte in chunk)
  10.             ascii_chunk = ''.join(chr(byte) if 32 <= byte < 127 else '.' for byte in chunk)
  11.            
  12.             print(f"{offset:08X} | {hex_chunk:<48} | {ascii_chunk}")
  13.             offset += chunk_size
  14.  
  15. if __name__ == "__main__":
  16.     rom_path = "rom.smc" #Add your rom to the directory and change filename
  17.     hex_viewer(rom_path)
  18. """
  19. Copyright (c) 2023 Zeromega
  20. Drop a link or a Sub on one of my videos if this script help you, copy the link below
  21. https://www.youtube.com/channel/UCfqUJ4rmk6W-ZAjDtkBZ1CA?sub_confirmation=1
  22. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement