Advertisement
nonogamer9

NumPY-8 Rom Converter

Feb 6th, 2025
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | Software | 0 0
  1. import sys
  2.  
  3. def convert_rom(input_file):
  4.     with open(input_file, 'rb') as f:
  5.         rom_data = f.read()
  6.    
  7.     converted_data = [f"0x{byte:02X}" for byte in rom_data]
  8.    
  9.     print("rom_data = [")
  10.     for i in range(0, len(converted_data), 16):
  11.         print("    " + ", ".join(converted_data[i:i+16]) + ",")
  12.     print("]")
  13.  
  14. if __name__ == "__main__":
  15.     if len(sys.argv) != 2:
  16.         print("Usage: python rom_converter.py <input_rom.ch8>")
  17.         sys.exit(1)
  18.    
  19.     input_file = sys.argv[1]
  20.     convert_rom(input_file)
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement