/**************************************************************************** * BUBBLEPUMPER STUDIOS * * presents * * !!! HELICOPTER GAME !!! * * * * By:Scott Ward * * * * My first real attempt to produce any kind of Yaroze game. Come to think * * of it, my first real attempt to create anything of use in C code aswell. * ****************************************************************************/ /*********************************INCLUDES**********************************/ #include #include #include "control.h" #include "angles.h" #include "struct.h" #include "CLines.c" /********************************CONSTANTS**********************************/ #define OT_LENGTH 3 //#define COLOT_LENGTH 1 #define HELIADDRESS 0x00090000 #define SKYADDRESS 0x00091200 #define LANDADDRESS 0x00091a50 #define AAGUNADDRESS 0x000922a0 #define HITADDRESS 0x000925c0 #define MENADDRESS 0x000927d0 #define SAMADDRESS 0x00092d50 #define PRISOADDRESS 0x00092f60 /********************************PROTOTYPES*********************************/ void LoadSprite(u_long *timaddress); void InitSprite(GsSPRITE *sprite,u_long attribute,short x,short y,u_short w,u_short h,u_short tpage,u_char u,u_char v,short cx,short cy,u_char r,u_char g,u_char b,short mx,short my,short scalex,short scaley,long rotate); void HeliMove(void); void SetupBG(void); void InitCLines(void); void GunLine(void); void GunFire(void); void AAGuns(void); void MoveMen(void); int HeliCollision(void); /*****************************GLOBAL VARIABLES******************************/ PACKET packetaddress[2][24000]/*,colpacketaddress[2][2000]*/; int currentbuffer,currentline,xline,shotx,shoty,poscode,poscount,screenbit,vertcount; GsOT OTtable[2]/*,ColOTtable[2]*/; GsOT_TAG OTtags[2][1<px; rect.y=image->py; rect.w=image->pw; rect.h=image->ph; LoadImage(&rect,image->pixel); //Wait for LoadImage() function to finish DrawSync(0); //Load CLUT data into frame buffer if there is one rect.x=image->cx; rect.y=image->cy; rect.w=image->cw; rect.h=image->ch; LoadImage(&rect,image->clut); //Wait for LoadImage() function to finish DrawSync(0); } //End of 'LoadSprite();' /******************************************************** * Name: void InitSprite(GsSPRITE *sprite,......) * * Parameters: Sprite pointer for GsSPRITE and all * * relevent arguments contained in structure * * Returns: Void * * Purpose: Initialises sprite variables. * ********************************************************/ void InitSprite(GsSPRITE *sprite,u_long attribute,short x,short y,u_short w,u_short h,u_short tpage,u_char u,u_char v,short cx,short cy,u_char r,u_char g,u_char b,short mx,short my,short scalex,short scaley,long rotate) { //Initialise all sprite variables with relevent info sprite->attribute=attribute; sprite->x=x; sprite->y=y; sprite->w=w; sprite->h=h; sprite->tpage=tpage; sprite->u=u; sprite->v=v; sprite->cx=cx; sprite->cy=cy; sprite->r=r; sprite->g=g; sprite->b=b; sprite->mx=mx; sprite->my=my; sprite->scalex=scalex; sprite->scaley=scaley; sprite->rotate=rotate; } //End of 'InitSprite();' /********************************************** * Name: void HeliMove(void) * * Parameters: Void * * Returns: Void * * Purpose: Deals with helicopter movements * **********************************************/ void HeliMove(void) { switch(HeliCollision()) { case 1: vertmomentum=(-20+(abs(vertmomentum/3)*-1)); if(colcode==0) { horimomentum=((horimomentum/3)*-1); colcode=1; } break; case 2: vertmomentum=(-20+(abs(vertmomentum/3)*-1)); horimomentum/=2; break; case 3: vertmomentum=0; horimomentum=0; landed=1; break; default:colcode=0; break; } if(PAD1UP) { vertmomentum-=4; if(vertmomentum<-200) vertmomentum=-200; } if(landed==0) { if(PAD1DOWN) { vertmomentum+=4; if(vertmomentum>200) vertmomentum=200; } if(!PAD1DOWN && !PAD1UP) { if(vertmomentum<0) vertmomentum++; if(vertmomentum>0) vertmomentum--; } if(PAD1RIGHT) { if(heliangle<20) helicopter.rotate+=2048; horimomentum+=4; if(horimomentum>200) horimomentum=200; } else if(PAD1LEFT) { if(heliangle>-20) helicopter.rotate-=2048; horimomentum-=4; if(horimomentum<-200) horimomentum=-200; } else { if(heliangle<0) helicopter.rotate+=1024; else if(heliangle>0) helicopter.rotate-=1024; else helicopter.rotate=0; if(horimomentum>0) horimomentum--; if(horimomentum<0) horimomentum++; } if(PAD1R1) poscode=1; if(PAD1L1) poscode=2; if(PAD1R1 && PAD1L1) poscode=3; if(poscode!=0) { poscount++; if(poscount==10) { if(poscode==1) { if(helicopter.u==216) poscode=0; else helicopter.u+=36; } else if(poscode==2) { if(helicopter.u==0) poscode=0; else helicopter.u-=36; } else { if(helicopter.u>108) helicopter.u-=36; if(helicopter.u<108) helicopter.u+=36; } poscount=0; } } } vertmove+=vertmomentum; if(vertmove<5000) { vertmove=5000; vertmomentum=0; } if(vertmove>23000) { vertmove=23000; vertmomentum=0; } helicopter.y=(vertmove/100); horimove+=horimomentum; if(horimove<200) { horimove=200; horimomentum=0; } if(horimove>64000) { horimove=64000; horimomentum=0; } landbg.scrollx=(horimove/100); helicopter.v+=12; if(helicopter.v==36) helicopter.v=0; heliangle=(helicopter.rotate/4096); } //End of 'HeliMove();' void SetupBG(void) { int a,b; static u_short skymapdata[16]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; static u_short landmapdata[16][60]={ -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,-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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //Initialise sky cells for(a=0;a<16;a++) { skycell[a].u=0; skycell[a].v=(a*16); skycell[a].cba=16468; skycell[a].flag=0; skycell[a].tpage=5; } //Initialise land cells for(a=0;a<4;a++) { for(b=0;b<4;b++) { landcell[((a*4)+b)].u=((b*16)+16); landcell[((a*4)+b)].v=(a*16); landcell[((a*4)+b)].cba=16532; landcell[((a*4)+b)].flag=0; landcell[((a*4)+b)].tpage=5; } } //Initialise skymap skymap.cellw=16; skymap.cellh=16; skymap.ncellw=1; skymap.ncellh=16; skymap.base=skycell; skymap.index=skymapdata; //Initialise landmap landmap.cellw=16; landmap.cellh=16; landmap.ncellw=60; landmap.ncellh=16; landmap.base=landcell; landmap.index=(u_short *)landmapdata; //Initialise background structure skybg.attribute=0; skybg.x=0; skybg.y=0; skybg.w=320; skybg.h=256; skybg.scrollx=0; skybg.scrolly=0; skybg.r=128; skybg.g=128; skybg.b=128; skybg.map=&skymap; skybg.mx=0; skybg.my=0; skybg.scalex=ONE; skybg.scaley=ONE; skybg.rotate=0; //Initialise land background structure landbg.attribute=0; landbg.x=0; landbg.y=0; landbg.w=320; landbg.h=256; landbg.scrollx=0; landbg.scrolly=0; landbg.r=128; landbg.g=128; landbg.b=128; landbg.map=&landmap; landbg.mx=0; landbg.my=0; landbg.scalex=ONE; landbg.scaley=ONE; landbg.rotate=0; } void GunLine(void) { int a,x2,x3,b0,b1,d0; if((groundlines[currentline].x-landbg.scrollx)>160) { currentline--; } if((groundlines[currentline].x1-landbg.scrollx)<160) { currentline++; } if(helicopter.u==216) { if(PAD1R2) { gunmove++; if(gunmove>90) { gunmove=90; } } if(PAD1L2) { gunmove--; if(gunmove<2) { gunmove=2; } } gunangle=gunmove/2; for(a=0;a<20;a++) { if(groundlines[(currentline+a)].gradient==0) { shotx=((((groundlines[(currentline+a)].y-helicopter.y)<<12)/gungradient[gunangle])+160); shoty=groundlines[(currentline+a)].y; if(shotx>=(groundlines[(currentline+a)].x-landbg.scrollx) && shotx<=(groundlines[(currentline+a)].x1-landbg.scrollx)) { xline=(currentline+a); break; } } else if(groundlines[(currentline+a)].gradient==1) { shotx=(groundlines[(currentline+a)].x-landbg.scrollx); shoty=(((gungradient[gunangle]*((groundlines[(currentline+a)].x-landbg.scrollx)-160))>>12)+helicopter.y); if(shoty>=groundlines[(currentline+a)].y && shoty<=groundlines[(currentline+a)].y1) { xline=(currentline+a); break; } } else { x2=((((groundlines[(currentline+a)].y1-helicopter.y)<<12)/gungradient[gunangle])+160); x3=((((groundlines[(currentline+a)].y-helicopter.y)<<12)/gungradient[gunangle])+160); if(x2<=(groundlines[(currentline+a)].x1-landbg.scrollx) && x3>=(groundlines[(currentline+a)].x-landbg.scrollx)) { b0=((helicopter.y<<12)-(gungradient[gunangle]*160)); b1=((groundlines[(currentline+a)].y<<12)-(groundlines[(currentline+a)].gradient*(groundlines[(currentline+a)].x-landbg.scrollx))); d0=((4096<<12)/((gungradient[gunangle]*-1)-(groundlines[(currentline+a)].gradient*-1))); shotx=((((b1*-1-b0*-1)>>12)*d0)>>12); shoty=((((shotx-(groundlines[(currentline+a)].x-landbg.scrollx))*groundlines[(currentline+a)].gradient)>>12)+groundlines[(currentline+a)].y); if(groundlines[(currentline+a)].gradient<0 && shoty>groundlines[(currentline+a)].y || groundlines[(currentline+a)].gradient>0 && shoty0 && shoty>groundlines[(currentline+a)].y1) { shoty=groundlines[(currentline+a)].y1; } xline=(currentline+a); break; } } } } if(helicopter.u==0) { if(PAD1L2) { gunmove++; if(gunmove>90) { gunmove=90; } } if(PAD1R2) { gunmove--; if(gunmove<2) { gunmove=2; } } gunangle=gunmove/2; for(a=0;a<20;a++) { if(groundlines[(currentline-a)].gradient==0) { shotx=((((groundlines[(currentline-a)].y-helicopter.y)<<12)/(gungradient[gunangle]*-1))+160); shoty=groundlines[(currentline-a)].y; if(shotx>=(groundlines[(currentline-a)].x-landbg.scrollx) && shotx<=(groundlines[(currentline-a)].x1-landbg.scrollx)) { xline=(currentline-a); break; } } else if(groundlines[(currentline-a)].gradient==1) { shotx=(groundlines[(currentline-a)].x-landbg.scrollx); shoty=((((gungradient[gunangle]*-1)*((groundlines[(currentline-a)].x-landbg.scrollx)-160))>>12)+helicopter.y); if(shoty>=groundlines[(currentline-a)].y && shoty<=groundlines[(currentline-a)].y1) { xline=(currentline-a); break; } } else { x2=((((groundlines[(currentline-a)].y1-helicopter.y)<<12)/(gungradient[gunangle]*-1))+160); x3=((((groundlines[(currentline-a)].y-helicopter.y)<<12)/(gungradient[gunangle]*-1))+160); if(x2<=(groundlines[(currentline-a)].x1-landbg.scrollx) && x3>=(groundlines[(currentline-a)].x-landbg.scrollx)) { b0=((helicopter.y<<12)-((gungradient[gunangle]*-1)*160)); b1=((groundlines[(currentline-a)].y<<12)-(groundlines[(currentline-a)].gradient*(groundlines[(currentline-a)].x-landbg.scrollx))); d0=((4096<<12)/(gungradient[gunangle]-(groundlines[(currentline-a)].gradient*-1))); shotx=((((b1*-1-b0*-1)>>12)*d0)>>12); shoty=((((shotx-(groundlines[(currentline-a)].x-landbg.scrollx))*groundlines[(currentline-a)].gradient)>>12)+groundlines[(currentline-a)].y); if(groundlines[(currentline-a)].gradient<0 && shoty>groundlines[(currentline-a)].y || groundlines[(currentline-a)].gradient>0 && shoty0 && shoty>groundlines[(currentline-a)].y1) { shoty=groundlines[(currentline-a)].y1; } xline=(currentline-a); break; } } } } if(PAD1CROSS) { GunFire(); } else { fireline.attribute=(1<<31); gunhit.attribute=(1<<31); gunfire.attribute=(1<<31); } /*line1.attribute=0; line1.x0=(groundlines[currentline].x-landbg.scrollx); line1.y0=groundlines[currentline].y; line1.x1=(groundlines[currentline].x1-landbg.scrollx); line1.y1=groundlines[currentline].y1; line1.r=200; line1.g=200; line1.b=100; line2.attribute=0; line2.x0=(groundlines[xline].x-landbg.scrollx); line2.y0=groundlines[xline].y; line2.x1=(groundlines[xline].x1-landbg.scrollx); line2.y1=groundlines[xline].y1; line2.r=200; line2.g=100; line2.b=0; line3.attribute=((1<<29)&(1<<28)&(1<<30)); line3.x0=160; line3.y0=helicopter.y; line3.x1=shotx; line3.y1=shoty; line3.r=100; line3.g=0; line3.b=200;*/ } void AAGuns(void) { short i,j; long misx,misy,dx,dy,dxy; aagun[0].x=(gun[0].xco_ord-landbg.scrollx); aagun[1].x=(gun[1].xco_ord-landbg.scrollx); samsite.x=(site.xco_ord-landbg.scrollx); // WORK OUT THE SAMSITE MOVEMENT AND FIRING. if(abs(samsite.x-150)<=25) { samsite.u=188; } else if((samsite.x-150)>25) { samsite.u=176; } else { samsite.u=200; } if(site.fire==0) { if(abs(samsite.x-155)<=100) { site.mislock--; if(site.mislock<=0) { site.fire=1; } } else { site.mislock=200; } } if(site.fire==1) { missile.attribute=0; missmoke[0].attribute=0; missmoke[1].attribute=0; missmoke[2].attribute=0; site.miscount--; if(site.miscount>=200) site.misspeed=1; else if(site.miscount>=100) site.misspeed=2; else site.misspeed=3; dx=(helicopter.x-missile.x); dy=(helicopter.y-missile.y); if(dx==0 && dy==0) { site.fire=2; } else { if(site.miscount%2) { missile.v+=4; if(missile.v>21) missile.v=13; } if(site.miscount%10==0) { missmoke[2].y=missmoke[1].y; missmoke[1].y=missmoke[0].y; missmoke[0].y=missile.y; site.smokexco_ord[2]=site.smokexco_ord[1]; site.smokexco_ord[1]=site.smokexco_ord[0]; site.smokexco_ord[0]=site.misco_ord; } if(abs(dy)<(abs(dx)/2)) { if(dx>=0) missile.u=184; if(dx<0) missile.u=200; } else if(abs(dx)<(abs(dy)/2)) { if(dy>=0) missile.u=192; if(dy<0) missile.u=176; } else { if(dx>=0) { if(dy>=0) missile.u=188; else missile.u=180; } if(dx<0) { if(dy>=0) missile.u=196; else missile.u=204; } } dxy=(abs(dx)+abs(dy)); misx=(((dx*100)*site.misspeed)/dxy); misy=(((dy*100)*site.misspeed)/dxy); site.misxmove+=misx; site.misymove+=misy; site.misco_ord=(site.misxmove/100); missile.y=(site.misymove/100); } if(missile.x<0 || missile.x>320 || missile.y<0 || site.fire==2 || site.miscount<0) { missile.attribute=(1<<31); missmoke[0].attribute=(1<<31); missmoke[1].attribute=(1<<31); missmoke[2].attribute=(1<<31); site.smokexco_ord[0]=0; site.smokexco_ord[1]=0; site.smokexco_ord[2]=0; site.misco_ord=(site.xco_ord+4); site.misxmove=(site.misco_ord*100); site.misymove=((samsite.y+4)*100); site.fire=0; site.mislock=200; site.misspeed=1; site.miscount=300; } } missile.x=(site.misco_ord-landbg.scrollx); missmoke[0].x=(site.smokexco_ord[0]-landbg.scrollx); missmoke[1].x=(site.smokexco_ord[1]-landbg.scrollx); missmoke[2].x=(site.smokexco_ord[2]-landbg.scrollx); //WORK OUT THE MOVEMENT AND FIRING FOR AAGUNS. for(i=0;i<2;i++) { if(abs(aagun[i].x-160)<=80) { if(abs(aagun[i].x-160)<=20) { aagun[i].u=96; } else if(aagun[i].x-160>20) { aagun[i].u=80; } else { aagun[i].u=112; } if(gun[i].fire==0 && (aagun[i].y-helicopter.y)>20) { aagun[i].v=15; for(j=0;j<5;j++) { if(blast[j].status==0) { explode[j].y=(helicopter.y-10); blast[j].xco_ord=(150+landbg.scrollx); blast[j].status=1; blast[j].travel=(((aagun[i].y-helicopter.y)/2)+(abs(aagun[i].x-160)/3)); break; } } gun[i].fire=100; } else { aagun[i].v=0; if(gun[i].fire>0) { gun[i].fire--; } } } } for(i=0;i<5;i++) { if(blast[i].status==1) { if(blast[i].travel<=0) { explode[i].attribute=0; explode[i].x=(blast[i].xco_ord-landbg.scrollx); blast[i].time--; if(blast[i].time<=0) { blast[i].time=20; blast[i].status=0; explode[i].attribute=(1<<31); } } else { blast[i].travel--; } } } } void GunFire(void) { int firex0,firey0,firex1,firey1; if(helicopter.u==0 || helicopter.u==216) { if(helicopter.u==216) { firey0=((rand()%(shoty-helicopter.y))+helicopter.y); firey1=(firey0+10); if(firey1>shoty) { firey1=shoty; } firex0=((((firey0-helicopter.y)<<12)/gungradient[gunangle])+160); firex1=((((firey1-helicopter.y)<<12)/gungradient[gunangle])+160); } if(helicopter.u==0) { firey0=((rand()%(shoty-helicopter.y))+helicopter.y); firey1=(firey0+10); if(firey1>shoty) { firey1=shoty; } firex0=((((firey0-helicopter.y)<<12)/(gungradient[gunangle]*-1))+160); firex1=((((firey1-helicopter.y)<<12)/(gungradient[gunangle]*-1))+160); } fireline.attribute=0; fireline.x0=firex0; fireline.y0=firey0; fireline.x1=firex1; fireline.y1=firey1; fireline.r0=255; fireline.g0=0; fireline.b0=0; fireline.r1=255; fireline.g1=255; fireline.b1=0; gunhit.attribute=0; gunhit.x=((shotx-3)+rand()%3); gunhit.y=((shoty-3)+rand()%3); gunhit.u=(80+((rand()%3)*5)); gunhit.v=(30+(5*groundlines[xline].surface)); gunfire.attribute=0; gunfire.y=(helicopter.y+1); gunfire.u=(80+((rand()%3)*5)); } else { fireline.attribute=(1<<31); gunhit.attribute=(1<<31); gunfire.attribute=(1<<31); } } void MoveMen(void) { int a; prison.x=(jail.xco_ord-landbg.scrollx); if((soldiers.y-helicopter.y)<100 && abs(soldiers.x-160)<90) { am.direction=2; am.count=100; am.firecount--; if(am.firecount<=0) { am.firecount=3; if(abs(soldiers.x-160)<=15) { if(soldiers.u==144) soldiers.u=152; else if(soldiers.u==152) soldiers.u=144; else soldiers.u=144; } else if(soldiers.x-160>15) { if(soldiers.u==128) soldiers.u=136; else if(soldiers.u==136) soldiers.u=128; else soldiers.u=128; } else { if(soldiers.u==160) soldiers.u=168; else if(soldiers.u==168) soldiers.u=160; else soldiers.u=160; } } } else { am.count--;; if(am.count<=0) { am.count=400; am.direction=rand()%3; } if(landed==1 && (base.start-landbg.scrollx)<160 && (base.finish-landbg.scrollx)>160) { if(soldiers.x>160) am.direction=1; if(soldiers.x<160) am.direction=0; } if(am.count%4==0) { switch(am.direction) { case 0: am.xco_ord++; break; case 1: am.xco_ord--; break; default:break; } if(am.xco_ord<=base.start) { am.direction=0; } if(am.xco_ord>=base.finish) { am.direction=1; } for(a=0;a<4;a++) { if(am.xco_ord>=base.slpstrt[a] && am.xco_ord<=base.slpfnsh[a]) { if(am.xco_ord==base.slpstrt[a] && am.direction==0) { break; } if(am.xco_ord==base.slpfnsh[a] && am.direction==1) { break; } if(base.slpgrdt[a]==1) { switch(am.direction) { case 0: soldiers.y--; break; case 1: soldiers.y++; break; default: break; } } else if(base.slpgrdt[a]==2) { switch(am.direction) { case 0: soldiers.y++; break; case 1: soldiers.y--; break; default: break; } } } } } } if(am.count%4==0 && am.direction!=2) { soldiers.u+=8; if(soldiers.u>168) { soldiers.u=128; } } if(am.direction==2 && ((soldiers.y-helicopter.y)>=100 || abs(soldiers.x-160)>=90)) { soldiers.u=152; } soldiers.v=(am.direction*8); soldiers.x=(am.xco_ord-landbg.scrollx); } int HeliCollision(void) { short i,j,lineno,refpoint,min,max,x1,y1,x2,y2,x3,y3,x4,y4,start,stop; int m1,m2,a,b; switch(helicopter.u) { case 0: lineno=((heliangle/3)+6); refpoint=1; break; case 36: if(abs(heliangle)==20) { if(heliangle==20) lineno=21; if(heliangle==-20) lineno=13; } else lineno=((heliangle/4)+17); refpoint=1; break; case 72: if(abs(heliangle)==20) { if(heliangle==20) lineno=30; if(heliangle==-20) lineno=22; } else lineno=((heliangle/4)+26); refpoint=1; break; case 108: lineno=((heliangle/3)+37); refpoint=1; break; case 144: if(abs(heliangle)==20) { if(heliangle==20) lineno=22; if(heliangle==-20) lineno=30; } else lineno=(((heliangle*-1)/4)+26); refpoint=-1; break; case 180: if(abs(heliangle)==20) { if(heliangle==20) lineno=13; if(heliangle==-20) lineno=21; } else lineno=(((heliangle*-1)/4)+17); refpoint=-1; break; case 216: lineno=(((heliangle*-1)/3)+6); refpoint=-1; break; default : break; } a=(160+(collines[lineno].x1[4]*refpoint)); b=(160+(collines[lineno].x2[4]*refpoint)); for(i=0;i<4;i++) { if(a<(160+(collines[lineno].x1[i]*refpoint))) a=(160+(collines[lineno].x1[i]*refpoint)); if(b<(160+(collines[lineno].x2[i]*refpoint))) b=(160+(collines[lineno].x2[i]*refpoint)); } max=(a(160+(collines[lineno].x1[i]*refpoint))) a=(160+(collines[lineno].x1[i]*refpoint)); if(b>(160+(collines[lineno].x2[i]*refpoint))) b=(160+(collines[lineno].x2[i]*refpoint)); } min=(a>b) ? b : a; for(i=0;i<10;i++) { if((groundlines[(currentline-i)].x1-landbg.scrollx)max) { stop=((currentline+i)-start); break; } } //printf("Start: %d Stop: %d Min: %d Max: %d\n",start,stop,min,max); //start=currentline; //i=0; //j=4; if(groundlines[currentline].gradient==0 && ((groundlines[currentline].x-landbg.scrollx)<=158) && ((groundlines[currentline].x1-landbg.scrollx)>=164) && (groundlines[currentline].y==(helicopter.y+5)) && helicopter.u==108 && heliangle==0 && vertmomentum<40 && vertmomentum>=0) return(3); else landed=0; for(i=0;i=x1) return(2); } else if(m2==1) { if(y3<=y1 && y4>=y1 && x3>=x1 && x3<=x2) return(2); } else { if(y3<=y1 && y4>=y1) { a=((((y1-(helicopter.y+collines[lineno].y1[j]))<<12)/m2)+(160+(collines[lineno].x1[j]*refpoint))); if(a>=x1 && a<=x2) return(2); } } } if(groundlines[(start+i)].gradient==1 && (y1-helicopter.y)<10) { if(m2==0) { if(y3>=y1 && y3<=y2 && x3<=x1 && x4>=x1) return(1); } else if(m2==1) { if(x1==x3 && y4>=y1 && y3<=y2) return(1); } else { if(x3<=x1 && x4>=x1) { a=((m2*(x1-(160+(collines[lineno].x1[j]*refpoint)))>>12)+(helicopter.y+collines[lineno].y1[j])); if(a>=y1 && a<=y2) return(1); } } } if(groundlines[(start+i)].gradient!=0 && groundlines[(start+i)].gradient!=1 && (y1-helicopter.y)<10) { if(m2==0) { if(y3<=y2 && y3>=y1) { a=((((y3-groundlines[(start+i)].y)<<12)/groundlines[(start+i)].gradient)+(groundlines[(start+i)].x-landbg.scrollx)); if(a<=x4 && a>=x3) return(1); } } else if(m2==1) { if(x1<=x3 && x2>=x3) { a=((groundlines[(start+i)].gradient*(x3-(groundlines[(start+i)].x-landbg.scrollx)))+groundlines[(start+i)].y); if(a<=y4 && a>=y3) return(1); } } else { if(y4>=y1 && x3<=x2 && x4>=x1) { if(m1==-4096) m1=-3000; y1=groundlines[(start+i)].y; y2=groundlines[(start+i)].y1; y3=(x3==(160+(collines[lineno].x1[j]*refpoint))) ? (collines[lineno].y1[j]+helicopter.y) : (collines[lineno].y2[j]+helicopter.y); y4=(y3==(collines[lineno].y1[j]+helicopter.y)) ? (collines[lineno].y2[j]+helicopter.y) : (collines[lineno].y1[j]+helicopter.y); if(x1>12)+y1); if(x3>12)+y4); a=y3-y1; if(x2>x4) y2=((((x4-x1)*m1)>>12)+y1); if(x4>x2) y4=((((x2-x3)*m2)>>12)+y3); b=y4-y2; if(a==0 || b==0 || (a<0 && b>0) || (a>0 && b<0)) return(1); } } } } } l1.attribute=0; l1.x0=158; l1.y0=(helicopter.y+5); l1.x1=164; l1.y1=(helicopter.y+5); l1.r=255; l1.g=255; l1.b=0; /*l2.attribute=0; l2.x0=(160+(collines[lineno].x1[1]*refpoint)); l2.y0=(helicopter.y+collines[lineno].y1[1]); l2.x1=(160+(collines[lineno].x2[1]*refpoint)); l2.y1=(helicopter.y+collines[lineno].y2[1]); l2.r=255; l2.g=0; l2.b=255; l3.attribute=0; l3.x0=(160+(collines[lineno].x1[2]*refpoint)); l3.y0=(helicopter.y+collines[lineno].y1[2]); l3.x1=(160+(collines[lineno].x2[2]*refpoint)); l3.y1=(helicopter.y+collines[lineno].y2[2]); l3.r=0; l3.g=255; l3.b=255; l4.attribute=0; l4.x0=(160+(collines[lineno].x1[3]*refpoint)); l4.y0=(helicopter.y+collines[lineno].y1[3]); l4.x1=(160+(collines[lineno].x2[3]*refpoint)); l4.y1=(helicopter.y+collines[lineno].y2[3]); l4.r=255; l4.g=0; l4.b=0; l5.attribute=0; l5.x0=(160+(collines[lineno].x1[4]*refpoint)); l5.y0=(helicopter.y+collines[lineno].y1[4]); l5.x1=(160+(collines[lineno].x2[4]*refpoint)); l5.y1=(helicopter.y+collines[lineno].y2[4]); l5.r=0; l5.g=0; l5.b=255;*/ l6.attribute=0; l6.x0=(groundlines[currentline].x-landbg.scrollx); l6.y0=groundlines[currentline].y; l6.x1=(groundlines[currentline].x1-landbg.scrollx); l6.y1=groundlines[currentline].y1; l6.r=0; l6.g=0; l6.b=255; GsSortLine(&l1,&OTtable[currentbuffer],0); //GsSortLine(&l2,&OTtable[currentbuffer],0); //GsSortLine(&l3,&OTtable[currentbuffer],0); //GsSortLine(&l4,&OTtable[currentbuffer],0); //GsSortLine(&l5,&OTtable[currentbuffer],0); GsSortLine(&l6,&OTtable[currentbuffer],0); return(0); }