diff --git a/CppOutRun.layout b/CppOutRun.layout index 71f8325..bbb7b91 100644 --- a/CppOutRun.layout +++ b/CppOutRun.layout @@ -2,34 +2,72 @@ + + + + + + + + + + + + + + + + + + - + - + - + + + + + + + + + + + - - - - - + + + + + + + + + + - + + + + + + @@ -37,9 +75,14 @@ + + + + + - + @@ -53,31 +96,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -88,39 +106,31 @@ + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/include/drawstuff.h b/src/include/drawstuff.h index 43f1385..a4457e2 100644 --- a/src/include/drawstuff.h +++ b/src/include/drawstuff.h @@ -7,7 +7,7 @@ void drawPolygon( int x1min, int x1max, int y1, int x2min, int x2max, int y2, ui void drawGrass( int y1, int y2, uint8_t R, uint8_t G, uint8_t B ); void drawGrass( int y1, int y2, uint16_t color ); -void drawSky( void ); +void drawSkyFull( uint16_t color ); void drawSky( uint16_t color ); void drawSky( uint8_t R, uint8_t G, uint8_t B ); void drawSky( int ymin, int ymax ); diff --git a/src/include/menus.h b/src/include/menus.h index 3b6a9ac..2d1db8c 100644 --- a/src/include/menus.h +++ b/src/include/menus.h @@ -14,4 +14,8 @@ void getInputCircuitSelect( void ); void drawCredit( void ); void getInputCredit( void ); +void drawOptions( void ); +void getInputOptions( void ); + + #endif // MENUS_H diff --git a/src/main.cc b/src/main.cc index eeff38d..344b573 100644 --- a/src/main.cc +++ b/src/main.cc @@ -64,8 +64,12 @@ bool ShowDebug3 = false; bool BDrawDeco = true; bool BDrawClds = true; bool BDrawCars = true; +bool BDrawBack = true; bool BDrawFPS = false; +bool OptionMode = false; +bool PauseMode = false; + uint16_t currentcurve=0; uint8_t shiftcolor=0; @@ -257,6 +261,8 @@ static void get_inputs( float dt, int index ) if(keydown(KEY_EXIT)) stop = true; + if(keydown(KEY_OPTN)) drawOptions(); + #if IS_FXLIB==1 if(keydown(KEY_XOT)) { @@ -392,7 +398,7 @@ int main(void) } else if (stage==2) { - // Option Menu TO BE DONE + drawOptions(); } else if (stage==3) { @@ -555,7 +561,7 @@ int main(void) { projectCircuitFP( k ); // We project the current segment - if (circuit[k]->Y < minYRoad) // This is a trick to save precious time while drawing the Sky + if (k!= indexend && circuit[k]->Y < minYRoad) // This is a trick to save precious time while drawing the Sky minYRoad = circuit[k]->Y; circuit[k]->CumulatedCurve = cumulCurve; // This is the curve accumulated when we are drawing curves @@ -579,13 +585,21 @@ int main(void) prof_enter(perf_render); - drawSky( DAY_BLUE_SKY ); + if (BDrawBack) drawSkyOptimised( DAY_BLUE_SKY ); + else drawSkyFull( DAY_BLUE_SKY ); + if (BDrawClds) + { drawClouds( ); + } + + if (BDrawBack) + { + drawFarBackground( deltaFarbackground, CurrentCircuitBiome ); + drawNearBackground( deltaNearbackground, CurrentCircuitBiome ); + } - drawFarBackground( deltaFarbackground, CurrentCircuitBiome ); - drawNearBackground( deltaNearbackground, CurrentCircuitBiome ); cam->cY = fix( 300+2*CS ) + interpolatePositionY(fround(cam->cZ) ); @@ -605,7 +619,7 @@ int main(void) drawTraffic( indexCar ); } - circuit[k]->CarList.clear(); + if (BDrawCars) circuit[k]->CarList.clear(); } if (circuit[indexstart]->Special == CHECKPOINT && circuit[indexstart]->CheckValidated == false) diff --git a/src/src/drawstuff.cc b/src/src/drawstuff.cc index 3dfa713..e568f88 100644 --- a/src/src/drawstuff.cc +++ b/src/src/drawstuff.cc @@ -100,9 +100,10 @@ void drawPolygon( int x1min, int x1max, int y1, int x2min, int x2max, int y2, ui }; -void drawSky( void ) +void drawSkyFull( uint16_t color ) { - dclear( C_RGB(0,45,255) ); + //dclear( color ); + dma_memset(gint_vram, (color << 16) | color, 396 * 174 * 2); }; @@ -113,7 +114,7 @@ void drawSky( uint16_t color ) void drawSkyOptimised( uint16_t color ) { - dma_memset(gint_vram, (color << 16) | color, 396 * (minYRoad+1) * 2); + dma_memset(gint_vram, (color << 16) | color, 396 * (minYRoad+10) * 2); }; void drawSky( uint8_t R, uint8_t G, uint8_t B ) diff --git a/src/src/menus.cc b/src/src/menus.cc index 5903e7a..a90cbbb 100644 --- a/src/src/menus.cc +++ b/src/src/menus.cc @@ -26,7 +26,14 @@ int8_t CircuitSelection=0; bool doneMenuCredit = false; +bool doneOptions = false; +uint8_t OptionsSelection=0; +extern bool BDrawDeco; +extern bool BDrawClds; +extern bool BDrawCars; +extern bool BDrawFPS; +extern bool BDrawBack; void drawStartTitle( void ) @@ -475,5 +482,158 @@ void getInputCredit( void ) } +void drawOptions( void ) +{ + uint16_t pulse=0; + doneOptions = false; + + OptionsSelection=0; + + while (!doneOptions) + { + + dclear(0x0000); + dimage( 0, 0, &mainscreen); + + dfont(&autofont); + + if (BDrawDeco) + { + dprint_opt(102, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [Y]" ); + if (OptionsSelection!=0) dprint_opt(100, 20, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [Y]" ); + else dprint_opt(100, 20, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [Y]" ); + } + else + { + dprint_opt(102, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [N]" ); + if (OptionsSelection!=0) dprint_opt(100, 20, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [N]" ); + else dprint_opt(100, 20, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [N]" ); + } + + + if (BDrawCars) + { + dprint_opt(102, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [Y]" ); + if (OptionsSelection!=1) dprint_opt(100, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [Y]" ); + else dprint_opt(100, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [Y]" ); + } + else + { + dprint_opt(102, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [N]" ); + if (OptionsSelection!=1) dprint_opt(100, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [N]" ); + else dprint_opt(100, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [N]" ); + } + + + if (BDrawClds) + { + dprint_opt(102, 82, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [Y]" ); + if (OptionsSelection!=2) dprint_opt(100, 80, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [Y]" ); + else dprint_opt(100, 80, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [Y]" ); + } + else + { + dprint_opt(102, 82, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [N]" ); + if (OptionsSelection!=2) dprint_opt(100, 80, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [N]" ); + else dprint_opt(100, 80, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [N]" ); + } + + if (BDrawBack) + { + dprint_opt(102, 112, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [Y]" ); + if (OptionsSelection!=3) dprint_opt(100, 110, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [Y]" ); + else dprint_opt(100, 110, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [Y]" ); + } + else + { + dprint_opt(102, 112, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [N]" ); + if (OptionsSelection!=3) dprint_opt(100, 110, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [N]" ); + else dprint_opt(100, 110, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [N]" ); + } + + if (BDrawFPS) + { + dprint_opt(102, 142, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [Y]" ); + if (OptionsSelection!=4) dprint_opt(100, 140, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [Y]" ); + else dprint_opt(100, 140, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [Y]" ); + } + else + { + dprint_opt(102, 142, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [N]" ); + if (OptionsSelection!=4) dprint_opt(100, 140, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [N]" ); + else dprint_opt(100, 140, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [N]" ); + } + + + dprint_opt(102, 172, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" ); + if (OptionsSelection!=5) dprint_opt(100, 170, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" ); + else dprint_opt(100, 170, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" ); + + dimage( 10, 5+30*OptionsSelection, &flag ); + + // CODE HERE TO PRINT WELCOME MENU + + dupdate(); + + pulse++; + getInputOptions(); + +#if IS_FXLIB==1 + if (screenshot && usb_is_open()) + { + usb_fxlink_screenshot(false); + screenshot = false; + } + + if(record && usb_is_open()) + { + usb_fxlink_videocapture(false); + } +#endif + } + + return; +} + +void getInputOptions( void ) +{ + int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS; + int timeout = 1; + + while(1) + { + key_event_t ev = getkey_opt(opt, &timeout); + if(ev.type == KEYEV_NONE) return; + + int key = ev.key; + + if (key==KEY_EXE) + { + if (OptionsSelection==0) BDrawDeco = !BDrawDeco; + else if (OptionsSelection==1) BDrawCars = !BDrawCars; + else if (OptionsSelection==2) BDrawClds = !BDrawClds; + else if (OptionsSelection==3) BDrawBack = !BDrawBack; + else if (OptionsSelection==4) BDrawFPS = !BDrawFPS; + else doneOptions=true; + } + if (key==KEY_UP) + { + if (OptionsSelection==0) OptionsSelection=5; + else OptionsSelection--; + } + + if (key==KEY_DOWN) + { + if (OptionsSelection==5) OptionsSelection=0; + else OptionsSelection++; + } + +#if IS_FXLIB==1 + if(keydown(KEY_F5)) screenshot = true; + if(keydown(KEY_F6)) record = !record; +#endif // IS_FXLIB + } +} +