#include #include #define NO 0 #define YES 1 extern struct IOAudio *ioa,*audchan[4],*finish[4]; extern SHORT audiochan[128]; extern SHORT waiting[5]; /************************************************************/ VOID SoundOn(SHORT key,UBYTE *ws) /* Start a sound channel */ { UWORD tone; UWORD periods[16]={452, 428, 404, 381, 359, 339, 320, 302, 285, 269, 254, 240, 226, 214, 202, 190}; SHORT channo,FreeChan(); switch (key) { case 0x31: {tone=periods[0]; break;} case 0x32: {tone=periods[1]; break;} case 0x22: {tone=periods[2]; break;} case 0x33: {tone=periods[3]; break;} case 0x23: {tone=periods[4]; break;} case 0x34: {tone=periods[5]; break;} case 0x35: {tone=periods[6]; break;} case 0x25: {tone=periods[7]; break;} case 0x36: {tone=periods[8]; break;} case 0x26: {tone=periods[9]; break;} case 0x37: {tone=periods[10]; break;} case 0x27: {tone=periods[11]; break;} case 0x38: {tone=periods[12]; break;} case 0x39: {tone=periods[13]; break;} case 0x29: {tone=periods[14]; break;} case 0x3A: {tone=periods[15]; break;} default: tone=0; } if (((channo = FreeChan())<4)&(key<64)) { audchan[channo]->ioa_Period=tone; if(tone==0) audchan[channo]->ioa_Volume=0; else audchan[channo]->ioa_Volume=64; audchan[channo]->ioa_Data=(UBYTE *)ws; audiochan[key]=channo; WaitIO(audchan[channo]); BeginIO(audchan[channo]); } } /************************************************************/ VOID SoundOff(SHORT key) /* Stop a sound channel */ { SHORT channo; channo = audiochan[key]; audiochan[key]=-1; if ((channo>=0)&(key<64)) { BeginIO(finish[channo]); WaitIO(finish[channo]); waiting[channo]=NO; } } /************************************************************/ SHORT FreeChan() /* Finds the first unused audio channel */ { SHORT i; i=0; while ((waiting[i]==YES)&&(i<4)) i++; waiting[i]=YES; return(i); }