Advertisement
Guest User

extract_gimmick

a guest
Jul 13th, 2023
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | Gaming | 0 0
  1. iNesHeader = [0x4e, 0x45, 0x53, 0x1A, 0x10, 0x10, 0x50, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
  2. counter = 0
  3.  
  4. def extract(file, offset):
  5.  print('Found ROM at offset %s' % (hex(offset)))
  6.  print('Writing ROM to TRICK.nes...')
  7.  file.seek(offset)
  8.  with open('TRICK.nes', 'wb') as out:
  9.   for i in range(0, 385):
  10.    out.write(f.read(1024))
  11.  print('Done')
  12.  
  13. with open('TRICK.DMP', 'rb') as f:
  14.  print('Searching for the ROM in TRICK.DMP')
  15.  offset = 0x0
  16.  while (bytes := f.read(128)):
  17.   offsetoffset = 0
  18.   for byte in list(bytes):
  19.    if(iNesHeader[counter] == byte):
  20.     counter += 1
  21.     if(counter == len(iNesHeader)):
  22.      extract(f, offset + offsetoffset - counter + 1)
  23.      quit()
  24.    else:
  25.     if(0 < counter):
  26.      counter = 0
  27.    offsetoffset += 1
  28.   offset = f.tell()
  29.  print('Could not find ROM in TRICK.DMP')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement