119 lines
2.5 KiB
C
119 lines
2.5 KiB
C
/*
|
|
T_MUSFRC.C - Test the musical sound driver from the Frc
|
|
|
|
Written by John, April 1992
|
|
*/
|
|
|
|
#include <plib.h>
|
|
|
|
/* all are 1 sec duration by default */
|
|
LOCAL_D UBYTE notes[] = {
|
|
/* Basic note numbers */
|
|
0x30,
|
|
0x31,
|
|
0x32,
|
|
0x33,
|
|
0x34,
|
|
0x35,
|
|
0x36,
|
|
0x37,
|
|
0x38,
|
|
0x39,
|
|
0x3a,
|
|
0x29,
|
|
0x3b,
|
|
0x3c,
|
|
0x3d,
|
|
0x0e,
|
|
0x3e,
|
|
0x2c,
|
|
0x3f,
|
|
0x04,
|
|
0x05,
|
|
0x25,
|
|
0x2f,
|
|
0x06,
|
|
0x07
|
|
};
|
|
|
|
LOCAL_D WORD volume=0; /* volume to use */
|
|
LOCAL_D WORD length=100; /* length of notes */
|
|
|
|
LOCAL_C VOID panic(
|
|
INT num,
|
|
INT errno)
|
|
{
|
|
TEXT b[100];
|
|
|
|
p_errs(&b[p_atob(&b[0],"panic num %d - ",&num)],errno);
|
|
t_panic(&b[0]);
|
|
}
|
|
|
|
GLDEF_C main(VOID)
|
|
{
|
|
INT ret,i;
|
|
VOID *pcb;
|
|
UBYTE bb[100],*p;
|
|
|
|
p_loadldd("SNDFRC.LDD");
|
|
if (ret=p_open(&pcb,"MUS:",-1))
|
|
panic(2,ret);
|
|
p_puts("Musical notes tester - ? for help");
|
|
FOREVER
|
|
{
|
|
p_print("Next>");
|
|
p_gets(p=(&bb[0]));
|
|
p=p_skipwh(p);
|
|
if (!*p)
|
|
continue;
|
|
switch (p_toupper(*p++))
|
|
{
|
|
case '?':
|
|
p_puts("Q - Quit");
|
|
p_puts("V<vol> - Volume 0-3");
|
|
p_puts("L<len> - Length 0-256");
|
|
p_puts("P - Play scale");
|
|
break;
|
|
case 'Q': /* Quit */
|
|
p_close(pcb);
|
|
if (ret=p_devdel("MUS",E_LDD))
|
|
panic(7,ret);
|
|
return(0);
|
|
case 'V': /* Volume */
|
|
if (p_stoi(&p,&volume)<0)
|
|
volume=0;
|
|
if (volume<0 || volume>3)
|
|
volume=0;
|
|
break;
|
|
case 'L': /* Length */
|
|
if (p_stoi(&p,&length)<0)
|
|
length=100;
|
|
if (length<0 || length>256)
|
|
length=100;
|
|
break;
|
|
case 'P': /* play that lot */
|
|
for (i=0;i<sizeof(notes);i++)
|
|
{
|
|
bb[i<<1]=notes[i]|(volume<<6);
|
|
bb[(i<<1)+1]=length;
|
|
}
|
|
p_write(pcb,&bb[0],sizeof(notes));
|
|
break;
|
|
case '0':
|
|
case '1':
|
|
case '2':
|
|
case '3':
|
|
case '4':
|
|
case '5':
|
|
case '6':
|
|
case '7':
|
|
case '8':
|
|
case '9':
|
|
bb[0]=notes[((*(p-1))-'0')<<1]|(volume<<6);
|
|
bb[1]=length;
|
|
p_write(pcb,&bb[0],1);
|
|
break;
|
|
}
|
|
}
|
|
}
|