rem: AHIA_PlayerFreq, 100 << 16 );
add: AHIA_PlayerFreq, 100 << 16, TAG_DONE );
context: InstallPUH( ULONG           flags,            ULONG           audio_mode,            ULONG           frequency,            struct PUHData* pd ){  BOOL ahi_ok = FALSE;  pd->m_Flags     = flags;  pd->m_AudioMode = audio_mode;  // Activate AHI  pd->m_AudioCtrl = AHI_AllocAudio( AHIA_AudioID,    audio_mode,                                    AHIA_MixFreq,    frequency,                                    AHIA_Channels,   4,                                    AHIA_Sounds,     1,                                    AHIA_SoundFunc,  (ULONG) &pd->m_SoundFunc,                                    AHIA_PlayerFreq, 100 << 16 );  if( pd->m_AudioCtrl == NULL )  {    printf( "Unable to allocate audio mode $%08lx.\n", audio_mode );  }  else  {    struct AHISampleInfo si =     {      AHIST_M8S,   // An 8-bit sample      0,           // beginning at address 0      0xffffffff   // and ending at the last address.    };        if( AHI_LoadSound( 0, AHIST_DYNAMICSAMPLE, &si, pd->m_AudioCtrl ) != AHIE_OK )    {      printf( "Unable to load dynamic sample.\n" );    }    else    {      if( AHI_ControlAudio( pd->m_AudioCtrl, AHIC_Play, TRUE ) != AHIE_OK )      {        printf( "Unable to start playback.\n" );      }      else      {        ahi_ok = TRUE;      }    }  }  if( ! ahi_ok )  {    // Clean up    UninstallPUH( pd );    return FALSE;  }  // Activate MMU  pd->m_UserException =       AddContextHook( MADTAG_CONTEXT, (ULONG) pd->m_UserContext,                      MADTAG_TYPE,    MMUEH_SEGFAULT,                      MADTAG_CODE,    (ULONG) PUHHandler,                      MADTAG_DATA,    (ULONG) pd,                      MADTAG_PRI,     127,                      TAG_DONE );  if( pd->m_UserException == NULL )  {    printf( "Unable to install user context hook.\n" );  }  else  {    pd->m_SuperException =        AddContextHook( MADTAG_CONTEXT, (ULONG) pd->m_SuperContext,                        MADTAG_TYPE,    MMUEH_SEGFAULT,                        MADTAG_CODE,    (ULONG) PUHHandler,                        MADTAG_DATA,    (ULONG) pd,                        MADTAG_PRI,     127,                        TAG_DONE );    if( pd->m_SuperException == NULL )    {      printf( "Unable to install supervisor context hook.\n" );    }    else    {      ActivateException( pd->m_UserException );      ActivateException( pd->m_SuperException );      // Are we supposed to patch the ROM?      if( flags & PUHF_PATCH_ROM )      {        pd->m_ROMShadowBuffer = AllocAligned( pd->m_ROMSize,                                              MEMF_PUBLIC | MEMF_FAST,                                              RemapSize( pd->m_UserContext  ) );               if( pd->m_ROMShadowBuffer == NULL )        {          printf( "Out of memory!\n" );        }        else        {          CopyMemQuick( pd->m_ROM, pd->m_ROMShadowBuffer, pd->m_ROMSize );          PatchROMShadowBuffer( pd );          CacheClearU();        }      }      if( ! ( flags & PUHF_PATCH_ROM ) || pd->m_ROMShadowBuffer != NULL )      {        // Re-map         if( ! RemapMemory( pd ) )        {          printf( "Unable to install remap.\n" );        }        else        {          pd->m_Active = TRUE;        }      }    }  }  if( ! pd->m_Active )  {    // Clean up    UninstallPUH( pd );  }  return pd->m_Active;}