"""Automatic goal replay with the native Instant Replay (replay.s)."""
ORIGIN = 0x2E5000


def install(data, assemble, patch):
    code = assemble('replay', ORIGIN)
    assert len(code) < 0x400
    patch(ORIGIN, b'\xFF' * len(code), code)
    patch(0x7948, bytes.fromhex('610003ae60ea'), bytes.fromhex('4ef9002e5004'))
    patch(0xA41E, bytes.fromhex('4a78d04666000010'), bytes.fromhex('4ef9002e50084e71'))
