nesi 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env python
  2. '''
  3. The nesi executable can analyze a .nes rom image for information. In
  4. particular, nesi will extract the following:
  5. 1. ROM Header (16 bytes)
  6. 2. Mapper information
  7. 3. PRG, CHR size info
  8. 4. Example ROMs similar to this one (useful for emulator testing)
  9. 5. Battery, Mirroring, VRAM, and Trainer information
  10. 6. If bytes 7-15 appear valid or not
  11. '''
  12. # Import all standard library modules
  13. from __future__ import print_function
  14. import argparse
  15. # Import all nesi modules
  16. from nes import rom
  17. def main():
  18. '''
  19. The main entry point for nesi. The entry point should parse command
  20. line arguments and delegate all work to the nes module.
  21. '''
  22. parser = argparse.ArgumentParser(
  23. description='Specify a .nes rom image to be analyzed'
  24. )
  25. parser.add_argument(
  26. '-r',
  27. '--rom',
  28. help='path to a .nes rom image to be analyzed',
  29. type=str
  30. )
  31. parser.add_argument(
  32. '-v',
  33. '--version',
  34. help='show the current nesi version',
  35. action='store_true'
  36. )
  37. args = parser.parse_args()
  38. if args.rom:
  39. rom.NesRom(args.rom).print_analysis()
  40. elif args.version:
  41. print(rom.nesi_information())
  42. else:
  43. parser.print_help()
  44. if __name__ == '__main__':
  45. main()
  46. # vim: ai tabstop=4 expandtab shiftwidth=4 softtabstop=4 ft=python