2022-03-04 21:58:14 +01:00
# include <gint/display.h>
# include <gint/drivers/r61524.h>
2022-03-19 23:29:36 +01:00
# include <gint/rtc.h>
2022-03-04 21:58:14 +01:00
# include <gint/keyboard.h>
# include <gint/gint.h>
# include <gint/defs/types.h>
# include <fxlibc/printf.h>
# include <libprof.h>
# include <gint/usb.h>
# include <gint/usb-ff-bulk.h>
# include <math.h>
# include <vector>
2022-03-11 22:44:47 +01:00
# include "parameters.h"
# include "colors.h"
2022-03-04 21:58:14 +01:00
# include "include/camera.h"
# include "include/segment.h"
# include "include/circuit.h"
# include "include/drawstuff.h"
2022-03-07 15:24:04 +01:00
# include "include/clouds.h"
2022-03-11 22:44:47 +01:00
# include "include/cars.h"
2022-03-15 20:20:28 +01:00
# include "include/menus.h"
2022-03-04 21:58:14 +01:00
2022-03-21 23:34:51 +01:00
# include <gint/kmalloc.h>
# include <stdio.h>
2022-03-04 21:58:14 +01:00
2022-03-06 20:21:22 +01:00
extern bopti_image_t player ;
2022-03-22 22:55:45 +01:00
extern font_t speedfont , startseq ;
2022-03-13 11:32:00 +01:00
extern bopti_image_t speedhud ;
2022-03-22 22:55:45 +01:00
extern bopti_image_t flag , bigflag ;
2022-03-04 21:58:14 +01:00
2022-03-16 23:18:18 +01:00
int CurrentCircuitBiome = PLAINS ;
2022-03-04 21:58:14 +01:00
std : : vector < Segment * > circuit ;
2022-03-07 15:24:04 +01:00
std : : vector < Clouds * > nuages ;
2022-03-11 22:44:47 +01:00
std : : vector < Cars * > traffic ;
2022-03-17 21:59:52 +01:00
int MAX_SEGMENT = 0 ;
camera * cam ;
2022-03-04 21:58:14 +01:00
2022-03-06 20:21:22 +01:00
2022-03-20 21:34:34 +01:00
struct DataPerf
{
uint8_t update = 0 ;
uint8_t project = 0 ;
uint8_t render = 0 ;
} ;
# define MAXDATA 120
DataPerf GraphPerf [ MAXDATA ] ;
unsigned int DataIndex = 0 ;
2022-03-04 21:58:14 +01:00
bool stop = false ;
2022-03-22 22:55:45 +01:00
bool exitToOS = false ;
2022-03-04 21:58:14 +01:00
bool record = false ;
bool screenshot = false ;
2022-03-11 22:44:47 +01:00
2022-03-06 20:21:22 +01:00
bool ShowDebug1 = false ;
bool ShowDebug2 = false ;
2022-03-11 22:44:47 +01:00
bool ShowDebug3 = false ;
bool BDrawDeco = true ;
bool BDrawClds = true ;
bool BDrawCars = true ;
2022-03-22 15:08:36 +01:00
bool BDrawBack = true ;
2022-03-20 21:34:34 +01:00
bool BDrawFPS = false ;
2022-03-11 22:44:47 +01:00
2022-03-22 15:08:36 +01:00
bool OptionMode = false ;
bool PauseMode = false ;
2022-03-22 22:55:45 +01:00
bool SkipTime = false ;
2022-03-04 21:58:14 +01:00
uint16_t currentcurve = 0 ;
uint8_t shiftcolor = 0 ;
2022-03-19 23:29:36 +01:00
2022-03-13 11:32:00 +01:00
float speed = 0.0 ;
float maxspeedforward = 5.0 ;
float maxspeedbackward = 2.0 ;
2022-03-04 21:58:14 +01:00
int direction = 1 ;
bool speedcontrol = false ;
2022-03-11 22:44:47 +01:00
uint8_t minYRoad = 224 ; // We will track the upper Y (in fact the minimum Y during the RoadDrawing to optimize the rendering of the Sky
int8_t viewside = 0 ;
int deltaFarbackground = 0 ;
int deltaNearbackground = 0 ;
int lastindex = 0 ;
int CC = 0 ; // current curve
int CS = 0 ;
2022-03-21 23:34:51 +01:00
void initEverything ( void )
{
CurrentCircuitBiome = PLAINS ;
circuit . clear ( ) ;
nuages . clear ( ) ;
traffic . clear ( ) ;
MAX_SEGMENT = 0 ;
DataIndex = 0 ;
stop = false ;
record = false ;
screenshot = false ;
ShowDebug1 = false ;
ShowDebug2 = false ;
ShowDebug3 = false ;
BDrawDeco = true ;
BDrawClds = true ;
BDrawCars = true ;
BDrawFPS = false ;
currentcurve = 0 ;
shiftcolor = 0 ;
speed = 0.0 ;
maxspeedforward = 5.0 ;
maxspeedbackward = 2.0 ;
direction = 1 ;
speedcontrol = false ;
minYRoad = 224 ; // We will track the upper Y (in fact the minimum Y during the RoadDrawing to optimize the rendering of the Sky
viewside = 0 ;
deltaFarbackground = 0 ;
deltaNearbackground = 0 ;
lastindex = 0 ;
CC = 0 ; // current curve
CS = 0 ;
}
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 ;
}
2022-03-11 22:44:47 +01:00
static void get_inputs ( float dt , int index )
2022-03-04 21:58:14 +01:00
{
2022-03-11 22:44:47 +01:00
CC = circuit [ index ] - > Curve ;
CS = circuit [ index ] - > Slope ;
2022-03-04 21:58:14 +01:00
key_event_t ev ;
while ( ( ev = pollevent ( ) ) . type ! = KEYEV_NONE )
{
}
speedcontrol = false ;
2022-03-11 22:44:47 +01:00
viewside = 0 ;
if ( CC < 0 )
{
viewside = - 1 ;
2022-03-19 23:29:36 +01:00
//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
2022-03-11 22:44:47 +01:00
}
else if ( CC > 0 )
{
viewside = + 1 ;
2022-03-19 23:29:36 +01:00
//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
2022-03-11 22:44:47 +01:00
}
if ( keydown ( KEY_LEFT ) )
{
2022-03-19 23:29:36 +01:00
//cam->decX(25.0);
cam - > decX ( 5.0 * speed * direction ) ;
2022-03-11 22:44:47 +01:00
viewside = - 1 ;
if ( CC < 0 ) viewside = - 2 ; // We are in a curve and turning
if ( CC > 0 ) viewside = 0 ;
}
if ( keydown ( KEY_RIGHT ) )
{
2022-03-19 23:29:36 +01:00
//cam->incX(25.0);
cam - > incX ( 5.0 * speed * direction ) ;
2022-03-11 22:44:47 +01:00
viewside = 1 ;
if ( CC > 0 ) viewside = + 2 ;
if ( CC < 0 ) viewside = 0 ;
}
2022-03-04 21:58:14 +01:00
2022-03-19 23:29:36 +01:00
if ( keydown ( KEY_SHIFT ) ) // Accelerates
2022-03-04 21:58:14 +01:00
{
if ( direction = = - 1 & & speed > 0 )
{
direction = - 1 ;
speed - = 0.5 ;
if ( speed < 0 ) speed = 0 ;
cam - > decZ ( speed * dt ) ;
}
else
{
direction = 1 ;
speed + = 0.05 ;
if ( speed > maxspeedforward ) speed = maxspeedforward ;
cam - > incZ ( speed * dt ) ;
}
speedcontrol = true ;
}
2022-03-15 22:02:53 +01:00
2022-03-19 23:29:36 +01:00
if ( keydown ( KEY_ALPHA ) ) // breaks or rear if speed <0
2022-03-04 21:58:14 +01:00
{
if ( direction = = 1 & & speed > 0 )
{
direction = 1 ;
speed - = 0.5 ;
if ( speed < 0 ) speed = 0 ;
cam - > incZ ( speed * dt ) ;
}
else
{
direction = - 1 ;
speed + = 0.025 ;
if ( speed > maxspeedbackward ) speed = maxspeedbackward ;
cam - > decZ ( speed * dt ) ;
}
speedcontrol = true ;
}
2022-03-22 22:55:45 +01:00
if ( keydown ( KEY_EXIT ) ) drawPauseQuit ( ) ;
2022-03-04 21:58:14 +01:00
2022-03-22 15:08:36 +01:00
if ( keydown ( KEY_OPTN ) ) drawOptions ( ) ;
2022-03-11 22:44:47 +01:00
# if IS_FXLIB==1
if ( keydown ( KEY_XOT ) )
{
ShowDebug1 = false ;
ShowDebug2 = false ;
ShowDebug3 = false ;
}
if ( keydown ( KEY_LOG ) )
2022-03-06 20:21:22 +01:00
{
2022-03-11 22:44:47 +01:00
ShowDebug1 = true ;
2022-03-06 20:21:22 +01:00
ShowDebug2 = false ;
2022-03-11 22:44:47 +01:00
ShowDebug3 = false ;
2022-03-06 20:21:22 +01:00
}
2022-03-11 22:44:47 +01:00
if ( keydown ( KEY_LN ) )
2022-03-06 20:21:22 +01:00
{
ShowDebug1 = false ;
2022-03-11 22:44:47 +01:00
ShowDebug2 = true ;
ShowDebug3 = false ;
2022-03-06 20:21:22 +01:00
}
2022-03-11 22:44:47 +01:00
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 ;
2022-03-20 21:34:34 +01:00
if ( keydown ( KEY_F4 ) ) BDrawFPS = ! BDrawFPS ;
2022-03-06 20:21:22 +01:00
2022-03-11 22:44:47 +01:00
if ( keydown ( KEY_F5 ) ) screenshot = true ;
2022-03-04 21:58:14 +01:00
if ( keydown ( KEY_F6 ) ) record = ! record ;
2022-03-11 22:44:47 +01:00
# endif // IS_FXLIB
2022-03-04 21:58:14 +01:00
if ( speedcontrol = = false )
{
2022-03-19 23:29:36 +01:00
speed - = 0.1 ;
2022-03-04 21:58:14 +01:00
if ( speed < 0 ) speed = 0 ;
if ( direction = = 1 )
cam - > incZ ( speed * dt ) ;
else
cam - > decZ ( speed * dt ) ;
}
2022-03-11 22:44:47 +01:00
2022-03-21 23:34:51 +01:00
// Adjust position of the background
2022-03-11 22:44:47 +01:00
if ( lastindex ! = index )
{
deltaFarbackground - = CC * speed * dt / 250 ;
deltaNearbackground - = CC * speed * dt / 100 ;
}
lastindex = index ;
2022-03-21 23:34:51 +01:00
// adjust speed if we drive on the side of the road
2022-03-11 22:44:47 +01:00
if ( fround ( cam - > cX ) < - 1 * ROAD_WIDTH & & speed > 2.0 ) speed = 2.0 ;
if ( fround ( cam - > cX ) > ROAD_WIDTH & & speed > 2.0 ) speed = 2.0 ;
if ( fround ( cam - > cX ) < - 1.35 * ROAD_WIDTH & & speed > 0.0 )
{
speed = 0.0 ;
2022-03-19 23:29:36 +01:00
cam - > cX = fix ( - 0.0 * ROAD_WIDTH ) ; //set the car in the center of the road (was formerly -0.75)
2022-03-11 22:44:47 +01:00
}
if ( fround ( cam - > cX ) > 1.35 * ROAD_WIDTH & & speed > 0.0 )
{
speed = 0.0 ;
2022-03-19 23:29:36 +01:00
cam - > cX = fix ( 0.0 * ROAD_WIDTH ) ; //set the car in the center of the road (was formerly 0.75)
2022-03-11 22:44:47 +01:00
}
2022-03-04 21:58:14 +01:00
}
2022-03-22 22:55:45 +01:00
static void get_minimum_inputs ( void )
{
key_event_t ev ;
while ( ( ev = pollevent ( ) ) . type ! = KEYEV_NONE )
{
}
if ( keydown ( KEY_EXIT ) ) drawPauseQuit ( ) ;
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 ;
# endif // IS_FXLIB
}
2022-03-21 23:34:51 +01:00
2022-03-04 21:58:14 +01:00
int main ( void )
{
__printf_enable_fp ( ) ;
__printf_enable_fixed ( ) ;
2022-03-15 20:20:28 +01:00
# if IS_FXLIB==1
2022-03-04 21:58:14 +01:00
usb_interface_t const * interfaces [ ] = { & usb_ff_bulk , NULL } ;
usb_open ( interfaces , GINT_CALL_NULL ) ;
2022-03-15 20:20:28 +01:00
# endif
2022-03-04 21:58:14 +01:00
2022-03-17 21:59:52 +01:00
2022-03-21 23:34:51 +01:00
kmalloc_arena_t * _uram = kmalloc_get_arena ( " _uram " ) ;
kmalloc_gint_stats_t * _uram_stats ;
2022-03-19 23:29:36 +01:00
srand ( rtc_ticks ( ) ) ;
2022-03-15 20:20:28 +01:00
2022-03-04 21:58:14 +01:00
prof_init ( ) ;
2022-03-15 20:20:28 +01:00
drawStartTitle ( ) ;
2022-03-21 23:34:51 +01:00
char texttosend [ 1024 ] ;
2022-03-17 21:59:52 +01:00
2022-03-22 22:55:45 +01:00
exitToOS = false ;
2022-03-15 20:20:28 +01:00
do
{
2022-03-23 21:35:29 +01:00
/*
_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 ) ;
*/
2022-03-21 23:34:51 +01:00
// Try to restart from very begining
initEverything ( ) ;
2022-03-17 21:59:52 +01:00
prof_t perf_update , perf_create , perf_project , perf_render ;
int32_t start_time = 99000000 ;
uint32_t score = 99999 ;
uint8_t stage = 0 ;
2022-03-19 23:29:36 +01:00
int8_t selectedCircuit = 0 ;
2022-03-17 21:59:52 +01:00
uint32_t time_update = 0 , time_create = 0 , time_project = 0 , time_render = 0 ;
exitToOS = false ;
stop = false ;
bool exitflag = false ;
do
2022-03-15 20:20:28 +01:00
{
2022-03-17 21:59:52 +01:00
exitflag = false ;
stage = drawMainMenu ( ) ;
if ( stage = = 0 | | stage = = 1 )
{
selectedCircuit = drawMenuCircuitSelect ( ) ;
if ( selectedCircuit ! = - 1 ) exitflag = true ;
}
else if ( stage = = 2 )
{
2022-03-22 15:08:36 +01:00
drawOptions ( ) ;
2022-03-17 21:59:52 +01:00
}
else if ( stage = = 3 )
{
drawCredit ( ) ;
}
else if ( stage = = 4 )
{
// Exit Menu TO BE DONE
// quick and dirty
exitToOS = true ;
exitflag = true ;
}
2022-03-15 20:20:28 +01:00
}
2022-03-17 21:59:52 +01:00
while ( ! exitflag ) ;
if ( exitToOS = = false )
2022-03-15 20:20:28 +01:00
{
2022-03-17 21:59:52 +01:00
stage = selectedCircuit ;
2022-03-15 20:20:28 +01:00
2022-03-17 21:59:52 +01:00
if ( selectedCircuit = = 0 ) CurrentCircuitBiome = PLAINS ;
else if ( selectedCircuit = = 1 ) CurrentCircuitBiome = DESERT ;
else if ( selectedCircuit = = 2 ) CurrentCircuitBiome = USA ;
else if ( selectedCircuit = = 3 ) CurrentCircuitBiome = FINLAND ;
else if ( selectedCircuit = = 4 ) CurrentCircuitBiome = AFRICA ;
else if ( selectedCircuit = = 5 ) CurrentCircuitBiome = PLAINS ;
else if ( selectedCircuit = = 6 ) CurrentCircuitBiome = DESERT ;
else if ( selectedCircuit = = 7 ) CurrentCircuitBiome = USA ;
else if ( selectedCircuit = = 8 ) CurrentCircuitBiome = FINLAND ;
else if ( selectedCircuit = = 9 ) CurrentCircuitBiome = AFRICA ;
else CurrentCircuitBiome = PLAINS ;
2022-03-15 20:20:28 +01:00
2022-03-16 23:18:18 +01:00
2022-03-17 21:59:52 +01:00
int nbInterestingSegments = ( MAX_RENDER_DISTANCE / SEGMENT_LENGTH ) ; // the number of segments to be projected considering the rendering distance
2022-03-16 23:18:18 +01:00
2022-03-15 20:20:28 +01:00
2022-03-17 21:59:52 +01:00
perf_create = prof_make ( ) ;
prof_enter ( perf_create ) ;
2022-03-04 21:58:14 +01:00
2022-03-23 21:35:29 +01:00
initData ( ) ; // Positioning of the Camera
2022-03-21 23:34:51 +01:00
2022-03-23 21:35:29 +01:00
createCircuit ( selectedCircuit ) ; // Creates the circuit
2022-03-21 23:34:51 +01:00
2022-03-23 21:35:29 +01:00
MAX_SEGMENT = circuit . size ( ) ;
uint32_t maxDistance = ( MAX_SEGMENT - nbInterestingSegments - 5 ) * SEGMENT_LENGTH ;
2022-03-21 23:34:51 +01:00
2022-03-23 21:35:29 +01:00
putBillBoards ( ) ;
2022-03-21 23:34:51 +01:00
2022-03-23 21:35:29 +01:00
createClouds ( ) ; // Creates the Sky and Clouds
2022-03-04 21:58:14 +01:00
2022-03-23 21:35:29 +01:00
createTraffic ( MAX_SEGMENT ) ; // Creates the cars
2022-03-19 23:29:36 +01:00
2022-03-23 21:35:29 +01:00
prepareDecoration ( CurrentCircuitBiome ) ; // Prepares the multiple variations of Decoration (image scaling)
2022-03-21 23:34:51 +01:00
2022-03-23 21:35:29 +01:00
prepareTraffic ( ) ; // Prepares the multiple variations of Cars (image scaling)
2022-03-04 21:58:14 +01:00
2022-03-19 23:29:36 +01:00
2022-03-12 21:56:55 +01:00
2022-03-17 21:59:52 +01:00
prof_leave ( perf_create ) ;
time_create = prof_time ( perf_create ) ;
2022-03-12 21:56:55 +01:00
2022-03-17 21:59:52 +01:00
//--------------
2022-03-19 23:29:36 +01:00
2022-03-04 21:58:14 +01:00
2022-03-17 21:59:52 +01:00
int indexstart = 0 ;
int indexend = 0 ;
2022-03-04 21:58:14 +01:00
2022-03-19 23:29:36 +01:00
float dt = 0 ;
2022-03-17 21:59:52 +01:00
uint16_t l = 0 ;
uint32_t remaining_time ;
2022-03-06 20:21:22 +01:00
2022-03-20 21:34:34 +01:00
DataIndex = 0 ;
2022-03-22 22:55:45 +01:00
bool initiateStart = true ; // are we in the start sequence ?
int32_t startCount = 6000000 ;
int32_t startRemaining ;
bool finishSequence = false ; // Did we reached the end of the race ?
bool failSequence = false ; // Did we run out of time ?
2022-03-17 21:59:52 +01:00
while ( ! stop )
{
2022-03-04 21:58:14 +01:00
2022-03-20 21:34:34 +01:00
2022-03-17 21:59:52 +01:00
perf_update = prof_make ( ) ;
prof_enter ( perf_update ) ;
2022-03-04 21:58:14 +01:00
2022-03-22 22:55:45 +01:00
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
2022-03-11 22:44:47 +01:00
2022-03-22 22:55:45 +01:00
if ( ! SkipTime )
{
dt = ( ( float ) ( time_update + time_render + time_project ) / 1000.0 ) ;
}
else
{
dt = 0 ;
SkipTime = false ;
}
2022-03-11 22:44:47 +01:00
2022-03-22 22:55:45 +01:00
if ( initiateStart )
{
startCount - = dt * 1000 ;
startRemaining = ( ( float ) ( startCount ) / 100000.0 ) ;
}
start_time - = dt * 1000 ;
2022-03-17 21:59:52 +01:00
if ( start_time < 0 ) start_time = 0 ;
remaining_time = ( ( float ) ( start_time ) / 1000000.0 ) ;
2022-03-13 11:32:00 +01:00
2022-03-17 21:59:52 +01:00
//--------------
if ( fround ( cam - > cZ ) < = 0 ) cam - > cZ = fixdouble ( 0.0 ) ;
if ( fround ( cam - > cZ ) > = maxDistance ) cam - > cZ = fixdouble ( maxDistance ) ;
2022-03-04 21:58:14 +01:00
2022-03-17 21:59:52 +01:00
indexstart = fround ( cam - > cZ ) / SEGMENT_LENGTH ;
if ( indexstart < 0 ) indexstart = 0 ;
2022-03-13 11:32:00 +01:00
2022-03-17 21:59:52 +01:00
indexend = indexstart + nbInterestingSegments + 1 ;
if ( indexstart > MAX_SEGMENT - nbInterestingSegments - 2 ) indexstart = MAX_SEGMENT - nbInterestingSegments - 2 ;
2022-03-04 21:58:14 +01:00
2022-03-06 20:21:22 +01:00
2022-03-17 21:59:52 +01:00
prof_leave ( perf_update ) ;
time_update = prof_time ( perf_update ) ;
2022-03-04 21:58:14 +01:00
2022-03-17 21:59:52 +01:00
//--------------
2022-03-04 21:58:14 +01:00
2022-03-17 21:59:52 +01:00
perf_project = prof_make ( ) ;
prof_enter ( perf_project ) ;
2022-03-04 21:58:14 +01:00
2022-03-23 21:35:29 +01:00
minYRoad = SCREEN_HEIGHT ;
2022-03-04 21:58:14 +01:00
2022-03-17 21:59:52 +01:00
if ( BDrawCars )
{
updateTraffic ( dt , maxDistance ) ;
2022-03-04 21:58:14 +01:00
2022-03-19 23:29:36 +01:00
for ( unsigned int k = 0 ; k < traffic . size ( ) ; k + + ) // Need to project 1 more segment than actual drawing
2022-03-15 22:02:53 +01:00
{
2022-03-17 21:59:52 +01:00
uint16_t CarSegment = traffic [ k ] - > wZ / SEGMENT_LENGTH ;
if ( CarSegment > = indexstart & & CarSegment < indexend )
2022-03-15 22:02:53 +01:00
{
2022-03-17 21:59:52 +01:00
//traffic[k]->visible = true;
circuit [ CarSegment ] - > CarList . push_back ( k ) ;
2022-03-15 22:02:53 +01:00
}
2022-03-17 21:59:52 +01:00
//else
//traffic[k]->visible = false;
2022-03-15 22:02:53 +01:00
}
2022-03-11 22:44:47 +01:00
2022-03-23 21:35:29 +01:00
float roadpart = f2float ( cam - > cX ) / ( float ) ROAD_WIDTH ;
2022-03-11 22:44:47 +01:00
2022-03-23 21:35:29 +01:00
// Update car positions : car with higher speed change line not to collide with player
2022-03-19 23:29:36 +01:00
for ( unsigned int l = 0 ; l < circuit [ indexstart ] - > CarList . size ( ) ; l + + ) // For all cars inside that road segment
2022-03-17 21:59:52 +01:00
{
uint8_t indexCar = circuit [ indexstart ] - > CarList [ l ] ;
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
if ( traffic [ indexCar ] - > wX > ( roadpart - 0.25f ) & & traffic [ indexCar ] - > wX < ( roadpart + 0.25f ) & & traffic [ indexCar ] - > Speed > speed )
{
if ( traffic [ indexCar ] - > wX > - 0.25 ) traffic [ indexCar ] - > wX - = 0.5 ; // if we are on one of the most right lanes, we overtake by the left
else traffic [ indexCar ] - > wX = - 0.25 ; // else we change to the lane on the right
}
}
2022-03-04 21:58:14 +01:00
2022-03-19 23:29:36 +01:00
for ( unsigned int l = 0 ; l < circuit [ indexstart + 1 ] - > CarList . size ( ) ; l + + ) // For all cars inside that road segment
2022-03-17 21:59:52 +01:00
{
uint8_t indexCar = circuit [ indexstart + 1 ] - > CarList [ l ] ;
2022-03-04 21:58:14 +01:00
2022-03-19 23:29:36 +01:00
if ( traffic [ indexCar ] - > wX > ( roadpart - 0.20f ) & & traffic [ indexCar ] - > wX < ( roadpart + 0.20f ) & & traffic [ indexCar ] - > Speed < speed )
2022-03-17 21:59:52 +01:00
{
speed = 2.0 ;
}
}
2022-03-23 21:35:29 +01:00
}
2022-03-04 21:58:14 +01:00
2022-03-17 21:59:52 +01:00
uint16_t cumulCurve = 0 ;
2022-03-23 21:35:29 +01:00
2022-03-17 21:59:52 +01:00
for ( int k = indexstart ; k < = indexend ; k + + ) // Need to project 1 more segment than actual drawing
{
projectCircuitFP ( k ) ; // We project the current segment
2022-03-11 22:44:47 +01:00
2022-03-23 21:35:29 +01:00
//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 ;
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
circuit [ k ] - > CumulatedCurve = cumulCurve ; // This is the curve accumulated when we are drawing curves
cumulCurve + = circuit [ k ] - > Curve ;
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
if ( BDrawCars )
2022-03-19 23:29:36 +01:00
for ( unsigned int l = 0 ; l < circuit [ k ] - > CarList . size ( ) ; l + + ) // For all cars inside that road segment
2022-03-17 21:59:52 +01:00
{
uint8_t indexCar = circuit [ k ] - > CarList [ l ] ;
traffic [ indexCar ] - > Project3DFP ( cam , k ) ;
}
}
2022-03-04 21:58:14 +01:00
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
prof_leave ( perf_project ) ;
time_project = prof_time ( perf_project ) ;
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
//--------------
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
perf_render = prof_make ( ) ;
prof_enter ( perf_render ) ;
2022-03-11 22:44:47 +01:00
2022-03-23 21:35:29 +01:00
//if (BDrawBack) drawSkyOptimised( DAY_BLUE_SKY );
//else drawSkyFull( DAY_BLUE_SKY );
2022-03-23 21:45:44 +01:00
drawSkyFull ( DAY_BLUE_SKY ) ;
2022-03-22 15:08:36 +01:00
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
if ( BDrawClds )
2022-03-22 15:08:36 +01:00
{
2022-03-19 23:29:36 +01:00
drawClouds ( ) ;
2022-03-22 15:08:36 +01:00
}
if ( BDrawBack )
{
drawFarBackground ( deltaFarbackground , CurrentCircuitBiome ) ;
drawNearBackground ( deltaNearbackground , CurrentCircuitBiome ) ;
}
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
cam - > cY = fix ( 300 + 2 * CS ) + interpolatePositionY ( fround ( cam - > cZ ) ) ;
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
for ( int k = indexend - 1 ; k > = indexstart ; k - - )
{
currentcurve = circuit [ k ] - > CumulatedCurve ;
2022-03-11 22:44:47 +01:00
2022-03-20 21:34:34 +01:00
drawCircuitSegment ( k ) ;
2022-03-04 21:58:14 +01:00
2022-03-17 21:59:52 +01:00
if ( BDrawDeco )
drawDecoration ( k ) ;
2022-03-06 22:06:48 +01:00
2022-03-17 21:59:52 +01:00
if ( BDrawCars )
2022-03-19 23:29:36 +01:00
for ( unsigned int l = 0 ; l < circuit [ k ] - > CarList . size ( ) ; l + + ) // For all cars inside that road segment
2022-03-17 21:59:52 +01:00
{
uint8_t indexCar = circuit [ k ] - > CarList [ l ] ;
drawTraffic ( indexCar ) ;
}
2022-03-15 20:20:28 +01:00
2022-03-22 15:08:36 +01:00
if ( BDrawCars ) circuit [ k ] - > CarList . clear ( ) ;
2022-03-17 21:59:52 +01:00
}
2022-03-15 20:20:28 +01:00
2022-03-23 21:35:29 +01:00
2022-03-19 23:29:36 +01:00
if ( circuit [ indexstart ] - > Special = = CHECKPOINT & & circuit [ indexstart ] - > CheckValidated = = false )
{
start_time + = 60000000 ;
circuit [ indexstart ] - > CheckValidated = true ;
}
2022-03-23 21:35:29 +01:00
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 ;
}
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
int mod_base = 20 ;
int mod_comp = 10 ;
2022-03-11 22:44:47 +01:00
2022-03-13 11:32:00 +01:00
2022-03-17 21:59:52 +01:00
if ( abs ( speed ) < 1.0 ) mod_base = 30 , mod_comp = 15 ;
else if ( abs ( speed ) < 2.0 ) mod_base = 20 , mod_comp = 10 ;
else if ( abs ( speed ) < 3.0 ) mod_base = 16 , mod_comp = 8 ;
else if ( abs ( speed ) < 4.0 ) mod_base = 12 , mod_comp = 6 ;
else if ( abs ( speed ) < 5.0 ) mod_base = 8 , mod_comp = 4 ;
else mod_base = 4 , mod_comp = 2 ;
2022-03-13 11:32:00 +01:00
2022-03-17 21:59:52 +01:00
if ( ( speed = = 0 ) | | ( l % mod_base < = mod_comp ) ) // the small rick to have the speed impression on wheels and to have the correct view of the car during turns
{
if ( viewside = = - 2 ) dsubimage ( SCREEN_CX - 40 , SCREEN_HEIGHT - 46 , & player , 99 , 1 , 80 , 46 , DIMAGE_NONE ) ;
else if ( viewside = = - 1 ) dsubimage ( SCREEN_CX - 37 , SCREEN_HEIGHT - 46 , & player , 181 , 1 , 74 , 46 , DIMAGE_NONE ) ;
else if ( viewside = = 0 ) dsubimage ( SCREEN_CX - 36 , SCREEN_HEIGHT - 46 , & player , 257 , 1 , 72 , 46 , DIMAGE_NONE ) ;
else if ( viewside = = 1 ) dsubimage ( SCREEN_CX - 37 , SCREEN_HEIGHT - 46 , & player , 331 , 1 , 74 , 46 , DIMAGE_NONE ) ;
else if ( viewside = = 2 ) dsubimage ( SCREEN_CX - 40 , SCREEN_HEIGHT - 46 , & player , 407 , 1 , 80 , 46 , DIMAGE_NONE ) ;
}
else
{
if ( viewside = = - 2 ) dsubimage ( SCREEN_CX - 40 , SCREEN_HEIGHT - 46 , & player , 99 , 49 , 80 , 46 , DIMAGE_NONE ) ;
else if ( viewside = = - 1 ) dsubimage ( SCREEN_CX - 37 , SCREEN_HEIGHT - 46 , & player , 181 , 49 , 74 , 46 , DIMAGE_NONE ) ;
else if ( viewside = = 0 ) dsubimage ( SCREEN_CX - 36 , SCREEN_HEIGHT - 46 , & player , 257 , 49 , 72 , 46 , DIMAGE_NONE ) ;
else if ( viewside = = 1 ) dsubimage ( SCREEN_CX - 37 , SCREEN_HEIGHT - 46 , & player , 331 , 49 , 74 , 46 , DIMAGE_NONE ) ;
else if ( viewside = = 2 ) dsubimage ( SCREEN_CX - 40 , SCREEN_HEIGHT - 46 , & player , 407 , 49 , 80 , 46 , DIMAGE_NONE ) ;
}
2022-03-15 20:20:28 +01:00
2022-03-17 21:59:52 +01:00
score = fround ( cam - > cZ ) / 100 ;
2022-03-13 11:32:00 +01:00
2022-03-17 21:59:52 +01:00
float drawspeed = ( float ) ( speed * 5.0f ) ;
2022-03-15 20:20:28 +01:00
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
dsubimage ( 5 , 5 , & speedhud , 0 , 117 , 37 , 13 , DIMAGE_NONE ) ; // speed logo
dsubimage ( 135 , 5 , & speedhud , 0 , 130 , 37 , 13 , DIMAGE_NONE ) ; // timer logo
2022-03-06 22:06:48 +01:00
2022-03-17 21:59:52 +01:00
dsubimage ( 245 , 5 , & speedhud , 37 , 117 , 38 , 13 , DIMAGE_NONE ) ; // speed logo
dsubimage ( 245 , 25 , & speedhud , 37 , 130 , 38 , 13 , DIMAGE_NONE ) ; // timer logo
2022-03-07 15:24:04 +01:00
2022-03-17 21:59:52 +01:00
dfont ( & speedfont ) ;
if ( drawspeed = = 0.0 )
{
dprint_opt ( 122 , 3 , C_RGB ( 0 , 0 , 0 ) , C_NONE , DTEXT_RIGHT , DTEXT_TOP , " 0 : " , drawspeed ) ;
dprint_opt ( 120 , 1 , C_RGB ( 255 , 0 , 0 ) , C_NONE , DTEXT_RIGHT , DTEXT_TOP , " 0 : " , drawspeed ) ;
}
else
{
dprint_opt ( 122 , 3 , C_RGB ( 0 , 0 , 0 ) , C_NONE , DTEXT_RIGHT , DTEXT_TOP , " %.1f : " , drawspeed ) ;
dprint_opt ( 120 , 1 , C_RGB ( 255 , 0 , 0 ) , C_NONE , DTEXT_RIGHT , DTEXT_TOP , " %.1f : " , drawspeed ) ; //the ':' char corresponds to "Km/h"
}
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
dprint_opt ( 233 , 3 , C_RGB ( 0 , 0 , 0 ) , C_NONE , DTEXT_RIGHT , DTEXT_TOP , " %.3D ; " , remaining_time ) ;
dprint_opt ( 230 , 1 , C_RGB ( 255 , 255 , 0 ) , C_NONE , DTEXT_RIGHT , DTEXT_TOP , " %.3D ; " , remaining_time ) ; // the ';' char corresponds to "s"
2022-03-07 15:24:04 +01:00
2022-03-17 21:59:52 +01:00
dprint_opt ( 390 , 3 , C_RGB ( 0 , 0 , 0 ) , C_NONE , DTEXT_RIGHT , DTEXT_TOP , " %.3D " , score ) ;
dprint_opt ( 388 , 1 , C_RGB ( 255 , 255 , 0 ) , C_NONE , DTEXT_RIGHT , DTEXT_TOP , " %.3D " , score ) ; // the ';' char corresponds to "s"
2022-03-15 22:02:53 +01:00
2022-03-17 21:59:52 +01:00
dprint_opt ( 390 , 23 , C_RGB ( 0 , 0 , 0 ) , C_NONE , DTEXT_RIGHT , DTEXT_TOP , " %.3D " , stage ) ;
dprint_opt ( 388 , 21 , C_RGB ( 255 , 255 , 0 ) , C_NONE , DTEXT_RIGHT , DTEXT_TOP , " %.3D " , stage ) ; // the ';' char corresponds to "s"
2022-03-15 22:02:53 +01:00
2022-03-11 22:44:47 +01:00
2022-03-17 21:59:52 +01:00
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 ) ;
2022-03-15 22:02:53 +01:00
2022-03-23 21:35:29 +01:00
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 " ) ;
}
2022-03-22 22:55:45 +01:00
if ( initiateStart ) // We are in the start sequence with the countdown
{
dfont ( & startseq ) ;
if ( startRemaining < 54 & & startRemaining > 46 )
{
dprint_opt ( 200 , 114 , C_RGB ( 0 , 0 , 0 ) , C_NONE , DTEXT_CENTER , DTEXT_CENTER , " >5< " ) ;
dprint_opt ( 198 , 112 , C_RGB ( 255 , 0 , 255 ) , C_NONE , DTEXT_CENTER , DTEXT_CENTER , " >5< " ) ;
}
else if ( startRemaining < 44 & & startRemaining > 36 )
{
dprint_opt ( 200 , 114 , C_RGB ( 0 , 0 , 0 ) , C_NONE , DTEXT_CENTER , DTEXT_CENTER , " >4< " ) ;
dprint_opt ( 198 , 112 , C_RGB ( 255 , 0 , 255 ) , C_NONE , DTEXT_CENTER , DTEXT_CENTER , " >4< " ) ;
}
else if ( startRemaining < 34 & & startRemaining > 26 )
{
dprint_opt ( 200 , 114 , C_RGB ( 0 , 0 , 0 ) , C_NONE , DTEXT_CENTER , DTEXT_CENTER , " >3< " ) ;
dprint_opt ( 198 , 112 , C_RGB ( 255 , 0 , 255 ) , C_NONE , DTEXT_CENTER , DTEXT_CENTER , " >3< " ) ;
}
else if ( startRemaining < 24 & & startRemaining > 16 )
{
dprint_opt ( 200 , 114 , C_RGB ( 0 , 0 , 0 ) , C_NONE , DTEXT_CENTER , DTEXT_CENTER , " >2< " ) ;
dprint_opt ( 198 , 112 , C_RGB ( 255 , 0 , 255 ) , C_NONE , DTEXT_CENTER , DTEXT_CENTER , " >2< " ) ;
}
else if ( startRemaining < 14 & & startRemaining > 6 )
{
dprint_opt ( 200 , 114 , C_RGB ( 0 , 0 , 0 ) , C_NONE , DTEXT_CENTER , DTEXT_CENTER , " >1< " ) ;
dprint_opt ( 198 , 112 , C_RGB ( 255 , 0 , 255 ) , C_NONE , DTEXT_CENTER , DTEXT_CENTER , " >1< " ) ;
}
else if ( startRemaining < 4 & & startRemaining > - 4 )
{
2022-03-23 21:35:29 +01:00
dimage ( 198 - bigflag . width / 2 , 112 - bigflag . height / 2 , & bigflag ) ;
2022-03-22 22:55:45 +01:00
}
else if ( startRemaining < - 4 )
{
start_time = 99000000 ;
initiateStart = false ;
}
}
2022-03-17 21:59:52 +01:00
//dupdate();
2022-03-19 23:29:36 +01:00
//dprint( 3, 202, C_BLACK, "%.0f", dt );
//dprint( 1, 200, C_WHITE, "%.0f", dt );
2022-03-20 21:34:34 +01:00
if ( BDrawFPS )
{
2022-03-22 22:55:45 +01:00
dfont ( & speedfont ) ;
2022-03-21 23:34:51 +01:00
dsubimage ( 5 , 205 , & speedhud , 0 , 143 , 27 , 13 , DIMAGE_NONE ) ; // fps logo
2022-03-20 21:34:34 +01:00
dprint_opt ( 42 , 202 , C_RGB ( 0 , 0 , 0 ) , C_NONE , DTEXT_LEFT , DTEXT_TOP , " %.0f < " , ( float ) ( 1000.0f / dt ) ) ; // the '>' symbol corresponds to "fps"
dprint_opt ( 40 , 200 , C_RGB ( 255 , 255 , 0 ) , C_NONE , DTEXT_LEFT , DTEXT_TOP , " %.0f < " , ( float ) ( 1000.0f / dt ) ) ;
GraphPerf [ DataIndex ] . update = ( uint8_t ) ( time_update / 1000 ) ;
GraphPerf [ DataIndex ] . project = ( uint8_t ) ( time_project / 1000 ) ;
GraphPerf [ DataIndex ] . render = ( uint8_t ) ( time_render / 1000 ) ;
DataIndex + + ;
DataIndex = DataIndex % MAXDATA ;
dline ( 249 , 201 , 375 , 201 , C_BLACK ) ;
dline ( 249 , 202 , 375 , 202 , C_BLACK ) ;
dline ( 249 , 200 - 33 , 375 , 200 - 33 , C_BLACK ) ;
dline ( 249 , 200 - 40 , 375 , 200 - 40 , C_BLACK ) ;
dline ( 249 , 200 - 50 , 375 , 200 - 50 , C_BLACK ) ;
dline ( 249 , 201 , 249 , 100 , C_BLACK ) ;
dline ( 248 , 201 , 248 , 100 , C_BLACK ) ;
for ( unsigned int k = 0 ; k < MAXDATA - 1 ; k + + )
{
dpixel ( 250 + k , 200 - GraphPerf [ k ] . update , C_RGB ( 255 , 0 , 0 ) ) ;
dpixel ( 250 + k , 201 - GraphPerf [ k ] . update , C_RGB ( 255 , 0 , 0 ) ) ;
dpixel ( 250 + k , 200 - GraphPerf [ k ] . update - GraphPerf [ k ] . project , C_RGB ( 0 , 255 , 0 ) ) ;
dpixel ( 250 + k , 201 - GraphPerf [ k ] . update - GraphPerf [ k ] . project , C_RGB ( 0 , 255 , 0 ) ) ;
dpixel ( 250 + k , 200 - GraphPerf [ k ] . update - GraphPerf [ k ] . project - GraphPerf [ k ] . render , C_RGB ( 0 , 0 , 255 ) ) ;
dpixel ( 250 + k , 201 - GraphPerf [ k ] . update - GraphPerf [ k ] . project - GraphPerf [ k ] . render , C_RGB ( 0 , 0 , 255 ) ) ;
}
}
2022-03-19 23:29:36 +01:00
2022-03-17 21:59:52 +01:00
r61524_display ( gint_vram , 0 , DHEIGHT , R61524_DMA_WAIT ) ;
2022-03-15 22:02:53 +01:00
2022-03-04 21:58:14 +01:00
2022-03-17 21:59:52 +01:00
prof_leave ( perf_render ) ;
time_render = prof_time ( perf_render ) ;
2022-03-04 21:58:14 +01:00
2022-03-17 21:59:52 +01:00
# if IS_FXLIB==1
if ( screenshot & & usb_is_open ( ) )
{
usb_fxlink_screenshot ( false ) ;
screenshot = false ;
}
if ( record & & usb_is_open ( ) )
{
usb_fxlink_videocapture ( false ) ;
}
2022-03-11 22:44:47 +01:00
# endif
2022-03-04 21:58:14 +01:00
2022-03-17 21:59:52 +01:00
l + + ;
}
2022-03-23 21:35:29 +01:00
/*
_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 ) ;
*/
2022-03-21 23:34:51 +01:00
// Free all memory
freeTraffic ( ) ;
freeDecoration ( ) ;
2022-03-22 22:55:45 +01:00
for ( unsigned int i = 0 ; i < circuit . size ( ) ; i + + ) delete circuit [ i ] ; // Not to forget to delete each elements
2022-03-17 21:59:52 +01:00
circuit . clear ( ) ;
2022-03-21 23:34:51 +01:00
2022-03-22 22:55:45 +01:00
for ( unsigned int i = 0 ; i < nuages . size ( ) ; i + + ) delete nuages [ i ] ; // Not to forget to delete each elements
2022-03-17 21:59:52 +01:00
nuages . clear ( ) ;
2022-03-21 23:34:51 +01:00
2022-03-22 22:55:45 +01:00
for ( unsigned int i = 0 ; i < traffic . size ( ) ; i + + ) delete traffic [ i ] ; // Not to forget to delete each elements
2022-03-17 21:59:52 +01:00
traffic . clear ( ) ;
2022-03-21 23:34:51 +01:00
2022-03-17 21:59:52 +01:00
}
2022-03-04 21:58:14 +01:00
}
2022-03-17 21:59:52 +01:00
while ( exitToOS = = false ) ;
2022-03-04 21:58:14 +01:00
prof_quit ( ) ;
2022-03-11 22:44:47 +01:00
# if IS_FXLIB==1
usb_close ( ) ;
# endif
2022-03-06 22:06:48 +01:00
2022-03-04 21:58:14 +01:00
delete cam ;
2022-03-06 22:06:48 +01:00
2022-03-04 21:58:14 +01:00
return 1 ;
}