"""Guarded native pwrplay clear correction."""
ORIGIN=0x2DCC00
def install(data,assemble,patch,with_refinements=False):
    code=assemble('pwrplay_clear',ORIGIN)
    assert 0<len(code)<0x400,'helper exceeds reserved ROM block'
    patch(ORIGIN,b'\xff'*len(code),code)
    patch(0x12B32,bytes.fromhex('08b80005c2ee'),b'\x4e\xf9'+ORIGIN.to_bytes(4,'big'))
    if with_refinements:
        patch(0x12ACC,bytes.fromhex('08f80005c2ee'),b'\x4e\xf9'+(ORIGIN+4).to_bytes(4,'big'))
