Skip to content

Commit

Permalink
Thu 19 Sep 2019 16:31:38 EDT - fixed folder, prep for firmware build
Browse files Browse the repository at this point in the history
  • Loading branch information
32teeth committed Sep 19, 2019
1 parent 6b27f9b commit 5df9842
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 34 deletions.
8 changes: 4 additions & 4 deletions Emulators/handy-go/sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ CONFIG_MONITOR_BAUD=115200
#
# Retro ESP32 Configuration
#
CONFIG_LCD_DRIVER_CHIP_ODROID_GO=
CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32=y
CONFIG_DEFAULT_MENU_KEY=
CONFIG_COMBO_MENU_KEY=y
CONFIG_LCD_DRIVER_CHIP_ODROID_GO=y
CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32=
CONFIG_DEFAULT_MENU_KEY=y
CONFIG_COMBO_MENU_KEY=
CONFIG_IN_GAME_MENU_YES=y
CONFIG_IN_GAME_MENU_NO=

Expand Down
3 changes: 2 additions & 1 deletion Launchers/retro-esp32/main/includes/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@
#include "../sprites/characters.h"
#include "../sprites/icons.h"
#include "../sprites/logo.h"
#include "../sprites/media.h"
#include "../sprites/media.h"
#include "../sprites/folder.h"
1 change: 1 addition & 0 deletions Launchers/retro-esp32/main/includes/declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void get_restore_states();
*/
void draw_systems();
void draw_media(int x, int y, bool current);
void draw_folder(int x, int y, bool current);
void draw_battery();
void draw_numbers();
void draw_launcher();
Expand Down
2 changes: 1 addition & 1 deletion Launchers/retro-esp32/main/includes/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
/*
*/
#define MAX_FILES 2048
#define MAX_FILES 1024
1 change: 0 additions & 1 deletion Launchers/retro-esp32/main/includes/structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ typedef struct{
int page;
} LIST;
LIST ROMS = {8, 0, 0, 0, 0};
bool LAUNCHER = false;

// FILE
typedef struct{
Expand Down
97 changes: 76 additions & 21 deletions Launchers/retro-esp32/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@
//}#pragma endregion Odroid

//{#pragma region Global
bool SAVED = false;
bool RESTART = false;
bool LAUNCHER = false;
bool FOLDER = false;

int STEP = 1;
int OPTION = 0;
bool SAVED = false;
int PREVIOUS = 0;
int8_t USER;
bool RESTART = false;

char** FILES;
char folder_path[256] = "";

DIR *directory;
struct dirent *file;
//}#pragma endregion Global
Expand Down Expand Up @@ -227,8 +234,8 @@
//{#pragma region Text
int get_letter(char letter) {
int dx = 0;
char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!-'&?.,/()[]~ ";
char lower[] = "abcdefghijklmnopqrstuvwxyz0123456789!-'&?.,/()[]~ ";
char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!-'&?.,/()[] ";
char lower[] = "abcdefghijklmnopqrstuvwxyz0123456789!-'&?.,/()[] ";
for(int n = 0; n < strlen(upper); n++) {
if(letter == upper[n] || letter == lower[n]) {
return letter != ' ' ? n * 5 : 0;
Expand Down Expand Up @@ -360,6 +367,17 @@
}
}

void draw_folder(int x, int y, bool current) {
int i = 0;
for(int h = 0; h < 16; h++) {
for(int w = 0; w < 16; w++) {
buffer[i] = folder[h][w] == WHITE ? current ? WHITE : GUI.fg : GUI.bg;
i++;
}
}
ili9341_write_frame_rectangleLE(x, y, 16, 16, buffer);
}

void draw_media(int x, int y, bool current) {
int offset = (STEP-1) * 16;
int i = 0;
Expand Down Expand Up @@ -561,40 +579,53 @@
//}#pragma endregion Sort

void get_files() {
ROMS.total = 0;

FILES = (char**)malloc(MAX_FILES * sizeof(void*));
ROMS.total = 0;

char path[256] = "/sd/roms/";
strcat(&path[strlen(path) - 1], DIRECTORIES[STEP]);
strcat(&path[strlen(path) - 1],folder_path);
printf("\npath:%s", path);

strcpy(ROM.path, path);
//bool files = !(directory = opendir(path)) ? false : true;

DIR *directory = opendir(path);

if(directory == NULL) {
char message[100] = "no games available";
int center = ceil((320/2)-((strlen(message)*5)/2));
draw_text(center,134,message,false,false);
} else {
struct dirent *file;
while ((file = readdir(directory)) != NULL) {
int rom_length = strlen(file->d_name);
int ext_lext = strlen(EXTENSIONS[STEP]);
bool extenstion = strcmp(&file->d_name[rom_length - ext_lext], EXTENSIONS[STEP]) == 0 && file->d_name[0] != '.';
if(extenstion) {
if(extenstion || (file->d_type == 2)) {
if(ROMS.total >= MAX_FILES) { break; }
size_t len = strlen(file->d_name);
FILES[ROMS.total] = (char*)malloc(len + 1);
strcpy(FILES[ROMS.total], file->d_name);
FILES[ROMS.total] = (file->d_type == 2) ? (char*)malloc(len + 5) : (char*)malloc(len + 1);
if((file->d_type == 2)) {
char dir[256];
strcpy(dir, file->d_name);
char dd[8];
sprintf(dd, "%s", ext_lext == 2 ? "dir" : ".dir");
strcat(&dir[strlen(dir) - 1], dd);
strcpy(FILES[ROMS.total], dir);
} else {
strcpy(FILES[ROMS.total], file->d_name);
}
ROMS.total++;
if(ROMS.total > MAX_FILES) { break; }
}
}
ROMS.pages = ROMS.total/ROMS.limit;
if(ROMS.offset > ROMS.total) { ROMS.offset = 0;}

closedir(directory);
free(FILES);

if(ROMS.total < 500) sort_files(FILES);
draw_files();

//free(FILES);
}
}

Expand All @@ -618,7 +649,9 @@
int limit = (ROMS.offset + ROMS.limit) > ROMS.total ? ROMS.total : ROMS.offset + ROMS.limit;
for(int n = ROMS.offset; n < limit; n++) {
draw_text(x+24,y,FILES[n],true,n == ROMS.offset ? true : false);
draw_media(x,y-6,n == ROMS.offset ? true : false);

bool directory = strcmp(&FILES[n][strlen(FILES[n]) - 3], "dir") == 0;
directory ? draw_folder(x,y-6,n == ROMS.offset ? true : false) : draw_media(x,y-6,n == ROMS.offset ? true : false);
if(n == ROMS.offset) {
strcpy(ROM.name, FILES[n]);
ROM.ready = true;
Expand Down Expand Up @@ -908,7 +941,7 @@
LEFT
*/
if(gamepad.values[ODROID_INPUT_LEFT]) {
if(!LAUNCHER) {
if(!LAUNCHER && !FOLDER) {
STEP--;
if( STEP < 0 ) {
STEP = COUNT - 1;
Expand All @@ -925,7 +958,7 @@
RIGHT
*/
if(gamepad.values[ODROID_INPUT_RIGHT]) {
if(!LAUNCHER) {
if(!LAUNCHER && !FOLDER) {
STEP++;
if( STEP > COUNT-1 ) {
STEP = 0;
Expand Down Expand Up @@ -1035,13 +1068,27 @@
} else {
if (ROM.ready && !LAUNCHER) {
OPTION = 0;
LAUNCHER = true;

char file_to_load[256] = "";
sprintf(file_to_load, "%s/%s", ROM.path, ROM.name);
odroid_settings_RomFilePath_set(file_to_load);

draw_launcher();
bool directory = strcmp(&file_to_load[strlen(file_to_load) - 3], "dir") == 0;

if(directory) {
FOLDER = true;
PREVIOUS = ROMS.offset;
ROMS.offset = 0;
ROMS.total = 0;

sprintf(folder_path, "/%s", ROM.name);
folder_path[strlen(folder_path)-(strlen(EXTENSIONS[STEP]) == 3 ? 4 : 3)] = 0;
draw_background();
draw_systems();
draw_text(16,16,EMULATORS[STEP],false,true);
get_files();
} else {
LAUNCHER = true;
odroid_settings_RomFilePath_set(file_to_load);
draw_launcher();
}
} else {
switch(OPTION) {
case 0:
Expand Down Expand Up @@ -1069,6 +1116,14 @@
draw_text(16,16,EMULATORS[STEP],false,true);
STEP == 0 ? draw_themes() : draw_files();
}
if(FOLDER) {
FOLDER = false;
ROMS.offset = PREVIOUS;
ROMS.total = 0;
PREVIOUS = 0;
folder_path[0] = 0;
get_files();
}
debounce(ODROID_INPUT_B);
}

Expand Down
10 changes: 5 additions & 5 deletions Launchers/retro-esp32/sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CONFIG_FLASH_ENCRYPTION_ENABLED=
#
# Serial flasher config
#
CONFIG_ESPTOOLPY_PORT="/dev/cu.usbserial-AE01AFC0"
CONFIG_ESPTOOLPY_PORT="/dev/cu.SLAB_USBtoUART"
CONFIG_ESPTOOLPY_BAUD_115200B=
CONFIG_ESPTOOLPY_BAUD_230400B=
CONFIG_ESPTOOLPY_BAUD_921600B=y
Expand Down Expand Up @@ -82,10 +82,10 @@ CONFIG_MONITOR_BAUD=115200
#
# Retro ESP32 Configuration
#
CONFIG_LCD_DRIVER_CHIP_ODROID_GO=
CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32=y
CONFIG_DEFAULT_MENU_KEY=
CONFIG_COMBO_MENU_KEY=y
CONFIG_LCD_DRIVER_CHIP_ODROID_GO=y
CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32=
CONFIG_DEFAULT_MENU_KEY=y
CONFIG_COMBO_MENU_KEY=

#
# Partition Table
Expand Down
2 changes: 1 addition & 1 deletion Launchers/retro-esp32/sdkconfig.old
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CONFIG_FLASH_ENCRYPTION_ENABLED=
#
# Serial flasher config
#
CONFIG_ESPTOOLPY_PORT="/dev/cu.usbserial-AE01AFC0"
CONFIG_ESPTOOLPY_PORT="/dev/cu.SLAB_USBtoUART"
CONFIG_ESPTOOLPY_BAUD_115200B=
CONFIG_ESPTOOLPY_BAUD_230400B=
CONFIG_ESPTOOLPY_BAUD_921600B=y
Expand Down

0 comments on commit 5df9842

Please sign in to comment.