diff --git a/CppOutRun.layout b/CppOutRun.layout
index bbb7b91..e146200 100644
--- a/CppOutRun.layout
+++ b/CppOutRun.layout
@@ -2,9 +2,48 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -15,29 +54,9 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -45,65 +64,34 @@
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -111,26 +99,24 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/fixed.h b/src/fixed.h
index e4b00e3..cc8ea2a 100644
--- a/src/fixed.h
+++ b/src/fixed.h
@@ -1,5 +1,5 @@
//---
-// fixed: 16:16 fixed-point arithmetic
+// fixed: 48:16 fixed-point arithmetic
//---
#pragma once
#include
diff --git a/src/include/segment.h b/src/include/segment.h
index fc4bd6f..82dca37 100644
--- a/src/include/segment.h
+++ b/src/include/segment.h
@@ -37,7 +37,7 @@ class Segment
void Project3DFP( camera* c );
int8_t Environment = PLAINS;
- int8_t Special = 0;
+ int8_t Special = -1;
bool CheckValidated = false;
int8_t Curve=0;
diff --git a/src/main.cc b/src/main.cc
index 25bde48..a1360fd 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -416,11 +416,11 @@ 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);
-*/
+ /*
+ _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();
@@ -489,22 +489,22 @@ int main(void)
perf_create = prof_make();
prof_enter(perf_create);
- initData( ); // Positioning of the Camera
+ initData( ); // Positioning of the Camera
- createCircuit( selectedCircuit ); // Creates the circuit
+ createCircuit( selectedCircuit ); // Creates the circuit
- MAX_SEGMENT = circuit.size();
- uint32_t maxDistance = (MAX_SEGMENT-nbInterestingSegments-5)*SEGMENT_LENGTH;
+ MAX_SEGMENT = circuit.size();
+ uint32_t maxDistance = (MAX_SEGMENT-nbInterestingSegments-5)*SEGMENT_LENGTH;
- putBillBoards();
+ putBillBoards();
- createClouds(); // Creates the Sky and Clouds
+ createClouds(); // Creates the Sky and Clouds
- createTraffic( MAX_SEGMENT ); // Creates the cars
+ createTraffic( MAX_SEGMENT ); // Creates the cars
- prepareDecoration( CurrentCircuitBiome ); // Prepares the multiple variations of Decoration (image scaling)
+ prepareDecoration( CurrentCircuitBiome ); // Prepares the multiple variations of Decoration (image scaling)
- prepareTraffic(); // Prepares the multiple variations of Cars (image scaling)
+ prepareTraffic(); // Prepares the multiple variations of Cars (image scaling)
@@ -583,6 +583,7 @@ int main(void)
perf_project = prof_make();
prof_enter(perf_project);
+ minYRoad = SCREEN_HEIGHT;
if (BDrawCars)
{
@@ -599,14 +600,10 @@ int main(void)
//else
//traffic[k]->visible = false;
}
- }
- minYRoad = SCREEN_HEIGHT;
+ float roadpart = f2float(cam->cX)/(float) ROAD_WIDTH;
- float roadpart = f2float(cam->cX)/(float) ROAD_WIDTH;
-
- // Update car positions : car with higher speed change line not to collide with player
- if (BDrawCars)
+ // Update car positions : car with higher speed change line not to collide with player
for(unsigned int l=0; lCarList.size(); l++ ) // For all cars inside that road segment
{
uint8_t indexCar = circuit[indexstart]->CarList[l];
@@ -618,8 +615,6 @@ int main(void)
}
}
-
- if (BDrawCars)
for( unsigned int l=0; lCarList.size(); l++ ) // For all cars inside that road segment
{
uint8_t indexCar = circuit[indexstart+1]->CarList[l];
@@ -629,15 +624,16 @@ int main(void)
speed = 2.0;
}
}
-
+ }
uint16_t cumulCurve=0;
+
for (int k=indexstart; k<=indexend; k++) // Need to project 1 more segment than actual drawing
{
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
- minYRoad = circuit[k]->Y;
+ //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
cumulCurve += circuit[k]->Curve;
@@ -660,8 +656,10 @@ int main(void)
prof_enter(perf_render);
- if (BDrawBack) drawSkyOptimised( DAY_BLUE_SKY );
- else drawSkyFull( DAY_BLUE_SKY );
+ //if (BDrawBack) drawSkyOptimised( DAY_BLUE_SKY );
+ //else drawSkyFull( DAY_BLUE_SKY );
+
+ drawSkyOptimised( DAY_BLUE_SKY );
if (BDrawClds)
@@ -697,11 +695,30 @@ int main(void)
if (BDrawCars) circuit[k]->CarList.clear();
}
+
if (circuit[indexstart]->Special == CHECKPOINT && circuit[indexstart]->CheckValidated == false)
{
start_time+=60000000;
circuit[indexstart]->CheckValidated = true;
}
+ else if (circuit[indexstart]->Special == FINISH && circuit[indexstart]->CheckValidated == false)
+ {
+ start_time+=60000000;
+ circuit[indexstart]->CheckValidated = true;
+ }
+ else if (circuit[indexstart]->Special == START && circuit[indexstart]->CheckValidated == false)
+ {
+ start_time=99000000;
+ circuit[indexstart]->CheckValidated = true;
+ }
+
+
+ // Draw a message when time is over
+ if (start_time<=0)
+ {
+ failSequence=true;
+ }
+
int mod_base=20;
int mod_comp=10;
@@ -778,6 +795,22 @@ int main(void)
else dsubimage( 48, 25, &speedhud, 0, 104, 76, 13, DIMAGE_NONE);
+
+
+ if (failSequence)
+ {
+ 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(255,0,255), 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" );
+ }
+
+
if (initiateStart) // We are in the start sequence with the countdown
{
dfont(&startseq);
@@ -808,7 +841,7 @@ int main(void)
}
else if (startRemaining<4 && startRemaining>-4)
{
- dimage( 198-bigflag.width/2, 112-bigflag.height/2, &bigflag );
+ dimage( 198-bigflag.width/2, 112-bigflag.height/2, &bigflag );
}
else if (startRemaining<-4)
{
@@ -884,6 +917,12 @@ int main(void)
l++;
}
+ /*
+ _uram_stats = kmalloc_get_gint_stats(_uram);
+ sprintf( texttosend, "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);
+ */
+
// Free all memory
freeTraffic();
diff --git a/src/src/circuit.cc b/src/src/circuit.cc
index 82dbca7..df6f2eb 100644
--- a/src/src/circuit.cc
+++ b/src/src/circuit.cc
@@ -433,11 +433,12 @@ void createCircuit( int circuitNumber )
void putBillBoards( void )
{
- for (unsigned int k = 0; kCurve;
+
+ int nextcurve = circuit[k+7]->Curve;
int currentcurve = circuit[k]->Curve;
- int nextslope = circuit[k+3]->Slope;
+ int nextslope = circuit[k+7]->Slope;
int currentslope = circuit[k]->Slope;
if (nextcurve==currentcurve && nextslope==currentslope)
@@ -451,12 +452,37 @@ void putBillBoards( void )
{
circuit[k]->RDeco=UPHILL;
circuit[k]->LDeco=UPHILL;
+
+ circuit[k+1]->RDeco=UPHILL;
+ circuit[k+1]->LDeco=UPHILL;
+
+ circuit[k+2]->RDeco=UPHILL;
+ circuit[k+2]->LDeco=UPHILL;
+
+ circuit[k+4]->RDeco=UPHILL;
+ circuit[k+4]->LDeco=UPHILL;
+
+ circuit[k+6]->RDeco=UPHILL;
+ circuit[k+6]->LDeco=UPHILL;
}
else if (nextslope<0) //downhill
{
circuit[k]->RDeco=DOWNHILL;
circuit[k]->LDeco=DOWNHILL;
+
+ circuit[k+1]->RDeco=DOWNHILL;
+ circuit[k+1]->LDeco=DOWNHILL;
+
+ circuit[k+2]->RDeco=DOWNHILL;
+ circuit[k+2]->LDeco=DOWNHILL;
+
+ circuit[k+4]->RDeco=DOWNHILL;
+ circuit[k+4]->LDeco=DOWNHILL;
+
+ circuit[k+6]->RDeco=DOWNHILL;
+ circuit[k+6]->LDeco=DOWNHILL;
}
+ k+=7;
}
else if (nextcurve!=currentcurve && nextslope==currentslope)
{
@@ -465,12 +491,37 @@ void putBillBoards( void )
{
circuit[k]->RDeco=LEFTTURN;
circuit[k]->LDeco=LEFTTURN;
+
+ circuit[k+1]->RDeco=LEFTTURN;
+ circuit[k+1]->LDeco=LEFTTURN;
+
+ circuit[k+2]->RDeco=LEFTTURN;
+ circuit[k+2]->LDeco=LEFTTURN;
+
+ circuit[k+4]->RDeco=LEFTTURN;
+ circuit[k+4]->LDeco=LEFTTURN;
+
+ circuit[k+6]->RDeco=LEFTTURN;
+ circuit[k+6]->LDeco=LEFTTURN;
}
else if (nextcurve>0) //downhill
{
circuit[k]->RDeco=RIGHTTURN;
circuit[k]->LDeco=RIGHTTURN;
+
+ circuit[k+1]->RDeco=RIGHTTURN;
+ circuit[k+1]->LDeco=RIGHTTURN;
+
+ circuit[k+2]->RDeco=RIGHTTURN;
+ circuit[k+2]->LDeco=RIGHTTURN;
+
+ circuit[k+4]->RDeco=RIGHTTURN;
+ circuit[k+4]->LDeco=RIGHTTURN;
+
+ circuit[k+6]->RDeco=RIGHTTURN;
+ circuit[k+6]->LDeco=RIGHTTURN;
}
+ k+=7;
}
else if (nextcurve!=currentcurve && nextslope!=currentslope)
{
@@ -478,20 +529,74 @@ void putBillBoards( void )
if (nextcurve<0) //uphill
{
circuit[k]->RDeco=LEFTTURN;
- if (nextslope>0) circuit[k]->LDeco=UPHILL;
- else if (nextslope<0) circuit[k]->LDeco=DOWNHILL;
+ circuit[k+1]->RDeco=LEFTTURN;
+ circuit[k+2]->RDeco=LEFTTURN;
+ circuit[k+4]->RDeco=LEFTTURN;
+ circuit[k+6]->RDeco=LEFTTURN;
+
+ if (nextslope>0)
+ {
+ circuit[k]->LDeco=UPHILL;
+ circuit[k+1]->LDeco=UPHILL;
+ circuit[k+2]->LDeco=UPHILL;
+ circuit[k+4]->LDeco=UPHILL;
+ circuit[k+6]->LDeco=UPHILL;
+ }
+ else if (nextslope<0)
+ {
+ circuit[k]->LDeco=DOWNHILL;
+ circuit[k+1]->LDeco=DOWNHILL;
+ circuit[k+2]->LDeco=DOWNHILL;
+ circuit[k+4]->LDeco=DOWNHILL;
+ circuit[k+6]->LDeco=DOWNHILL;
+ }
+ k+=7;
}
else if (nextcurve>0) //downhill
{
circuit[k]->LDeco=RIGHTTURN;
- if (nextslope>0) circuit[k]->RDeco=UPHILL;
- else if (nextslope<0) circuit[k]->RDeco=DOWNHILL;
+ circuit[k+1]->LDeco=RIGHTTURN;
+ circuit[k+2]->LDeco=RIGHTTURN;
+ circuit[k+4]->LDeco=RIGHTTURN;
+ circuit[k+6]->LDeco=RIGHTTURN;
+
+ if (nextslope>0)
+ {
+ circuit[k]->RDeco=UPHILL;
+ circuit[k+1]->RDeco=UPHILL;
+ circuit[k+2]->RDeco=UPHILL;
+ circuit[k+4]->RDeco=UPHILL;
+ circuit[k+6]->RDeco=UPHILL;
+ }
+ else if (nextslope<0)
+ {
+ circuit[k]->RDeco=DOWNHILL;
+ circuit[k+1]->RDeco=DOWNHILL;
+ circuit[k+2]->RDeco=DOWNHILL;
+ circuit[k+4]->RDeco=DOWNHILL;
+ circuit[k+6]->RDeco=DOWNHILL;
+ }
+ k+=7;
}
}
-
-
- if (nextcurve<0 && currentcurve!=nextcurve) circuit[k]->RDeco=LEFTTURN;
- if (nextcurve>0 && currentcurve!=nextcurve) circuit[k]->LDeco=RIGHTTURN;
+ else if (nextcurve<0 && currentcurve!=nextcurve)
+ {
+ circuit[k]->RDeco=LEFTTURN;
+ circuit[k+1]->RDeco=LEFTTURN;
+ circuit[k+2]->RDeco=LEFTTURN;
+ circuit[k+4]->RDeco=LEFTTURN;
+ circuit[k+6]->RDeco=LEFTTURN;
+ k+=7;
+ }
+ else if (nextcurve>0 && currentcurve!=nextcurve)
+ {
+ circuit[k]->LDeco=RIGHTTURN;
+ circuit[k+1]->LDeco=RIGHTTURN;
+ circuit[k+2]->LDeco=RIGHTTURN;
+ circuit[k+4]->LDeco=RIGHTTURN;
+ circuit[k+6]->LDeco=RIGHTTURN;
+ k+=7;
+ }
}
}
diff --git a/src/src/drawstuff.cc b/src/src/drawstuff.cc
index e568f88..414354a 100644
--- a/src/src/drawstuff.cc
+++ b/src/src/drawstuff.cc
@@ -114,7 +114,7 @@ void drawSky( uint16_t color )
void drawSkyOptimised( uint16_t color )
{
- dma_memset(gint_vram, (color << 16) | color, 396 * (minYRoad+10) * 2);
+ dma_memset(gint_vram, (color << 16) | color, 396 * (minYRoad+2) * 2);
};
void drawSky( uint8_t R, uint8_t G, uint8_t B )