170170/*
171171 METHODS
172172*/
173- //{#pragma region Debounce
174- void debounce (int key ) {
175- draw_battery ();
176- draw_speaker ();
177- draw_contrast ();
178- while (gamepad .values [key ]) odroid_input_gamepad_read (& gamepad );
179- }
180- //}#pragma endregion Debounce
181173
182- char * remove_ext (char * myStr , char extSep , char pathSep ) {
183- char * retStr , * lastExt , * lastPath ;
174+ //{#pragma region Helpers
175+ char * remove_ext (char * myStr , char extSep , char pathSep ) {
176+ char * retStr , * lastExt , * lastPath ;
184177
185- // Error checks and allocate string.
178+ // Error checks and allocate string.
186179
187- if (myStr == NULL ) return NULL ;
188- if ((retStr = malloc (strlen (myStr ) + 1 )) == NULL ) return NULL ;
180+ if (myStr == NULL ) return NULL ;
181+ if ((retStr = malloc (strlen (myStr ) + 1 )) == NULL ) return NULL ;
189182
190- // Make a copy and find the relevant characters.
183+ // Make a copy and find the relevant characters.
191184
192- strcpy (retStr , myStr );
193- lastExt = strrchr (retStr , extSep );
194- lastPath = (pathSep == 0 ) ? NULL : strrchr (retStr , pathSep );
185+ strcpy (retStr , myStr );
186+ lastExt = strrchr (retStr , extSep );
187+ lastPath = (pathSep == 0 ) ? NULL : strrchr (retStr , pathSep );
195188
196- // If it has an extension separator.
189+ // If it has an extension separator.
197190
198- if (lastExt != NULL ) {
199- // and it's to the right of the path separator.
191+ if (lastExt != NULL ) {
192+ // and it's to the right of the path separator.
200193
201- if (lastPath != NULL ) {
202- if (lastPath < lastExt ) {
203- // then remove it.
194+ if (lastPath != NULL ) {
195+ if (lastPath < lastExt ) {
196+ // then remove it.
204197
205- * lastExt = '\0' ;
206- }
207- } else {
208- // Has extension separator with no path separator.
198+ * lastExt = '\0' ;
199+ }
200+ } else {
201+ // Has extension separator with no path separator.
209202
210- * lastExt = '\0' ;
211- }
212- }
203+ * lastExt = '\0' ;
204+ }
205+ }
213206
214- // Return the modified string.
207+ // Return the modified string.
215208
216- return retStr ;
217- }
209+ return retStr ;
210+ }
211+ //}#pragma endregion Helpers
212+
213+ //{#pragma region Debounce
214+ void debounce (int key ) {
215+ draw_battery ();
216+ draw_speaker ();
217+ draw_contrast ();
218+ while (gamepad .values [key ]) odroid_input_gamepad_read (& gamepad );
219+ }
220+ //}#pragma endregion Debounce
218221
219222//{#pragma region States
220223 void get_step_state () {
@@ -1225,6 +1228,7 @@ char *remove_ext (char* myStr, char extSep, char pathSep) {
12251228 void get_cover () {
12261229 preview_cover (false);
12271230 }
1231+
12281232 void preview_cover (bool error ) {
12291233 ROM .crc = 0 ;
12301234
@@ -1246,7 +1250,6 @@ char *remove_ext (char* myStr, char extSep, char pathSep) {
12461250 ROM .crc = 1 ;
12471251 fclose (f );
12481252 } else {
1249- printf ("FILE NOT FOUND" );
12501253 error = true;
12511254 }
12521255 }
@@ -1262,13 +1265,17 @@ char *remove_ext (char* myStr, char extSep, char pathSep) {
12621265 int y = POS .y + 8 ;
12631266 ili9341_write_frame_rectangleLE (x , y , bw , bh , buffer );
12641267
1265- draw_text (x + (error ? 30 : 40 ), y + (bh /2 ), error ? "NO PREVIEW" : "PREVIEW" , false, false, false);
1268+ int center = x + bw /2 ;
1269+ center -= error ? 30 : 22 ;
1270+
1271+ draw_text (center , y + (bh /2 ) - 3 , error ? "NO PREVIEW" : "PREVIEW" , false, false, false);
12661272
12671273 if (ROM .crc == 1 ) {
12681274 usleep (20000 );
12691275 draw_cover ();
12701276 }
12711277 }
1278+
12721279 void draw_cover () {
12731280 printf ("\n----- %s -----\n%s\n" , __func__ , "OPENNING" );
12741281 char file [256 ] = "/sd/romart" ;
@@ -1297,7 +1304,6 @@ char *remove_ext (char* myStr, char extSep, char pathSep) {
12971304 fclose (f );
12981305 }
12991306 }
1300-
13011307//}#pragma endregion Cover
13021308
13031309//{#pragma region Animations
0 commit comments