Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- iNesHeader = [0x4e, 0x45, 0x53, 0x1A, 0x10, 0x10, 0x50, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
- counter = 0
- def extract(file, offset):
- print('Found ROM at offset %s' % (hex(offset)))
- print('Writing ROM to TRICK.nes...')
- file.seek(offset)
- with open('TRICK.nes', 'wb') as out:
- for i in range(0, 385):
- out.write(f.read(1024))
- print('Done')
- with open('TRICK.DMP', 'rb') as f:
- print('Searching for the ROM in TRICK.DMP')
- offset = 0x0
- while (bytes := f.read(128)):
- offsetoffset = 0
- for byte in list(bytes):
- if(iNesHeader[counter] == byte):
- counter += 1
- if(counter == len(iNesHeader)):
- extract(f, offset + offsetoffset - counter + 1)
- quit()
- else:
- if(0 < counter):
- counter = 0
- offsetoffset += 1
- offset = f.tell()
- print('Could not find ROM in TRICK.DMP')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement