/*******************************/
/*                             */
/* RISC User C library         */
/* Alt key and Sound functions */
/* by Lee Calcraft             */
/*                             */
/*******************************/

#include "wimpt.h"
#include "os.h"

#define OS_Byte               6
#define Sound_Control   0x40189

BOOL akbd_pollalt(void);
void lo_blip(void);
void hi_blip(void);
void lo_sound(void);
void hi_sound(void);
void sound(int vol,int pitch,int duration);


BOOL akbd_pollalt(void)
/* check for the Alt key */
{
  int r2;
  wimpt_complain(os_swi3r(OS_Byte,0x81,-3,0xff,0,0,&r2));
  if (r2) return 1;
  return 0;
}

void lo_blip(void)
/* pitch 70 duration 1 */
{
  sound(0x1ff,70,1);
}

void hi_blip(void)
/* pitch 200 duration 1 */
{
  sound(0x1ff,200,1);
}

void lo_sound(void)
/* pitch 70 duration 5 */
{
  sound(0x1ff,70,5);
}

void hi_sound(void)
/* pitch 200 duration 5 */
{
  sound(0x1ff,200,5);
}

void sound(int vol,int pitch,int duration)
/* generate a sound
 * uses chan 1, Vol is 0x100 to 0x1ff
 * pitch is 0 to 0xff, duration is in 5csec units
 */
{
  wimpt_complain(os_swi4(Sound_Control,1,vol,pitch,duration));
}
