/******************************************** * * * TRACK N' NO FIELD * * =================== * * * * Written by Steven Lewis * * * * Downloaded from: * * http://www.netyaroze-europe.com/~slewis/ * * * * -- UNFINISHED VERSION -- * * Version Number: 0.6 * * Version Date: 07/01/00 * * * ********************************************/ // ---------------- // HEADER FILES // ---------------- #include // Loads the standard PlayStation library functions #include // Loads the joypad reading functions // ----------------- // DEFINITIONS // ----------------- #define SCREEN_WIDTH (320) // Width of the display screen #define SCREEN_HEIGHT (256) // Height of the display screen #define SPRITE_COUNT (2) // Number of sprites on screen at one time // ------------ TIM FILE ADDRESSES -------------------- #define SPRITE_ADDRESS1 (0x800a2000) // Memory address of the player sprites TIM file #define SPRITE_ADDRESS2 (0x800ae000) // Memory address of the general graphics TIM file #define BG_ADDRESS1 (0x800bd000) // Memory address of background image 1 #define BG_ADDRESS2 (0x800d2000) // Memory address of background image 2 #define BG_ADDRESS3 (0x800e6000) // Memory address of background image 3 #define BG_ADDRESS4 (0x800fb000) // Memory address of background image 4 #define SPRITE_ADDRESS3 (0x80110000) // Memory address of the second general graphics file #define SPRITE_ADDRESS4 (0x8011f000) // Memory address of the third general graphics file. This contains the 4 bit images // ---------------------------------------------------- #define BG_IMAGES (4) // Sets the number of background images #define TOTAL_IMAGES (25) // Sets the total number of images #define PLAYERS (8) // Sets the number of on-screen players #define RACE_LENGTH (1760) // Sets the length of the race #define SPRITE1_HEIGHT (77) // Sets the height of sprite one (player 1) #define SPRITE2_HEIGHT (64) // Sets the height of sprite two (computer characters) // Initial sprite screen positions #define SCREEN_POSITION_X_P1 (63) // Start screen position of player 1 - x axis - lane 3 #define SCREEN_POSITION_Y_P1 (107) // Start screen position of player 1 - y axis #define SCREEN_POSITION_X_C1 (54) // Screen position of Computer Player - lane 4 #define SCREEN_POSITION_Y_C1 (132) #define SCREEN_POSITION_X_C2 (45) // Screen position of the 2nd Computer player - lane 5 #define SCREEN_POSITION_Y_C2 (145) #define SCREEN_POSITION_X_C3 (28) // Screen position of 3rd comp opponent - lane 7 #define SCREEN_POSITION_Y_C3 (170) #define SCREEN_POSITION_X_C4 (20) // Screen position of 4th comp opponent - lane 8 #define SCREEN_POSITION_Y_C4 (183) #define SCREEN_POSITION_X_C5 (81) // Screen position of 5th comp player - lane 1 #define SCREEN_POSITION_Y_C5 (100) #define SCREEN_POSITION_X_C6 (72) // Screen position of 6th computer player - lane 2 #define SCREEN_POSITION_Y_C6 (110) #define SCREEN_POSITION_X_C7 (36) // Screen position of 7th computer player - lane 6 #define SCREEN_POSITION_Y_C7 (158) #define INITIAL_ANIM_FRAME (128) // Sets the initial animation frames for each sprite // In-game screen display #define PLAYERBAR1_XPOS (3) // Sets the x axis screen position of the player 1 display bar #define PLAYERBAR1_YPOS (0) // Sets the y axis screen position of the player 1 display bar #define PLAYERBAR_HEIGHT (20) // Sets the height of the first part of the information display bar so the second part can be correctly positioned #define PLAYERBAR1_WIDTH (38*2) // Sets the width of the first part of the player infomation display - *2 as it is an 8-bit sprite #define PLAYERBAR_WIDTH (79) // Sets the width of each individual screen display graphic within the playerbar TIM file #define PLAYERBAR2_WIDTH (42*2) // Width of the player 2 information display bar #define PLAYERBAR3_WIDTH (39*2) // Width of the player 3 info display bar #define PLAYERBAR4_WIDTH (38*2) // Width of the fianl part of the info display bar #define TIMEBAR_X (230) // Sets the x axis coordinate for the 'game time' display #define TIMEBAR_Y (210) // Sets the y axis coordinate for the 'game time' display #define TIMEBAR_WIDTH (82) // The width of the time bar image // Title screen definitions #define TITLE_TIM_X_POSITION (0) // u texture page address for the main title screen image #define TITLE_TIM_Y_POSITION (41) // v texture page address for the main title screen image (40=20*2) #define TITLE_TIM_WIDTH (216) // Width of the title TIM image #define TITLE_TIM_HEIGHT (100) // Height of the title TIM image #define TITLE_POSITIONX (160) // x axis position of the main title screen image (320/2) #define TITLE_POSITIONY (70) // y axis position of the main title screen image #define START_TIM_WIDTH (100) // Width of the main 'press start' image #define START_TIM_HEIGHT (20) // Height of the 'press start' image #define START_TIM_X_POSITION (0) // u texture page address of 'press start' image #define START_TIM_Y_POSITION (10) // v texture page address #define START_X_VALUE (105) // Screen position of 'press start' image - x axis #define START_Y_VALUE (170) // Screen position of 'press start' image - y axis #define GRASS_WIDTH (240) // Sets the width of the grass image that appears on the title screen #define GRASS_HEIGHT (10) // Height of the grass image #define GRASS_U_POSITION (0) // u texture page position of the grass image #define GRASS_V_POSITION (0) // v texture page position #define GRASS_SCREEN_POSITION_X (42) // x axis screen position of the grass #define GRASS_SCREEN_POSITION_Y (240) // y axis screen position // Initial race countdown definitions #define THREE_WIDTH (40) // Details of the '3' image used when starting a race #define THREE_HEIGHT (45) #define TWO_WIDTH (50) // Details of the '2' image #define TWO_HEIGHT (45) #define ONE_WIDTH (30) // Details of the '1' image #define ONE_HEIGHT (45) #define GO_WIDTH (90) // Details of the 'GO!' image #define GO_HEIGHT (45) #define NUMBER_SCREEN_POSITION_X (160) // Screen position of the race countdown #define NUMBER_SCREEN_POSITION_Y (100) #define THREE_TEXTURE_POSITION_X (0) // Texture page position of the '3' image #define THREE_TEXTURE_POSITION_Y (142) #define TWO_TEXTURE_POSITION_X (40) // Texture page position of the '2' image #define TWO_TEXTURE_POSITION_Y (142) #define ONE_TEXTURE_POSITION_X (90) // Texture page position of the '1' image #define ONE_TEXTURE_POSITION_Y (142) #define GO_TEXTURE_POSITION_X (120) // Texture page position of the 'GO!' image #define GO_TEXTURE_POSITION_Y (142) #define GO_SCREEN_POSITION_X (120) // Screen position of the 'GO!' image #define GO_SCREEN_POSITION_Y (80) #define INIT_X_SCALE_VALUE (4096) // Initial x axis scale size of the countdown number images #define INIT_Y_SCALE_VALUE (4096) // Initial y axis scale value of countdown number images #define RACE_COUNTDOWN_THREE (3) // Finite state machine values for use in the main race countdown #define RACE_COUNTDOWN_TWO (2) #define RACE_COUNTDOWN_ONE (1) #define RACE_COUNTDOWN_1P (1) // State values for the race countdown - This is the 1 player championahip race count #define RACE_COUNTDOWN_TT1 (2) // For Time Trial 1 int countdown_state = RACE_COUNTDOWN_1P; // Sets initial count state // PLAYER POSITION SPRITE VALUES FOR USE IN THE RACE #define POS_WIDTH (28) // Width of the number sprites #define POS_HEIGHT (49) // Height of the number images #define P1_XPOSITION (25) // x position of player 1 position sprites #define P1_YPOSITION (20) // y position of player 1 position sprites #define P2_XPOSITION (105) // x screen position of player 2 position values #define P2_YPOSITION (21) // y screen position of player 2 position values #define P3_XPOSITION (188) // x screen position of yellow player 3 position values #define P3_YPOSITION (21) // y screen position of yellow player 3 position values #define P4_XPOSITION (264) // x screen position of green player 4 position values #define P4_YPOSITION (22) // y screen position of green player 4 position values // ---- TEXTURE PAGE VALUES FOR THE DIFFERENT NUMBERS AND FOR EACH PLAYER ----- #define TEXTUREPAGEU_P1 ((28*8)+1) // x texture page address for player one - sets at default '~' image to start #define TEXTUREPAGEV_P1 (42) // y texture page address for player one - sets at default '~' image to start #define TEXTUREPAGEU_P2 ((28*8)+1) // x texture page address for player one - sets at default '~' image to start #define TEXTUREPAGEV_P2 (89) // y texture page address for player one - sets at default '~' image to start #define TEXTUREPAGEU_P3 ((28*8)+2) // x texture page address for player one - sets at default '~' image to start #define TEXTUREPAGEV_P3 (136) // y texture page address for player one - sets at default '~' image to start #define TEXTUREPAGEU_P4 ((28*8)+2) // x texture page address for player one - sets at default '~' image to start #define TEXTUREPAGEV_P4 (184) // y texture page address for player one - sets at default '~' image to start // 'CONGRATULATIONS!' MESSAGE DEFINITIONS #define CONGRAT_WIDTH (256) // Sets the width of the 'CONGRATULATIONS!' image #define CONGRAT_HEIGHT (42) // Height of the 'CONGRATULATIONS!' message #define CONGRAT_XPOS (-256) // x screen position of the 'CONGRATULATIONS!' message #define CONGRAT_YPOS (105) // y screen position of the 'CONGRATULATIONS!' message #define STATE_SETUP (0) // Finite state machine setup for displaying the 'CONGRATULATIONS!' message #define STATE_OFFSCREEN (1) // Finite state for use in displaying the 'CONGRATULATIONS!' message - this is the initial state #define STATE_INPOSITION (2) // State for when the 'CONGRATULATIONS!' message is in the centre of the screen #define STATE_ROTATEDOWN (3) // Flip the 'CONGRATULATIONS!' image - this state flips it upside-down #define STATE_ROTATEUP (4) // This state flips the image the correct way up #define STATE_LEAVESCREEN (5) // Moves the message off the screen // LEFT AND RIGHT OPTION SCREEN ARROWS #define LEFTARROW_XPOS (112) // Sets the left arrow x axis screen position #define LEFTARROW_YPOS (151) // Sets the left arrow y axis screen position #define LEFTARROW_UVALUE (25*4) // u texture page value of the left arrow #define LEFTARROW_VVALUE (13) // v texture page position of the left arrow #define ARROW_WIDTH (4*4) // Sets the width of the left and right arrows as 14 (4*4 because the image is 7 pixels wide in an 4-bit format) #define ARROW_HEIGHT (14) // Sets the height of the left and right arrows #define RIGHTARROW_XPOS (196) // Sets the left arrow x axis screen position #define RIGHTARROW_YPOS (151) // Sets the left arrow y axis screen position #define RIGHTARROW_UVALUE (29*4) // u texture page value of the left arrow #define RIGHTARROW_VVALUE (13) // v texture page position of the left arrow #define ARROWOPTION_1 (1) // Possible selections for the player - option 1 is 1 player #define ARROWOPTION_2 (2) // Two player option #define ARROWOPTION_3 (3) // Three player option #define ARROWOPTION_4 (4) // Four player option int arrow_state = 1; // POSITIONS FOR THE ARROWS ON THE 2nd OPTION SCREEN (1 PLAYER OPTIONS) #define LEFTARROW_XPOS2 (92) // Sets x axis screen position for the left arrow #define LEFTARROW_YPOS2 (157) // Sets y axis screen position of left arrow #define RIGHTARROW_XPOS2 (216) // Sets x axis screen position of the right arrow #define RIGHTARROW_YPOS2 (157) // Sets y axis screen position of right arrow #define P1_ARROWOPTION1 (1) // Finite state for possible player 1 options - option 1 = championship #define P1_ARROWOPTION2 (2) // Option 2 = time trial #define P1_ARROWOPTION3 (3) // Challenge Game option int p1_ArrowState = 1; // Sets the initial arrow state // IN-GAME SPEED BARS USED TO DISPLAY THE DIFFERENT SPEEDS OF EACH PLAYER #define SPEEDBAR_WIDTH (72) // Width of the speed bar images #define SPEEDBAR_HEIGHT (22) // Height of the speed bar images #define SPEEDBARP1_XPOS (5) // x screen position of the speed bar images for player 1 #define SPEEDBARP1_YPOS (72) // y screen position of the speed bar images for player 1 #define SPEEDBARP2_XPOS (85) // x screen position of the speed bar images for player 2 #define SPEEDBARP2_YPOS (72) // y screen position of the speed bar images for player 2 #define SPEEDBARP3_XPOS (164) // x screen position of the speed bar images for player 3 #define SPEEDBARP3_YPOS (72) // y screen position of the speed bar images for player 3 #define SPEEDBARP4_XPOS (242) // x screen position of the speed bar images for player 4 #define SPEEDBARP4_YPOS (72) // y screen position of the speed bar images for player 4 #define SPEEDBAR_UVALUE1 (0) // u texture page value of speed bars 0, 3, and 6 #define SPEEDBAR_UVALUE2 (72) // u texture page value of speed bars 1 and 4 #define SPEEDBAR_UVALUE3 (144) // u texture page value of speed bars 2 and 5 #define SPEEDBAR_VVALUE1 (188) // v texture page value of speed bars 0, 1, and 2 #define SPEEDBAR_VVALUE2 (210) // v texture page value of speed bars 3, 4, and 5 #define SPEEDBAR_VVALUE3 (232) // v texture page value of speed bar 6 // ------------------------------------------ // MAIN GAME LOOP FINITE STATE MACHINE SETUP // ------------------------------------------ #define GAME_STATE_TITLESCREEN (1) // Possible game states #define GAME_STATE_OPTIONS1 (2) // Number of players option #define GAME_STATE_OPTIONS2 (3) // Game-type options for 1 player #define GAME_STATE_RUN1P (4) // Game running (1 player) #define GAME_STATE_COUNTDOWN (5) // countdown to begin a race #define GAME_STATE_SETUP (6) // Sets up the in-game variables #define GAME_STATE_SHOWRESULT1P (7) // Shows the finishing time and position of player 1 after a one-player race #define GAME_STATE_TIMETRIAL1 (8) // Time trial game for 1 player - without the computer player int game_state = GAME_STATE_TITLESCREEN; // Initial game state // -------------------------- // SPRITE STRUCTURE POINTER // -------------------------- GsSPRITE spritep1, spritec1, spritec2, spritec3, spritec4, spritec5, spritec6, spritec7; // Sprite structures GsSPRITE playerbar1, playerbar2, playerbar3, playerbar4, timebar, titleimg, startimg, grassimg, threeimg, twoimg, oneimg, goimg; GsSPRITE player1pos, player2pos, player3pos, player4pos, congratimg, leftarrow, rightarrow, speedbar1, speedbar2, speedbar3, speedbar4; GsSPRITE background[BG_IMAGES]; // Declares a structure for the background // -------------------------- // ORDERING TABLE VARIABLES // -------------------------- #define OT_LENGTH (1) // Sets the length of the Ordering Table GsOT WorldOT[2]; // Sets two Ordering Table headers GsOT_TAG OTTags[2][1< 4) { arrow_state = ARROWOPTION_1; leftarrow.y = LEFTARROW_YPOS; rightarrow.y = RIGHTARROW_YPOS; } padUse = 1; padUseCount = 0; } } if(pad1Check & PADLup) { if(padUse==0) { leftarrow.y -= 16; rightarrow.y -= 16; arrow_state--; if(arrow_state < 1) { arrow_state = ARROWOPTION_4; leftarrow.y = LEFTARROW_YPOS + 48; rightarrow.y = RIGHTARROW_YPOS + 48; } padUse = 1; padUseCount = 0; } } if(pad1Check & PADRdown) // If an option is selected { switch(arrow_state) { case(ARROWOPTION_1): // If the 1 player option if selected... { game_state = GAME_STATE_OPTIONS2; // ... call the 1 player options screen break; } case(ARROWOPTION_2): { game_state = GAME_STATE_SETUP; break; } case(ARROWOPTION_3): { game_state = GAME_STATE_SETUP; break; } case(ARROWOPTION_4): { game_state = GAME_STATE_SETUP; break; } default: { break; } } } if(padUseCount>10) { padUse = 0; padUseCount = 0; } TitleScreenDisplay(); // Sends the main title screen images to the OT ScreenDisplay(); break; } case(GAME_STATE_OPTIONS2): { ScreenSetup(); optionSelectCount++; padUseCount++; MainTitleFlip(); // Flip the main title image FntPrint("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t SELECT GAME TYPE"); FntPrint("\n\n\n\t\t CHAMPIONSHIP"); FntPrint("\n\n\n\t\t TIME TRIAL"); FntPrint("\n\n\n\t\t CHALLENGE GAME"); FntFlush(-1); // Output text to the screen if(optionSelectCount==1) // Changes positions of on-screen arrows from the last options screen - only called once { leftarrow.x = LEFTARROW_XPOS2; leftarrow.y = LEFTARROW_YPOS2; rightarrow.x = RIGHTARROW_XPOS2; rightarrow.y = RIGHTARROW_YPOS2; } if(pad1Check & PADLdown) { if(padUse==0) { leftarrow.y += 25; rightarrow.y += 25; p1_ArrowState++; if(p1_ArrowState > 3) { p1_ArrowState = P1_ARROWOPTION1; leftarrow.y = LEFTARROW_YPOS2; rightarrow.y = RIGHTARROW_YPOS2; } padUse = 1; padUseCount = 0; } } if(pad1Check & PADLup) { if(padUse==0) { p1_ArrowState--; if(p1_ArrowState < 1) { p1_ArrowState = P1_ARROWOPTION3; leftarrow.y = LEFTARROW_YPOS2 + 50; rightarrow.y = RIGHTARROW_YPOS2 + 50; } else { leftarrow.y -= 25; rightarrow.y -= 25; } padUse = 1; padUseCount = 0; } } if(optionSelectCount>10) { if(pad1Check & PADRdown) // If an option is selected { switch(p1_ArrowState) { case(P1_ARROWOPTION1): { countdown_state = RACE_COUNTDOWN_1P; // sets race countdown type optionSelectCount=0; game_state = GAME_STATE_SETUP; // changes the game state break; } case(P1_ARROWOPTION2): { countdown_state = RACE_COUNTDOWN_TT1; // sets race countdown type optionSelectCount=0; game_state = GAME_STATE_SETUP; // changes the game state break; } default: { countdown_state = RACE_COUNTDOWN_1P; optionSelectCount=0; game_state = GAME_STATE_SETUP; break; } } } } if(padUseCount>10) { padUse = 0; padUseCount = 0; } TitleScreenDisplay(); // Sends the main title screen images to the OT ScreenDisplay(); break; } case(GAME_STATE_SETUP): { InitVars(); // Initiate the variables for use in the game count = 0; raceCountdown = 3; // Sets start of the count to the correct state game_state = GAME_STATE_COUNTDOWN; break; } case(GAME_STATE_COUNTDOWN): // Race start countdown { ScreenSetup(); count++; switch(raceCountdown) { case(3): { threeimg.scalex += 40; threeimg.scaley += 40; if(count>100) { raceCountdown-=1; count = 0; } // Draw the on-screen graphics GsSortSprite(&threeimg,&WorldOT[activeBuffer],0); // Draws '3' sprite into OT break; } case(2): { twoimg.scalex += 40; twoimg.scaley += 40; if(count>100) { raceCountdown-=1; count=0; } // Draw the on-screen graphics GsSortSprite(&twoimg,&WorldOT[activeBuffer],0); // Draws '2' sprite into OT break; } case(1): { oneimg.scalex += 40; oneimg.scaley += 40; if(count>100) { count=0; raceCountdown=3; // Resets the race countdown switch(countdown_state) { case(RACE_COUNTDOWN_1P): { game_state = GAME_STATE_RUN1P; // Changes game state break; } case(RACE_COUNTDOWN_TT1): { game_state = GAME_STATE_TIMETRIAL1; break; } } } // Draw the on-screen graphics GsSortSprite(&oneimg,&WorldOT[activeBuffer],0); // Draws '1' sprite into OT break; } } // Display the appropriate onsceen graphics switch(countdown_state) { case(RACE_COUNTDOWN_TT1): { GameGraphicsTT(); break; } default: { GameGraphics(); break; } } DisplayTime(); // Display the race time on screen FntFlush(-1); // Send the text output to the display buffer ScreenDisplay(); break; } case(GAME_STATE_RUN1P): { if(distance[0]RACE_LENGTH) { while(setP1!=1) SetFinishTimeP1(); } if(distance[1]>RACE_LENGTH) { while(setC1!=1) SetFinishTimeC1(); } if(distance[2]>RACE_LENGTH) { while(setC2!=1) SetFinishTimeC2(); } if(distance[3]>RACE_LENGTH) { while(setC3!=1) SetFinishTimeC3(); } if(distance[4]>RACE_LENGTH) { while(setC4!=1) SetFinishTimeC4(); } // ************************* // OTHER COMPUTER PLAYER FINISH TIMES NEED TO BE ADDED HERE // ************************* if((distance[0]>RACE_LENGTH)&&(distance[1]>RACE_LENGTH)&&(distance[2]>RACE_LENGTH)&&(distance[3]>RACE_LENGTH)&&(distance[4]>RACE_LENGTH)&&(distance[5]>RACE_LENGTH)&&(distance[6]>RACE_LENGTH)&&(distance[7]>RACE_LENGTH)) { finish = 1; go=0; // Resets the 'GO!' image state godisptime=0; // resets the 'GO!' display time RaceOver(); if(displayCongrat == 1) DispCongratMess(); // Calls the function to display the 'CONGRATULATIONS!' message else game_state = GAME_STATE_SHOWRESULT1P; // Returns to the title screen } ScreenSetup(); // Set up the drawing area and ordering table ready to use if(go==0) // Checks whether the 'GO!' image needs to be displayed { godisptime++; // Counter for how long the 'GO!' image is displayed if((godisptime<100)&&(finish==0)) GsSortFastSprite(&goimg,&WorldOT[activeBuffer],0); // Draws 'GO!' sprite into OT else go = 1; } FntFlush(-1); // Send the text output to the display buffer // Draw the on-screen graphics GameGraphics(); ScreenDisplay(); // Draw the above into the active buffer break; } case(GAME_STATE_SHOWRESULT1P): { initVarsOK = 0; // So games variables can be reset ScreenSetup(); // Set up the drawing area and ordering table ready to use switch(racePositionP1) { case(1): { FntPrint("~c991\n\n\n\n\n\n\n WELL DONE PLAYER 1\n\n"); FntPrint(" You finished 1st in %d:%d%d seconds",finishTime1Digitp1,finishTime2Digitp1,finishTime3Digitp1); FntPrint("\n\n Your fastest time: %d:%d%d seconds\n",bestTime1Digit,bestTime2Digit,bestTime3Digit); FntPrint("\n\n Press 'X' to continue"); FntPrint("~c707\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t %3d:%d%d",raceTimer1Digit,raceTimer2Digit,raceTimer3Digit); break; } case(2): { FntPrint("~c991\n\n\n\n\n\n\n WELL DONE PLAYER 1\n\n"); FntPrint(" You finished 2nd in %d:%d%d seconds",finishTime1Digitp1,finishTime2Digitp1,finishTime3Digitp1); FntPrint("\n\n Your fastest time: %d:%d%d seconds\n",bestTime1Digit,bestTime2Digit,bestTime3Digit); FntPrint("\n\n Press 'X' to continue"); FntPrint("~c707\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t %3d:%d%d",raceTimer1Digit,raceTimer2Digit,raceTimer3Digit); break; } case(3): { FntPrint("~c991\n\n\n\n\n\n\n WELL DONE PLAYER 1\n\n"); FntPrint(" You finished 3rd in %d:%d%d seconds",finishTime1Digitp1,finishTime2Digitp1,finishTime3Digitp1); FntPrint("\n\n Your fastest time: %d:%d%d seconds\n",bestTime1Digit,bestTime2Digit,bestTime3Digit); FntPrint("\n\n Press 'X' to continue"); FntPrint("~c707\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t %3d:%d%d",raceTimer1Digit,raceTimer2Digit,raceTimer3Digit); break; } default: { FntPrint("~c991\n\n\n\n\n\n\n BAD LUCK PLAYER 1\n\n"); FntPrint(" You finished in %d:%d%d seconds",finishTime1Digitp1,finishTime2Digitp1,finishTime3Digitp1); FntPrint("\n\n Your fastest time: %d:%d%d seconds\n",bestTime1Digit,bestTime2Digit,bestTime3Digit); FntPrint("\n\n Press 'X' to continue"); FntPrint("~c707\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t %3d:%d%d",raceTimer1Digit,raceTimer2Digit,raceTimer3Digit); break; } }// end switch FntFlush(-1); // Sens the above text to the OT // Draw the on-screen graphics GameGraphics(); if(pad1Check & PADRdown) { InitVars(); game_state = GAME_STATE_TITLESCREEN; } ScreenDisplay(); // Draw the above into the active buffer break; } case(GAME_STATE_TIMETRIAL1): { if(distance[0]<=RACE_LENGTH) { Player1Input(); // Player One Movement SpeedCalc(); // Player 1 DistanceCalc(); ScrollBg(characterSpeed); // Scrolls the background framesPerSecondCount1++; framesPerSecondCount2++; SpeedDisplay(); // Displays the speed of each player on-screen if(distance[0]2) { if(total==3) { spritep1.u += 64; counter++; animCounter1++; // Increments animation variable if(animCounter1>4) animCounter1 = 1; if(spritep1.u>256) spritep1.u = 0; // ScrollBg(characterSpeed); // Scrolls the background total = 0; } if(!(total==3)) { lastPressedLeft = 0; lastPressedRight = 0; total = 0; } } } // ---------------------------------- // PLAYER TWO INPUT READING FUNCTION // ---------------------------------- void Player2Input() { if(pad2Check & PADLleft) lastPressedLeft2 = 1; if(pad2Check & PADLright) lastPressedRight2 = 2; total2 = lastPressedLeft2 + lastPressedRight2; if(total2>2) { if(total2==3) { total2 = 0; } if(!(total==3)) { lastPressedLeft2 = 0; lastPressedRight2 = 0; total2 = 0; } } } // --------------------------------------- // FUNCTION TO MOVE COMPUTER OPPONENT ONE // --------------------------------------- void CompMove1() { compCount1++; if(compCount1==c1Value) { spritec1.u += 64; // Increments the texture page to show the next animation frame counter2++; animCounter2++; // Variable to hold the animation frame number if(animCounter2>4) animCounter2 = 1; if(distance[0]>=distance[1]) { distDiff = (distance[0] - distance[1]); if(distDiff>25) c1Value = 3; } if(spritec1.u > 256) { spritec1.u = 0; } compCount1 = 0; // Resets the computer count variable } } // --------------------------------------- // FUNCTION TO MOVE COMPUTER OPPONENT TWO // --------------------------------------- void CompMove2() { compCount2++; if(compCount2==c2Value) { spritec2.u += 64; counter3++; animCounter3++; // Variable to hold the animation frame number if(animCounter3>4) animCounter3 = 1; if((distance[2]>150)&&(distance[2]<400)) c2Value = 5; // Sets speed change if(distance[2]>=400) c2Value = 2; if(spritec1.u > 256) { spritec1.u = 0; } compCount2 = 0; // Resets the computer count variable } } // -------------------------------------- // FUNCTION TO CONTROL COMPUTER PLAYER 3 // -------------------------------------- void CompMove3() { compCount3++; if(compCount3==c3Value) { spritec3.u += 64; if(spritec3.u>256) spritec3.u = 0; if(distance[3]>500) c3Value = 6; if(distance[3]>1300) c3Value = 4; counter4++; compCount3 = 0; } } // --------------------------- // COMPUTER PLAYER 4 MOVEMENT // --------------------------- void CompMove4() { compCount4++; if(compCount4==c4Value) { spritec4.u += 64; if(spritec4.u>256) spritec4.u = 0; if(distance[4]>1000) c4Value = 3; counter5++; compCount4 = 0; } } // --------------------------- // COMPUTER PLAYER 5 MOVEMENT // --------------------------- void CompMove5() { compCount5++; if(compCount5==c5Value) { spritec5.u += 64; if(spritec5.u>256) spritec5.u = 0; if((distance[5]>800)&&(distance[5]<1250)) c5Value = 6; if(distance[5]>=1250) c5Value = 3; counter6++; compCount5 = 0; } } // --------------------------- // COMPUTER PLAYER 6 MOVEMENT // --------------------------- void CompMove6() { compCount6++; if(compCount6==c6Value) { spritec6.u += 64; if(spritec6.u > 256) spritec6.u = 0; if((distance[6]>700)&&(distance[6]<1100)) c6Value = 2; // Speed up character if(distance[6]>=1100) c6Value = 1; counter7++; compCount6 = 0; } } // --------------------------- // COMPUTER PLAYER 7 MOVEMENT // --------------------------- void CompMove7() { compCount7++; if(compCount7==c7Value) { spritec7.u += 64; if(spritec7.u > 256) spritec7.u = 0; if((distance[7]>700)&&(distance[7]<900)) c7Value = 2; if((distance[7]>=900)&&(distance[7]<1400)) c7Value = 3; if(distance[7]>=1400) c7Value = 7; counter8++; compCount7 = 0; } } // -------------------------------------- // FUNCTION TO CHECK IF THE RACE IS OVER // -------------------------------------- void RaceOver() { if(racePositionP1==1) { displayCongrat = 1; // Display the 'CONGRATULATIONS!' message } if((finishTime1Digitp10)) AssignBestTime(); if((finishTime1Digitp1==bestTime1Digit)&(finishTime1Digitp1>0)) { if(finishTime2Digitp1= 145) // Stops the 'CONGRATULATIONS!' image in the centre of the screen congratState = STATE_INPOSITION; break; } case(STATE_INPOSITION): { congratCentral = 1; // Enables text to be displayed congratState = STATE_ROTATEDOWN; break; } case(STATE_ROTATEDOWN): { if(timer>200) { congratimg.scaley -= 500; // pseudo-flip the 'CONGRATULATIONS!' image if(congratimg.scaley <= -4000) { congratState = STATE_ROTATEUP; } } break; } case(STATE_ROTATEUP): { congratimg.scaley += 500; // Flip the image the correct way up if(congratimg.scaley >= 4096) { if(congratCount++ == 1) { timer = 0; } if(congratCount>1) { timer = 0; if(congratCount == 2) { congratState = STATE_LEAVESCREEN; congratCount = 0; } } else { congratState = STATE_ROTATEDOWN; } } break; } case(STATE_LEAVESCREEN): { if(timer>20) { if(!(congratimg.x >= 450)) { congratimg.x += 20; } else { timer++; if(timer>150) { congratState = STATE_SETUP; // Resets 'CONGRATULATIONS!' message game_state = GAME_STATE_SHOWRESULT1P; // Returns to the title screen } } } break; } } } // ------------------------------------------------------------- // FUNCTION TO DISPLAY THE RACE TIMER ON SCREEN DURING THE RACE // ------------------------------------------------------------- void DisplayTime() { FntPrint("~c707\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t %3d:%d%d",raceTimer1Digit,raceTimer2Digit,raceTimer3Digit); } // ---------------------------- // SPEED CALCULATION FUNCTION // ---------------------------- void SpeedCalc() { // Calculates the speed of the character speedCounter++; if(speedCounter==13) { calc = 1000/(counter); if(calc<1000) { if(calc<499) if(calc<330) if(calc<249) if(calc<199) if(calc<165) characterSpeed = 6; else characterSpeed = 5; else characterSpeed = 4; else characterSpeed = 3; else characterSpeed = 2; else characterSpeed = 1; } else characterSpeed = 0; speedCounter = 0; counter = 1; } } // ------------------------------------------ // CALCULATES THE SPEED OF COMPUTER PLAYER 1 // ------------------------------------------ void SpeedCalcC1() { speedCounter2++; if(speedCounter2==13) { calc = 1000/(counter2); if(calc<1000) { if(calc<499) if(calc<330) if(calc<249) if(calc<199) if(calc<165) characterSpeedC1 = 6; else characterSpeedC1 = 5; else characterSpeedC1 = 4; else characterSpeedC1 = 3; else characterSpeedC1 = 2; else characterSpeedC1 = 1; } else characterSpeedC1 = 0; speedCounter2 = 0; counter2 = 1; } } // ------------------------------------------ // CALCULATES THE SPEED OF COMPUTER PLAYER 2 // ------------------------------------------ void SpeedCalcC2() { speedCounter3++; if(speedCounter3==13) { calc = 1000/(counter3); if(calc<1000) { if(calc<499) if(calc<330) if(calc<249) if(calc<199) if(calc<165) characterSpeedC2 = 6; else characterSpeedC2 = 5; else characterSpeedC2 = 4; else characterSpeedC2 = 3; else characterSpeedC2 = 2; else characterSpeedC2 = 1; } else characterSpeedC2 = 0; speedCounter3 = 0; counter3 = 1; } } // ------------------------------------------ // CALCULATES THE SPEED OF COMPUTER PLAYER 3 // ------------------------------------------ void SpeedCalcC3() { speedCounter4++; if(speedCounter4==13) { calc = 1000/(counter4); if(calc<1000) { if(calc<499) if(calc<330) if(calc<249) if(calc<199) if(calc<165) characterSpeedC3 = 6; else characterSpeedC3 = 5; else characterSpeedC3 = 4; else characterSpeedC3 = 3; else characterSpeedC3 = 2; else characterSpeedC3 = 1; } else characterSpeedC3 = 0; speedCounter4 = 0; counter4 = 1; } } // ------------------------------------------ // CALCULATES THE SPEED OF COMPUTER PLAYER 4 // ------------------------------------------ void SpeedCalcC4() { speedCounter5++; if(speedCounter5==13) { calc = 1000/(counter5); if(calc<1000) { if(calc<499) if(calc<330) if(calc<249) if(calc<199) if(calc<165) characterSpeedC4 = 6; else characterSpeedC4 = 5; else characterSpeedC4 = 4; else characterSpeedC4 = 3; else characterSpeedC4 = 2; else characterSpeedC4 = 1; } else characterSpeedC4 = 0; speedCounter5 = 0; counter5 = 1; } } // ------------------------------------------ // CALCULATES THE SPEED OF COMPUTER PLAYER 5 // ------------------------------------------ void SpeedCalcC5() { speedCounter6++; if(speedCounter6==13) { calc = 1000/(counter6); if(calc<1000) { if(calc<499) if(calc<330) if(calc<249) if(calc<199) if(calc<165) characterSpeedC5 = 6; else characterSpeedC5 = 5; else characterSpeedC5 = 4; else characterSpeedC5 = 3; else characterSpeedC5 = 2; else characterSpeedC5 = 1; } else characterSpeedC5 = 0; speedCounter6 = 0; counter6 = 1; } } // ------------------------------------------ // CALCULATES THE SPEED OF COMPUTER PLAYER 6 // ------------------------------------------ void SpeedCalcC6() { speedCounter7++; if(speedCounter7==13) { calc = 1000/(counter7); if(calc<1000) { if(calc<499) if(calc<330) if(calc<249) if(calc<199) if(calc<165) characterSpeedC6 = 6; else characterSpeedC6 = 5; else characterSpeedC6 = 4; else characterSpeedC6 = 3; else characterSpeedC6 = 2; else characterSpeedC6 = 1; } else characterSpeedC6 = 0; speedCounter7 = 0; counter7 = 1; } } // ------------------------------------------ // CALCULATES THE SPEED OF COMPUTER PLAYER 7 // ------------------------------------------ void SpeedCalcC7() { speedCounter8++; if(speedCounter8==13) { calc = 1000/(counter8); if(calc<1000) { if(calc<499) if(calc<330) if(calc<249) if(calc<199) if(calc<165) characterSpeedC7 = 6; else characterSpeedC7 = 5; else characterSpeedC7 = 4; else characterSpeedC7 = 3; else characterSpeedC7 = 2; else characterSpeedC7 = 1; } else characterSpeedC7 = 0; speedCounter8 = 0; counter8 = 1; } } // --------------------------------------------------------------------------- // FUNCTION TO DISPLAY THE SPEED OF EACH CHARACTER USING THE SPEED BAR IMAGES // --------------------------------------------------------------------------- void SpeedDisplay() { switch(characterSpeed) // Displays human player 1's speed on screen using little speed bar images { case(6): // Fastest speed (value 6) { speedbar1.u = SPEEDBAR_UVALUE1; // Bottom-left speed bar in TIM file speedbar1.v = SPEEDBAR_VVALUE3; speedbar1.x = SPEEDBARP1_XPOS; // Makes sure the image is displayed on screen in the correct position break; } case(5): { speedbar1.u = SPEEDBAR_UVALUE3; // Middle-right speed bar in TIM file speedbar1.v = SPEEDBAR_VVALUE2; speedbar1.x = SPEEDBARP1_XPOS - 2; break; } case(4): { speedbar1.u = SPEEDBAR_UVALUE2; // Centre speed bar in TIM file speedbar1.v = SPEEDBAR_VVALUE2; speedbar1.x = SPEEDBARP1_XPOS - 1; break; } case(3): { speedbar1.u = SPEEDBAR_UVALUE1; // Middle-left speed bar in TIM file speedbar1.v = SPEEDBAR_VVALUE2; speedbar1.x = SPEEDBARP1_XPOS; break; } case(2): { speedbar1.u = SPEEDBAR_UVALUE3; // Top-right speed bar in TIM file speedbar1.v = SPEEDBAR_VVALUE1; speedbar1.x = SPEEDBARP1_XPOS - 2; break; } case(1): { speedbar1.u = SPEEDBAR_UVALUE2; // Top-centre speed bar in TIM file speedbar1.v = SPEEDBAR_VVALUE1; speedbar1.x = SPEEDBARP1_XPOS - 1; break; } default: // Stationary (value 0) { speedbar1.u = SPEEDBAR_UVALUE1; // Top-left speed bar in TIM file speedbar1.v = SPEEDBAR_VVALUE1; speedbar1.x = SPEEDBARP1_XPOS; break; } } } // --------------------- // MAIN TITLE FLIP CODE // --------------------- void MainTitleFlip() { count++; if(count<181) { titleimg.scalex += 23; titleimg.scaley += 23; titleimg.rotate += 8192; } if(count>=500) { switch(rotatestate) { case(0): { titleimg.scalex -= 500; if(titleimg.scalex <= -4096) rotatestate = 1; break; } case(1): { titleimg.scalex += 500; if(titleimg.scalex >= 4096) rotatestate = 2; break; } } } if(count>700) { count = 200; rotatestate = 0; } } // ---------------------------------------------------------- // FUNCTION TO CHECK THE DIFFERENCE IN SPEED BETWEEN PLAYERS // ---------------------------------------------------------- void SpeedCheckC1() // Checks speeds and adjusts screen positions accordingly { // If computer player 1 is faster than player 1 if(characterSpeedC1>characterSpeed) { if(characterSpeed==0) { if(characterSpeedC1==1) spritec1.x += 1; if(characterSpeedC1==2) spritec1.x += 2; if(characterSpeedC1==3) spritec1.x += 3; if(characterSpeedC1==4) spritec1.x += 4; if(characterSpeedC1==5) spritec1.x += 5; if(characterSpeedC1==6) spritec1.x += 6; } if(characterSpeed==1) { if(characterSpeedC1==2) spritec1.x += 1; if(characterSpeedC1==3) spritec1.x += 2; if(characterSpeedC1==4) spritec1.x += 3; if(characterSpeedC1==5) spritec1.x += 4; if(characterSpeedC1==6) spritec1.x += 5; } if(characterSpeed==2) { if(characterSpeedC1==3) spritec1.x += 1; if(characterSpeedC1==4) spritec1.x += 2; if(characterSpeedC1==5) spritec1.x += 3; if(characterSpeedC1==6) spritec1.x += 4; } if(characterSpeed==3) { if(characterSpeedC1==4) spritec1.x += 1; if(characterSpeedC1==5) spritec1.x += 2; if(characterSpeedC1==6) spritec1.x += 3; } if(characterSpeed==4) { if(characterSpeedC1==5) spritec1.x += 1; if(characterSpeedC1==6) spritec1.x += 2; } if(characterSpeed==5) { if(characterSpeedC1==6) spritec1.x += 1; } } // If player 1 is faster than computer player 1 if(characterSpeedC1characterSpeed) { if(characterSpeed==0) { if(characterSpeedC2==1) spritec2.x += 1; if(characterSpeedC2==2) spritec2.x += 2; if(characterSpeedC2==3) spritec2.x += 3; if(characterSpeedC2==4) spritec2.x += 4; if(characterSpeedC2==5) spritec2.x += 5; if(characterSpeedC2==6) spritec2.x += 6; } if(characterSpeed==1) { if(characterSpeedC2==2) spritec2.x += 1; if(characterSpeedC2==3) spritec2.x += 2; if(characterSpeedC2==4) spritec2.x += 3; if(characterSpeedC2==5) spritec2.x += 4; if(characterSpeedC2==6) spritec2.x += 5; } if(characterSpeed==2) { if(characterSpeedC2==3) spritec2.x += 1; if(characterSpeedC2==4) spritec2.x += 2; if(characterSpeedC2==5) spritec2.x += 3; if(characterSpeedC2==6) spritec2.x += 4; } if(characterSpeed==3) { if(characterSpeedC2==4) spritec2.x += 1; if(characterSpeedC2==5) spritec2.x += 2; if(characterSpeedC2==6) spritec2.x += 3; } if(characterSpeed==4) { if(characterSpeedC2==5) spritec2.x += 1; if(characterSpeedC2==6) spritec2.x += 2; } if(characterSpeed==5) { if(characterSpeedC2==6) spritec2.x += 1; } } // If player 1 is faster than computer player 2 if(characterSpeedC2characterSpeed) { if(characterSpeed==0) { if(characterSpeedC3==1) spritec3.x += 1; if(characterSpeedC3==2) spritec3.x += 2; if(characterSpeedC3==3) spritec3.x += 3; if(characterSpeedC3==4) spritec3.x += 4; if(characterSpeedC3==5) spritec3.x += 5; if(characterSpeedC3==6) spritec3.x += 6; } if(characterSpeed==1) { if(characterSpeedC3==2) spritec3.x += 1; if(characterSpeedC3==3) spritec3.x += 2; if(characterSpeedC3==4) spritec3.x += 3; if(characterSpeedC3==5) spritec3.x += 4; if(characterSpeedC3==6) spritec3.x += 5; } if(characterSpeed==2) { if(characterSpeedC3==3) spritec3.x += 1; if(characterSpeedC3==4) spritec3.x += 2; if(characterSpeedC3==5) spritec3.x += 3; if(characterSpeedC3==6) spritec3.x += 4; } if(characterSpeed==3) { if(characterSpeedC3==4) spritec3.x += 1; if(characterSpeedC3==5) spritec3.x += 2; if(characterSpeedC3==6) spritec3.x += 3; } if(characterSpeed==4) { if(characterSpeedC3==5) spritec3.x += 1; if(characterSpeedC3==6) spritec3.x += 2; } if(characterSpeed==5) { if(characterSpeedC3==6) spritec3.x += 1; } } // If player 1 is faster than computer player 3 if(characterSpeedC3characterSpeed) { if(characterSpeed==0) { if(characterSpeedC4==1) spritec4.x += 1; if(characterSpeedC4==2) spritec4.x += 2; if(characterSpeedC4==3) spritec4.x += 3; if(characterSpeedC4==4) spritec4.x += 4; if(characterSpeedC4==5) spritec4.x += 5; if(characterSpeedC4==6) spritec4.x += 6; } if(characterSpeed==1) { if(characterSpeedC4==2) spritec4.x += 1; if(characterSpeedC4==3) spritec4.x += 2; if(characterSpeedC4==4) spritec4.x += 3; if(characterSpeedC4==5) spritec4.x += 4; if(characterSpeedC4==6) spritec4.x += 5; } if(characterSpeed==2) { if(characterSpeedC4==3) spritec4.x += 1; if(characterSpeedC4==4) spritec4.x += 2; if(characterSpeedC4==5) spritec4.x += 3; if(characterSpeedC4==6) spritec4.x += 4; } if(characterSpeed==3) { if(characterSpeedC4==4) spritec4.x += 1; if(characterSpeedC4==5) spritec4.x += 2; if(characterSpeedC4==6) spritec4.x += 3; } if(characterSpeed==4) { if(characterSpeedC4==5) spritec4.x += 1; if(characterSpeedC4==6) spritec4.x += 2; } if(characterSpeed==5) { if(characterSpeedC4==6) spritec4.x += 1; } } // If player 1 is faster than computer player 4 if(characterSpeedC4characterSpeed) { if(characterSpeed==0) { if(characterSpeedC5==1) spritec5.x += 1; if(characterSpeedC5==2) spritec5.x += 2; if(characterSpeedC5==3) spritec5.x += 3; if(characterSpeedC5==4) spritec5.x += 4; if(characterSpeedC5==5) spritec5.x += 5; if(characterSpeedC5==6) spritec5.x += 6; } if(characterSpeed==1) { if(characterSpeedC5==2) spritec5.x += 1; if(characterSpeedC5==3) spritec5.x += 2; if(characterSpeedC5==4) spritec5.x += 3; if(characterSpeedC5==5) spritec5.x += 4; if(characterSpeedC5==6) spritec5.x += 5; } if(characterSpeed==2) { if(characterSpeedC5==3) spritec5.x += 1; if(characterSpeedC5==4) spritec5.x += 2; if(characterSpeedC5==5) spritec5.x += 3; if(characterSpeedC5==6) spritec5.x += 4; } if(characterSpeed==3) { if(characterSpeedC5==4) spritec5.x += 1; if(characterSpeedC5==5) spritec5.x += 2; if(characterSpeedC5==6) spritec5.x += 3; } if(characterSpeed==4) { if(characterSpeedC5==5) spritec5.x += 1; if(characterSpeedC5==6) spritec5.x += 2; } if(characterSpeed==5) { if(characterSpeedC5==6) spritec5.x += 1; } } // If player 1 is faster than computer player 5 if(characterSpeedC5characterSpeed) { if(characterSpeed==0) { if(characterSpeedC6==1) spritec6.x += 1; if(characterSpeedC6==2) spritec6.x += 2; if(characterSpeedC6==3) spritec6.x += 3; if(characterSpeedC6==4) spritec6.x += 4; if(characterSpeedC6==5) spritec6.x += 5; if(characterSpeedC6==6) spritec6.x += 6; } if(characterSpeed==1) { if(characterSpeedC6==2) spritec6.x += 1; if(characterSpeedC6==3) spritec6.x += 2; if(characterSpeedC6==4) spritec6.x += 3; if(characterSpeedC6==5) spritec6.x += 4; if(characterSpeedC6==6) spritec6.x += 5; } if(characterSpeed==2) { if(characterSpeedC6==3) spritec6.x += 1; if(characterSpeedC6==4) spritec6.x += 2; if(characterSpeedC6==5) spritec6.x += 3; if(characterSpeedC6==6) spritec6.x += 4; } if(characterSpeed==3) { if(characterSpeedC6==4) spritec6.x += 1; if(characterSpeedC6==5) spritec6.x += 2; if(characterSpeedC6==6) spritec6.x += 3; } if(characterSpeed==4) { if(characterSpeedC6==5) spritec6.x += 1; if(characterSpeedC6==6) spritec6.x += 2; } if(characterSpeed==5) { if(characterSpeedC6==6) spritec6.x += 1; } } // If player 1 is faster than computer player 6 if(characterSpeedC6characterSpeed) { if(characterSpeed==0) { if(characterSpeedC7==1) spritec7.x += 1; if(characterSpeedC7==2) spritec7.x += 2; if(characterSpeedC7==3) spritec7.x += 3; if(characterSpeedC7==4) spritec7.x += 4; if(characterSpeedC7==5) spritec7.x += 5; if(characterSpeedC7==6) spritec7.x += 6; } if(characterSpeed==1) { if(characterSpeedC7==2) spritec7.x += 1; if(characterSpeedC7==3) spritec7.x += 2; if(characterSpeedC7==4) spritec7.x += 3; if(characterSpeedC7==5) spritec7.x += 4; if(characterSpeedC7==6) spritec7.x += 5; } if(characterSpeed==2) { if(characterSpeedC7==3) spritec7.x += 1; if(characterSpeedC7==4) spritec7.x += 2; if(characterSpeedC7==5) spritec7.x += 3; if(characterSpeedC7==6) spritec7.x += 4; } if(characterSpeed==3) { if(characterSpeedC7==4) spritec7.x += 1; if(characterSpeedC7==5) spritec7.x += 2; if(characterSpeedC7==6) spritec7.x += 3; } if(characterSpeed==4) { if(characterSpeedC7==5) spritec7.x += 1; if(characterSpeedC7==6) spritec7.x += 2; } if(characterSpeed==5) { if(characterSpeedC7==6) spritec7.x += 1; } } // If player 1 is faster than computer player 7 if(characterSpeedC79) { raceTimer2Digit = 0; } framesPerSecondCount2 = 0; } raceTimer3Digit = raceTimer3Digit + 2; if(raceTimer3Digit>9) raceTimer3Digit = 0; break; } } // ------------------------------------ // FUNCTION TO SET THE BEST TIME VALUE // ------------------------------------ void AssignBestTime() { bestTime1Digit = finishTime1Digitp1; bestTime2Digit = finishTime2Digitp1; bestTime3Digit = finishTime3Digitp1; } // --------------------------------------------- // FUNCTION TO SET THE FINISH TIME FOR PLAYER 1 // --------------------------------------------- void SetFinishTimeP1() { finishTime1Digitp1 = raceTimer1Digit; finishTime2Digitp1 = raceTimer2Digit; finishTime3Digitp1 = raceTimer3Digit; //p1FinishPosition = p1Position; // Sets Finishing position setP1 = 1; } // ------------------------------------------------------ // FUNCTION TO SET THE FINISH TIME FOR COMPUTER PLAYER 2 // ------------------------------------------------------ void SetFinishTimeC1() { finishTime1Digitc1 = raceTimer1Digit; finishTime2Digitc1 = raceTimer2Digit; finishTime3Digitc1 = raceTimer3Digit; //c1FinishPosition = c1Position; setC1 = 1; } // -------------------------------------------------------- // FUNCTION TO SET THE FINISHING TIME OF COMPUTER PLAYER 2 // -------------------------------------------------------- void SetFinishTimeC2() { finishTime1Digitc2 = raceTimer1Digit; finishTime2Digitc2 = raceTimer2Digit; finishTime3Digitc2 = raceTimer3Digit; //c2FinishPosition = c2Position; setC2 = 1; } // -------------------------------------------------------- // FUNCTION TO SET THE FINISHING TIME OF COMPUTER PLAYER 3 // -------------------------------------------------------- void SetFinishTimeC3() { finishTime1Digitc3 = raceTimer1Digit; finishTime2Digitc3 = raceTimer2Digit; finishTime3Digitc3 = raceTimer3Digit; //c3FinishPosition = c3Position; setC3 = 1; } // -------------------------------------------------------- // FUNCTION TO SET THE FINISHING TIME OF COMPUTER PLAYER 4 // -------------------------------------------------------- void SetFinishTimeC4() { finishTime1Digitc4 = raceTimer1Digit; finishTime2Digitc4 = raceTimer2Digit; finishTime3Digitc4 = raceTimer3Digit; //c4FinishPosition = c4Position; setC4 = 1; } // ---------------------------------------------------------------------- // FUNCTION TO CORRECT THE DISTANCE CALCULATION FOR THE COMPUTER PLAYERS // ---------------------------------------------------------------------- void DistanceCalc() { if(characterSpeed==0) { // Player 1 distance[0] = distance[0] + 0; // Computer opponent 1 if(characterSpeedC1==0) distance[1] = distance[1]+0; if(characterSpeedC1==1) distance[1] = distance[1]+1; if(characterSpeedC1==2) distance[1] = distance[1]+2; if(characterSpeedC1==3) distance[1] = distance[1]+3; if(characterSpeedC1==4) distance[1] = distance[1]+4; if(characterSpeedC1==5) distance[1] = distance[1]+5; if(characterSpeedC1==6) distance[1] = distance[1]+6; // Computer opponent 2 if(characterSpeedC2==0) distance[2] = distance[2]+0; if(characterSpeedC2==1) distance[2] = distance[2]+1; if(characterSpeedC2==2) distance[2] = distance[2]+2; if(characterSpeedC2==3) distance[2] = distance[2]+3; if(characterSpeedC2==4) distance[2] = distance[2]+4; if(characterSpeedC2==5) distance[2] = distance[2]+5; if(characterSpeedC2==6) distance[2] = distance[2]+6; // Computer opponent 3 if(characterSpeedC3==0) distance[3] = distance[3]+0; if(characterSpeedC3==1) distance[3] = distance[3]+1; if(characterSpeedC3==2) distance[3] = distance[3]+2; if(characterSpeedC3==3) distance[3] = distance[3]+3; if(characterSpeedC3==4) distance[3] = distance[3]+4; if(characterSpeedC3==5) distance[3] = distance[3]+5; if(characterSpeedC3==6) distance[3] = distance[3]+6; // Computer opponent 4 if(characterSpeedC4==0) distance[4] = distance[4]+0; if(characterSpeedC4==1) distance[4] = distance[4]+1; if(characterSpeedC4==2) distance[4] = distance[4]+2; if(characterSpeedC4==3) distance[4] = distance[4]+3; if(characterSpeedC4==4) distance[4] = distance[4]+4; if(characterSpeedC4==5) distance[4] = distance[4]+5; if(characterSpeedC4==6) distance[4] = distance[4]+6; // Computer opponent 5 if(characterSpeedC5==0) distance[5] = distance[5]+0; if(characterSpeedC5==1) distance[5] = distance[5]+1; if(characterSpeedC5==2) distance[5] = distance[5]+2; if(characterSpeedC5==3) distance[5] = distance[5]+3; if(characterSpeedC5==4) distance[5] = distance[5]+4; if(characterSpeedC5==5) distance[5] = distance[5]+5; if(characterSpeedC5==6) distance[5] = distance[5]+6; // Computer opponent 6 if(characterSpeedC6==0) distance[6] = distance[6]+0; if(characterSpeedC6==1) distance[6] = distance[6]+1; if(characterSpeedC6==2) distance[6] = distance[6]+2; if(characterSpeedC6==3) distance[6] = distance[6]+3; if(characterSpeedC6==4) distance[6] = distance[6]+4; if(characterSpeedC6==5) distance[6] = distance[6]+5; if(characterSpeedC6==6) distance[6] = distance[6]+6; // Computer opponent 7 if(characterSpeedC7==0) distance[7] = distance[7]+0; if(characterSpeedC7==1) distance[7] = distance[7]+1; if(characterSpeedC7==2) distance[7] = distance[7]+2; if(characterSpeedC7==3) distance[7] = distance[7]+3; if(characterSpeedC7==4) distance[7] = distance[7]+4; if(characterSpeedC7==5) distance[7] = distance[7]+5; if(characterSpeedC7==6) distance[7] = distance[7]+6; } if(characterSpeed==1) { // Player 1 distance[0] = distance[0]+1; // Computer opponent 1 if(characterSpeedC1==0) distance[1] = distance[1]+0; if(characterSpeedC1==1) distance[1] = distance[1]+1; if(characterSpeedC1==2) distance[1] = distance[1]+2; if(characterSpeedC1==3) distance[1] = distance[1]+3; if(characterSpeedC1==4) distance[1] = distance[1]+4; if(characterSpeedC1==5) distance[1] = distance[1]+5; if(characterSpeedC1==6) distance[1] = distance[1]+6; // Computer opponent 2 if(characterSpeedC2==0) distance[2] = distance[2]+0; if(characterSpeedC2==1) distance[2] = distance[2]+1; if(characterSpeedC2==2) distance[2] = distance[2]+2; if(characterSpeedC2==3) distance[2] = distance[2]+3; if(characterSpeedC2==4) distance[2] = distance[2]+4; if(characterSpeedC2==5) distance[2] = distance[2]+5; if(characterSpeedC2==6) distance[2] = distance[2]+6; // Computer opponent 3 if(characterSpeedC3==0) distance[3] = distance[3]+0; if(characterSpeedC3==1) distance[3] = distance[3]+1; if(characterSpeedC3==2) distance[3] = distance[3]+2; if(characterSpeedC3==3) distance[3] = distance[3]+3; if(characterSpeedC3==4) distance[3] = distance[3]+4; if(characterSpeedC3==5) distance[3] = distance[3]+5; if(characterSpeedC3==6) distance[3] = distance[3]+6; // Computer opponent 4 if(characterSpeedC4==0) distance[4] = distance[4]+0; if(characterSpeedC4==1) distance[4] = distance[4]+1; if(characterSpeedC4==2) distance[4] = distance[4]+2; if(characterSpeedC4==3) distance[4] = distance[4]+3; if(characterSpeedC4==4) distance[4] = distance[4]+4; if(characterSpeedC4==5) distance[4] = distance[4]+5; if(characterSpeedC4==6) distance[4] = distance[4]+6; // Computer opponent 5 if(characterSpeedC5==0) distance[5] = distance[5]+0; if(characterSpeedC5==1) distance[5] = distance[5]+1; if(characterSpeedC5==2) distance[5] = distance[5]+2; if(characterSpeedC5==3) distance[5] = distance[5]+3; if(characterSpeedC5==4) distance[5] = distance[5]+4; if(characterSpeedC5==5) distance[5] = distance[5]+5; if(characterSpeedC5==6) distance[5] = distance[5]+6; // Computer opponent 6 if(characterSpeedC6==0) distance[6] = distance[6]+0; if(characterSpeedC6==1) distance[6] = distance[6]+1; if(characterSpeedC6==2) distance[6] = distance[6]+2; if(characterSpeedC6==3) distance[6] = distance[6]+3; if(characterSpeedC6==4) distance[6] = distance[6]+4; if(characterSpeedC6==5) distance[6] = distance[6]+5; if(characterSpeedC6==6) distance[6] = distance[6]+6; // Computer opponent 7 if(characterSpeedC7==0) distance[7] = distance[7]+0; if(characterSpeedC7==1) distance[7] = distance[7]+1; if(characterSpeedC7==2) distance[7] = distance[7]+2; if(characterSpeedC7==3) distance[7] = distance[7]+3; if(characterSpeedC7==4) distance[7] = distance[7]+4; if(characterSpeedC7==5) distance[7] = distance[7]+5; if(characterSpeedC7==6) distance[7] = distance[7]+6; } if(characterSpeed==2) { // Player 1 distance[0] = distance[0] + 2; // Computer opponent 1 if(characterSpeedC1==0) distance[1] = distance[1]+0; if(characterSpeedC1==1) distance[1] = distance[1]+1; if(characterSpeedC1==2) distance[1] = distance[1]+2; if(characterSpeedC1==3) distance[1] = distance[1]+3; if(characterSpeedC1==4) distance[1] = distance[1]+4; if(characterSpeedC1==5) distance[1] = distance[1]+5; if(characterSpeedC1==6) distance[1] = distance[1]+6; // Computer opponent 2 if(characterSpeedC2==0) distance[2] = distance[2]+0; if(characterSpeedC2==1) distance[2] = distance[2]+1; if(characterSpeedC2==2) distance[2] = distance[2]+2; if(characterSpeedC2==3) distance[2] = distance[2]+3; if(characterSpeedC2==4) distance[2] = distance[2]+4; if(characterSpeedC2==5) distance[2] = distance[2]+5; if(characterSpeedC2==6) distance[2] = distance[2]+6; // Computer opponent 3 if(characterSpeedC3==0) distance[3] = distance[3]+0; if(characterSpeedC3==1) distance[3] = distance[3]+1; if(characterSpeedC3==2) distance[3] = distance[3]+2; if(characterSpeedC3==3) distance[3] = distance[3]+3; if(characterSpeedC3==4) distance[3] = distance[3]+4; if(characterSpeedC3==5) distance[3] = distance[3]+5; if(characterSpeedC3==6) distance[3] = distance[3]+6; // Computer opponent 4 if(characterSpeedC4==0) distance[4] = distance[4]+0; if(characterSpeedC4==1) distance[4] = distance[4]+1; if(characterSpeedC4==2) distance[4] = distance[4]+2; if(characterSpeedC4==3) distance[4] = distance[4]+3; if(characterSpeedC4==4) distance[4] = distance[4]+4; if(characterSpeedC4==5) distance[4] = distance[4]+5; if(characterSpeedC4==6) distance[4] = distance[4]+6; // Computer opponent 5 if(characterSpeedC5==0) distance[5] = distance[5]+0; if(characterSpeedC5==1) distance[5] = distance[5]+1; if(characterSpeedC5==2) distance[5] = distance[5]+2; if(characterSpeedC5==3) distance[5] = distance[5]+3; if(characterSpeedC5==4) distance[5] = distance[5]+4; if(characterSpeedC5==5) distance[5] = distance[5]+5; if(characterSpeedC5==6) distance[5] = distance[5]+6; // Computer opponent 6 if(characterSpeedC6==0) distance[6] = distance[6]+0; if(characterSpeedC6==1) distance[6] = distance[6]+1; if(characterSpeedC6==2) distance[6] = distance[6]+2; if(characterSpeedC6==3) distance[6] = distance[6]+3; if(characterSpeedC6==4) distance[6] = distance[6]+4; if(characterSpeedC6==5) distance[6] = distance[6]+5; if(characterSpeedC6==6) distance[6] = distance[6]+6; // Computer opponent 7 if(characterSpeedC7==0) distance[7] = distance[7]+0; if(characterSpeedC7==1) distance[7] = distance[7]+1; if(characterSpeedC7==2) distance[7] = distance[7]+2; if(characterSpeedC7==3) distance[7] = distance[7]+3; if(characterSpeedC7==4) distance[7] = distance[7]+4; if(characterSpeedC7==5) distance[7] = distance[7]+5; if(characterSpeedC7==6) distance[7] = distance[7]+6; } if(characterSpeed==3) { // Player 1 distance[0] = distance[0] + 3; // Computer opponent 1 if(characterSpeedC1==0) distance[1] = distance[1]+0; if(characterSpeedC1==1) distance[1] = distance[1]+1; if(characterSpeedC1==2) distance[1] = distance[1]+2; if(characterSpeedC1==3) distance[1] = distance[1]+3; if(characterSpeedC1==4) distance[1] = distance[1]+4; if(characterSpeedC1==5) distance[1] = distance[1]+5; if(characterSpeedC1==6) distance[1] = distance[1]+6; // Computer opponent 2 if(characterSpeedC2==0) distance[2] = distance[2]+0; if(characterSpeedC2==1) distance[2] = distance[2]+1; if(characterSpeedC2==2) distance[2] = distance[2]+2; if(characterSpeedC2==3) distance[2] = distance[2]+3; if(characterSpeedC2==4) distance[2] = distance[2]+4; if(characterSpeedC2==5) distance[2] = distance[2]+5; if(characterSpeedC2==6) distance[2] = distance[2]+6; // Computer opponent 3 if(characterSpeedC3==0) distance[3] = distance[3]+0; if(characterSpeedC3==1) distance[3] = distance[3]+1; if(characterSpeedC3==2) distance[3] = distance[3]+2; if(characterSpeedC3==3) distance[3] = distance[3]+3; if(characterSpeedC3==4) distance[3] = distance[3]+4; if(characterSpeedC3==5) distance[3] = distance[3]+5; if(characterSpeedC3==6) distance[3] = distance[3]+6; // Computer opponent 4 if(characterSpeedC4==0) distance[4] = distance[4]+0; if(characterSpeedC4==1) distance[4] = distance[4]+1; if(characterSpeedC4==2) distance[4] = distance[4]+2; if(characterSpeedC4==3) distance[4] = distance[4]+3; if(characterSpeedC4==4) distance[4] = distance[4]+4; if(characterSpeedC4==5) distance[4] = distance[4]+5; if(characterSpeedC4==6) distance[4] = distance[4]+6; // Computer opponent 5 if(characterSpeedC5==0) distance[5] = distance[5]+0; if(characterSpeedC5==1) distance[5] = distance[5]+1; if(characterSpeedC5==2) distance[5] = distance[5]+2; if(characterSpeedC5==3) distance[5] = distance[5]+3; if(characterSpeedC5==4) distance[5] = distance[5]+4; if(characterSpeedC5==5) distance[5] = distance[5]+5; if(characterSpeedC5==6) distance[5] = distance[5]+6; // Computer opponent 6 if(characterSpeedC6==0) distance[6] = distance[6]+0; if(characterSpeedC6==1) distance[6] = distance[6]+1; if(characterSpeedC6==2) distance[6] = distance[6]+2; if(characterSpeedC6==3) distance[6] = distance[6]+3; if(characterSpeedC6==4) distance[6] = distance[6]+4; if(characterSpeedC6==5) distance[6] = distance[6]+5; if(characterSpeedC6==6) distance[6] = distance[6]+6; // Computer opponent 7 if(characterSpeedC7==0) distance[7] = distance[7]+0; if(characterSpeedC7==1) distance[7] = distance[7]+1; if(characterSpeedC7==2) distance[7] = distance[7]+2; if(characterSpeedC7==3) distance[7] = distance[7]+3; if(characterSpeedC7==4) distance[7] = distance[7]+4; if(characterSpeedC7==5) distance[7] = distance[7]+5; if(characterSpeedC7==6) distance[7] = distance[7]+6; } if(characterSpeed==4) { // Player 1 distance[0] = distance[0] + 4; // Computer opponent 1 if(characterSpeedC1==0) distance[1] = distance[1]+0; if(characterSpeedC1==1) distance[1] = distance[1]+1; if(characterSpeedC1==2) distance[1] = distance[1]+2; if(characterSpeedC1==3) distance[1] = distance[1]+3; if(characterSpeedC1==4) distance[1] = distance[1]+4; if(characterSpeedC1==5) distance[1] = distance[1]+5; if(characterSpeedC1==6) distance[1] = distance[1]+6; // Computer opponent 2 if(characterSpeedC2==0) distance[2] = distance[2]+0; if(characterSpeedC2==1) distance[2] = distance[2]+1; if(characterSpeedC2==2) distance[2] = distance[2]+2; if(characterSpeedC2==3) distance[2] = distance[2]+3; if(characterSpeedC2==4) distance[2] = distance[2]+4; if(characterSpeedC2==5) distance[2] = distance[2]+5; if(characterSpeedC2==6) distance[2] = distance[2]+6; // Computer opponent 3 if(characterSpeedC3==0) distance[3] = distance[3]+0; if(characterSpeedC3==1) distance[3] = distance[3]+1; if(characterSpeedC3==2) distance[3] = distance[3]+2; if(characterSpeedC3==3) distance[3] = distance[3]+3; if(characterSpeedC3==4) distance[3] = distance[3]+4; if(characterSpeedC3==5) distance[3] = distance[3]+5; if(characterSpeedC3==6) distance[3] = distance[3]+6; // Computer opponent 4 if(characterSpeedC4==0) distance[4] = distance[4]+0; if(characterSpeedC4==1) distance[4] = distance[4]+1; if(characterSpeedC4==2) distance[4] = distance[4]+2; if(characterSpeedC4==3) distance[4] = distance[4]+3; if(characterSpeedC4==4) distance[4] = distance[4]+4; if(characterSpeedC4==5) distance[4] = distance[4]+5; if(characterSpeedC4==6) distance[4] = distance[4]+6; // Computer opponent 5 if(characterSpeedC5==0) distance[5] = distance[5]+0; if(characterSpeedC5==1) distance[5] = distance[5]+1; if(characterSpeedC5==2) distance[5] = distance[5]+2; if(characterSpeedC5==3) distance[5] = distance[5]+3; if(characterSpeedC5==4) distance[5] = distance[5]+4; if(characterSpeedC5==5) distance[5] = distance[5]+5; if(characterSpeedC5==6) distance[5] = distance[5]+6; // Computer opponent 6 if(characterSpeedC6==0) distance[6] = distance[6]+0; if(characterSpeedC6==1) distance[6] = distance[6]+1; if(characterSpeedC6==2) distance[6] = distance[6]+2; if(characterSpeedC6==3) distance[6] = distance[6]+3; if(characterSpeedC6==4) distance[6] = distance[6]+4; if(characterSpeedC6==5) distance[6] = distance[6]+5; if(characterSpeedC6==6) distance[6] = distance[6]+6; // Computer opponent 7 if(characterSpeedC7==0) distance[7] = distance[7]+0; if(characterSpeedC7==1) distance[7] = distance[7]+1; if(characterSpeedC7==2) distance[7] = distance[7]+2; if(characterSpeedC7==3) distance[7] = distance[7]+3; if(characterSpeedC7==4) distance[7] = distance[7]+4; if(characterSpeedC7==5) distance[7] = distance[7]+5; if(characterSpeedC7==6) distance[7] = distance[7]+6; } if(characterSpeed==5) { // Player 1 distance[0] = distance[0] + 5; // Computer opponent 1 if(characterSpeedC1==0) distance[1] = distance[1]+0; if(characterSpeedC1==1) distance[1] = distance[1]+1; if(characterSpeedC1==2) distance[1] = distance[1]+2; if(characterSpeedC1==3) distance[1] = distance[1]+3; if(characterSpeedC1==4) distance[1] = distance[1]+4; if(characterSpeedC1==5) distance[1] = distance[1]+5; if(characterSpeedC1==6) distance[1] = distance[1]+6; // Computer opponent 2 if(characterSpeedC2==0) distance[2] = distance[2]+0; if(characterSpeedC2==1) distance[2] = distance[2]+1; if(characterSpeedC2==2) distance[2] = distance[2]+2; if(characterSpeedC2==3) distance[2] = distance[2]+3; if(characterSpeedC2==4) distance[2] = distance[2]+4; if(characterSpeedC2==5) distance[2] = distance[2]+5; if(characterSpeedC2==6) distance[2] = distance[2]+6; // Computer opponent 3 if(characterSpeedC3==0) distance[3] = distance[3]+0; if(characterSpeedC3==1) distance[3] = distance[3]+1; if(characterSpeedC3==2) distance[3] = distance[3]+2; if(characterSpeedC3==3) distance[3] = distance[3]+3; if(characterSpeedC3==4) distance[3] = distance[3]+4; if(characterSpeedC3==5) distance[3] = distance[3]+5; if(characterSpeedC3==6) distance[3] = distance[3]+6; // Computer opponent 4 if(characterSpeedC4==0) distance[4] = distance[4]+0; if(characterSpeedC4==1) distance[4] = distance[4]+1; if(characterSpeedC4==2) distance[4] = distance[4]+2; if(characterSpeedC4==3) distance[4] = distance[4]+3; if(characterSpeedC4==4) distance[4] = distance[4]+4; if(characterSpeedC4==5) distance[4] = distance[4]+5; if(characterSpeedC4==6) distance[4] = distance[4]+6; // Computer opponent 5 if(characterSpeedC5==0) distance[5] = distance[5]+0; if(characterSpeedC5==1) distance[5] = distance[5]+1; if(characterSpeedC5==2) distance[5] = distance[5]+2; if(characterSpeedC5==3) distance[5] = distance[5]+3; if(characterSpeedC5==4) distance[5] = distance[5]+4; if(characterSpeedC5==5) distance[5] = distance[5]+5; if(characterSpeedC5==6) distance[5] = distance[5]+6; // Computer opponent 6 if(characterSpeedC6==0) distance[6] = distance[6]+0; if(characterSpeedC6==1) distance[6] = distance[6]+1; if(characterSpeedC6==2) distance[6] = distance[6]+2; if(characterSpeedC6==3) distance[6] = distance[6]+3; if(characterSpeedC6==4) distance[6] = distance[6]+4; if(characterSpeedC6==5) distance[6] = distance[6]+5; if(characterSpeedC6==6) distance[6] = distance[6]+6; // Computer opponent 7 if(characterSpeedC7==0) distance[7] = distance[7]+0; if(characterSpeedC7==1) distance[7] = distance[7]+1; if(characterSpeedC7==2) distance[7] = distance[7]+2; if(characterSpeedC7==3) distance[7] = distance[7]+3; if(characterSpeedC7==4) distance[7] = distance[7]+4; if(characterSpeedC7==5) distance[7] = distance[7]+5; if(characterSpeedC7==6) distance[7] = distance[7]+6; } if(characterSpeed==6) { // Player 1 distance[0] = distance[0] + 6; // Computer opponent 1 if(characterSpeedC1==0) distance[1] = distance[1]+0; if(characterSpeedC1==1) distance[1] = distance[1]+1; if(characterSpeedC1==2) distance[1] = distance[1]+2; if(characterSpeedC1==3) distance[1] = distance[1]+3; if(characterSpeedC1==4) distance[1] = distance[1]+4; if(characterSpeedC1==5) distance[1] = distance[1]+5; if(characterSpeedC1==6) distance[1] = distance[1]+6; // Computer opponent 2 if(characterSpeedC2==0) distance[2] = distance[2]+0; if(characterSpeedC2==1) distance[2] = distance[2]+1; if(characterSpeedC2==2) distance[2] = distance[2]+2; if(characterSpeedC2==3) distance[2] = distance[2]+3; if(characterSpeedC2==4) distance[2] = distance[2]+4; if(characterSpeedC2==5) distance[2] = distance[2]+5; if(characterSpeedC2==6) distance[2] = distance[2]+6; // Computer opponent 3 if(characterSpeedC3==0) distance[3] = distance[3]+0; if(characterSpeedC3==1) distance[3] = distance[3]+1; if(characterSpeedC3==2) distance[3] = distance[3]+2; if(characterSpeedC3==3) distance[3] = distance[3]+3; if(characterSpeedC3==4) distance[3] = distance[3]+4; if(characterSpeedC3==5) distance[3] = distance[3]+5; if(characterSpeedC3==6) distance[3] = distance[3]+6; // Computer opponent 4 if(characterSpeedC4==0) distance[4] = distance[4]+0; if(characterSpeedC4==1) distance[4] = distance[4]+1; if(characterSpeedC4==2) distance[4] = distance[4]+2; if(characterSpeedC4==3) distance[4] = distance[4]+3; if(characterSpeedC4==4) distance[4] = distance[4]+4; if(characterSpeedC4==5) distance[4] = distance[4]+5; if(characterSpeedC4==6) distance[4] = distance[4]+6; // Computer opponent 5 if(characterSpeedC5==0) distance[5] = distance[5]+0; if(characterSpeedC5==1) distance[5] = distance[5]+1; if(characterSpeedC5==2) distance[5] = distance[5]+2; if(characterSpeedC5==3) distance[5] = distance[5]+3; if(characterSpeedC5==4) distance[5] = distance[5]+4; if(characterSpeedC5==5) distance[5] = distance[5]+5; if(characterSpeedC5==6) distance[5] = distance[5]+6; // Computer opponent 6 if(characterSpeedC6==0) distance[6] = distance[6]+0; if(characterSpeedC6==1) distance[6] = distance[6]+1; if(characterSpeedC6==2) distance[6] = distance[6]+2; if(characterSpeedC6==3) distance[6] = distance[6]+3; if(characterSpeedC6==4) distance[6] = distance[6]+4; if(characterSpeedC6==5) distance[6] = distance[6]+5; if(characterSpeedC6==6) distance[6] = distance[6]+6; // Computer opponent 7 if(characterSpeedC7==0) distance[7] = distance[7]+0; if(characterSpeedC7==1) distance[7] = distance[7]+1; if(characterSpeedC7==2) distance[7] = distance[7]+2; if(characterSpeedC7==3) distance[7] = distance[7]+3; if(characterSpeedC7==4) distance[7] = distance[7]+4; if(characterSpeedC7==5) distance[7] = distance[7]+5; if(characterSpeedC7==6) distance[7] = distance[7]+6; } } // ------------------------------- // BACKGROUND SCROLLING FUNCTION // ------------------------------- void ScrollBg(int charSpeed) { if(charSpeed==0) scrollSpeed = 0; if(charSpeed==1) scrollSpeed = 1; if(charSpeed==2) scrollSpeed = 2; if(charSpeed==3) scrollSpeed = 3; if(charSpeed==4) scrollSpeed = 4; if(charSpeed==5) scrollSpeed = 5; if(charSpeed==6) scrollSpeed = 6; scrollCounter -= scrollSpeed; if(scrollCounter <= -(SCREEN_WIDTH*6)) scrollCounter = 0; } // -------------------------------- // SPRITE INITIALISATION FUNCTION // -------------------------------- void InitSprite() { RECT rect; // Creates a rectangular structure around the sprites GsIMAGE tim_info; // Structure for holding all the information relevant to the TIM files GsGetTimInfo((u_long *)(SPRITE_ADDRESS1+4),&tim_info); /* Gets all the information needed about the TIM files */ // Loads the sprite into the frame buffer rect.x = tim_info.px; // x position of sprite rect.y = tim_info.py; // y position of sprite rect.w = tim_info.pw; // width of sprite rect.h = tim_info.ph; // height of sprite LoadImage(&rect,tim_info.pixel); // Loads all of the above into the frame buffer // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; // x position of CLUT rect.y = tim_info.cy; // y position of CLUT rect.w = tim_info.cw; // width of the CLUT rect.h = tim_info.ch; // height of the CLUT LoadImage(&rect,tim_info.clut); // Loads all of the above into the frame buffer } // switch statement to initialise the structure of the sprite switch(tim_info.pmode) { // If the sprite is 4-bit case 0x08: spritep1.attribute = 0x00000000; spritep1.w = (tim_info.pw*4)/4; spritep1.tpage = GetTPage(0,0,tim_info.px,tim_info.py); break; // If the sprite is 8-bit case 0x09: spritep1.attribute = 0x01000000; spritep1.w = (tim_info.pw*2)/4; spritep1.tpage = GetTPage(1,0,tim_info.px,tim_info.py); break; // If the sprite is 16-bit default: spritep1.attribute = 0x02000000; spritep1.w = tim_info.pw/4; spritep1.tpage = GetTPage(2,0,tim_info.px,tim_info.py); break; } spritep1.x = SCREEN_POSITION_X_P1; // Sprite position on screen - x axis spritep1.y = SCREEN_POSITION_Y_P1; // Sprite position on screen - y axis spritep1.h = SPRITE1_HEIGHT; // Height of the sprite spritep1.u = 0; // Texture page offset - x axis spritep1.v = 0; // Texture page offset - y axis spritep1.cx = tim_info.cx; // CLUT x axis position spritep1.cy = tim_info.cy; // CLUT y axis position spritep1.r = 128; // Screen tint red, 128=normal spritep1.g = 128; // Screen tint green, 128=normal spritep1.b = 128; // Screen tint blue, 128=normal spritep1.mx = 0; // Sets display point - x axis spritep1.my = 0; // Sets display point - y axis spritep1.scalex = ONE; // Sets scale ratio to 1:1 on the x axis spritep1.scaley = ONE; // Sets scale ratio to 1:1 on the y axis spritep1.rotate = 0; // Sets sprite rotation to off DrawSync(0); // Waits for all the above to finish before continuing printf("Player 1 sprite loaded\n"); /* Sends text to the PC screen when sprites have loaded */ } // -------------------------------------------- // FUNCTION TO LOAD COMPUTER PLAYER TWO SPRITE // -------------------------------------------- void InitSpriteComp() { RECT rect; // Creates a rectangular structure around the sprites GsIMAGE tim_info; // Structure for holding all the information relevant to the TIM files GsGetTimInfo((u_long *)(SPRITE_ADDRESS1+4),&tim_info); /* Gets all the information needed about the TIM files */ // Loads the sprite into the frame buffer rect.x = tim_info.px; // x position of sprite rect.y = tim_info.py; // y position of sprite rect.w = tim_info.pw; // width of sprite rect.h = tim_info.ph; // height of sprite LoadImage(&rect,tim_info.pixel); // Loads all of the above into the frame buffer // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; // x position of CLUT rect.y = tim_info.cy; // y position of CLUT rect.w = tim_info.cw; // width of the CLUT rect.h = tim_info.ch; // height of the CLUT LoadImage(&rect,tim_info.clut); // Loads all of the above into the frame buffer } // switch statement to initialise the structure of the sprite switch(tim_info.pmode) { // If the sprite is 4-bit case 0x08: spritec1.attribute = 0x00000000; spritec1.w = (tim_info.pw*4)/4; spritec1.tpage = GetTPage(0,0,tim_info.px,tim_info.py); break; // If the sprite is 8-bit case 0x09: spritec1.attribute = 0x01000000; spritec1.w = (tim_info.pw*2)/4; spritec1.tpage = GetTPage(1,0,tim_info.px,tim_info.py); break; // If the sprite is 16-bit default: spritec1.attribute = 0x02000000; spritec1.w = tim_info.pw/4; spritec1.tpage = GetTPage(2,0,tim_info.px,tim_info.py); break; } spritec1.x = SCREEN_POSITION_X_C1; // Sprite position on screen - x axis spritec1.y = SCREEN_POSITION_Y_C1; // Sprite position on screen - y axis spritec1.h = SPRITE2_HEIGHT; // Height of the sprite spritec1.u = 0; // Texture page offset - x axis spritec1.v = SPRITE1_HEIGHT; // Texture page offset - y axis spritec1.cx = tim_info.cx; // CLUT x axis position spritec1.cy = tim_info.cy; // CLUT y axis position spritec1.r = 128; // Screen tint red, 128=normal spritec1.g = 128; // Screen tint green, 128=normal spritec1.b = 128; // Screen tint blue, 128=normal spritec1.mx = 0; // Sets display point - x axis spritec1.my = 0; // Sets display point - y axis spritec1.scalex = ONE; // Sets scale ratio to 1:1 on the x axis spritec1.scaley = ONE; // Sets scale ratio to 1:1 on the y axis spritec1.rotate = 0; // Sets sprite rotation to off DrawSync(0); // Waits for all the above to finish before continuing printf("Computer character 1 loaded\n"); /* Sends text to the PC screen when sprites have loaded */ } // ------------------------------------------------------ // FUNCTION TO LOAD IN THE 2nd COMPUTER CHARACTER SPRITE // ------------------------------------------------------ void InitSpriteComp2() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS1+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the sprite switch(tim_info.pmode) { // 4-bit sprite case 0x08: spritec2.attribute = 0x00000000; spritec2.w = (tim_info.pw*4)/4; spritec2.tpage = GetTPage(0,0,tim_info.px,tim_info.py); break; // 8-bit sprite case 0x09: spritec2.attribute = 0x01000000; spritec2.w = (tim_info.pw*2)/4; spritec2.tpage = GetTPage(1,0,tim_info.px,tim_info.py); break; // 16-bit sprite default: spritec2.attribute = 0x02000000; spritec2.w = (tim_info.pw)/4; spritec2.tpage = GetTPage(2,0,tim_info.px,tim_info.py); break; } spritec2.x = SCREEN_POSITION_X_C2; spritec2.y = SCREEN_POSITION_Y_C2; spritec2.h = SPRITE2_HEIGHT; spritec2.u = 0; spritec2.v = SPRITE1_HEIGHT; spritec2.cx = tim_info.cx; spritec2.cy = tim_info.cy; spritec2.r = 128; spritec2.g = 128; spritec2.b = 128; spritec2.mx = 0; spritec2.my = 0; spritec2.scalex = ONE; spritec2.scaley = ONE; spritec2.rotate = 0; DrawSync(0); printf("Computer character 2 loaded\n"); } // ---------------------------------------------- // FUNCTION TO LOAD THE THIRD COMPUTER CHARACTER // ---------------------------------------------- void InitSpriteComp3() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS1+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the sprite switch(tim_info.pmode) { // 4-bit sprite case 0x08: spritec3.attribute = 0x00000000; spritec3.w = (tim_info.pw*4)/4; spritec3.tpage = GetTPage(0,0,tim_info.px,tim_info.py); break; // 8-bit sprite case 0x09: spritec3.attribute = 0x01000000; spritec3.w = (tim_info.pw*2)/4; spritec3.tpage = GetTPage(1,0,tim_info.px,tim_info.py); break; // 16-bit sprite default: spritec3.attribute = 0x02000000; spritec3.w = (tim_info.pw)/4; spritec3.tpage = GetTPage(2,0,tim_info.px,tim_info.py); break; } spritec3.x = SCREEN_POSITION_X_C3; spritec3.y = SCREEN_POSITION_Y_C3; spritec3.h = SPRITE2_HEIGHT; spritec3.u = 0; spritec3.v = SPRITE1_HEIGHT; spritec3.cx = tim_info.cx; spritec3.cy = tim_info.cy; spritec3.r = 128; spritec3.g = 128; spritec3.b = 128; spritec3.mx = 0; spritec3.my = 0; spritec3.scalex = ONE; spritec3.scaley = ONE; spritec3.rotate = 0; DrawSync(0); printf("Computer character 3 loaded\n"); } // ------------------------------- // LOAD FOURTH COMPUTER CHARACTER // ------------------------------- void InitSpriteComp4() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS1+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the sprite switch(tim_info.pmode) { // 4-bit sprite case 0x08: spritec4.attribute = 0x00000000; spritec4.w = (tim_info.pw*4)/4; spritec4.tpage = GetTPage(0,0,tim_info.px,tim_info.py); break; // 8-bit sprite case 0x09: spritec4.attribute = 0x01000000; spritec4.w = (tim_info.pw*2)/4; spritec4.tpage = GetTPage(1,0,tim_info.px,tim_info.py); break; // 16-bit sprite default: spritec4.attribute = 0x02000000; spritec4.w = (tim_info.pw)/4; spritec4.tpage = GetTPage(2,0,tim_info.px,tim_info.py); break; } spritec4.x = SCREEN_POSITION_X_C4; spritec4.y = SCREEN_POSITION_Y_C4; spritec4.h = SPRITE2_HEIGHT; spritec4.u = 0; spritec4.v = SPRITE1_HEIGHT; spritec4.cx = tim_info.cx; spritec4.cy = tim_info.cy; spritec4.r = 128; spritec4.g = 128; spritec4.b = 128; spritec4.mx = 0; spritec4.my = 0; spritec4.scalex = ONE; spritec4.scaley = ONE; spritec4.rotate = 0; DrawSync(0); printf("Computer character 4 loaded\n"); } // -------------------------- // LOAD COMPUTER CHARACTER 5 // -------------------------- void InitSpriteComp5() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS1+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the sprite switch(tim_info.pmode) { // 4-bit sprite case 0x08: spritec5.attribute = 0x00000000; spritec5.w = (tim_info.pw*4)/4; spritec5.tpage = GetTPage(0,0,tim_info.px,tim_info.py); break; // 8-bit sprite case 0x09: spritec5.attribute = 0x01000000; spritec5.w = (tim_info.pw*2)/4; spritec5.tpage = GetTPage(1,0,tim_info.px,tim_info.py); break; // 16-bit sprite default: spritec5.attribute = 0x02000000; spritec5.w = (tim_info.pw)/4; spritec5.tpage = GetTPage(2,0,tim_info.px,tim_info.py); break; } spritec5.x = SCREEN_POSITION_X_C5; spritec5.y = SCREEN_POSITION_Y_C5; spritec5.h = SPRITE2_HEIGHT; spritec5.u = 0; spritec5.v = SPRITE1_HEIGHT; spritec5.cx = tim_info.cx; spritec5.cy = tim_info.cy; spritec5.r = 128; spritec5.g = 128; spritec5.b = 128; spritec5.mx = 0; spritec5.my = 0; spritec5.scalex = ONE; spritec5.scaley = ONE; spritec5.rotate = 0; DrawSync(0); printf("Computer character 5 loaded\n"); } // -------------------------- // LOAD COMPUTER CHARACTER 6 // -------------------------- void InitSpriteComp6() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS1+4),&tim_info); // Load Sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Load the CLUT into the frame buffer - if one is present if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the sprite switch(tim_info.pmode) { // 4-bit sprite case 0x08: spritec6.attribute = 0x00000000; spritec6.w = (tim_info.pw*4)/4; spritec6.tpage = GetTPage(0,0,tim_info.px,tim_info.py); break; // 8-bit sprite case 0x09: spritec6.attribute = 0x01000000; spritec6.w = (tim_info.pw*2)/4; spritec6.tpage = GetTPage(1,0,tim_info.px,tim_info.py); break; // 16-bit sprite default: spritec6.attribute = 0x02000000; spritec6.w = (tim_info.pw)/4; spritec6.tpage = GetTPage(2,0,tim_info.px,tim_info.py); break; } spritec6.x = SCREEN_POSITION_X_C6; spritec6.y = SCREEN_POSITION_Y_C6; spritec6.h = SPRITE2_HEIGHT; spritec6.u = 0; spritec6.v = SPRITE1_HEIGHT; spritec6.cx = tim_info.cx; spritec6.cy = tim_info.cy; spritec6.r = 128; spritec6.g = 128; spritec6.b = 128; spritec6.mx = 0; spritec6.my = 0; spritec6.scalex = ONE; spritec6.scaley = ONE; spritec6.rotate = 0; DrawSync(0); printf("Computer character 6 loaded\n"); } // -------------------------- // LOAD COMPUTER CHARACTER 7 // -------------------------- void InitSpriteComp7() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS1+4),&tim_info); // Load Sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Load the CLUT into the frame buffer - if one is present if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the sprite switch(tim_info.pmode) { // 4-bit sprite case 0x08: spritec7.attribute = 0x00000000; spritec7.w = (tim_info.pw*4)/4; spritec7.tpage = GetTPage(0,0,tim_info.px,tim_info.py); break; // 8-bit sprite case 0x09: spritec7.attribute = 0x01000000; spritec7.w = (tim_info.pw*2)/4; spritec7.tpage = GetTPage(1,0,tim_info.px,tim_info.py); break; // 16-bit sprite default: spritec7.attribute = 0x02000000; spritec7.w = (tim_info.pw)/4; spritec7.tpage = GetTPage(2,0,tim_info.px,tim_info.py); break; } spritec7.x = SCREEN_POSITION_X_C7; spritec7.y = SCREEN_POSITION_Y_C7; spritec7.h = SPRITE2_HEIGHT; spritec7.u = 0; spritec7.v = SPRITE1_HEIGHT; spritec7.cx = tim_info.cx; spritec7.cy = tim_info.cy; spritec7.r = 128; spritec7.g = 128; spritec7.b = 128; spritec7.mx = 0; spritec7.my = 0; spritec7.scalex = ONE; spritec7.scaley = ONE; spritec7.rotate = 0; DrawSync(0); printf("Computer character 7 loaded\n"); } // --------------------------------------------------------------------------- // FUNCTION TO LOAD THE PLAYER 1 TEXT FOR THE IN-GAME INFORMATION DISPLAY BAR // --------------------------------------------------------------------------- void InitDispBar1() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Load the sprite structure for the 8-bit sprite playerbar1.tpage = GetTPage(1,0,tim_info.px,tim_info.py); playerbar1.attribute = 0x01000000; playerbar1.x = PLAYERBAR1_XPOS; // Position the 'player 1' part of the titlebar in the top left corner, leaving a small gap playerbar1.y = PLAYERBAR1_YPOS; playerbar1.w = PLAYERBAR1_WIDTH; playerbar1.h = PLAYERBAR_HEIGHT; playerbar1.u = 0; playerbar1.v = 0; playerbar1.cx = tim_info.cx; playerbar1.cy = tim_info.cy; playerbar1.r = 128; playerbar1.g = 128; playerbar1.b = 128; playerbar1.mx = 0; playerbar1.my = 0; playerbar1.scalex = ONE; playerbar1.scaley = ONE; playerbar1.rotate = 0; DrawSync(0); } // --------------------------------------------------------------------------- // FUNCTION TO LOAD THE 'PLAYER 2' PART OF THE PLAYER INFORMATION DISPLAY BAR // --------------------------------------------------------------------------- void InitDispBar2() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite playerbar2.attribute = 0x01000000; playerbar2.tpage = GetTPage(1,0,tim_info.px,tim_info.py); playerbar2.x = PLAYERBAR1_WIDTH + 1; // Position the second part after the first - +1 leaves a small gap playerbar2.y = 0; playerbar2.w = PLAYERBAR2_WIDTH; playerbar2.h = PLAYERBAR_HEIGHT; playerbar2.u = PLAYERBAR1_WIDTH; playerbar2.v = 0; playerbar2.cx = tim_info.cx; playerbar2.cy = tim_info.cy; playerbar2.r = 128; playerbar2.g = 128; playerbar2.b = 128; playerbar2.mx = 0; playerbar2.my = 0; playerbar2.scalex = ONE; playerbar2.scaley = ONE; playerbar2.rotate = 0; DrawSync(0); } // ---------------------------------------------------------------------- // FUNCTION TO LOAD THE THIRD PART OF THE PLAYER INFORMATION DISPLAY BAR // ---------------------------------------------------------------------- void InitDispBar3() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite playerbar3.attribute = 0x01000000; playerbar3.tpage = GetTPage(1,0,tim_info.px,tim_info.py); playerbar3.x = (PLAYERBAR1_WIDTH + PLAYERBAR2_WIDTH) + 1; // Position the third part after the first two playerbar3.y = 0; playerbar3.w = PLAYERBAR3_WIDTH; playerbar3.h = PLAYERBAR_HEIGHT; playerbar3.u = PLAYERBAR1_WIDTH + PLAYERBAR2_WIDTH; playerbar3.v = 0; playerbar3.cx = tim_info.cx; playerbar3.cy = tim_info.cy; playerbar3.r = 128; playerbar3.g = 128; playerbar3.b = 128; playerbar3.mx = 0; playerbar3.my = 0; playerbar3.scalex = ONE; playerbar3.scaley = ONE; playerbar3.rotate = 0; DrawSync(0); } // ---------------------------------------------------------------------- // FUNCTION TO LOAD THE FINAL PART OF THE PLAYER INFORMATION DISPLAY BAR // ---------------------------------------------------------------------- void InitDispBar4() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite playerbar4.attribute = 0x01000000; playerbar4.tpage = GetTPage(1,0,tim_info.px,tim_info.py); playerbar4.x = (PLAYERBAR1_WIDTH + PLAYERBAR2_WIDTH + PLAYERBAR3_WIDTH) + 1; // Position the final part after the others playerbar4.y = 0; playerbar4.w = PLAYERBAR4_WIDTH; playerbar4.h = PLAYERBAR_HEIGHT; playerbar4.u = 0; playerbar4.v = PLAYERBAR_HEIGHT; playerbar4.cx = tim_info.cx; playerbar4.cy = tim_info.cy; playerbar4.r = 128; playerbar4.g = 128; playerbar4.b = 128; playerbar4.mx = 0; playerbar4.my = 0; playerbar4.scalex = ONE; playerbar4.scaley = ONE; playerbar4.rotate = 0; DrawSync(0); } // ------------------------------------------------------ // FUNCTION TO LOAD THE 'GAME TIME' SCREEN DISPLAY IMAGE // ------------------------------------------------------ void InitTimeBar() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite timebar.attribute = 0x01000000; timebar.w = TIMEBAR_WIDTH; timebar.tpage = GetTPage(1,0,tim_info.px,tim_info.py); timebar.x = TIMEBAR_X; // Position the 'game time' display image in the bottom right-hand corner of the screen timebar.y = TIMEBAR_Y; timebar.h = PLAYERBAR_HEIGHT; timebar.u = PLAYERBAR_WIDTH; timebar.v = PLAYERBAR_HEIGHT; timebar.cx = tim_info.cx; timebar.cy = tim_info.cy; timebar.r = 128; timebar.g = 128; timebar.b = 128; timebar.mx = 0; timebar.my = 0; timebar.scalex = ONE; timebar.scaley = ONE; timebar.rotate = 0; DrawSync(0); printf("Game Time Display Image Loaded\n"); } // --------------------------------------------- // FUNCTION TO LOAD THE MAIN TITLE SCREEN IMAGE // --------------------------------------------- void InitTitle() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite titleimg.attribute = 0x01000000; titleimg.w = TITLE_TIM_WIDTH; titleimg.tpage = GetTPage(1,0,tim_info.px,tim_info.py); titleimg.x = TITLE_POSITIONX; // Position the 'game time' display image in the bottom right-hand corner of the screen titleimg.y = TITLE_POSITIONY; titleimg.h = TITLE_TIM_HEIGHT; titleimg.u = TITLE_TIM_X_POSITION; titleimg.v = TITLE_TIM_Y_POSITION; titleimg.cx = tim_info.cx; titleimg.cy = tim_info.cy; titleimg.r = 128; titleimg.g = 128; titleimg.b = 128; titleimg.mx = TITLE_TIM_WIDTH/2; titleimg.my = TITLE_TIM_HEIGHT/2; titleimg.scalex = 0; titleimg.scaley = 0; titleimg.rotate = 0; DrawSync(0); printf("Game Title Image Loaded\n"); } // ---------------------------------------------- // FUNCTION TO LOAD THE MAIN 'PRESS START' IMAGE // ---------------------------------------------- void InitStart() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS4+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite startimg.attribute = 0x00000000; startimg.w = START_TIM_WIDTH; startimg.tpage = GetTPage(0,0,tim_info.px,tim_info.py); startimg.x = START_X_VALUE; // Position the 'press start' image startimg.y = START_Y_VALUE; startimg.h = START_TIM_HEIGHT; startimg.u = START_TIM_X_POSITION; startimg.v = START_TIM_Y_POSITION; startimg.cx = tim_info.cx; startimg.cy = tim_info.cy; startimg.r = 128; startimg.g = 128; startimg.b = 128; startimg.mx = 0; startimg.my = 0; startimg.scalex = ONE; startimg.scaley = ONE; startimg.rotate = 0; DrawSync(0); } // ------------------------------------------------------------------ // FUNCTION TO LOAD THE GRASS IMAGE THAT APPEARS ON THE TITLE SCREEN // ------------------------------------------------------------------ void InitGrass() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS4+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 4-bit sprite grassimg.attribute = 0x00000000; grassimg.w = GRASS_WIDTH; grassimg.tpage = GetTPage(0,0,tim_info.px,tim_info.py); grassimg.x = GRASS_SCREEN_POSITION_X; // Position the grass image grassimg.y = GRASS_SCREEN_POSITION_Y; grassimg.h = GRASS_HEIGHT; grassimg.u = GRASS_U_POSITION; grassimg.v = GRASS_V_POSITION; grassimg.cx = tim_info.cx; grassimg.cy = tim_info.cy; grassimg.r = 128; grassimg.g = 128; grassimg.b = 128; grassimg.mx = 0; grassimg.my = 0; grassimg.scalex = ONE; grassimg.scaley = ONE; grassimg.rotate = 0; DrawSync(0); } // ------------------------------- // FUNCTION TO LOAD THE '3' IMAGE // ------------------------------- void InitThreeImage() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite threeimg.attribute = 0x01000000; threeimg.w = THREE_WIDTH; threeimg.tpage = GetTPage(1,0,tim_info.px,tim_info.py); threeimg.x = NUMBER_SCREEN_POSITION_X; // Screen position of the '3' image threeimg.y = NUMBER_SCREEN_POSITION_Y; threeimg.h = THREE_HEIGHT; threeimg.u = THREE_TEXTURE_POSITION_X; threeimg.v = THREE_TEXTURE_POSITION_Y; threeimg.cx = tim_info.cx; threeimg.cy = tim_info.cy; threeimg.r = 128; threeimg.g = 128; threeimg.b = 128; threeimg.mx = threeimg.w/2; threeimg.my = threeimg.h/2; threeimg.scalex = INIT_X_SCALE_VALUE; // ONE threeimg.scaley = INIT_Y_SCALE_VALUE; // ONE threeimg.rotate = 0; DrawSync(0); } // ------------------------------- // FUNCTION TO LOAD THE '2' IMAGE // ------------------------------- void InitTwoImage() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite twoimg.attribute = 0x01000000; twoimg.w = TWO_WIDTH; twoimg.tpage = GetTPage(1,0,tim_info.px,tim_info.py); twoimg.x = NUMBER_SCREEN_POSITION_X; // Screen position of the '2' image twoimg.y = NUMBER_SCREEN_POSITION_Y; twoimg.h = TWO_HEIGHT; twoimg.u = TWO_TEXTURE_POSITION_X; twoimg.v = TWO_TEXTURE_POSITION_Y; twoimg.cx = tim_info.cx; twoimg.cy = tim_info.cy; twoimg.r = 128; twoimg.g = 128; twoimg.b = 128; twoimg.mx = twoimg.w/2; twoimg.my = twoimg.h/2; twoimg.scalex = INIT_X_SCALE_VALUE; // ONE twoimg.scaley = INIT_Y_SCALE_VALUE; // ONE twoimg.rotate = 0; DrawSync(0); } // ------------------------------- // FUNCTION TO LOAD THE '1' IMAGE // ------------------------------- void InitOneImage() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite oneimg.attribute = 0x01000000; oneimg.w = ONE_WIDTH; oneimg.tpage = GetTPage(1,0,tim_info.px,tim_info.py); oneimg.x = NUMBER_SCREEN_POSITION_X; // Screen position of the '1' image oneimg.y = NUMBER_SCREEN_POSITION_Y; oneimg.h = ONE_HEIGHT; oneimg.u = ONE_TEXTURE_POSITION_X; oneimg.v = ONE_TEXTURE_POSITION_Y; oneimg.cx = tim_info.cx; oneimg.cy = tim_info.cy; oneimg.r = 128; oneimg.g = 128; oneimg.b = 128; oneimg.mx = oneimg.w/2; oneimg.my = oneimg.h/2; oneimg.scalex = INIT_X_SCALE_VALUE; // ONE oneimg.scaley = INIT_Y_SCALE_VALUE; // ONE oneimg.rotate = 0; DrawSync(0); } // ------------------------------- // FUNCTION TO LOAD THE 'GO!' IMAGE // ------------------------------- void InitGoImage() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite goimg.attribute = 0x01000000; goimg.w = GO_WIDTH; goimg.tpage = GetTPage(1,0,tim_info.px,tim_info.py); goimg.x = GO_SCREEN_POSITION_X; // Screen position of 'GO!' image goimg.y = GO_SCREEN_POSITION_Y; goimg.h = GO_HEIGHT; goimg.u = GO_TEXTURE_POSITION_X; goimg.v = GO_TEXTURE_POSITION_Y; goimg.cx = tim_info.cx; goimg.cy = tim_info.cy; goimg.r = 128; goimg.g = 128; goimg.b = 128; goimg.mx = goimg.w/2; goimg.my = goimg.h/2; goimg.scalex = INIT_X_SCALE_VALUE; // ONE goimg.scaley = INIT_Y_SCALE_VALUE; // ONE goimg.rotate = 0; DrawSync(0); } // ---------------------------------------------------- // FUNCTION TO LOAD THE RED PLAYER ONE POSITION VALUES // ---------------------------------------------------- void InitPositionNumP1() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS3+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite player1pos.attribute = 0x01000000; player1pos.w = POS_WIDTH; player1pos.tpage = GetTPage(1,0,tim_info.px,tim_info.py); player1pos.x = P1_XPOSITION; // Screen position of position images player1pos.y = P1_YPOSITION; player1pos.h = POS_HEIGHT; player1pos.u = TEXTUREPAGEU_P1; player1pos.v = TEXTUREPAGEV_P1; player1pos.cx = tim_info.cx; player1pos.cy = tim_info.cy; player1pos.r = 128; player1pos.g = 128; player1pos.b = 128; player1pos.mx = player1pos.w/(9*2); // Divided by 18 as there are nine different images and the centre of the first on is wnated player1pos.my = player1pos.h/2; player1pos.scalex = ONE; player1pos.scaley = ONE; player1pos.rotate = 0; DrawSync(0); } // ----------------------------------------------------- // FUNCTION TO LOAD THE BLUE PLAYER TWO POSITION VALUES // ----------------------------------------------------- void InitPositionNumP2() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS3+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite player2pos.attribute = 0x01000000; player2pos.w = POS_WIDTH; player2pos.tpage = GetTPage(1,0,tim_info.px,tim_info.py); player2pos.x = P2_XPOSITION; // Screen position of position images player2pos.y = P2_YPOSITION; player2pos.h = POS_HEIGHT; player2pos.u = TEXTUREPAGEU_P2; player2pos.v = TEXTUREPAGEV_P2; player2pos.cx = tim_info.cx; player2pos.cy = tim_info.cy; player2pos.r = 128; player2pos.g = 128; player2pos.b = 128; player2pos.mx = player2pos.w/(9*2); // Divided by 18 as there are nine different images and the centre of the first on is wnated player2pos.my = player2pos.h/2; player2pos.scalex = ONE; player2pos.scaley = ONE; player2pos.rotate = 0; DrawSync(0); } // --------------------------------------------------------- // FUNCTION TO LOAD THE YELLOW PLAYER THREE POSITION VALUES // --------------------------------------------------------- void InitPositionNumP3() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS3+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite player3pos.attribute = 0x01000000; player3pos.w = POS_WIDTH; player3pos.tpage = GetTPage(1,0,tim_info.px,tim_info.py); player3pos.x = P3_XPOSITION; // Screen position of position images player3pos.y = P3_YPOSITION; player3pos.h = POS_HEIGHT; player3pos.u = TEXTUREPAGEU_P3; player3pos.v = TEXTUREPAGEV_P3; player3pos.cx = tim_info.cx; player3pos.cy = tim_info.cy; player3pos.r = 128; player3pos.g = 128; player3pos.b = 128; player3pos.mx = player3pos.w/(9*2); // Divided by 18 as there are nine different images and the centre of the first on is wnated player3pos.my = player3pos.h/2; player3pos.scalex = ONE; player3pos.scaley = ONE; player3pos.rotate = 0; DrawSync(0); } // --------------------------------------------------------- // FUNCTION TO LOAD THE GREEN PLAYER FOUR POSITION VALUES // --------------------------------------------------------- void InitPositionNumP4() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS3+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite player4pos.attribute = 0x01000000; player4pos.w = POS_WIDTH; player4pos.tpage = GetTPage(1,0,tim_info.px,tim_info.py); player4pos.x = P4_XPOSITION; // Screen position of position images player4pos.y = P4_YPOSITION; player4pos.h = POS_HEIGHT; player4pos.u = TEXTUREPAGEU_P4; player4pos.v = TEXTUREPAGEV_P4; player4pos.cx = tim_info.cx; player4pos.cy = tim_info.cy; player4pos.r = 128; player4pos.g = 128; player4pos.b = 128; player4pos.mx = player4pos.w/(9*2); // Divided by 18 as there are nine different images and the centre of the first on is wnated player4pos.my = player4pos.h/2; player4pos.scalex = ONE; player4pos.scaley = ONE; player4pos.rotate = 0; DrawSync(0); } // --------------------------------------------------- // FUNCTION TO LOAD THE SPEED BAR IMAGES FOR PLAYER 1 // --------------------------------------------------- void InitSpeedBar1() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite speedbar1.attribute = 0x01000000; speedbar1.tpage = GetTPage(1,0,tim_info.px,tim_info.py); speedbar1.x = SPEEDBARP1_XPOS; // Screen position of the left arrow speedbar1.y = SPEEDBARP1_YPOS; speedbar1.w = SPEEDBAR_WIDTH; speedbar1.h = SPEEDBAR_HEIGHT; speedbar1.u = SPEEDBAR_UVALUE1; // Sets default speed bar to be the image depicting no speed speedbar1.v = SPEEDBAR_VVALUE1; speedbar1.cx = tim_info.cx; speedbar1.cy = tim_info.cy; speedbar1.r = 128; speedbar1.g = 128; speedbar1.b = 128; speedbar1.mx = speedbar1.w/2; speedbar1.my = speedbar1.h/2; speedbar1.scalex = ONE; speedbar1.scaley = ONE; speedbar1.rotate = 0; DrawSync(0); } // --------------------------------------------------- // FUNCTION TO LOAD THE SPEED BAR IMAGES FOR PLAYER 2 // --------------------------------------------------- void InitSpeedBar2() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite speedbar2.attribute = 0x01000000; speedbar2.tpage = GetTPage(1,0,tim_info.px,tim_info.py); speedbar2.x = SPEEDBARP2_XPOS; // Screen position of the left arrow speedbar2.y = SPEEDBARP2_YPOS; speedbar2.w = SPEEDBAR_WIDTH; speedbar2.h = SPEEDBAR_HEIGHT; speedbar2.u = SPEEDBAR_UVALUE1; // Sets default speed bar to be the image depicting no speed speedbar2.v = SPEEDBAR_VVALUE1; speedbar2.cx = tim_info.cx; speedbar2.cy = tim_info.cy; speedbar2.r = 128; speedbar2.g = 128; speedbar2.b = 128; speedbar2.mx = speedbar2.w/2; speedbar2.my = speedbar2.h/2; speedbar2.scalex = ONE; speedbar2.scaley = ONE; speedbar2.rotate = 0; DrawSync(0); } // --------------------------------------------------- // FUNCTION TO LOAD THE SPEED BAR IMAGES FOR PLAYER 3 // --------------------------------------------------- void InitSpeedBar3() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite speedbar3.attribute = 0x01000000; speedbar3.tpage = GetTPage(1,0,tim_info.px,tim_info.py); speedbar3.x = SPEEDBARP3_XPOS; // Screen position of the left arrow speedbar3.y = SPEEDBARP3_YPOS; speedbar3.w = SPEEDBAR_WIDTH; speedbar3.h = SPEEDBAR_HEIGHT; speedbar3.u = SPEEDBAR_UVALUE1; // Sets default speed bar to be the image depicting no speed speedbar3.v = SPEEDBAR_VVALUE1; speedbar3.cx = tim_info.cx; speedbar3.cy = tim_info.cy; speedbar3.r = 128; speedbar3.g = 128; speedbar3.b = 128; speedbar3.mx = speedbar3.w/2; speedbar3.my = speedbar3.h/2; speedbar3.scalex = ONE; speedbar3.scaley = ONE; speedbar3.rotate = 0; DrawSync(0); } // --------------------------------------------------- // FUNCTION TO LOAD THE SPEED BAR IMAGES FOR PLAYER 4 // --------------------------------------------------- void InitSpeedBar4() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS2+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite speedbar4.attribute = 0x01000000; speedbar4.tpage = GetTPage(1,0,tim_info.px,tim_info.py); speedbar4.x = SPEEDBARP4_XPOS; // Screen position of the left arrow speedbar4.y = SPEEDBARP4_YPOS; speedbar4.w = SPEEDBAR_WIDTH; speedbar4.h = SPEEDBAR_HEIGHT; speedbar4.u = SPEEDBAR_UVALUE1; // Sets default speed bar to be the image depicting no speed speedbar4.v = SPEEDBAR_VVALUE1; speedbar4.cx = tim_info.cx; speedbar4.cy = tim_info.cy; speedbar4.r = 128; speedbar4.g = 128; speedbar4.b = 128; speedbar4.mx = speedbar4.w/2; speedbar4.my = speedbar4.h/2; speedbar4.scalex = ONE; speedbar4.scaley = ONE; speedbar4.rotate = 0; DrawSync(0); } // ---------------------------------------------- // FUNCTION TO LOAD THE 'CONGRATULATIONS!' IMAGE // ---------------------------------------------- void InitCongratImage() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS3+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite congratimg.attribute = 0x01000000; congratimg.tpage = GetTPage(1,0,tim_info.px,tim_info.py); congratimg.x = CONGRAT_XPOS; // Screen position of 'CONGRATULATIONS!' image congratimg.y = CONGRAT_YPOS; congratimg.w = CONGRAT_WIDTH; congratimg.h = CONGRAT_HEIGHT; congratimg.u = 0; congratimg.v = 0; congratimg.cx = tim_info.cx; congratimg.cy = tim_info.cy; congratimg.r = 128; congratimg.g = 128; congratimg.b = 128; congratimg.mx = congratimg.w/2; congratimg.my = congratimg.h/2; congratimg.scalex = ONE; congratimg.scaley = ONE; congratimg.rotate = 0; DrawSync(0); } // ------------------------------------------------------- // FUNCTION TO LOAD THE LEFT ARROW USED ON OPTION SCREENS // ------------------------------------------------------- void InitLeftArrow() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS4+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite leftarrow.attribute = 0x00000000; leftarrow.tpage = GetTPage(0,0,tim_info.px,tim_info.py); leftarrow.x = LEFTARROW_XPOS; // Screen position of the left arrow leftarrow.y = LEFTARROW_YPOS; leftarrow.w = ARROW_WIDTH; leftarrow.h = ARROW_HEIGHT; leftarrow.u = LEFTARROW_UVALUE; leftarrow.v = LEFTARROW_VVALUE; leftarrow.cx = tim_info.cx; leftarrow.cy = tim_info.cy; leftarrow.r = 128; leftarrow.g = 128; leftarrow.b = 128; leftarrow.mx = leftarrow.w/2; leftarrow.my = leftarrow.h/2; leftarrow.scalex = ONE; leftarrow.scaley = ONE; leftarrow.rotate = 0; DrawSync(0); } // ------------------------------------------------------- // FUNCTION TO LOAD THE RIGHT ARROW USED ON OPTION SCREENS // ------------------------------------------------------- void InitRightArrow() { RECT rect; GsIMAGE tim_info; GsGetTimInfo((u_long *)(SPRITE_ADDRESS4+4),&tim_info); // Loads the sprite into the frame buffer rect.x = tim_info.px; rect.y = tim_info.py; rect.w = tim_info.pw; rect.h = tim_info.ph; LoadImage(&rect,tim_info.pixel); // Loads the CLUT into the frame buffer if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; rect.y = tim_info.cy; rect.w = tim_info.cw; rect.h = tim_info.ch; LoadImage(&rect,tim_info.clut); } // Initialise the structure of the 8-bit sprite rightarrow.attribute = 0x00000000; rightarrow.tpage = GetTPage(0,0,tim_info.px,tim_info.py); rightarrow.x = RIGHTARROW_XPOS; // Screen position of the left arrow rightarrow.y = RIGHTARROW_YPOS; rightarrow.w = ARROW_WIDTH; rightarrow.h = ARROW_HEIGHT; rightarrow.u = RIGHTARROW_UVALUE; rightarrow.v = RIGHTARROW_VVALUE; rightarrow.cx = tim_info.cx; rightarrow.cy = tim_info.cy; rightarrow.r = 128; rightarrow.g = 128; rightarrow.b = 128; rightarrow.mx = leftarrow.w/2; rightarrow.my = leftarrow.h/2; rightarrow.scalex = ONE; rightarrow.scaley = ONE; rightarrow.rotate = 0; DrawSync(0); } // ------------------------------- // LOAD IN THE BACKGROUND IMAGES // ------------------------------- void InitBg(GsSPRITE* sprite, long bgAddress) { RECT rect; GsIMAGE tim_info; // Gets the relevant TIM info GsGetTimInfo((u_long *)(bgAddress + 4), &tim_info); // Load the sprite into the frame buffer rect.x = tim_info.px; // x position of image rect.y = tim_info.py; // y position of image rect.w = tim_info.pw; // width of the image rect.h = tim_info.ph; // height of the image LoadImage(&rect,tim_info.pixel); // Loads all of the above into frame buffer // Load the CLUT into the frame buffer, if there is one if((tim_info.pmode>>3) & 0x01) { rect.x = tim_info.cx; // x position of CLUT rect.y = tim_info.cy; // y position of CLUT rect.w = tim_info.cw; // width of the CLUT rect.h = tim_info.ch; // height of the CLUT LoadImage(&rect,tim_info.clut); // loads all of the above into frame buffer } // switch statement to initialise the structure of the image switch(tim_info.pmode) { // If the image is 4-bit... case 0x08: sprite->attribute = 0x00000000; sprite->w = tim_info.pw*4; sprite->tpage = GetTPage(0,0,tim_info.px,tim_info.py); break; // If the image is 8-bit... case 0x09: sprite->attribute = 0x01000000; sprite->w = tim_info.pw*2; sprite->tpage = GetTPage(1,0,tim_info.px,tim_info.py); break; // If the image is 16-bit... default: sprite->attribute = 0x02000000; sprite->w = tim_info.pw; sprite->tpage = GetTPage(2,0,tim_info.px,tim_info.py); break; } // Set up the image position on screen - x axis if(imageNo==0) sprite->x = 0; if((imageNo==1)|(imageNo==2)) sprite->x = 160; if(imageNo==3) sprite->x = 320; sprite->y = 0; // Set up the image position on screen - y axis sprite->h = tim_info.ph; // Height of the image sprite->u = 0; // Texture page offset of image - x axis sprite->v = 0; // Texture page offset of image - y axis sprite->cx = tim_info.cx; // Position of CLUT - x axis sprite->cy = tim_info.cy; // Position of CLUT - y axis sprite->r = 128; // Screen tint red - 128=normal sprite->g = 128; // Screen tint green - 128=normal sprite->b = 128; // Screen tint blue - 128=normal sprite->mx = 0; // Sets center display position of image - x axis sprite->my = 0; // Sets center display position of image - y axis sprite->scalex = ONE; // Sets scale ratio x axis to be 1:1 sprite->scaley = ONE; // Sets scale ratio y axis to be 1:1 sprite->rotate = 0; // Sets sprite rotation to be off DrawSync(0); printf("\nBackground %d Loaded",currentBg); currentBg++; } // ----------------------------------- // PLAYSTATION JOYPAD READING ROUTINE // ----------------------------------- static u_long ReadPads(u_char port) // Function to read what is being pressed on the pads { return(~(*(padBuffer[port]+3)|*(padBuffer[port]+2)<<8)); } // ------------------------------- // JOYPAD INITIALISATION ROUTINE // ------------------------------- static long InitPads() // Function to set up the pads for use { pad1Check = ReadPads(PORT_ONE); pad2Check = ReadPads(PORT_TWO); if((pad1Check & PADselect)&&(pad1Check & PADstart)) // Start and Select exits the game return(99); }