Skip to content

Commit 6d017b2

Browse files
Fri 20 Dec 2019 17:09:56 EST - seekdir and telldir bug fix
1 parent 70c2e02 commit 6d017b2

File tree

8 files changed

+51
-30
lines changed

8 files changed

+51
-30
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=y
87-
CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32=
88-
CONFIG_DEFAULT_MENU_KEY=y
89-
CONFIG_COMBO_MENU_KEY=
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
9090
CONFIG_IN_GAME_MENU_YES=y
9191
CONFIG_IN_GAME_MENU_NO=
9292

-7.24 MB
Binary file not shown.
-7.24 MB
Binary file not shown.

Launchers/retro-esp32-beta/sdkconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ CONFIG_MONITOR_BAUD=115200
8282
#
8383
# Retro ESP32 Configuration
8484
#
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=
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
8989

9090
#
9191
# Partition Table

Launchers/retro-esp32-beta/sdkconfig.old

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ CONFIG_MONITOR_BAUD=115200
8282
#
8383
# Retro ESP32 Configuration
8484
#
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=
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
8989

9090
#
9191
# Partition Table

Launchers/retro-esp32/main/main.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
bool SETTINGS = false;
2020

2121
int8_t STEP = 0;
22+
int16_t SEEK[8] = {0,0,0,0,0,0,0,0};
2223
int OPTION = 0;
2324
int PREVIOUS = 0;
2425
int32_t VOLUME = 0;
@@ -906,6 +907,7 @@
906907

907908
void count_files() {
908909
delete_numbers();
910+
SEEK[0] = 0;
909911

910912
printf("\n----- %s -----", __func__);
911913

@@ -922,7 +924,13 @@
922924

923925
printf("\npath:%s", path);
924926

925-
DIR *directory = opendir(path);
927+
if(directory != NULL) {
928+
printf("\npath:%s", path);
929+
free(directory);
930+
closedir(directory);
931+
}
932+
933+
directory = opendir(path);
926934
if(!directory) {
927935
draw_mask(0,132,320,10);
928936
sprintf(message, "unable to open %s directory", DIRECTORIES[STEP]);
@@ -937,6 +945,7 @@
937945
draw_text(center,134,message,false,false, false);
938946
} else {
939947
rewinddir(directory);
948+
seekdir(directory, SEEK[0]);
940949
struct dirent *file;
941950
while ((file = readdir(directory)) != NULL) {
942951
int rom_length = strlen(file->d_name);
@@ -950,8 +959,8 @@
950959
printf("\nnumber of files:\t%d", ROMS.total);
951960
printf("\nfree space:0x%x (%#08x)", esp_get_free_heap_size(), heap_caps_get_free_size(MALLOC_CAP_DMA));
952961
}
953-
free(directory);
954-
closedir(directory);
962+
//free(directory);
963+
//closedir(directory);
955964
printf("\n%s: freed & closed", path);
956965
}
957966

@@ -980,7 +989,7 @@
980989
free(FILES);
981990
FILES = (char**)malloc(ROMS.limit * sizeof(void*));
982991

983-
DIR *directory = opendir(path);
992+
//DIR *directory = opendir(path);
984993
if(!directory) {
985994
draw_mask(0,132,320,10);
986995
sprintf(message, "unable to open %s directory", DIRECTORIES[STEP]);
@@ -994,13 +1003,22 @@
9941003
int center = ceil((320/2)-((strlen(message)*5)/2));
9951004
draw_text(center,134,message,false,false, false);
9961005
} else {
997-
rewinddir(directory);
1006+
//rewinddir(directory);
9981007
//seekdir(directory, ROMS.offset);
1008+
seekdir(directory, SEEK[0]);
9991009
struct dirent *file;
10001010
int n =0;
1011+
/*
1012+
NOTES:
1013+
- restore SEEK if scrolling back up;
1014+
*/
10011015
for(;;) {
10021016
if(n == ROMS.limit || (ROMS.offset + n) == ROMS.total){break;}
1003-
file = readdir(directory);
1017+
if(!(file = readdir(directory))) {
1018+
SEEK[0] = 0;
1019+
seek_files();
1020+
break;
1021+
};
10041022
int rom_length = strlen(file->d_name);
10051023
int ext_length = strlen(EXTENSIONS[STEP]);
10061024
bool extenstion = strcmp(&file->d_name[rom_length - ext_length], EXTENSIONS[STEP]) == 0 && file->d_name[0] != '.';
@@ -1017,14 +1035,18 @@
10171035
} else {
10181036
strcpy(FILES[n], file->d_name);
10191037
}
1038+
printf("\ntelldir(directory):%ld", telldir(directory));
1039+
SEEK[n] = telldir(directory);
10201040
n++;
10211041
}
10221042
}
1043+
printf("\nSEEK[0]:%d", SEEK[0]);
10231044
}
1024-
free(directory);
1025-
closedir(directory);
1045+
//free(directory);
1046+
//closedir(directory);
10261047
printf("\n%s: freed & closed", path);
10271048
}
1049+
printf("\n---------------------\n");
10281050
ROMS.pages = ROMS.total/ROMS.limit;
10291051
if(ROMS.offset > ROMS.total) { ROMS.offset = 0;}
10301052
if(ROMS.total != 0) {
@@ -1036,7 +1058,6 @@
10361058
draw_mask(0,132,320,10);
10371059
draw_text(center,134,message,false,false, false);
10381060
}
1039-
printf("\n---------------------\n");
10401061
}
10411062

10421063
void get_files() {

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.SLAB_USBtoUART"
40+
CONFIG_ESPTOOLPY_PORT="/dev/cu.usbserial-A1015RV2"
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=y
86-
CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32=
87-
CONFIG_DEFAULT_MENU_KEY=y
88-
CONFIG_COMBO_MENU_KEY=
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
8989

9090
#
9191
# Partition Table

Launchers/retro-esp32/sdkconfig.old

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ CONFIG_MONITOR_BAUD=115200
8282
#
8383
# Retro ESP32 Configuration
8484
#
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=
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
8989

9090
#
9191
# Partition Table

0 commit comments

Comments
 (0)