#include "ps_world.hpp" #include #define setColor(c,_r,_g,_b) (c)->r = (_r), (c)->g = (_g), (c)->b = (_b) extern unsigned long PadStatus[2]; unsigned long PLAYING = 1; long gameMode = 1; #define LF1_MEM_ADDR (0x80093000) #define RT1_MEM_ADDR (0x80093080) #define UP1_MEM_ADDR (0x80093100) #define DN1_MEM_ADDR (0x80093180) #define BM1_MEM_ADDR (0x80093200) #define TP1_MEM_ADDR (0x80093280) #define LF2_MEM_ADDR (0x80093300) #define RT2_MEM_ADDR (0x80093380) #define UP2_MEM_ADDR (0x80093400) #define DN2_MEM_ADDR (0x80093480) #define BM2_MEM_ADDR (0x80093500) #define TP2_MEM_ADDR (0x80093580) #define LF3_MEM_ADDR (0x80093600) #define RT3_MEM_ADDR (0x80093680) #define UP3_MEM_ADDR (0x80093700) #define DN3_MEM_ADDR (0x80093780) #define BM3_MEM_ADDR (0x80093800) #define TP3_MEM_ADDR (0x80093880) #define BULLET_MEM_ADDR (0x80093900) #define MARKER_MEM_ADDR (0x80093B00) #define DUUP1_MEM_ADDR (0x80094000) #define LRUP1_MEM_ADDR (0x80094108) #define RLUP1_MEM_ADDR (0x80094210) #define UDUP1_MEM_ADDR (0x80094318) #define DUUP2_MEM_ADDR (0x80094420) #define LRUP2_MEM_ADDR (0x80094528) #define RLUP2_MEM_ADDR (0x80094630) #define UDUP2_MEM_ADDR (0x80094738) #define DUUP3_MEM_ADDR (0x80094840) #define LRUP3_MEM_ADDR (0x80094948) #define RLUP3_MEM_ADDR (0x80094A50) #define UDUP3_MEM_ADDR (0x80094B58) #define CHASER_MEM_ADDR (0x80094C00) #define PLAYER_MEM_ADDR (0x80094E00) #define UNIQUEWALL1_MEM_ADDR (0x80095000) #define UNIQUEWALL2_MEM_ADDR (0x80095080) #define MAP1_ARRAY (0x800A0000) #define MAP2_ARRAY (0x800A2000) #define NAME1_IMAGE_MEM_ADDR (0x800A4000) #define NAME2_IMAGE_MEM_ADDR (0x800A6000) #define NAME3_IMAGE_MEM_ADDR (0x800A7000) #define WALL1_TEX_MEM_ADDR (0x800B0000) #define CEIL1_TEX_MEM_ADDR (0x800B1000) #define FLOO1_TEX_MEM_ADDR (0x800B2000) #define WALL2_TEX_MEM_ADDR (0x800B3000) #define CEIL2_TEX_MEM_ADDR (0x800B5000) #define FLOO2_TEX_MEM_ADDR (0x800B6000) #define WALL3_TEX_MEM_ADDR (0x800B7000) #define CEIL3_TEX_MEM_ADDR (0x800B8000) #define FLOO3_TEX_MEM_ADDR (0x800B9000) #define BULLET_TEX_MEM_ADDR (0x800BA000) #define MARKER_TEX_MEM_ADDR (0x800BA800) #define CHASER1_TEX_MEM_ADDR (0x800BB100) #define UNIQUEWALL1_TEX_MEM_ADDR (0x800BC000) #define UNIQUEWALL2_TEX_MEM_ADDR (0x800BC900) #define PLAYER_TEX_MEM_ADDR (0x800BD400) #define CHASER2_TEX_MEM_ADDR (0x800BE400) #define VHAddr (u_char *)0x800C0000 #define VBAddr (u_char *)0x800C2400 //#define BACK_IMAGE_MEM_ADDR (0x80100000) /* #define NAME1_IMAGE_MEM_ADDR (0x80120000) #define NAME2_IMAGE_MEM_ADDR (0x80122000) #define NAME3_IMAGE_MEM_ADDR (0x80123000) */ #define DEMO_IMAGE_MEM_ADDR (0x800F0000) //#define FACE_IMAGE_MEM_ADDR (0x800C0000) int globalCount; // just to help debug int gameOver = 0; //extern char worldGroundData[MAX_Z][MAX_X]; short VAB; short heartvoice; // voice used by heart beat short levelvoice; int playVsync; char playingMusic; int grandTotalTmds; 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; } void AsPSWorld::Run() { Initialise(); while(PLAYING) { PerformLoop(); } End(); } void AsPSWorld::Initialise() { // set up print-to-screen font FntLoad(960, 256); // FntOpen(-96, -96, 192, 192, 0, 512); FntOpen(-128, 96, 192, 192, 1, 512); // set up the controller pad inputHandler.PadInit(); graphicsSystem.InitialiseGraphics(); graphicsSystem.init(); /* RECT rect; rect.x = 320; rect.y = 256; rect.w = 320; rect.h = 256; MoveImage(&rect,0,0); MoveImage(&rect,0,256); DrawSync(0); VSync(0); */ // VAB = SsVabTransfer(VHAddr, VBAddr, -1, 1); // open sound stuff if (VAB < 0) { //printf("VAB open failed\n"); //exit(1); return; }// //SsUtKeyOn(VAB, 10, 0, 36, 0, 100, 100); // background noise //heartvoice = SsUtKeyOn(VAB, 0, 0, 60, 0, 0, 0); // heartbeat noise //levelvoice = SsUtKeyOn(VAB, 11, 0, 60, 0, 127, 127); playVsync = VSync(-1); playingMusic = 1; LoadTexture(WALL1_TEX_MEM_ADDR); LoadTexture(CEIL1_TEX_MEM_ADDR); LoadTexture(FLOO1_TEX_MEM_ADDR); LoadTexture(WALL2_TEX_MEM_ADDR); LoadTexture(CEIL2_TEX_MEM_ADDR); LoadTexture(FLOO2_TEX_MEM_ADDR); LoadTexture(WALL3_TEX_MEM_ADDR); LoadTexture(CEIL3_TEX_MEM_ADDR); LoadTexture(FLOO3_TEX_MEM_ADDR); LoadTexture(BULLET_TEX_MEM_ADDR); LoadTexture(MARKER_TEX_MEM_ADDR); LoadTexture(CHASER1_TEX_MEM_ADDR); LoadTexture(CHASER2_TEX_MEM_ADDR); LoadTexture(PLAYER_TEX_MEM_ADDR); LoadTexture(UNIQUEWALL1_TEX_MEM_ADDR); LoadTexture(UNIQUEWALL2_TEX_MEM_ADDR); //initialiseSprite((u_long *)FACE_IMAGE_MEM_ADDR,&demodisc); //initialiseSprite((u_long *)DEMO_IMAGE_MEM_ADDR,&demodisc); //initialiseSprite((u_long *)BACK_IMAGE_MEM_ADDR,&background); initialiseSprite((u_long *)NAME1_IMAGE_MEM_ADDR,&name1); initialiseSprite((u_long *)NAME2_IMAGE_MEM_ADDR,&name2); initialiseSprite((u_long *)NAME3_IMAGE_MEM_ADDR,&name3); demodisc.attribute &=~0x80000000; setColor(&demodisc,128,128,128); background.attribute &=~0x80000000; setColor(&background,128,128,128); name1.attribute &=~0x80000040; // turn on display and brightness control name2.attribute &=~0x80000040; // er.. is bottom bit 0 or 1? i.e. 40 works, 80 doesn't name3.attribute &=~0x80000040; demodisc.x = -160;//-50; demodisc.y = -120;//-50; background.x = -160;//-50; background.y = -128;//-50; name1.x = -128; name1.y = -100; name2.x = -64; name2.y = -40; name3.x = -128; name3.y = 32; initialSpriteTime = 0; initialSpriteCount = 0; demoSpriteTime = 0; //LoadTexture(BACK_IMAGE_MEM_ADDR); //InitialiseStaticView(&view, 250, 0, 0, -500,-1000, 0, 0, 0 ); //InitialiseAllLights(); //InitialisePlayer(&theCar, 0, -200,0, (unsigned long*)CAR_MEM_ADDR); //LoadTexture( CAR_TEX_MEM_ADDR); //arenaBuilder.ReadBinaryMap((void *)MAP1_ARRAY); InitialiseWorld(); player.initCords( ) ; //player.model( CUBE_DATA ) ; //player.position( 0, -200, 0 ) ; //player.position( 1000, -1000, -1000 ) ; player.Setposition( 1000, -1000, -1000 ) ; player.SetPosition( 1000, -1000, -1000 ) ; //player.SetPosition( 1000, -700, 1000 ) ; gameManager.SetHandlers(&player,&arenaBuilder,&chaserManager,&bulletManager,&markerManager); bulletManager.SetFeatures(&arenaBuilder,&player); markerManager.SetFeatures(&arenaBuilder,&player); chaserManager.SetFeatures(&arenaBuilder,&player); GsCOORDINATE2 *ptrCoord = &(player.gsObjectCoord); //CCord center(0,-300,-1500); CCord center(0,0,400); // CCord look(0, -700, 3000 ); CCord look(0, 0, 0 ); viewer.projection(center); viewer.reference(look); viewer.distance(150);//280 viewer.twist(0); viewer.parent(ptrCoord); timeBox.x = 50; timeBox.y = 50; timeBox.w = 50; timeBox.h = 20; setColor(&timeBox,128,128,128); //timeBox.r = 2000; //timeBox.g = 2000; //timeBox.b = 1500; //timeBox.attribute &=~0x80000000; timeBox.attribute = 0;//&=~0xC0000000; oldStage = -1; } //void AsPSWorld::AddModelToWorld(WorldStructType0 *theWorld, int nX, int nY, int nZ, void AsPSWorld::AddModelToWorld(int nX, int nY, int nZ, // unsigned long *lModelAddress,int z, int x) unsigned long lModelAddress,int z, int x) { //* objects[totalObjects].model(lModelAddress); objects[totalObjects].initCords( ); objects[totalObjects].position( nX, nY, nZ) ; //graphicsSystem+= &objects[totalObjects]; totalObjects++; // // add it to the world /* theWorld->lObjectPointer[z][x] = (unsigned long*)lModelAddress; //increment the pointer to move past the model id. (weird huh?) theWorld->lObjectPointer[z][x]++; // map tmd data to its actual address GsMapModelingData(theWorld->lObjectPointer[z][x]); // initialise the objects coordinate system - set to be that of the WORLD GsInitCoordinate2(WORLD, &theWorld->gsObjectCoord[z][x]); // increment pointer twice more - to point to top of model data (beats me!) theWorld->lObjectPointer[z][x]++; theWorld->lObjectPointer[z][x]++; // link the model (tmd) with the players object handler GsLinkObject4((unsigned long)theWorld->lObjectPointer[z][x], &theWorld->gsObjectHandler[z][x], 0); // set the amount of polygon subdivision that will be done at runtime (none!) theWorld->gsObjectHandler[z][x].attribute = GsDIV1; // Assign the coordinates of the object model to the Object Handler theWorld->gsObjectHandler[z][x].coord2 = &theWorld->gsObjectCoord[z][x]; // Set The Position of the Object theWorld->gsObjectCoord[z][x].coord.t[0]=nX; // X theWorld->gsObjectCoord[z][x].coord.t[1]=nY; // Y theWorld->gsObjectCoord[z][x].coord.t[2]=nZ; // Z // Increment the object counter //theWorld->nTotalModels++; // flag the object as needing to be drawn theWorld->gsObjectCoord[z][x].flg = 0; //*/ } void AsPSWorld::initialiseSprite(u_long *timAddr, GsSPRITE *sprite) { GsIMAGE image; RECT t,c; GsGetTimInfo(++timAddr,&image); setRECT(&t,image.px,image.py,image.pw,image.ph); LoadImage(&t,image.pixel); DrawSync(0); // load CLUT as necessary if (image.pmode & 8) { setRECT(&c,image.cx,image.cy,image.cw,image.ch); LoadImage(&c,image.clut); DrawSync(0); } sprite->attribute = 0x08000000; // basic has rotation off - bit 27 sprite->attribute |= (image.pmode & 3) << 24; sprite->w = image.pw << (2 - (image.pmode & 3)); sprite->h = image.ph; sprite->u = image.px & 31; sprite->v = image.py & 511; sprite->cx = image.cx; sprite->cy = image.cy; setColor(sprite,128,128,128); //setColor(sprite,0,0,0); sprite->tpage = (image.px >> 6) + (image.py >> 10); } // load up from conventional memeory into video memory int AsPSWorld::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); DrawSync(0); // 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); } // DrawSync(0); return(0); } void AsPSWorld::InitialiseWorld () { /* int tmpx,tmpz; char c; int roomsToCreate; // The bits are used to indicate which rooms to create int level, row, column; int baseX, baseY, baseZ; AsMapArrayElement *mapArray; unsigned long tmdPointer; */ totalObjects = 0; //initialise total number of models to zero //theWorld.nTotalModels=0; // load up the square1 texture to video memeory //LoadTexture(SQUARE1_TEX_MEM_ADDR); //LoadTexture(BM_TEX_MEM_ADDR); /* LoadTexture(DN_TEX_MEM_ADDR); LoadTexture(TP_TEX_MEM_ADDR); */ // then for each element of the worldGroundData array if we find a 1 // then place an instance of square1.tmd at the appropriate position // in the world. /* for (tmpz = 0; tmpz < MAX_Z; tmpz++ ){ for (tmpx = 0; tmpx < MAX_X; tmpx++ ){ theWorld.lObjectPointer[tmpz][tmpx]=0; c= worldGroundData[tmpz][tmpx]; if(c == '1') { AddModelToWorld(&theWorld, (tmpz * SEPERATION),(0), // (tmpx * SEPERATION), (unsigned long *)SQUARE1_MEM_ADDR,tmpz,tmpx); (tmpx * SEPERATION), SQUARE1_MEM_ADDR,tmpz,tmpx); } //end if } //end for tmpx } //end for tmpz */ /* for (int r = 0; r < AS_MAX_REPLICATE; r++)//AS_MAX_REPLICATE { // int panelCount; for (level = 0; level < AS_MAP_LEVELS; level++) //for (level = 0; level < 1; level++) { //baseY = AS_MAP_ROOM_LENGTH * level; for (row = 0; row < AS_MAP_ROWS; row++) //for (row = 0; row < 1; row++) { //baseX = AS_MAP_ROOM_LENGTH * row; for (column = 0; column < AS_MAP_COLUMNS; column++) //for (column = 0; column < 1; column++) { //baseZ = AS_MAP_ROOM_LENGTH * column; // not panel count for psx, really the tmd count - some have > 1 panel arenaBuilder.panelCount[level][row][column] = 0; mapArray = arenaBuilder.GetMapArray(level,row,column); if (!mapArray->isRoom) continue; // no room so nothing to add roomsToCreate = arenaBuilder.GetRooms2(level,row,column);//0; for (int bitcount = 0; bitcount < 14; bitcount++) { int roomMask = 1 << bitcount; if (roomsToCreate & roomMask) // we must add this panel to the object { // set panel type, which is bitcount - for panels [0 .. (arenaBuilder.panelCount - 1)] panelCount = arenaBuilder.panelCount[level][row][column]; panelTypes[level][row][column][panelCount] = bitcount; arenaBuilder.panelCount[level][row][column]++; switch(bitcount) { case 0: tmdPointer = UP1_MEM_ADDR; break; // up case 1: tmdPointer = DN1_MEM_ADDR; break; // down case 2: tmdPointer = LF1_MEM_ADDR; break; // left case 3: tmdPointer = RT1_MEM_ADDR; break; // right case 4: tmdPointer = TP1_MEM_ADDR; break; // top case 5: tmdPointer = BM1_MEM_ADDR; break; // bottom case 6: tmdPointer = UDUP1_MEM_ADDR; break; // up to down, facing up case 7: tmdPointer = RLUP1_MEM_ADDR; break; // right to left, facing up case 8: tmdPointer = DUUP1_MEM_ADDR; break; // down to up, facing up case 9: tmdPointer = LRUP1_MEM_ADDR; break; // left to right, facing up //default: globalError = 1;// error } //AddModelToWorld(&theWorld, baseX,0,//-baseY, // -baseZ, tmdPointer,tmpz,tmpx); AddModelToWorld(0,0,//-baseY, -0, tmdPointer,tmpz,tmpx); } } } } } } // r */ // AddModelToWorld(0,0,0, UP1_MEM_ADDR,0,0); AddModelToWorld(0,0,0, DN1_MEM_ADDR,0,0); AddModelToWorld(0,0,0, LF1_MEM_ADDR,0,0); AddModelToWorld(0,0,0, RT1_MEM_ADDR,0,0); AddModelToWorld(0,0,0, TP1_MEM_ADDR,0,0); AddModelToWorld(0,0,0, BM1_MEM_ADDR,0,0); AddModelToWorld(0,0,0, UDUP1_MEM_ADDR,0,0); AddModelToWorld(0,0,0, RLUP1_MEM_ADDR,0,0); AddModelToWorld(0,0,0, DUUP1_MEM_ADDR,0,0); AddModelToWorld(0,0,0, LRUP1_MEM_ADDR,0,0); AddModelToWorld(0,0,0, UP2_MEM_ADDR,0,0); AddModelToWorld(0,0,0, DN2_MEM_ADDR,0,0); AddModelToWorld(0,0,0, LF2_MEM_ADDR,0,0); AddModelToWorld(0,0,0, RT2_MEM_ADDR,0,0); AddModelToWorld(0,0,0, TP2_MEM_ADDR,0,0); AddModelToWorld(0,0,0, BM2_MEM_ADDR,0,0); AddModelToWorld(0,0,0, UDUP2_MEM_ADDR,0,0); AddModelToWorld(0,0,0, RLUP2_MEM_ADDR,0,0); AddModelToWorld(0,0,0, DUUP2_MEM_ADDR,0,0); AddModelToWorld(0,0,0, LRUP2_MEM_ADDR,0,0); AddModelToWorld(0,0,0, UP3_MEM_ADDR,0,0); AddModelToWorld(0,0,0, DN3_MEM_ADDR,0,0); AddModelToWorld(0,0,0, LF3_MEM_ADDR,0,0); AddModelToWorld(0,0,0, RT3_MEM_ADDR,0,0); AddModelToWorld(0,0,0, TP3_MEM_ADDR,0,0); AddModelToWorld(0,0,0, BM3_MEM_ADDR,0,0); AddModelToWorld(0,0,0, UDUP3_MEM_ADDR,0,0); AddModelToWorld(0,0,0, RLUP3_MEM_ADDR,0,0); AddModelToWorld(0,0,0, DUUP3_MEM_ADDR,0,0); AddModelToWorld(0,0,0, LRUP3_MEM_ADDR,0,0); // //for (int i = 0; i < AS_MAX_BULLETS; i++) //{ AddModelToWorld(0,0,0, BULLET_MEM_ADDR,0,0); AddModelToWorld(0,0,0, MARKER_MEM_ADDR,0,0); AddModelToWorld(0,0,0, CHASER_MEM_ADDR,0,0); AddModelToWorld(0,0,0, PLAYER_MEM_ADDR,0,0); AddModelToWorld(0,0,0, UNIQUEWALL1_MEM_ADDR,0,0); AddModelToWorld(0,0,0, UNIQUEWALL2_MEM_ADDR,0,0); //} } void AsPSWorld::CreateCurrentMap () { int tmpx,tmpz; char c; int roomsToCreate; // The bits are used to indicate which rooms to create int level, row, column; int baseX, baseY, baseZ; AsMapArrayElement *mapArray; unsigned long tmdPointer; int panelCount; switch(gameManager.mapNumber) { case 0: arenaBuilder.ReadBinaryMap((void *)MAP1_ARRAY,0); break; case 1: arenaBuilder.ReadBinaryMap((void *)MAP2_ARRAY,1); break; } //for (level = 0; level < AS_MAP_LEVELS; level++) for (level = 0; level < arenaBuilder.levelsInMap[gameManager.mapNumber]; level++) //for (level = 0; level < 1; level++) { //baseY = AS_MAP_ROOM_LENGTH * level; for (row = 0; row < AS_MAP_ROWS; row++) //for (row = 0; row < 1; row++) { //baseX = AS_MAP_ROOM_LENGTH * row; for (column = 0; column < AS_MAP_COLUMNS; column++) //for (column = 0; column < 1; column++) { //baseZ = AS_MAP_ROOM_LENGTH * column; // not panel count for psx, really the tmd count - some have > 1 panel arenaBuilder.panelCount[level][row][column] = 0; mapArray = arenaBuilder.GetMapArray(level,row,column); if (!mapArray->isRoom) continue; // no room so nothing to add roomsToCreate = arenaBuilder.GetRooms2(level,row,column);//0; for (int bitcount = 0; bitcount < 14; bitcount++) { int roomMask = 1 << bitcount; if (roomsToCreate & roomMask) // we must add this panel to the object { // set panel type, which is bitcount - for panels [0 .. (arenaBuilder.panelCount - 1)] panelCount = arenaBuilder.panelCount[level][row][column]; panelTypes[level][row][column][panelCount] = bitcount + (10 * (mapArray->isRoom - 1)); // specials switch(gameManager.mapNumber) { case 0: // easy { if ((level == 0) && (row == 0) && (column == 9) && (bitcount == 0)) panelTypes[level][row][column][panelCount] = 34; if ((level == 0) && (row == 0) && (column == 0) && (bitcount == 2)) panelTypes[level][row][column][panelCount] = 35; break; } case 1: // hard { if ((level == 1) && (row == 0) && (column == 4) && (bitcount == 0)) panelTypes[level][row][column][panelCount] = 34; if ((level == 0) && (row == 6) && (column == 0) && (bitcount == 2)) panelTypes[level][row][column][panelCount] = 35; break; } } arenaBuilder.panelCount[level][row][column]++; } } } } } } void AsPSWorld::UpdateVisualMap (int rep) { int level, row, column; int shown, count; int rotation; unsigned int panelCount; AsMapArrayElement *mapArray; panelCount = 0; //int obj = 0; //int startObj; int tmd,totaltmds; int x,y,z; int i,r; MATRIX *co; MATRIX rotationMatrix; int panelType; SVECTOR rotationVector; SVECTOR inputVector; VECTOR outputVector; GsOT *ot = graphicsSystem.GetOT(); //for (int i = 0; i < 400; i++) // graphicsSystem.init(); AsChaser *chaser; int chaserSubX,chaserSubZ; //obj = 0; // *** CHASERS *** for (i = 0; i < chaserManager.numberOfChasers; i++) { chaser = chaserManager.GetChaser(i); level = chaser->yRoom; row = chaser->xRoom; column = chaser->zRoom; for (r = 0; r < AS_MAX_REPLICATE; r++)//AS_MAX_REPLICATE { if (arenaBuilder.visualMap[r][level][row][column]) { x = arenaBuilder.visualX[r][level][row][column]; y = -arenaBuilder.visualY[r][level][row][column]; z = -arenaBuilder.visualZ[r][level][row][column]; chaserSubX = chaser->X; chaserSubZ = chaser->Z; rotation = arenaBuilder.visualRotation[r][level][row][column]; if (rotation) { ResetMatrix(rotationMatrix.m); RotMatrixY(rotation,&rotationMatrix); inputVector.vx = chaser->X - 1000; inputVector.vz = chaser->Z - 1000; ApplyMatrix(&rotationMatrix,&inputVector,&outputVector); chaserSubX = outputVector.vx + 1000;// + 0.5; chaserSubZ = outputVector.vz + 1000;// + 0.5; } objects[32].ResetRotation( ); //objects[32].rotate(chaser->aroundX,chaser->aroundY + rotation,chaser->aroundZ); objects[32].rotate(chaser->aroundX,chaser->aroundY,chaser->aroundZ); objects[32].Setposition(x+chaserSubX,y-chaser->Y,z-chaserSubZ); objects[32].gsObjectHandler.attribute &=~ GsDIV3; objects[33].gsObjectHandler.attribute |= GsDIV1; objects[32].draw(*ot); }//if visualMap else break; //obj++; }// r }//i // *** PLAYER *** int playerSubX,playerSubZ; // player coords in PSX axes i.e. y and z already negative level = player.yRoom; row = player.xRoom; column = player.zRoom; for (r = 0; r < AS_MAX_REPLICATE; r++)//AS_MAX_REPLICATE { if (arenaBuilder.visualMap[r][level][row][column]) { x = arenaBuilder.visualX[r][level][row][column]; y = -arenaBuilder.visualY[r][level][row][column]; z = -arenaBuilder.visualZ[r][level][row][column]; playerSubX = player.X; playerSubZ = player.Z; rotation = arenaBuilder.visualRotation[r][level][row][column]; if (rotation) { ResetMatrix(rotationMatrix.m); RotMatrixY(-rotation,&rotationMatrix); inputVector.vx = player.X - 1000; inputVector.vz = player.Z + 1000; ApplyMatrix(&rotationMatrix,&inputVector,&outputVector); playerSubX = outputVector.vx + 1000;// + 0.5; playerSubZ = outputVector.vz - 1000;// + 0.5; } objects[33].ResetRotation( ); objects[33].rotate(0,player.aroundY,0); objects[33].Setposition(x+playerSubX,y+player.Y,z+playerSubZ); objects[33].gsObjectHandler.attribute &=~ GsDIV3; //objects[33].gsObjectHandler.attribute |= GsDIV1; objects[33].draw(*ot); }//if visualMap else break; }//r // *** BULLET *** AsBullet *bullet; int bulletsSubX,bulletsSubZ; for (i = 0; i < AS_MAX_BULLETS; i++) { // if ((i % 5) == 0) // { bullet = bulletManager.GetBullet(i); if (bullet->Active()) { level = bullet->yRoom; row = bullet->xRoom; column = bullet->zRoom; for (r = 0; r < AS_MAX_REPLICATE; r++)//AS_MAX_REPLICATE { if (arenaBuilder.visualMap[r][level][row][column]) { x = arenaBuilder.visualX[r][level][row][column]; y = -arenaBuilder.visualY[r][level][row][column]; z = -arenaBuilder.visualZ[r][level][row][column]; bulletsSubX = bullet->X; bulletsSubZ = bullet->Z; rotation = arenaBuilder.visualRotation[r][level][row][column]; if (rotation) { ResetMatrix(rotationMatrix.m); RotMatrixY(rotation,&rotationMatrix); inputVector.vx = bullet->X - 1000; inputVector.vz = bullet->Z - 1000; ApplyMatrix(&rotationMatrix,&inputVector,&outputVector); bulletsSubX = outputVector.vx + 1000;// + 0.5; bulletsSubZ = outputVector.vz + 1000;// + 0.5; } objects[30].Setposition(x+bulletsSubX,y-bullet->Y,z-bulletsSubZ); objects[30].gsObjectHandler.attribute &=~ GsDIV3; objects[30].draw(*ot); }//if visualMap else break; }//r }//if active // }// if % }// i // *** MARKERS *** AsMarker *marker; int markerSubX, markerSubZ; // obj = 0; for (i = 0; i < AS_MAX_MARKERS; i++) { //if ((i % 5) == 0) // { marker = markerManager.GetMarker(i); if (marker->active) { level = marker->yRoom; row = marker->xRoom; column = marker->zRoom; for (r = 0; r < AS_MAX_REPLICATE; r++)//AS_MAX_REPLICATE { if (arenaBuilder.visualMap[r][level][row][column]) { x = arenaBuilder.visualX[r][level][row][column]; y = -arenaBuilder.visualY[r][level][row][column]; z = -arenaBuilder.visualZ[r][level][row][column]; markerSubX = marker->X; markerSubZ = marker->Z; rotation = arenaBuilder.visualRotation[r][level][row][column]; if (rotation) { ResetMatrix(rotationMatrix.m); RotMatrixY(rotation,&rotationMatrix); inputVector.vx = marker->X - 1000; inputVector.vz = marker->Z - 1000; ApplyMatrix(&rotationMatrix,&inputVector,&outputVector); markerSubX = outputVector.vx + 1000;// + 0.5; markerSubZ = outputVector.vz + 1000;// + 0.5; } objects[31].Setposition(x+markerSubX,y-marker->Y,z-markerSubZ); objects[30].gsObjectHandler.attribute &=~ GsDIV3; objects[31].draw(*ot); }//if visualMap else break; //obj++; }//r }//if active //}// if % }// i // *** AREA *** grandTotalTmds = 0; /* for (level = 0; level < AS_MAP_LEVELS; level++) { for (row = 0; row < AS_MAP_ROWS; row++) { for (column = 0; column < AS_MAP_COLUMNS; column++) { for (r = 0; r < AS_MAX_REPLICATE; r++)//AS_MAX_REPLICATE { if (arenaBuilder.visualMap[r][level][row][column]) { */ int poly; for (int vb = 0; vb < arenaBuilder.visibleBlocks; vb++) { level = arenaBuilder.visibleBlock[vb].level; row = arenaBuilder.visibleBlock[vb].row; column = arenaBuilder.visibleBlock[vb].column; r = arenaBuilder.visibleBlock[vb].replicate; r = r & 0x0000000F; // mask out polygon info poly = arenaBuilder.visibleBlock[vb].replicate >> 4; x = arenaBuilder.visualX[r][level][row][column]; y = -arenaBuilder.visualY[r][level][row][column]; z = -arenaBuilder.visualZ[r][level][row][column]; totaltmds = arenaBuilder.panelCount[level][row][column]; for (tmd = 0; tmd < totaltmds; tmd++) { panelType = panelTypes[level][row][column][tmd]; //co = &objects[panelType].gsObjectCoord.coord; rotation = arenaBuilder.visualRotation[r][level][row][column]; if (rotation) { RotMatrixY(-rotation,&objects[panelType].gsObjectCoord.coord); } objects[panelType].Setposition(x+1000,y-1000,z-1000); objects[panelType].gsObjectHandler.attribute &=~ GsDIV3; switch(poly) { case 2: objects[panelType].gsObjectHandler.attribute |= GsDIV3; break; //case 1: objects[panelType].gsObjectHandler.attribute |= GsDIV2; break; default: objects[panelType].gsObjectHandler.attribute |= GsDIV2; break; } objects[panelType].draw(*ot); if (rotation) // rotate object back to original position { RotMatrixY(rotation,&objects[panelType].gsObjectCoord.coord); } } // tmd grandTotalTmds+=totaltmds; // reset those drawn - but must be performed after drawing everything else //arenaBuilder.visualMap[r][level][row][column] = 0; }// vb /* } // if visualMap } // r } // column } // row } // level */ } void AsPSWorld::End() { SsUtAllKeyOff(0); // switch off sounds SsVabClose(VAB); // close sound // clean up //ResetGraph(0); } void AsPSWorld::DisplayTime(int time) { int fiftieths, hundredths, secs, mins; fiftieths = time % 50; hundredths = fiftieths * 2; secs = (time - fiftieths) / 50; mins = (secs - (secs % 60)) / 60; FntPrint("%d:%d.%d\n",mins,secs % 60,hundredths); } void AsPSWorld::PerformLoop() { int buffer; RECT rect; inputHandler.GetInput(); // ProcessUserInput(); AsBullet *bullet; AsChaser *chaser; char message[30]; /* for (int i = 0; i < AS_MAX_BULLETS; i++) { bullet = bulletManager.GetBullet(i); bullet->SetPosition(bullets[i].gsObjectCoord.coord.t[0],bullets[i].gsObjectCoord.coord.t[1],bullets[i].gsObjectCoord.coord.t[2]); } */ GsOT *ot = graphicsSystem.GetOT(); //arenaBuilder.CalculateVisualMap(player.xRoom, player.yRoom, player.zRoom,player.aroundY,0); int oldGameMode = gameMode; gameManager.UpdateGameState(); if (oldGameMode < gameMode) { if (gameMode == 3) CreateCurrentMap (); } // if (currentTime > 250) // SsUtKeyOff(levelvoice, VAB, 11, 0, 60); // gameMode = 2; graphicsSystem.Render1(&viewer); switch (gameMode) { case 0: // Demo disc screen { if (demoSpriteTime > 500) gameMode++; demoSpriteTime++; buffer = graphicsSystem.GetCurrentBuffer(); rect.x = 320; rect.y = 0; rect.w = 320; rect.h = 240; //DrawSync(0); /* FntPrint("XXX\nXXX\nXXX\nXXX\nXXX\n"); FntPrint("XXX\nXXX\nXXX\nXXX\nXXX\n"); FntPrint("XXX\nXXX\nXXX\nXXX\nXXX\n"); FntPrint("XXX\nXXX\nXXX\nXXX\nXXX\n"); FntPrint("XXX\nXXX\nXXX\nXXX\nXXX\n"); FntPrint("XXX\nXXX\nXXX\nXXX\nXXX\n"); FntPrint("\nFastest Time: "); */ MoveImage(&rect,0,0 + (buffer * 256)); DrawSync(0); VSync(0); GsSwapDispBuff(); //GsSortFastSprite(&demodisc,ot,0); break; } case 1: // Intro screen { //gameMode++; //break; demoSpriteTime = 0; if (initialSpriteTime > 1000) gameMode++; if (initialSpriteTime == 0 ) { setColor(&name1,0,0,0); setColor(&name2,0,0,0); setColor(&name3,0,0,0); } initialSpriteTime += 1; // fiftieths of sec int timeOfCurrent = initialSpriteTime - (initialSpriteCount * 200); // 4 secs int colourTime = timeOfCurrent / 2; switch(initialSpriteCount) { case 0:setColor(&name1,colourTime,colourTime,colourTime);break; case 1:setColor(&name2,colourTime,colourTime,colourTime);break; case 2:setColor(&name3,colourTime,colourTime,colourTime);break; default:; // no need to set anything } if (timeOfCurrent == 200) initialSpriteCount++; GsSortFastSprite(&name1,ot,0); GsSortFastSprite(&name2,ot,0); GsSortFastSprite(&name3,ot,0); break; } case 2: // Main menu { setColor(&name1,128,128,128); setColor(&name2,128,128,128); setColor(&name3,128,128,128); GsSortFastSprite(&name1,ot,0); GsSortFastSprite(&name3,ot,0); FntPrint("\n\n\n\n\n"); FntPrint("\nFastest Time: "); if (gameManager.fastestTimeSet[gameManager.mapNumber]) DisplayTime(gameManager.fastestTime[gameManager.mapNumber]); else FntPrint("-:--.--\n"); FntPrint("\n\nSlowest Time: "); if (gameManager.slowestTimeSet[gameManager.mapNumber]) DisplayTime(gameManager.slowestTime[gameManager.mapNumber]); else FntPrint("-:--.--\n"); FntPrint("\n\nLongest Time: "); if (gameManager.longestTimeSet[gameManager.mapNumber]) DisplayTime(gameManager.longestTime[gameManager.mapNumber]); else FntPrint("-:--.--\n"); FntPrint("\n\n\tPress Start\n"); FntPrint("\n\n\n\n\n"); if (gameManager.mapNumber == 0) FntPrint(">"); else FntPrint(" "); FntPrint("Easy\t\t\t"); if (gameManager.mapNumber == 1) FntPrint(">"); else FntPrint(" "); FntPrint("Hard\n"); FntFlush(-1); //GsSortFastSprite(&background,ot,0); break; } case 3: // Game { //if ( PadStatus[AS_PLAYER_ONE] & PADR1 ) //objects[0].position( 50,0,0); //if ( PadStatus[AS_PLAYER_ONE] & PADR2 ) //objects[0].position(-50,0,0); /* FntPrint("X %d\n",player.gsObjectCoord.coord.t[0]); FntPrint("Y %d\n",player.gsObjectCoord.coord.t[1]); FntPrint("Z %d\n",player.gsObjectCoord.coord.t[2]); FntPrint("Y %d\n",player.yRoom); FntPrint("X %d\n",player.xRoom); FntPrint("Z %d\n",player.zRoom); */ arenaBuilder.CalculateVisualMap(player.xRoom, player.yRoom, player.zRoom,player.aroundY,0); UpdateVisualMap (0);//r); /* for (int r = 0; r < AS_MAX_REPLICATE; r++)//AS_MAX_REPLICATE { UpdateVisualMap (0);//r); }*/ //graphicsSystem.DrawList(); //GsSortBoxFill(&timeBox,ot,0); FntPrint("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "); if (oldStage != gameManager.stage) { oldTime = gameManager.currentTime; oldStage = gameManager.stage; } if ((gameManager.currentTime - oldTime) < 150) { switch(gameManager.stage) { case 0: strncpy(message,"Find room with symbol",30); break; case 1: strncpy(message,"Achieved Objective. Exit!",30); break; } FntPrint("%s ",message); } else { FntPrint("\t\t\t\t "); DisplayTime(gameManager.currentTime); } //chaser = chaserManager.GetChaser(0); //FntPrint("\n%d\n",chaser->yRoom); //FntPrint("%d\n",chaser->xRoom); //FntPrint("%d\n",chaser->zRoom); //FntPrint("\n%d\n",chaserManager.numberOfChasers); //FntPrint("%d\n",gameManager.stage); //FntPrint("%d\n",grandTotalTmds); FntFlush(-1); //GsSortFastSprite(&name3,ot,0); // graphicsSystem.Render(&theWorld,&viewer); // graphicsSystem.Render(&viewer); // RenderWorld(&theCar,&theWorld); break; } case 4: // End Screen { /* buffer = graphicsSystem.GetCurrentBuffer(); rect.x = 320; rect.y = 256; rect.w = 320; rect.h = 256; MoveImage(&rect,0,0 + (buffer * 256)); DrawSync(0); VSync(0); GsSwapDispBuff(); */ //GsSortFastSprite(&background,ot,0); // GsSortFastSprite(&name1,ot,0); GsSortFastSprite(&name3,ot,0); FntPrint("\n\n\n\n\n\n"); switch(gameManager.stage) { case 0:FntPrint("Mission Failed\n"); break; case 1:FntPrint("Achieved objective, but\n"); break; case 2:FntPrint("Completed Mission\n"); break; } FntPrint("\n"); switch(gameManager.gameOutcome) { case 0: break; case 1:FntPrint("Killed by guard\n"); break; case 2:FntPrint("Shot yourself\n"); break; case 3:FntPrint("Aborted mission\n"); break; } FntPrint("\n\n\tTime: "); DisplayTime(gameManager.currentTime); if (gameManager.newTimes) { if (gameManager.newTimes & 1) { FntPrint("\nNew fastest time: "); DisplayTime(gameManager.fastestTime[gameManager.mapNumber]); } if (gameManager.newTimes & 2) { FntPrint("\nNew slowest time: "); DisplayTime(gameManager.slowestTime[gameManager.mapNumber]); } if (gameManager.newTimes & 4) { FntPrint("\nNew longest time: "); DisplayTime(gameManager.longestTime[gameManager.mapNumber]); } } FntFlush(-1); initialSpriteTime = 0;// temporary while I allow screen to be seen twice initialSpriteCount = 0; // break; } } //if ((gameMode != 0) && (gameMode != 4)) graphicsSystem.Render2(); if ((gameMode != 0)) graphicsSystem.Render2(); }