home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d158 / yachtc3.lha / YachtC3 / src / soundproc.c < prev    next >
C/C++ Source or Header  |  1988-10-02  |  3KB  |  93 lines

  1. /***
  2.  
  3.  
  4.  
  5.                soundproc.c    M.E.S.   87-12-28
  6.  
  7.                   a process for multitasking "scales"
  8.  
  9.  
  10. ***/
  11. #include "soundproc.h"
  12.  
  13. main()
  14.  {
  15.     register int  howlong;
  16.     register struct MsgPort *gimmemessagePort;
  17.     register char *words;
  18.     register ULONG what;
  19.     register ULONG class;
  20.     register UBYTE type;
  21.  
  22.     if ( !(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",0)))  return;
  23.  
  24. /*    SysBase = (struct ExecBase *)OpenLibrary("exec.library", 0);
  25.  
  26.     echo = (int)Output(); */
  27.  
  28.  
  29. /*  Allocating memory for the message "t" is done in the parent.
  30.       "sounproc" just shares this memory block temporarily.      */
  31.  
  32.    if((gimmemessagePort = CreatePort("gimme.my.message",0)) == 0)
  33.       {
  34.          printf("could not create the reply port\n");
  35.          return(0);
  36.       }
  37.  
  38.    InitIOA(); /* in bonesound.c  */
  39.  
  40.    makewaves();
  41.  
  42.    for (;;)
  43.       {
  44.          Wait( 1L << gimmemessagePort->mp_SigBit);
  45.          while( t = (struct test_message *)GetMsg(gimmemessagePort))
  46.             {
  47.                words = t->d.string;
  48.                what = t->d.function;
  49.                howlong = t->d.length;
  50.                class = t->d.flags;
  51.                type = t->d.id;
  52.                t->d.flags = IGOTMESSAGE;
  53.                ReplyMsg(t);
  54.  
  55.                if (class == TURNOFF)   /* then turn this task off */
  56.                   {
  57.                      printf("So long ......\n");
  58.                      goto cleanup;
  59.                   }
  60.  
  61.                /* check if we're already making sounds */
  62.  
  63.                if (class == VERBAGE)  /* actually this is the task */
  64.                   {
  65.                       switch(what)  /* call the function */
  66.                         {
  67.                           case DICEROLL:
  68.                                     Click(howlong);
  69.                                     break;
  70.                           case YAHSOUND:
  71.                                     YahtzeeSound(howlong);
  72.                                     break;
  73.                           case HAPPYSOUND:
  74.                                     Happy(howlong);
  75.                                     break;
  76.                           case BOMBSOUND:
  77.                                     Bomb(howlong);
  78.                                     break;
  79.                           default:
  80.                                     Happy(howlong);
  81.                                     break;
  82.                         }
  83.                   }
  84.             }
  85.       }  /*   end of forever loop */
  86.  
  87. cleanup:
  88.         printf("for now ......\n");
  89.         FinishProg(0);
  90.         DeletePort(gimmemessagePort);
  91.       /*  return(0); */
  92. }
  93.