home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. CD ROM (Annual Premium Edition)
/
premium.zip
/
premium
/
MUSICLAB
/
SOUNDZZ.ZIP
/
SOUNDZZ.C
next >
Wrap
Text File
|
1989-07-20
|
5KB
|
332 lines
/* SOUNDZZ.C
Written by: Tom Grubbe
Date: 07/19/89
This little program was written in Turbo C 2.0 but will also
compile in version 1.5. It uses no external routines other than the
Turbo runtime library functions and the functions contained in here.
This was by no means a difficult program to write (it took less
than an hour), so feel free to modify, hack, share, or anything else
you wish to do with it. It's just here for fun. So have some...
*/
#include <stdio.h>
#include <dos.h>
#include <stdlib.h>
#include <conio.h>
void Menu(void);
void Highlight(int y, int c);
void Cursor(int x, int y);
void Boxx(int x, int y, int xx, int yy);
void Quit(void);
void FryEgg(void);
void LoNoise(void);
void WhiteNoise(void);
void Chopper(void);
void Zombies(void);
void Whoopie(void);
void Phone(void);
void Crash(void);
void Jungle(void);
char *SndMnu[] = {
" Fried Egg ",
" Low noise ",
" White Noise ",
" Chopper ",
" Zombies ",
" Whoopie ",
" Phone ",
" Crash ",
" Jungle ",
" Exit "
};
void main()
{
int Y=5;
clrscr();
Menu();
HighLight(Y, 1);
for (;;) {
HighLight(Y, 1);
Cursor(0,26); /* Hide cursor */
switch (getch()) {
case 72 : /* UP */
HighLight(Y, 0);
if (--Y < 5) Y = 14;
break;
case 80 : /* DN */
HighLight(Y, 0);
if (++Y > 14) Y = 5;
break;
case 13 : /* CR */
switch (Y) {
case 5 : FryEgg(); break;
case 6 : LoNoise(); break;
case 7 : WhiteNoise(); break;
case 8 : Chopper(); break;
case 9 : Zombies(); break;
case 10 : Whoopie(); break;
case 11 : Phone(); break;
case 12 : Crash(); break;
case 13 : Jungle(); break;
case 14 : Quit();
}
break;
case 27 : /* ESC */
case 'q': Quit();
}
}
}
void Menu()
{
int x, y;
register int i;
x = 34; y = 5;
clrscr();
Boxx(33,4,47,15);
for (i=0; i<10; i++, y++) {
Cursor(x, y); cprintf(SndMnu[i]);
}
}
void Highlight(int y, int c)
{
switch (c) {
case 0 : textattr(0x07); break;
case 1 : textattr(0x70); break;
}
Cursor(34,y);
cprintf(SndMnu[y-5]);
}
void Cursor(int x, int y)
{
union REGS r;
r.h.bh = 0;
r.h.dl = x;
r.h.dh = y;
r.h.ah = 2; /* BIOS set cursor pos. */
int86(0x10, &r, &r);
}
void Boxx(int x, int y, int xx, int yy)
{
register int i;
for (i=x+1; i<xx; i++) {
Cursor(i,y); putchar(196);
Cursor(i,yy); putchar(196);
}
for (i=y+1; i<yy; i++) {
Cursor(x,i); putchar(179);
Cursor(xx,i); putchar(179);
}
Cursor(x,y); putchar(218);
Cursor(xx,y); putchar(191);
Cursor(x,yy); putchar(192);
Cursor(xx,yy);putchar(217);
}
void Quit()
{
textattr(0x07);
clrscr();
Cursor(0,0);
exit(0);
}
void FryEgg(void)
{
int i, j;
randomize();
while( !kbhit() ){
i=random(40);
j=random(70);
sound(i);
sound(i*100);
sound(j);
sound(j*100);
}
nosound();
getch();
}
void LoNoise(void)
{
int i;
while( !kbhit() ){
for( i=0 ; i<1000 ; ++i ){
if(kbhit()) break;
sound(66000);
sound(78000);
sound(98000);
delay(random(10));
}
}
nosound();
getch();
}
void WhiteNoise(void)
{
int i, j;
randomize();
while( !kbhit() ){
for( i=0 ; i<1000 ; ++i ){
if(kbhit()) break;
j = random(4);
sound(100);
delay(j);
sound(92000);
delay(random(10));
}
}
nosound();
getch();
}
void Chopper(void)
{
int i, j, k;
randomize();
while( !kbhit() ) {
nosound();
delay(60);
for( i=1000, j=1050 ; j>50 ; i+=200, j-=100, ++i, --j ) {
if( kbhit() ) break;
k = random(4);
sound(j);
delay(k);
sound(i*10);
}
}
nosound();
getch();
}
void Zombies(void)
{
int i, j, k;
randomize();
while( !kbhit() ){
for( i=1000, j=20 ; j<1000 ; --i, ++j ) {
if(kbhit()) break;
k=random(3);
sound(i);
delay(k);
sound(j);
delay(k);
}
}
nosound();
getch();
}
void Whoopie(void)
{
int i, j, k;
randomize();
for( i=20, j=120 ; j<16000 ; i+=20, j+=20, ++i, ++j ) {
if(kbhit()) break;
k = random(4);
sound(j);
delay(k);
sound(i);
}
for( i=15000, j=16000 ; j>120 ; i-=20, j-=20, --i, --j ) {
if(kbhit()) break;
k = random(4);
sound(j);
delay(k);
sound(i);
}
sound(120);
sound(20);
delay(30);
nosound();
}
void Phone(void)
{
int i, k;
randomize();
while( !kbhit() ) {
for( i=1 ; i<62 ; ++i ) {
if(kbhit()) break;
sound(1500);
delay(15);
sound(600);
delay(10);
nosound();
delay(20);
}
nosound();
for( i=1 ; i<2500 ; ++i )
if(kbhit()) break;
}
nosound();
getch();
}
void Crash(void)
{
int i, j, k;
randomize();
for( i=8031, j=8000 ; j>1 ; i-=.5, j-=2, --i, --j ) {
if(kbhit()) break;
k = random(4);
sound(i);
delay(k);
sound(j);
}
nosound();
}
void Jungle(void)
{
int h, i, j, k;
int g=100, f=100;
randomize();
while(!kbhit()) {
for( i=30000,j=9000,h=7500 ; h>4500 ; j-=f,h-=g,++i,--j,--h ) {
if(kbhit()) break;
k = random(6);
g = random(200);
f = random(300);
g += 100;
f += 100;
sound(j);
delay(k);
sound(i);
delay(k);
sound(h);
delay(k);
sound(f*1000);
}
}
nosound();
getch();
}