home *** CD-ROM | disk | FTP | other *** search
- /*
- Boomerang
- by Kevin Dixon
- Amiga version by Troy Tucker using Lattice C (V5.02)
- Copyright © 1990 COMPUTE! Publications, Inc.
- All Rights Reserved
- */
-
- #define STILL 0
- #define UP 1
- #define DOWN 2
- #define LEFT 3
- #define RIGHT 4
- #define ESC 0x045
- #define RETURN 0x044
- #define SPACE 0x040
-
- #define NUMSAMPLES 3
- #define JIF0 8
- #define PER0 400
- #define VOL0 48
- #define JIF1 1
- #define PER1 250
- #define VOL1 64
- #define JIF2 8
- #define PER2 500
- #define VOL2 64
-
- void openthelibs(),openthefiles(),initthebmaps(),openthescreen();
- void readthepic(),initialize(),gameloop(),setbitmap(),opensounds(),pause();
- void checkmen(),checkboomerangs(),placeobjects(),changemen(),moveboomerangs();
- void dotitle(),flipem(),readthesticks(),cleantheamiga(),getnewboard();
-
- #include <stdio.h>
- #include <intuition/intuition.h>
- #include <exec/memory.h>
- #include <hardware/blit.h>
- #include <graphics/copper.h>
- #include <graphics/view.h>
- #include "boomsound.c"
-
- short frame=0,direction[2],olddirection[2],px[2],py[2],ox[2],oy[2];
- short shapex[2],shapey[2],animate[2],startword,speed=2,bspeed=4,lives[2];
- short bx[2],by[2],obx[2],oby[2],bshapex[2],bshapey[2],bflag[2],bstate[2];
- short rpx1[2],rpy1[2],rpx2[2],rpy2[2],rpx3[2],rpy3[2],bdirection[2],obstate[2];
- short brpx1[2],brpy1[2],brpx2[2],brpy2[2],safethrow[2],deadshapex,deadshapey;
- short bulbx[2],bulby[2],bulbshapex[2],bulbshapey[2],dead[2],next=0,reset=0;
- char *cia,*filename,numplanes=4;
- short *joy[2];
- UWORD *copperlist;
-
- FILE *IFFfile;
- struct Screen *scr;
- struct Window *wdw;
- struct ViewPort *vp;
- struct View *v;
- struct RastPort *rp;
- struct IntuitionBase *IntuitionBase;
- struct IntuiMessage *message;
- struct GfxBase *GfxBase;
- struct BitMap *Bmap[5] = {NULL,NULL,NULL,NULL,NULL};
- struct TextAttr StdFont =
- { "topaz.font",TOPAZ_EIGHTY,FS_NORMAL,FPF_ROMFONT };
- struct NewScreen my_screen =
- { 0,0,320,200,4,0,1,NULL,CUSTOMSCREEN|CUSTOMBITMAP,&StdFont,NULL,NULL,NULL};
- struct NewWindow my_window =
- { 0,0,320,200,-1,-1,RAWKEY,RMBTRAP|ACTIVATE|BORDERLESS|BACKDROP|NOCAREREFRESH,
- NULL,NULL,NULL,NULL,NULL,0,0,0,0,CUSTOMSCREEN };
-
- UWORD blackmap[16]={ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
- UWORD chip Blank_Data[6] = {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000};
- UWORD colormap[16]=
- { 0x0002,0x0223,0x0c00,0x0f60,0x0070,0x0040,0x000f,0x0000,
- 0x0f8b,0x080b,0x0407,0x0830,0x0fe0,0x0dd9,0x0774,0x0332
- };
-
- void main()
- {
- openthelibs();
- printf ("\n\n Boomerang\n");
- printf (" by Kevin Dixon\n");
- printf (" Amiga version by Troy Tucker\n");
- printf (" Copyright © 1990 COMPUTE! Pub., Inc.\n");
- printf (" All Rights Reserved\n\n");
- waveform[0]=LoadSample("samples/footsteps.snd",&wavelength[0]);
- waveform[1]=LoadSample("samples/spin.snd",&wavelength[1]);
- waveform[2]=LoadSample("samples/boom.snd",&wavelength[2]);
- initthebmaps();
- openthescreen();
- openthefiles();
- Forbid();
- initialize();
- dotitle();
- gameloop();
- }
-
- void openthelibs() /* open the libraries */
- {
- IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0);
- if (IntuitionBase == NULL) exit(FALSE);
- GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0);
- if (GfxBase == NULL)
- { CloseLibrary("intuition.library");
- exit(FALSE);
- }
- }
-
- void initthebmaps() /* allocate bmaps and clear them */
- {
- register short i,j;
-
- for (j=0; j<5; j++)
- {
- if ((Bmap[j]=(struct BitMap *)AllocMem(sizeof(struct BitMap),MEMF_CHIP))==0)
- cleantheamiga();
- InitBitMap (Bmap[j],4,320,200);
- for (i=0; i<4; i++)
- { if ((Bmap[j]->Planes[i] = (PLANEPTR)AllocRaster(320,200)) == 0)
- cleantheamiga();
- BltClear(Bmap[j]->Planes[i],(320 / 8)*200,1);
- }
- }
- my_screen.CustomBitMap = Bmap[0];
- }
-
- void openthescreen() /* open window,screen,kill pointer,etc. */
- {
- if ((scr=(struct Screen *)OpenScreen(&my_screen))==NULL)
- { printf("Can't open the screen \n");
- cleantheamiga();
- }
- my_window.Screen = scr;
- if ((wdw=(struct Window *)OpenWindow(&my_window))==NULL)
- { printf("Can't open the window \n");
- cleantheamiga();
- }
- SetPointer(wdw,&Blank_Data[0],1,1,0,0);
- vp=(struct ViewPort *)&scr->ViewPort;;
- v=(struct View *)ViewAddress();
- rp=&scr->RastPort;
- copperlist = (UWORD *)v->LOFCprList->start;
- startword=0;
- while (*(copperlist+startword) != (UWORD)0x00e0) startword += 2;
- }
-
- void openthefiles() /* open pics for reading */
- {
- LoadRGB4(vp,&blackmap,16);
- scr->BitMap = *Bmap[3];
- filename="boomer1.pic";
- readthepic();
- scr->BitMap = *Bmap[4];
- filename="boomer2.pic";
- readthepic();
- BltBitMap(Bmap[4],0,0,Bmap[2],0,0,320,200,0xC0,0xff,NULL);
- }
-
- void readthepic() /* DPaintIII (320x200) pic reader */
- {
- char *newbyte[8], context_header[4], code, counter, goodbyte;
- short Height, Plane, bytes_read, bytes_per_row=320>>3;
-
- IFFfile=fopen(filename,"r");
- if (IFFfile==NULL)
- { printf("Can't find the pictures! \n");
- exit(FALSE);
- }
- for (counter=0; counter<80; counter++) /* skip to BODY */
- fread(context_header,4,1,IFFfile);
- fread(context_header,2,1,IFFfile);
- fread(context_header,4,1,IFFfile);
- if (strcmp(context_header,"BODY")!=0)
- { printf("Something's wrong with the pictures! \n");
- cleantheamiga();
- }
- fread(context_header,4,1,IFFfile);
- for (Plane=0; Plane<numplanes; Plane++) /* read in the body */
- newbyte[Plane]=(char *)(scr->RastPort.BitMap->Planes[Plane]);
- for (Height=0; Height<200; Height++)
- { for (Plane=0; Plane<numplanes; Plane++)
- { bytes_read=0;
- do
- { fread(&code,1,1,IFFfile);
- if (code>=0)
- { code++;
- fread(newbyte[Plane],(long)code,1,IFFfile);
- newbyte[Plane] += code;
- bytes_read += code;
- }
- else if (code != -127)
- { code = -code;
- code++;
- fread(&goodbyte,1,1,IFFfile);
- for (counter=0; counter<code; counter++)
- { *newbyte[Plane]=goodbyte;
- newbyte[Plane]++;
- }
- bytes_read += code;
- }
- }
- while ((bytes_read<bytes_per_row) && feof(IFFfile)==0);
- }
- }
- fclose(IFFfile);
- }
-
- void initialize() /* refreshes vars between rounds */
- {
- register short i,x;
-
- if ((lives[0]==6)&&(lives[1]==6)) /* light up the lifebulbs */
- {
- x=215;
- for (i=0;i<5;i++)
- {
- BltBitMap(Bmap[3],70,80,
- Bmap[2],x,190,5,5,0xC0,0xff,NULL);
- x=x+14;
- }
- x=46;
- for (i=0;i<5;i++)
- {
- BltBitMap(Bmap[3],70,90,
- Bmap[2],x,190,5,5,0xC0,0xff,NULL);
- x=x+14;
- }
- }
- px[0]=292,px[1]=14,py[0]=12,py[1]=164;
- ox[0]=292,ox[1]=14,oy[0]=12,oy[1]=164;
- rpx1[0]=rpx2[0]=rpx3[0]=rpy1[0]=rpy2[0]=rpy3[0]=px[0];
- rpx1[1]=rpx2[1]=rpx3[1]=rpy1[1]=rpy2[1]=rpy3[1]=px[0];
- bshapex[0]=15,bshapey[0]=79,bshapex[1]=35,bshapey[1]=89;
- shapex[0]=15,shapey[0]=28,shapex[1]=15,shapey[1]=44;
- deadshapex=0,dead[0]=0,dead[1]=0;
- joy[1] = (short *)(0xdff00a); /* Joystick 1 (port 1) */
- joy[0] = (short *)(0xdff00c); /* Joystick 0 (mouse) */
- cia = (char *)(0xbfe001);
- animate[0]=0; animate[1]=0;
- bflag[0]=bflag[1]=bstate[0]=bstate[1]=0;
- safethrow[0]=safethrow[1]=0;
- bdirection[0]=LEFT,bdirection[1]=RIGHT;
- direction[0]=LEFT,direction[1]=RIGHT;
- olddirection[0]=LEFT,olddirection[1]=RIGHT;
- /* make the screen copies */
- BltBitMap(Bmap[2],0,0,Bmap[0],0,0,320,200,0xC0,0xff,NULL);
- BltBitMap(Bmap[2],0,0,Bmap[1],0,0,320,200,0xC0,0xff,NULL);
- /* blit the men */
- BltBitMap(Bmap[3],shapex[0]+112,shapey[0],Bmap[0],px[0],py[0],13,15,0x20,0xff,NULL);
- BltBitMap(Bmap[3],shapex[0],shapey[0],Bmap[0],px[0],py[0],13,15,0xE0,0xff,NULL);
- BltBitMap(Bmap[3],shapex[1]+112,shapey[1],Bmap[0],px[1],py[1],13,15,0x20,0xff,NULL);
- BltBitMap(Bmap[3],shapex[1],shapey[1],Bmap[0],px[1],py[1],13,15,0xE0,0xff,NULL);
- frame=0;
- scr->BitMap = *Bmap[0];
- setbitmap();
- frame=1;
- pause(255);
- LoadRGB4(vp,&colormap,16);
- }
-
- void dotitle() /* place select box then get input */
- {
- register short i;
- ULONG class;
- USHORT code = 0;
- BltBitMap(Bmap[3],14,127,Bmap[1-frame],98,78,124,38,0xC0,0xff,NULL);
- lives[0]=lives[1]=6;
- bulbx[0]=215,bulby[0]=190,bulbx[1]=102,bulby[1]=190;
- bulbshapex[0]=59,bulbshapey[0]=80,bulbshapex[1]=59,bulbshapey[1]=90;
- deadshapex=0,deadshapey=99,dead[0]=0,dead[1]=0;
- *dmaconw=0x000F; for (i=0;i<4;i++) inuse[i]=0;
- Permit();
-
- while (code != RETURN)
- { Wait(1<<wdw->UserPort->mp_SigBit);
- while (message = (struct IntuiMessage *)GetMsg(wdw->UserPort))
- {
- code = message->Code;
- class = message->Class;
- ReplyMsg(message);
- if ((class==RAWKEY)&&(code==ESC)) cleantheamiga();
- if ((class==RAWKEY)&&(code==SPACE))
- { BltBitMap(Bmap[4],0,0,Bmap[2],0,0,320,200,0xC0,0xff,NULL);
- getnewboard();
- initialize();
- BltBitMap(Bmap[3],14,127,Bmap[1-frame],
- 98,78,124,38,0xC0,0xff,NULL);
- }
- }
- }
- Forbid();
- BltBitMap(Bmap[2],98,78,Bmap[1-frame],98,78,124,38,0xC0,0xff,NULL);
- }
-
- void getnewboard() /* random board generator */
- {
- register short i,j,wx,wy,wd,wl;
- ULONG Seconds,Micros,seed;
- CurrentTime(&Seconds, &Micros);
- seed=Seconds + Micros;
- srand(seed);
-
- for (i=0;i<20;i++)
- {
- wx=((rand() % 28)*10)+25;
- wy=((rand() % 16)*10)+25;
- wd=(rand() % 10);
- if (wd>5) wd=1;
- else wd=0;
- wl=(rand() % 7)+2;
- for (j=0; j<wl; j++)
- {
- if ((wx>280)||(wy>160)) break;
- BltBitMap(Bmap[3],26,180,Bmap[2],wx,wy,11,11,0x20,0xff,NULL);
- BltBitMap(Bmap[3],14,180,Bmap[2],wx,wy,11,11,0xE0,0xff,NULL);
- if (wd==0) wx=wx+10;
- else wy=wy+10;
- }
- }
- }
-
- void setbitmap() /* Tell copper to display Bmap */
- {
- *(copperlist+startword+1) = ((ULONG)(Bmap[frame]->Planes[0]) / 65536);
- *(copperlist+startword+3) = ((ULONG)(Bmap[frame]->Planes[0]) % 65536);
- *(copperlist+startword+5) = ((ULONG)(Bmap[frame]->Planes[1]) / 65536);
- *(copperlist+startword+7) = ((ULONG)(Bmap[frame]->Planes[1]) % 65536);
- *(copperlist+startword+9) = ((ULONG)(Bmap[frame]->Planes[2]) / 65536);
- *(copperlist+startword+11) = ((ULONG)(Bmap[frame]->Planes[2]) % 65536);
- *(copperlist+startword+13) = ((ULONG)(Bmap[frame]->Planes[3]) / 65536);
- *(copperlist+startword+15) = ((ULONG)(Bmap[frame]->Planes[3]) % 65536);
- }
-
- void gameloop() /* main game loop */
- {
- for (;;)
- {
- UpdateSounds();
- if ((dead[0]==0) && (dead[1]==0))
- {
- readthesticks();
- checkmen();
- changemen();
- moveboomerangs();
- checkboomerangs();
- }
- placeobjects();
- if ((dead[0])||(dead[1])) pause(100);
- if (reset==1)
- {
- reset=0;
- pause(255);
- if ((lives[0]==0)||(lives[1]==0)) dotitle();
- initialize();
- }
- }
- }
-
- void readthesticks() /* update x & y for men */
- {
- register short port,i;
- for (i=0; i<2; i++)
- {
- port=2-i;
- direction[i]=STILL;
-
- if ((!(*cia & 64 * port))&&(bflag[i]==0)&&(safethrow[i]==0))
- { bflag[i]=1;
- bstate[i]=1;
- obstate[i]=0;
- }
-
- if (*joy[i] & 512) /* stick left */
- { direction[i]=LEFT;
- bdirection[i]=LEFT;
- px[i]=px[i]-speed;
- rpx1[i]=px[i]; rpy1[i]=py[i]+1;
- rpx2[i]=rpx1[i]; rpy2[i]=py[i]+7;
- rpx3[i]=rpx1[i]; rpy3[i]=py[i]+13;
- continue;
- }
- if (*joy[i] & 2) /* stick right */
- { direction[i]=RIGHT;
- bdirection[i]=RIGHT;
- px[i]=px[i]+speed;
- rpx1[i]=px[i]+11; rpy1[i]=py[i]+1;
- rpx2[i]=rpx1[i]; rpy2[i]=py[i]+7;
- rpx3[i]=rpx1[i]; rpy3[i]=py[i]+13;
- continue;
- }
- if ((*joy[i]>>1^*joy[i])&256) /* stick up */
- { direction[i]=UP;
- bdirection[i]=UP;
- py[i]=py[i]-speed;
- rpx1[i]=px[i]+3; rpy1[i]=py[i];
- rpx2[i]=px[i]+6; rpy2[i]=rpy1[i];
- rpx3[i]=px[i]+9; rpy3[i]=rpy1[i];
- continue;
- }
- if ((*joy[i]>>1^*joy[i])&1) /* stick down */
- { direction[i]=DOWN;
- bdirection[i]=DOWN;
- py[i]=py[i]+speed;
- rpx1[i]=px[i]+3; rpy1[i]=py[i]+13;
- rpx2[i]=px[i]+6; rpy2[i]=rpy1[i];
- rpx3[i]=px[i]+9; rpy3[i]=rpy1[i];
- continue;
- }
- }
- }
-
- void checkmen()
- {
- register short color1,color2,color3,i;
- for (i=0;i<2;i++)
- {
- safethrow[i]=0;
- if (px[i]<2) px[i]=303; /* man run into wall? */
- else if (px[i]>303) px[i]=2;
- if (py[i]<2) py[i]=174;
- else if (py[i]>174) py[i]=2;
- color1 = ReadPixel(rp,rpx1[i],rpy1[i]);
- color2 = ReadPixel(rp,rpx2[i],rpy2[i]);
- color3 = ReadPixel(rp,rpx3[i],rpy3[i]);
- if ((color1>1)||(color2>1)||(color3>1))
- {
- px[i]=ox[i];
- py[i]=oy[i];
- safethrow[i]=1;
- }
- }
- }
-
- void changemen() /* player shape changer */
- {
- register short i;
- for (i=0; i<2; i++)
- {
- if ((animate[i]==4)||(olddirection[i] != direction[i]))
- {
- switch(direction[i])
- {
- case (LEFT): if (olddirection[i]==LEFT) shapex[i]=shapex[i]+14;
- else
- { shapex[i]=15;
- olddirection[i]=LEFT;
- }
- if (i==0) shapey[i]=28;
- else shapey[i]=60;
- if (shapex[i] > 57) shapex[i]=15;
- break;
-
- case (RIGHT): if (olddirection[i]==RIGHT) shapex[i]=shapex[i]+14;
- else
- { shapex[i]=15;
- olddirection[i]=RIGHT;
- }
- if (i==0) shapey[i]=12;
- else shapey[i]=44;
- if (shapex[i] > 57) shapex[i]=15;
- break;
-
- case (UP): if (olddirection[i]==UP) shapex[i]=shapex[i]+14;
- else
- { shapex[i]=85;
- olddirection[i]=UP;
- }
- if (i==0) shapey[i]=28;
- else shapey[i]=60;
- if (shapex[i] > 99) shapex[i]=85;
- break;
-
- case (DOWN): if (olddirection[i]==DOWN) shapex[i]=shapex[i]+14;
- else
- { shapex[i]=85;
- olddirection[i]=DOWN;
- }
- if (i==0) shapey[i]=12;
- else shapey[i]=44;
- if (shapex[i] > 99) shapex[i]=85;
- break;
- }
- }
- if (direction[i] != STILL)
- StartSound(waveform[0],wavelength[0],JIF0,PER0,VOL0,i+2);
- if (animate[i]==4) animate[i]=0;
- animate[i]++;
- }
- }
-
- void moveboomerangs() /* update x & y for boomerangs */
- {
- register short i;
- for (i=0;i<2;i++)
- {
- if ((bflag[i])&&(bstate[i]))
- {
- switch(bdirection[i])
- {
- case (LEFT): if (obstate[i]==0)
- { bx[i]=px[i]-6; by[i]=py[i]+3; }
- bx[i]=bx[i]-bspeed;
- brpx1[i]=bx[i]-1; brpy1[i]=by[i]+2;
- brpx2[i]=bx[i]-1; brpy2[i]=by[i]+6;
- break;
-
- case (RIGHT): if (obstate[i]==0)
- { bx[i]=px[i]+8; by[i]=py[i]+3; }
- bx[i]=bx[i]+bspeed;
- brpx1[i]=bx[i]+8; brpy1[i]=by[i]+2;
- brpx2[i]=bx[i]+8; brpy2[i]=by[i]+6;
- break;
-
- case (UP): if (obstate[i]==0)
- { bx[i]=px[i]+3; by[i]=py[i]-5; }
- by[i]=by[i]-bspeed;
- brpx1[i]=bx[i]+2; brpy1[i]=by[i];
- brpx2[i]=bx[i]+6; brpy2[i]=by[i];
- break;
-
- case (DOWN): if (obstate[i]==0)
- { bx[i]=px[i]+3; by[i]=py[i]+11; }
- by[i]=by[i]+bspeed;
- brpx1[i]=bx[i]+2; brpy1[i]=by[i]+7;
- brpx2[i]=bx[i]+6; brpy2[i]=by[i]+7;
- break;
- }
- if ((brpy1[i]<1)||(brpy2[i]<1)) brpy1[i]=brpy2[i]=179;
- else if ((brpy1[i]>179)||(brpy2[i]>179)) brpy1[i]=brpy2[i]=1;
- if ((brpx1[i]<1)||(brpx2[i]<1)) brpx1[i]=brpx2[i]=310;
- else if ((brpx1[i]>310)||(brpx2[i]>310)) brpx1[i]=brpx2[i]=1;
- if (animate[i]==4)
- { bshapex[i]=bshapex[i]+10;
- if (bshapex[i] > 45) bshapex[i] = 15;
- }
- }
- }
- }
-
- void checkboomerangs() /* check boomerangs for collisions */
- {
- register short i,color1,color2,color3,ch;
- for (i=0;i<2;i++)
- { /* is boomerang out there? */
- if (bflag[i])
- { /* did it hit the enemy? */
- if ((((bx[i] > px[1-i]) && (bx[i] < px[1-i]+12)) && /* hit enemy? */
- ((by[i] > py[1-i]) && (by[i] < py[1-i]+12))) ||
- (((bx[i]+8 > px[1-i]) && (bx[i]+8 < px[1-i]+12)) &&
- ((by[i]+8 > py[1-i]) && (by[i]+8 < py[1-i]+12))))
- {
- *dmaconw=0x000F; for (ch=0;ch<4;ch++) inuse[ch]=0;
- StartSound(waveform[2],wavelength[2],JIF2,PER2,VOL2,0);
- lives[1-i]--;
- dead[1-i]=1;
- next=20;
- if (lives[1-i] > 0) BltBitMap(Bmap[3],bulbshapex[1-i],bulbshapey[1-i],
- Bmap[2],bulbx[1-i],190,5,5,0xC0,0xff,NULL);
- if (i==1) bulbx[0]=bulbx[0]+14;
- else bulbx[1]=bulbx[1]-14;
- }
- /* pick up boomerang if out there */
-
- if (((rpx2[i]>=bx[i])&&(rpx2[i]<=bx[i]+8)) &&
- ((rpy2[i]>=by[i])&&(rpy2[i]<=by[i]+8)))
- {
- bflag[i]=0;
- BltBitMap(Bmap[2],bx[i],by[i],Bmap[frame],
- bx[i],by[i],9,9,0xC0,0xff,NULL);
- BltBitMap(Bmap[2],obx[i],oby[i],Bmap[1-frame],
- obx[i],oby[i],9,9,0xC0,0xff,NULL);
- }
-
- if (bstate[i]==1) /* boomerang flying? */
- {
- if (bx[i]<1) bx[i]=310;
- else if (bx[i]>310) bx[i]=1;
- if (by[i]<1) by[i]=179;
- else if (by[i]>179) by[i]=1; /* boomerang hit a wall? */
- if (obstate[i]==0)
- { obx[i]=bx[i];
- oby[i]=by[i];
- }
- color1 = ReadPixel(rp,brpx1[i],brpy1[i]);
- color2 = ReadPixel(rp,brpx2[i],brpy2[i]);
- color3 = ReadPixel(rp,bx[i]+4,by[i]+4);
- if ((color1>1)||(color2>1)||(color3>1))
- { bstate[i]=0;
- if (obstate[i]==0)
- { bflag[i]=0;
- BltBitMap(Bmap[2],bx[i],by[i],Bmap[frame],
- bx[i],by[i],9,9,0xC0,0xff,NULL);
- BltBitMap(Bmap[2],obx[i],oby[i],Bmap[1-frame],
- obx[i],oby[i],9,9,0xC0,0xff,NULL);
- continue;
- }
- else
- {
- bx[i]=obx[i];
- by[i]=oby[i];
- }
- }
- /* boomerang hit thrower? */
-
- if ((((brpx1[i] > px[i]+3)&&(brpx1[i] < px[i]+8)) &&
- ((brpy1[i] > py[i]+3)&&(brpy1[i] < py[i]+8))) ||
- (((brpx2[i] > px[i]+3)&&(brpx2[i] < px[i]+8)) &&
- ((brpy2[i] > py[i]+3)&&(brpy2[i] < py[i]+8))))
- {
- bflag[i]=bstate[i]=0;
- BltBitMap(Bmap[2],bx[i],by[i],Bmap[frame],
- bx[i],by[i],9,9,0xC0,0xff,NULL);
- BltBitMap(Bmap[2],obx[i],oby[i],Bmap[1-frame],
- obx[i],oby[i],9,9,0xC0,0xff,NULL);
- }
- if ((animate[i]==4)&&(bstate[i]==1))
- StartSound(waveform[1],wavelength[1],JIF1,PER1,VOL1,i);
- }
- }
- }
- }
-
- void placeobjects() /* Bust holes in background & place objects */
- {
- register short i;
- for (i=0;i<2;i++)
- {
- if (dead[i]==0) /* if man is safe */
- {
- BltBitMap(Bmap[3],shapex[i]+112,shapey[i],Bmap[frame],
- px[i],py[i],13,15,0x20,0xff,NULL);
- BltBitMap(Bmap[3],shapex[i],shapey[i],Bmap[frame],
- px[i],py[i],13,15,0xE0,0xff,NULL);
- }
- else /* else kill him */
- {
- if (deadshapex==0) deadshapex=15;
- else deadshapex=deadshapex+next;
- if (deadshapex>75)
- { deadshapex=55;
- next=-20;
- }
- if (deadshapex<15) reset=1;
- else
- {
- BltBitMap(Bmap[3],deadshapex+112,deadshapey,Bmap[frame],
- px[i]-2,py[i]-2,19,17,0x20,0xff,NULL);
- BltBitMap(Bmap[3],deadshapex,deadshapey,Bmap[frame],
- px[i]-2,py[i]-2,19,17,0xE0,0xff,NULL);
- }
- }
- if (bflag[i]) /* blit boomerang */
- {
- BltBitMap(Bmap[3],bshapex[i]+112,bshapey[i],Bmap[frame],
- bx[i],by[i],9,9,0x20,0xff,NULL);
- BltBitMap(Bmap[3],bshapex[i],bshapey[i],Bmap[frame],
- bx[i],by[i],9,9,0xE0,0xff,NULL);
- }
- }
-
- flipem();
- /* Repair background */
- BltBitMap(Bmap[2],ox[0],oy[0],Bmap[frame],ox[0],oy[0],13,15,0xC0,0xff,NULL);
- BltBitMap(Bmap[2],ox[1],oy[1],Bmap[frame],ox[1],oy[1],13,15,0xC0,0xff,NULL);
- if (bflag[0]) BltBitMap(Bmap[2],obx[0],oby[0],Bmap[frame],
- obx[0],oby[0],9,9,0xC0,0xff,NULL);
- if (bflag[1]) BltBitMap(Bmap[2],obx[1],oby[1],Bmap[frame],
- obx[1],oby[1],9,9,0xC0,0xff,NULL);
- if (dead[0])
- BltBitMap(Bmap[2],px[0]-2,py[0]-2,Bmap[frame],
- px[0]-2,py[0]-2,19,17,0xC0,0xff,NULL);
- if (dead[1])
- BltBitMap(Bmap[2],px[1]-2,py[1]-2,Bmap[frame],
- px[1]-2,py[1]-2,19,17,0xC0,0xff,NULL);
- ox[0]=px[0],oy[0]=py[0],ox[1]=px[1],oy[1]=py[1];
- obx[0]=bx[0],oby[0]=by[0],obx[1]=bx[1],oby[1]=by[1];
- obstate[0]=bstate[0],obstate[1]=bstate[1];
- }
-
- void flipem() /* Double-buffer controller */
- {
- while (VBeamPos() != 250);
- setbitmap();
- frame = (1 - frame);
- scr->BitMap = *Bmap[frame];
- }
-
- void pause(pcount)
- USHORT pcount;
- {
- short i;
- for (i=0;i<pcount;i++) WaitBOVP(vp);
- }
-
- void cleantheamiga() /* cleanup routine */
- {
- register short i,j;
- Permit();
- ClearPointer(wdw);
- KillSounds();
- if (wdw != NULL) CloseWindow(wdw);
- if (scr != NULL) CloseScreen(scr);
- for (j=0; j<5; j++)
- { if (Bmap[j] != NULL)
- { for (i=0; i<4; i++)
- { if (Bmap[j]->Planes[i] != 0)
- FreeRaster(Bmap[j]->Planes[i],320,200);
- }
- FreeMem(Bmap[j], sizeof(struct BitMap));
- }
- }
- CloseLibrary(IntuitionBase);
- CloseLibrary(GfxBase);
- exit(FALSE);
- }
-