Skip to content

Commit 5df9842

Browse files
committed
Thu 19 Sep 2019 16:31:38 EDT - fixed folder, prep for firmware build
1 parent 6b27f9b commit 5df9842

File tree

8 files changed

+90
-34
lines changed

8 files changed

+90
-34
lines changed

Emulators/handy-go/sdkconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ CONFIG_MONITOR_BAUD=115200
8383
#
8484
# Retro ESP32 Configuration
8585
#
86-
CONFIG_LCD_DRIVER_CHIP_ODROID_GO=
87-
CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32=y
88-
CONFIG_DEFAULT_MENU_KEY=
89-
CONFIG_COMBO_MENU_KEY=y
86+
CONFIG_LCD_DRIVER_CHIP_ODROID_GO=y
87+
CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32=
88+
CONFIG_DEFAULT_MENU_KEY=y
89+
CONFIG_COMBO_MENU_KEY=
9090
CONFIG_IN_GAME_MENU_YES=y
9191
CONFIG_IN_GAME_MENU_NO=
9292

Launchers/retro-esp32/main/includes/core.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@
5656
#include "../sprites/characters.h"
5757
#include "../sprites/icons.h"
5858
#include "../sprites/logo.h"
59-
#include "../sprites/media.h"
59+
#include "../sprites/media.h"
60+
#include "../sprites/folder.h"

Launchers/retro-esp32/main/includes/declarations.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void get_restore_states();
4141
*/
4242
void draw_systems();
4343
void draw_media(int x, int y, bool current);
44+
void draw_folder(int x, int y, bool current);
4445
void draw_battery();
4546
void draw_numbers();
4647
void draw_launcher();

Launchers/retro-esp32/main/includes/definitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
/*
3030
3131
*/
32-
#define MAX_FILES 2048
32+
#define MAX_FILES 1024

Launchers/retro-esp32/main/includes/structures.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ typedef struct{
2424
int page;
2525
} LIST;
2626
LIST ROMS = {8, 0, 0, 0, 0};
27-
bool LAUNCHER = false;
2827

2928
// FILE
3029
typedef struct{

Launchers/retro-esp32/main/main.c

Lines changed: 76 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111
//}#pragma endregion Odroid
1212

1313
//{#pragma region Global
14+
bool SAVED = false;
15+
bool RESTART = false;
16+
bool LAUNCHER = false;
17+
bool FOLDER = false;
18+
1419
int STEP = 1;
1520
int OPTION = 0;
16-
bool SAVED = false;
21+
int PREVIOUS = 0;
1722
int8_t USER;
18-
bool RESTART = false;
23+
1924
char** FILES;
25+
char folder_path[256] = "";
26+
2027
DIR *directory;
2128
struct dirent *file;
2229
//}#pragma endregion Global
@@ -227,8 +234,8 @@
227234
//{#pragma region Text
228235
int get_letter(char letter) {
229236
int dx = 0;
230-
char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!-'&?.,/()[]~ ";
231-
char lower[] = "abcdefghijklmnopqrstuvwxyz0123456789!-'&?.,/()[]~ ";
237+
char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!-'&?.,/()[] ";
238+
char lower[] = "abcdefghijklmnopqrstuvwxyz0123456789!-'&?.,/()[] ";
232239
for(int n = 0; n < strlen(upper); n++) {
233240
if(letter == upper[n] || letter == lower[n]) {
234241
return letter != ' ' ? n * 5 : 0;
@@ -360,6 +367,17 @@
360367
}
361368
}
362369

370+
void draw_folder(int x, int y, bool current) {
371+
int i = 0;
372+
for(int h = 0; h < 16; h++) {
373+
for(int w = 0; w < 16; w++) {
374+
buffer[i] = folder[h][w] == WHITE ? current ? WHITE : GUI.fg : GUI.bg;
375+
i++;
376+
}
377+
}
378+
ili9341_write_frame_rectangleLE(x, y, 16, 16, buffer);
379+
}
380+
363381
void draw_media(int x, int y, bool current) {
364382
int offset = (STEP-1) * 16;
365383
int i = 0;
@@ -561,40 +579,53 @@
561579
//}#pragma endregion Sort
562580

563581
void get_files() {
564-
ROMS.total = 0;
565-
566582
FILES = (char**)malloc(MAX_FILES * sizeof(void*));
583+
ROMS.total = 0;
567584

568585
char path[256] = "/sd/roms/";
569586
strcat(&path[strlen(path) - 1], DIRECTORIES[STEP]);
587+
strcat(&path[strlen(path) - 1],folder_path);
588+
printf("\npath:%s", path);
589+
570590
strcpy(ROM.path, path);
571-
//bool files = !(directory = opendir(path)) ? false : true;
591+
572592
DIR *directory = opendir(path);
573593

574594
if(directory == NULL) {
575595
char message[100] = "no games available";
576596
int center = ceil((320/2)-((strlen(message)*5)/2));
577597
draw_text(center,134,message,false,false);
578598
} else {
599+
struct dirent *file;
579600
while ((file = readdir(directory)) != NULL) {
580601
int rom_length = strlen(file->d_name);
581602
int ext_lext = strlen(EXTENSIONS[STEP]);
582603
bool extenstion = strcmp(&file->d_name[rom_length - ext_lext], EXTENSIONS[STEP]) == 0 && file->d_name[0] != '.';
583-
if(extenstion) {
604+
if(extenstion || (file->d_type == 2)) {
605+
if(ROMS.total >= MAX_FILES) { break; }
584606
size_t len = strlen(file->d_name);
585-
FILES[ROMS.total] = (char*)malloc(len + 1);
586-
strcpy(FILES[ROMS.total], file->d_name);
607+
FILES[ROMS.total] = (file->d_type == 2) ? (char*)malloc(len + 5) : (char*)malloc(len + 1);
608+
if((file->d_type == 2)) {
609+
char dir[256];
610+
strcpy(dir, file->d_name);
611+
char dd[8];
612+
sprintf(dd, "%s", ext_lext == 2 ? "dir" : ".dir");
613+
strcat(&dir[strlen(dir) - 1], dd);
614+
strcpy(FILES[ROMS.total], dir);
615+
} else {
616+
strcpy(FILES[ROMS.total], file->d_name);
617+
}
587618
ROMS.total++;
588-
if(ROMS.total > MAX_FILES) { break; }
589619
}
590620
}
591621
ROMS.pages = ROMS.total/ROMS.limit;
622+
if(ROMS.offset > ROMS.total) { ROMS.offset = 0;}
592623

593624
closedir(directory);
594-
free(FILES);
595-
596625
if(ROMS.total < 500) sort_files(FILES);
597626
draw_files();
627+
628+
//free(FILES);
598629
}
599630
}
600631

@@ -618,7 +649,9 @@
618649
int limit = (ROMS.offset + ROMS.limit) > ROMS.total ? ROMS.total : ROMS.offset + ROMS.limit;
619650
for(int n = ROMS.offset; n < limit; n++) {
620651
draw_text(x+24,y,FILES[n],true,n == ROMS.offset ? true : false);
621-
draw_media(x,y-6,n == ROMS.offset ? true : false);
652+
653+
bool directory = strcmp(&FILES[n][strlen(FILES[n]) - 3], "dir") == 0;
654+
directory ? draw_folder(x,y-6,n == ROMS.offset ? true : false) : draw_media(x,y-6,n == ROMS.offset ? true : false);
622655
if(n == ROMS.offset) {
623656
strcpy(ROM.name, FILES[n]);
624657
ROM.ready = true;
@@ -908,7 +941,7 @@
908941
LEFT
909942
*/
910943
if(gamepad.values[ODROID_INPUT_LEFT]) {
911-
if(!LAUNCHER) {
944+
if(!LAUNCHER && !FOLDER) {
912945
STEP--;
913946
if( STEP < 0 ) {
914947
STEP = COUNT - 1;
@@ -925,7 +958,7 @@
925958
RIGHT
926959
*/
927960
if(gamepad.values[ODROID_INPUT_RIGHT]) {
928-
if(!LAUNCHER) {
961+
if(!LAUNCHER && !FOLDER) {
929962
STEP++;
930963
if( STEP > COUNT-1 ) {
931964
STEP = 0;
@@ -1035,13 +1068,27 @@
10351068
} else {
10361069
if (ROM.ready && !LAUNCHER) {
10371070
OPTION = 0;
1038-
LAUNCHER = true;
1039-
10401071
char file_to_load[256] = "";
10411072
sprintf(file_to_load, "%s/%s", ROM.path, ROM.name);
1042-
odroid_settings_RomFilePath_set(file_to_load);
1043-
1044-
draw_launcher();
1073+
bool directory = strcmp(&file_to_load[strlen(file_to_load) - 3], "dir") == 0;
1074+
1075+
if(directory) {
1076+
FOLDER = true;
1077+
PREVIOUS = ROMS.offset;
1078+
ROMS.offset = 0;
1079+
ROMS.total = 0;
1080+
1081+
sprintf(folder_path, "/%s", ROM.name);
1082+
folder_path[strlen(folder_path)-(strlen(EXTENSIONS[STEP]) == 3 ? 4 : 3)] = 0;
1083+
draw_background();
1084+
draw_systems();
1085+
draw_text(16,16,EMULATORS[STEP],false,true);
1086+
get_files();
1087+
} else {
1088+
LAUNCHER = true;
1089+
odroid_settings_RomFilePath_set(file_to_load);
1090+
draw_launcher();
1091+
}
10451092
} else {
10461093
switch(OPTION) {
10471094
case 0:
@@ -1069,6 +1116,14 @@
10691116
draw_text(16,16,EMULATORS[STEP],false,true);
10701117
STEP == 0 ? draw_themes() : draw_files();
10711118
}
1119+
if(FOLDER) {
1120+
FOLDER = false;
1121+
ROMS.offset = PREVIOUS;
1122+
ROMS.total = 0;
1123+
PREVIOUS = 0;
1124+
folder_path[0] = 0;
1125+
get_files();
1126+
}
10721127
debounce(ODROID_INPUT_B);
10731128
}
10741129

Launchers/retro-esp32/sdkconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ CONFIG_FLASH_ENCRYPTION_ENABLED=
3737
#
3838
# Serial flasher config
3939
#
40-
CONFIG_ESPTOOLPY_PORT="/dev/cu.usbserial-AE01AFC0"
40+
CONFIG_ESPTOOLPY_PORT="/dev/cu.SLAB_USBtoUART"
4141
CONFIG_ESPTOOLPY_BAUD_115200B=
4242
CONFIG_ESPTOOLPY_BAUD_230400B=
4343
CONFIG_ESPTOOLPY_BAUD_921600B=y
@@ -82,10 +82,10 @@ CONFIG_MONITOR_BAUD=115200
8282
#
8383
# Retro ESP32 Configuration
8484
#
85-
CONFIG_LCD_DRIVER_CHIP_ODROID_GO=
86-
CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32=y
87-
CONFIG_DEFAULT_MENU_KEY=
88-
CONFIG_COMBO_MENU_KEY=y
85+
CONFIG_LCD_DRIVER_CHIP_ODROID_GO=y
86+
CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32=
87+
CONFIG_DEFAULT_MENU_KEY=y
88+
CONFIG_COMBO_MENU_KEY=
8989

9090
#
9191
# Partition Table

Launchers/retro-esp32/sdkconfig.old

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ CONFIG_FLASH_ENCRYPTION_ENABLED=
3737
#
3838
# Serial flasher config
3939
#
40-
CONFIG_ESPTOOLPY_PORT="/dev/cu.usbserial-AE01AFC0"
40+
CONFIG_ESPTOOLPY_PORT="/dev/cu.SLAB_USBtoUART"
4141
CONFIG_ESPTOOLPY_BAUD_115200B=
4242
CONFIG_ESPTOOLPY_BAUD_230400B=
4343
CONFIG_ESPTOOLPY_BAUD_921600B=y

0 commit comments

Comments
 (0)