unlock RAM +3Mb - 5 linear circuits OK

This commit is contained in:
Sylvain PILLOT 2022-03-28 22:42:56 +02:00
parent 40683e0d76
commit 6fcfd3b764
6 changed files with 554 additions and 253 deletions

View File

@ -2,36 +2,52 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="src/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/circuit.cc" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8620" topLine="378" />
</Cursor>
</File>
<File name="src/src/circuit.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="210" topLine="0" />
<Cursor1 position="14837" topLine="224" />
</Cursor>
<Folding>
<Collapse line="498" />
<Collapse line="514" />
<Collapse line="539" />
<Collapse line="549" />
<Collapse line="594" />
<Collapse line="630" />
<Collapse line="640" />
<Collapse line="687" />
<Collapse line="722" />
<Collapse line="760" />
<Collapse line="797" />
<Collapse line="1089" />
<Collapse line="1096" />
<Collapse line="1106" />
<Collapse line="1116" />
<Collapse line="375" />
<Collapse line="385" />
<Collapse line="413" />
<Collapse line="441" />
<Collapse line="469" />
<Collapse line="499" />
<Collapse line="672" />
<Collapse line="688" />
<Collapse line="720" />
<Collapse line="730" />
<Collapse line="779" />
<Collapse line="829" />
<Collapse line="880" />
<Collapse line="953" />
<Collapse line="990" />
<Collapse line="1282" />
<Collapse line="1289" />
<Collapse line="1299" />
<Collapse line="1309" />
</Folding>
</File>
<File name="src/include/clouds.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="306" topLine="0" />
<Cursor1 position="3139" topLine="103" />
</Cursor>
<Folding>
<Collapse line="110" />
<Collapse line="162" />
<Collapse line="308" />
<Collapse line="687" />
<Collapse line="1007" />
</Folding>
</File>
<File name="src/colors.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="35" topLine="0" />
</Cursor>
</File>
<File name="src/src/utils.cc" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="30" topLine="0" />
</Cursor>
</File>
<File name="src/fixed.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -39,11 +55,81 @@
<Cursor1 position="5" topLine="0" />
</Cursor>
</File>
<File name="src/include/drawstuff.h" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="655" topLine="0" />
</Cursor>
</File>
<File name="src/src/clouds.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="203" topLine="0" />
</Cursor>
</File>
<File name="src/include/segment.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="783" topLine="3" />
</Cursor>
</File>
<File name="src/parameters.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="355" topLine="0" />
</Cursor>
</File>
<File name="src/include/menus.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="510" topLine="0" />
</Cursor>
</File>
<File name="src/src/menus.cc" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="27007" topLine="247" />
</Cursor>
<Folding>
<Collapse line="64" />
<Collapse line="102" />
<Collapse line="128" />
<Collapse line="229" />
<Collapse line="241" />
<Collapse line="420" />
<Collapse line="514" />
<Collapse line="883" />
</Folding>
</File>
<File name="src/include/clouds.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="306" topLine="0" />
</Cursor>
</File>
<File name="TODO.txt" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="251" topLine="0" />
</Cursor>
</File>
<File name="src/src/segment.cc" open="1" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="410" topLine="29" />
</Cursor>
</File>
<File name="src/include/cars.h" open="1" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="412" topLine="2" />
</Cursor>
</File>
<File name="src/include/utils.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="107" topLine="0" />
</Cursor>
</File>
<File name="src/src/cars.cc" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1019" topLine="8" />
</Cursor>
</File>
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="370" topLine="0" />
</Cursor>
</File>
<File name="src/src/drawstuff.cc" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2807" topLine="14" />
@ -57,96 +143,14 @@
<Collapse line="131" />
</Folding>
</File>
<File name="src/include/utils.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="107" topLine="0" />
</Cursor>
</File>
<File name="src/include/cars.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="332" topLine="0" />
</Cursor>
</File>
<File name="src/src/utils.cc" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="30" topLine="0" />
</Cursor>
</File>
<File name="src/src/clouds.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="203" topLine="0" />
</Cursor>
</File>
<File name="src/parameters.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="559" topLine="0" />
</Cursor>
</File>
<File name="src/include/segment.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="252" topLine="9" />
</Cursor>
</File>
<File name="TODO.txt" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="251" topLine="0" />
</Cursor>
</File>
<File name="src/src/menus.cc" open="1" top="1" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="33866" topLine="179" />
</Cursor>
<Folding>
<Collapse line="61" />
<Collapse line="99" />
<Collapse line="125" />
<Collapse line="190" />
<Collapse line="226" />
<Collapse line="238" />
<Collapse line="375" />
<Collapse line="417" />
<Collapse line="488" />
<Collapse line="511" />
<Collapse line="626" />
<Collapse line="669" />
<Collapse line="781" />
<Collapse line="873" />
<Collapse line="935" />
</Folding>
</File>
<File name="src/include/drawstuff.h" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="655" topLine="0" />
</Cursor>
</File>
<File name="src/include/menus.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="510" topLine="0" />
</Cursor>
</File>
<File name="src/include/camera.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="221" topLine="0" />
</Cursor>
</File>
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="370" topLine="0" />
</Cursor>
</File>
<File name="src/colors.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="35" topLine="0" />
</Cursor>
</File>
<File name="src/src/segment.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="230" topLine="30" />
</Cursor>
</File>
<File name="src/include/circuit.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1291" topLine="0" />
<Cursor1 position="1686" topLine="12" />
</Cursor>
</File>
<File name="CMakeLists.txt" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">

View File

@ -86,9 +86,9 @@ void prepareDecoration( int biometoload );
void freeTraffic( void );
void prepareTraffic( void );
void addCheckPoint( int8_t biome );
void addStartLine( int8_t biome );
void addFinishLine( int8_t biome );
void addCheckPoint( int8_t biome, uint8_t extra );
void addStartLine( int8_t biome, uint8_t extra );
void addFinishLine( int8_t biome, uint8_t extra );
void addStraightLine( Length l, int8_t biome );
void addCurve( Length l, CurveStrength s, CurveType t, int8_t biome );
void addHill( Length l, HillSize s, HillType t, int8_t biome );

View File

@ -40,6 +40,9 @@ class Segment
int8_t Special = -1;
bool CheckValidated = false;
uint32_t Extratime = 0;
uint8_t CheckLap = 0;
int8_t Curve=0;
int8_t Slope=0;
int16_t CumulatedCurve=0;

View File

@ -28,6 +28,10 @@
#include <gint/kmalloc.h>
#include <stdio.h>
#define DEBUGXXX 0
extern bopti_image_t player;
extern font_t speedfont, startseq, plate;
extern bopti_image_t speedhud;
@ -164,6 +168,10 @@ static void get_inputs( float dt, int index )
CC = circuit[index]->Curve;
CS = circuit[index]->Slope;
maxspeedforward = 5.0 - (((float) CS)/100.0f) + (((float) CC)*f2float(cam->cX)/ROAD_WIDTH/20.0f);
key_event_t ev;
while((ev = pollevent()).type != KEYEV_NONE)
{
@ -297,6 +305,7 @@ static void get_inputs( float dt, int index )
speed=0.0;
cam->cX=fix(0.0*ROAD_WIDTH); //set the car in the center of the road (was formerly 0.75)
}
}
@ -341,6 +350,27 @@ int main(void)
kmalloc_gint_stats_t *_uram_stats;
/* allow more RAM */
char const *osv = (char*) 0x80020020;
static kmalloc_arena_t extended_ram = { 0 };
kmalloc_gint_stats_t *extram_stats;
bool canWeAllocateMore = false;
if(!strncmp(osv, "03.", 3) && osv[3] <= '6')
{
extended_ram.name = "extram";
extended_ram.is_default = true; // Je suis pas sûr de ça, j'imagine que mettre true veut dire utilisation exclusive de "_extram"
extended_ram.start = (void *)0x8c200000;
extended_ram.end = (void *)0x8c500000 ; // 0x8c200000 + 0x00300000 correspondant à 3Mo
kmalloc_init_arena(&extended_ram , true);
kmalloc_add_arena(&extended_ram );
canWeAllocateMore = true;
}
srand( rtc_ticks() );
prof_init();
@ -350,11 +380,11 @@ int main(void)
drawStartTitle();
//char texttosend[1024];
char texttosend[1024];
exitToOS = false;
do
{
@ -369,8 +399,9 @@ int main(void)
prof_t perf_update, perf_create, perf_project, perf_render;
int32_t start_time = 100000000;
uint32_t elapsed_time = 0;
uint32_t score=0;
uint8_t stage=0;
uint8_t stage=0, mode=0;
int8_t selectedCircuit=0, secondvalidation=0;
uint32_t time_update=0, time_create=0, time_project=0, time_render=0;
@ -384,35 +415,35 @@ int main(void)
do
{
exitflag = false;
stage = drawMainMenu();
mode = drawMainMenu();
if (stage==0)
if (mode==0)
{
selectedCircuit = drawMenuCircuitSelect();
if (selectedCircuit != -1) secondvalidation = drawMenuCircuitDetails( selectedCircuit, 0 );
if (selectedCircuit != -1 && secondvalidation != -1) exitflag=true;
}
else if (stage==1)
else if (mode==1)
{
selectedCircuit = drawMenuCircuitSelect();
if (selectedCircuit != -1) secondvalidation = drawMenuCircuitDetails( selectedCircuit, 1 );
if (selectedCircuit != -1 && secondvalidation != -1) exitflag=true;
}
else if (stage==2)
else if (mode==2)
{
drawGameOptions();
}
else if (stage==3)
else if (mode==3)
{
drawOptions();
}
else if (stage==4)
else if (mode==4)
{
drawCredit();
}
else if (stage==5)
else if (mode==5)
{
exitToOS = true;
exitflag=true;
@ -422,7 +453,7 @@ int main(void)
if (!exitToOS)
{
stage = selectedCircuit;
//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;
@ -456,13 +487,48 @@ int main(void)
createClouds(); // Creates the Sky and Clouds
createTraffic( MAX_SEGMENT ); // Creates the cars
if (mode==0)
{
// linear circuits needs many cars
if (selectedCircuit>=0 && selectedCircuit<=3)
{
if (CarsNumb==0) NB_CARS_TRAFFIC=100;
else if (CarsNumb==1) NB_CARS_TRAFFIC=200;
else if (CarsNumb==2) NB_CARS_TRAFFIC=500;
else if (CarsNumb==3) NB_CARS_TRAFFIC=1000;
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=10;
else if (CarsNumb==1) NB_CARS_TRAFFIC=20;
else if (CarsNumb==2) NB_CARS_TRAFFIC=50;
else if (CarsNumb==3) NB_CARS_TRAFFIC=100;
else NB_CARS_TRAFFIC=10;
}
createTraffic( MAX_SEGMENT ); // Creates the cars
prepareTraffic(); // Prepares the multiple variations of Cars (image scaling)
}
prepareDecoration( CurrentCircuitBiome ); // Prepares the multiple variations of Decoration (image scaling)
prepareTraffic(); // Prepares the multiple variations of Cars (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);
@ -522,6 +588,7 @@ int main(void)
}
start_time -= dt*1000;
elapsed_time += dt*1000;
if (start_time<0) start_time=0;
remaining_time = ((float) (start_time) / 1000000.0);
@ -546,7 +613,7 @@ int main(void)
minYRoad = SCREEN_HEIGHT;
if (BDrawCars)
if (BDrawCars && mode==0)
{
updateTraffic( dt, maxDistance );
@ -583,6 +650,7 @@ int main(void)
if (traffic[indexCar]->wX>(roadpart-0.22f) && traffic[indexCar]->wX<(roadpart+0.22f) && traffic[indexCar]->Speed<speed)
{
speed = traffic[indexCar]->Speed - 0.5;
score = max(0, score-250);
}
}
@ -622,9 +690,9 @@ int main(void)
if (traffic[k]->Turn == 0)
{
int mov = rand() % 100;
int mov = rand() % 1000;
if (mov>=95) // we let the car change its lane in 5% of cases
if (mov>=990) // we let the car change its lane in 5% of cases
{
if (traffic[k]->wX==-0.75) traffic[k]->Turn = +1;
else if (traffic[k]->wX==0.75) traffic[k]->Turn = -1;
@ -662,11 +730,11 @@ int main(void)
}
*/
traffic[k]->wX += (float) traffic[k]->Turn * 0.10f;
if (traffic[k]->wX>=-0.80 && traffic[k]->wX<=-0.70) traffic[k]->wX = -0.75, traffic[k]->Turn = 0;
else if (traffic[k]->wX>=-0.30 && traffic[k]->wX<=-0.20) traffic[k]->wX = -0.25, traffic[k]->Turn = 0;
else if (traffic[k]->wX>=0.20 && traffic[k]->wX<=0.30) traffic[k]->wX = 0.25, traffic[k]->Turn = 0;
else if (traffic[k]->wX>=0.70 && traffic[k]->wX<=0.80) 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;
else if (traffic[k]->wX>=0.225 && traffic[k]->wX<=0.275) traffic[k]->wX = 0.25, traffic[k]->Turn = 0;
else if (traffic[k]->wX>=0.725 && traffic[k]->wX<=0.775) traffic[k]->wX = 0.75, traffic[k]->Turn = 0;
}
}
@ -685,7 +753,7 @@ int main(void)
circuit[k]->CumulatedCurve = cumulCurve; // This is the curve accumulated when we are drawing curves
cumulCurve += circuit[k]->Curve;
if (BDrawCars)
if (BDrawCars && mode==0)
for( unsigned int l=0; l<circuit[k]->CarList.size(); l++ ) // For all cars inside that road segment
{
uint8_t indexCar = circuit[k]->CarList[l];
@ -733,40 +801,99 @@ int main(void)
if (BDrawDeco)
drawDecoration( k );
if (BDrawCars)
if (BDrawCars && mode==0)
for( unsigned int l=0; l<circuit[k]->CarList.size(); l++ ) // For all cars inside that road segment
{
uint8_t indexCar = circuit[k]->CarList[l];
drawTraffic( indexCar );
}
if (BDrawCars) circuit[k]->CarList.clear();
if (BDrawCars && mode==0)
circuit[k]->CarList.clear();
}
uint32_t handicap;
if (DiffLevel==0) handicap=0; // we use normal additional time when easy
else if (DiffLevel==1) handicap=1000000; // we remove 2 seconds when normal
else if (DiffLevel==2) handicap=2000000; // we remove 4 seconds when hard
else handicap=0;
if (circuit[indexstart]->Special == CHECKPOINT && circuit[indexstart]->CheckValidated == false)
// Action raised when passing through the different points : START, CHECKPOINTS/ FINISH LINE
if (circuit[indexstart]->Special == CHECKPOINT && circuit[indexstart]->CheckValidated == false && circuit[indexstart]->CheckLap!=currentLap)
{
start_time+=60000000;
start_time += circuit[indexstart]->Extratime - handicap;
circuit[indexstart]->CheckLap=currentLap;
stage++;
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)
else if (circuit[indexstart]->Special == FINISH && circuit[indexstart]->CheckValidated == false && circuit[indexstart]->CheckLap!=currentLap)
{
circuit[indexstart]->CheckLap=currentLap;
stage++;
if (currentLap<numlap)
{
currentLap++;
start_time += circuit[indexstart]->Extratime - handicap;
score += 5000;
cam->decZ( indexstart*SEGMENT_LENGTH );
for( unsigned int k=0; k<traffic.size(); k++ ) traffic[k]->wZ-=indexstart*SEGMENT_LENGTH;
if (mode==0)
for( unsigned int k=0; k<traffic.size(); k++ )
traffic[k]->wZ-=indexstart*SEGMENT_LENGTH;
}
else
{
circuit[indexstart]->CheckValidated = true;
score+=20000;
finishSequence=true;
}
#if DEBUGXXX==1
if (usb_is_open())
{
//sprintf( texttosend, "FNSH : Chrono %D - %D", elapsed_time/1000000, start_time/1000000 );
sprintf( texttosend, "FNSH : 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 == START && circuit[indexstart]->CheckValidated == false)
else if (circuit[indexstart]->Special == START && circuit[indexstart]->CheckValidated == false && circuit[indexstart]->CheckLap!=currentLap)
{
start_time=99000000;
circuit[indexstart]->CheckValidated = true;
if (currentLap==1)
{
score = 0;
start_time = circuit[indexstart]->Extratime - handicap;
circuit[indexstart]->CheckLap=currentLap;
elapsed_time = 0;
}
else
{
circuit[indexstart]->CheckLap = currentLap;
start_time += circuit[indexstart]->Extratime - handicap;
circuit[indexstart]->CheckValidated = true;
}
#if DEBUGXXX==1
if (usb_is_open())
{
//sprintf( texttosend, "STRT : Chrono %D - %D", elapsed_time/1000000, start_time/1000000 );
sprintf( texttosend, "STRT : 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
}
@ -813,7 +940,8 @@ 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] );
score = fround(cam->cZ)/100;
if (direction==+1) score += speed*dt/10;
float drawspeed = (float) (speed*5.0f);
@ -1014,7 +1142,6 @@ int main(void)
// Free all memory
freeTraffic();
freeDecoration();
@ -1024,8 +1151,15 @@ int main(void)
for(unsigned int i=0; i<nuages.size(); i++ ) delete nuages[i]; // Not to forget to delete each elements
nuages.clear();
for(unsigned int i=0; i<traffic.size(); i++ ) delete traffic[i]; // Not to forget to delete each elements
traffic.clear();
if (mode==0)
{
freeTraffic();
for(unsigned int i=0; i<traffic.size(); i++ )
delete traffic[i]; // Not to forget to delete each elements
traffic.clear();
}
}
}
@ -1040,5 +1174,9 @@ int main(void)
delete cam;
// We set back zeros at the end of the program
if (canWeAllocateMore) memset( extended_ram.start, 0, 0x00300000 );
return 1;
}

View File

@ -14,6 +14,12 @@
#include "../colors.h"
#include "../include/utils.h"
#include <gint/usb.h>
#include <gint/usb-ff-bulk.h>
#include <gint/kmalloc.h>
#include <stdio.h>
extern uint8_t NB_CARS_TRAFFIC;
extern std::vector<Segment*> circuit;
@ -61,103 +67,187 @@ void createCircuit( int circuitNumber )
{
if (circuitNumber==0)
{
addStartLine( PLAINS );
addStraightLine( L_VERYSHORT, PLAINS );
addStraightLine( L_VERYSHORT, PLAINS );
addStraightLine( L_VERYSHORT, PLAINS );
addStraightLine( L_VERYSHORT, PLAINS );
addStartLine( PLAINS, 70 ); // Start = 0s
addStraightLine( L_VERYLONG, PLAINS );
addCurve( L_LONG, C_EASY, LEFT_CURVE, PLAINS );
addCurve( L_LONG, C_EASY, RIGHT_CURVE, PLAINS );
addCurve( L_LONG, C_EASY, LEFT_CURVE, PLAINS );
addStraightLine( L_MEDIUM, PLAINS );
addCheckPoint( PLAINS, 60 ); // time around 66s
addStraightLine( L_MEDIUM, PLAINS );
addHill( L_MEDIUM, H_SMALL, UP_HILL, PLAINS );
addHill( L_MEDIUM, H_SMALL, DOWN_HILL, PLAINS );
addCurve( L_LONG, C_EASY, RIGHT_CURVE, PLAINS );
addStraightLine( L_VERYLONG, PLAINS );
addCheckPoint( PLAINS, 70 ); // time around 121s = Delta: 55s
addStraightLine( L_VERYLONG, PLAINS );
addCurve( L_LONG, C_EASY, LEFT_CURVE, PLAINS );
addCurve( L_LONG, C_EASY, RIGHT_CURVE, PLAINS );
addCurve( L_LONG, C_EASY, LEFT_CURVE, PLAINS );
addStraightLine( L_MEDIUM, PLAINS );
addCheckPoint( PLAINS, 20 ); // time around 188s = Delta: 67s
addStraightLine( L_VERYSHORT, PLAINS );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, PLAINS );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, PLAINS );
addStraightLine( L_VERYSHORT, PLAINS );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, PLAINS );
addCheckPoint( PLAINS );
addStraightLine( L_VERYSHORT, PLAINS );
addCheckPoint( PLAINS );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, PLAINS );
addCurve( L_SHORT, C_HARD, RIGHT_CURVE, PLAINS );
addStraightLine( L_LONG, PLAINS );
addHill( L_MEDIUM, H_BIG, UP_HILL, PLAINS );
addHill( L_MEDIUM, H_BIG, DOWN_HILL, PLAINS );
addCheckPoint( PLAINS, 60 ); // time around 204s = Delta: 16s
addStraightLine( L_MEDIUM, PLAINS );
addHill( L_MEDIUM, H_SMALL, UP_HILL, PLAINS );
addHill( L_MEDIUM, H_SMALL, DOWN_HILL, PLAINS );
addCurve( L_LONG, C_EASY, RIGHT_CURVE, PLAINS );
addStraightLine( L_VERYLONG, PLAINS );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, PLAINS );
addCheckPoint( PLAINS, 70 ); // time around 259s = Delta: 55s
addStraightLine( L_VERYLONG, PLAINS );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, PLAINS );
addCheckPoint( PLAINS );
addFinishLine( PLAINS );
addCurve( L_LONG, C_EASY, LEFT_CURVE, PLAINS );
addCurve( L_LONG, C_EASY, RIGHT_CURVE, PLAINS );
addCurve( L_LONG, C_EASY, LEFT_CURVE, PLAINS );
addStraightLine( L_MEDIUM, PLAINS );
addFinishLine( PLAINS, 0 ); // time around 326s = Delta: 67s
addStraightLine( L_VERYSHORT, PLAINS );
}
else if (circuitNumber==1)
{
addStartLine( DESERT );
addStraightLine( L_VERYSHORT, DESERT );
addStartLine( DESERT, 55 ); // Start = 0s
addStraightLine( L_LONG, DESERT );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, DESERT );
addStraightLine( L_LONG, DESERT );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, RIGHT_CURVE, DESERT );
addStraightLine( L_VERYSHORT, DESERT );
addCurve( L_MEDIUM, C_MEDIUM, RIGHT_CURVE, DESERT );
addCurve( L_SHORT, C_MEDIUM, LEFT_CURVE, DESERT );
addStraightLine( L_VERYSHORT, DESERT );
addCheckPoint( DESERT, 45 );
addStraightLine( L_VERYSHORT, DESERT );
addHill( L_MEDIUM, H_BIG, UP_HILL, DESERT );
addStraightLine( L_LONG, DESERT );
addHill( L_MEDIUM, H_BIG, DOWN_HILL, DESERT );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, DESERT );
addStraightLine( L_LONG, DESERT );
addCheckPoint( DESERT, 40 );
addStraightLine( L_VERYSHORT, DESERT );
addCurve( L_SHORT, C_MEDIUM, RIGHT_CURVE, DESERT );
addCurve( L_SHORT, C_MEDIUM, LEFT_CURVE, DESERT );
addCurve( L_SHORT, C_MEDIUM, RIGHT_CURVE, DESERT );
addCurve( L_SHORT, C_MEDIUM, LEFT_CURVE, DESERT );
addStraightLine( L_VERYSHORT, DESERT );
addHill( L_MEDIUM, H_BIG, UP_HILL, DESERT );
addStraightLine( L_LONG, DESERT );
addCheckPoint( DESERT, 30 );
addStraightLine( L_VERYSHORT, DESERT );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, DESERT );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, DESERT );
addStraightLine( L_VERYSHORT, DESERT );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_EASY, RIGHT_CURVE, DESERT );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, DESERT );
addCheckPoint( DESERT );
addStraightLine( L_VERYSHORT, DESERT );
addCheckPoint( DESERT );
addCheckPoint( DESERT, 75 );
addStraightLine( L_VERYSHORT, DESERT );
addHill( L_MEDIUM, H_BIG, DOWN_HILL, DESERT );
addStraightLine( L_VERYLONG, DESERT );
addStraightLine( L_LONG, DESERT );
addStraightLine( L_VERYLONG, DESERT );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, DESERT );
addStraightLine( L_VERYSHORT, DESERT );
addCheckPoint( DESERT, 35 );
addStraightLine( L_VERYSHORT, DESERT );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, DESERT );
addCurve( L_SHORT, C_HARD, RIGHT_CURVE, DESERT );
addStraightLine( L_LONG, DESERT );
addHill( L_MEDIUM, H_BIG, UP_HILL, DESERT );
addHill( L_MEDIUM, H_BIG, DOWN_HILL, DESERT );
addStraightLine( L_VERYLONG, DESERT );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, DESERT );
addStraightLine( L_VERYLONG, DESERT );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, DESERT );
addCheckPoint( DESERT );
addFinishLine( DESERT );
addStraightLine( L_VERYSHORT, DESERT );
addFinishLine( DESERT, 0 );
addStraightLine( L_VERYSHORT, DESERT );
}
else if (circuitNumber==2)
{
addStartLine( USA );
addStraightLine( L_VERYSHORT, USA );
addStartLine( USA, 35 );
addStraightLine( L_VERYSHORT, USA );
addStraightLine( L_VERYSHORT, USA );
addStraightLine( L_VERYSHORT, USA );
addStraightLine( L_VERYSHORT, USA );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, USA );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, USA );
addStraightLine( L_VERYSHORT, USA );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, USA );
addCheckPoint( USA );
addStraightLine( L_VERYSHORT, USA );
addCheckPoint( USA );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, USA );
addCurve( L_SHORT, C_HARD, RIGHT_CURVE, USA );
addCurve( L_SHORT, C_MEDIUM, LEFT_CURVE, USA );
addCurve( L_SHORT, C_MEDIUM, RIGHT_CURVE, USA );
addCurve( L_SHORT, C_MEDIUM, LEFT_CURVE, USA );
addCurve( L_SHORT, C_MEDIUM, RIGHT_CURVE, USA );
addCurvyHill( L_MEDIUM, H_MEDIUM, UP_HILL, C_HARD, LEFT_CURVE, USA );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, RIGHT_CURVE, USA );
addStraightLine( L_SHORT, USA );
addCheckPoint( USA, 60 );
addStraightLine( L_LONG, USA );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, USA );
addStraightLine( L_VERYSHORT, USA );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, LEFT_CURVE, USA );
addStraightLine( L_VERYSHORT, USA );
addCurve( L_LONG, C_MEDIUM, LEFT_CURVE, USA );
addHill( L_MEDIUM, H_BIG, UP_HILL, USA );
addStraightLine( L_VERYSHORT, USA );
addHill( L_MEDIUM, H_BIG, DOWN_HILL, USA );
addStraightLine( L_VERYSHORT, USA );
addCheckPoint( USA, 80 );
addStraightLine( L_VERYLONG, USA );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, USA );
addStraightLine( L_VERYLONG, USA );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, USA );
addCheckPoint( USA );
addFinishLine( USA );
addCurve( L_SHORT, C_MEDIUM, RIGHT_CURVE, USA );
addCurvyHill( L_MEDIUM, H_MEDIUM, UP_HILL, C_HARD, LEFT_CURVE, USA );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, USA );
addStraightLine( L_MEDIUM, USA );
addCheckPoint( USA, 70 );
addStraightLine( L_VERYLONG, USA );
addCurve( L_LONG, C_EASY, LEFT_CURVE, USA );
addCurve( L_LONG, C_EASY, RIGHT_CURVE, USA );
addCurve( L_LONG, C_EASY, LEFT_CURVE, USA );
addStraightLine( L_MEDIUM, USA );
addFinishLine( USA, 0 );
addStraightLine( L_VERYSHORT, USA );
}
else if (circuitNumber==3)
{
addStartLine( FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, FINLAND );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, FINLAND );
addStartLine( FINLAND, 30 );
addStraightLine( L_SHORT, FINLAND );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_EASY, LEFT_CURVE, FINLAND );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_MEDIUM, LEFT_CURVE, FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, FINLAND );
addCheckPoint( FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
addCheckPoint( FINLAND );
addCheckPoint( FINLAND, 90 );
addStraightLine( L_VERYSHORT, FINLAND );
addHill( L_MEDIUM, H_BIG, UP_HILL, FINLAND );
addHill( L_MEDIUM, H_BIG, DOWN_HILL, FINLAND );
addStraightLine( L_VERYLONG, FINLAND );
addCurve( L_LONG, C_HARD, LEFT_CURVE, FINLAND );
addStraightLine( L_VERYLONG, FINLAND );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
addCheckPoint( FINLAND, 90 );
addStraightLine( L_VERYSHORT, FINLAND );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, FINLAND );
addCurve( L_SHORT, C_HARD, RIGHT_CURVE, FINLAND );
addStraightLine( L_LONG, FINLAND );
@ -167,27 +257,81 @@ void createCircuit( int circuitNumber )
addCurve( L_SHORT, C_HARD, LEFT_CURVE, FINLAND );
addStraightLine( L_VERYLONG, FINLAND );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, FINLAND );
addCheckPoint( FINLAND );
addFinishLine( FINLAND );
addCheckPoint( FINLAND, 90 );
addStraightLine( L_VERYSHORT, FINLAND );
addHill( L_MEDIUM, H_BIG, UP_HILL, FINLAND );
addHill( L_MEDIUM, H_BIG, DOWN_HILL, FINLAND );
addStraightLine( L_VERYLONG, FINLAND );
addCurve( L_LONG, C_HARD, LEFT_CURVE, FINLAND );
addStraightLine( L_VERYLONG, FINLAND );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
addCheckPoint( FINLAND, 95 );
addStraightLine( L_LONG, FINLAND );
addHill( L_MEDIUM, H_BIG, UP_HILL, FINLAND );
addHill( L_MEDIUM, H_BIG, DOWN_HILL, FINLAND );
addStraightLine( L_VERYLONG, FINLAND );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, FINLAND );
addStraightLine( L_VERYLONG, FINLAND );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, FINLAND );
addStraightLine( L_LONG, FINLAND );
addFinishLine( FINLAND, 0 );
addStraightLine( L_VERYSHORT, FINLAND );
}
else if (circuitNumber==4)
{
addStartLine( AFRICA );
addStraightLine( L_VERYSHORT, AFRICA );
addStartLine( AFRICA, 55 ); // Start = 0s
addStraightLine( L_LONG, AFRICA );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, AFRICA );
addStraightLine( L_LONG, AFRICA );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, RIGHT_CURVE, AFRICA );
addStraightLine( L_VERYSHORT, AFRICA );
addCurve( L_MEDIUM, C_MEDIUM, RIGHT_CURVE, AFRICA );
addCurve( L_SHORT, C_MEDIUM, LEFT_CURVE, AFRICA );
addStraightLine( L_VERYSHORT, AFRICA );
addCheckPoint( AFRICA, 70 );
addStraightLine( L_VERYLONG, AFRICA );
addCurve( L_LONG, C_EASY, LEFT_CURVE, AFRICA );
addCurve( L_LONG, C_EASY, RIGHT_CURVE, AFRICA );
addCurve( L_LONG, C_EASY, LEFT_CURVE, AFRICA );
addStraightLine( L_MEDIUM, AFRICA );
addCheckPoint( AFRICA, 40 );
addStraightLine( L_VERYSHORT, AFRICA );
addCurve( L_SHORT, C_MEDIUM, RIGHT_CURVE, AFRICA );
addCurve( L_SHORT, C_MEDIUM, LEFT_CURVE, AFRICA );
addCurve( L_SHORT, C_MEDIUM, RIGHT_CURVE, AFRICA );
addCurve( L_SHORT, C_MEDIUM, LEFT_CURVE, AFRICA );
addStraightLine( L_VERYSHORT, AFRICA );
addHill( L_MEDIUM, H_BIG, UP_HILL, AFRICA );
addStraightLine( L_LONG, AFRICA );
addCheckPoint( AFRICA, 30 );
addStraightLine( L_VERYSHORT, AFRICA );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, AFRICA );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, AFRICA );
addStraightLine( L_VERYSHORT, AFRICA );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_EASY, RIGHT_CURVE, AFRICA );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, AFRICA );
addCheckPoint( AFRICA );
addStraightLine( L_VERYSHORT, AFRICA );
addCheckPoint( AFRICA );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, AFRICA );
addCurve( L_SHORT, C_HARD, RIGHT_CURVE, AFRICA );
addCheckPoint( AFRICA, 85 );
addStraightLine( L_VERYSHORT, AFRICA );
addHill( L_MEDIUM, H_BIG, UP_HILL, AFRICA );
addHill( L_MEDIUM, H_BIG, DOWN_HILL, AFRICA );
addStraightLine( L_VERYLONG, AFRICA );
addCurve( L_LONG, C_HARD, LEFT_CURVE, AFRICA );
addStraightLine( L_VERYLONG, AFRICA );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, AFRICA );
addStraightLine( L_VERYSHORT, AFRICA );
addCheckPoint( AFRICA, 95 );
addStraightLine( L_LONG, AFRICA );
addHill( L_MEDIUM, H_BIG, UP_HILL, AFRICA );
addHill( L_MEDIUM, H_BIG, DOWN_HILL, AFRICA );
@ -195,23 +339,24 @@ void createCircuit( int circuitNumber )
addCurve( L_SHORT, C_HARD, LEFT_CURVE, AFRICA );
addStraightLine( L_VERYLONG, AFRICA );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, AFRICA );
addCheckPoint( AFRICA );
addFinishLine( AFRICA );
addStraightLine( L_LONG, AFRICA );
addFinishLine( AFRICA, 0 );
addStraightLine( L_VERYSHORT, AFRICA );
}
if (circuitNumber==5)
{
addStraightLine( L_VERYSHORT, PLAINS );
addStartLine( PLAINS );
addStartLine( PLAINS, 30 );
addStraightLine( L_VERYSHORT, PLAINS );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, PLAINS );
addCurve( L_SHORT, C_HARD, RIGHT_CURVE, PLAINS );
addFinishLine( PLAINS );
addFinishLine( PLAINS, 30 );
addStraightLine( L_VERYSHORT, PLAINS );
}
else if (circuitNumber==6)
{
addStartLine( DESERT );
addStartLine( DESERT, 30 );
addStraightLine( L_VERYSHORT, DESERT );
addStraightLine( L_VERYSHORT, DESERT );
addStraightLine( L_VERYSHORT, DESERT );
@ -221,9 +366,9 @@ void createCircuit( int circuitNumber )
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, DESERT );
addStraightLine( L_VERYSHORT, DESERT );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, DESERT );
addCheckPoint( DESERT );
addCheckPoint( DESERT, 30 );
addStraightLine( L_VERYSHORT, DESERT );
addCheckPoint( DESERT );
addCheckPoint( DESERT, 30 );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, DESERT );
addCurve( L_SHORT, C_HARD, RIGHT_CURVE, DESERT );
addStraightLine( L_LONG, DESERT );
@ -233,13 +378,13 @@ void createCircuit( int circuitNumber )
addCurve( L_SHORT, C_HARD, LEFT_CURVE, DESERT );
addStraightLine( L_VERYLONG, DESERT );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, DESERT );
addCheckPoint( DESERT );
addFinishLine( DESERT );
addCheckPoint( DESERT, 30 );
addFinishLine( DESERT, 30 );
addStraightLine( L_VERYSHORT, DESERT );
}
else if (circuitNumber==7)
{
addStartLine( USA );
addStartLine( USA, 30 );
addStraightLine( L_VERYSHORT, USA );
addStraightLine( L_VERYSHORT, USA );
addStraightLine( L_VERYSHORT, USA );
@ -249,9 +394,9 @@ void createCircuit( int circuitNumber )
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, USA );
addStraightLine( L_VERYSHORT, USA );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, USA );
addCheckPoint( USA );
addCheckPoint( USA, 30 );
addStraightLine( L_VERYSHORT, USA );
addCheckPoint( USA );
addCheckPoint( USA, 30 );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, USA );
addCurve( L_SHORT, C_HARD, RIGHT_CURVE, USA );
addStraightLine( L_LONG, USA );
@ -261,13 +406,13 @@ void createCircuit( int circuitNumber )
addCurve( L_SHORT, C_HARD, LEFT_CURVE, USA );
addStraightLine( L_VERYLONG, USA );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, USA );
addCheckPoint( USA );
addFinishLine( USA );
addCheckPoint( USA, 30 );
addFinishLine( USA, 30 );
addStraightLine( L_VERYSHORT, USA );
}
else if (circuitNumber==8)
{
addStartLine( FINLAND );
addStartLine( FINLAND, 30 );
addStraightLine( L_VERYSHORT, FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
@ -277,9 +422,9 @@ void createCircuit( int circuitNumber )
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, FINLAND );
addStraightLine( L_VERYSHORT, FINLAND );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, FINLAND );
addCheckPoint( FINLAND );
addCheckPoint( FINLAND, 30 );
addStraightLine( L_VERYSHORT, FINLAND );
addCheckPoint( FINLAND );
addCheckPoint( FINLAND, 30 );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, FINLAND );
addCurve( L_SHORT, C_HARD, RIGHT_CURVE, FINLAND );
addStraightLine( L_LONG, FINLAND );
@ -289,13 +434,13 @@ void createCircuit( int circuitNumber )
addCurve( L_SHORT, C_HARD, LEFT_CURVE, FINLAND );
addStraightLine( L_VERYLONG, FINLAND );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, FINLAND );
addCheckPoint( FINLAND );
addFinishLine( FINLAND );
addCheckPoint( FINLAND, 30 );
addFinishLine( FINLAND, 30 );
addStraightLine( L_VERYSHORT, FINLAND );
}
else if (circuitNumber==9)
{
addStartLine( AFRICA );
addStartLine( AFRICA, 30 );
addStraightLine( L_VERYSHORT, AFRICA );
addStraightLine( L_VERYSHORT, AFRICA );
addStraightLine( L_VERYSHORT, AFRICA );
@ -305,9 +450,9 @@ void createCircuit( int circuitNumber )
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, AFRICA );
addStraightLine( L_VERYSHORT, AFRICA );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, AFRICA );
addCheckPoint( AFRICA );
addCheckPoint( AFRICA, 30 );
addStraightLine( L_VERYSHORT, AFRICA );
addCheckPoint( AFRICA );
addCheckPoint( AFRICA, 30 );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, AFRICA );
addCurve( L_SHORT, C_HARD, RIGHT_CURVE, AFRICA );
addStraightLine( L_LONG, AFRICA );
@ -317,8 +462,8 @@ void createCircuit( int circuitNumber )
addCurve( L_SHORT, C_HARD, LEFT_CURVE, AFRICA );
addStraightLine( L_VERYLONG, AFRICA );
addCurve( L_SHORT, C_EASY, LEFT_CURVE, AFRICA );
addCheckPoint( AFRICA );
addFinishLine( AFRICA );
addCheckPoint( AFRICA, 30 );
addFinishLine( AFRICA, 30 );
addStraightLine( L_VERYSHORT, AFRICA );
}
};
@ -554,7 +699,7 @@ inline int getRandom( int8_t biome )
}
void addCheckPoint( int8_t biome )
void addCheckPoint( int8_t biome, uint8_t extra )
{
double lastZ=0;
int16_t lastY=0;
@ -582,7 +727,11 @@ void addCheckPoint( int8_t biome )
if (seg!=nullptr)
{
seg->Environment = biome;
if (i==7) seg->Special = CHECKPOINT;
if (i==7)
{
seg->Special = CHECKPOINT;
seg->Extratime = (uint32_t) (extra)*1000000;
}
circuit.push_back( seg );
}
}
@ -599,7 +748,7 @@ void addCheckPoint( int8_t biome )
}
void addStartLine( int8_t biome )
void addStartLine( int8_t biome, uint8_t extra )
{
double lastZ=0;
int16_t lastY=0;
@ -627,7 +776,11 @@ void addStartLine( int8_t biome )
if (seg!=nullptr)
{
seg->Environment = biome;
if (i==7) seg->Special = START;
if (i==7)
{
seg->Special = START;
seg->Extratime = (uint32_t) (extra)*1000000;
}
circuit.push_back( seg );
}
}
@ -645,7 +798,7 @@ void addStartLine( int8_t biome )
void addFinishLine( int8_t biome )
void addFinishLine( int8_t biome, uint8_t extra )
{
double lastZ=0;
int16_t lastY=0;
@ -673,7 +826,11 @@ void addFinishLine( int8_t biome )
if (seg!=nullptr)
{
seg->Environment = biome;
if (i==7) seg->Special = FINISH;
if (i==7)
{
seg->Special = FINISH;
seg->Extratime = (uint32_t) (extra)*1000000;
}
circuit.push_back( seg );
}
}

View File

@ -706,23 +706,29 @@ void drawGameOptions( void )
if (CarsNumb==0)
{
dprint_opt(94, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <50>" );
if (GameOptionsSelection!=1) dprint_opt(92, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <50>" );
else dprint_opt(92, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <50>" );
}
else if (CarsNumb==1)
{
dprint_opt(94, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <100>" );
if (GameOptionsSelection!=1) dprint_opt(92, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <100>" );
else dprint_opt(92, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <100>" );
}
else if (CarsNumb==2)
else if (CarsNumb==1)
{
dprint_opt(94, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <200>" );
if (GameOptionsSelection!=1) dprint_opt(92, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <200>" );
else dprint_opt(92, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <200>" );
}
else if (CarsNumb==2)
{
dprint_opt(94, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <500>" );
if (GameOptionsSelection!=1) dprint_opt(92, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <500>" );
else dprint_opt(92, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <500>" );
}
else if (CarsNumb==3)
{
dprint_opt(94, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <1000>" );
if (GameOptionsSelection!=1) dprint_opt(92, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <1000>" );
else dprint_opt(92, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <1000>" );
}
dprint_opt(94, 82, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "PLAYER" );
dprint_opt(92, 80, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "PLAYER" );
@ -776,13 +782,6 @@ void drawGameOptions( void )
#endif
}
if (CarsNumb==0) NB_CARS_TRAFFIC=50;
else if (CarsNumb==1) NB_CARS_TRAFFIC=100;
else if (CarsNumb==2) NB_CARS_TRAFFIC=200;
else NB_CARS_TRAFFIC=150;
SkipTime = true; // To avoid counting or de-counting time during menu
return;
@ -866,7 +865,7 @@ void getInputGameOptions( void )
else if (GameOptionsSelection==2) selectedChar=0;
if (GameOptionsSelection==0 && DiffLevel<2) DiffLevel++;
else if (GameOptionsSelection==1 && CarsNumb<2) CarsNumb++;
else if (GameOptionsSelection==1 && CarsNumb<3) CarsNumb++;
}
#if IS_FXLIB==1