diff --git a/CMakeLists.txt b/CMakeLists.txt index 128fc78..94420ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ find_package(LibProf 2.4 REQUIRED) set(SOURCES src/main.cc - src/clock.cc + # src/clock.cc src/src/segment.cc src/src/camera.cc src/src/circuit.cc @@ -66,6 +66,10 @@ set(ASSETS_cg assets-cg/decos/common/cc_void.png assets-cg/player/player.png + assets-cg/player/smoke1.png + assets-cg/player/smoke2.png + assets-cg/player/smoke3.png + assets-cg/clouds/sky1.png assets-cg/clouds/sky2.png assets-cg/clouds/sky3.png @@ -100,6 +104,7 @@ set(ASSETS_cg assets-cg/hud/speedhud.png assets-cg/screens/mainscreen.png + assets-cg/screens/mainscrbright.png assets-cg/miniscreen/africa1.png assets-cg/miniscreen/desert1.png diff --git a/CppOutRun.layout b/CppOutRun.layout index 65bf75b..fe9c033 100644 --- a/CppOutRun.layout +++ b/CppOutRun.layout @@ -2,7 +2,27 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -29,80 +49,36 @@ - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - + - + - + @@ -118,19 +94,17 @@ - + - + + + + - + - - - - - - + @@ -138,41 +112,64 @@ - + - + - + - + - + - + - + - + + + + + + - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets-cg/billboard/fxconv-metadata.txt b/assets-cg/billboard/fxconv-metadata.txt index 7e05b58..ac7543f 100644 --- a/assets-cg/billboard/fxconv-metadata.txt +++ b/assets-cg/billboard/fxconv-metadata.txt @@ -1,5 +1,5 @@ *.png: type: bopti-image - profile: p4 + profile: p8 name_regex: (.*)\.png \1 diff --git a/assets-cg/decos/africa/fxconv-metadata.txt b/assets-cg/decos/africa/fxconv-metadata.txt index 7e05b58..ac7543f 100644 --- a/assets-cg/decos/africa/fxconv-metadata.txt +++ b/assets-cg/decos/africa/fxconv-metadata.txt @@ -1,5 +1,5 @@ *.png: type: bopti-image - profile: p4 + profile: p8 name_regex: (.*)\.png \1 diff --git a/assets-cg/decos/common/fxconv-metadata.txt b/assets-cg/decos/common/fxconv-metadata.txt index 7e05b58..ac7543f 100644 --- a/assets-cg/decos/common/fxconv-metadata.txt +++ b/assets-cg/decos/common/fxconv-metadata.txt @@ -1,5 +1,5 @@ *.png: type: bopti-image - profile: p4 + profile: p8 name_regex: (.*)\.png \1 diff --git a/assets-cg/decos/desert/fxconv-metadata.txt b/assets-cg/decos/desert/fxconv-metadata.txt index 7e05b58..ac7543f 100644 --- a/assets-cg/decos/desert/fxconv-metadata.txt +++ b/assets-cg/decos/desert/fxconv-metadata.txt @@ -1,5 +1,5 @@ *.png: type: bopti-image - profile: p4 + profile: p8 name_regex: (.*)\.png \1 diff --git a/assets-cg/decos/finland/fxconv-metadata.txt b/assets-cg/decos/finland/fxconv-metadata.txt index 7e05b58..ac7543f 100644 --- a/assets-cg/decos/finland/fxconv-metadata.txt +++ b/assets-cg/decos/finland/fxconv-metadata.txt @@ -1,5 +1,5 @@ *.png: type: bopti-image - profile: p4 + profile: p8 name_regex: (.*)\.png \1 diff --git a/assets-cg/decos/plains/fxconv-metadata.txt b/assets-cg/decos/plains/fxconv-metadata.txt index 7e05b58..ac7543f 100644 --- a/assets-cg/decos/plains/fxconv-metadata.txt +++ b/assets-cg/decos/plains/fxconv-metadata.txt @@ -1,5 +1,5 @@ *.png: type: bopti-image - profile: p4 + profile: p8 name_regex: (.*)\.png \1 diff --git a/assets-cg/decos/usa/fxconv-metadata.txt b/assets-cg/decos/usa/fxconv-metadata.txt index 7e05b58..ac7543f 100644 --- a/assets-cg/decos/usa/fxconv-metadata.txt +++ b/assets-cg/decos/usa/fxconv-metadata.txt @@ -1,5 +1,5 @@ *.png: type: bopti-image - profile: p4 + profile: p8 name_regex: (.*)\.png \1 diff --git a/assets-cg/miniscreen/fxconv-metadata.txt b/assets-cg/miniscreen/fxconv-metadata.txt index ac7543f..3baf1c8 100644 --- a/assets-cg/miniscreen/fxconv-metadata.txt +++ b/assets-cg/miniscreen/fxconv-metadata.txt @@ -1,5 +1,5 @@ *.png: type: bopti-image - profile: p8 + profile: p8_rgb565a name_regex: (.*)\.png \1 diff --git a/assets-cg/player/smoke1.png b/assets-cg/player/smoke1.png new file mode 100644 index 0000000..e30a60b Binary files /dev/null and b/assets-cg/player/smoke1.png differ diff --git a/assets-cg/player/smoke2.png b/assets-cg/player/smoke2.png new file mode 100644 index 0000000..9830a17 Binary files /dev/null and b/assets-cg/player/smoke2.png differ diff --git a/assets-cg/player/smoke3.png b/assets-cg/player/smoke3.png new file mode 100644 index 0000000..b5f8229 Binary files /dev/null and b/assets-cg/player/smoke3.png differ diff --git a/assets-cg/screens/fxconv-metadata.txt b/assets-cg/screens/fxconv-metadata.txt index ac7543f..ffea3ff 100644 --- a/assets-cg/screens/fxconv-metadata.txt +++ b/assets-cg/screens/fxconv-metadata.txt @@ -1,5 +1,5 @@ *.png: type: bopti-image - profile: p8 + profile: p8_rgb565 name_regex: (.*)\.png \1 diff --git a/assets-cg/screens/mainscrbright.png b/assets-cg/screens/mainscrbright.png new file mode 100644 index 0000000..de7a3ef Binary files /dev/null and b/assets-cg/screens/mainscrbright.png differ diff --git a/assets-cg/screens/mainscreen.png b/assets-cg/screens/mainscreen.png index de7a3ef..ea4b6a6 100644 Binary files a/assets-cg/screens/mainscreen.png and b/assets-cg/screens/mainscreen.png differ diff --git a/assets-cg/traffic/fxconv-metadata.txt b/assets-cg/traffic/fxconv-metadata.txt index 7e05b58..ac7543f 100644 --- a/assets-cg/traffic/fxconv-metadata.txt +++ b/assets-cg/traffic/fxconv-metadata.txt @@ -1,5 +1,5 @@ *.png: type: bopti-image - profile: p4 + profile: p8 name_regex: (.*)\.png \1 diff --git a/src/include/circuit.h b/src/include/circuit.h index b0b83e7..c6091c5 100644 --- a/src/include/circuit.h +++ b/src/include/circuit.h @@ -62,6 +62,7 @@ enum Decoration void initData( void ); void createCircuit( int circuitNumber ); void putBillBoards( void ); +void createMilestones( uint8_t nblap ); void createClouds( void ); void createTraffic( uint16_t maxSegment ); diff --git a/src/include/segment.h b/src/include/segment.h index c0ff69e..a174920 100644 --- a/src/include/segment.h +++ b/src/include/segment.h @@ -25,6 +25,19 @@ enum Specialty FINISH = 2 }; +class MileStone +{ + public: + MileStone( ) {type = -1; wZ = 0.0; lap = 0; }; + MileStone( uint8_t t, double Z, uint8_t l ) {type = t; wZ = Z; lap = l; }; + ~MileStone( ) { }; + + uint8_t type; + double wZ; + uint8_t lap; +} ; + + class Segment { public: diff --git a/src/main.cc b/src/main.cc index 8d222c7..1eeef8d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -31,15 +31,15 @@ #include -#include "clock.h" +#include #define DEBUGXXX 0 #define OVERCLCK_ACTIVABLE 1 -char version[5] = {'V','1','.','0','7'}; +char version[5] = {'V','1','.','0','8'}; -extern bopti_image_t player; +extern bopti_image_t player, smoke1, smoke2, smoke3; extern font_t speedfont, startseq, plate, autofont; extern bopti_image_t speedhud; extern bopti_image_t flag, bigflag; @@ -49,6 +49,8 @@ int CurrentCircuitBiome = PLAINS; std::vector circuit; std::vector nuages; std::vector traffic; +std::vector jalons; + int MAX_SEGMENT=0; camera *cam; @@ -109,11 +111,17 @@ bool OptionMode = false; bool PauseMode = false; bool SkipTime = false; + +///HUD options +bool visualspeedindicator = false; +bool visualnextpoint = true; + // for multilap bool multilap = false; uint8_t numlap = 1; uint8_t currentLap = 1; +int currentpoint = 0; uint16_t currentcurve=0; uint8_t shiftcolor=0; @@ -136,7 +144,7 @@ int lastindex=0; int CC=0; // current curve int CS=0; -overclock_level EntryLevel; +int EntryLevel; void initEverything( void ) @@ -191,6 +199,11 @@ void initEverything( void ) } +float timepressed = 0.0f; +int directionPressed = 0; +bool CarIsSliding = false; +uint16_t framesmoke = 0; + static void get_inputs( float dt, int index ) { CC = circuit[index]->Curve; @@ -213,36 +226,47 @@ static void get_inputs( float dt, int index ) { viewside=-1; - if (CurrentCircuitBiome==FINLAND) cam->decX( CC*dt*speed/50 ); // very hard to turn in Finland with snow - else if (CurrentCircuitBiome==AFRICA) cam->decX( CC*dt*speed/75 ); // hard in Africa with dirt - else cam->decX( CC*dt*speed/100 ); // more easy on normal roads + if (CurrentCircuitBiome==FINLAND) cam->decX( CC*dt*speed/50); // 50 ); // very hard to turn in Finland with snow + else if (CurrentCircuitBiome==AFRICA) cam->decX( CC*dt*speed/70); //75 ); // hard in Africa with dirt + else cam->decX( CC*dt*speed/85); // 100 ); // more easy on normal roads } else if (CC>0) { viewside=+1; - if (CurrentCircuitBiome==FINLAND) cam->decX( CC*dt*speed/50 ); // very hard to turn in Finland with snow - else if (CurrentCircuitBiome==AFRICA) cam->decX( CC*dt*speed/75 ); // hard in Africa with dirt - else cam->decX( CC*dt*speed/100 ); // more easy on normal roads + if (CurrentCircuitBiome==FINLAND) cam->decX( CC*dt*speed/50); // 50 ); // very hard to turn in Finland with snow + else if (CurrentCircuitBiome==AFRICA) cam->decX( CC*dt*speed/70); //75 ); // hard in Africa with dirt + else cam->decX( CC*dt*speed/85); // 100 ); // more easy on normal roads } if(keydown(KEY_LEFT) || keydown(KEY_F5)) { cam->decX(5.0*speed*direction); + /// This is to implement sliding and speed loss + if (directionPressed!=-1) directionPressed=-1, timepressed = 0.0f; + else if (directionPressed==-1 && CC<0) timepressed += dt; + viewside=-1; if (CC<0) viewside=-2; // We are in a curve and turning if (CC>0) viewside=0; } - - if(keydown(KEY_RIGHT) || keydown(KEY_F6)) + else if(keydown(KEY_RIGHT) || keydown(KEY_F6)) { cam->incX(5.0*speed*direction); + /// This is to implement sliding and speed loss + if (directionPressed!=1) directionPressed=1, timepressed = 0.0f; + else if (directionPressed==1 && CC>0) timepressed += dt; + viewside=1; if (CC>0) viewside=+2; if (CC<0) viewside=0; } + else if (!keydown(KEY_RIGHT) && !keydown(KEY_F6) && !keydown(KEY_LEFT) && !keydown(KEY_F5)) + { + directionPressed=0, timepressed = 0.0f; + } if(keydown(KEY_SHIFT) || keydown(KEY_XOT) || keydown(KEY_F1)) // Accelerates { @@ -328,6 +352,21 @@ static void get_inputs( float dt, int index ) cam->cX=fix(0.0*ROAD_WIDTH); //set the car in the center of the road (was formerly 0.75) } + + /// This part controls the sliding of player's car, if we keep pressed the keys to turn too long, the car starts sliding, smoke will appear and speed is decreasing + if (timepressed>=300.0f) // was 500.0f + { + CarIsSliding = true; + cam->decX( CC*dt*speed/50 ); + speed = speed * 0.975; + framesmoke++; + } + else + { + CarIsSliding = false; + framesmoke=0; + } + } @@ -339,7 +378,7 @@ static void get_minimum_inputs( void ) } - if(keydown(KEY_EXIT)) drawPauseQuit(); + if(keydown(KEY_EXIT) || keydown(KEY_SHIFT)) drawPauseQuit(); if(keydown(KEY_OPTN)) drawOptions(); @@ -401,7 +440,7 @@ int main(void) #if (OVERCLCK_ACTIVABLE==1) if (gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) { - EntryLevel = overclock_detect(); + EntryLevel = clock_get_speed(); isOCPossible = true; } else @@ -467,13 +506,6 @@ int main(void) do { - - /* - _uram_stats = kmalloc_get_gint_stats(_uram); - sprintf( texttosend, "[Begining of loop] Memory Status - Used: %d - Free: %d - Peak Used: %d", _uram_stats->used_memory, _uram_stats->free_memory, _uram_stats->peak_used_memory); - usb_fxlink_text(texttosend, 0); - */ - // Try to restart from very begining initEverything(); @@ -491,6 +523,7 @@ int main(void) time_render=0; ranking = -1; + currentpoint = 0; exitToOS = false; @@ -530,9 +563,9 @@ int main(void) gint_world_switch( GINT_CALL( saveparameters ) ); - if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == true) clock_overclock( OC_PtuneF5 ); - else if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == false && EntryLevel != OC_Undefined) clock_overclock( EntryLevel ); - else if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == false && EntryLevel == OC_Undefined) clock_overclock( OC_Default ); + if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == true) clock_set_speed( CLOCK_SPEED_F5 ); + else if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == false && EntryLevel != CLOCK_SPEED_UNKNOWN) clock_set_speed( EntryLevel ); + else if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == false && EntryLevel == CLOCK_SPEED_UNKNOWN) clock_set_speed( CLOCK_SPEED_DEFAULT ); } else if (mode==3) { @@ -554,8 +587,6 @@ int main(void) if (!exitToOS) { - //stage = selectedCircuit; - if (selectedCircuit==0) CurrentCircuitBiome = PLAINS, multilap = false, currentLap = 1, numlap = 1; else if (selectedCircuit==1) CurrentCircuitBiome = DESERT, multilap = false, currentLap = 1, numlap = 1; else if (selectedCircuit==2) CurrentCircuitBiome = USA, multilap = false, currentLap = 1, numlap = 1; @@ -576,18 +607,18 @@ int main(void) prof_enter(perf_create); - initData( ); // Positioning of the Camera createCircuit( selectedCircuit ); // Creates the circuit MAX_SEGMENT = circuit.size(); - //uint32_t maxDistance = (MAX_SEGMENT-nbInterestingSegments-5)*SEGMENT_LENGTH; double maxDistance = (double) ((MAX_SEGMENT-1)*SEGMENT_LENGTH); putBillBoards(); + createMilestones( numlap ); + createClouds(); // Creates the Sky and Clouds if (mode==0) @@ -601,15 +632,6 @@ int main(void) else if (CarsNumb==3) NB_CARS_TRAFFIC=300; else NB_CARS_TRAFFIC=100; } - /* else if (selectedCircuit==4) // except for Africa which is very heavy so we need more memory - { - if (CarsNumb==0) NB_CARS_TRAFFIC=50; - else if (CarsNumb==1) NB_CARS_TRAFFIC=75; - else if (CarsNumb==2) NB_CARS_TRAFFIC=100; - else if (CarsNumb==3) NB_CARS_TRAFFIC=150; - else NB_CARS_TRAFFIC=75; - } - */ else // while circular needs much less { if (CarsNumb==0) NB_CARS_TRAFFIC=25; @@ -625,15 +647,6 @@ int main(void) prepareDecoration( CurrentCircuitBiome ); // Prepares the multiple variations of Decoration (image scaling) -#if DEBUGXXX==1 - _uram_stats = kmalloc_get_gint_stats(_uram); - extram_stats = kmalloc_get_gint_stats(&extended_ram); - sprintf( texttosend, "[_U RAM] Memory Status - Used: %d - Free: %d - Peak Used: %d", _uram_stats->used_memory, _uram_stats->free_memory, _uram_stats->peak_used_memory); - if (usb_is_open()) usb_fxlink_text(texttosend, 0); - sprintf( texttosend, "[EXT RAM] Memory Status - Used: %d - Free: %d - Peak Used: %d", extram_stats->used_memory, extram_stats->free_memory, extram_stats->peak_used_memory); - if (usb_is_open()) usb_fxlink_text(texttosend, 0); -#endif // DEBUGXXX - prof_leave(perf_create); time_create = prof_time(perf_create); @@ -698,14 +711,11 @@ int main(void) //-------------- if (fround(cam->cZ)<=0) cam->cZ=fixdouble(0.0); - //if (fround(cam->cZ)>=maxDistance) cam->cZ=fixdouble(maxDistance); indexstart = fround(cam->cZ) / SEGMENT_LENGTH; if (indexstart<0) indexstart=0; indexend = indexstart+nbInterestingSegments+1; - //if (indexstart>MAX_SEGMENT-nbInterestingSegments-2) indexstart=MAX_SEGMENT-nbInterestingSegments-2; - prof_leave(perf_update); time_update = prof_time(perf_update); @@ -727,11 +737,8 @@ int main(void) uint16_t CarSegment = traffic[k]->wZ / SEGMENT_LENGTH; if (CarSegment>=indexstart && CarSegmentvisible = true; circuit[CarSegment]->CarList.push_back(k); } - //else - //traffic[k]->visible = false; } float roadpart = f2float(cam->cX)/(float) ROAD_WIDTH; @@ -820,21 +827,6 @@ int main(void) unsigned int k = circuit[u]->CarList[v]; - - - /* - if (traffic[k]->Turn == -1) - { - traffic[k]->wX -= 0.10; - if (traffic[k]->wX==-0.75 || traffic[k]->wX==-0.25 || traffic[k]->wX==0.25) traffic[k]->Turn = 0; - } - else if (traffic[k]->Turn == 1) - { - traffic[k]->wX += 0.10; - if (traffic[k]->wX==-0.25 || traffic[k]->wX==0.25 || traffic[k]->wX==0.75) traffic[k]->Turn = 0; - } - */ - traffic[k]->wX += (float) traffic[k]->Turn * 0.05f; if (traffic[k]->wX>=-0.775 && traffic[k]->wX<=-0.725) traffic[k]->wX = -0.75, traffic[k]->Turn = 0; else if (traffic[k]->wX>=-0.275 && traffic[k]->wX<=-0.225) traffic[k]->wX = -0.25, traffic[k]->Turn = 0; @@ -852,7 +844,6 @@ int main(void) { projectCircuitFP( k ); // We project the current segment - //if (k!= indexend && circuit[k]->Y < minYRoad) // This is a trick to save precious time while drawing the Sky if (circuit[k]->Y <= minYRoad) minYRoad = circuit[k]->Y; circuit[k]->CumulatedCurve = cumulCurve; // This is the curve accumulated when we are drawing curves @@ -934,15 +925,6 @@ int main(void) score += 5000; circuit[indexstart]->CheckValidated = true; -#if DEBUGXXX==1 - if (usb_is_open()) - { - //sprintf( texttosend, "CKPT : Chrono %D - %D", elapsed_time/1000000, start_time/1000000 ); - sprintf( texttosend, "CKPT : Chrono %D - Reste %D - Extra %D --> Total %D", elapsed_time/1000000, (start_time-circuit[indexstart]->Extratime+handicap)/1000000, (circuit[indexstart]->Extratime-handicap)/1000000, start_time/1000000 ); - usb_fxlink_text(texttosend, 0); - } -#endif - } else if (circuit[indexstart]->Special == FINISH && circuit[indexstart]->CheckValidated == false && circuit[indexstart]->CheckLap!=currentLap) { @@ -1048,6 +1030,13 @@ int main(void) else if (viewside==1) dprint_opt( 193, 203, C_WHITE, C_BLACK, DTEXT_CENTER, DTEXT_CENTER, "%c%c%c", PlayerName[0], PlayerName[1], PlayerName[2] ); else if (viewside==2) dprint_opt( 189, 203, C_WHITE, C_BLACK, DTEXT_CENTER, DTEXT_CENTER, "%c%c%c", PlayerName[0], PlayerName[1], PlayerName[2] ); + if (CarIsSliding) + { + if (framesmoke>=0 && framesmoke<10) dimage(SCREEN_CX-smoke1.width/2, SCREEN_HEIGHT-smoke1.height, &smoke1 ); + else if (framesmoke>=10 && framesmoke<20) dimage(SCREEN_CX-smoke2.width/2, SCREEN_HEIGHT-smoke2.height, &smoke2 ); + else if (framesmoke>=30 && framesmoke<30) dimage(SCREEN_CX-smoke3.width/2, SCREEN_HEIGHT-smoke3.height, &smoke3 ); + else framesmoke=0; + } if (direction==+1) score += speed*dt/10; @@ -1101,44 +1090,51 @@ int main(void) } - if (drawspeed==0.0) dsubimage( 48, 25, &speedhud, 0, 0, 76, 13, DIMAGE_NONE); - else if (drawspeed<3.30) dsubimage( 48, 25, &speedhud, 0, 13, 76, 13, DIMAGE_NONE); - else if (drawspeed<6.70) dsubimage( 48, 25, &speedhud, 0, 26, 76, 13, DIMAGE_NONE); - else if (drawspeed<10.0) dsubimage( 48, 25, &speedhud, 0, 39, 76, 13, DIMAGE_NONE); - else if (drawspeed<13.3) dsubimage( 48, 25, &speedhud, 0, 52, 76, 13, DIMAGE_NONE); - else if (drawspeed<16.7) dsubimage( 48, 25, &speedhud, 0, 65, 76, 13, DIMAGE_NONE); - else if (drawspeed<20.0) dsubimage( 48, 25, &speedhud, 0, 78, 76, 13, DIMAGE_NONE); - else if (drawspeed<23.3) dsubimage( 48, 25, &speedhud, 0, 91, 76, 13, DIMAGE_NONE); - else dsubimage( 48, 25, &speedhud, 0, 104, 76, 13, DIMAGE_NONE); + /// Graphical speed indicator + if (visualspeedindicator) + { + if (drawspeed==0.0) dsubimage( 48, 25, &speedhud, 0, 0, 76, 13, DIMAGE_NONE); + else if (drawspeed<3.30) dsubimage( 48, 25, &speedhud, 0, 13, 76, 13, DIMAGE_NONE); + else if (drawspeed<6.70) dsubimage( 48, 25, &speedhud, 0, 26, 76, 13, DIMAGE_NONE); + else if (drawspeed<10.0) dsubimage( 48, 25, &speedhud, 0, 39, 76, 13, DIMAGE_NONE); + else if (drawspeed<13.3) dsubimage( 48, 25, &speedhud, 0, 52, 76, 13, DIMAGE_NONE); + else if (drawspeed<16.7) dsubimage( 48, 25, &speedhud, 0, 65, 76, 13, DIMAGE_NONE); + else if (drawspeed<20.0) dsubimage( 48, 25, &speedhud, 0, 78, 76, 13, DIMAGE_NONE); + else if (drawspeed<23.3) dsubimage( 48, 25, &speedhud, 0, 91, 76, 13, DIMAGE_NONE); + else dsubimage( 48, 25, &speedhud, 0, 104, 76, 13, DIMAGE_NONE); + } + /// Checkpoint indicator + if (visualnextpoint) + { + double Z1 = jalons[currentpoint]->wZ; + double Z2 = jalons[currentpoint+1]->wZ; + + double frac = (fround(cam->cZ) - Z1) / (Z2 - Z1 ); + if (frac<0) frac=0; + + if (fround(cam->cZ) >= Z2) currentpoint++; + + drect( 15, 50, 20, 150, C_WHITE ); + + drect( 10, 49+frac*100, 25, 51+frac*100, C_RED ); + } + if (finishSequence) { if (mode==1 && !skipranking) { -#if DEBUGXXX==1 - if (usb_is_open()) usb_fxlink_text("save perf", 0); -#endif - bool donerank = false; int k=0; while (!donerank && k<5) { - -#if DEBUGXXX==1 - if (usb_is_open()) usb_fxlink_text("in the loop", 0); -#endif - if (FinalTime<=HallOfFame[selectedCircuit][k].bestTime) { -#if DEBUGXXX==1 - if (usb_is_open()) usb_fxlink_text("found", 0); -#endif - for( int l=4; l>k; l--) { HallOfFame[selectedCircuit][l].playerName[0] = HallOfFame[selectedCircuit][l-1].playerName[0]; @@ -1347,6 +1343,9 @@ int main(void) for(unsigned int i=0; i circuit; extern std::vector nuages; extern std::vector traffic; +extern std::vector jalons; extern camera *cam; extern uint16_t currentcurve; @@ -549,6 +550,41 @@ void putBillBoards( void ) } +void outputMilestones( void ) +{ + char texttosend[1024]; + if (usb_is_open()) + { + for(int k = 0; k< jalons.size(); k++) + { + sprintf( texttosend, "Jalons %d --> Lap = %d : Type = %d ; Position = %.0f \n", k, jalons[k]->lap, jalons[k]->type, jalons[k]->wZ ); + usb_fxlink_text(texttosend, 0); + } + } +} + +void createMilestones( uint8_t nblap ) +{ + for( unsigned int l=0; lSpecial != -1) + { + MileStone *mile=new MileStone( ); + mile->type = circuit[k]->Special; + mile->wZ = (double) ((double) k * (double) SEGMENT_LENGTH); + mile->lap = l ; + jalons.push_back(mile); + } + } + } +#if DEBUGXXX==1 + outputMilestones(); +#endif // DEBUGXXX +} + + void createClouds( void ) @@ -579,8 +615,8 @@ void createTraffic( uint16_t maxSegment ) uint8_t S; // if Difficulty = easy, all cars are at the same speed 175km/h) - if (DiffLevel==0) S=3.5; - else S = 2 + (rand() % 3); // else speed is random and then overtaking can happen + if (DiffLevel==0) S=4.0; + else S = 3.5 + (rand() % 2); // else speed is random and then overtaking can happen uint8_t T = rand() % 8; @@ -1252,7 +1288,8 @@ void freeDecoration( void ) { for( int k=0; kX + circuit[index]->CumulatedCurve - 1.5*circuit[index]->W - image->width/2; int Y = circuit[index]->Y - image->height; + //dimage_p4_clearbg_alt( X, Y, image, 0, image->alpha ); dimage( X, Y, image ); } @@ -1296,6 +1334,7 @@ void drawDecoration( uint16_t index ) int X = circuit[index]->X + circuit[index]->CumulatedCurve + 1.5*circuit[index]->W - image->width/2; int Y = circuit[index]->Y - image->height; + //dimage_p4_clearbg_alt( X, Y, image, 0, image->alpha ); dimage( X, Y, image ); } } diff --git a/src/src/menus.cc b/src/src/menus.cc index 4471814..453e70a 100644 --- a/src/src/menus.cc +++ b/src/src/menus.cc @@ -11,6 +11,8 @@ #include "../include/utils.h" #include "../include/saves.h" +#include + extern BestRanking HallOfFame[10][5]; @@ -19,7 +21,7 @@ extern uint8_t NB_CARS_TRAFFIC; extern bool isOCPossible; extern bool isOCActivated; -extern bopti_image_t mainscreen; +extern bopti_image_t mainscreen, mainscrbright; extern bopti_image_t africa1, desert1, finland1, plains1, usa1; extern bopti_image_t flag, linear, circular; extern font_t autofont, autofontsmall, speedfont; @@ -79,7 +81,7 @@ void drawStartTitle( void ) { dclear( C_BLACK ); - dsubimage( 0, 32, &mainscreen, 0, 32, 396, 160, DIMAGE_NONE); + dsubimage( 0, 32, &mainscrbright, 0, 32, 396, 160, DIMAGE_NONE); dfont(&autofont); @@ -1200,8 +1202,8 @@ int drawMenuCircuitDetails( int circuit ) } - free(preview1); - free(preview2); + image_free(preview1); + image_free(preview2); return CircuitDetailsSelection; } diff --git a/src/src/utils.cc b/src/src/utils.cc index edeb33e..8386545 100644 --- a/src/src/utils.cc +++ b/src/src/utils.cc @@ -1,7 +1,8 @@ #include "../include/utils.h" +#include - +/* size_t image_size_profile(int profile, int width, int height) { size_t size = sizeof(bopti_image_t); @@ -21,6 +22,7 @@ size_t image_size(bopti_image_t const *img) return image_size_profile(img->profile, img->width, img->height); } + int get_pixel(bopti_image_t const *img, int x, int y) { if((unsigned)x >= img->width || (unsigned)y >= img->height) @@ -93,4 +95,11 @@ bopti_image_t *resize(bopti_image_t const *src, int w, int h) return img; } +*/ +bopti_image_t *resize(bopti_image_t const *src, int w, int h) +{ + image_linear_map scale; + image_scale( src, 65536*w/src->width, 65536*h/src->height, &scale ); + return image_linear_alloc(src, &scale ); +}