#define DELAY_TO_HZ(x)	((0xb600*0x1c)/x)
static void play_bell_sound();
static void play_dupe_sound();
static void play_message_sound();
static void play_band_change_sound();
static void play_single_mult_sound();
static void play_double_mult_sound();
static void play_bad_call_sound();
static void play_bad_key_sound();
static void play_speed_change_sound();

static void bsd_play_bells(int isound)
{
  switch(isound)
    {
    case BELL_SOUND :
     play_bell_sound ();
     break;
    case DUPE_SOUND :
     play_dupe_sound ();
     break;
    case MESSAGE_SOUND :
     play_message_sound ();
     break;
    case BAND_CHANGE_SOUND :
     play_band_change_sound ();
     break;
    case SINGLE_MULT_SOUND :
     play_single_mult_sound ();
     break;
    case DOUBLE_MULT_SOUND :
     play_double_mult_sound ();
     break;
    case BAD_CALL_SOUND :
     play_bad_call_sound ();
     break;
    case BAD_KEY_SOUND :
     play_bad_key_sound ();
     break;
    case SPEED_CHANGE_SOUND :
     play_speed_change_sound ();
     break;
    default:
     break;
    }
}

static void play_bell_sound()
{
  tone_t tones;

  tones.frequency = DELAY_TO_HZ(0x474);
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
}

static void play_dupe_sound()
{
  tone_t tones;

  tones.frequency = DELAY_TO_HZ(0xfe0);
  tones.duration = 12;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = DELAY_TO_HZ(0x17c8);
  tones.duration = 12;
  ioctl(fd_bells, SPKRTONE, &tones);
}

static void play_message_sound()
{
  tone_t tones;

  tones.frequency = DELAY_TO_HZ(0xd58);
  tones.duration = 12;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = DELAY_TO_HZ(0x8e8);
  tones.duration = 12;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = DELAY_TO_HZ(0xd58);
  tones.duration = 12;
  ioctl(fd_bells, SPKRTONE, &tones);
}

static void play_band_change_sound()
{
  tone_t tones;

  tones.frequency = DELAY_TO_HZ(0x710);
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = 0;
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = DELAY_TO_HZ(0x710);
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = 0;
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = DELAY_TO_HZ(0x710);
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
}

static void play_single_mult_sound()
{
  tone_t tones;

  tones.frequency = DELAY_TO_HZ(0x8e8);
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = DELAY_TO_HZ(0x6ac);
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
}

static void play_double_mult_sound()
{
  tone_t tones;

  tones.frequency = DELAY_TO_HZ(0x8e8);
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = DELAY_TO_HZ(0x6ac);
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = 0;
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = DELAY_TO_HZ(0x8e8);
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
  tones.frequency = DELAY_TO_HZ(0x6ac);
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
}

static void play_bad_call_sound()
{
  tone_t tones;

  tones.frequency = DELAY_TO_HZ(0x11d0);
  tones.duration = 38;
  ioctl(fd_bells, SPKRTONE, &tones);
}

static void play_bad_key_sound()
{
  tone_t tones;

  tones.frequency = DELAY_TO_HZ(0x17cc);
  tones.duration = 42;
  ioctl(fd_bells, SPKRTONE, &tones);
}

static void play_speed_change_sound()
{
  tone_t tones;

  tones.frequency = DELAY_TO_HZ(0x710);
  tones.duration = 6;
  ioctl(fd_bells, SPKRTONE, &tones);
}

