From 9ac4d047901566f8f5d49e7fef5500e0dc882692 Mon Sep 17 00:00:00 2001 From: Slyvtt Date: Mon, 4 Apr 2022 20:11:19 +0200 Subject: [PATCH] V1.0 Final (simply added a save of parameters) --- CppOutRun.layout | 180 +++++++++++++++++----------------- assets-cg/fxconv-metadata.txt | 5 - icon.png | Bin 0 -> 1219 bytes src/include/saves.h | 13 +++ src/main.cc | 25 ++++- src/src/saves.cc | 41 +++++++- 6 files changed, 166 insertions(+), 98 deletions(-) delete mode 100644 assets-cg/fxconv-metadata.txt create mode 100644 icon.png diff --git a/CppOutRun.layout b/CppOutRun.layout index aa081e1..048f191 100644 --- a/CppOutRun.layout +++ b/CppOutRun.layout @@ -2,78 +2,17 @@ - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - @@ -88,18 +27,22 @@ - - + - + - + - + + + + + + @@ -107,32 +50,39 @@ - + - + - + - + - + - + - - - - - - - - - + - + + + + + + + + + + + + + + + + @@ -157,19 +107,67 @@ - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets-cg/fxconv-metadata.txt b/assets-cg/fxconv-metadata.txt deleted file mode 100644 index fc1422a..0000000 --- a/assets-cg/fxconv-metadata.txt +++ /dev/null @@ -1,5 +0,0 @@ -#*.png: -# type: bopti-image -# profile: p4 -# name_regex: (.*)\.png \1 - diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..6ce595dd0fc56de2ebd88e33e6c4ebaf0642c0f8 GIT binary patch literal 1219 zcmV;!1U&nRP)fa0004mX+uL$Nkc;* zaB^>EX>4Tx04R}tkv&MmKpe$iTSbwIgBe5wGt^ENM2k3T6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfbaGO3krMxx6k5c1aNLh~_a1lefMBD-G^=X@&~)2O zClg{ew<`9$B7{*0h$AX9%b1g-6nw|mJpz2ai}5V~bAOJ0HE%H>AQI0q!?cMvh^IGg zgY!PIz)G@8d`>)W(glehxvqHp#<}QnkY@^JCOuCq5R1hQRyvrKOpQ2B98oo$@`G8A zRnA+SwMvb(?#W*m&g(17T&FpLBo?s*2_h8KP(}qdVzla{SV+@;!pA@C`XzEHeSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00NsyL_t(o!^M}sY8yci#=n&p84PK!HhKets)(2vY;3qk zaA7!5p(1$#xr*EbQn^qeBG4m*U@RelfELx8i0uBhu3G&;-9}O-@LjbfUBLN^I6Pf5S@q();abQ#a9$g6k?;Br zWP!bf=_1c-YnKy#IMru>N86?Fvbv3_>tx-V>O_fWq)FqZPT<dx8N>S>HZ zxsr5%7pP4nZCjuTl;-?eRz?W?v3i}%0EgGT#06gWylEX>Mr?xOhf_4WJt6-Wyp25l zaEjH_cs(gswyw_?(RK~!H0#nyvNW%gL%L82dIiK%G3{6d0QK5Um~BRM(JgEuOV9+Y z>ptA+X16Eii)ih@K6|`Q4v*FA#Jo_hSZkl`+mD~(=&<-tLb2913zDZUBR7%;*D!(F z$a2>`B%jO-xH^$18$9|PTK8ARi}&boy|GNxK%OtH%NLlxgF9dYZE{3@|Mgq=AK$;p zAC-$Nxa^wUo{$FzSUx{z0#oGaSS||^`-V4VmPbDe9zYCF$MZ!5@pb$M?^b_N`%vEd h&eK$oJo>Jgcman`8&$>?GLQfO002ovPDHLkV1j_9Aou_P literal 0 HcmV?d00001 diff --git a/src/include/saves.h b/src/include/saves.h index 0effce4..04439f4 100644 --- a/src/include/saves.h +++ b/src/include/saves.h @@ -9,8 +9,21 @@ struct BestRanking uint32_t bestTime = 0x0FFFFFFF; }; +struct Parameters +{ + uint8_t DiffLevel = 1; + uint8_t CarsNumb = 1; + char PlayerName[3] = { 'S', 'L', 'Y' }; +}; + void is_save_existing( void ); void saveprogress( void ); void loadprogress( void ); + +void is_param_existing( void ); +void saveparameters( void ); +void loadparameters( void ); + + diff --git a/src/main.cc b/src/main.cc index 176abba..6226633 100644 --- a/src/main.cc +++ b/src/main.cc @@ -61,6 +61,8 @@ uint8_t DiffLevel = 1; uint8_t CarsNumb = 1; char PlayerName[3] = { 'S', 'L', 'Y' }; +Parameters PlayerPara[1]; + struct DataPerf { uint8_t update=0; @@ -369,11 +371,24 @@ int main(void) 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 + gint_world_switch( GINT_CALL( is_param_existing )); + + if (!saveexist) // if we do not have saves + gint_world_switch( GINT_CALL( saveparameters ) ); // we create a progress file which is empty + + gint_world_switch( GINT_CALL( loadparameters )); // then we load it + + + DiffLevel=PlayerPara[0].DiffLevel; + CarsNumb=PlayerPara[0].CarsNumb; + PlayerName[0]=PlayerPara[0].PlayerName[0]; + PlayerName[1]=PlayerPara[0].PlayerName[1]; + PlayerName[2]=PlayerPara[0].PlayerName[2]; + kmalloc_arena_t *_uram = kmalloc_get_arena("_uram"); kmalloc_gint_stats_t *_uram_stats; @@ -487,6 +502,14 @@ int main(void) else if (mode==2) { drawGameOptions(); + + PlayerPara[0].DiffLevel = DiffLevel; + PlayerPara[0].CarsNumb = CarsNumb; + PlayerPara[0].PlayerName[0]=PlayerName[0]; + PlayerPara[0].PlayerName[1]=PlayerName[1]; + PlayerPara[0].PlayerName[2]=PlayerName[2]; + + gint_world_switch( GINT_CALL( saveparameters ) ); } else if (mode==3) { diff --git a/src/src/saves.cc b/src/src/saves.cc index e4ee539..4a6dfab 100644 --- a/src/src/saves.cc +++ b/src/src/saves.cc @@ -4,12 +4,14 @@ static const char *filepath= "OutRun.sav"; +static const char *filepara= "OutRun.prm"; bool saveexist; +bool paraexist; unsigned int sizeoffile; extern BestRanking HallOfFame[10][5]; - +extern Parameters PlayerPara[1]; void is_save_existing( void ) { @@ -48,3 +50,40 @@ void loadprogress( void ) fclose( file ); } +void is_param_existing( void ) +{ + FILE *file = fopen( filepara, "r" ); + + if (file==NULL) + { + paraexist = false; + } + else + { + fclose( file ); + paraexist = true; + } +} + + +void saveparameters( void ) +{ + sizeoffile = sizeof( PlayerPara ); + + FILE *file = fopen( filepara, "w" ); + fwrite( PlayerPara, sizeoffile, 1, file ); + + fclose( file ); +} + + +void loadparameters( void ) +{ + sizeoffile = sizeof( PlayerPara ); + + FILE *file = fopen( filepara, "r" ); + fread( PlayerPara, sizeoffile, 1, file ); + + fclose( file ); +} +