170
170
/*
171
171
METHODS
172
172
*/
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
181
173
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 ;
184
177
185
- // Error checks and allocate string.
178
+ // Error checks and allocate string.
186
179
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 ;
189
182
190
- // Make a copy and find the relevant characters.
183
+ // Make a copy and find the relevant characters.
191
184
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 );
195
188
196
- // If it has an extension separator.
189
+ // If it has an extension separator.
197
190
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.
200
193
201
- if (lastPath != NULL ) {
202
- if (lastPath < lastExt ) {
203
- // then remove it.
194
+ if (lastPath != NULL ) {
195
+ if (lastPath < lastExt ) {
196
+ // then remove it.
204
197
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.
209
202
210
- * lastExt = '\0' ;
211
- }
212
- }
203
+ * lastExt = '\0' ;
204
+ }
205
+ }
213
206
214
- // Return the modified string.
207
+ // Return the modified string.
215
208
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
218
221
219
222
//{#pragma region States
220
223
void get_step_state () {
@@ -1225,6 +1228,7 @@ char *remove_ext (char* myStr, char extSep, char pathSep) {
1225
1228
void get_cover () {
1226
1229
preview_cover (false);
1227
1230
}
1231
+
1228
1232
void preview_cover (bool error ) {
1229
1233
ROM .crc = 0 ;
1230
1234
@@ -1246,7 +1250,6 @@ char *remove_ext (char* myStr, char extSep, char pathSep) {
1246
1250
ROM .crc = 1 ;
1247
1251
fclose (f );
1248
1252
} else {
1249
- printf ("FILE NOT FOUND" );
1250
1253
error = true;
1251
1254
}
1252
1255
}
@@ -1262,13 +1265,17 @@ char *remove_ext (char* myStr, char extSep, char pathSep) {
1262
1265
int y = POS .y + 8 ;
1263
1266
ili9341_write_frame_rectangleLE (x , y , bw , bh , buffer );
1264
1267
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);
1266
1272
1267
1273
if (ROM .crc == 1 ) {
1268
1274
usleep (20000 );
1269
1275
draw_cover ();
1270
1276
}
1271
1277
}
1278
+
1272
1279
void draw_cover () {
1273
1280
printf ("\n----- %s -----\n%s\n" , __func__ , "OPENNING" );
1274
1281
char file [256 ] = "/sd/romart" ;
@@ -1297,7 +1304,6 @@ char *remove_ext (char* myStr, char extSep, char pathSep) {
1297
1304
fclose (f );
1298
1305
}
1299
1306
}
1300
-
1301
1307
//}#pragma endregion Cover
1302
1308
1303
1309
//{#pragma region Animations
0 commit comments