V1.08 WIP - added compatibility with gint 2.8

This commit is contained in:
Sylvain PILLOT 2022-05-23 22:02:45 +02:00
parent a664af3a64
commit 8b64a2db55
24 changed files with 272 additions and 207 deletions

View File

@ -11,7 +11,7 @@ find_package(LibProf 2.4 REQUIRED)
set(SOURCES
src/main.cc
src/clock.cc
# src/clock.cc
src/src/segment.cc
src/src/camera.cc
src/src/circuit.cc
@ -66,6 +66,10 @@ set(ASSETS_cg
assets-cg/decos/common/cc_void.png
assets-cg/player/player.png
assets-cg/player/smoke1.png
assets-cg/player/smoke2.png
assets-cg/player/smoke3.png
assets-cg/clouds/sky1.png
assets-cg/clouds/sky2.png
assets-cg/clouds/sky3.png
@ -100,6 +104,7 @@ set(ASSETS_cg
assets-cg/hud/speedhud.png
assets-cg/screens/mainscreen.png
assets-cg/screens/mainscrbright.png
assets-cg/miniscreen/africa1.png
assets-cg/miniscreen/desert1.png

View File

@ -2,7 +2,27 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="src/src/circuit.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<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/clock.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="src/parameters.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="505" topLine="0" />
</Cursor>
</File>
<File name="src/include/cars.h" open="0" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="412" topLine="1" />
</Cursor>
</File>
<File name="src/src/circuit.cc" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="31927" topLine="269" />
</Cursor>
@ -29,80 +49,36 @@
<Collapse line="1175" />
</Folding>
</File>
<File name="src/include/utils.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<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="107" topLine="0" />
<Cursor1 position="306" topLine="0" />
</Cursor>
</File>
<File name="src/include/drawstuff.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/menus.cc" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="655" topLine="0" />
</Cursor>
</File>
<File name="src/src/saves.cc" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="294" topLine="2" />
</Cursor>
</File>
<File name="src/include/menus.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="505" topLine="0" />
</Cursor>
</File>
<File name="src/include/segment.h" open="0" 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/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/include/saves.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="319" 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/include/cars.h" open="0" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="412" topLine="1" />
</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" />
<Cursor1 position="46095" topLine="898" />
</Cursor>
<Folding>
<Collapse line="116" />
<Collapse line="551" />
<Collapse line="666" />
<Collapse line="709" />
<Collapse line="872" />
</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/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-2" zoom_2="0">
<Cursor>
<Cursor1 position="43460" topLine="306" />
</Cursor>
<Folding>
<Collapse line="141" />
<Collapse line="203" />
<Collapse line="211" />
<Collapse line="219" />
</Folding>
</File>
<File name="src/clock.cc" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5691" topLine="162" />
<Cursor1 position="975" topLine="73" />
</Cursor>
</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/fixed.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="306" topLine="0" />
<Cursor1 position="5" topLine="0" />
</Cursor>
</File>
<File name="src/src/drawstuff.cc" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -118,19 +94,17 @@
<Collapse line="131" />
</Folding>
</File>
<File name="src/src/utils.cc" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/main.cc" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-2" zoom_2="0">
<Cursor>
<Cursor1 position="30" topLine="0" />
<Cursor1 position="43460" topLine="93" />
</Cursor>
<Folding>
<Collapse line="194" />
</Folding>
</File>
<File name="src/src/segment.cc" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<File name="src/include/menus.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="410" topLine="29" />
</Cursor>
</File>
<File name="CMakeLists.txt" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="302" topLine="0" />
<Cursor1 position="505" 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">
@ -138,41 +112,64 @@
<Cursor1 position="203" topLine="0" />
</Cursor>
</File>
<File name="src/clock.h" open="1" top="1" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/utils.cc" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
<Cursor1 position="2658" topLine="57" />
</Cursor>
</File>
<File name="src/parameters.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/saves.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="505" topLine="0" />
<Cursor1 position="294" topLine="2" />
</Cursor>
</File>
<File name="src/include/circuit.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/drawstuff.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1093" topLine="47" />
<Cursor1 position="655" topLine="0" />
</Cursor>
</File>
<File name="src/src/menus.cc" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/segment.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="46095" topLine="898" />
<Cursor1 position="783" topLine="3" />
</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>
<Folding>
<Collapse line="116" />
<Collapse line="551" />
<Collapse line="666" />
<Collapse line="709" />
<Collapse line="872" />
</Folding>
</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/fixed.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/saves.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5" topLine="0" />
<Cursor1 position="319" 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="CMakeLists.txt" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="302" topLine="0" />
</Cursor>
</File>
<File name="src/include/circuit.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1093" topLine="47" />
</Cursor>
</File>
<File name="src/src/segment.cc" open="0" 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/utils.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="107" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -1,5 +1,5 @@
*.png:
type: bopti-image
profile: p4
profile: p8
name_regex: (.*)\.png \1

View File

@ -1,5 +1,5 @@
*.png:
type: bopti-image
profile: p4
profile: p8
name_regex: (.*)\.png \1

View File

@ -1,5 +1,5 @@
*.png:
type: bopti-image
profile: p4
profile: p8
name_regex: (.*)\.png \1

View File

@ -1,5 +1,5 @@
*.png:
type: bopti-image
profile: p4
profile: p8
name_regex: (.*)\.png \1

View File

@ -1,5 +1,5 @@
*.png:
type: bopti-image
profile: p4
profile: p8
name_regex: (.*)\.png \1

View File

@ -1,5 +1,5 @@
*.png:
type: bopti-image
profile: p4
profile: p8
name_regex: (.*)\.png \1

View File

@ -1,5 +1,5 @@
*.png:
type: bopti-image
profile: p4
profile: p8
name_regex: (.*)\.png \1

View File

@ -1,5 +1,5 @@
*.png:
type: bopti-image
profile: p8
profile: p8_rgb565a
name_regex: (.*)\.png \1

BIN
assets-cg/player/smoke1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
assets-cg/player/smoke2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
assets-cg/player/smoke3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1,5 +1,5 @@
*.png:
type: bopti-image
profile: p8
profile: p8_rgb565
name_regex: (.*)\.png \1

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 97 KiB

View File

@ -1,5 +1,5 @@
*.png:
type: bopti-image
profile: p4
profile: p8
name_regex: (.*)\.png \1

View File

@ -62,6 +62,7 @@ enum Decoration
void initData( void );
void createCircuit( int circuitNumber );
void putBillBoards( void );
void createMilestones( uint8_t nblap );
void createClouds( void );
void createTraffic( uint16_t maxSegment );

View File

@ -25,6 +25,19 @@ enum Specialty
FINISH = 2
};
class MileStone
{
public:
MileStone( ) {type = -1; wZ = 0.0; lap = 0; };
MileStone( uint8_t t, double Z, uint8_t l ) {type = t; wZ = Z; lap = l; };
~MileStone( ) { };
uint8_t type;
double wZ;
uint8_t lap;
} ;
class Segment
{
public:

View File

@ -31,15 +31,15 @@
#include <stdio.h>
#include "clock.h"
#include <gint/clock.h>
#define DEBUGXXX 0
#define OVERCLCK_ACTIVABLE 1
char version[5] = {'V','1','.','0','7'};
char version[5] = {'V','1','.','0','8'};
extern bopti_image_t player;
extern bopti_image_t player, smoke1, smoke2, smoke3;
extern font_t speedfont, startseq, plate, autofont;
extern bopti_image_t speedhud;
extern bopti_image_t flag, bigflag;
@ -49,6 +49,8 @@ int CurrentCircuitBiome = PLAINS;
std::vector<Segment*> circuit;
std::vector<Clouds*> nuages;
std::vector<Cars*> traffic;
std::vector<MileStone*> jalons;
int MAX_SEGMENT=0;
camera *cam;
@ -109,11 +111,17 @@ bool OptionMode = false;
bool PauseMode = false;
bool SkipTime = false;
///HUD options
bool visualspeedindicator = false;
bool visualnextpoint = true;
// for multilap
bool multilap = false;
uint8_t numlap = 1;
uint8_t currentLap = 1;
int currentpoint = 0;
uint16_t currentcurve=0;
uint8_t shiftcolor=0;
@ -136,7 +144,7 @@ int lastindex=0;
int CC=0; // current curve
int CS=0;
overclock_level EntryLevel;
int EntryLevel;
void initEverything( void )
@ -191,6 +199,11 @@ void initEverything( void )
}
float timepressed = 0.0f;
int directionPressed = 0;
bool CarIsSliding = false;
uint16_t framesmoke = 0;
static void get_inputs( float dt, int index )
{
CC = circuit[index]->Curve;
@ -213,36 +226,47 @@ static void get_inputs( float dt, int index )
{
viewside=-1;
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
if (CurrentCircuitBiome==FINLAND) cam->decX( CC*dt*speed/50); // 50 ); // very hard to turn in Finland with snow
else if (CurrentCircuitBiome==AFRICA) cam->decX( CC*dt*speed/70); //75 ); // hard in Africa with dirt
else cam->decX( CC*dt*speed/85); // 100 ); // more easy on normal roads
}
else if (CC>0)
{
viewside=+1;
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
if (CurrentCircuitBiome==FINLAND) cam->decX( CC*dt*speed/50); // 50 ); // very hard to turn in Finland with snow
else if (CurrentCircuitBiome==AFRICA) cam->decX( CC*dt*speed/70); //75 ); // hard in Africa with dirt
else cam->decX( CC*dt*speed/85); // 100 ); // more easy on normal roads
}
if(keydown(KEY_LEFT) || keydown(KEY_F5))
{
cam->decX(5.0*speed*direction);
/// This is to implement sliding and speed loss
if (directionPressed!=-1) directionPressed=-1, timepressed = 0.0f;
else if (directionPressed==-1 && CC<0) timepressed += dt;
viewside=-1;
if (CC<0) viewside=-2; // We are in a curve and turning
if (CC>0) viewside=0;
}
if(keydown(KEY_RIGHT) || keydown(KEY_F6))
else if(keydown(KEY_RIGHT) || keydown(KEY_F6))
{
cam->incX(5.0*speed*direction);
/// This is to implement sliding and speed loss
if (directionPressed!=1) directionPressed=1, timepressed = 0.0f;
else if (directionPressed==1 && CC>0) timepressed += dt;
viewside=1;
if (CC>0) viewside=+2;
if (CC<0) viewside=0;
}
else if (!keydown(KEY_RIGHT) && !keydown(KEY_F6) && !keydown(KEY_LEFT) && !keydown(KEY_F5))
{
directionPressed=0, timepressed = 0.0f;
}
if(keydown(KEY_SHIFT) || keydown(KEY_XOT) || keydown(KEY_F1)) // Accelerates
{
@ -328,6 +352,21 @@ static void get_inputs( float dt, int index )
cam->cX=fix(0.0*ROAD_WIDTH); //set the car in the center of the road (was formerly 0.75)
}
/// This part controls the sliding of player's car, if we keep pressed the keys to turn too long, the car starts sliding, smoke will appear and speed is decreasing
if (timepressed>=300.0f) // was 500.0f
{
CarIsSliding = true;
cam->decX( CC*dt*speed/50 );
speed = speed * 0.975;
framesmoke++;
}
else
{
CarIsSliding = false;
framesmoke=0;
}
}
@ -339,7 +378,7 @@ static void get_minimum_inputs( void )
}
if(keydown(KEY_EXIT)) drawPauseQuit();
if(keydown(KEY_EXIT) || keydown(KEY_SHIFT)) drawPauseQuit();
if(keydown(KEY_OPTN)) drawOptions();
@ -401,7 +440,7 @@ int main(void)
#if (OVERCLCK_ACTIVABLE==1)
if (gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM)
{
EntryLevel = overclock_detect();
EntryLevel = clock_get_speed();
isOCPossible = true;
}
else
@ -467,13 +506,6 @@ 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);
*/
// Try to restart from very begining
initEverything();
@ -491,6 +523,7 @@ int main(void)
time_render=0;
ranking = -1;
currentpoint = 0;
exitToOS = false;
@ -530,9 +563,9 @@ int main(void)
gint_world_switch( GINT_CALL( saveparameters ) );
if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == true) clock_overclock( OC_PtuneF5 );
else if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == false && EntryLevel != OC_Undefined) clock_overclock( EntryLevel );
else if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == false && EntryLevel == OC_Undefined) clock_overclock( OC_Default );
if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == true) clock_set_speed( CLOCK_SPEED_F5 );
else if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == false && EntryLevel != CLOCK_SPEED_UNKNOWN) clock_set_speed( EntryLevel );
else if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == false && EntryLevel == CLOCK_SPEED_UNKNOWN) clock_set_speed( CLOCK_SPEED_DEFAULT );
}
else if (mode==3)
{
@ -554,8 +587,6 @@ int main(void)
if (!exitToOS)
{
//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;
else if (selectedCircuit==2) CurrentCircuitBiome = USA, multilap = false, currentLap = 1, numlap = 1;
@ -576,18 +607,18 @@ int main(void)
prof_enter(perf_create);
initData( ); // Positioning of the Camera
createCircuit( selectedCircuit ); // Creates the circuit
MAX_SEGMENT = circuit.size();
//uint32_t maxDistance = (MAX_SEGMENT-nbInterestingSegments-5)*SEGMENT_LENGTH;
double maxDistance = (double) ((MAX_SEGMENT-1)*SEGMENT_LENGTH);
putBillBoards();
createMilestones( numlap );
createClouds(); // Creates the Sky and Clouds
if (mode==0)
@ -601,15 +632,6 @@ int main(void)
else if (CarsNumb==3) NB_CARS_TRAFFIC=300;
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=25;
@ -625,15 +647,6 @@ int main(void)
prepareDecoration( CurrentCircuitBiome ); // Prepares the multiple variations of Decoration (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);
@ -698,14 +711,11 @@ int main(void)
//--------------
if (fround(cam->cZ)<=0) cam->cZ=fixdouble(0.0);
//if (fround(cam->cZ)>=maxDistance) cam->cZ=fixdouble(maxDistance);
indexstart = fround(cam->cZ) / SEGMENT_LENGTH;
if (indexstart<0) indexstart=0;
indexend = indexstart+nbInterestingSegments+1;
//if (indexstart>MAX_SEGMENT-nbInterestingSegments-2) indexstart=MAX_SEGMENT-nbInterestingSegments-2;
prof_leave(perf_update);
time_update = prof_time(perf_update);
@ -727,11 +737,8 @@ int main(void)
uint16_t CarSegment = traffic[k]->wZ / SEGMENT_LENGTH;
if (CarSegment>=indexstart && CarSegment<indexend)
{
//traffic[k]->visible = true;
circuit[CarSegment]->CarList.push_back(k);
}
//else
//traffic[k]->visible = false;
}
float roadpart = f2float(cam->cX)/(float) ROAD_WIDTH;
@ -820,21 +827,6 @@ int main(void)
unsigned int k = circuit[u]->CarList[v];
/*
if (traffic[k]->Turn == -1)
{
traffic[k]->wX -= 0.10;
if (traffic[k]->wX==-0.75 || traffic[k]->wX==-0.25 || traffic[k]->wX==0.25) traffic[k]->Turn = 0;
}
else if (traffic[k]->Turn == 1)
{
traffic[k]->wX += 0.10;
if (traffic[k]->wX==-0.25 || traffic[k]->wX==0.25 || 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;
@ -852,7 +844,6 @@ int main(void)
{
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
if (circuit[k]->Y <= minYRoad) minYRoad = circuit[k]->Y;
circuit[k]->CumulatedCurve = cumulCurve; // This is the curve accumulated when we are drawing curves
@ -934,15 +925,6 @@ int main(void)
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 && circuit[indexstart]->CheckLap!=currentLap)
{
@ -1048,6 +1030,13 @@ 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] );
if (CarIsSliding)
{
if (framesmoke>=0 && framesmoke<10) dimage(SCREEN_CX-smoke1.width/2, SCREEN_HEIGHT-smoke1.height, &smoke1 );
else if (framesmoke>=10 && framesmoke<20) dimage(SCREEN_CX-smoke2.width/2, SCREEN_HEIGHT-smoke2.height, &smoke2 );
else if (framesmoke>=30 && framesmoke<30) dimage(SCREEN_CX-smoke3.width/2, SCREEN_HEIGHT-smoke3.height, &smoke3 );
else framesmoke=0;
}
if (direction==+1) score += speed*dt/10;
@ -1101,44 +1090,51 @@ int main(void)
}
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);
/// Graphical speed indicator
if (visualspeedindicator)
{
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);
}
/// Checkpoint indicator
if (visualnextpoint)
{
double Z1 = jalons[currentpoint]->wZ;
double Z2 = jalons[currentpoint+1]->wZ;
double frac = (fround(cam->cZ) - Z1) / (Z2 - Z1 );
if (frac<0) frac=0;
if (fround(cam->cZ) >= Z2) currentpoint++;
drect( 15, 50, 20, 150, C_WHITE );
drect( 10, 49+frac*100, 25, 51+frac*100, C_RED );
}
if (finishSequence)
{
if (mode==1 && !skipranking)
{
#if DEBUGXXX==1
if (usb_is_open()) usb_fxlink_text("save perf", 0);
#endif
bool donerank = false;
int k=0;
while (!donerank && k<5)
{
#if DEBUGXXX==1
if (usb_is_open()) usb_fxlink_text("in the loop", 0);
#endif
if (FinalTime<=HallOfFame[selectedCircuit][k].bestTime)
{
#if DEBUGXXX==1
if (usb_is_open()) usb_fxlink_text("found", 0);
#endif
for( int l=4; l>k; l--)
{
HallOfFame[selectedCircuit][l].playerName[0] = HallOfFame[selectedCircuit][l-1].playerName[0];
@ -1347,6 +1343,9 @@ int main(void)
for(unsigned int i=0; i<circuit.size(); i++ ) delete circuit[i]; // Not to forget to delete each elements
circuit.clear();
for(unsigned int i=0; i<jalons.size(); i++ ) delete jalons[i]; // Not to forget to delete each elements
jalons.clear();
for(unsigned int i=0; i<nuages.size(); i++ ) delete nuages[i]; // Not to forget to delete each elements
nuages.clear();
@ -1375,8 +1374,8 @@ int main(void)
usb_close();
#endif
if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == true && EntryLevel != OC_Undefined) clock_overclock( EntryLevel );
else if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == true && EntryLevel == OC_Undefined) clock_overclock( OC_Default );
if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == true && EntryLevel != CLOCK_SPEED_UNKNOWN) clock_set_speed( EntryLevel );
else if ((gint[HWCALC] == HWCALC_FXCG50 || gint[HWCALC] == HWCALC_PRIZM) && isOCActivated == true && EntryLevel == CLOCK_SPEED_UNKNOWN) clock_set_speed( CLOCK_SPEED_DEFAULT );
delete cam;

View File

@ -28,7 +28,7 @@
#define std ustl
#define IS_FXLIB 0
#define IS_FXLIB 1
#endif // PARAMETERS_H

View File

@ -25,6 +25,7 @@ extern uint16_t NB_CARS_TRAFFIC;
extern std::vector<Segment*> circuit;
extern std::vector<Clouds*> nuages;
extern std::vector<Cars*> traffic;
extern std::vector<MileStone*> jalons;
extern camera *cam;
extern uint16_t currentcurve;
@ -549,6 +550,41 @@ void putBillBoards( void )
}
void outputMilestones( void )
{
char texttosend[1024];
if (usb_is_open())
{
for(int k = 0; k< jalons.size(); k++)
{
sprintf( texttosend, "Jalons %d --> Lap = %d : Type = %d ; Position = %.0f \n", k, jalons[k]->lap, jalons[k]->type, jalons[k]->wZ );
usb_fxlink_text(texttosend, 0);
}
}
}
void createMilestones( uint8_t nblap )
{
for( unsigned int l=0; l<nblap;l++)
{
for (unsigned int k = 0; k<circuit.size(); k++ )
{
if (circuit[k]->Special != -1)
{
MileStone *mile=new MileStone( );
mile->type = circuit[k]->Special;
mile->wZ = (double) ((double) k * (double) SEGMENT_LENGTH);
mile->lap = l ;
jalons.push_back(mile);
}
}
}
#if DEBUGXXX==1
outputMilestones();
#endif // DEBUGXXX
}
void createClouds( void )
@ -579,8 +615,8 @@ void createTraffic( uint16_t maxSegment )
uint8_t S;
// if Difficulty = easy, all cars are at the same speed 175km/h)
if (DiffLevel==0) S=3.5;
else S = 2 + (rand() % 3); // else speed is random and then overtaking can happen
if (DiffLevel==0) S=4.0;
else S = 3.5 + (rand() % 2); // else speed is random and then overtaking can happen
uint8_t T = rand() % 8;
@ -1252,7 +1288,8 @@ void freeDecoration( void )
{
for( int k=0; k<NB_TREES_TYPES; k++)
for( int i=0; i<MAX_SUBIMAGES_TREES; i++)
free(scaledTrees[k][i]);
image_free(scaledTrees[k][i]); //free(scaledTrees[k][i]);
}
@ -1260,7 +1297,7 @@ void freeTraffic( void )
{
for( int k=0; k<NB_CARS_TYPES; k++)
for( int i=0; i<MAX_SUBIMAGES_CARS; i++)
free(scaledCars[k][i]);
image_free(scaledCars[k][i]); //free(scaledCars[k][i]);
}
@ -1284,6 +1321,7 @@ void drawDecoration( uint16_t index )
int X = circuit[index]->X + circuit[index]->CumulatedCurve - 1.5*circuit[index]->W - image->width/2;
int Y = circuit[index]->Y - image->height;
//dimage_p4_clearbg_alt( X, Y, image, 0, image->alpha );
dimage( X, Y, image );
}
@ -1296,6 +1334,7 @@ void drawDecoration( uint16_t index )
int X = circuit[index]->X + circuit[index]->CumulatedCurve + 1.5*circuit[index]->W - image->width/2;
int Y = circuit[index]->Y - image->height;
//dimage_p4_clearbg_alt( X, Y, image, 0, image->alpha );
dimage( X, Y, image );
}
}

View File

@ -11,6 +11,8 @@
#include "../include/utils.h"
#include "../include/saves.h"
#include <gint/image.h>
extern BestRanking HallOfFame[10][5];
@ -19,7 +21,7 @@ extern uint8_t NB_CARS_TRAFFIC;
extern bool isOCPossible;
extern bool isOCActivated;
extern bopti_image_t mainscreen;
extern bopti_image_t mainscreen, mainscrbright;
extern bopti_image_t africa1, desert1, finland1, plains1, usa1;
extern bopti_image_t flag, linear, circular;
extern font_t autofont, autofontsmall, speedfont;
@ -79,7 +81,7 @@ void drawStartTitle( void )
{
dclear( C_BLACK );
dsubimage( 0, 32, &mainscreen, 0, 32, 396, 160, DIMAGE_NONE);
dsubimage( 0, 32, &mainscrbright, 0, 32, 396, 160, DIMAGE_NONE);
dfont(&autofont);
@ -1200,8 +1202,8 @@ int drawMenuCircuitDetails( int circuit )
}
free(preview1);
free(preview2);
image_free(preview1);
image_free(preview2);
return CircuitDetailsSelection;
}

View File

@ -1,7 +1,8 @@
#include "../include/utils.h"
#include <gint/image.h>
/*
size_t image_size_profile(int profile, int width, int height)
{
size_t size = sizeof(bopti_image_t);
@ -21,6 +22,7 @@ size_t image_size(bopti_image_t const *img)
return image_size_profile(img->profile, img->width, img->height);
}
int get_pixel(bopti_image_t const *img, int x, int y)
{
if((unsigned)x >= img->width || (unsigned)y >= img->height)
@ -93,4 +95,11 @@ bopti_image_t *resize(bopti_image_t const *src, int w, int h)
return img;
}
*/
bopti_image_t *resize(bopti_image_t const *src, int w, int h)
{
image_linear_map scale;
image_scale( src, 65536*w/src->width, 65536*h/src->height, &scale );
return image_linear_alloc(src, &scale );
}