30 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
| import Utils
 | |
| from Patch import read_rom
 | |
| 
 | |
| JAP10HASH = '21f3e98df4780ee1c667b84e57d88675'
 | |
| 
 | |
| import hashlib
 | |
| import os
 | |
| 
 | |
| 
 | |
| def get_base_rom_bytes(file_name: str = "") -> bytes:
 | |
|     base_rom_bytes = getattr(get_base_rom_bytes, "base_rom_bytes", None)
 | |
|     if not base_rom_bytes:
 | |
|         file_name = get_base_rom_path(file_name)
 | |
|         base_rom_bytes = bytes(read_rom(open(file_name, "rb")))
 | |
| 
 | |
|         basemd5 = hashlib.md5()
 | |
|         basemd5.update(base_rom_bytes)
 | |
|         if JAP10HASH != basemd5.hexdigest():
 | |
|             raise Exception('Supplied Base Rom does not match known MD5 for JAP(1.0) release. '
 | |
|                             'Get the correct game and version, then dump it')
 | |
|         get_base_rom_bytes.base_rom_bytes = base_rom_bytes
 | |
|     return base_rom_bytes
 | |
| 
 | |
| def get_base_rom_path(file_name: str = "") -> str:
 | |
|     options = Utils.get_options()
 | |
|     if not file_name:
 | |
|         file_name = options["sm_options"]["rom_file"]
 | |
|     if not os.path.exists(file_name):
 | |
|         file_name = Utils.local_path(file_name)
 | |
|     return file_name |