//-------------------------------------------------------------- // Alien Looter //-------------------------------------------------------------- #include #include #include #include #include "pad.h" #define SHIP_TIM 0x80090000 #define FRONT_TIM 0x80090214 #define ENEMY1_TIM 0x8009d068 #define EXPLODE_TIM 0x8009d27c #define NORM_TIM 0x8009f290 #define ROCK_TIM 0x8009f324 #define ROCK2_TIM 0x8009f738 #define SOUNDS_VH 0x8009fb4c #define SOUNDS_VB 0x800a156c #define FONT_TIM 0x800beabc #define MISSILE_TIM 0x800c2430 #define TUBE_TIM 0x800c2504 #define ADDON_TIM 0x800c2618 #define BIGLAS_TIM 0x800c282c #define PLANET_TIM 0x800c2c40 #define FIRE1_TIM 0x800d3f54 #define IONISER_TIM 0x800d4368 #define WIDE_TIM 0x800d4b7c #define RING_TIM 0x800d5090 #define JUPITER_TIM 0x800d58a4 #define MARS_TIM 0x800d5ab8 #define MOON_TIM 0x800d5ccc #define NEPTUNE_TIM 0x800d5ee0 #define LASER1_TIM 0x800d60f4 #define LASER2_TIM 0x800d6508 #define UFO_TIM 0x800d691c #define BOMB_TIM 0x800d6d30 #define ENEMY2_TIM 0x800d6e44 #define ENEMY3_TIM 0x800d7058 #define ENEMY4_TIM 0x800d726c #define ENEMY5_TIM 0x800d7480 #define ENEMY6_TIM 0x800d7694 #define ENEMY7_TIM 0x800d78a8 #define ENEMY8_TIM 0x800d7abc #define YOYO_TIM 0x800d7cd0 #define SOUNDS2_VH 0x800d84e4 #define SOUNDS2_VB 0x800d9f04 #define GAMEOVER_TIM 0x800e0d04 #define PSTART_TIM 0x800e4918 #define OT_LEN 12 #define MAX_PACKETS 102400 #define MAX_ENEMIES 40 #define MAX_BOMBS 128 #define MAX_ORD 128 #define MAX_BSPLATS 1024 #define MAX_EXPLODE 128 #define SPACE 4 #define PRI_CHAR 0 #define PRI_PLAYER 1 #define PRI_OTHER 3 #define PRI_ENEMY 2 #define PRI_EXPLODE 4 #define PRI_FIRE 5 #define FORM_SIZE 40 #define WEAP_NORM 0 #define WEAP_LASER 1 #define WEAP_WIDE 2 #define WEAP_FIRE1 3 #define WEAP_IONISER 4 #define WEAP_RING 5 #define TUBE1 0x01 #define TUBE2 0x02 #define ADD1 0x04 #define ADD2 0x08 //-------------------------------------------------------------- typedef struct { GsSPRITE sprite; GsIMAGE image; int add; int c; int weap; int score; int lives; int speed; int holdX, holdTR, holdSQ; }Player; typedef struct { GsSPRITE sprite; int type; }Enemy; typedef struct { GsSPRITE sprite; int ax,ay; int type; } Ord; typedef struct { GsSPRITE sprite; int ax,ay; int c,f; }Explode; typedef struct { GsGLINE line; int x,y; int ax,ay; }BSplat; u_long PADstatus=0; volatile u_char *bb0, *bb1; int hiscore; int nTune=0; int bang; int strobe=0; int nEDir; int nEnemies; int nBuffer; int bPlaying; int bRunning=1; int bComplete; int nVab; int nVab2; int nVab3; int nLevel; PACKET out_packet[2][MAX_PACKETS]; GsOT othWorld[2]; GsOT_TAG otWorld[2][1<hiscore) hiscore=player.score; GameOver(); } SsVabClose(nVab); SsVabClose(nVab2); rClear.h=512; ClearImage(&rClear,0,0,0); ResetGraph(3); return 0; } //-------------------------------------------------------------- int ShowTitles(void) { int nCount=0; int nStrobe=0; char text[64]; RECT rBlob={960,256,16,16}; RECT rArea={0,0,320,512}; RECT rClear={0,0,320,256}; GsSPRITE pf; pf.x=160; pf.y=180; pf.w=256; pf.h=62; pf.u=0; pf.v=58; pf.r=0; pf.g=128; pf.b=0; pf.mx=128; pf.my=20; pf.scalex=ONE; pf.scaley=ONE; pf.rotate=0; pf.tpage=GetTPage(2, 0, 320, 314); pf.attribute=(1<<25); do { PADstatus=PadRead(0); nBuffer=GsGetActiveBuff(); GsSetWorkBase((PACKET*)out_packet[nBuffer]); GsClearOt(0, 0, &othWorld[nBuffer]); if(!nTune) SsUtKeyOn(nVab, 2,0, 48, 0, 128,128); nTune++; if(nTune>329) nTune=0; rClear.y=nBuffer*256; ClearImage(&rClear, 0, 0, 0); rArea.x=60; rArea.y=nBuffer*256; rArea.w=200; rArea.h=132; LoadImage(&rArea, (u_long *)FRONT_TIM+5); if(nStrobe<400) { if((nStrobe%32)>8) GsSortSprite(&pf, &othWorld[nBuffer], 0); } else if(nStrobe<800) { strcpy(text, "Controls:"); OutputString(text, -1, GetCentre(text),140); strcpy(text, "LEFT: Move Left"); OutputString(text, -1, GetCentre(text),160); strcpy(text, "RIGHT: Move Right"); OutputString(text, -1, GetCentre(text),180); strcpy(text, "X: Fire Weapons"); OutputString(text, -1, GetCentre(text),200); strcpy(text, "SELECT: Quit"); OutputString(text, -1, GetCentre(text),220); } else if(nStrobe<1600) { strcpy(text, "Pick-ups:"); OutputString(text, -1, GetCentre(text),140); rBlob.y=256; MoveImage(&rBlob, 50, (nBuffer*256)+160); rBlob.y+=16; MoveImage(&rBlob, 50, (nBuffer*256)+180); rBlob.y+=16; MoveImage(&rBlob, 50, (nBuffer*256)+200); rBlob.y+=16; MoveImage(&rBlob, 50, (nBuffer*256)+220); strcpy(text, "Upgrade weapon or extra life"); OutputString(text, -1, 70,163); strcpy(text, "New add-on or extra life"); OutputString(text, -1, 70,183); strcpy(text, "Upgrade weapon or 5000 points"); OutputString(text, -1, 70,203); strcpy(text, "Extra life"); OutputString(text, -1, 70,223); } else if(nStrobe<1600) { strcpy(text, "Today's highest score: "); strcat(text, OutputNum(hiscore,8)); OutputString(text, -1, GetCentre(text),180); } else if(nStrobe<2000) { strcpy(text, "ALIEN LOOTER was written by Ben James"); OutputString(text, -1, GetCentre(text),160); strcpy(text, "during May 1998 and is dedicated"); OutputString(text, -1, GetCentre(text),180); strcpy(text, "to everyone who plays it."); OutputString(text, -1, GetCentre(text),200); } GsDrawOt(&othWorld[nBuffer]); FntFlush(-1); DrawSync(0); VSync(0); GsSwapDispBuff(); GsSortClear(0,0,0,&othWorld[nBuffer]); nStrobe++; if(nStrobe>2000) nStrobe=0; } while(!(PADstatus & PADstart)); } //-------------------------------------------------------------- int LoadTIM(long addr) { RECT rect; GsIMAGE tim1; GsGetTimInfo((u_long *)(addr+4),&tim1); rect.x=tim1.px; rect.y=tim1.py; rect.w=tim1.pw; rect.h=tim1.ph; LoadImage(&rect,tim1.pixel); if((tim1.pmode>>3)&0x01) { rect.x=tim1.cx; rect.y=tim1.cy; rect.w=tim1.cw; rect.h=tim1.ch; LoadImage(&rect,tim1.clut); } DrawSync(0); return(0); } //-------------------------------------------------------------- void Initialise() { int nCount; LoadTIM(NORM_TIM); LoadTIM(SHIP_TIM); LoadTIM(ENEMY1_TIM); LoadTIM(ENEMY2_TIM); LoadTIM(ENEMY3_TIM); LoadTIM(ENEMY4_TIM); LoadTIM(ENEMY5_TIM); LoadTIM(ENEMY6_TIM); LoadTIM(ENEMY7_TIM); LoadTIM(ENEMY8_TIM); LoadTIM(EXPLODE_TIM); LoadTIM(ROCK_TIM); LoadTIM(ROCK2_TIM); LoadTIM(MISSILE_TIM); LoadTIM(TUBE_TIM); LoadTIM(ADDON_TIM); LoadTIM(BIGLAS_TIM); LoadTIM(WIDE_TIM); LoadTIM(FIRE1_TIM); LoadTIM(IONISER_TIM); LoadTIM(RING_TIM); LoadTIM(LASER1_TIM); LoadTIM(LASER2_TIM); LoadTIM(BOMB_TIM); LoadTIM(UFO_TIM); LoadTIM(YOYO_TIM); LoadTIM(MARS_TIM); LoadTIM(MOON_TIM); LoadTIM(NEPTUNE_TIM); LoadTIM(JUPITER_TIM); LoadTIM(GAMEOVER_TIM); LoadTIM(PSTART_TIM); LoadTIM(FONT_TIM); SetVideoMode(MODE_PAL); GsInitGraph(320, 240, GsINTER|GsOFSGPU, 0, 0); GsDefDispBuff(0, 0, 0, 256); othWorld[0].length=OT_LEN; othWorld[1].length=OT_LEN; othWorld[0].org=otWorld[0]; othWorld[1].org=otWorld[1]; GsClearOt(0,0,&othWorld[0]); GsClearOt(0,0,&othWorld[1]); nVab=SsVabTransfer((u_char *)SOUNDS_VH, (u_char *)SOUNDS_VB, -1, 1); nVab2=SsVabTransfer((u_char *)SOUNDS2_VH, (u_char *)SOUNDS2_VB, -1, 1); player.sprite.w=16; player.sprite.h=16; player.sprite.u=0; player.sprite.v=0; player.sprite.r=128; player.sprite.g=128; player.sprite.b=128; player.sprite.y=218; player.sprite.mx=0; player.sprite.my=0; player.sprite.tpage=GetTPage(2, 0, 320, 0); player.sprite.attribute=(1<<25)+(1<<27); rock.sprite.w=32; rock.sprite.h=16; rock.sprite.u=0; rock.sprite.r=128; rock.sprite.g=128; rock.sprite.b=128; rock.sprite.mx=16; rock.sprite.my=8; rock.sprite.scalex=ONE; rock.sprite.scaley=ONE; rock.sprite.rotate=0; rock.sprite.tpage=GetTPage(2, 0, 768, 0); rock.sprite.attribute=(1<<25); ufo.sprite.x=0; ufo.sprite.y=12; ufo.sprite.w=32; ufo.sprite.h=16; ufo.sprite.u=0; ufo.sprite.v=16; ufo.sprite.r=128; ufo.sprite.g=128; ufo.sprite.b=128; ufo.sprite.mx=0; ufo.sprite.my=0; ufo.sprite.scalex=ONE; ufo.sprite.scaley=ONE; ufo.sprite.rotate=0; ufo.sprite.tpage=GetTPage(2, 0, 704, 16); ufo.sprite.attribute=(1<<25)+(1<<27); yoyo.sprite.x=0; yoyo.sprite.y=0; yoyo.sprite.w=32; yoyo.sprite.h=32; yoyo.sprite.u=0; yoyo.sprite.v=20; yoyo.sprite.r=128; yoyo.sprite.g=128; yoyo.sprite.b=128; yoyo.sprite.mx=16; yoyo.sprite.my=16; yoyo.sprite.scalex=ONE; yoyo.sprite.scaley=ONE; yoyo.sprite.rotate=0; yoyo.sprite.tpage=GetTPage(2, 0, 960, 20); yoyo.sprite.attribute=(1<<25); pickup.sprite.w=16; pickup.sprite.h=16; pickup.sprite.u=0; pickup.sprite.r=128; pickup.sprite.g=128; pickup.sprite.b=128; pickup.sprite.mx=0; pickup.sprite.my=0; pickup.sprite.scalex=ONE; pickup.sprite.scaley=ONE; pickup.sprite.attribute=(1<<25)+(1<<27); } //-------------------------------------------------------------- void NewGame() { int nCount; nLevel=1; player.sprite.x=144; player.speed=4; player.score=0; player.lives=3; player.weap=WEAP_NORM; player.add=0; nEDir=1; rock.c=-1; ufo.c=-100; pickup.c=-1; for(nCount=0; nCount=MAX_ENEMIES*3) nForm=0; type[7]=type[0]; for(nCount=0; nCount<7; nCount++) type[nCount]=type[nCount+1]; for(nCount=0; nCount=250) { x=50; y+=20; } } } //-------------------------------------------------------------- void GetInput() { PADstatus=PadRead(0); if(PADstatus & PADLleft) player.sprite.x-=player.speed; else if(PADstatus & PADLright) player.sprite.x+=player.speed; if(PADstatus & PADRdown) { if(!player.holdX) StartFiring(); player.holdX=1; } else player.holdX=0; if(PADstatus & PADselect) { bRunning=0; bPlaying=0; } } //-------------------------------------------------------------- void StartFiring() { int nCount=0; while(ord[nCount].type!=-1) nCount++; ord[nCount].sprite.r=128; ord[nCount].sprite.g=128; ord[nCount].sprite.b=128; ord[nCount].sprite.u=0; ord[nCount].sprite.v=0; ord[nCount].sprite.mx=0; ord[nCount].sprite.my=0; ord[nCount].sprite.attribute=(1<<25)+(1<<27); switch(player.weap) { case WEAP_NORM: SsUtKeyOn(nVab, 0,0, 48, 0, 128,128); ord[nCount].type=WEAP_NORM; ord[nCount].sprite.w=4; ord[nCount].sprite.h=16; ord[nCount].sprite.v=32; ord[nCount].sprite.r=255; ord[nCount].sprite.tpage=GetTPage(2, 0, 320, 32); ord[nCount].sprite.x=player.sprite.x+6; ord[nCount].sprite.y=player.sprite.y; ord[nCount].ax=0; ord[nCount].ay=-10; break; case WEAP_LASER: SsUtKeyOn(nVab, 7,0, 36, 0, 128,128); ord[nCount].type=WEAP_LASER; ord[nCount].sprite.w=16; ord[nCount].sprite.h=32; ord[nCount].sprite.r=64; ord[nCount].sprite.g=255; ord[nCount].sprite.b=64; if(strobe&1) { ord[nCount].sprite.tpage=GetTPage(2, 0, 640, 32); ord[nCount].sprite.v=32; } else { ord[nCount].sprite.tpage=GetTPage(2, 0, 640, 64); ord[nCount].sprite.v=64; } ord[nCount].sprite.x=player.sprite.x; ord[nCount].sprite.y=player.sprite.y-8; ord[nCount].ax=0; ord[nCount].ay=-14; break; case WEAP_WIDE: SsUtKeyOn(nVab, 6,0, 36, 0, 128,128); ord[nCount].type=WEAP_WIDE; ord[nCount].sprite.w=32; ord[nCount].sprite.h=20; ord[nCount].sprite.tpage=GetTPage(2, 0, 960, 0); ord[nCount].sprite.x=player.sprite.x-8; ord[nCount].sprite.y=player.sprite.y; ord[nCount].ax=0; ord[nCount].ay=-16; break; case WEAP_FIRE1: SsUtKeyOn(nVab, 5,0, 36, 0, 128,128); ord[nCount].type=WEAP_FIRE1; ord[nCount].sprite.w=16; ord[nCount].sprite.h=32; ord[nCount].sprite.tpage=GetTPage(2, 0, 896, 0); ord[nCount].sprite.x=player.sprite.x; ord[nCount].sprite.y=player.sprite.y; ord[nCount].ax=0; ord[nCount].ay=-28; break; case WEAP_IONISER: SsUtKeyOn(nVab, 3,0, 40, 0, 128,128); ord[nCount].type=WEAP_IONISER; ord[nCount].sprite.g=228; ord[nCount].sprite.b=228; ord[nCount].sprite.w=32; ord[nCount].sprite.h=32; ord[nCount].sprite.tpage=GetTPage(2, 0, 832, 0); ord[nCount].sprite.x=player.sprite.x-8; ord[nCount].sprite.y=player.sprite.y+8; ord[nCount].ax=0; ord[nCount].ay=-30; break; case WEAP_RING: SsUtKeyOn(nVab, 0,0, 44, 0, 128,128); ord[nCount].type=WEAP_RING; ord[nCount].sprite.w=32; ord[nCount].sprite.h=32; ord[nCount].sprite.v=16; ord[nCount].sprite.tpage=GetTPage(2, 0, 576, 16); ord[nCount].sprite.x=player.sprite.x-8; ord[nCount].sprite.y=player.sprite.y+8; ord[nCount].ax=0; ord[nCount].ay=-26; break; default: break; } if(player.add&TUBE1) { nCount=0; while(ord[nCount].type!=-1) nCount++; ord[nCount].type=WEAP_NORM; ord[nCount].sprite.w=6; ord[nCount].sprite.h=16; ord[nCount].sprite.u=0; ord[nCount].sprite.v=16; ord[nCount].sprite.r=128; ord[nCount].sprite.g=128; ord[nCount].sprite.b=128; ord[nCount].sprite.mx=0; ord[nCount].sprite.my=0; ord[nCount].sprite.tpage=GetTPage(2, 0, 320, 16); ord[nCount].sprite.attribute=(1<<25)+(1<<27); ord[nCount].sprite.x=player.sprite.x-8; if(player.add&ADD1) ord[nCount].sprite.x-=16; ord[nCount].sprite.y=player.sprite.y; ord[nCount].ax=-1; ord[nCount].ay=-6; } if(player.add&TUBE2) { nCount=0; while(ord[nCount].type!=-1) nCount++; ord[nCount].type=WEAP_NORM; ord[nCount].sprite.w=6; ord[nCount].sprite.h=16; ord[nCount].sprite.u=0; ord[nCount].sprite.v=16; ord[nCount].sprite.r=128; ord[nCount].sprite.g=128; ord[nCount].sprite.b=128; ord[nCount].sprite.mx=0; ord[nCount].sprite.my=0; ord[nCount].sprite.tpage=GetTPage(2, 0, 320, 16); ord[nCount].sprite.attribute=(1<<25)+(1<<27); ord[nCount].sprite.x=player.sprite.x+16; if(player.add&ADD2) ord[nCount].sprite.x+=16; ord[nCount].sprite.y=player.sprite.y; ord[nCount].ax=1; ord[nCount].ay=-6; } if(player.add&ADD1) { nCount=0; while(ord[nCount].type!=-1) nCount++; ord[nCount].type=WEAP_NORM; ord[nCount].sprite.w=16; ord[nCount].sprite.h=32; ord[nCount].sprite.u=0; ord[nCount].sprite.v=0; ord[nCount].sprite.r=64; ord[nCount].sprite.g=128; ord[nCount].sprite.b=128; ord[nCount].sprite.mx=0; ord[nCount].sprite.my=0; ord[nCount].sprite.tpage=GetTPage(2, 0, 640, 0); ord[nCount].sprite.attribute=(1<<25)+(1<<27); ord[nCount].sprite.x=player.sprite.x-16; ord[nCount].sprite.y=player.sprite.y; ord[nCount].ax=0; ord[nCount].ay=-16; } if(player.add&ADD2) { nCount=0; while(ord[nCount].type!=-1) nCount++; ord[nCount].type=WEAP_NORM; ord[nCount].sprite.w=16; ord[nCount].sprite.h=32; ord[nCount].sprite.u=0; ord[nCount].sprite.v=0; ord[nCount].sprite.r=64; ord[nCount].sprite.g=128; ord[nCount].sprite.b=128; ord[nCount].sprite.mx=0; ord[nCount].sprite.my=0; ord[nCount].sprite.tpage=GetTPage(2, 0, 640, 0); ord[nCount].sprite.attribute=(1<<25)+(1<<27); ord[nCount].sprite.x=player.sprite.x+16; ord[nCount].sprite.y=player.sprite.y; ord[nCount].ax=0; ord[nCount].ay=-16; } } //-------------------------------------------------------------- void MoveOrd() { int nCount; for(nCount=0; nCount320)||(ord[nCount].sprite.y+ord[nCount].sprite.h<0)) ord[nCount].type=-1; } } } //-------------------------------------------------------------- void DrawOrd() { int nCount; for(nCount=0; nCount300)) change=1; } } if(change) nEDir=-nEDir; } //-------------------------------------------------------------- void DrawEnemies() { int nCount; for(nCount=0; nCount=16) explode[nCount].c=-1; } } } //-------------------------------------------------------------- void DrawOther() { GsGLINE line; int nCount; char string[32]; line.r0=64; line.g0=32; line.b0=32; line.r1=255; line.g1=128; line.b1=128; strcpy(string, "SCORE: "); strcat(string, OutputNum(player.score,8)); OutputString(string, -1, 20,0); strcpy(string, "LIVES: "); strcat(string, OutputNum(player.lives,2)); OutputString(string, -1, 150,0); strcpy(string, "LEVEL: "); strcat(string, OutputNum(nLevel,4)); OutputString(string, -1, 230,0); for(nCount=0; nCount=240) bomb[nCount].sprite.y=0; } } if(rock.c!=-1) { rock.sprite.x+=rock.ax; rock.sprite.y+=rock.ay; rock.sprite.rotate+=rock.c; if(rock.sprite.rotate>=ONE*360) rock.sprite.rotate=0; GsSortSprite(&rock.sprite, &othWorld[nBuffer], PRI_OTHER); if((rock.sprite.x<-50)||(rock.sprite.x>400)||(rock.sprite.y<-50)||(rock.sprite.y>300)) rock.c=-1; } else if((rand()<80)&&(pickup.c==-1)) { rock.c=rand()*2; if(rand()>16000) { rock.sprite.v=16; rock.sprite.y=30; rock.sprite.x=-30; rock.ay=1; rock.ax=2; } else { rock.sprite.v=0; rock.sprite.y=30; rock.sprite.x=350; rock.ay=1; rock.ax=-2; } } ufo.c+=2; if(ufo.c<320) { ufo.sprite.x=ufo.c; GsSortFastSprite(&ufo.sprite, &othWorld[nBuffer], PRI_ENEMY); yoyo.sprite.rotate+=ONE*20; if(yoyo.sprite.rotate>=ONE*360) yoyo.sprite.rotate=0; yoyo.sprite.y=ufo.c*2; if(yoyo.sprite.y>170) yoyo.sprite.y=170; if(yoyo.sprite.y<0) yoyo.sprite.y=0; yoyo.sprite.x=ufo.sprite.x; GsSortSprite(&yoyo.sprite, &othWorld[nBuffer], PRI_ENEMY+1); yoyo.sprite.r=128; yoyo.sprite.g=128; yoyo.sprite.b=128; line.x0=ufo.sprite.x+16; line.y0=ufo.sprite.y+12; line.x1=yoyo.sprite.x; line.y1=yoyo.sprite.y; GsSortGLine(&line, &othWorld[nBuffer], 10); } else if(ufo.c>3500) ufo.c=-20; if(pickup.c!=-1) { pickup.sprite.y++; pickup.sprite.v=pickup.c*16; pickup.sprite.tpage=GetTPage(2, 0, 960, 256); GsSortFastSprite(&pickup.sprite, &othWorld[nBuffer], PRI_OTHER); if(pickup.sprite.y>240) pickup.c=-1; } } //-------------------------------------------------------------- int Collision(long cx, long cy, long x, long y, long r) { if((x>cx-r && xcy-r && y3) nPickUpType=0; pickup.c=nPickUpType; pickup.sprite.x=rock.sprite.x; pickup.sprite.y=rock.sprite.y; } } if((ufo.c>-32)&&(ufo.c<320)&&(ord[nOrd].type!=-1)) { if(Overlap(&ord[nOrd].sprite, &ufo.sprite)) { player.score+=500; ord[nOrd].type=-1; ufo.c=320; for(nSplat=0; nSplat<64; nSplat++) StartSplat(1, ufo.sprite.x+16, ufo.sprite.y+8); SsUtKeyOn(nVab, 1,0, 48, 0, 128,128); StartExplode(ufo.sprite.x+16, ufo.sprite.y+16, 0); StartExplode(ufo.sprite.x+8, ufo.sprite.y+8, 0); } if(Overlap(&ord[nOrd].sprite, &yoyo.sprite)) { for(nSplat=0; nSplat<8; nSplat++) StartSplat(1, yoyo.sprite.x+16, yoyo.sprite.y+16); yoyo.sprite.r=255; yoyo.sprite.g=255; yoyo.sprite.b=255; if(!shield) { SsUtKeyOn(nVab2, 0,0, 48, 0, 128,128); shield=8; } ord[nOrd].type=-1; } } } if(!player.c) { for(nCount=0; nCounty+a->h>b->y)&&(a->yy+b->h)) { if((a->x+a->w>b->x)&&(a->xx+b->w)) return 1; } return 0; } //-------------------------------------------------------------- void DrawPlayer() { GsSPRITE add; if(player.sprite.x<0) player.sprite.x=0; if(player.sprite.x>304) player.sprite.x=304; GsSortFastSprite(&player.sprite, &othWorld[nBuffer], PRI_PLAYER); if(player.add) { add.u=0; add.v=0; add.r=128; add.g=128; add.b=128; add.mx=0; add.my=0; add.tpage=GetTPage(2, 0, 704, 0); add.attribute=(1<<25)+(1<<27); if(player.add&TUBE1) { add.w=8; add.h=16; add.x=player.sprite.x-8; if(player.add&ADD1) add.x-=16; add.y=player.sprite.y+4; GsSortFastSprite(&add, &othWorld[nBuffer], PRI_PLAYER); } if(player.add&TUBE2) { add.w=8; add.h=16; add.x=player.sprite.x+16; if(player.add&ADD2) add.x+=16; add.y=player.sprite.y+4; GsSortFastSprite(&add, &othWorld[nBuffer], PRI_PLAYER); } add.tpage=GetTPage(2, 0, 576, 0); if(player.add&ADD1) { add.w=16; add.h=16; add.x=player.sprite.x-16; add.y=player.sprite.y+2; GsSortFastSprite(&add, &othWorld[nBuffer], PRI_PLAYER); } if(player.add&ADD2) { add.w=16; add.h=16; add.x=player.sprite.x+16; add.y=player.sprite.y+2; GsSortFastSprite(&add, &othWorld[nBuffer], PRI_PLAYER); } } } //-------------------------------------------------------------- void GameOver() { int nTemp; int nCount; int nScript=100; GsSPRITE seq; RECT rClear={0,0,320,240}; nTune=300; seq.r=128; seq.g=128; seq.b=128; seq.x=160; seq.w=256; seq.h=30; seq.u=0; seq.v=28; seq.mx=128; seq.my=16; seq.y=100; seq.scalex=ONE; seq.scaley=ONE; seq.rotate=0; seq.tpage=GetTPage(2, 0, 320, 284); seq.attribute=(1<<25); do { PADstatus=PadRead(0); nBuffer=GsGetActiveBuff(); GsSetWorkBase((PACKET*)out_packet[nBuffer]); GsClearOt(0, 0, &othWorld[nBuffer]); if(!nTune) SsUtKeyOn(nVab, 2,0, 48, 0, 128,128); nTune++; if(nTune>329) nTune=0; rClear.y=nBuffer*256; ClearImage(&rClear, 0, 0, 0); seq.scalex=ONE-(nScript*80); seq.scaley=ONE-(nScript*40); seq.rotate=nScript*ONE*8; if(seq.y>100) seq.y=100; GsSortSprite(&seq, &othWorld[nBuffer], 0); OutputString("PRESS X", -1, GetCentre("PRESS X"),200); GsDrawOt(&othWorld[nBuffer]); FntFlush(-1); DrawSync(0); VSync(0); GsSwapDispBuff(); GsSortClear(0,0,0,&othWorld[nBuffer]); if(nScript) nScript--; } while(!(PADstatus & PADRdown)); } //-------------------------------------------------------------- void Complete() { } //-------------------------------------------------------------- void SmearClear(int r, int g, int b, int s, int ax, int ay) { int nBlur=0; int nCount; char lLine[640]; RECT rLine={0,0,320,1}; RECT rImage={0,0,320,240}; GsSPRITE screen; GsSPRITE screen2; for(rLine.y=(1-nBuffer)*256; rLine.y<((1-nBuffer)*256)+240; rLine.y++) { StoreImage(&rLine, (u_long *)&lLine[0]); for(nCount=0; nCount<640; nCount+=2) lLine[nCount+1]|=0x80; LoadImage(&rLine, (u_long *)&lLine[0]); } screen.attribute=(1<<25)+(1<<30); screen.r=r; screen.g=g; screen.b=b; screen.mx=160; screen.my=120; screen.x=160; screen.y=120; screen.w=160; screen.h=240; screen.u=0; screen.v=0; screen.rotate=0; screen.scalex=ONE; screen.scaley=ONE; screen2.attribute=(1<<25)+(1<<30); screen2.r=r; screen2.g=g; screen2.b=b; screen2.mx=0; screen2.my=120; screen2.x=160; screen2.y=120; screen2.w=160; screen2.h=240; screen2.rotate=0; screen2.scalex=ONE; screen2.scaley=ONE; screen2.u=32; screen2.v=0; rImage.y=(1-nBuffer)*256; MoveImage(&rImage, 0, nBuffer*256); for(nCount=0; nCount<120; nCount++) { screen.x=160; screen.y=120; screen2.x=160; screen2.y=120; if(nBlur==0) { screen.x--; screen2.x--; } else if(nBlur==1) { screen.x++; screen2.x++; } else if(nBlur==2) { screen.y++; screen2.y++; } else if(nBlur==3) { screen.y--; screen2.y--; } nBlur++; if(nBlur>3) nBlur=0; GsSetWorkBase((PACKET*)out_packet[nBuffer]); GsClearOt(0, 0, &othWorld[nBuffer]); screen.tpage=GetTPage(2,0, 0, (1-nBuffer)*256); GsSortSprite(&screen, &othWorld[nBuffer], 0); screen2.tpage=screen.tpage+2; GsSortSprite(&screen2, &othWorld[nBuffer], 1); GsDrawOt(&othWorld[nBuffer]); DrawSync(0); VSync(0); if(!nBlur) { GsSwapDispBuff(); } nBuffer=GsGetActiveBuff(); GsSortClear(0,0,0,&othWorld[nBuffer]); } } //-------------------------------------------------------------- int Difference(int a, int b) { if(a>b) return a-b; else return b-a; } //-------------------------------------------------------------- void StartSplat(int type, int x, int y) { int nCount=0; while(((splat[nCount].ax)||(splat[nCount].ay))&&(nCount>9)-32; splat[nCount].ay=(rand()>>9)-32; splat[nCount].line.x1=x; splat[nCount].line.y1=y; if(type) { splat[nCount].line.r1=255; splat[nCount].line.g1=255-rand()>>8; splat[nCount].line.b1=255-rand()>>7; splat[nCount].line.r0=128; splat[nCount].line.g0=0; splat[nCount].line.b0=0; } else { splat[nCount].line.r1=255; splat[nCount].line.g1=0; splat[nCount].line.b1=0; splat[nCount].line.r0=64; splat[nCount].line.g0=0; splat[nCount].line.b0=0; } } //-------------------------------------------------------------- void DrawSplats(void) { int nCount; for(nCount=0; nCount0) splat[nCount].ax--; else if(splat[nCount].ax<0) splat[nCount].ax++; if(splat[nCount].ay>0) splat[nCount].ay--; else if(splat[nCount].ay<0) splat[nCount].ay++; splat[nCount].line.x0=splat[nCount].line.x1; splat[nCount].line.y0=splat[nCount].line.y1; splat[nCount].x+=splat[nCount].ax; splat[nCount].y+=splat[nCount].ay; splat[nCount].line.x1=splat[nCount].x; splat[nCount].line.y1=splat[nCount].y; GsSortGLine(&splat[nCount].line, &othWorld[nBuffer], 0); } } } //-------------------------------------------------------------- void OtherChecks() { int nCount; int nTemp=0; if(!nEnemies) { for(nCount=0; nCount=201) nLevel=1; if(!nLevel%10) player.lives++; NewLevel(); } } if(player.c) { if(player.c>80) { if(player.c&1) StartExplode(player.sprite.x+8,player.sprite.y+8, 0); } player.c--; } if((player.lives<0)&&(!player.c)) bPlaying=0; } //-------------------------------------------------------------- void MakeTrans(u_long* addr) { int nCount; char lLine[2048]; GsIMAGE image; RECT rLine={0,0,0,1}; GsGetTimInfo((u_long *)(addr+4), &image); rLine.x=image.px; rLine.w=image.pw; for(rLine.y=image.py; rLine.y<(image.py+image.ph); rLine.y++) { StoreImage(&rLine, (u_long *)&lLine[0]); for(nCount=0; nCount>1); return nLen; } //-------------------------------------------------------------- char * OutputNum(int num, int len) { static char string[16]; int nCol; string[len]='\0'; if(num<0) num=0; while(len) { if(num) nCol=num%10; else nCol=0; num-=nCol; num/=10; len--; string[len]=nCol+48; } return (char *)&string; } //-------------------------------------------------------------- void PadInit() { GetPadBuf(&bb0, &bb1); } //-------------------------------------------------------------- u_long PadRead(int mode) { u_long read; u_long temp; read=(~(*(bb0+3) | *(bb0+2) << 8 | *(bb1+3) << 16 | *(bb1+2) << 24)); if(mode) { temp=read>>16; read|=temp; } return read; }