home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************/
- /* */
- /* WaveMaker - a program to allow a user to construct waveforms */
- /* by superposition of harmonic sine waves. */
- /* */
- /* */
- /* This program is intended for beginning physics students to help */
- /* them get a better intuitive feel for constructing a complex wave */
- /* form from a sum of harmonics. Musicians may also find it */
- /* useful. */
- /* */
- /* For program operation see WaveMaker.doc. */
- /* */
- /* This program was written in Lattice C, version 5.04.02. It is */
- /* compiled with the command: lc -O -j30. */
- /* */
- /* It is linked with the following "with" file: */
- /* from lib:c.o */
- /* wavemaker.o */
- /* lib lib:lcm.lib lib:lc.lib lib:amiga.lib */
- /* SMALLCODE */
- /* SMALLDATA */
- /* */
- /* WaveMaker is freely distributable as long as it is not sold for */
- /* profit. It is permitted (encouraged) to include it on software */
- /* collections sold for a nominal sum, such as club disks and */
- /* Fish disks. Copyright is retained by the author. */
- /* */
- /* Thanks are due to those people who posted example programs in */
- /* the BIX listings area. One good example is worth several chapters*/
- /* of explanation. Of particular use were gad.c and menu.c. both by */
- /* John Draper, and scales.c by Steven A. Bennett. */
- /* */
- /* Comments, bugs, complaints, and praise may be sent to me at */
- /* Thomas Meyer */
- /* 12 Physics, Iowa State University */
- /* Ames, IA 50010 */
- /* BIX: TMEYER, BITNET:MEYER@ALISUVAX */
- /* */
- /**********************************************************************/
- /* */
- /* Update history: */
- /* 1/24/90 Version 1.1 */
- /* Easy game added */
- /* Fixed crashes from rawkey>64 */
- /* Closed down in correct order */
- /* Game doesn't interfere with amps[] */
- /* Random seed from timer */
- /* 1/21/90 Version 1.0 released on AAAUG club disk */
- /**********************************************************************/
-
- #include <math.h>
- #include <stdio.h>
- #include <exec/types.h>
- #include <exec/nodes.h>
- #include <exec/lists.h>
- #include <exec/ports.h>
- #include <exec/devices.h>
- #include <exec/memory.h>
- #include <hardware/custom.h>
- #include <hardware/dmabits.h>
- #include <libraries/dos.h>
- #include <devices/audio.h>
- #include <devices/inputevent.h>
- #include <intuition/intuition.h>
- #include <graphics/gfxbase.h>
- #include <graphics/gfx.h>
- #include <graphics/clip.h>
- #include <graphics/view.h>
- #include <graphics/rastport.h>
- #include <graphics/layers.h>
-
- extern struct MsgPort *CreatePort();
- extern VOID ModifyProp();
- extern VOID PrintIText();
-
- struct IntuitionBase *IntuitionBase;
- struct GfxBase *GfxBase;
- struct Window *Window;
- struct Screen *Screen;
- struct ViewPort *ViewPort;
- struct RastPort *rport;
- struct IntuiMessage *mesg;
- struct IOAudio *ioa,*audio,*finish,*audchan[4];
-
- /****************************************/
- /* Build the Intuition Gadgets */
- /****************************************/
-
- /* Define Logicals for GadgetIDs */
-
- #define HARMON0 0
- #define HARMON1 1
- #define HARMON2 2
- #define HARMON3 3
- #define HARMON4 4
- #define HARMON5 5
- #define HARMON6 6
- #define HARMON7 7
- #define INTEG 0
- #define UPARROW 8
- #define DNARROW 16
- #define PROPOR 24
- #define PLUSMINUS 32
- #define YES 1
- #define NO 0
- #define NBR_IOA_STRUCTS 6
-
- /* define logicals for ErrExit */
-
- #define SUCCESS 0
- #define INTUITION_FAIL 1
- #define GRAPHICS_FAIL 2
- #define PORTPN_FAIL 3
- #define PORTP0_FAIL 4
- #define AUDIOALLOC_FAIL 5
- #define AUDIO_FAIL 6
- #define USERSOUND_FAIL 7
- #define REFSOUND_FAIL 8
- #define SCREEN_FAIL 9
- #define WINDOW_FAIL 10
-
- /* Miscellaneous logicals */
-
- #define INTUITION_REV 0
- #define GRAPHICS_REV 0
-
- #define TWOPI 6.283185
-
- /*************************************/
- /* Global variables and structures */
- /*************************************/
-
- SHORT sinewave[8][513];
- LONG amps[8],refamps[8];
- LONG maxuser=1,maxref=1;
- LONG maxamp=16066;
- BYTE waveform[514],refform[514];
- BYTE *usersound,*refsound;
- BYTE sunit=0x0F;
- SHORT audiochan[128] ={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
- SHORT waiting[5]={NO, NO, NO, NO, NO};
- SHORT gameon=NO;
- VOID ErrExit();
-
- /* Structures for drawing waveforms */
-
- USHORT userwave[513][2],refwave[513][2];
-
- struct Border UWave_brd1 =
- {
- 64,13, /* LeftEdge, TopEdge */
- 4,0,JAM1, /* FrontPen, BackPen, DrawMode */
- 127,(APTR)&userwave[0][0], /* Count, *XY */
- NULL /* *NextBorder */
- };
- struct Border UWave_brd2 =
- {
- 64,13, /* LeftEdge, TopEdge */
- 4,0,JAM1, /* FrontPen, BackPen, DrawMode */
- 127,(APTR)&userwave[126][0], /* Count, *XY */
- (APTR)&UWave_brd1 /* *NextBorder */
- };
- struct Border UWave_brd3 =
- {
- 64,13, /* LeftEdge, TopEdge */
- 4,0,JAM1, /* FrontPen, BackPen, DrawMode */
- 127,(APTR)&userwave[252][0], /* Count, *XY */
- (APTR)&UWave_brd2 /* *NextBorder */
- };
- struct Border UWave_brd4 =
- {
- 64,13, /* LeftEdge, TopEdge */
- 4,0,JAM1, /* FrontPen, BackPen, DrawMode */
- 127,(APTR)&userwave[378][0], /* Count, *XY */
- (APTR)&UWave_brd3 /* *NextBorder */
- };
- struct Border UWave_brd5 =
- {
- 64,13, /* LeftEdge, TopEdge */
- 4,0,JAM1, /* FrontPen, BackPen, DrawMode */
- 9,(APTR)&userwave[504][0], /* Count, *XY */
- (APTR)&UWave_brd4 /* *NextBorder */
- };
- struct Border RWave_brd1 =
- {
- 64,13, /* LeftEdge, TopEdge */
- 6,0,JAM1, /* FrontPen, BackPen, DrawMode */
- 127,(APTR)&refwave[0][0], /* Count, *XY */
- NULL /* *NextBorder */
- };
- struct Border RWave_brd2 =
- {
- 64,13, /* LeftEdge, TopEdge */
- 6,0,JAM1, /* FrontPen, BackPen, DrawMode */
- 127,(APTR)&refwave[126][0], /* Count, *XY */
- (APTR)&RWave_brd1 /* *NextBorder */
- };
- struct Border RWave_brd3 =
- {
- 64,13, /* LeftEdge, TopEdge */
- 6,0,JAM1, /* FrontPen, BackPen, DrawMode */
- 127,(APTR)&refwave[252][0], /* Count, *XY */
- (APTR)&RWave_brd2 /* *NextBorder */
- };
- struct Border RWave_brd4 =
- {
- 64,13, /* LeftEdge, TopEdge */
- 6,0,JAM1, /* FrontPen, BackPen, DrawMode */
- 127,(APTR)&refwave[378][0], /* Count, *XY */
- (APTR)&RWave_brd3 /* *NextBorder */
- };
- struct Border RWave_brd5 =
- {
- 64,13, /* LeftEdge, TopEdge */
- 6,0,JAM1, /* FrontPen, BackPen, DrawMode */
- 9,(APTR)&refwave[504][0], /* Count, *XY */
- (APTR)&RWave_brd4 /* *NextBorder */
- };
-
- /* Declare the character buffer for IntuitText structures
- (to be filled later). */
-
- char textbuf[6]=" 0";
-
- struct IntuiText textamp =
- {
- 1,0,JAM2, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge (use offsets to set) */
- NULL, /* *ITextFont (use default) */
- (APTR)&textbuf, /* *IText (fill later) */
- NULL /* *NextText */
- };
-
- /* Border structures for the amplitude display box */
-
- USHORT BoxPairsb[9][2]=
- {
- 2,11, 53,11, 53,2, 54,2, 54,11,
- 55,11, 55,2, 56,2, 56,11 /* Brown shadow around int */
- };
-
- struct Border brdi1b =
- {
- -2,-2,2,0, /* LeftEdge, TopEdge, FrontPen, BackPen */
- JAM1, 9, /* DrawMode, Count */
- (APTR)&BoxPairsb, /* *XY */
- NULL /* *NextBorder */
- };
-
- USHORT BoxPairs[5][2]=
- {
- 0, 0, 52,0, 52,10, 0,10, 0,0 /* Coords of box */
- };
-
- struct Border brdi1 =
- {
- -2,-2,1,0, /* LeftEdge, TopEdge, FrontPen, BackPen */
- JAM1, 5, /* DrawMode, Count */
- (APTR)&BoxPairs, /* *XY */
- &brdi1b /* *NextBorder */
- };
-
- /*************************************/
- /* First amplitude gadgets */
- /*************************************/
-
- /* Proportional gadget */
-
- struct PropInfo prop_info1 =
- {
- AUTOKNOB|FREEVERT, /* Flags */
- 0xFFFF,0xFFFF, /* HorizPot, VertPot */
- 0x0800,0x0800, /* HorizBody, VertBody */
- 16,64, /* CWidth,CHeight */
- 0x0800,0x0800, /* HPotRes, VPotRes */
- 0,0 /* LeftBorder, TopBorder */
- };
-
- struct IntuiText protext1 =
- {
- 5, 2, JAM2, /* FrontPen, BackPen, DrawMode */
- -20, 3, /* LeftEdge, TopEdge */
- NULL,"1:", /* *ITextFont, *Itext */
- NULL /* *NextText */
- };
-
- struct Image empty1,empty2,empty3,empty4,empty5,empty6,empty7,empty8;
-
- struct Gadget propor1 =
- {
- NULL,65,113, /* *NextGadget, LeftEdge, TopEdge */
- 14,69,GADGHCOMP|AUTOKNOB, /* Width, Height, Flags */
- RELVERIFY|GADGIMMEDIATE, /* Activation */
- PROPGADGET,(APTR)&empty1, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- (APTR)&protext1,0, /* *GadgetText, MutualExclude */
- (APTR)&prop_info1, /* SpecialInfo */
- HARMON0|PROPOR, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Up arrow gadget */
-
- USHORT updn_shadata[] = {2,7, 17,7, 17,1, 18,1, 18,7, 19,7, 19,1};
- struct Border updn_shadow =
- {
- -2,-1,2,0, /* LeftEdge, TopEdge, FrontPen, BackPen */
- JAM1,7, /* DrawMode, Count */
- (APTR)&updn_shadata, /* *XY */
- NULL /* *NextBorder */
- };
-
- USHORT updn_data[] = {0,0, 0,6, 16,6, 16,0, 0,0};
- struct Border updn_border =
- {
- -2,-1,1,0, /* LeftEdge, TopEdge, FrontPen, BackPen */
- JAM1,5, /* DrawMode, Count */
- (APTR)&updn_data, /* *XY */
- &updn_shadow /* *NextBorder */
- };
-
- USHORT uparr_data[] = {8,2, 3,4, 13,4, 8,2};
- struct Border up_arr =
- {
- -2,-1,1,0, /* LeftEdge, TopEdge, FrontPen, BackPen */
- JAM1,4, /* DrawMode, Count */
- (APTR)&uparr_data, /* *XY */
- &updn_border /* *NextBorder */
- };
-
- struct Gadget up1 =
- {
- &propor1,44,143, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&up_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON0|UPARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* down arrow gadget */
-
- USHORT dnarr_data[] = {3,2, 13,2, 8,4, 3,2};
- struct Border dn_arr =
- {
- -2,-1,1,0, /* LeftEdge, TopEdge, FrontPen, BackPen */
- JAM1,4, /* DrawMode, Count */
- (APTR)&dnarr_data, /* *XY */
- &updn_border /* *NextBorder */
- };
-
- struct Gadget dn1 =
- {
- &up1,44,152, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&dn_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON0|DNARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Change sign gadget */
-
- /* tie shadow for proportional gadget here since
- I can't get border structures working for prop gadgets */
- USHORT pshad_data[] = {24,17, 38,17, 38,-51, 39,-51, 39,17, 40,17, 40,-51};
-
- struct Border propshad =
- {
- -2,-2,2,0, /* LeftEdge, TopEdge, FrontPen, BackPen */
- JAM1, 7, /* DrawMode, Count */
- (APTR)&pshad_data, /* *XY */
- NULL /* *NextBorder */
- };
-
- USHORT plus1[] = {5,3, 9,3};
- USHORT plus2[] = {7,2, 7,4};
- USHORT minus[] = {5,6, 9,6};
- USHORT plmi_data[] = {0,0, 0,8, 15,8, 15,0, 0,0};
- USHORT plmi_datas[]= {2,9, 16,9, 16,1, 17,1, 17,9, 18,9, 18,1};
-
- struct Border plmi1 =
- {
- -2,-1,1,0, /* LeftEdge, TopEdge, Frontpen, BackPen */
- JAM1,2, /* DrawMode, Count */
- (APTR)&plus1, /* *XY */
- &propshad /* *NextBorder */
- };
-
- struct Border plmi2 =
- {
- -2,-1,1,0, /* LeftEdge, TopEdge, Frontpen, BackPen */
- JAM1,2, /* DrawMode, Count */
- (APTR)&plus2,&plmi1 /* *XY, *NextBorder */
- };
-
- struct Border plmi3 =
- {
- -2,-1,1,0, /* LeftEdge, TopEdge, Frontpen, BackPen */
- JAM1,2, /* DrawMode, Count */
- (APTR)&minus,&plmi2 /* *XY, *NextBorder */
- };
-
- struct Border plmi4 =
- {
- -2,-1,1,0, /* LeftEdge, TopEdge, Frontpen, BackPen */
- JAM1,5, /* DrawMode, Count */
- (APTR)&plmi_data,&plmi3 /* *XY, *NextBorder */
- };
-
- struct Border plmi5 =
- {
- -2,-1,2,0, /* LeftEdge, TopEdge, Frontpen, BackPen */
- JAM1,7, /* DrawMode, Count */
- (APTR)&plmi_datas,&plmi4 /* *XY, *NextBorder */
- };
-
- struct Gadget plusminus1 =
- {
- &dn1,44,167, /* *NextGadget, LeftEdge, TopEdge */
- 15,8,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&plmi5, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON0|PLUSMINUS, /* GadgetID */
- NULL /* UserData */
- };
-
-
- /*************************************/
- /* Second amplitude gadgets */
- /*************************************/
-
- /* Proportional gadget */
-
- struct PropInfo prop_info2 =
- {
- AUTOKNOB|FREEVERT, /* Flags */
- 0xFFFF,0xFFFF, /* HorizPot, VertPot */
- 0x0800,0x0800, /* HorizBody, VertBody */
- 16,64, /* CWidth,CHeight */
- 0x0800,0x0800, /* HPotRes, VPotRes */
- 0,0 /* LeftBorder, TopBorder */
- };
-
- struct IntuiText protext2 =
- {
- 5, 2, JAM2, /* FrontPen, BackPen, DrawMode */
- -20, 3, /* LeftEdge, TopEdge */
- NULL,"2:", /* *ITextFont, *Itext */
- NULL /* *NextText */
- };
-
- struct Gadget propor2 =
- {
- &plusminus1,139,113, /* *NextGadget, LeftEdge, TopEdge */
- 14,69,GADGHCOMP|AUTOKNOB, /* Width, Height, Flags */
- RELVERIFY|GADGIMMEDIATE, /* Activation */
- PROPGADGET,(APTR)&empty2, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- (APTR)&protext2,0, /* *GadgetText, MutualExclude */
- (APTR)&prop_info2, /* SpecialInfo */
- HARMON1|PROPOR, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Up arrow gadget */
-
- struct Gadget up2 =
- {
- &propor2,118,143, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&up_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON1|UPARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* down arrow gadget */
-
- struct Gadget dn2 =
- {
- &up2,118,152, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&dn_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON1|DNARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Change sign gadget */
-
- struct Gadget plusminus2 =
- {
- &dn2,118,167, /* *NextGadget, LeftEdge, TopEdge */
- 15,8,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&plmi5, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON1|PLUSMINUS, /* GadgetID */
- NULL /* UserData */
- };
-
- /*************************************/
- /* Third amplitude gadgets */
- /*************************************/
-
- /* Proportional gadget */
-
- struct PropInfo prop_info3 =
- {
- AUTOKNOB|FREEVERT, /* Flags */
- 0xFFFF,0xFFFF, /* HorizPot, VertPot */
- 0x0800,0x0800, /* HorizBody, VertBody */
- 16,64, /* CWidth,CHeight */
- 0x0800,0x0800, /* HPotRes, VPotRes */
- 0,0 /* LeftBorder, TopBorder */
- };
-
- struct IntuiText protext3 =
- {
- 5, 2, JAM2, /* FrontPen, BackPen, DrawMode */
- -20, 3, /* LeftEdge, TopEdge */
- NULL,"3:", /* *ITextFont, *Itext */
- NULL /* *NextText */
- };
-
- struct Gadget propor3 =
- {
- &plusminus2,213,113, /* *NextGadget, LeftEdge, TopEdge */
- 14,69,GADGHCOMP|AUTOKNOB, /* Width, Height, Flags */
- RELVERIFY|GADGIMMEDIATE, /* Activation */
- PROPGADGET,(APTR)&empty3, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- (APTR)&protext3,0, /* *GadgetText, MutualExclude */
- (APTR)&prop_info3, /* SpecialInfo */
- HARMON2|PROPOR, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Up arrow gadget */
-
- struct Gadget up3 =
- {
- &propor3,192,143, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&up_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON2|UPARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* down arrow gadget */
-
- struct Gadget dn3 =
- {
- &up3,192,152, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&dn_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON2|DNARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Change sign gadget */
-
- struct Gadget plusminus3 =
- {
- &dn3,192,167, /* *NextGadget, LeftEdge, TopEdge */
- 15,8,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&plmi5, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON2|PLUSMINUS, /* GadgetID */
- NULL /* UserData */
- };
-
- /*************************************/
- /* Fourth amplitude gadgets */
- /*************************************/
-
- /* Proportional gadget */
-
- struct PropInfo prop_info4 =
- {
- AUTOKNOB|FREEVERT, /* Flags */
- 0xFFFF,0xFFFF, /* HorizPot, VertPot */
- 0x0800,0x0800, /* HorizBody, VertBody */
- 16,64, /* CWidth,CHeight */
- 0x0800,0x0800, /* HPotRes, VPotRes */
- 0,0 /* LeftBorder, TopBorder */
- };
-
- struct IntuiText protext4 =
- {
- 5, 2, JAM2, /* FrontPen, BackPen, DrawMode */
- -20, 3, /* LeftEdge, TopEdge */
- NULL,"4:", /* *ITextFont, *Itext */
- NULL /* *NextText */
- };
-
- struct Gadget propor4 =
- {
- &plusminus3,287,113, /* *NextGadget, LeftEdge, TopEdge */
- 14,69,GADGHCOMP|AUTOKNOB, /* Width, Height, Flags */
- RELVERIFY|GADGIMMEDIATE, /* Activation */
- PROPGADGET,(APTR)&empty4, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- (APTR)&protext4,0, /* *GadgetText, MutualExclude */
- (APTR)&prop_info4, /* SpecialInfo */
- HARMON3|PROPOR, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Up arrow gadget */
-
- struct Gadget up4 =
- {
- &propor4,266,143, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&up_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON3|UPARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* down arrow gadget */
-
- struct Gadget dn4 =
- {
- &up4,266,152, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&dn_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON3|DNARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Change sign gadget */
-
- struct Gadget plusminus4 =
- {
- &dn4,266,167, /* *NextGadget, LeftEdge, TopEdge */
- 15,8,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&plmi5, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON3|PLUSMINUS, /* GadgetID */
- NULL /* UserData */
- };
-
- /*************************************/
- /* Fifth amplitude gadgets */
- /*************************************/
-
- /* Proportional gadget */
-
- struct PropInfo prop_info5 =
- {
- AUTOKNOB|FREEVERT, /* Flags */
- 0xFFFF,0xFFFF, /* HorizPot, VertPot */
- 0x0800,0x0800, /* HorizBody, VertBody */
- 16,64, /* CWidth,CHeight */
- 0x0800,0x0800, /* HPotRes, VPotRes */
- 0,0 /* LeftBorder, TopBorder */
- };
-
- struct IntuiText protext5 =
- {
- 5, 2, JAM2, /* FrontPen, BackPen, DrawMode */
- -20, 3, /* LeftEdge, TopEdge */
- NULL,"5:", /* *ITextFont, *Itext */
- NULL /* *NextText */
- };
-
- struct Gadget propor5 =
- {
- &plusminus4,361,113, /* *NextGadget, LeftEdge, TopEdge */
- 14,69,GADGHCOMP|AUTOKNOB, /* Width, Height, Flags */
- RELVERIFY|GADGIMMEDIATE, /* Activation */
- PROPGADGET,(APTR)&empty5, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- (APTR)&protext5,0, /* *GadgetText, MutualExclude */
- (APTR)&prop_info5, /* SpecialInfo */
- HARMON4|PROPOR, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Up arrow gadget */
-
- struct Gadget up5 =
- {
- &propor5,341,143, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&up_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON4|UPARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* down arrow gadget */
-
- struct Gadget dn5 =
- {
- &up5,340,152, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&dn_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON4|DNARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Change sign gadget */
-
- struct Gadget plusminus5 =
- {
- &dn5,340,167, /* *NextGadget, LeftEdge, TopEdge */
- 15,8,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&plmi5, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON4|PLUSMINUS, /* GadgetID */
- NULL /* UserData */
- };
-
- /*************************************/
- /* Sixth amplitude gadgets */
- /*************************************/
-
- /* Proportional gadget */
-
- struct PropInfo prop_info6 =
- {
- AUTOKNOB|FREEVERT, /* Flags */
- 0xFFFF,0xFFFF, /* HorizPot, VertPot */
- 0x0800,0x0800, /* HorizBody, VertBody */
- 16,64, /* CWidth,CHeight */
- 0x0800,0x0800, /* HPotRes, VPotRes */
- 0,0 /* LeftBorder, TopBorder */
- };
-
- struct IntuiText protext6 =
- {
- 5, 2, JAM2, /* FrontPen, BackPen, DrawMode */
- -20, 3, /* LeftEdge, TopEdge */
- NULL,"6:", /* *ITextFont, *Itext */
- NULL /* *NextText */
- };
-
- struct Gadget propor6 =
- {
- &plusminus5,435,113, /* *NextGadget, LeftEdge, TopEdge */
- 14,69,GADGHCOMP|AUTOKNOB, /* Width, Height, Flags */
- RELVERIFY|GADGIMMEDIATE, /* Activation */
- PROPGADGET,(APTR)&empty6, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- (APTR)&protext6,0, /* *GadgetText, MutualExclude */
- (APTR)&prop_info6, /* SpecialInfo */
- HARMON5|PROPOR, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Up arrow gadget */
-
- struct Gadget up6 =
- {
- &propor6,414,143, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&up_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON5|UPARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* down arrow gadget */
-
- struct Gadget dn6 =
- {
- &up6,414,152, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&dn_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON5|DNARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Change sign gadget */
-
- struct Gadget plusminus6 =
- {
- &dn6,414,167, /* *NextGadget, LeftEdge, TopEdge */
- 15,8,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&plmi5, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON5|PLUSMINUS, /* GadgetID */
- NULL /* UserData */
- };
-
- /*************************************/
- /* Seventh amplitude gadgets */
- /*************************************/
-
- /* Proportional gadget */
-
- struct PropInfo prop_info7 =
- {
- AUTOKNOB|FREEVERT, /* Flags */
- 0xFFFF,0xFFFF, /* HorizPot, VertPot */
- 0x0800,0x0800, /* HorizBody, VertBody */
- 16,64, /* CWidth,CHeight */
- 0x0800,0x0800, /* HPotRes, VPotRes */
- 0,0 /* LeftBorder, TopBorder */
- };
-
- struct IntuiText protext7 =
- {
- 5, 2, JAM2, /* FrontPen, BackPen, DrawMode */
- -20, 3, /* LeftEdge, TopEdge */
- NULL,"7:", /* *ITextFont, *Itext */
- NULL /* *NextText */
- };
-
- struct Gadget propor7 =
- {
- &plusminus6,509,113, /* *NextGadget, LeftEdge, TopEdge */
- 14,69,GADGHCOMP|AUTOKNOB, /* Width, Height, Flags */
- RELVERIFY|GADGIMMEDIATE, /* Activation */
- PROPGADGET,(APTR)&empty7, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- (APTR)&protext7,0, /* *GadgetText, MutualExclude */
- (APTR)&prop_info7, /* SpecialInfo */
- HARMON6|PROPOR, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Up arrow gadget */
-
- struct Gadget up7 =
- {
- &propor7,488,143, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&up_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON6|UPARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* down arrow gadget */
-
- struct Gadget dn7 =
- {
- &up7,488,152, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&dn_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON6|DNARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Change sign gadget */
-
- struct Gadget plusminus7 =
- {
- &dn7,488,167, /* *NextGadget, LeftEdge, TopEdge */
- 15,8,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&plmi5, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON6|PLUSMINUS, /* GadgetID */
- NULL /* UserData */
- };
-
- /*************************************/
- /* Eighth amplitude gadgets */
- /*************************************/
-
- /* Proportional gadget */
-
- struct PropInfo prop_info8 =
- {
- AUTOKNOB|FREEVERT, /* Flags */
- 0xFFFF,0xFFFF, /* HorizPot, VertPot */
- 0x0800,0x0800, /* HorizBody, VertBody */
- 16,64, /* CWidth,CHeight */
- 0x0800,0x0800, /* HPotRes, VPotRes */
- 0,0 /* LeftBorder, TopBorder */
- };
-
- struct IntuiText protext8 =
- {
- 5, 2, JAM2, /* FrontPen, BackPen, DrawMode */
- -20, 3, /* LeftEdge, TopEdge */
- NULL,"8:", /* *ITextFont, *Itext */
- NULL /* *NextText */
- };
-
- struct Gadget propor8 =
- {
- &plusminus7,583,113, /* *NextGadget, LeftEdge, TopEdge */
- 14,69,GADGHCOMP|AUTOKNOB, /* Width, Height, Flags */
- RELVERIFY|GADGIMMEDIATE, /* Activation */
- PROPGADGET,(APTR)&empty8, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- (APTR)&protext8,0, /* *GadgetText, MutualExclude */
- (APTR)&prop_info8, /* SpecialInfo */
- HARMON7|PROPOR, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Up arrow gadget */
-
- struct Gadget up8 =
- {
- &propor8,562,143, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&up_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON7|UPARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* down arrow gadget */
-
- struct Gadget dn8 =
- {
- &up8,562,152, /* *NextGadget, LeftEdge, TopEdge */
- 16,6,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&dn_arr, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON7|DNARROW, /* GadgetID */
- NULL /* UserData */
- };
-
- /* Change sign gadget */
-
- struct Gadget plusminus8 =
- {
- &dn8,562,167, /* *NextGadget, LeftEdge, TopEdge */
- 15,8,GADGHCOMP, /* Width, Height, Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET,(APTR)&plmi5, /* GadgetType, GadgetRender */
- NULL, /* SelectRender */
- NULL,0, /* *GadgetText, MutualExclude */
- NULL, /* SpecialInfo */
- HARMON7|PLUSMINUS, /* GadgetID */
- NULL /* UserData */
- };
-
- struct Gadget *propadd[8]={&propor1,&propor2,&propor3,&propor4,
- &propor5,&propor6,&propor7,&propor8};
-
- /********************/
- /* Menu Structures */
- /********************/
-
-
- struct IntuiText stoptext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"Stop", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem stopgame = {
- NULL, /* *NextItem */
- 0,20,80,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&stoptext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct IntuiText hardtext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"Start-Hard", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem starthard = {
- &stopgame, /* *NextItem */
- 0,10,80,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&hardtext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct IntuiText easytext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"Start-Easy", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem starteasy = {
- &starthard, /* *NextItem */
- 0,0,80,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&easytext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct Menu game = {
- NULL, /* *NextMenu */
- 161,0,80,10, /* LeftEdge, TopEdge, Width, Height */
- MENUENABLED, /* Flags */
- "Game", /* *MenuName */
- &starteasy /* First Item */
- };
-
- struct IntuiText squaretext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"Square", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem square = {
- NULL, /* *NextItem */
- 0,30,80,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&squaretext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct IntuiText sawtext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"Sawtooth", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem sawtooth = {
- &square, /* *NextItem */
- 0,20,80,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&sawtext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct IntuiText triangletext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"Triangle", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem triangle = {
- &sawtooth, /* *NextItem */
- 0,10,80,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&triangletext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct IntuiText resettext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"Reset", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem resetwave = {
- &triangle, /* *NextItem */
- 0,0,80,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&resettext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct Menu waves = {
- &game, /* *NextMenu */
- 81,0,80,10, /* LeftEdge, TopEdge, Width, Height */
- MENUENABLED, /* Flags */
- "Waveforms", /* *MenuName */
- &resetwave /* First Item */
- };
-
- struct IntuiText quittext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"Quit", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem quit = {
- NULL, /* *NextItem */
- 0,40,120,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&quittext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct IntuiText fronttext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"Screen to Front", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem scfront = {
- &quit, /* *NextItem */
- 0,30,120,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&fronttext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct IntuiText backtext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"Screen to Back", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem scback = {
- &scfront, /* *NextItem */
- 0,20,120,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&backtext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct IntuiText expandtext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"Full Scale", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem expand = {
- &scback, /* *NextItem */
- 0,10,120,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&expandtext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct IntuiText abouttext = {
- 0,1,JAM1, /* FrontPen, BackPen, DrawMode */
- 0,0, /* LeftEdge, TopEdge */
- NULL,"About", /* ITextFont, *IText */
- NULL /* *NextText */
- };
-
- struct MenuItem about = {
- &expand, /* *NextItem */
- 0,0,120,10, /* LeftEdge, TopEdge, Width, Height */
- ITEMTEXT|ITEMENABLED|HIGHCOMP, /* Flags */
- NULL, (APTR)&abouttext, /* MutualExclude, ItemFill */
- NULL,NULL, /* Command, *SubItem */
- NULL /* NextSelect */
- };
-
- struct Menu project = {
- &waves, /* *NextMenu */
- 0,0,80,10, /* LeftEdge, TopEdge, Width, Height */
- MENUENABLED, /* Flags */
- "Project", /* *MenuName */
- &about /* First Item */
- };
-
- /****************************************/
- /* "about" requester structures */
- /****************************************/
-
- struct IntuiText OK = {0,1,JAM2,5,4,NULL,"OK",NULL};
-
- struct IntuiText About6 = {0,1,JAM2,8,80,NULL,
- "Click on either <OK> box to proceed",
- NULL};
-
- struct IntuiText About5 = {0,1,JAM2,8,60,NULL,
- "Ames, IA, 50011, USA. BITNET: MEYER@ALISUVAX",
- &About6};
-
- struct IntuiText About4 = {0,1,JAM2,8,50,NULL,
- "W. T. Meyer, 12 Physics, Iowa State University,",
- &About5};
-
- struct IntuiText About3 = {0,1,JAM2,8,30,NULL,
- "Comments and suggestions may be sent to:",
- &About4};
-
- struct IntuiText About2 = {0,1,JAM2,8,20,NULL,
- "Copyright (c) 1990 by W. T. Meyer.",
- &About3};
-
- struct IntuiText About1 = {0,1,JAM2,8,10,NULL,
- "WaveMaker is freely distributable for noncommercial use.",
- &About2};
-
- /*************************************/
- /* "Answers" requester structures */
- /*************************************/
-
- char Answers[80];
-
- struct IntuiText Answer3 = {0,1,JAM2,8,30,NULL,
- "Click on either <OK> box to proceed",
- NULL};
-
- struct IntuiText Answer2 = {0,1,JAM2,8,20,NULL,
- (APTR)&Answers,&Answer3};
-
- struct IntuiText Answer1 = {0,1,JAM2,8,10,NULL,
- "The answers are:",&Answer2};
-
- /************************************************************/
- main()
- /************************************************************/
- {
- ULONG mclass;
- USHORT mcode,mqual,gadID,gadno,gadtyp,i;
- USHORT amptopot();
- unsigned seed;
- LONG pottoamp(),MakeWave();
- SHORT potsign,keyraw,keyup,keyrepeat;
- struct Gadget *mgadget;
- struct PropInfo *propinfo;
- VOID OpenLibs(),Cleanup(),MakeDisplay(),MakeSin(),MakePalette();
- VOID AmpsUpDate(),PropUpdate(),DrawBoxes(),DrawUser();
- VOID SoundOn(),SoundOff(),MenuSetup(),DoMenu(),OpenAudio();
- VOID Update(),InitArrays();
-
- /* Initialization */
-
- OpenLibs();
-
- OpenAudio();
-
- seed = (unsigned)time(NULL);
- srand(seed);
-
- MakeSin();
-
- for (i=0;i<8;++i) amps[i]=0;
-
- InitArrays();
-
- MakeDisplay();
-
- SetMenuStrip(Window,&project);
-
-
- /* Set up an IDCMP Read Loop */
-
- for(;;) {
- Wait(1<<Window->UserPort->mp_SigBit);
-
- while((mesg=(struct IntuiMessage *)
- GetMsg(Window->UserPort))!=NULL) /* Wait for IntuiMessage */
- {
- mclass = mesg->Class; /* Run through all of them */
- mcode = mesg->Code; /* Local copies of variables*/
- mqual = mesg->Qualifier;
- mgadget =(struct Gadget *)mesg->IAddress;
- gadID = mgadget->GadgetID;
- switch(mclass)
- {
- case CLOSEWINDOW:
- {
- Cleanup();
- Exit(TRUE);
- break;
- }
- case REFRESHWINDOW:
- {
- DrawBoxes();
- Update(0);
- break;
- }
- case MENUPICK:
- {
- DoMenu(mcode);
- break;
- }
- case GADGETDOWN:
- {
- gadno = gadID&0x7;
- gadtyp = gadID&0x38;
- switch(gadtyp)
- {
- case UPARROW:
- if (amps[gadno]>=0) ++amps[gadno];
- else --amps[gadno];
- Update(gadno);
- ModifyProp(propadd[gadno],Window,NULL,
- FREEVERT|AUTOKNOB,0xFFFF,
- amptopot(amps[gadno]),0x0800,0x0800);
- break;
- case DNARROW:
- if (amps[gadno]>=0) --amps[gadno];
- else ++amps[gadno];
- Update(gadno);
- ModifyProp(propadd[gadno],Window,NULL,
- FREEVERT|AUTOKNOB,0xFFFF,
- amptopot(amps[gadno]),0x0800,0x0800);
- break;
- case PLUSMINUS:
- amps[gadno]=-amps[gadno];
- Update(gadno);
- break;
- case PROPOR:
- break;
- }
- break;
- }
- case GADGETUP:
- {
- gadno = gadID&0x7;
- gadtyp = gadID&0x38;
- switch(gadtyp)
- {
- case UPARROW:
- break;
- case DNARROW:
- break;
- case PLUSMINUS:
- break;
- case PROPOR:
- potsign=1;
- if (amps[gadno]<0) potsign=-1;
- propinfo=mgadget->SpecialInfo;
- amps[gadno]=pottoamp(propinfo->VertPot,
- potsign);
- Update(gadno);
- break;
- }
- break;
- }
- case RAWKEY:
- keyrepeat=mqual&IEQUALIFIER_REPEAT;
- keyraw = mcode&0x7F;
- keyup = mcode&0x80;
- if (keyup==0&&!keyrepeat)
- SoundOn(keyraw,usersound);
- if (keyup!=0) SoundOff(keyraw);
- break;
- }
- ReplyMsg(mesg); /* Give message back */
- }
- }
- }
-
- /**************************************************************/
- VOID OpenLibs()
-
- /* Open all required libraries */
-
- {
- /* ==Open Intuition... */
-
- IntuitionBase = (struct IntuitionBase *)
- OpenLibrary("intuition.library",INTUITION_REV);
- if(IntuitionBase == NULL)
- ErrExit(INTUITION_FAIL);
-
- /* ==Open Graphics... */
- GfxBase = (struct GfxBase *)
- OpenLibrary("graphics.library",GRAPHICS_REV);
- if(GfxBase == NULL)
- ErrExit(GRAPHICS_FAIL);
-
- }
-
- /*******************************************************************/
- VOID Cleanup()
- /* ======Close down the window, the screen, and the libraries====== */
- {
- ClearMenuStrip(Window);
- CloseWindow(Window);
- CloseScreen(Screen);
- FreeMem(refsound,516);
- FreeMem(usersound,516);
- CloseDevice(ioa);
- CloseLibrary(GfxBase);
- CloseLibrary(IntuitionBase);
- exit(NULL);
- }
-
- /******************************************************************/
- VOID ErrExit(SHORT errno)
-
- /* This routine gets called if a fatal error occurs. It ends */
- /* the program gracefully by closing all of the resources opened */
- /* to that point. */
-
- {
- char *ErrMess[]={"Successful Completion\n",
- "Unable to open Intuition.library\n",
- "Unable to open Graphics.library\n",
- "Unable to allocate port PN\n",
- "Unable to allocate port P0\n",
- "Unable to allocate audio memory\n",
- "Unable to open audio device\n",
- "Unable to allocate usersound\n",
- "Unable to allocate refsound\n",
- "Unable to open Screen\n",
- "Unable to open Window\n"};
-
- printf(ErrMess[errno]);
-
- switch(errno) /* Yes, the fall-through is deliberate */
- {
- case SUCCESS:
- ClearMenuStrip(Window);
- CloseWindow(Window);
- case WINDOW_FAIL:
- CloseScreen(Screen);
- case SCREEN_FAIL:
- FreeMem(refsound,516);
- case REFSOUND_FAIL:
- FreeMem(usersound,516);
- case USERSOUND_FAIL:
- CloseDevice(ioa);
- case AUDIOALLOC_FAIL:
- case AUDIO_FAIL:
- case PORTP0_FAIL:
- case PORTPN_FAIL:
- CloseLibrary(GfxBase);
- case GRAPHICS_FAIL:
- CloseLibrary(IntuitionBase);
- case INTUITION_FAIL:
- break;
- }
- Exit(FALSE);
- }
-
- /********************************************************************/
- VOID Update(USHORT gadno)
-
- /* Update the amplitudes and screen when one amplitude has been changed */
-
- {
- VOID AmpsUpdate(),DrawUser();
- LONG MakeWave();
-
- if (amps[gadno]>127) amps[gadno]=127;
- if (amps[gadno]<-127) amps[gadno]=-127;
- AmpsUpdate();
- maxuser=MakeWave(amps,waveform,usersound);
- DrawUser();
- }
-
- /*************************************************************/
- VOID DoMenu(USHORT mcode)
-
- /* Does the right thing when a menu option is chosen */
-
- {
- #define PROJECT_MENU 0
- #define WAVE_MENU 1
- #define GAME_MENU 2
-
- #define ABOUT 0
- #define FULLSCALE 1
- #define SCREENBACK 2
- #define SCREENFRONT 3
- #define QUIT 4
-
- #define START_EASY 0
- #define START_HARD 1
- #define STOP 2
-
- switch(MENUNUM(mcode))
- {
- LONG peak;
- SHORT i,item,scale;
- LONG temp,AddWaves(),randamp(),checkval(),MakeWave();
- VOID AmpsUpdate(),PropUpdate(),AutoRequest(),
- DrawUser(),Cleanup(),rescale();
- static SHORT canned[4][8]={{ 0, 0, 0, 0, 0, 0, 0, 0},
- {108, 0,-12, 0, 4, 0, -2, 0},
- { 74,-38, 24,-20, 14,-12, 10, -9},
- {124, 0, 41, 0, 25, 0, 18, 0}};
-
-
-
- case PROJECT_MENU:
- switch (ITEMNUM(mcode))
- {
- case ABOUT:
- {
- AutoRequest(Window,&About1,&OK,&OK,
- NULL,NULL,500,130);
- break;
- }
- case FULLSCALE:
- {
- if ((peak=checkval(maxuser,amps))!=0)
- rescale(peak,amps);
- maxuser=AddWaves(amps,waveform,
- usersound)>>15;
- AmpsUpdate();
- PropUpdate();
- DrawUser();
- break;
- }
- case SCREENBACK:
- {
- ScreenToBack(Screen);
- break;
- }
- case SCREENFRONT:
- {
- ScreenToFront(Screen);
- break;
- }
- case QUIT:
- {
- Cleanup();
- Exit(TRUE);
- }
- }
- break;
- case WAVE_MENU:
- item = ITEMNUM(mcode);
- for (i=0; i<8; ++i)
- {
- amps[i] = canned[item][i];
- }
- AmpsUpdate();
- PropUpdate();
- maxuser=MakeWave(amps,waveform,usersound);
- DrawUser();
- break;
- case GAME_MENU:
- switch (ITEMNUM(mcode))
- {
- case START_EASY:
- gameon = YES;
- for (i=0; i<4; i++)
- {
- refamps[i] = randamp();
- }
- for (i=4;i<8;i++) refamps[i]=0;
- maxref=MakeWave(refamps,refform,refsound);
- if (maxref==0) maxref=1;
- scale=maxamp/maxref;
- for (i=0;i<4;++i)
- {
- temp=refamps[i]*scale;
- refamps[i]=temp>>7;
- }
- maxref=AddWaves(refamps,refform,
- refsound)>>15;
- for (i=0; i<513; ++i)
- {
- refwave[i][1]=((129-refform[i])*48)>>7;
- }
- DrawUser();
- break;
- case START_HARD:
- gameon = YES;
- for (i=0; i<8; i++)
- {
- refamps[i] = randamp();
- }
- maxref=MakeWave(refamps,refform,refsound);
- if (maxref==0) maxref=1;
- scale=maxamp/maxref;
- for (i=0;i<8;++i)
- {
- temp=refamps[i]*scale;
- refamps[i]=temp>>7;
- }
- maxref=AddWaves(refamps,refform,
- refsound)>>15;
- for (i=0; i<513; ++i)
- {
- refwave[i][1]=((129-refform[i])*48)>>7;
- }
- DrawUser();
- break;
- case STOP:
- gameon = NO;
- sprintf(Answers,
- "%6d %6d %6d %6d %6d %6d %6d %6d",
- refamps[0],refamps[1],refamps[2],
- refamps[3],refamps[4],refamps[5],
- refamps[6],refamps[7]);
- AutoRequest(Window,&Answer1,&OK,&OK,
- NULL,NULL,620,80);
- DrawUser();
- break;
- }
- break;
- }
- }
-
- /*************************************************************/
- VOID MakeDisplay()
-
- /* Opens the screen and window, and creates the initial display */
-
- {
- VOID DrawBoxes();
-
- Screen = (struct Screen *)MakeScreen();
- if (Screen == NULL) ErrExit(SCREEN_FAIL);
-
- Window = (struct Window *)MakeWindow();
- if (Window == NULL) ErrExit(WINDOW_FAIL);
-
- MakePalette(Window);
-
- DrawBoxes();
- }
-
- /*************************************************************/
- VOID DrawBoxes()
-
- /* Draws the waveform display area and the boxes around the */
- /* numerical display */
- {
- SHORT i;
- static SHORT boxx[8]={34,108,182,256,330,404,478,552};
-
- /* Draw waveform display area */
- rport = Window->RPort;
- SetAPen(rport,5);
- RectFill(rport,40,14,601,109);
- SetAPen(rport,2);
- RectFill(rport,44,12,597,111);
- SetAPen(rport,1);
- RectFill(rport,64,14,577,109);
- SetAPen(rport,3);
- RectFill(rport,64,61,577,61);
-
- /* Draw boxes for digital display of amplitudes */
- for (i=0;i<8;++i)
- {
- DrawBorder(rport,&brdi1,boxx[i],188);
- sprintf(textbuf,"%5d",amps[i]);
- PrintIText(rport,&textamp,boxx[i],188);
- }
- }
-
- /****************************************************************/
- VOID InitArrays()
- /* Initialize data arrays for waveform displays */
- {
- SHORT i;
-
- for (i=0;i<513;++i)
- {
- userwave[i][0]=refwave[i][0]=i;
- userwave[i][1]=refwave[i][1]=0;
- }
- }
-
- /***************************************************************/
- VOID MakePalette(Window)
-
- /* Sets the color palette */
-
- {
- ViewPort = (struct ViewPort *)ViewPortAddress(Window);
-
- /* ==Set palette... */
-
- SetRGB4(ViewPort, 0, 7, 4, 3); /* Dark beige */
- SetRGB4(ViewPort, 1, 15, 12, 9); /* Light beige */
- SetRGB4(ViewPort, 2, 5, 1, 0); /* Brown */
- SetRGB4(ViewPort, 3, 4, 4, 4); /* dark gray */
- SetRGB4(ViewPort, 4, 11, 0, 0); /* Red */
- SetRGB4(ViewPort, 5, 13, 10, 0); /* Yellow */
- SetRGB4(ViewPort, 6, 6, 8, 2); /* Green */
- SetRGB4(ViewPort, 7, 0, 0, 0); /* Black */
- }
-
- /*****************************************************************/
- MakeScreen()
-
- {
- /* ==Open a custom screen... */
-
- struct NewScreen NewScreen =
- { 0, 0, 640, 200, /* LeftEdge, TopEdge, Width, Height */
- 3, 0x00, 0x01, /* Depth, DetailPen, BlockPen */
- HIRES,CUSTOMSCREEN, /* ViewModes, Type */
- NULL,"WaveScreen",NULL,/* Font, DefaultTitle, Gadgets */
- NULL /* CustomBitMap */
- };
-
- return(OpenScreen(&NewScreen));
- }
-
- /******************************************************************/
- MakeWindow()
-
- /* This function initializes the NewWindow structure and opens
- the window */
-
- {
- struct NewWindow NewWindow;
- ULONG flags;
- USHORT iflags;
-
- /* ==Open the window... */
-
- flags=SMART_REFRESH|WINDOWSIZING|WINDOWDRAG|WINDOWCLOSE;
- iflags=CLOSEWINDOW|REFRESHWINDOW|GADGETDOWN|GADGETUP|RAWKEY|
- MENUPICK;
- NewWindow.LeftEdge=0;
- NewWindow.TopEdge=0;
- NewWindow.Width=640;
- NewWindow.Height=200;
- NewWindow.DetailPen=0x00;
- NewWindow.BlockPen=0x01;
- NewWindow.Flags=flags;
- NewWindow.IDCMPFlags=iflags;
- NewWindow.FirstGadget=&plusminus8;
- NewWindow.CheckMark=NULL;
- NewWindow.Title="WaveMaker 1.1";
- NewWindow.Screen=Screen;
- NewWindow.BitMap=NULL;
- NewWindow.MinWidth=16;
- NewWindow.MinHeight=16;
- NewWindow.MaxWidth=640;
- NewWindow.MaxHeight=200;
- NewWindow.Type=CUSTOMSCREEN;
-
- return(OpenWindow(&NewWindow));
-
- }
-
- /*********************************************************************/
- VOID MakeSin()
-
- /* Initialize the sine wave arrays for all eight frequencies. */
- /* This saves a lot of time later. */
-
- {
- SHORT i,j,k;
- FLOAT step;
-
- step = 6.283185/512.0;
- for (i=0; i<513; ++i) sinewave[0][i]=sin(i*step)*0x7FFF;
- for (j=1; j<8; ++j)
- {
- for (i=0; i<513; ++i)
- {
- k=((j+1)*i)%512;
- sinewave[j][i]=sinewave[0][k];
- }
- }
- }
-
- /****************************************************************/
- VOID OpenAudio()
-
- /* Alloc and open the audio device and initialize the structures */
-
- {
- char *portstring[]={"aud0","aud1","aud2","aud3","aud4"};
- SHORT i;
- static SHORT chanbits[4]={1,2,4,8};
-
- /* allocate memory for IOAudio structures */
-
- ioa=(struct IOAudio *)AllocMem((NBR_IOA_STRUCTS*sizeof(*ioa)),
- MEMF_PUBLIC|MEMF_CLEAR);
- if (ioa==NULL) ErrExit(AUDIOALLOC_FAIL);
-
- /* set the IOAudio structure pointers */
-
- finish = &ioa[5];
- audio = &ioa[0];
-
- /* open the audio device */
-
- ioa->ioa_Request.io_Message.mn_Node.ln_Pri=10;
- ioa->ioa_Data=&sunit;
- ioa->ioa_Length=(ULONG)sizeof(sunit);
- ioa->ioa_Request.io_Message.mn_ReplyPort=CreatePort("aud0",0);
- if (ioa->ioa_Request.io_Message.mn_ReplyPort==NULL)
- ErrExit(PORTP0_FAIL);
- if((OpenDevice(AUDIONAME,0,ioa,0))!=NULL) ErrExit(AUDIO_FAIL);
-
- /* set up the finish structure */
-
- *finish = *ioa;
- finish->ioa_Request.io_Flags = IOF_QUICK;
- finish->ioa_Request.io_Command = ADCMD_FINISH;
-
- /* set up the audio channels and initialize them */
-
- for (i=0; i<4; ++i)
- {
- audchan[i]=&ioa[i+1];
- *audchan[i]=*ioa;
- if ((audchan[i]->ioa_Request.io_Message.mn_ReplyPort =
- CreatePort(portstring[i],0))==NULL) ErrExit(PORTPN_FAIL);
- audchan[i]->ioa_Request.io_Command=CMD_WRITE;
- audchan[i]->ioa_Request.io_Flags=IOF_QUICK|ADIOF_PERVOL;
- audchan[i]->ioa_Cycles=0;
- audchan[i]->ioa_Length=128;
- audchan[i]->ioa_Request.io_Unit=chanbits[i];
- }
- if((usersound = (BYTE *)AllocMem(516, MEMF_CHIP))==0)
- ErrExit(USERSOUND_FAIL);
- if((refsound = (BYTE *)AllocMem(516, MEMF_CHIP))==0)
- ErrExit(REFSOUND_FAIL);
- }
-
- /****************************************************************/
- VOID AmpsUpdate()
-
- /* Update the numerical amplitude displays */
-
- {
- SHORT i;
- SHORT boxx[8]={34,108,182,256,330,404,478,552};
-
- for (i=0;i<8;i++)
- {
- sprintf(textbuf,"%5d",amps[i]);
- PrintIText(rport,&textamp,boxx[i],188);
- }
- }
-
- /****************************************************************/
- VOID PropUpdate()
-
- /* Update the proportional gadgets after a rescaling */
-
- {
- USHORT temp;
- temp=amptopot(amps[7]);
- ModifyProp(&propor8,Window,NULL,FREEVERT|AUTOKNOB,0xFFFF,
- temp,0x0800,0x0800);
- temp=amptopot(amps[6]);
- ModifyProp(&propor7,Window,NULL,FREEVERT|AUTOKNOB,0xFFFF,
- temp,0x0800,0x0800);
- temp=amptopot(amps[5]);
- ModifyProp(&propor6,Window,NULL,FREEVERT|AUTOKNOB,0xFFFF,
- temp,0x0800,0x0800);
- temp=amptopot(amps[4]);
- ModifyProp(&propor5,Window,NULL,FREEVERT|AUTOKNOB,0xFFFF,
- temp,0x0800,0x0800);
- temp=amptopot(amps[3]);
- ModifyProp(&propor4,Window,NULL,FREEVERT|AUTOKNOB,0xFFFF,
- temp,0x0800,0x0800);
- temp=amptopot(amps[2]);
- ModifyProp(&propor3,Window,NULL,FREEVERT|AUTOKNOB,0xFFFF,
- temp,0x0800,0x0800);
- temp=amptopot(amps[1]);
- ModifyProp(&propor2,Window,NULL,FREEVERT|AUTOKNOB,0xFFFF,
- temp,0x0800,0x0800);
- temp=amptopot(amps[0]);
- ModifyProp(&propor1,Window,NULL,FREEVERT|AUTOKNOB,0xFFFF,
- temp,0x0800,0x0800);
- }
-
- /****************************************************************/
- USHORT amptopot(amp)
-
- /* Convert an amplitude to an integer to put in the proportional */
- /* gadget's VertPot value. */
-
- LONG amp;
- {
- USHORT temp;
-
- temp = (127-abs(amp))<<9;
- return(temp);
- }
-
- /****************************************************************/
- LONG pottoamp(pot,potsign)
-
- /* Converts a proportional gadget's VertPot value to an amplitude */
-
- USHORT pot;
- SHORT potsign;
- {
- LONG temp;
- temp = (127-(pot>>9))*potsign;
- return(temp);
- }
-
- /****************************************************************/
- LONG AddWaves(LONG ampl[],BYTE wf[],UBYTE *ws)
-
- /* Create the compound waveform by adding the harmonics. This */
- /* routine is a likely candidate for future conversion to assembler */
- /* to speed things up. */
-
- {
- SHORT i,j;
- LONG wavebuff[513];
- LONG maxval,minval;
-
- for (j=0;j<513;++j) wavebuff[j]=ampl[0]*sinewave[0][j];
- for (i=1;i<8;++i)
- {
- for (j=0;j<513;++j)
- {
- wavebuff[j]=wavebuff[j]+ampl[i]*sinewave[i][j];
- }
- }
- maxval=minval=0;
- for (j=0;j<513;++j)
- {
- wf[j]=wavebuff[j]>>15;
- ws[j/4]=wf[j];
- if (wavebuff[j]>maxval) maxval=wavebuff[j];
- if (wavebuff[j]<minval) minval=wavebuff[j];
- }
- if (abs(minval)>maxval) maxval=abs(minval);
- return(maxval);
- }
-
- /*****************************************************************/
- LONG MakeWave(LONG ampl[],BYTE wf[],UBYTE *ws)
-
- /* Makes the compound waveform (via AddWaves) and checks that it */
- /* is not off scale. If it is, it rescales. */
- {
- LONG peak;
- LONG maxnow;
- LONG AddWaves();
- LONG checkval();
- VOID rescale();
-
- maxnow=AddWaves(ampl,wf,ws)>>15;
- if ((peak=checkval(maxnow,ampl))>127)
- {
- rescale(peak,ampl);
- maxnow=AddWaves(ampl,wf,ws)>>15;
- }
- return(maxnow);
- }
-
- /******************************************************************/
- LONG checkval(LONG maxval,LONG ampl[])
-
- /* Checks maxval, and all of the amps[i] to find the largest */
- /* in absolute value. */
-
- {
- SHORT i;
- LONG temp;
-
- temp = maxval;
- for (i=0; i<8; ++i)
- {
- if (abs(ampl[i])>temp) temp=abs(ampl[i]);
- }
- return(temp);
- }
-
- /******************************************************************/
- VOID rescale(LONG peak,LONG ampl[])
-
- /* rescale to make the amplitude a high as possible without having */
- /* any ampltiude or the compound wave exceed 127 in absolute value */
- {
- extern LONG maxamp;
- SHORT scale,i;
- LONG temp;
-
- scale=maxamp/peak;
- for (i=0;i<8;++i) /* Be careful not to lose bits */
- {
- temp=ampl[i]*scale;
- ampl[i]=temp>>7;
- }
- }
- /***********************************************************************/
- VOID DrawUser()
-
- /* Draws the compound waveform in the display area. */
-
- {
- SHORT i;
- for (i=0;i<513;++i) userwave[i][1]=((129-waveform[i])*48)>>7;
- SetAPen(rport,1);
- RectFill(rport,64,14,577,109);
- SetAPen(rport,3);
- RectFill(rport,64,61,577,61);
- if (gameon) DrawBorder(rport,&RWave_brd5,0,0);
- DrawBorder(rport,&UWave_brd5,0,0);
- }
-
- /************************************************************/
- 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;
- static SHORT chanbits[4]={1,2,4,8};
-
- channo = audiochan[key];
- audiochan[key]=-1;
- if ((channo>=0)&(key<64))
- {
- finish->ioa_Request.io_Unit=chanbits[channo];
- BeginIO(finish);
- WaitIO(audchan[channo]);
- waiting[channo]=NO;
- }
- }
-
- /************************************************************/
- LONG randamp()
-
- /* Picks a random amplitude (for the game mode) */
-
- {
- LONG temp;
-
- temp=(rand()&0xFF)-127;
- if (temp==128) temp=127;
- return(temp);
- }
-
- /************************************************************/
- SHORT FreeChan()
-
- /* Finds the first unused audio channel */
- {
- SHORT i;
-
- i=0;
- while ((waiting[i]==YES)&&(i<4)) i++;
- waiting[i]=YES;
- return(i);
- }
-