home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
120.lha
/
Muncho2
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-11-21
|
2KB
|
127 lines
#include <exec/types.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <lattice/stdio.h>
#include <lattice/math.h>
#include <graphics/gfxbase.h>
#include <graphics/rastport.h>
#include <intuition/intuition.h>
#include "soundobj.h"
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
static struct NewWindow New_Window = {
0, 12,
128, 10, /* width & height */
-1, -1, /* Default pens */
CLOSEWINDOW /* IDCMP flags */
| DISKINSERTED
| DISKREMOVED,
WINDOWCLOSE
| SMART_REFRESH
| WINDOWDRAG,
(struct Gadget *) NULL,
(struct Image *) NULL,
(UBYTE *)"Disk Sounds",
(struct Screen *) NULL,
(struct BitMap *) NULL,
10, 17, 640, 400,
WBENCHSCREEN /* Of course! */
};
main(argc,argv)
int argc;
char *argv[];
{
struct IntuiMessage *GetMsg();
struct IntuiMessage *msg_;
struct Window *OpenWindow();
struct Window *w_ = NULL;
struct SOUNDOBJ *sin_ = NULL;
struct SOUNDOBJ *sout_ = NULL;
int signal;
ULONG msgClass;
/*
Open libraries:
===============*/
if(!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0))){
exit(1);
}
if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0))){
CloseLibrary(GfxBase);
exit(1);
}
if(audio_init()){
goto l_exit;
}
/*
Open a window:
==============*/
if(!(w_=OpenWindow(&New_Window))){
CloseLibrary(GfxBase);
CloseLibrary(IntuitionBase);
exit(3);
}
/*
Load sounds:
============*/
if(argc != 3){
if(!(sin_=SOCreate("crunch"))){
goto l_exit;
}
if(!(sout_=SOCreate("sneeze"))){
goto l_exit;
}
}
else{
if(!(sin_=SOCreate(argv[1]))){
goto l_exit;
}
if(!(sout_=SOCreate(argv[2]))){
goto l_exit;
}
}
/*
Wait for messages:
==================*/
while(1){
msgClass = 0x0;
signal = Wait(1 << w_->UserPort->mp_SigBit);
while(msg_=GetMsg(w_->UserPort)){
msgClass |= msg_->Class;
ReplyMsg(msg_);
}
if(msgClass & DISKINSERTED){
SOSound(sin_);
}
if(msgClass & DISKREMOVED){
SOSound(sout_);
}
if(msgClass & CLOSEWINDOW){
break;
}
}
/*
Exit:
=====*/
l_exit:
audio_close();
if(sin_){
SODelete(sin_);
}
if(sout_){
SODelete(sout_);
}
if(w_){
CloseWindow(w_);
}
CloseLibrary(GfxBase);
CloseLibrary(IntuitionBase);
exit(0);
}