// --- Magic Forest -------------------------------------------------------------- #include #include #include #include #include "pad.h" #define BACK1_TIM 0x80090000 #define BACK5_TIM 0x80099614 #define FONT_TIM 0x800a2c28 #define FONT2_TIM 0x800a5bdc #define FORE1_TIM 0x800ab5a0 #define FORE2_TIM 0x800ad5b4 #define FORE3_TIM 0x800af5c8 #define FORE4_TIM 0x800b15dc #define FORE5_TIM 0x800b35f0 #define FORE6_TIM 0x800b5604 #define FORE7_TIM 0x800b7618 #define FORE8_TIM 0x800b962c #define FORE9_TIM 0x800bb640 #define GAMEOVER_TIM 0x800bd654 #define GRASS2_TIM 0x800c1268 #define GRASS3_TIM 0x800c327c #define GROUND2_TIM 0x800c5290 #define GRUBBIG_TIM 0x800c82a4 #define GRUBMAN_TIM 0x800ccf98 #define GRUBSML_TIM 0x800d2fac #define MAP_TIM 0x800d39c0 #define OBJECTS_TIM 0x800f91d4 #define ROCK_TIM 0x800fcde8 #define SANDWICH_TIM 0x801045fc #define TITLE_TIM 0x80104e10 #define TREE1_TIM 0x80117a24 #define TREE2_TIM 0x80118a38 #define TREE3_TIM 0x80119a4c #define TREE4_TIM 0x8011aa60 #define TREE5_TIM 0x8011ba74 #define TREE6_TIM 0x8011ca88 #define TREE7_TIM 0x8011da9c #define TREE8_TIM 0x8011eab0 #define WINGS_TIM 0x8011fac4 #define FX_VB 0x80122ad8 #define FX_VH 0x8013c9b8 #define LEVEL_TIM 0x8013e3d8 #define GRUBMAN3_TIM 0x8013fd6c #define BADGUYS_TIM 0x80142d80 #define FX2_VB 0x80143d94 #define FX2_VH 0x8014b314 #define BADGUYS2_TIM 0x8014cd34 #define GROUND3_TIM 0x8014ed48 #define BOOK_TIM 0x80151d5c #define SLIP_TIM 0x80152d70 #define MUSIC_VH 0x80154d84 #define MUSIC_VB 0x801567a4 #define ENYA_SEQ 0x801980e4 #define OT_LEN 12 #define MAX_PACKETS 102400 #define MAX_BSPLATS 256 #define MAX_SCENE 48 #define MAX_FORE 16 #define MAX_OBJ 10 #define MAX_LEVELS 4 #define MAX_GRUBMAN 300 #define MAX_BADGUYS 16 #define SPACE 4 #define GROUND 160 #define NORMAL 0 #define SANDWICH 1 #define FLYING 2 #define TINY 3 #define TOAD 1 #define GFROG 2 #define TURTLE 3 #define LIZARD 4 #define BFLY 5 #define BFROG 6 #define SFUNGI 7 #define BAT 8 #define VBAT 9 #define LFUNGI 10 #define BOUNCE 0 #define SINE 1 #define SCORPION 2 #define BUG 3 #define FRUIT 4 #define TICK 5 typedef struct { int x,y; int g; int state,crouch; int energy, magic; int frame; int o1,o2,o3; int hRL, hRU, hRR, hRD; int hLL, hLU, hLR, hLD; }Player; typedef struct { int x,y; int type,param,max; int active, rot; GsSPRITE spr; }Enemy; typedef struct { GsGLINE line; int x,y; int ax,ay; }BSplat; typedef struct { int x; GsSPRITE spr; }Scene; typedef struct { int x,y,d; GsSPRITE spr; }Pickup; typedef struct { int x[MAX_OBJ]; int d[MAX_OBJ]; }LevelInfo; u_long PADstatus=0; volatile u_char *bb0, *bb1; short tune; float wind=0.05; int mlevel=80; int fxlevel=100; int discount=0; int speed; int mrate; int nBuffer; int bPlaying; int bRunning=1; int bComplete; int grubman=0; int nVab; int nVab2; int nVab3; int nLevel; int nMaxMagic; int nMapx; int nMap[4096]; int nFont[92]={0,3,8,15,15,21,27,29,32,35,39,45,48,51,54,59,65,71,77,83,89,95,101,107,113,119,122,125,131,137,143,149, 159,167,174,181,189,196,202,210,218,220,226,233,239,248,256,264,271,279,287,294,301,308,315,326,333,340,348,351,356,359,364,371, 374,380,386,392,398,404,407,413,419,421,423,429,431,439,445,451,457,463,466,471,474,480,486,494,498,504,508}; int nFont2[28]={0,16,32,46,62,77,91,106,124,131,144,160,167,195,213,227,243,259,272,286,296,314,332,358,375,392,410}; char onames[10][20]={"magic toad", "green frog", "tortoise", "lizard", "bufferfly", "black frog", "small fungi", "bat", "vampire bat", "fungus"}; char lastobject[20]; char chapter[2][512]={ "From his mentor's quarters, the Magic Forest loomed large in the distance.\n\nAce quickly gathered together Lenpuis' last remaining spells and headed toward the great forest. He tried to forget that time was fast running out.", "As Ace approached the edge of the forest, an eery mist decended through the trees. He knew Grubman's lair was close by the distant sounds of his giant insects.\n\nMore unsettlingly, the forests magical forces were beginning to turn against him."}; RECT rClear; PACKET out_packet[2][MAX_PACKETS]; GsOT othWorld[2]; GsOT_TAG otWorld[2][1<=4090) { FadeToBlack(2); nLevel++; bPlaying=0; } GsSwapDispBuff(); GsSortClear(0,0,0,&othWorld[nBuffer]); } if(player.energy>0) bPlaying=1; else GameOver(); } } SsVabClose(nVab2); SsVabClose(nVab3); SsVabClose(nVab); SsSeqClose(tune); ClearImage(&rVMem,0,0,0); ResetGraph(3); return 0; } //-------------------------------------------------------------- int ShowTitles(void) { int mode=0; int select=0; int option=0; char string[256]; GsIMAGE tim1; GsSPRITE sprite={1<<25, 32,0, 0,0, 0,0,0, 0,0, 0,0,0, 0,0, ONE,ONE, 0}; GsSPRITE level={1<<25, 0,0, 0,0, 0,0,0, 0,0, 128,128,128, 0,0, ONE,ONE, 0}; GsSPRITE slip={1<<25|1<<30, 0,0, 64,64, 0,0,0, 0,0, 128,128,128, 0,0, ONE,ONE, 0}; GsSPRITE slip2={1<<25|1<<30, 0,0, 64,64, 0,0,0, 0,0, 128,128,128, 32,32, ONE,ONE, ONE*180}; GsLINE line={1<<30, 286,0, 0,0, 0,0,0}; int bright=0; int reel=0; int count=0; int bcount=0; int bcount2=0; rClear.x=0; rClear.y=0; rClear.w=320; rClear.h=240; LoadTIM(TITLE_TIM,0); LoadTIM(FONT_TIM,0); LoadTIM(FONT2_TIM,0); LoadTIM(LEVEL_TIM,0); LoadTIM(SLIP_TIM,1); GsGetTimInfo((u_long *)TITLE_TIM+1, &tim1); sprite.u=tim1.px%64; sprite.v=tim1.py%256; sprite.w=tim1.pw; sprite.h=tim1.ph; sprite.tpage=GetTPage(2, 0, tim1.px, tim1.py); do { PADstatus=PadRead(1); nBuffer=GsGetActiveBuff(); GsSetWorkBase((PACKET*)out_packet[nBuffer]); GsClearOt(0, 0, &othWorld[nBuffer]); rClear.y=(nBuffer*240); ClearImage(&rClear,0,0,0); reel++; if(reel>1600) reel=0; if(sprite.r<128) { sprite.r+=8; sprite.g+=8; sprite.b+=8; } else if(!mode) { if(reel==1000||reel==1300||reel==700) bright=32; if(bright<128) bright+=2; if(reel<700) { strcpy(string, "start game"); OutputString(string, -1, GetCentre(string, &nFont2[0], 97), 170, 255-(select*128), &nFont2[0], (u_long *)FONT2_TIM, 97); strcpy(string, "options"); OutputString(string, -1, GetCentre(string, &nFont2[0], 97), 210, 127+(select*128), &nFont2[0], (u_long *)FONT2_TIM, 97); } else if(reel<1000) { strcpy(string, "Design, code, graphics and sound effects"); OutputString(string, -1, 30,170,bright,&nFont[0], (u_long *)FONT_TIM, 33); strcpy(string, "ben james"); OutputString(string, -1, 30,190,bright, &nFont2[0], (u_long *)FONT2_TIM, 97); } else if(reel<1300) { strcpy(string, "Additional design"); OutputString(string, -1, 213,170,bright,&nFont[0], (u_long *)FONT_TIM, 33); strcpy(string, "jon angell"); OutputString(string, -1, 170,190,bright, &nFont2[0], (u_long *)FONT2_TIM, 97); } else if(reel<1600) { strcpy(string, "Music"); OutputString(string, -1, 30,170,bright,&nFont[0], (u_long *)FONT_TIM, 33); strcpy(string, "enya"); OutputString(string, -1, 30,190,bright, &nFont2[0], (u_long *)FONT2_TIM, 97); } } else { strcpy(string, "effects"); OutputString(string, -1, 30, 170, 255-(option*128), &nFont2[0], (u_long *)FONT2_TIM, 97); strcpy(string, "music"); OutputString(string, -1, 30, 210, 127+(option*128), &nFont2[0], (u_long *)FONT2_TIM, 97); GsGetTimInfo((u_long *)LEVEL_TIM+1, &tim1); level.u=tim1.px%64; level.v=tim1.py%256; level.w=tim1.pw; level.h=tim1.ph; level.tpage=GetTPage(2, 0, tim1.px, tim1.py); level.x=154; level.y=172; GsSortFastSprite(&level, &othWorld[nBuffer], 1); level.y=212; GsSortFastSprite(&level, &othWorld[nBuffer], 1); if(fxlevel<128) { for(line.y0=176; line.y0<192; line.y0++) { line.x1=158+fxlevel; line.y1=line.y0; GsSortLine(&line, &othWorld[nBuffer], 0); } } if(mlevel<128) { for(line.y0=216; line.y0<232; line.y0++) { line.x1=158+mlevel; line.y1=line.y0; GsSortLine(&line, &othWorld[nBuffer], 0); } } if(PADstatus&PADLleft) { if(!option&&fxlevel) fxlevel--; else if(option&&mlevel) mlevel--; } else if(PADstatus&PADLright) { if(!option&&(fxlevel<128)) fxlevel++; else if(option&&(mlevel<128)) mlevel++; } } SsSeqSetVol(tune, mlevel,mlevel); GsSortFastSprite(&sprite, &othWorld[nBuffer], 0); if(PADstatus) reel=0; if(!mode) { if(PADstatus & PADLup) { if(!player.hLU) { SsUtKeyOn(nVab2, 4,0, 48, 0, fxlevel,fxlevel); select=1-select; player.hLU=1; } } else player.hLU=0; if(PADstatus & PADLdown) { if(!player.hLD) { SsUtKeyOn(nVab2, 4,0, 48, 0, fxlevel,fxlevel); select=1-select; player.hLD=1; } } else player.hLD=0; } else { if((PADstatus & PADLup)&&(!(PADstatus&PADLleft))&&(!(PADstatus&PADLright))) { if(!player.hLU) { SsUtKeyOn(nVab2, 4,0, 48, 0, fxlevel,fxlevel); option=1-option; player.hLU=1; } } else player.hLU=0; if((PADstatus & PADLdown)&&(!(PADstatus&PADLleft))&&(!(PADstatus&PADLright))) { if(!player.hLD) { SsUtKeyOn(nVab2, 4,0, 48, 0, fxlevel,fxlevel); option=1-option; player.hLD=1; } } else player.hLD=0; } if(PADstatus & PADRdown) { if(!player.hRD) { SsUtKeyOn(nVab2, 0,0, 48, 0, fxlevel,fxlevel); mode=1-mode; player.hRD=1; } } else player.hRD=0; if((PADstatus & PADRup)&&(mode)) { SsUtKeyOn(nVab2, 0,0, 48, 0, fxlevel,fxlevel); mode=0; } if(PADstatus & PADselect) { bRunning=0; return; } GsGetTimInfo((u_long *)SLIP_TIM+1, &tim1); slip.u=tim1.px%64; slip.v=tim1.py%256; slip.tpage=GetTPage(2, 0, tim1.px, tim1.py); slip.y=172; slip2.u=tim1.px%64; slip2.v=tim1.py%256; slip2.tpage=GetTPage(2, 0, tim1.px, tim1.py); slip2.y=204; bcount--; if(bcount<-64) bcount=0; slip.x=bcount; while(slip.x<320) { GsSortSprite(&slip, &othWorld[nBuffer], 5); slip.x+=64; } bcount2++; if(bcount2>32) bcount2=-32; slip2.x=bcount2; while(slip2.x<352) { GsSortSprite(&slip2, &othWorld[nBuffer], 5); slip2.x+=64; } GsDrawOt(&othWorld[nBuffer]); DrawSync(0); VSync(0); GsSwapDispBuff(); GsSortClear(0,0,0,&othWorld[nBuffer]); rand(); }while((!(PADstatus&PADRdown))||(sprite.r<128)||(select==1)); SmearClear(128,128,128,1,0,0); } //-------------------------------------------------------------- int LoadTIM(long addr, int trans) { 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); if(trans) MakeTrans(&tim1); return(0); } //-------------------------------------------------------------- void Initialise() { SetVideoMode(MODE_PAL); GsInitGraph(320, 240, GsINTER|GsOFSGPU, 0, 0); GsDefDispBuff(0, 0, 0, 240); 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 *)MUSIC_VH, (u_char *)MUSIC_VB, -1, 1); nVab2=SsVabTransfer((u_char *)FX_VH, (u_char *)FX_VB, -1, 1); nVab3=SsVabTransfer((u_char *)FX2_VH, (u_char *)FX2_VB, -1, 1); tune=SsSeqOpen((u_long*)ENYA_SEQ, nVab); SsSetMVol(127,127); SsSeqSetVol(tune, mlevel,mlevel); SsSeqPlay(tune, SSPLAY_PLAY, SSPLAY_INFINITY); } //-------------------------------------------------------------- void NewGame(int numplayers) { bPlaying=1; nLevel=1; nMaxMagic=32; player.o1=BFROG; player.o2=GFROG; player.o3=BFLY; } //-------------------------------------------------------------- void NewLevel() { int r; int count; int order[10]={8,4,9,10,6,2,3,5,7,1}; char string[256]; char numbers[4][4]={"one", "two"}; GsIMAGE tim1; GsSPRITE map1={1<<25, 0,0, 160,240, 0,0,0, 0,0, 0,0,0, 0,0, ONE,ONE, 0}; GsSPRITE map2={1<<25, 160,0, 160,240, 0,0,0, 0,0, 0,0,0, 0,0, ONE,ONE, 0}; LoadTIM(MAP_TIM,0); GsGetTimInfo((u_long *)MAP_TIM+1, &tim1); map1.u=tim1.px%64; map1.v=tim1.py%256; map1.tpage=GetTPage(2, 0, tim1.px, tim1.py); map2.u=(tim1.px+160)%64; map2.v=tim1.py%256; map2.tpage=GetTPage(2, 0, tim1.px+160, tim1.py); do { PADstatus=PadRead(1); nBuffer=GsGetActiveBuff(); GsSetWorkBase((PACKET*)out_packet[nBuffer]); GsClearOt(0, 0, &othWorld[nBuffer]); if(map1.r<128) { map1.r+=8; map1.g+=8; map1.b+=8; map2.r+=8; map2.g+=8; map2.b+=8; } else { sprintf(string, "chapter %s", numbers[nLevel-1]); OutputString(string, -1, 92, 18, 64, &nFont2[0], (u_long *)FONT2_TIM, 97); OutputString(chapter[nLevel-1], -1, 92,50,32,&nFont[0], (u_long *)FONT_TIM, 33); } GsSortFastSprite(&map1, &othWorld[nBuffer], 1); GsSortFastSprite(&map2, &othWorld[nBuffer], 1); GsDrawOt(&othWorld[nBuffer]); DrawSync(0); VSync(0); GsSwapDispBuff(); GsSortClear(0,0,0,&othWorld[nBuffer]); }while((!PADstatus)||(map1.r<128)); FadeToBlack(2); for(count=0; count>8); plant[count].spr.y=135-(rand()&15); plant[count].spr.w=tim1.pw; plant[count].spr.h=tim1.ph; plant[count].spr.scalex=(ONE>>1)+(rand()&4095); plant[count].spr.scaley=plant[count].spr.scalex; plant[count].spr.rotate=0; plant[count].spr.r=128; plant[count].spr.g=128; plant[count].spr.b=128; plant[count].spr.mx=16; plant[count].spr.my=64; plant[count].spr.u=tim1.px%64; plant[count].spr.v=tim1.py%256; plant[count].spr.tpage=GetTPage(2, 0, tim1.px, tim1.py); } for(count=0; count>9); fore[count].spr.y=121; fore[count].spr.w=tim1.pw; fore[count].spr.h=tim1.ph; fore[count].spr.scalex=ONE; fore[count].spr.scaley=ONE; fore[count].spr.rotate=0; fore[count].spr.r=128; fore[count].spr.g=128; fore[count].spr.b=128; fore[count].spr.mx=0; fore[count].spr.my=0; fore[count].spr.u=tim1.px%64; fore[count].spr.v=tim1.py%256; fore[count].spr.tpage=GetTPage(2, 0, tim1.px, tim1.py); } nMapx=1; player.energy=64; player.magic=0; player.y=GROUND-64; grubman=0; LoadTIM(ROCK_TIM,0); LoadTIM(BACK5_TIM,0); LoadTIM(BACK1_TIM,0); LoadTIM(GRASS2_TIM,0); LoadTIM(GRASS3_TIM,0); LoadTIM(GROUND2_TIM,0); LoadTIM(GROUND3_TIM,0); LoadTIM(GRUBMAN_TIM,0); LoadTIM(GRUBMAN3_TIM,0); LoadTIM(SANDWICH_TIM,0); LoadTIM(OBJECTS_TIM,0); LoadTIM(WINGS_TIM,0); LoadTIM(BOOK_TIM,0); LoadTIM(GRUBSML_TIM,0); LoadTIM(FONT_TIM,0); LoadTIM(BADGUYS_TIM,0); LoadTIM(BADGUYS2_TIM,0); LoadTIM(TREE1_TIM,0); LoadTIM(TREE2_TIM,0); LoadTIM(TREE3_TIM,0); LoadTIM(TREE4_TIM,0); LoadTIM(TREE5_TIM,0); LoadTIM(TREE6_TIM,0); LoadTIM(TREE7_TIM,0); LoadTIM(TREE8_TIM,0); LoadTIM(FORE1_TIM,1); LoadTIM(FORE2_TIM,1); LoadTIM(FORE3_TIM,1); LoadTIM(FORE4_TIM,1); LoadTIM(FORE5_TIM,1); LoadTIM(FORE6_TIM,1); LoadTIM(FORE7_TIM,1); LoadTIM(FORE8_TIM,1); LoadTIM(FORE9_TIM,1); for(count=0; count=0)) { if(player.frame>0) player.frame=-player.frame; nMapx-=speed; if((nMapx&1)||(player.state==TINY)) player.frame--; if(player.frame<-12) player.frame=-1; } else if((PADstatus & PADLright)&&(nMapx<4096)) { if(player.frame<0) player.frame=-player.frame; nMapx+=speed; if((nMapx&1)||(player.state==TINY)) player.frame++; if(player.frame>12) player.frame=1; } else { if(player.frame<0) player.frame=-1; else player.frame=1; } if(player.state==FLYING) { if((PADstatus & PADLup)&&(player.y>64)&&(player.g>-4-((64-nMaxMagic)>>3))) player.g-=2; } player.y+=player.g; player.g++; if(player.y>GROUND+4) { SsUtKeyOn(nVab2, 4,0, 47, 0, fxlevel,fxlevel); SsUtKeyOn(nVab2, 3,0, 47, 0, fxlevel,fxlevel); } if(player.y>GROUND) { player.y=GROUND; player.g=0; } if((PADstatus & PADRdown)&&(player.y==GROUND)) { if(player.state==TINY) player.g=-6; else player.g=-11; SsUtKeyOn(nVab2, 5,0, 48, 0, fxlevel,fxlevel); } if(PADstatus & PADLdown) { player.crouch=1; if(PADstatus & PADRleft) { if(!player.hRL) { CheckPickup(&player.o1); player.hRL=1; } } else player.hRL=0; if(PADstatus & PADRup) { if(!player.hRU) { CheckPickup(&player.o2); player.hRU=1; } } else player.hRU=0; if(PADstatus & PADRright) { if(!player.hRR) { CheckPickup(&player.o3); player.hRR=1; } } else player.hRR=0; } else if(!(PADstatus & PADLdown)) { player.crouch=0; if(PADstatus & PADRleft) { if((!player.hRL)||(player.o1==TOAD)) { UseObject(&player.o1); player.hRL=1; } } else player.hRL=0; if(PADstatus & PADRup) { if((!player.hRU)||(player.o2==TOAD)) { UseObject(&player.o2); player.hRU=1; } } else player.hRU=0; if(PADstatus & PADRright) { if((!player.hRR)||(player.o3==TOAD)) { UseObject(&player.o3); player.hRR=1; } } else player.hRR=0; } } //-------------------------------------------------------------- void UseObject(int *object) { int count=0; if((player.magic)||(grubman&&*object!=LFUNGI)) return; switch(*object) { case BFROG: SsUtKeyOn(nVab2, 2,0, 48, 0, fxlevel,fxlevel); player.magic=nMaxMagic; player.g=-(12+(nMaxMagic>>4)); nMapx|=1; speed=4; mrate=0; break; case GFROG: SsUtKeyOn(nVab2, 2,0, 48, 0, fxlevel>>1,fxlevel>>1); player.magic=nMaxMagic; player.g=-(10+(nMaxMagic>>4)); nMapx|=1; speed=2; mrate=0; break; case SFUNGI: SsUtKeyOn(nVab3, 1,0, 48, 0, fxlevel,fxlevel); player.state=SANDWICH; player.magic=nMaxMagic; for(count=0; count<64; count++) StartSplat(0, 160, player.y-16); if(player.y==GROUND) player.g=-5; mrate=2; break; case LFUNGI: SsUtKeyOn(nVab3, 1,0, 48, 0, fxlevel,fxlevel); grubman=0; break; case BFLY: player.state=FLYING; player.magic=nMaxMagic; mrate=4; speed=nMaxMagic>>4; break; case TURTLE: nMapx|=1; speed=2; player.magic=nMaxMagic; mrate=4; break; case BAT: SsUtKeyOn(nVab2, 1,0, 48, 0, fxlevel,fxlevel); if(nMaxMagic<48) nMaxMagic=48; player.magic=nMaxMagic; mrate=0; break; case VBAT: SsUtKeyOn(nVab2, 1,0, 48, 0, fxlevel,fxlevel); nMaxMagic=64; player.magic=nMaxMagic; mrate=0; break; case LIZARD: SsUtKeyOn(nVab3, 0,0, 48, 0, fxlevel,fxlevel); player.magic=nMaxMagic; player.state=TINY; mrate=4; break; case TOAD: count=0; while(((splat[count].ax)||(splat[count].ay))&&(count>1,fxlevel>>1); splat[count].y=player.y-27; if(player.frame>0) { splat[count].ax=(rand()>>11); splat[count].x=165; } else { splat[count].ax=-(rand()>>11); splat[count].x=155; } splat[count].ay=-(rand()>>12); splat[count].line.x1=splat[count].x; splat[count].line.y1=splat[count].y; splat[count].line.r1=101; splat[count].line.g1=127; splat[count].line.b1=19; splat[count].line.r0=160; splat[count].line.g0=191; splat[count].line.b0=65; break; default: break; } if((*object)&&(!grubman)) { strcpy(lastobject, onames[(*object)-1]); discount=150; if(*object!=TOAD) *object=0; } } //-------------------------------------------------------------- void CheckPickup(int * object) { int count; int temp; for(count=0; count(nMapx<<1)+138)&&(item[count].x<(nMapx<<1)+168)) { temp=*object; *object=item[count].d; item[count].d=temp; SsUtKeyOn(nVab2, 0,0, 48, 0, fxlevel,fxlevel); strcpy(lastobject, onames[(*object)-1]); discount=150; } } } } //-------------------------------------------------------------- int Collided(int count, int r) { if(player.state!=SANDWICH) { if(Collision(badguy[count].spr.x, badguy[count].spr.y, 160, player.y-16, r)) { SsUtKeyOn(nVab3, 3,0, 48, 0, fxlevel,fxlevel); badguy[count].active=0; StartSplat(0, badguy[count].spr.x, badguy[count].spr.y); StartSplat(0, badguy[count].spr.x, badguy[count].spr.y); StartSplat(0, badguy[count].spr.x, badguy[count].spr.y); StartSplat(0, badguy[count].spr.x, badguy[count].spr.y); StartSplat(0, badguy[count].spr.x, badguy[count].spr.y); StartSplat(0, badguy[count].spr.x, badguy[count].spr.y); StartSplat(0, badguy[count].spr.x, badguy[count].spr.y); StartSplat(0, badguy[count].spr.x, badguy[count].spr.y); return 1; } } else return 0; } //-------------------------------------------------------------- int Collision(long cx, long cy, long x, long y, long r) { if((x>cx-r && xcy-r && y>1))%320; while(back.x>0) back.x-=160; if(nLevel==1) { back.h=77; ripple.v=(tim1.py%256)+y; ripple.tpage=GetTPage(2,0, tim1.px, tim1.py+y); ripple.u=tim1.px%64; soff++; if(soff>32) soff=0; while(back.x<320) { GsSortFastSprite(&back, &othWorld[nBuffer], 8); y=77; off=soff>>1; mult=0; while(y<120) { ripple.y=y; ripple.x=back.x+(int)(wave[off]*mult); ripple.v=(tim1.py+y)%256; ripple.tpage=GetTPage(2, 0, tim1.px, tim1.py+y); GsSortFastSprite(&ripple, &othWorld[nBuffer], 8); y++; off++; mult+=wind; if(off>16) off=0; } back.x+=160; } } else if(nLevel==2) { while(back.x<320) { GsSortFastSprite(&back, &othWorld[nBuffer], 8); back.x+=160; } } if(nLevel==1) GsGetTimInfo((u_long *)GRASS2_TIM+1, &tim1); else if(nLevel==2) GsGetTimInfo((u_long *)GRASS3_TIM+1, &tim1); row2.u=tim1.px%64; row2.v=tim1.py%256; row2.tpage=GetTPage(2, 0, tim1.px, tim1.py); row2.x=(-nMapx)%256; while(row2.x>0) row2.x-=128; while(row2.x<320) { GsSortFastSprite(&row2, &othWorld[nBuffer], 7); row2.x+=128; } if(nLevel==1) GsGetTimInfo((u_long *)GROUND2_TIM+1, &tim1); else if(nLevel==2) GsGetTimInfo((u_long *)GROUND3_TIM+1, &tim1); lx=nMapx; row3.u=tim1.px%64; row3.v=tim1.py%256; row3.tpage=GetTPage(2, 0, tim1.px, tim1.py); row3.x=(-(nMapx<<1))%256; while(row3.x>0) row3.x-=128; while(row3.x<320) { GsSortFastSprite(&row3, &othWorld[nBuffer], 6); row3.x+=128; } for(count=0; count-24)&&(plant[count].spr.x<344)) GsSortSprite(&plant[count].spr, &othWorld[nBuffer], 3); } for(count=0; count-64)&&(fore[count].spr.x<320)) GsSortFastSprite(&fore[count].spr, &othWorld[nBuffer], 0); } GsGetTimInfo((u_long *)BOOK_TIM+1, &tim1); obj.u=tim1.px%64; obj.v=((page&0xfe)<<3)+tim1.py%256; obj.tpage=GetTPage(2, 0, tim1.px, ((page&0xfe)<<3)+tim1.py); page++; if(page>15) page=0; for(count=0; count(nMapx<<1)-16)&&(item[count].x<(nMapx<<1)+320)) { obj.x=item[count].x-(nMapx<<1); GsSortFastSprite(&obj, &othWorld[nBuffer], 2); } } } } //-------------------------------------------------------------- void DrawPlayer(int nNumPlayers) { int x,y,v; int offset; static int loffset=0; static int wframe=0; static int wsize=0; static int lx=0; static int ly=GROUND; GsLINE shadow={1<<30, 0,0, 0,0, 0,0,0}; GsIMAGE tim1; GsSPRITE man={1<<25, 160,0, 32,32, 0,0,0, 0,0, 128,128,128, 16,32, ONE,ONE, 0}; GsSPRITE wings={1<<25, 160,0, 32,32, 0,0,0, 0,0, 128,128,128, 19,19, ONE,ONE, 0}; man.y=player.y; if((player.state==NORMAL)||(player.state==TINY)) { if((lx!=nMapx)&&(!player.crouch)&&(player.y>=GROUND)) { GsGetTimInfo((u_long *)GRUBMAN_TIM+1, &tim1); x=tim1.px; if((player.frame>6)||(player.frame<-6)) x+=32; offset=player.frame; if(offset<0) offset=-offset; if((offset==2)&&(loffset!=2)) SsUtKeyOn(nVab2, 3,0, 47, 0, fxlevel,fxlevel); if((offset==8)&&(loffset!=2)) SsUtKeyOn(nVab2, 4,0, 49, 0, fxlevel,fxlevel); if(offset>6) offset-=6; loffset=offset; y=tim1.py+((offset-1)*32); } else { GsGetTimInfo((u_long *)GRUBMAN3_TIM+1, &tim1); x=tim1.px; y=tim1.py; if((player.y>=GROUND)&&(!player.crouch)) y=tim1.py; else if(player.g>1) y+=64; else if(player.g<-4) y+=32; else if(!player.crouch) y+=96; else y+=125; } } else if(player.state==SANDWICH) { GsGetTimInfo((u_long *)SANDWICH_TIM+1, &tim1); x=tim1.px; y=tim1.py; } else if(player.state==FLYING) { if(player.magic==nMaxMagic) wsize=0; else if(wsize>1)*32))%256; wings.y=player.y-24; wings.scaley=wsize; if(player.frame<0) wings.scalex=-wsize; else wings.scalex=wsize; GsSortSprite(&wings, &othWorld[nBuffer], 1); wframe++; if(wframe>11) wframe=0; } man.tpage=GetTPage(2, 0, x, y); man.u=x%64; man.v=y%256; if(player.frame<0) man.scalex=-ONE; else man.scalex=ONE; if(player.state==TINY) { man.scalex/=2; man.scaley=ONE>>1; } else man.scaley=ONE; GsSortSprite(&man, &othWorld[nBuffer], 0); if(player.state==TINY) offset=4; else offset=8; shadow.y0=GROUND-2; shadow.y1=GROUND-2; shadow.x0=(160-offset)-((GROUND-player.y)>>4); shadow.x1=(160+offset)+((GROUND-player.y)>>4); GsSortLine(&shadow, &othWorld[nBuffer], 5); shadow.x0-=3; shadow.x1+=3; shadow.y0++; shadow.y1++; GsSortLine(&shadow, &othWorld[nBuffer], 5); shadow.x0-=1; shadow.x1+=1; shadow.y0++; shadow.y1++; GsSortLine(&shadow, &othWorld[nBuffer], 5); shadow.x0+=1; shadow.x1-=1; shadow.y0++; shadow.y1++; GsSortLine(&shadow, &othWorld[nBuffer], 5); shadow.x0+=3; shadow.x1-=3; shadow.y0++; shadow.y1++; GsSortLine(&shadow, &othWorld[nBuffer], 5); lx=nMapx; ly=player.y; } //-------------------------------------------------------------- void DrawBadguys() { int ypos,y,param; int count; GsIMAGE tim1; if(nMapx==501) { GsGetTimInfo((u_long *)BADGUYS_TIM+1, &tim1); for(count=0; count=GROUND) param=-18; badguy[count].active=1; badguy[count].type=SCORPION; badguy[count].x=nMapx+330+(count*12); badguy[count].y=ypos; badguy[count].max=-18; badguy[count].spr.rotate=0; badguy[count].spr.r=128; badguy[count].spr.g=128; badguy[count].spr.b=128; badguy[count].spr.attribute=1<<25; badguy[count].spr.w=tim1.pw; badguy[count].spr.h=32; badguy[count].spr.u=tim1.px%64; y=((rand()&0)*32)+tim1.py; badguy[count].spr.v=y%256; badguy[count].spr.mx=16; badguy[count].spr.my=16; badguy[count].spr.scalex=ONE; badguy[count].spr.scaley=ONE; badguy[count].spr.tpage=GetTPage(2, 0, tim1.px, y); } } } else if((nMapx==1501)||(nMapx==2501)||(nMapx==3503)) { GsGetTimInfo((u_long *)BADGUYS2_TIM+1, &tim1); ypos=GROUND; param=0; for(count=8; count<16; count++) { if(!badguy[count].active) { ypos+=param; param++; if(ypos>=GROUND) param=-18; badguy[count].active=1; badguy[count].type=BUG; badguy[count].x=nMapx-(count*24)-20; badguy[count].y=ypos; badguy[count].max=-4; badguy[count].spr.rotate=0; badguy[count].spr.r=128; badguy[count].spr.g=128; badguy[count].spr.b=128; badguy[count].spr.attribute=1<<25; badguy[count].spr.w=tim1.pw; badguy[count].spr.h=32; badguy[count].spr.u=tim1.px%64; y=64+tim1.py; badguy[count].spr.v=y%256; badguy[count].spr.mx=16; badguy[count].spr.my=16; badguy[count].spr.scalex=ONE; badguy[count].spr.scaley=ONE; badguy[count].spr.tpage=GetTPage(2, 0, tim1.px, y); } } } else if((nMapx==2001)||(nMapx==3501)) { GsGetTimInfo((u_long *)BADGUYS2_TIM+1, &tim1); ypos=GROUND; param=0; for(count=0; count<8; count++) { if(!badguy[count].active) { ypos+=param; param++; if(ypos>=GROUND) param=-18; badguy[count].active=1; badguy[count].type=FRUIT; badguy[count].x=nMapx+330+(count*16); badguy[count].y=ypos; badguy[count].max=-6; badguy[count].spr.rotate=0; badguy[count].spr.r=128; badguy[count].spr.g=128; badguy[count].spr.b=128; badguy[count].spr.attribute=1<<25; badguy[count].spr.w=tim1.pw; badguy[count].spr.h=32; badguy[count].spr.u=tim1.px%64; y=32+tim1.py; badguy[count].spr.v=y%256; badguy[count].spr.mx=16; badguy[count].spr.my=16; badguy[count].spr.scalex=ONE; badguy[count].spr.scaley=ONE; badguy[count].spr.tpage=GetTPage(2, 0, tim1.px, y); } } } else if(nMapx==3001) { GsGetTimInfo((u_long *)BADGUYS2_TIM+1, &tim1); ypos=GROUND; param=0; for(count=0; count<8; count++) { if(!badguy[count].active) { ypos+=param; param++; if(ypos>=GROUND) param=-18; badguy[count].active=1; badguy[count].type=TICK; badguy[count].x=nMapx+330+(count*28); badguy[count].y=ypos; badguy[count].max=-10; badguy[count].spr.rotate=0; badguy[count].spr.r=128; badguy[count].spr.g=128; badguy[count].spr.b=128; badguy[count].spr.attribute=1<<25; badguy[count].spr.w=tim1.pw; badguy[count].spr.h=32; badguy[count].spr.u=tim1.px%64; y=96+tim1.py; badguy[count].spr.v=y%256; badguy[count].spr.mx=16; badguy[count].spr.my=16; badguy[count].spr.scalex=ONE; badguy[count].spr.scaley=ONE; badguy[count].spr.tpage=GetTPage(2, 0, tim1.px, y); } } } for(count=0; count=GROUND) { badguy[count].param=badguy[count].max; if(count&1) SsUtKeyOn(nVab3, 2,0, 48, 0, fxlevel>>2,fxlevel>>2); } badguy[count].spr.rotate+=badguy[count].rot*ONE; if(badguy[count].spr.rotate>=(ONE*360)) badguy[count].spr.rotate-=(ONE*360); badguy[count].spr.x=badguy[count].x-nMapx; badguy[count].spr.y=badguy[count].y; if((badguy[count].spr.x<-64)||(badguy[count].spr.x>500)) badguy[count].active=0; if(Collided(count, 12)) player.energy--; break; case SCORPION: badguy[count].x-=3; badguy[count].y+=badguy[count].param; badguy[count].param++; if(badguy[count].y>=GROUND) badguy[count].param=badguy[count].max; badguy[count].spr.x=badguy[count].x-nMapx; badguy[count].spr.y=badguy[count].y; if((badguy[count].spr.x<-64)||(badguy[count].spr.x>500)) badguy[count].active=0; if(Collided(count, 24)) player.energy-=2; break; case BUG: badguy[count].x+=2; badguy[count].y+=badguy[count].param; badguy[count].param++; if(badguy[count].y>=GROUND) badguy[count].param=badguy[count].max; badguy[count].spr.x=badguy[count].x-nMapx; badguy[count].spr.y=badguy[count].y; if((badguy[count].spr.x<-512)||(badguy[count].spr.x>500)) badguy[count].active=0; if(Collided(count, 24)) player.energy-=2; break; case FRUIT: badguy[count].x--; badguy[count].y+=badguy[count].param; badguy[count].param++; if(badguy[count].y>=GROUND) badguy[count].param=badguy[count].max; badguy[count].spr.x=badguy[count].x-nMapx; badguy[count].spr.y=badguy[count].y; if((badguy[count].spr.x<-256)||(badguy[count].spr.x>500)) badguy[count].active=0; if(Collided(count, 24)) player.energy-=2; break; case TICK: badguy[count].x--; badguy[count].y+=badguy[count].param; badguy[count].param++; if(badguy[count].y>=GROUND) badguy[count].param=badguy[count].max; badguy[count].spr.x=badguy[count].x-nMapx; badguy[count].spr.y=badguy[count].y; if((badguy[count].spr.x<-256)||(badguy[count].spr.x>500)) badguy[count].active=0; if(Collided(count, 24)) player.energy-=2; break; default: break; } GsSortSprite(&badguy[count].spr, &othWorld[nBuffer], 2); } } } //-------------------------------------------------------------- void DrawPanel(int x, int y) { static rate=0; RECT clear={0,185,320,7}; GsLINE line={1<<30, 235,0, 0,0, 0,0,0}; GsLINE max={1<<30, 0,220, 0,228, 255,255,255}; GsIMAGE tim1; GsSPRITE panel1={1<<25, 0,192, 160,48, 0,0,0, 0,0, 128,128,128, 0,0, ONE,ONE, 0}; GsSPRITE panel2={1<<25, 160,192, 160,48, 0,0,0, 0,0, 128,128,128, 0,0, ONE,ONE, 0}; GsSPRITE object={1<<25, 32,204, 32,24, 0,0,0, 0,0, 128,128,128, 0,0, ONE,ONE, 0}; static GsSPRITE grub={1<<25, 280,196, 32,40, 0,0,0, 0,0, 64,64,64, 0,0, ONE,ONE, 0}; GsGetTimInfo((u_long *)ROCK_TIM+1, &tim1); panel1.u=tim1.px%64; panel1.v=tim1.py%256; panel1.tpage=GetTPage(2, 0, tim1.px, tim1.py); panel2.u=(tim1.px+160)%64; panel2.v=tim1.py%256; panel2.tpage=GetTPage(2, 0, tim1.px+160, tim1.py); GsSortFastSprite(&panel1, &othWorld[nBuffer], 1); GsSortFastSprite(&panel2, &othWorld[nBuffer], 1); max.x0=max.x1=172+nMaxMagic; GsSortLine(&max, &othWorld[nBuffer], 0); if(player.energy<64) { for(line.y0=204; line.y0<212; line.y0++) { line.x1=172+player.energy; line.y1=line.y0; GsSortLine(&line, &othWorld[nBuffer], 0); } } if(player.magic<64) { for(line.y0=220; line.y0<228; line.y0++) { line.x1=172+player.magic; line.y1=line.y0; GsSortLine(&line, &othWorld[nBuffer], 0); } } if(player.magic) { if(!rate) { player.magic--; rate=mrate; } else rate--; } else { speed=1; player.state=NORMAL; } clear.y=(nBuffer*240)+185; ClearImage(&clear,0,0,0); GsGetTimInfo((u_long *)OBJECTS_TIM+1, &tim1); object.u=tim1.px%64; object.v=tim1.py%256; object.tpage=GetTPage(2,0, tim1.px, tim1.py); if(player.o1) { object.v=tim1.py+((player.o1-1)*24); GsSortFastSprite(&object, &othWorld[nBuffer], 0); } if(player.o2) { object.x=80; object.v=tim1.py+((player.o2-1)*24); GsSortFastSprite(&object, &othWorld[nBuffer], 0); } if(player.o3) { object.x=128; object.v=tim1.py+((player.o3-1)*24); GsSortFastSprite(&object, &othWorld[nBuffer], 0); } if(discount) { discount--; OutputString(lastobject, -1, 250,210, 255, &nFont[0], (u_long*)FONT_TIM, 33); OutputString(lastobject, -1, 251,211, 0, &nFont[0], (u_long*)FONT_TIM, 33); } if(grubman) { if(grub.r<128) { grub.r++; grub.g++; grub.b++; } GsGetTimInfo((u_long *)GRUBSML_TIM+1, &tim1); grub.u=tim1.px%64; grub.v=tim1.py%256; grub.tpage=GetTPage(2, 0, tim1.px, tim1.py); GsSortFastSprite(&grub, &othWorld[nBuffer], 0); grubman--; } else { grub.r=64; grub.g=64; grub.b=64; } if(nMapx>1024) { if(!(rand()&8191)) grubman=MAX_GRUBMAN; } } //-------------------------------------------------------------- void LevelClear() { } //-------------------------------------------------------------- void GameOver() { int count; GsIMAGE tim1; GsSPRITE grub={1<<25, 0,0, 0,0, 0,0,0, 0,0, 0,0,0, 0,0, ONE,ONE, 0}; GsSPRITE go={1<<25, 150,180, 0,0, 0,0,0, 0,0, 0,0,0, 0,0, 0,ONE, 0}; rClear.x=0; rClear.y=0; rClear.w=320; rClear.h=240; LoadTIM(GRUBBIG_TIM,0); LoadTIM(GAMEOVER_TIM,0); GsGetTimInfo((u_long *)GRUBBIG_TIM+1, &tim1); grub.x=160-(tim1.pw>>1); grub.y=32; grub.w=tim1.pw; grub.h=tim1.ph; grub.u=tim1.px%64; grub.v=tim1.py%256; grub.tpage=GetTPage(2, 0, tim1.px, tim1.py); GsGetTimInfo((u_long *)GAMEOVER_TIM+1, &tim1); go.w=tim1.pw; go.h=tim1.ph; go.u=tim1.px%64; go.v=tim1.py%256; go.mx=go.w>>1; go.my=go.h>>1; go.tpage=GetTPage(2, 0, tim1.px, tim1.py); do { PADstatus=PadRead(1); nBuffer=GsGetActiveBuff(); GsSetWorkBase((PACKET*)out_packet[nBuffer]); GsClearOt(0, 0, &othWorld[nBuffer]); rClear.y=(nBuffer*240); ClearImage(&rClear,0,0,0); if(grub.r<128) { grub.r+=2; grub.g+=2; grub.b+=2; } if(go.r<128) { go.r++; go.g++; go.b++; } if(grub.r==100) SsUtKeyOn(nVab2, 6,0, 48, 0, fxlevel>>1,fxlevel>>1); if(go.scalexpw; rLine.x=tim1->px; for(rLine.y=tim1->py; rLine.ypy+tim1->ph; rLine.y++) { StoreImage(&rLine, (u_long *)&lLine[0]); for(nCount=0; nCount<(tim1->pw*2); nCount+=2) lLine[nCount+1]|=0x80; LoadImage(&rLine, (u_long *)&lLine[0]); } } //-------------------------------------------------------------- void SmearClear(int r, int g, int b, int s, int ax, int ay) { int nCount; char lLine[640]; RECT rLine={0,0,320,1}; RECT rImage={0,0,320,240}; GsSPRITE screen={1<<25|1<<30, 160,120, 160,240, 0,0,0, 0,0, 0,0,0, 160,120, 0,0,0}; GsSPRITE screen2={1<<25|1<<30, 160,120, 160,240, 0,32,0, 0,0, 0,0,0, 0,120, 0,0,0}; for(rLine.y=(1-nBuffer)*240; rLine.y<((1-nBuffer)*240)+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.r=r; screen.g=g; screen.b=b; screen.rotate=ONE*(4/s); screen.scalex=ONE+(256/s); screen.scaley=ONE+(32/s); screen2.r=r; screen2.g=g; screen2.b=b; screen2.rotate=ONE*(4/s); screen2.scalex=ONE+(256/s); screen2.scaley=ONE+(32/s); rImage.y=(1-nBuffer)*240; MoveImage(&rImage, 0, nBuffer*240); for(nCount=92*s; nCount>0; nCount--) { if(nCount==64*s) { screen.r=127; screen.g=127; screen.b=127; screen2.r=127; screen2.g=127; screen2.b=127; } if(nCount>64) { screen.x+=ax; screen.y+=ay; screen2.x+=ax; screen2.y+=ay; } else { screen.x=160; screen.y=120; screen2.x=160; screen2.y=120; } GsSetWorkBase((PACKET*)out_packet[nBuffer]); GsClearOt(0, 0, &othWorld[nBuffer]); screen.tpage=GetTPage(2,0, 0, (1-nBuffer)*240); GsSortSprite(&screen, &othWorld[nBuffer], 0); screen2.tpage=screen.tpage+2; GsSortSprite(&screen2, &othWorld[nBuffer], 1); GsDrawOt(&othWorld[nBuffer]); DrawSync(0); VSync(0); GsSwapDispBuff(); nBuffer=GsGetActiveBuff(); GsSortClear(0,0,0,&othWorld[nBuffer]); } } //-------------------------------------------------------------- void FadeToBlack(int s) { RECT rImage={0,0,320,240}; GsSPRITE screen={1<<25, 0,0, 160,240, 0,0,0, 0,0, 128,128,128, 0,0, ONE,ONE,0}; GsSPRITE screen2={1<<25, 160,0, 160,240, 0,32,0, 0,0, 128,128,128, 0,0, ONE,ONE,0}; MoveImage(&rImage, 0,240); while(screen.r) { if(s>screen.r) s=screen.r; screen.r-=s; screen.g-=s; screen.b-=s; screen2.r-=s; screen2.g-=s; screen2.b-=s; GsSetWorkBase((PACKET*)out_packet[nBuffer]); GsClearOt(0, 0, &othWorld[nBuffer]); screen.tpage=GetTPage(2,0, 0, (1-nBuffer)*240); GsSortFastSprite(&screen, &othWorld[nBuffer], 0); screen2.tpage=screen.tpage+2; GsSortFastSprite(&screen2, &othWorld[nBuffer], 1); GsDrawOt(&othWorld[nBuffer]); DrawSync(0); VSync(0); GsSwapDispBuff(); nBuffer=GsGetActiveBuff(); GsSortClear(0,0,0,&othWorld[nBuffer]); } } //-------------------------------------------------------------- void OutputString(char * string, int len, int x, int y, int bright, int * font, u_long * fgfx, int offset) { int vx,vy; GsIMAGE tim1; GsSPRITE letter={1<<25, 0,0, 0,0, 0,0,0, 0,0, 0,0,0, 0,0, ONE,ONE, 0}; GsGetTimInfo(fgfx+1, &tim1); letter.h=tim1.ph; letter.x=x; letter.y=y; letter.r=bright; letter.g=bright; letter.b=bright; while(len&&*string) { if(*string==32) { letter.w=SPACE; if(letter.x>290) { letter.x=x-SPACE; letter.y+=letter.h+2; } } else if(*string=='\n') { letter.x=x-SPACE; letter.y+=letter.h+2; } else { vx=tim1.px+*(font+((*string)-offset)); letter.w=(*(font+(*string)-(offset-1)))-(*(font+(*string)-offset)); if((vx&1)&&(tim1.ph==12)) { vx--; letter.x--; letter.w++; } letter.tpage=GetTPage(2,0, vx,tim1.py); letter.u=vx%64; letter.v=tim1.py%256; GsSortSprite(&letter, &othWorld[nBuffer], 0); } letter.x+=letter.w; string++; len--; } } //-------------------------------------------------------------- int GetCentre(char * string, int * font, int offset) { int nLen=0; while(*string) { if(*string==32) nLen+=SPACE; else nLen+=nFont2[*string-(offset-1)]-nFont2[(*string)-offset]; string++; } nLen=160-(nLen>>1); return nLen; } //-------------------------------------------------------------- void OutputNum(int num, int len, int x, int y) { /*RECT rArea={704, 389, 5, 6}; int nCol; if(num<0) num=0; while(len) { if(num) nCol=num%10; else nCol=0; num-=nCol; num/=10; rArea.x=(nCol*5)+704; MoveImage(&rArea, x+(5*(len-1)), y); len--; }*/ } //-------------------------------------------------------------- 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 r; int nCount=0; while(((splat[nCount].ax)||(splat[nCount].ay))&&(nCount>1; splat[nCount].line.g1=splat[nCount].line.g0>>1; splat[nCount].line.b1=splat[nCount].line.b0>>1; } } //-------------------------------------------------------------- void DrawSplats(void) { int nCount; int bad; for(nCount=0; nCount0) splat[nCount].ax--; else if(splat[nCount].ax<0) splat[nCount].ax++; 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; if(splat[nCount].y>=GROUND) { splat[nCount].ax=0; splat[nCount].ay=0; } splat[nCount].line.x1=splat[nCount].x; splat[nCount].line.y1=splat[nCount].y; GsSortGLine(&splat[nCount].line, &othWorld[nBuffer], 2); splat[nCount].line.x0++; splat[nCount].line.x1++; splat[nCount].line.y0++; splat[nCount].line.y1++; GsSortGLine(&splat[nCount].line, &othWorld[nBuffer], 2); if(nCount&4) { for(bad=0; bad>1), badguy[bad].spr.y+(badguy[bad].spr.h>>1), badguy[bad].spr.w>>1)) { SsUtKeyOn(nVab3, 3,0, 48, 0, fxlevel,fxlevel); badguy[bad].active=0; StartSplat(0, badguy[bad].spr.x, badguy[bad].spr.y); StartSplat(0, badguy[bad].spr.x, badguy[bad].spr.y); StartSplat(0, badguy[bad].spr.x, badguy[bad].spr.y); StartSplat(0, badguy[bad].spr.x, badguy[bad].spr.y); } } } } } } else { if((splat[nCount].ax)||(splat[nCount].ay)) { if(splat[nCount].ax>0) 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], 2); } } } } //-------------------------------------------------------------- void PadInit (void) { 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; }