/*************************************************************** main.c ====== ***************************************************************/ #include #include #include #include #include "pad.h" #define ORDERING_TABLE_LENGTH (14) #define MAX_NO_PACKETS (248000) #define SCREEN_WIDTH (320) #define SCREEN_HEIGHT (240) //#define CAR_MEM_ADDR (0x80090000) #define F1_A 0x80090000 #define F2_A 0x80093C2C #define F3_A 0x80097858 #define F4_A 0x8009B484 #define F5_A 0x8009F0B0 #define F6_A 0x800A2CDC #define F7_A 0x800A6908 #define F8_A 0x800AA534 #define F9_A 0x800AE160 #define BOTTOP_A 0x800C4428 #define CUBE_A 0x800C7D9C #define GUN_A 0x800C7EAC #define PAINT_A 0x800C86EC #define HOUSE_A 0x800C8F2C #define MISSLE_A 0x800C9ABC #define POWER_A 0x800CA1E4 #define TSCREEN_A 0x800CAA24 #define MECHT_A 0x800F023C #define MENU_A 0x80115A54 // Total number of sprites plus one #define MAX_SPRITES 2 // Masks for setting sprite attribute #define SIXTEEN_BIT_MASK (1<<25) // Set ordering table length for sprites #define OT_LENGTH 1 // frame number int FRAME=0; /////////////////////////////////////////////////////////// #define PACKETMAX 2048 #define PACKETMAX2 (PACKETMAX*24) PACKET GpuPacketArea[2][PACKETMAX2]; GsIMAGE tscreen; GsIMAGE mecht; GsIMAGE menu; // Sprite pointer GsSPRITE leftSprite, rightSprite; GsSPRITE power[4]; // Ordering table variables GsOT WorldOT[2]; GsOT_TAG OTTags[2][1<gsObjectCoord); // increment pointer twice more - to point to top of model data // (beats me!) lModelAddress++; lModelAddress++; // link the model (tmd) with the players object handler // change unsigned long * to unsigned long GsLinkObject4((unsigned long )lModelAddress, &thePlayer->gsObjectHandler,0); // Assign the coordinates of the object model to the Object Handler thePlayer->gsObjectHandler.coord2 = &thePlayer->gsObjectCoord; // Set the initial position of the object thePlayer->gsObjectCoord.coord.t[0]=nX; // X thePlayer->gsObjectCoord.coord.t[1]=nY; // Y thePlayer->gsObjectCoord.coord.t[2]=nZ; // Z // setting the players gsObjectCoord.flg to 0 indicates it is to be // drawn thePlayer->gsObjectCoord.flg = 0; } // This function deals with setting up matrices needed for rendering // and sends the object to the ordering table so it is drawn //**************************************************************************** // DrawPlayer //**************************************************************************** void DrawPlayer(PlayerStructType1 *thePlayer, GsOT *othWorld) { MATRIX tmpls, tmplw; GsDOBJ2 *tmpPtr; // Set The Local World/Screen MATRIX GsGetLws(thePlayer->gsObjectHandler.coord2, &tmplw, &tmpls); GsSetLightMatrix(&tmplw); GsSetLsMatrix(&tmpls); tmpPtr = &thePlayer->gsObjectHandler; // Send Object To Ordering Table GsSortObject4( tmpPtr,othWorld,2,//16 - ORDERING_TABLE_LENGTH, (u_long *)getScratchAddr(0)); } //**************************************************************************** // InitialiseLight //**************************************************************************** void InitialiseLight(GsF_LIGHT *flLight, int nLight, int nX, int nY, int nZ, int nRed, int nGreen, int nBlue) { // Set the direction in which 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 //********************************************************************************************* void InitialiseAllLights() { InitialiseLight(&flLights[0], 0, -1, -1, -1, 255,255,255); InitialiseLight(&flLights[1], 1, 1, 1, 1, 255,255,255); GsSetAmbient(0,0,0); GsSetLightMode(0); } //********************************************************************************************* // InitialiseView //********************************************************************************************* 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; //&theCar.gsObjectCoord ; // Activate view GsSetRefView2(view); } //************************************************************************** // InitialiseGraphics //************************************************************************* // this function initialises the graphics system void InitialiseGraphics() { // Initialise The Graphics System to PAL as opposed to NTSC SetVideoMode(MODE_PAL); // Set the Actual Size of the Video memory GsInitGraph(SCREEN_WIDTH, SCREEN_HEIGHT, GsINTER|GsOFSGPU, 1, 0); // Set the Top Left Coordinates Of The Two Buffers in video memory GsDefDispBuff(0, 0, 0, SCREEN_HEIGHT); // Initialise the 3D Graphics... GsInit3D(); // Before we can use the ordering table headers, // we need to... // 1. Set them to the right length othWorld[0].length = ORDERING_TABLE_LENGTH; othWorld[1].length = ORDERING_TABLE_LENGTH; // 2. Associate them with an actual ordering table othWorld[0].org = otWorld[0]; othWorld[1].org = otWorld[1]; // 3. initialise the World Ordering Table Headers and Arrays GsClearOt(0,0,&othWorld[0]); GsClearOt(0,0,&othWorld[1]); } //************************************************************************* // RenderWorld //************************************************************************* // This function deals with double buffering and drawing of 3D objects void RenderWorld(PlayerStructType1 *thePlayer) { // This variable keeps track of the current buffer for double buffering int currentBuffer; //get the current buffer currentBuffer=GsGetActiveBuff(); // set address for GPU scratchpad area GsSetWorkBase((PACKET*)out_packet[currentBuffer]); // clear the ordering table GsClearOt(0, 0, &othWorld[currentBuffer]); // draw the player DrawPlayer(thePlayer, &othWorld[currentBuffer]); //print your elegant message // FntPrint("Code Warrior Rules!\n"); // force text output to the PSX screen FntFlush(-1); // wait for end of drawing DrawSync(0); // wait for V_BLANK interrupt VSync(0); // swap double buffers GsSwapDispBuff(); // register clear-command: clear ordering table to black GsSortClear(0, 0, 0,&othWorld[currentBuffer]); // register request to draw ordering table GsDrawOt(&othWorld[currentBuffer]); } //***************************************************************************** // RenderGAMEWorld //***************************************************************************** // This function deals with double buffering and drawing of 3D objects void RenderGAMEWorld(PlayerStructType1 *thePlayer) { int i; // This variable keeps track of the current buffer for double buffering int currentBuffer; //get the current buffer currentBuffer=GsGetActiveBuff(); // set address for GPU scratchpad area GsSetWorkBase((PACKET*)out_packet[currentBuffer]); // clear the ordering table GsClearOt(0, 0, &othWorld[currentBuffer]); // draw the player DrawPlayer(thePlayer, &othWorld[currentBuffer]); DrawPlayer(&cube, &othWorld[currentBuffer]); DrawPlayer(&bottop, &othWorld[currentBuffer]); DrawPlayer(&house, &othWorld[currentBuffer]); if(MISSLEDRAW==1)DrawPlayer(&missle, &othWorld[currentBuffer]); for(i=0;icoord, &matTmp,&gsObjectCoord->coord); gsObjectCoord->flg=0; } //********************************************************************************************* // MoveModel //********************************************************************************************* void MoveModel (GsCOORDINATE2 *gsObjectCoord, int nX, int nY, int nZ) { gsObjectCoord->coord.t[0]=gsObjectCoord->coord.t[0]+nX; gsObjectCoord->coord.t[1]=gsObjectCoord->coord.t[1]+nY; gsObjectCoord->coord.t[2]=gsObjectCoord->coord.t[2]+nZ; gsObjectCoord->flg=0; } //********************************************************************************************* // Advance model //********************************************************************************************* // move the model nD steps in the direction it is pointing void AdvanceModel (GsCOORDINATE2 *gsObjectCoord, SVECTOR *rotateVector, int nD) { // Moves the model nD units in the direction of its rotation vector MATRIX matTmp; SVECTOR startVector; SVECTOR currentDirection; // if nD = 0 there is no movement and we need to avoid the // main body of the function which will cause a divide by zero error if(nD!=0) { // set up original vector, pointing down the positive z axis startVector.vx = 0; startVector.vy = 0; startVector.vz = ONE; // RotMatrix sets up the matrix coefficients for rotation RotMatrix(rotateVector, &matTmp); // multiply startVector by mattmp and put the result in // currentDirection which is the vector defining the direction // the player is pointing ApplyMatrixSV(&matTmp, &startVector, ¤tDirection); // set the translation based on the currentDirection, note // currentDirection components have been scaled by 4096 so we // divide by 4096 to scale them back gsObjectCoord->coord.t[0] +=(currentDirection.vx * nD)/4096; gsObjectCoord->coord.t[1] +=(currentDirection.vy * nD)/4096; gsObjectCoord->coord.t[2] +=(currentDirection.vz * nD)/4096; // Because it has changed set flg to redraw object gsObjectCoord->flg = 0; } //end if } //********************************************************************************************* // reset the matrix //********************************************************************************************* void ResetMatrix (short m[3][3]) { m[0][0]=m[1][1]=m[2][2]=ONE; m[0][1]=m[0][2]=m[1][0]=m[1][2]=m[2][0]=m[2][1]=0; } //*************************************************************************** // move object //**************************************************************************** void MoveObject(GsCOORDINATE2 *gsObjectCoord,SVECTOR *rotateVector, int nRX, int nRY, int nRZ, int nD) { MATRIX matTmp; //SVECTOR svRotate; ///////////////////// SVECTOR startVector; SVECTOR currentDirection; // SVECTOR oldDirection; /////////////////////////////////////////////////////////////////////////// // Moves the model nD units in the direction of its rotation vector // MATRIX matTmp; ///////////////// ResetMatrix(gsObjectCoord->coord.m); // rotation vector rotateVector->vx = (rotateVector->vx+nRX)%ONE; rotateVector->vy = (rotateVector->vy+nRY)%ONE; rotateVector->vz = (rotateVector->vz+nRZ)%ONE; //RotMatrix sets up the matix coefficients for rotation RotMatrix(rotateVector, &matTmp); //concatenate the existing objects with the rotation matrix MulMatrix0(&gsObjectCoord->coord, &matTmp,&gsObjectCoord->coord); // gsObjectCoord->flg=0; ////////////////////////////// // if nD = 0 there is no movement and we need to avoid the // main body of the function which will cause a divide by zero error if(nD!=0) { // set up original vector, pointing down the positive z axis startVector.vx = 0; startVector.vy = 0; startVector.vz = ONE; // RotMatrix sets up the matrix coefficients for rotation RotMatrix(rotateVector, &matTmp); // multiply startVector by mattmp and put the result in // currentDirection which is the vector defining the direction // the player is pointing ApplyMatrixSV(&matTmp, &startVector, ¤tDirection); // set the translation based on the currentDirection, note // currentDirection components have been scaled by 4096 so we // divide by 4096 to scale them back gsObjectCoord->coord.t[0] +=(currentDirection.vx * nD)/4096; gsObjectCoord->coord.t[1] +=(currentDirection.vy * nD)/4096; gsObjectCoord->coord.t[2] +=(currentDirection.vz * nD)/4096; // gsObjectCoord->flg = 0; } //end if gsObjectCoord->flg = 0; } // //******************************************************************** // title screen //******************************************************************** void titlescreen() { { // Working variable int i,j; // FntPrint("Code Warrior Rules!\n"); // Initialise the drawing system GsInitGraph(SCREEN_WIDTH,SCREEN_HEIGHT,4,0,0); GsDefDispBuff(0,0,0,SCREEN_HEIGHT); // Initialise the ordering table for (i=0;i<2;i++) { WorldOT[i].length = OT_LENGTH; WorldOT[i].org = OTTags[i]; } // Initialise the sprite InitSprites(TSCREEN_A); // Get pad bits // GetPadBuf(&bb0,&bb1); // Keep playing until select pressed for(j=0;j<100;j++) { printf("%d",j); FntPrint("Code Warrior Rules!\n"); // Find out which buffer is being used activeBuff = GsGetActiveBuff(); // Packet area GsSetWorkBase((PACKET *)GpuPacketArea[activeBuff]); // Clear the ordering table GsClearOt(0,0,&WorldOT[activeBuff]); // Update the sprite GsSortFastSprite(&leftSprite,&WorldOT[activeBuff],0); GsSortFastSprite(&rightSprite,&WorldOT[activeBuff],0); // Wait for all drawing to finish DrawSync(0); // Wait for vertical blank interrupt VSync(0); // Switch display buffer GsSwapDispBuff(); // Clear the ordering table GsSortClear(0,0,0,&WorldOT[activeBuff]); /* The 3 zeros are the background colour */ // Draw the objects registered in the Ordering table GsDrawOt(&WorldOT[activeBuff]); } InitSprites(MECHT_A); for(j=0;j<100;j++) { printf("%d",j); FntPrint("Code Warrior Rules!\n"); // Find out which buffer is being used activeBuff = GsGetActiveBuff(); // Packet area GsSetWorkBase((PACKET *)GpuPacketArea[activeBuff]); // Clear the ordering table GsClearOt(0,0,&WorldOT[activeBuff]); // Update the sprite GsSortFastSprite(&leftSprite,&WorldOT[activeBuff],0); GsSortFastSprite(&rightSprite,&WorldOT[activeBuff],0); // Wait for all drawing to finish DrawSync(0); // Wait for vertical blank interrupt VSync(0); // Switch display buffer GsSwapDispBuff(); // Clear the ordering table GsSortClear(0,0,0,&WorldOT[activeBuff]); /* The 3 zeros are the background colour */ // Draw the objects registered in the Ordering table GsDrawOt(&WorldOT[activeBuff]); } InitSprites(MENU_A); for(j=0;j<100;j++) { printf("%d",j); FntPrint("Code Warrior Rules!\n"); // Find out which buffer is being used activeBuff = GsGetActiveBuff(); // Packet area GsSetWorkBase((PACKET *)GpuPacketArea[activeBuff]); // Clear the ordering table GsClearOt(0,0,&WorldOT[activeBuff]); // Update the sprite GsSortFastSprite(&leftSprite,&WorldOT[activeBuff],0); GsSortFastSprite(&rightSprite,&WorldOT[activeBuff],0); // Wait for all drawing to finish DrawSync(0); // Wait for vertical blank interrupt VSync(0); // Switch display buffer GsSwapDispBuff(); // Clear the ordering table GsSortClear(0,0,0,&WorldOT[activeBuff]); /* The 3 zeros are the background colour */ // Draw the objects registered in the Ordering table GsDrawOt(&WorldOT[activeBuff]); } } } void InitSprites(long ADDRESS) { RECT rect; GsIMAGE tim_data; // Put data from tim file into rect GsGetTimInfo ((u_long *)(ADDRESS+4),&tim_data); // Load the image into the frame buffer rect.x = 320; // Hard code the position of the tim data rect.y = 0; // Hard code the position of the tim data rect.w = tim_data.pw; // Data width rect.h = tim_data.ph; // Data height LoadImage(&rect, tim_data.pixel); // Load the tim data into the frame buffer // Initialise sprite structure leftSprite.attribute = SIXTEEN_BIT_MASK; leftSprite.x = 0; leftSprite.y = 0; leftSprite.w = tim_data.pw/2; // Sprite width leftSprite.h = tim_data.ph; // Sprite height leftSprite.tpage = GetTPage(2,0, 320, 0); leftSprite.u = 0; // No offset leftSprite.v = 0; // No offset leftSprite.r = 128; // Regular brightness leftSprite.g = 128; // Regular brightness leftSprite.b = 128; // Regular brightness leftSprite.mx = 0; // leftSprite.my = 0; // leftSprite.scalex = ONE; // Defined as 4096 leftSprite.scaley = ONE; // Defined as 4096 leftSprite.rotate = 0; // No rotation leftSprite.cx = 0; // No CLUT leftSprite.cy = 0; // No CLUT rightSprite.attribute = SIXTEEN_BIT_MASK; rightSprite.x = 160; rightSprite.y = 0; rightSprite.w = tim_data.pw/2; // Sprite width rightSprite.h = tim_data.ph; // Sprite height rightSprite.tpage = GetTPage(2,0, 480, 0); rightSprite.u = 32; // Set texture page offset rightSprite.v = 0; // Set texture page offset rightSprite.r = 128; // Regular brightness rightSprite.g = 128; // Regular brightness rightSprite.b = 128; // Regular brightness rightSprite.mx = 0; // rightSprite.my = 0; // rightSprite.scalex = ONE; // Defined as 4096 rightSprite.scaley = ONE; // Defined as 4096 rightSprite.rotate = 0; // No rotation rightSprite.cx = 0; // No CLUT rightSprite.cy = 0; // No CLUT // Wait until LoadImage() has finished before returning DrawSync(0); } // load up from conventional memory into video memory int LoadTexture(long addr) { RECT rect; GsIMAGE tim1; // get tim info/header, again a little bit of magic is needed 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 memory LoadImage(&rect,tim1.clut); } // wait for load to finish by calling drawsync. DrawSync(0); return(0); } //********************************************************************************************* // InitialiseTrackerView //********************************************************************************************* void InitialiseTrackerView(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 = &bot[0].gsObjectCoord ; // Activate view GsSetRefView2(view); } //********************************************************************************************* // InitialiseStaticView //********************************************************************************************* void InitialiseStaticView(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; //&theCar.gsObjectCoord ; // Activate view GsSetRefView2(view); } //////////////////////////////////////////////////////////////////////// // init sprite 256 /////////////////////////////////////////////////////////////////////// void InitSprite256(long ADDRESS) { RECT rect; // Define RECT structure GsIMAGE tim_data; // Define GsIMAGE structure int i; // Get the TIM file info - skip 4 bytes from start of file // to get to info we need GsGetTimInfo ((u_long *)(ADDRESS+4),&tim_data); // Load the image into the frame buffer rect.x = tim_data.px; // x pos in frame buffer rect.y = tim_data.py; // y pos in frame buffer rect.w = tim_data.pw; // width of image rect.h = tim_data.ph; // height of image LoadImage(&rect, tim_data.pixel); // load data into frame buffer // Load the CLUT into the frame buffer rect.x = tim_data.cx; // x pos in frame buffer rect.y = tim_data.cy; // y pos in frame buffer rect.w = tim_data.cw; // width of CLUT rect.h = tim_data.ch; // height of CLUT LoadImage(&rect, tim_data.clut); // load data into frame buffer for(i=0;i<4;i++) { // Initialise sprite structure power[i].attribute = 0x01000000; // sprite attribute - 8 bit power[i].x = -150; // sprite x axis position power[i].y = 60;// sprite y axis position // The width of an 8 bit sprite is half that of a 16 bit hence the *2 power[i].w = (tim_data.pw*2); // sprite width power[i].h = tim_data.ph; // sprite height power[i].tpage = GetTPage(1,0, tim_data.px, tim_data.py); power[i].u = 0; // Texture page offset x axis power[i].v = 0; // Texture page offset y axis power[i].cx = tim_data.cx; // CLUT x axis position power[i].cy = tim_data.cy; // CLUT y axis position power[i].r = 128; // Regular brightness power[i].g = 128; // Regular brightness power[i].b = 128; // Regular brightness power[i].mx = 0; // power[i].my = 0; // power[i].scalex = ONE; // Defined as 4096 power[i].scaley = ONE; // Defined as 4096 power[i].rotate = 0; // No rotation } power[0].x = -150; // sprite x axis position power[0].y = 60;// sprite y axis position power[1].x = -120; // sprite x axis position power[1].y = 60;// sprite y axis position power[2].x = -90; // sprite x axis position power[2].y = 60;// sprite y axis position power[3].x = -60; // sprite x axis position power[3].y = 60;// sprite y axis position // Wait until LoadImage() has finished before returning DrawSync(0); } ///////////////////////////////////////////////////////////////////// // process user input ///////////////////////////////////////////////////////////////////// void ProcessUserInput() { //read pad PADstatus=PadRead(); if(CHASE==0)InitialiseStaticView(&view, 250, 0, 1000,-500, 0, 0, 0, 0 ); //keep tracking if(CHASE==1)InitialiseTrackerView(&view, 250, 0, 0, -500, 1000, 0,500,-1000); //keep tracking if(CHASE==2)InitialiseTrackerView(&view, 250, 0, 0, -2500, 0, 0,0,0); if (DELAY>0) DELAY--; if (PADstatus & PADtriangle && DELAY==0) { CHASE++; if(CHASE>3)CHASE=0; DELAY=10; } if (PADstatus & PADsquare && MISSLEDRAW==0 && POWER>0) { MISSLEDRAW=1; MISSLEFUEL=200; missle.rotation=bottop.rotation; missle.gsObjectCoord.coord.t[1]=-200; missle.gsObjectCoord.coord.t[0]=bottop.gsObjectCoord.coord.t[0]; missle.gsObjectCoord.coord.t[2]=bottop.gsObjectCoord.coord.t[2]; POWER--; } ////////////////////////// if(MISSLEDRAW==1 && MISSLEFUEL>0) { MISSLEFUEL--; MoveObject(&missle.gsObjectCoord,&missle.rotation,0,0,0,-10); } else MISSLEDRAW=0; if (PADstatus & PADselect && PADstatus & PADstart) PLAYING=0; if (PADstatus & PADLright ) { MoveObject(&bot[0].gsObjectCoord,&bot[0].rotation,0,50,0,0); } if (PADstatus & PADLleft ) { MoveObject(&bot[0].gsObjectCoord,&bot[0].rotation,0,-50,0,0); } if (PADstatus & PADR1 ) { MoveObject(&bottop.gsObjectCoord,&bottop.rotation,0,50,0,0); // bottop.rotation = bot[0].rotation; } if (PADstatus & PADL1 ) { MoveObject(&bottop.gsObjectCoord,&bottop.rotation,0,-50,0,0); // bottop.rotation = bot[0].rotation; } if (PADstatus & PADLup ) { // bottop.rotation = bot[0].rotation; FRAME = (FRAME+1) % (9<<4); MoveObject(&bot[0].gsObjectCoord,&bot[0].rotation,0,0,0,-5); // MoveObject(&bottop.gsObjectCoord,&bottop.rotation,0,0,0,-5); bottop.gsObjectCoord.coord.t[0]=bot[0].gsObjectCoord.coord.t[0]; bottop.gsObjectCoord.coord.t[2]=bot[0].gsObjectCoord.coord.t[2]; bottop.gsObjectCoord.flg=0; } if (PADstatus & PADLdown ) { // bottop.rotation = bot[0].rotation; FRAME = (FRAME-1) % (9<<4); if(FRAME<0)FRAME=1000; MoveObject(&bot[0].gsObjectCoord,&bot[0].rotation,0,0,0,5); // MoveObject(&bottop.gsObjectCoord,&bottop.rotation,0,0,0,5); bottop.gsObjectCoord.coord.t[0]=bot[0].gsObjectCoord.coord.t[0]; bottop.gsObjectCoord.coord.t[2]=bot[0].gsObjectCoord.coord.t[2]; bottop.gsObjectCoord.flg=0; } if (PADstatus & PADstart) { // FntPrint ("PAD start\n"); bot[0].gsObjectCoord.coord=GsIDMATRIX; bottop.gsObjectCoord.coord=GsIDMATRIX; bottop.gsObjectCoord.coord.t[1]=-200; // theCar.speed=0; bot[0].rotation.vx=0; bot[0].rotation.vy=0; bot[0].rotation.vz=0; bottop.rotation.vx=0; bottop.rotation.vy=0; bottop.rotation.vz=0; bot[0].gsObjectCoord.flg=0; bottop.gsObjectCoord.flg=0; CHASE=0;POWER=4; // FntPrint ( "\nPAD padL1:STATIC_VIEW\n"); InitialiseStaticView(&view, 250, 0, 1000, -500, 0, 0, 0, 0 ); } } // //******************************************************************** // main //******************************************************************** int main() { int tempi; printf("got to first bit of main \n"); // set up print-to-screen font, the parameters are where the font is // loaded into the frame buffer FntLoad(960, 256); //specify where to write on the PSX screen FntOpen(-96, -96, 192, 192, 0, 512); // initialise the joypad PadInit(); // initialise graphics //title screen titlescreen(); printf("got pass title screen"); InitialiseGraphics(); // Setup view to view the car from the side InitialiseView(&view, 250, 0, 1000, -500, 0, 0, 0, 0 ); InitialiseAllLights(); // The car's initial xyz is set to 0,-200,0 // changed long* to unsigned long * // AddModelToPlayer(&theCar, 0, -200,0, (unsigned long *)F1_A); AddModelToPlayer(&bot[0], 0, 0,0, (unsigned long *)F1_A); AddModelToPlayer(&bot[1], 0, 0,0, (unsigned long *)F2_A); AddModelToPlayer(&bot[2], 0, 0,0, (unsigned long *)F3_A); AddModelToPlayer(&bot[3], 0, 0,0, (unsigned long *)F4_A); AddModelToPlayer(&bot[4], 0, 0,0, (unsigned long *)F5_A); AddModelToPlayer(&bot[5], 0, 0,0, (unsigned long *)F6_A); AddModelToPlayer(&bot[6], 0, 0,0, (unsigned long *)F7_A); AddModelToPlayer(&bot[7], 0, 0,0, (unsigned long *)F8_A); AddModelToPlayer(&bot[8], 0, 0,0, (unsigned long *)F9_A); AddModelToPlayer(&cube, 100, 0,100, (unsigned long *)CUBE_A); AddModelToPlayer(&bottop, 0, -200,0, (unsigned long *)BOTTOP_A); AddModelToPlayer(&house, -300, 0,-300, (unsigned long *)HOUSE_A); AddModelToPlayer(&missle, 0, -200,0, (unsigned long *)MISSLE_A); LoadTexture(GUN_A); LoadTexture(PAINT_A); for (tempi=1;tempi<9;tempi++) { bot[tempi].gsObjectHandler.coord2 = &bot[0].gsObjectCoord; } bottop.rotation = bot[0].rotation; InitSprite256(POWER_A); while(PLAYING) { ProcessUserInput(); RenderGAMEWorld(&bot[FRAME>>4]); // RenderWorld(&bottop); } // clean up ResetGraph(0); return 0; }