added time ranking and Hall Of Fame for time attack mode

master
Sylvain PILLOT 6 months ago
parent 6fcfd3b764
commit 28b4d462f2
  1. 1
      CMakeLists.txt
  2. 2
      CppOutRun.cbp
  3. 183
      CppOutRun.layout
  4. BIN
      fxlink-image-2022.02.28-23h13-6.png
  5. BIN
      fxlink-image-2022.02.28-23h14-21.png
  6. 3
      src/include/menus.h
  7. 16
      src/include/saves.h
  8. 192
      src/main.cc
  9. 2
      src/src/circuit.cc
  10. 111
      src/src/menus.cc
  11. 51
      src/src/saves.cc

@ -18,6 +18,7 @@ set(SOURCES
src/src/clouds.cc
src/src/cars.cc
src/src/menus.cc
src/src/saves.cc
src/src/utils.cc
)

@ -37,6 +37,7 @@
<Unit filename="src/include/clouds.h" />
<Unit filename="src/include/drawstuff.h" />
<Unit filename="src/include/menus.h" />
<Unit filename="src/include/saves.h" />
<Unit filename="src/include/segment.h" />
<Unit filename="src/include/utils.h" />
<Unit filename="src/main.cc" />
@ -47,6 +48,7 @@
<Unit filename="src/src/clouds.cc" />
<Unit filename="src/src/drawstuff.cc" />
<Unit filename="src/src/menus.cc" />
<Unit filename="src/src/saves.cc" />
<Unit filename="src/src/segment.cc" />
<Unit filename="src/src/utils.cc" />
<Extensions>

@ -2,160 +2,171 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="src/src/circuit.cc" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<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="14837" topLine="224" />
<Cursor1 position="412" topLine="1" />
</Cursor>
<Folding>
<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/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<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="3139" topLine="103" />
<Cursor1 position="251" topLine="0" />
</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>
<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">
<File name="src/main.cc" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-2" zoom_2="0">
<Cursor>
<Cursor1 position="30" topLine="0" />
<Cursor1 position="39899" topLine="1082" />
</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">
<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="5" topLine="0" />
<Cursor1 position="203" 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">
<File name="src/src/menus.cc" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="655" topLine="0" />
<Cursor1 position="39199" topLine="146" />
</Cursor>
<Folding>
<Collapse line="70" />
<Collapse line="108" />
<Collapse line="134" />
<Collapse line="199" />
<Collapse line="235" />
<Collapse line="247" />
<Collapse line="384" />
<Collapse line="426" />
<Collapse line="497" />
<Collapse line="520" />
<Collapse line="635" />
<Collapse line="678" />
<Collapse line="796" />
<Collapse line="888" />
<Collapse line="950" />
<Collapse line="1001" />
<Collapse line="1119" />
</Folding>
</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">
<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="203" topLine="0" />
<Cursor1 position="256" 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">
<File name="src/parameters.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="783" topLine="3" />
<Cursor1 position="355" 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">
<File name="src/include/circuit.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="355" topLine="0" />
<Cursor1 position="1686" 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">
<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="510" topLine="0" />
<Cursor1 position="30" 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">
<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="27007" topLine="247" />
<Cursor1 position="410" topLine="29" />
</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">
<Cursor>
<Cursor1 position="2807" topLine="14" />
</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" />
<Collapse line="9" />
<Collapse line="33" />
<Collapse line="40" />
<Collapse line="46" />
<Collapse line="76" />
<Collapse line="131" />
</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="CMakeLists.txt" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="306" topLine="0" />
<Cursor1 position="448" 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">
<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="251" topLine="0" />
<Cursor1 position="221" 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">
<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="410" topLine="29" />
<Cursor1 position="5" topLine="0" />
</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">
<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="412" topLine="2" />
<Cursor1 position="370" topLine="0" />
</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">
<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/src/cars.cc" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<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="1019" topLine="8" />
<Cursor1 position="448" topLine="0" />
</Cursor>
<Folding>
<Collapse line="68" />
<Collapse line="357" />
<Collapse line="385" />
<Collapse line="413" />
<Collapse line="441" />
<Collapse line="471" />
<Collapse line="644" />
<Collapse line="692" />
<Collapse line="702" />
<Collapse line="751" />
<Collapse line="801" />
<Collapse line="852" />
<Collapse line="925" />
<Collapse line="962" />
<Collapse line="1254" />
<Collapse line="1261" />
<Collapse line="1271" />
<Collapse line="1281" />
</Folding>
</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">
<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="370" topLine="0" />
<Cursor1 position="615" 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">
<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="2807" topLine="14" />
<Cursor1 position="504" topLine="15" />
</Cursor>
<Folding>
<Collapse line="9" />
<Collapse line="33" />
<Collapse line="40" />
<Collapse line="46" />
<Collapse line="76" />
<Collapse line="131" />
</Folding>
</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">
<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="221" topLine="0" />
<Cursor1 position="1019" topLine="8" />
</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">
<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="1686" topLine="12" />
<Cursor1 position="783" topLine="3" />
</Cursor>
</File>
<File name="CMakeLists.txt" 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="448" topLine="0" />
<Cursor1 position="655" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

@ -27,4 +27,7 @@ void getInputPauseQuit( void );
int drawMenuCircuitDetails( int circuit, int mode );
void getInputCircuitDetails( void );
int drawMenuBestTime( int circuit );
void getInputBestTime( void );
#endif // MENUS_H

@ -0,0 +1,16 @@
#include <gint/defs/types.h>
struct BestRanking
{
char playerName[3] = { '.', '.', '.' }; // name of the player
char padding = 'Z'; // toi tu m'auras fait me gratter la tête !! Mon cochon.
uint32_t bestScore = 9999;
uint32_t bestTime = 9999;
};
void is_save_existing( void );
void saveprogress( void );
void loadprogress( void );

@ -25,11 +25,13 @@
#include "include/cars.h"
#include "include/menus.h"
#include "include/saves.h"
#include <gint/kmalloc.h>
#include <stdio.h>
#define DEBUGXXX 0
#define DEBUGXXX 1
extern bopti_image_t player;
@ -45,10 +47,19 @@ std::vector<Cars*> traffic;
int MAX_SEGMENT=0;
camera *cam;
char texttosend[1024];
int32_t start_time = 100000000;
uint32_t elapsed_time = 0;
uint32_t score=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;
uint8_t DiffLevel = 1;
uint8_t CarsNumb = 1;
char PlayerName[3] = "SLY";
char PlayerName[3] = { 'S', 'L', 'Y' };
struct DataPerf
{
@ -57,11 +68,16 @@ struct DataPerf
uint8_t render=0;
};
extern bool saveexist;
BestRanking HallOfFame[10][5]; // Table of score : 10 levels * 5 best scores
uint32_t FinalTime=0;
bool skipranking=false;
#define MAXDATA 120
DataPerf GraphPerf[ MAXDATA ];
unsigned int DataIndex=0;
uint8_t NB_CARS_TRAFFIC=200;
uint16_t NB_CARS_TRAFFIC=200;
bool stop = false;
bool exitToOS = false;
@ -346,6 +362,18 @@ int main(void)
#endif
gint_world_switch( GINT_CALL( is_save_existing ));
if (!saveexist) // if we do not have saves
gint_world_switch( GINT_CALL( saveprogress ) ); // we create a progress file which is empty
gint_world_switch( GINT_CALL( loadprogress )); // then we load it
kmalloc_arena_t *_uram = kmalloc_get_arena("_uram");
kmalloc_gint_stats_t *_uram_stats;
@ -355,20 +383,39 @@ int main(void)
static kmalloc_arena_t extended_ram = { 0 };
kmalloc_gint_stats_t *extram_stats;
bool canWeAllocateMore = false;
bool canWeAllocate3Mb = false;
if(!strncmp(osv, "03.", 3) && osv[3] <= '6')
if((!strncmp(osv, "03.", 3) && osv[3] <= '6') && gint[HWCALC] == HWCALC_FXCG50)
{
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.is_default = true;
extended_ram.start = (void *)0x8c200000;
extended_ram.end = (void *)0x8c500000 ; // 0x8c200000 + 0x00300000 correspondant à 3Mo
extended_ram.end = (void *)0x8c500000 ;
kmalloc_init_arena(&extended_ram , true);
kmalloc_init_arena(&extended_ram, true);
kmalloc_add_arena(&extended_ram );
canWeAllocateMore = true;
canWeAllocate3Mb = true;
}
else if (gint[HWCALC] == HWCALC_PRIZM)
{
extended_ram.name = "extram";
extended_ram.is_default = true;
uint16_t *vram1, *vram2;
dgetvram(&vram1, &vram2);
dsetvram(vram1, vram1);
extended_ram.start = vram2;
extended_ram.end = (char *)vram2 + 396*224*2;
kmalloc_init_arena(&extended_ram, true);
kmalloc_add_arena(&extended_ram );
canWeAllocate3Mb = false;
}
else abort();
srand( rtc_ticks() );
@ -380,8 +427,6 @@ int main(void)
drawStartTitle();
char texttosend[1024];
exitToOS = false;
@ -398,12 +443,17 @@ int main(void)
initEverything();
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, mode=0;
int8_t selectedCircuit=0, secondvalidation=0;
uint32_t time_update=0, time_create=0, time_project=0, time_render=0;
start_time = 100000000;
elapsed_time = 0;
score=0;
stage=0;
mode=0;
selectedCircuit=0;
secondvalidation=0;
time_update=0;
time_create=0;
time_project=0;
time_render=0;
exitToOS = false;
@ -429,6 +479,7 @@ int main(void)
selectedCircuit = drawMenuCircuitSelect();
if (selectedCircuit != -1) secondvalidation = drawMenuCircuitDetails( selectedCircuit, 1 );
if (selectedCircuit != -1 && secondvalidation != -1) secondvalidation = drawMenuBestTime( selectedCircuit );
if (selectedCircuit != -1 && secondvalidation != -1) exitflag=true;
}
else if (mode==2)
@ -451,6 +502,8 @@ int main(void)
}
while (!exitflag);
skipranking = false;
if (!exitToOS)
{
//stage = selectedCircuit;
@ -491,27 +544,27 @@ int main(void)
{
// 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 if (CarsNumb==1) NB_CARS_TRAFFIC=100;
else if (CarsNumb==2) NB_CARS_TRAFFIC=200;
else if (CarsNumb==3) NB_CARS_TRAFFIC=300;
else NB_CARS_TRAFFIC=100;
}
*/ else // while circular needs much less
/* 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;
if (CarsNumb==0) NB_CARS_TRAFFIC=5;
else if (CarsNumb==1) NB_CARS_TRAFFIC=10;
else if (CarsNumb==2) NB_CARS_TRAFFIC=20;
else if (CarsNumb==3) NB_CARS_TRAFFIC=30;
else NB_CARS_TRAFFIC=10;
}
@ -861,6 +914,7 @@ int main(void)
circuit[indexstart]->CheckValidated = true;
score+=20000;
finishSequence=true;
FinalTime = elapsed_time/1000000;
}
#if DEBUGXXX==1
if (usb_is_open())
@ -898,7 +952,7 @@ int main(void)
// Draw a message when time is over
if (start_time<=0)
if (start_time<=0 && mode == 0)
{
failSequence=true;
}
@ -965,8 +1019,17 @@ int main(void)
dprint_opt(120,1, C_RGB(255,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.1f :", drawspeed ); //the ':' char corresponds to "Km/h"
}
dprint_opt(233,3, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D ;", remaining_time );
dprint_opt(231,1, C_RGB(255,255,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D ;", remaining_time ); // the ';' char corresponds to "s"
if (mode==0)
{
dprint_opt(233,3, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D ;", remaining_time );
dprint_opt(231,1, C_RGB(255,255,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D ;", remaining_time ); // the ';' char corresponds to "s"
}
else if (mode==1)
{
dprint_opt(233,3, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D ;", elapsed_time/1000000 );
dprint_opt(231,1, C_RGB(255,255,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D ;", elapsed_time/1000000 ); // the ';' char corresponds to "s"
}
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"
@ -1009,6 +1072,59 @@ int main(void)
dprint_opt(200,108, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "WIN" );
dprint_opt(198,112, C_RGB(0,255,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "WIN" );
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];
HallOfFame[selectedCircuit][l].playerName[1] = HallOfFame[selectedCircuit][l-1].playerName[1];
HallOfFame[selectedCircuit][l].playerName[2] = HallOfFame[selectedCircuit][l-1].playerName[2];
HallOfFame[selectedCircuit][l].padding = HallOfFame[selectedCircuit][l-1].padding;
HallOfFame[selectedCircuit][l].bestScore = HallOfFame[selectedCircuit][l-1].bestScore;
HallOfFame[selectedCircuit][l].bestTime = HallOfFame[selectedCircuit][l-1].bestTime;
}
HallOfFame[selectedCircuit][k].playerName[0] = PlayerName[0];
HallOfFame[selectedCircuit][k].playerName[1] = PlayerName[1];
HallOfFame[selectedCircuit][k].playerName[2] = PlayerName[2];
HallOfFame[selectedCircuit][k].padding = 'X';
HallOfFame[selectedCircuit][k].bestScore = score;
HallOfFame[selectedCircuit][k].bestTime = FinalTime;
donerank = true;
skipranking = true;
gint_world_switch( GINT_CALL( saveprogress ) );
}
else k++;
}
}
}
@ -1175,7 +1291,7 @@ int main(void)
// We set back zeros at the end of the program
if (canWeAllocateMore) memset( extended_ram.start, 0, 0x00300000 );
memset(extended_ram.start, 0, (char *)extended_ram.end - (char *)extended_ram.start);
return 1;

@ -20,7 +20,7 @@
#include <stdio.h>
extern uint8_t NB_CARS_TRAFFIC;
extern uint16_t NB_CARS_TRAFFIC;
extern std::vector<Segment*> circuit;
extern std::vector<Clouds*> nuages;

@ -8,8 +8,11 @@
#include <gint/std/stdlib.h>
#include "../include/utils.h"
#include "../include/saves.h"
extern BestRanking HallOfFame[10][5];
extern uint8_t NB_CARS_TRAFFIC;
@ -33,6 +36,9 @@ int8_t CircuitSelection=0;
bool doneMenuDetailsCircuit = false;
int8_t CircuitDetailsSelection=0;
bool doneMenuBestTime = false;
int8_t BestTimeSelection=0;
bool doneMenuCredit = false;
bool doneOptions = false;
@ -1156,3 +1162,108 @@ void getInputCircuitDetails( void )
}
}
int drawMenuBestTime( int circuit )
{
uint16_t pulse=0;
doneMenuBestTime = false;
BestTimeSelection=0;
while (!doneMenuBestTime)
{
dclear( C_BLACK );
dsubimage( 0, 32, &mainscreen, 0, 32, 396, 160, DIMAGE_NONE);
dfont(&autofont);
dprint_opt(198, 2, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_TOP, "HALL OF FAME" );
for( int k=0; k<5; k++)
{
if (HallOfFame[circuit][k].bestTime != 9999)
{
dprint_opt(12, 40+k*30, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%d %c%c%c - %D sec", k+1, HallOfFame[circuit][k].playerName[0],HallOfFame[circuit][k].playerName[1],HallOfFame[circuit][k].playerName[2], HallOfFame[circuit][k].bestTime );
dprint_opt(12, 38+k*30, C_RGB(255, 255, 255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%d %c%c%c - %D sec", k+1, HallOfFame[circuit][k].playerName[0],HallOfFame[circuit][k].playerName[1],HallOfFame[circuit][k].playerName[2], HallOfFame[circuit][k].bestTime );
}
else
{
dprint_opt(12, 40+k*30, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%d %c%c%c - ... sec", k+1, HallOfFame[circuit][k].playerName[0],HallOfFame[circuit][k].playerName[1],HallOfFame[circuit][k].playerName[2], HallOfFame[circuit][k].bestTime );
dprint_opt(12, 38+k*30, C_RGB(255, 255, 255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%d %c%c%c - ... sec", k+1, HallOfFame[circuit][k].playerName[0],HallOfFame[circuit][k].playerName[1],HallOfFame[circuit][k].playerName[2], HallOfFame[circuit][k].bestTime );
}
}
dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, ">> START <<" );
dupdate();
pulse++;
getInputBestTime();
#if IS_FXLIB==1
if (screenshot && usb_is_open())
{
usb_fxlink_screenshot(false);
screenshot = false;
}
if(record && usb_is_open())
{
usb_fxlink_videocapture(false);
}
#endif
}
return BestTimeSelection;
}
void getInputBestTime( void )
{
int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS;
int timeout = 1;
while(1)
{
key_event_t ev = getkey_opt(opt, &timeout);
if(ev.type == KEYEV_NONE) return;
int key = ev.key;
if (key==KEY_EXE)
{
doneMenuBestTime = true;
BestTimeSelection = 1;
}
if (key==KEY_EXIT)
{
BestTimeSelection = -1;
doneMenuBestTime = true;
}
/*
if (key==KEY_UP || key==KEY_LEFT)
{
if (CircuitSelection==0) CircuitSelection=9;
else CircuitSelection--;
}
if (key==KEY_DOWN || key==KEY_RIGHT)
{
if (CircuitSelection==9) CircuitSelection=0;
else CircuitSelection++;
}
*/
#if IS_FXLIB==1
if(keydown(KEY_7)) screenshot = true;
if(keydown(KEY_8)) record = !record;
#endif // IS_FXLIB
}
}

@ -0,0 +1,51 @@
#include "../include/saves.h"
#include <gint/std/stdlib.h>
#include <stdio.h>
static const char *filepath= "OutRun.sav";
bool saveexist;
unsigned int sizeoffile;
extern BestRanking HallOfFame[10][5];
void is_save_existing( void )
{
FILE *file = fopen( filepath, "r" );
if (file==NULL)
{
fclose( file );
saveexist = false;
}
else
{
fclose( file );
saveexist = true;
}
}
void saveprogress( void )
{
sizeoffile = sizeof( HallOfFame );
FILE *file = fopen( filepath, "w" );
fwrite( HallOfFame, sizeoffile, 1, file );
fclose( file );
}
void loadprogress( void )
{
sizeoffile = sizeof( HallOfFame );
FILE *file = fopen( filepath, "r" );
fread( HallOfFame, sizeoffile, 1, file );
fclose( file );
}
Loading…
Cancel
Save