1 /*************************************************************************** 2 Best Outrunners Name Entry & Display. 3 Used in attract mode, and at game end. 4 5 Copyright Chris White. 6 See license.txt for more details. 7 ***************************************************************************/ 8 9 #pragma once 10 11 #include "stdint.hpp" 12 13 struct score_entry 14 { 15 uint32_t score; 16 uint8_t initial1; 17 uint8_t initial2; 18 uint8_t initial3; 19 uint32_t maptiles; 20 uint16_t time; 21 }; 22 23 class OHiScore 24 { 25 public: 26 // Number of score entries in table 27 const static uint8_t NO_SCORES = 20; 28 29 // 20 Score Entries 30 score_entry scores[NO_SCORES]; 31 32 OHiScore(void); 33 ~OHiScore(void); 34 35 void init(); 36 void init_def_scores(); 37 void tick(); 38 void setup_pal_best(); 39 void setup_road_best(); 40 void display_scores(); 41 42 private: 43 const static uint16_t TILE_PROPS = 0x8030; 44 45 // +C : Best OutRunners State 46 uint8_t best_or_state; 47 48 // +14: State of score logic 49 uint8_t state; 50 51 // +16: High Score Position In Table 52 int8_t score_pos; 53 54 // +17 Selected Initial (0-2) 55 int8_t initial_selected; 56 57 // +18: Selected Letter 58 int16_t letter_selected; 59 60 // +1A: Acceleration Value Current 61 int16_t acc_curr; 62 63 // +1C: Acceleration Value Previous 64 int16_t acc_prev; 65 66 // +1E: Steering Value 67 int16_t steer; 68 69 // +22: Flashing counter 70 uint8_t flash; 71 72 // +24: Total number of minicars that have reached destination 73 int8_t dest_total; 74 75 // +26: High Score Table Display Position 76 int8_t score_display_pos; 77 78 enum 79 { 80 STATE_GETPOS, // Detect Score Position, Insert Score, Init Table 81 STATE_DISPLAY, // Display Basic High Score Table 82 STATE_ENTRY, // Init Name Entry 83 STATE_DONE // Score Done 84 }; 85 86 // Mini-car data format. 87 // These are the mini cars that move across and reveal the high score entries 88 struct minicar_entry 89 { 90 int16_t pos; // [+0] Word 0: Position 91 int16_t speed; // [+2] Word 1: Speed (increments over time) 92 int16_t base_speed; // [+4] Word 2: Base Speed 93 int16_t dst_reached; // [+6] Word 3: Set when reached destination 94 uint16_t tile_props; // [+8] Word 4: Palette/Priority bits for tile 95 }; 96 97 // Number of minicar entries 98 const static uint8_t NO_MINICARS = 7; 99 100 // 20 Score Entries 101 minicar_entry minicars[NO_MINICARS]; 102 103 // Stores Laptime conversion 104 // +0: Minutes Digit 1 105 // +1: Minutes Digit 2 106 // +2: Seconds Digit 1 107 // +3: Seconds Digit 2 108 // +4: Milliseconds Digit 1 109 // +5: Milliseconds Digit 2 110 uint16_t laptime[6]; 111 112 void get_score_pos(); 113 void insert_score(); 114 void set_display_pos(); 115 void check_name_entry(); 116 uint32_t get_score_adr(); 117 void blit_alphabet(); 118 void flash_entry(uint32_t adr); 119 void do_input(uint32_t adr); 120 int8_t read_controls(); 121 void setup_minicars(); 122 void tick_minicars(); 123 void setup_minicars_pal(minicar_entry*); 124 void blit_score_table(); 125 void blit_scores(); 126 void blit_digit(); 127 void blit_initials(); 128 void blit_route_map(); 129 void blit_lap_time(); 130 void convert_lap_time(uint16_t); 131 }; 132 133 extern OHiScore ohiscore;