1 /*************************************************************************** 2 In-Game Statistics. 3 - Stage Timers 4 - Route Info 5 - Speed to Score Conversion 6 - Bonus Time Increment 7 8 Copyright Chris White. 9 See license.txt for more details. 10 ***************************************************************************/ 11 12 #pragma once 13 14 #include "outrun.hpp" 15 16 class OStats 17 { 18 public: 19 // Current stage 20 // 0 = Stage 1 21 // 1 = Stage 2 22 // 2 = Stage 3 23 // 3 = Stage 4 24 // 4 = Stage 5 25 // -1 = Bonus Points Section 26 // 27 // A good way to quickly see the end sequence is to set this to '4' and play 28 // through the first level. 29 int8_t cur_stage; 30 31 // Score (Outputs Hex values directly) 32 uint32_t score; 33 34 // Store info on the route taken by the player 35 // 36 // +10 For each stage. 37 // 38 // Then increment by the following when Left Hand route selected at each stage. 39 // 40 // Stage 1 = +8 (1 << 3 - 0) 41 // Stage 2 = +4 (1 << 3 - 1) 42 // Stage 3 = +2 (1 << 3 - 2) 43 // Stage 4 = +1 (1 << 3 - 3) 44 // Stage 5 = Road doesn't split on this stage 45 // 46 // So if we reach Stage 2 (left route) we do 10 + 8 = 18 47 uint16_t route_info; 48 49 // Stores route_info for each stage. Used by course map screen 50 // First entry stores upcoming stage number 51 uint16_t routes[0x8]; 52 53 // Frame Counter Reset/Load Value. 54 // Load frame counter with this value when the counter has decremented and expired. 55 // Note: Values stored and used in hex. 56 int16_t frame_counter; 57 const static int16_t frame_reset = 30; 58 59 // Time Counter (Frames). Counts downwards from 30. 60 // Used in correspondence with 0x60860. 61 // Note: Values stored and used in hex. 62 int16_t time_counter; 63 64 // Extend Play Timer. 65 // 66 // Loaded to 0x80 when EXTEND PLAY! banner should flash 67 int16_t extend_play_timer; 68 69 // Time data array 70 static const uint8_t TIME[]; 71 72 // Counters that increment with each game tick. 73 // Each stage has an independent counter (increased to 15 from 5 to support continuous mode) 74 int16_t stage_counters[15]; 75 76 // Set when game completed 77 bool game_completed; 78 79 const uint8_t* lap_ms; 80 81 // Number of credits inserted 82 uint8_t credits; 83 84 // Each stage has an entry for minutes, seconds and MS. (Extended to 15 from 5 to support continuous mode) 85 uint8_t stage_times[15][3]; 86 87 OStats(void); 88 ~OStats(void); 89 90 void init(bool); 91 92 void clear_stage_times(); 93 void clear_route_info(); 94 95 void do_mini_map(); 96 void do_timers(); 97 void convert_speed_score(uint16_t); 98 void update_score(uint32_t); 99 void init_next_level(); 100 101 private: 102 // Converted Stage Millisecond Value 103 uint8_t ms_value; 104 105 void inc_lap_timer(); 106 }; 107 108 extern OStats ostats; 109