From bd3daee82a0c3e50e90a2c273a3aaa6323e7759f Mon Sep 17 00:00:00 2001 From: Slyvtt Date: Thu, 24 Mar 2022 20:18:56 +0100 Subject: [PATCH] corrected time stop during menus navigation + added finish sequence --- CppOutRun.layout | 150 +++++++++++++++++++++++++---------------------- src/main.cc | 149 +++++++++++++++------------------------------- src/src/menus.cc | 6 +- 3 files changed, 130 insertions(+), 175 deletions(-) diff --git a/CppOutRun.layout b/CppOutRun.layout index e146200..569985a 100644 --- a/CppOutRun.layout +++ b/CppOutRun.layout @@ -2,48 +2,29 @@ - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - + - + @@ -54,49 +35,14 @@ - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -104,9 +50,31 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + @@ -114,9 +82,49 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main.cc b/src/main.cc index 7b2fc7d..97625ce 100644 --- a/src/main.cc +++ b/src/main.cc @@ -145,27 +145,6 @@ void initEverything( void ) } - -int my_profile(int key, int duration, int count) -{ - // key: Key being repeated - // duration: How long that key has been pressed - // count: How many times it's been repeated already - // Return value: how long to wait before next repeat (\B5s) - - // Only allow KEY_LEFT and KEY_RIGHT - if(key!=KEY_LEFT && key!=KEY_RIGHT && key!=KEY_DOWN && key!=KEY_UP && key!=KEY_ALPHA && key!=KEY_SHIFT) - return -1; - - // 500 ms for first repeat, 50 ms after that; stop after 10 repeats - if(count == 0) - return 500*1000; - else - return -1; - -} - - static void get_inputs( float dt, int index ) { CC = circuit[index]->Curve; @@ -184,8 +163,6 @@ static void get_inputs( float dt, int index ) { viewside=-1; - //cam->decX( CC*dt*speed/100 ); - 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 @@ -194,8 +171,6 @@ static void get_inputs( float dt, int index ) { viewside=+1; - //cam->decX( CC*dt*speed/100 ); - 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 @@ -203,7 +178,6 @@ static void get_inputs( float dt, int index ) if(keydown(KEY_LEFT)) { - //cam->decX(25.0); cam->decX(5.0*speed*direction); viewside=-1; @@ -213,7 +187,6 @@ static void get_inputs( float dt, int index ) if(keydown(KEY_RIGHT)) { - //cam->incX(25.0); cam->incX(5.0*speed*direction); viewside=1; @@ -266,39 +239,14 @@ static void get_inputs( float dt, int index ) if(keydown(KEY_OPTN)) drawOptions(); #if IS_FXLIB==1 - if(keydown(KEY_XOT)) - { - ShowDebug1 = false; - ShowDebug2 = false; - ShowDebug3 = false; - } - if(keydown(KEY_LOG)) - { - ShowDebug1 = true; - ShowDebug2 = false; - ShowDebug3 = false; - } - if(keydown(KEY_LN)) - { - ShowDebug1 = false; - ShowDebug2 = true; - ShowDebug3 = false; - } - if(keydown(KEY_SIN)) - { - ShowDebug1 = false; - ShowDebug2 = false; - ShowDebug3 = true; - } - if(keydown(KEY_F1)) BDrawDeco = !BDrawDeco; if(keydown(KEY_F2)) BDrawClds = !BDrawClds; if(keydown(KEY_F3)) BDrawCars = !BDrawCars; - if(keydown(KEY_F4)) BDrawFPS = !BDrawFPS; - - if(keydown(KEY_F5)) screenshot = true; - if(keydown(KEY_F6)) record = !record; + if(keydown(KEY_F4)) BDrawBack = !BDrawBack; + if(keydown(KEY_F5)) BDrawFPS = !BDrawFPS; + if(keydown(KEY_7)) screenshot = true; + if(keydown(KEY_8)) record = !record; #endif // IS_FXLIB if (speedcontrol==false) @@ -351,39 +299,14 @@ static void get_minimum_inputs( void ) if(keydown(KEY_OPTN)) drawOptions(); #if IS_FXLIB==1 - if(keydown(KEY_XOT)) - { - ShowDebug1 = false; - ShowDebug2 = false; - ShowDebug3 = false; - } - if(keydown(KEY_LOG)) - { - ShowDebug1 = true; - ShowDebug2 = false; - ShowDebug3 = false; - } - if(keydown(KEY_LN)) - { - ShowDebug1 = false; - ShowDebug2 = true; - ShowDebug3 = false; - } - if(keydown(KEY_SIN)) - { - ShowDebug1 = false; - ShowDebug2 = false; - ShowDebug3 = true; - } - if(keydown(KEY_F1)) BDrawDeco = !BDrawDeco; if(keydown(KEY_F2)) BDrawClds = !BDrawClds; if(keydown(KEY_F3)) BDrawCars = !BDrawCars; - if(keydown(KEY_F4)) BDrawFPS = !BDrawFPS; - - if(keydown(KEY_F5)) screenshot = true; - if(keydown(KEY_F6)) record = !record; + if(keydown(KEY_F4)) BDrawBack = !BDrawBack; + if(keydown(KEY_F5)) BDrawFPS = !BDrawFPS; + if(keydown(KEY_7)) screenshot = true; + if(keydown(KEY_8)) record = !record; #endif // IS_FXLIB } @@ -403,14 +326,19 @@ int main(void) kmalloc_arena_t *_uram = kmalloc_get_arena("_uram"); kmalloc_gint_stats_t *_uram_stats; + srand( rtc_ticks() ); prof_init(); + drawStartTitle(); - char texttosend[1024]; + + //char texttosend[1024]; + + exitToOS = false; do @@ -426,8 +354,8 @@ int main(void) initEverything(); prof_t perf_update, perf_create, perf_project, perf_render; - int32_t start_time = 99000000; - uint32_t score=99999; + int32_t start_time = 100000000; + uint32_t score=0; uint8_t stage=0; int8_t selectedCircuit=0; uint32_t time_update=0, time_create=0, time_project=0, time_render=0; @@ -437,6 +365,8 @@ int main(void) stop = false; bool exitflag = false; + + do { exitflag = false; @@ -457,15 +387,13 @@ int main(void) } else if (stage==4) { - // Exit Menu TO BE DONE - // quick and dirty exitToOS = true; exitflag=true; } } while (!exitflag); - if (exitToOS==false) + if (!exitToOS) { stage = selectedCircuit; @@ -482,13 +410,14 @@ int main(void) else CurrentCircuitBiome = PLAINS; - int nbInterestingSegments = (MAX_RENDER_DISTANCE / SEGMENT_LENGTH); // the number of segments to be projected considering the rendering distance perf_create = prof_make(); prof_enter(perf_create); + + initData( ); // Positioning of the Camera createCircuit( selectedCircuit ); // Creates the circuit @@ -538,12 +467,7 @@ int main(void) { - perf_update = prof_make(); - prof_enter(perf_update); - - if (!initiateStart && !finishSequence && !failSequence) get_inputs( dt, indexstart ); // The racer is not started : no need to get inputs and we are not in fail or finish sequence - else get_minimum_inputs(); // the we can just have minimum inputs - + //new position if (!SkipTime) { dt = ((float) (time_update+time_render+time_project) / 1000.0); @@ -554,6 +478,16 @@ int main(void) SkipTime=false; } + + perf_update = prof_make(); + prof_enter(perf_update); + + if (!initiateStart && !finishSequence && !failSequence) get_inputs( dt, indexstart ); // The racer is not started : no need to get inputs and we are not in fail or finish sequence + else get_minimum_inputs(); // the we can just have minimum inputs + +//former position + + if (initiateStart) { startCount -= dt*1000; @@ -703,8 +637,8 @@ int main(void) } else if (circuit[indexstart]->Special == FINISH && circuit[indexstart]->CheckValidated == false) { - start_time+=60000000; circuit[indexstart]->CheckValidated = true; + finishSequence=true; } else if (circuit[indexstart]->Special == START && circuit[indexstart]->CheckValidated == false) { @@ -796,6 +730,19 @@ int main(void) + if (finishSequence) + { + dimage( 198-bigflag.width/2, 112-bigflag.height/2, &bigflag ); + + dfont(&startseq); + + dprint_opt(200,108, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, "YOU" ); + dprint_opt(198,112, C_RGB(0,255,0), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, "YOU" ); + + dprint_opt(200,108, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "WIN" ); + dprint_opt(198,112, C_RGB(0,255,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "WIN" ); + } + if (failSequence) { @@ -804,10 +751,10 @@ int main(void) dfont(&startseq); dprint_opt(200,108, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, "YOU" ); - dprint_opt(198,112, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, "YOU" ); + dprint_opt(198,112, C_RGB(255,0,0), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, "YOU" ); dprint_opt(200,108, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "LOOSE" ); - dprint_opt(198,112, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "LOOSE" ); + dprint_opt(198,112, C_RGB(255,0,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "LOOSE" ); } diff --git a/src/src/menus.cc b/src/src/menus.cc index 7375795..74a93f7 100644 --- a/src/src/menus.cc +++ b/src/src/menus.cc @@ -56,7 +56,7 @@ void drawStartTitle( void ) dfont(&autofont); - dprint_opt(198, 2, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "OUTRUN FOR GRAPH90" ); + dprint_opt(198, 2, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "OUTRUN FOR FX-CG50" ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, "PRESS EXE TO START" ); @@ -600,7 +600,7 @@ void drawOptions( void ) #endif } - SkipTime = true; + SkipTime = true; // To avoid counting or de-counting time during menu return; } @@ -704,7 +704,7 @@ void drawPauseQuit( void ) #endif } - SkipTime = true; + SkipTime = true; // To avoid counting or de-counting time during menu return; }