"""Main-menu lifetime, exact faster checksums and local directional repeat."""
ORIGIN=0x25C000
def install(data,assemble,patch):
 code=assemble('main_menu',ORIGIN)
 assert len(code)==0xA00 and code[16:20]==b'MM01'
 patch(ORIGIN,b'\xff'*len(code),code)
 for at,old,new in [
  (0xF739E,'4eb9000fe660','4eb90025c000'),
  (0xF843E,'4ef9002e6000','4ef90025c004'),
  (0x2340AA,'d0c7343cffff','4ef90025c008'),
  (0x256250,'41f90020a000','4ef90025c00c'),
  (0x17C62,'5278b03e4eb90001a50a','4ef90025c0184e714e71'),
  (0x2AA698,'d010548851c9fffa','4eb90025c01c4e71'),
  (0x2AA6F2,'d010548851c9fffa','4eb90025c01c4e71')]:patch(at,bytes.fromhex(old),bytes.fromhex(new))
 for at in [0x22013E,0x221460,0x222432,0x223402,0x224184,0x22609C,0x2DE1C0,0x2DE50A,0x2DE74A,0x2E6D52,0x2E84CC,0x2EB252,0x2EB7CA]:
  patch(at,bytes.fromhex('d010548851c9fffa'),bytes.fromhex('4eb90025c01c4e71'))
 for at in [0x2AA562,0x2AA57C]:
  patch(at,bytes.fromhex('12905488548951c8fff8'),bytes.fromhex('4eb90025c0204e714e71'))
 for at in [0x25604C,0x25609E]:
  patch(at,bytes.fromhex('12905488548951cafff8'),bytes.fromhex('4eb90025c0244e714e71'))
 patch(0x2AA434,bytes.fromhex('4210548851c8fffa'),bytes.fromhex('4eb90025c0284e71'))
 for at in [0xF832C,0xF835C,0xF8384,0xF83A4]:
  patch(at,bytes.fromhex('4eb900011318'),bytes.fromhex('4eb90025c014'))
