//*********************************************************** // // TANX2.0a by Stuart Macdonald // Codewarrior Version // display.c 1.0b // //*********************************************************** #include #include "header.h" // *********************************************************** // variables // *********************************************************** // extern stuff... extern int PLAYING; extern int INGAME; extern int MAX_NO_OF_POWERUPS; extern int MAX_NO_OF_KILLS; extern int setVictory; extern int whoWon; extern SpriteStructType0 theSprites[MAX_NO_OF_SPRITES]; extern LineStructType0 theLines[MAX_NO_OF_LINES]; extern BoxStructType0 theBoxes[MAX_NO_OF_BOXES]; extern ObjectStructType0 theTank[2]; extern ObjectStructType0 theTurret[2]; extern ObjectStructType0 theObjects[MAX_NO_OF_OBJECTS]; extern WorldStructType0 theWorld[2]; extern WorldStructType0 theBldgs[2]; extern voice_data bang,pickup,missile,missile2,shell2, shell, bang2, ping, alarm; // sound effects extern int gJoypads[2]; // global variables ------------------------------------------- // a variable to track the vsync interval u_long vsyncInterval=0; int optionkeypress1;// option up/down keypress state int optionkeypress2;//X option keypress state int Xpressed;//X option key pressed int runningIntro; int runningOptions; // display stuff --------------------------------- GsOT othWorld[2]; // We need two Ordering Table Headers, one for each buffer GsOT_TAG otWorld[2][1<lObjectPointer[theWorld->nTotalModels] = (unsigned long *)lModelAddress; //increment the pointer to move past the model id. (weird huh?) theWorld->lObjectPointer[theWorld->nTotalModels]++; // map tmd data to its actual address GsMapModelingData(theWorld->lObjectPointer[theWorld->nTotalModels]); // initialise the objects coordinate system - set to be that of the WORLD GsInitCoordinate2(WORLD, &theWorld->gsObjectCoord[theWorld->nTotalModels]); // increment pointer twice more - to point to top of model data (beats me!) theWorld->lObjectPointer[theWorld->nTotalModels]++; theWorld->lObjectPointer[theWorld->nTotalModels]++; // link the model (tmd) with the players object handler GsLinkObject4((unsigned long )theWorld->lObjectPointer[theWorld->nTotalModels], &theWorld->gsObjectHandler[theWorld->nTotalModels], 0); // set the amount of polygon subdivision that will be done at runtime (none!) theWorld->gsObjectHandler[theWorld->nTotalModels].attribute = GsDIV1; theWorld->gsObjectHandler[theWorld->nTotalModels].attribute = theWorld->gsObjectHandler[theWorld->nTotalModels].attribute & (1 << 6); theWorld->gsObjectHandler[theWorld->nTotalModels].attribute = theWorld->gsObjectHandler[theWorld->nTotalModels].attribute ^ (1 << 6); // Assign the coordinates of the object model to the Object Handler theWorld->gsObjectHandler[theWorld->nTotalModels].coord2 = &theWorld->gsObjectCoord[theWorld->nTotalModels]; // Set The Position of the Object theWorld->gsObjectCoord[theWorld->nTotalModels].coord.t[0]=nX; // X theWorld->gsObjectCoord[theWorld->nTotalModels].coord.t[1]=nY; // Y theWorld->gsObjectCoord[theWorld->nTotalModels].coord.t[2]=nZ; // Z theWorld->drawflag[theWorld->nTotalModels] = 1; // flag the object as needing to be drawn theWorld->gsObjectCoord[theWorld->nTotalModels].flg = 0; // Increment the object counter theWorld->nTotalModels++; } //*********************************************************** // LoadTexture // Loads texture into VRam // //*********************************************************** int LoadTexture (long addr) { RECT rect; GsIMAGE tim1; // get tim info/header, again a little bit of majic is needd the pointer // is incremented past the first 4 positions to get to this! GsGetTimInfo((u_long *)(addr+4),&tim1); // set the rect struct to contain the images x and y offset, width and height rect.x=tim1.px; rect.y=tim1.py; rect.w=tim1.pw; rect.h=tim1.ph; //load image from main memory to video memory LoadImage(&rect,tim1.pixel); // if image has clut we need to load it too, //pmode =8 for 4 bit and 9 for 8 bit colour if ((tim1.pmode >> 3) & 0x01) { // set the rect struct to contain the clut's x and y offset, width and height rect.x=tim1.cx; rect.y=tim1.cy; rect.w=tim1.cw; rect.h=tim1.ch; // load the clut into video memeory LoadImage(&rect,tim1.clut); } DrawSync(0); return (0); } //*********************************************************** // InitialiseAllTextures // Loads all the game's textures into VRam by calling // LoadTexture //*********************************************************** void InitialiseAllTextures (void) { LoadTexture(SNOW1_TIM); LoadTexture(SNOW2_TIM); LoadTexture(SNOW3_TIM); LoadTexture(SNOW4_TIM); LoadTexture(SNOW5_TIM); LoadTexture(BARREL_TIM); LoadTexture(PLATE_TIM); LoadTexture(PLTSTRIP_TIM); LoadTexture(TNKBACK_TIM); LoadTexture(TNKBODY_TIM); LoadTexture(RAILGLO_TIM); LoadTexture(TNKTOP_TIM); LoadTexture(TRACKS2_TIM); LoadTexture(CONC_TIM); LoadTexture(SNOWEDJ_TIM); LoadTexture(LASER_TIM); LoadTexture(BLUGLO_TIM); LoadTexture(FLAME1_TIM); LoadTexture(FLAME2_TIM); LoadTexture(FLAME3_TIM); LoadTexture(FLAME4_TIM); LoadTexture(FLAME5_TIM); LoadTexture(CANNON_TIM); LoadTexture(LASERGUN_TIM); LoadTexture(RAILGUN_TIM); LoadTexture(FLAMER_TIM); LoadTexture(MINIMAP_TIM); LoadTexture(PIXEL1_TIM); LoadTexture(PIXEL2_TIM); LoadTexture(PIXEL3_TIM); LoadTexture(PIXEL4_TIM); LoadTexture(PIXEL5_TIM); LoadTexture(PIXEL6_TIM); LoadTexture(EMPSICN_TIM); LoadTexture(INVISICN_TIM); LoadTexture(SHLDICN_TIM); LoadTexture(TELEPICN_TIM); LoadTexture(STATIC1_TIM); LoadTexture(STATIC2_TIM); LoadTexture(ELECTRO1_TIM); LoadTexture(ELECTRO2_TIM); LoadTexture(TAZERGUN_TIM); LoadTexture(MISLCHR_TIM); LoadTexture(NUM0_TIM); LoadTexture(NUM1_TIM); LoadTexture(NUM2_TIM); LoadTexture(NUM3_TIM); LoadTexture(NUM4_TIM); LoadTexture(NUM5_TIM); LoadTexture(NUM6_TIM); LoadTexture(NUM7_TIM); LoadTexture(NUM8_TIM); LoadTexture(NUM9_TIM); LoadTexture(SPEEDUP_TIM); LoadTexture(KILLTXT_TIM); LoadTexture(PERFECT_TIM); LoadTexture(POINTER1_TIM); LoadTexture(POINTER2_TIM); LoadTexture(OPTSTXT_TIM); LoadTexture(PLAYTXT_TIM); LoadTexture(EXITTXT_TIM); LoadTexture(WINSTXT_TIM); LoadTexture(PICKTXT_TIM); LoadTexture(BOTSTXT_TIM); LoadTexture(STARTXT_TIM); LoadTexture(PAUSETXT_TIM); LoadTexture(VICTORY_TIM); } //*********************************************************** // InitialiseSprite // Loads sprite into gsSPRITE structure // //*********************************************************** void InitialiseSprite (unsigned long timaddr, GsSPRITE *loadsprite, int px, int py) { GsIMAGE tim; /* Used to store info on TIM file */ //LoadTexture((long )timaddr); /* Load tim into VRAM */ GsGetTimInfo((unsigned long *)(timaddr+4),&tim); /* Get info on TIM file, and put it in the tim GsIMAGE struct */ loadsprite->attribute=(unsigned long int)(tim.pmode<<24); /* Set sprite attribute to the value passed to function */ loadsprite->x=px; /* Set starting x pos to a passed value */ loadsprite->y=py; /* Set starting y pos to a passed value */ if((tim.pmode<<24)& 0x01000000) loadsprite->w=tim.pw*2; else if((tim.pmode<<24)& 0x02000000) loadsprite->w=tim.pw; else loadsprite->w=tim.pw*4; loadsprite->h=tim.ph; /* Set sprite height */ loadsprite->tpage=GetTPage(1,0, tim.px, tim.py); /* Texture page info */ loadsprite->u=0; /* Set tpage x offset */ loadsprite->v=0; /* Set tpage y offset */ loadsprite->cx=tim.cx; /* Tell sprite x pos of clut */ loadsprite->cy=tim.cy; /* Tell sprite y pos of clut */ loadsprite->r=128; /* Set the r brightness */ loadsprite->g=128; /* Set the g brightness */ loadsprite->b=128; /* Set the b brightness */ loadsprite->mx=0; /* Set manipulation point x */ loadsprite->my=0; /* Set manipulation point y */ loadsprite->scalex=ONE; /* scale in x direction */ loadsprite->scaley=ONE; /* scale in y direction */ loadsprite->rotate=0; /* amount of rotation */ } //*********************************************************** // InitialiseLight // Sets up a light for the world // //*********************************************************** void InitialiseLight (GsF_LIGHT *flLight, int nLight, int nX, int nY, int nZ, int nRed, int nGreen, int nBlue) { // Set the direction in which the light travels flLight->vx = nX;flLight->vy = nY; flLight->vz = nZ; // Set the colour flLight->r = nRed; flLight->g = nGreen; flLight->b = nBlue; // Activate light GsSetFlatLight(nLight, flLight); } //*********************************************************** // InitialiseAllLights // Sets up all the light for the world by calling // InitialiseLight for the lights in the world //*********************************************************** void InitialiseAllLights (void) { InitialiseLight(&flLights[0], 0, 300, 100, 300, 0xee, 0xee, 0xee); InitialiseLight(&flLights[1], 1, -200, 200, -200, 0xcc, 0xcc, 0xcc); GsSetAmbient(0,0,0); GsSetLightMode(0); } //*********************************************************** // RenderWorld // Swaps display bufffers, calls draw to screen functions // for tanks, world and objects //*********************************************************** void RenderWorld (void) { RECT clip; //int n; // This variable keeps track of the current buffer for double buffering int currentBuffer; //get the current buffer currentBuffer=GsGetActiveBuff(); // Set the address of the packet area that will contain drawing commands GsSetWorkBase((PACKET*)out_packet[currentBuffer]); InitialiseBldgs(); InitialiseWorld(); //PLAYER 2's SCREEN // Set the viewing system GsSetRefView2(&view[1]); GsClearOt(0, 0, &othWorld2[currentBuffer]); // Draw the world DrawWorld(&theWorld[1], &othWorld2[currentBuffer], 2); // Draw the Buildings DrawBuildings(&theBldgs[1], &othWorld2[currentBuffer], 3); // Draw the players & bots DrawTanks(&othWorld2[currentBuffer],1); // Draw the other objects and sprites DrawAllObjects(&othWorld2[currentBuffer],2); DrawAllSprites(&othWorld2[currentBuffer], 1); DrawAllBoxes(&othWorld2[currentBuffer], 1); //PLAYER 1's SCREEN // Set the viewing system GsSetRefView2(&view[0]); GsClearOt(0, 0, &othWorld[currentBuffer]); // Draw the world DrawWorld(&theWorld[0], &othWorld[currentBuffer], 2); // Draw the Buildings DrawBuildings(&theBldgs[0], &othWorld[currentBuffer], 3); // Draw the players & bots DrawTanks(&othWorld[currentBuffer],0); // Draw the other objects and sprites DrawAllObjects(&othWorld[currentBuffer],1); DrawAllSprites(&othWorld[currentBuffer],0); DrawAllBoxes(&othWorld[currentBuffer],0); //SetMinimap(); // wait for end of drawing DrawSync(0); vsyncInterval=VSync(0); FntFlush(-1); // Swap The Buffers GsSwapDispBuff(); // register clear-command: clear to black //GsSortClear(0,0,0,&othWorld[currentBuffer]); //GsSortClear(127,127,127,&othWorld2[currentBuffer]); // Set offset of left screen GsSetOffset(SCREEN_WIDTH * 3 / 4, SCREEN_HEIGHT / 2); // Set clipping for left screen clip.x = SCREEN_WIDTH/2; clip.y = 0; clip.w = SCREEN_WIDTH/2; clip.h = SCREEN_HEIGHT; GsSetClip(&clip); // Start Drawing left screen GsDrawOt(&othWorld2[currentBuffer]); // Set offset of right screen GsSetOffset(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 2); // Set clipping for right screen clip.x = 0; clip.y = 0; clip.w = SCREEN_WIDTH / 2; clip.h = SCREEN_HEIGHT; GsSetClip(&clip); // Start Drawing right screen GsDrawOt(&othWorld[currentBuffer]); } //*********************************************************** // DrawObject // Draws an object of ObjectStructType // for tanks and objects //*********************************************************** void DrawObject (ObjectStructType0 *theObject, GsOT *othWorld, int depth) { MATRIX tmpls, tmplw; //Get the local world and screen coordinates, needed for light calculations GsGetLws(theObject->gsObjectHandler.coord2, &tmplw, &tmpls); // Set the resulting light source matrix GsSetLightMatrix(&tmplw); /* if (theObject->flag == BILLBOARD) { tmpls.m[0][0] = GsIDMATRIX2.m[0][0]; tmpls.m[0][1] = GsIDMATRIX2.m[0][1]; tmpls.m[0][2] = GsIDMATRIX2.m[0][2]; tmpls.m[1][0] = GsIDMATRIX2.m[1][0]; tmpls.m[1][1] = GsIDMATRIX2.m[1][1]; tmpls.m[1][2] = GsIDMATRIX2.m[1][2]; tmpls.m[2][0] = GsIDMATRIX2.m[2][0]; tmpls.m[2][1] = GsIDMATRIX2.m[2][1]; tmpls.m[2][2] = GsIDMATRIX2.m[2][2]; }*/ // Set the local screen matrix for the GTE (so it works out perspective etc) GsSetLsMatrix(&tmpls); // Send Object To Ordering Table GsSortObject4( &theObject->gsObjectHandler,othWorld,depth,(u_long *)getScratchAddr(0)); } //*********************************************************** // DrawPlayers // Draws a tank object of ObjectStructType // for tanks and objects. calls DrawObject //*********************************************************** void DrawTanks (GsOT *othWorld, int display) { int nCurrentModel; for (nCurrentModel = 0; nCurrentModel < 2; nCurrentModel++) { if((theTank[nCurrentModel].display == display) || (theTank[nCurrentModel].display == 3)) { DrawObject(&theTank[nCurrentModel], othWorld, theTank[nCurrentModel].depth); // Draw the turret DrawObject(&theTurret[nCurrentModel], othWorld, theTurret[nCurrentModel].depth); } } } //*********************************************************** // DrawAllObjects // Draws an object of ObjectStructType, cheking if its alive // where theObjects[n].id > 0. calls DrawObject //*********************************************************** void DrawAllObjects (GsOT *othWorld, int screen) { int nCurrentModel; for (nCurrentModel = 0; nCurrentModel < MAX_NO_OF_OBJECTS; nCurrentModel++) { if(theObjects[nCurrentModel].id > 0) { if((theObjects[nCurrentModel].display == screen) || (theObjects[nCurrentModel].display == 3)) { DrawObject(&theObjects[nCurrentModel], othWorld, theObjects[nCurrentModel].depth); } } } } //*********************************************************** // DrawWorld // Draws an object of ObjectStructType, checking if its to // be drawn where theWorld.drawflag[nCurrentModel] == 1 //*********************************************************** void DrawWorld (WorldStructType0 *theWorld, GsOT *othWorld, int depth) { MATRIX tmpls, tmplw; int nCurrentModel; for (nCurrentModel = 0; nCurrentModel < MAX_WORLD_OBJECTS; nCurrentModel++) { if (theWorld->drawflag[nCurrentModel] > 0) { //Get the local world and screen coordinates, needed for light calculations GsGetLws(theWorld->gsObjectHandler[nCurrentModel].coord2, &tmplw, &tmpls); // Set the resulting light source matrix // GsSetLightMatrix(&tmplw); // Set the local screen matrix for the GTE (so it works out perspective etc) GsSetLsMatrix(&tmpls); // Send Object To Ordering Table GsSortObject4( &theWorld->gsObjectHandler[nCurrentModel], othWorld, depth,(u_long *)getScratchAddr(0)); } } } //*********************************************************** // DrawBuildings // Draws an object of ObjectStructType, checking if its to // be drawn where theWorld.drawflag[nCurrentModel] == 1 //*********************************************************** void DrawBuildings (WorldStructType0 *theWorld, GsOT *othWorld, int depth) { MATRIX tmpls, tmplw; int nCurrentModel; for (nCurrentModel = 0; nCurrentModel < MAX_WORLD_OBJECTS; nCurrentModel++) { if (theWorld->drawflag[nCurrentModel] > 0) { //Get the local world and screen coordinates, needed for light calculations GsGetLws(theWorld->gsObjectHandler[nCurrentModel].coord2, &tmplw, &tmpls); // Set the resulting light source matrix //if(theWorld->drawflag[nCurrentModel] > 1){ // GsSetLightMatrix(&tmplw); //} // Set the local screen matrix for the GTE (so it works out perspective etc) GsSetLsMatrix(&tmpls); // Send Object To Ordering Table GsSortObject4( &theWorld->gsObjectHandler[nCurrentModel], othWorld, depth,(u_long *)getScratchAddr(0)); } } } //*********************************************************** // DrawSprite // Draws a Sprite of SpritetStructType // //*********************************************************** void DrawSprite (SpriteStructType0 *theSprite, GsOT *othWorld, int depth) { GsSortFastSprite(&theSprite->sprite, othWorld, depth); } //*********************************************************** // DrawAllSprites // Checks all sprites of SpriteStructType, checking // theSprites[n].id > 0. calls DrawSprite //*********************************************************** void DrawAllSprites (GsOT *othWorld, int display) { int nCurrentSprite; for (nCurrentSprite = 0; nCurrentSprite < MAX_NO_OF_SPRITES; nCurrentSprite++) { if(theSprites[nCurrentSprite].id > 0) { if((theSprites[nCurrentSprite].display == display) || (theSprites[nCurrentSprite].display == 3)) { DrawSprite(&theSprites[nCurrentSprite], othWorld, theSprites[nCurrentSprite].depth); } } } } //*********************************************************** // DrawAllLines // Checks all lines of LineStructType, checking // theLines[n].id > 0. calls DrawLine //*********************************************************** void DrawAllLines (GsOT *othWorld) { int n; for (n = 0; n < MAX_NO_OF_LINES; n++) { if (theLines[n].id > 0) { DrawLine(&theLines[n], othWorld, theLines[n].depth); } } } //*********************************************************** // DrawAllBoxes // Checks all boxes of BoxStructType, checking // theBoxes[n].id > 0. calls DrawBox //*********************************************************** void DrawAllBoxes (GsOT *othWorld, int display) { int n; for (n = 0; n < MAX_NO_OF_BOXES; n++) { if (theBoxes[n].id > 0) { if((theBoxes[n].display == display) || (theBoxes[n].display == 3)) { DrawBox(&theBoxes[n], othWorld, theBoxes[n].depth); } } } } //*********************************************************** // DrawBox // // //*********************************************************** void DrawBox (BoxStructType0 *theBox, GsOT *othWorld, int depth) { GsSortBoxFill(&theBox->gsBoxHandler, othWorld, depth); } //*********************************************************** // DrawLine // // //*********************************************************** void DrawLine (LineStructType0 *theLine, GsOT *othWorld, int depth) { GsSortLine(&theLine->gsLineHandler, othWorld, depth); } //*********************************************************** // InitialiseView // Sets up view according to the passed co-ords // //*********************************************************** void InitialiseView (GsRVIEW2 *view, int nProjDist, int nRZ, int nVPX, int nVPY, int nVPZ, int nVRX, int nVRY, int nVRZ) { // This is the distance between the eye // and the imaginary projection screen GsSetProjection(nProjDist); // Set the eye position or center of projection view->vpx = nVPX; view->vpy = nVPY; view->vpz = nVPZ; // Set the look at position view->vrx = nVRX; view->vry = nVRY; view->vrz = nVRZ; // Set which way is up view->rz=-nRZ; // Set the origin of the coord system in this case the car view->super = WORLD; //&theTurret[x].gsObjectCoord // Activate view GsSetRefView2(view); } //*********************************************************** // InitialiseTurretView // Sets up the view to follow the tank's turret // //*********************************************************** void InitialiseTurretView (GsRVIEW2 *view, int n) { view->super = &theTurret[n].gsObjectCoord; view->vrx = 0; view->vry = 0; view->vrz = 1800; view->vpx = 0; view->vpy = -4900; view->vpz = -5800; //GsSetRefView2(view); } //*********************************************************** // UpdateScores // Sets up the tank's frag scores // //*********************************************************** void updateScores ( void ) { int spritenum; int score; int posx; int n; for(n = 0; n < 2; n++) { if(theTank[n].score > 9){ theTank[n].score = 0; } score = theTank[n].score; spritenum = 11 + n; posx = 86 - (n * 189); //theSprites[spritenum].id = SCORES; //InitialiseSprite(NUM0_TIM, &theSprites[spritenum].sprite, posx, -48); // load score //theSprites[spritenum].sprite.u = (score * 16); //theSprites[spritenum].sprite.v = 32; //theSprites[spritenum].display = n; //theSprites[spritenum].depth = 2; LoadNumber (&theSprites[spritenum], score,posx, -48, n, 2, SCORES); } } //*********************************************************** // LoadNumber // // //*********************************************************** void LoadNumber (SpriteStructType0 *theSprite, int num, int posx, int posy, int display, int depth, int id) { theSprite->id = id; InitialiseSprite(NUM0_TIM, &theSprite->sprite , posx, posy); // load score theSprite->sprite.u = (num * 16); theSprite->sprite.v = 32; theSprite->display = display; theSprite->depth = depth; } //*********************************************************** // Greyscreen // // //*********************************************************** void GreyScreen (BoxStructType0 *theBox, int display, int depth) { theBox->gsBoxHandler.x = -127; theBox->gsBoxHandler.y = -127; theBox->gsBoxHandler.w = 256; theBox->gsBoxHandler.h = 256; theBox->gsBoxHandler.r = 200; //set to mid-grey theBox->gsBoxHandler.g = 200; theBox->gsBoxHandler.b = 200; theBox->depth = depth; theBox->display = display; theBox->id = 99; theBox->gsBoxHandler.attribute = theBox->gsBoxHandler.attribute | (1<<30); //make semi-transparent } //*********************************************************** // InitialiseIntroScreen // Sets up and updates the pre-game screen and options // //*********************************************************** void InitialiseIntroScreen ( void ) { int optioncounter; int killnum; int pownum; int bots; int option; int tempoption; runningIntro = 1; runningOptions = 0; option = 0; GreyScreen (&theBoxes[4], 3, 0); SetupIntro( option ); optioncounter = 0; Xpressed = 0; killnum = 4; pownum = 4; bots = false; MAX_NO_OF_KILLS = 1 + (killnum * 2); MAX_NO_OF_POWERUPS = 4 + (pownum * 4); // set-up pointer InitialiseSprite(POINTER1_TIM, &theSprites[13].sprite, -127, (option * 30)-20); theSprites[13].sprite.v = 32; theSprites[13].id = 1; theSprites[13].display = 1;// right hand screen only while(runningIntro) { InitialiseSprite(POINTER1_TIM, &theSprites[13].sprite, -127, (option * 30)-20); theSprites[13].sprite.v = 32; SetupIntro( option ); UpdatePads(); tempoption = ReadOptionsPad( option, 2 ); option = tempoption; switch(option) { case 0: if( Xpressed ) { runningOptions = 1; option = 0; } break; case 2: if( Xpressed ) { PLAYING = false; INGAME = false; } //note no break, flow falls through deliberately case 1: if( Xpressed ) { runningIntro = 0; } break; } while(runningOptions)// if in options screen { InitialiseSprite(POINTER1_TIM, &theSprites[13].sprite, -127, (option * 30)-20); theSprites[13].sprite.v = 32; SetupOptions( option ); UpdatePads(); tempoption = ReadOptionsPad( option, 3 ); option = tempoption; switch(option) { case 0: if( Xpressed ) { killnum ++; if (killnum > 4) killnum = 0; MAX_NO_OF_KILLS = 1 + (killnum * 2); } break; case 1: if( Xpressed ) { pownum ++; if (pownum > 4) pownum = 0; MAX_NO_OF_POWERUPS = 4 + (pownum * 4); } break; case 2: if( Xpressed ) { bots = false; } break; case 3: if( Xpressed ) { runningOptions = 0; option = 0; } break; } optioncounter ++; optioncounter %= 11; if ( optioncounter > 5 ) { InitialiseSprite(POINTER1_TIM, &theSprites[13].sprite, -127, (option * 30)-20); theSprites[13].sprite.v = 56; } RenderWorld (); } optioncounter ++; optioncounter %= 11; if ( optioncounter > 5 ) { InitialiseSprite(POINTER1_TIM, &theSprites[13].sprite, -127, (option * 30)-20); theSprites[13].sprite.v = 56; } RenderWorld (); } PLAYING = 1; // tidy up spirites etc. theBoxes[4].id = 0; theSprites[13].id = 0; theSprites[14].id = 0; theSprites[15].id = 0; theSprites[16].id = 0; theSprites[17].id = 0; theSprites[18].id = 0; theSprites[19].id = 0; theSprites[20].id = 0; setVictory = 0; return ; } //*********************************************************** // SetupIntro // Sets up and the pre-game screen // //*********************************************************** void SetupIntro ( int which ) { InitialiseSprite(OPTSTXT_TIM, &theSprites[14].sprite, 0, -20); theSprites[14].sprite.v = 32; theSprites[14].sprite.w -= 2; theSprites[14].display = 0; theSprites[14].depth = 0; theSprites[14].id = 1; InitialiseSprite(PLAYTXT_TIM, &theSprites[15].sprite, 0, 10); theSprites[15].sprite.v = 56; theSprites[15].display = 0; theSprites[15].depth = 0; theSprites[15].id = 1; InitialiseSprite(EXITTXT_TIM, &theSprites[16].sprite, 0, 40); theSprites[16].sprite.v = 80; theSprites[16].sprite.w -= 2; theSprites[16].display = 0; theSprites[16].depth = 0; theSprites[16].id = 1; theSprites[17].id = 0; theSprites[18].id = 0; theSprites[19].id = 0; theSprites[20].id = 0; } //*********************************************************** // SetupOptions // Sets up and the pre-game options screen // //*********************************************************** void SetupOptions ( int which ) { InitialiseSprite(WINSTXT_TIM, &theSprites[14].sprite, -50, -20); theSprites[14].sprite.v = 104; theSprites[14].display = 0; theSprites[14].depth = 0; theSprites[14].id = 1; LoadNumber (&theSprites[18],MAX_NO_OF_KILLS, 100, -24, 0, 0, 1); InitialiseSprite(PICKTXT_TIM, &theSprites[15].sprite, -50, 10); theSprites[15].sprite.v = 128; theSprites[15].display = 0; theSprites[15].depth = 0; theSprites[15].id = 1; //if(MAX_NO_OF_POWERUPS < 10) //{ LoadNumber (&theSprites[19],(MAX_NO_OF_POWERUPS/4), 100, 6, 0, 0, 1); theSprites[20].id = 0; //} //else { // if(MAX_NO_OF_POWERUPS < 20) // { // LoadNumber (&theSprites[19],1, 82, 16, 0, 0, 1); // LoadNumber (&theSprites[20],(MAX_NO_OF_POWERUPS - 10), 100, 16, 0, 0, 1); // } // else { // LoadNumber (&theSprites[19],2, 82, 16, 0, 0, 1); // LoadNumber (&theSprites[20],0, 100, 16, 0, 0, 1); // } //} InitialiseSprite(BOTSTXT_TIM, &theSprites[16].sprite, -50, 40); theSprites[16].sprite.v = 152; theSprites[16].display = 0; theSprites[16].depth = 0; theSprites[16].id = 1; //LoadNumber (&theSprites[20], 0, 100, 56, 0, 0, 1); InitialiseSprite(EXITTXT_TIM, &theSprites[17].sprite, -50, 70); theSprites[17].sprite.v = 80; theSprites[17].sprite.w -= 2; theSprites[17].display = 0; theSprites[17].depth = 0; theSprites[17].id = 1; } //*********************************************************** // ReadOptionsPad // Checks and updates options pointer // //*********************************************************** int ReadOptionsPad ( int option, int max ) { int i; int press1; int press2; int tempoption; tempoption = option; GetButtonsState (&gJoypads[0], &gJoypads[1]); //optionkeypress1 = 0; //optionkeypress2 = 0; press1 = 0; press2 = 0; Xpressed = 0; for(i = 0;i < 2;i++) { if (gJoypads[i] & SPADup) { if(optionkeypress1 == 0) { tempoption --; if(tempoption < 0) tempoption = max; InitialiseSprite(POINTER1_TIM, &theSprites[13].sprite, -127, (tempoption * 40)-20); theSprites[13].sprite.v = 32; PlaySFX(&pickup); } press1 = 1; } if (gJoypads[i] & SPADdown) { if(optionkeypress1 == 0) { tempoption ++; if(tempoption > max) tempoption = 0; InitialiseSprite(POINTER1_TIM, &theSprites[13].sprite, -127, (tempoption * 40)-20); theSprites[13].sprite.v = 32; PlaySFX(&pickup); } press1 = 1; } if (gJoypads[i] & SPADcr) { if((optionkeypress2 == 0)&&(optionkeypress1 == 0)) { Xpressed = 1; PlaySFX(&ping); } press1 = 1; press2 = 1; } } optionkeypress1 = press1; optionkeypress2 = press2; return tempoption; }