Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ducalex committed Dec 30, 2022
2 parents 8df7d4d + d974d53 commit 6c439f6
Show file tree
Hide file tree
Showing 23 changed files with 577 additions and 146 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Retro-Go 1.37 (2022-12-30)
- SNES: Fixed controls menu labels
- GEN: Small performance improvement
- Launcher: Added tool to download updates


# Retro-Go 1.36.3 (2022-12-14)
- SNES: Fixed freeze in controls menu (hopefully for real this time...)

Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ The roms must be packed with [LCD-Game-Shrinker](https://github.com/bzhxx/LCD-Ga

## Wifi

To use wifi you will need to add your config to `/retro-go/config/wifi.json` file.
It should look like this:
To use wifi you will need to create a `/retro-go/config/wifi.json` config file. Its content should look like this:

````json
{
Expand All @@ -90,6 +89,18 @@ It should look like this:
}
````

Multiple networks can be defined using the following format (then selectable in the Options menu):
````json
{
"ssid0": "my-network",
"password0": "my-password",
"ssid1": "my-network",
"password1": "my-password",
"ssid2": "my-network",
"password2": "my-password"
}
````

### Time synchronization
Time synchronization happens in the launcher immediately after a successful connection to the network.
This is done via NTP by contacting `pool.ntp.org` and cannot be disabled at this time.
Expand Down
6 changes: 6 additions & 0 deletions base.sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,9 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32
# CONFIG_HTTPD_LOG_PURGE_DATA is not set
# CONFIG_HTTPD_WS_SUPPORT is not set
# end of HTTP Server


# TLS
# Not ideal but I don't want to deal with CAs right now :(
CONFIG_ESP_TLS_INSECURE=y
CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y
6 changes: 3 additions & 3 deletions components/retro-go/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
set(COMPONENT_SRCDIRS ". fonts libs/netplay libs/lodepng")
set(COMPONENT_ADD_INCLUDEDIRS ". libs/netplay libs/lodepng")
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0")
set(COMPONENT_REQUIRES "spi_flash fatfs nvs_flash app_update driver esp_timer esp_adc json")
if($ENV{RG_ENABLE_NETWORKING})
set(COMPONENT_REQUIRES "spi_flash fatfs nvs_flash esp_http_client app_update esp_adc_cal esp32 json")
else()
set(COMPONENT_REQUIRES "spi_flash fatfs nvs_flash app_update esp_adc_cal esp32 json")
set(COMPONENT_REQUIRES "spi_flash fatfs app_update esp_adc_cal esp32 json")
endif()
register_component()

Expand Down
4 changes: 3 additions & 1 deletion components/retro-go/rg_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
#endif

static const rg_audio_sink_t sinks[] = {
#if !RG_AUDIO_USE_INT_DAC && !RG_AUDIO_USE_EXT_DAC
{RG_AUDIO_SINK_DUMMY, 0, "Dummy" },
#endif
#if RG_AUDIO_USE_INT_DAC
{RG_AUDIO_SINK_I2S_DAC, 0, "Speaker"},
#endif
Expand Down Expand Up @@ -77,7 +79,7 @@ void rg_audio_init(int sampleRate)

ACQUIRE_DEVICE(1000);

int sinkType = (int)rg_settings_get_number(NS_GLOBAL, SETTING_OUTPUT, sinks[RG_COUNT(sinks) > 1 ? 1 : 0].type);
int sinkType = (int)rg_settings_get_number(NS_GLOBAL, SETTING_OUTPUT, sinks[0].type);
for (size_t i = 0; i < RG_COUNT(sinks); ++i)
{
if (!audio.sink || sinks[i].type == sinkType)
Expand Down
178 changes: 114 additions & 64 deletions components/retro-go/rg_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ static struct
bool initialized;
} gui;

static const char *SETTING_FONTTYPE = "FontType";
static const char *SETTING_THEME = "Theme";
static const char *SETTING_FONTTYPE = "FontType";
static const char *SETTING_THEME = "Theme";


void rg_gui_init(void)
Expand Down Expand Up @@ -131,7 +131,7 @@ void rg_gui_copy_buffer(int left, int top, int width, int height, int stride, co
for (int y = 0; y < height; ++y)
{
uint16_t *dst = gui.screen_buffer + (top + y) * gui.screen_width + left;
const uint16_t *src = (void*)buffer + y * stride;
const uint16_t *src = (void *)buffer + y * stride;
for (int x = 0; x < width; ++x)
if (src[x] != C_TRANSPARENT)
dst[x] = src[x];
Expand Down Expand Up @@ -707,11 +707,13 @@ int rg_gui_dialog(const char *title, const rg_gui_option_t *options_const, int s
for (size_t i = 0; i < options_count; i++)
{
rg_gui_option_t *option = &options[i];
if (option->value && text_buffer) {
if (option->value && text_buffer)
{
option->value = strcpy(text_buffer_ptr, option->value);
text_buffer_ptr += strlen(text_buffer_ptr) + 24;
}
if (option->label && text_buffer) {
if (option->label && text_buffer)
{
option->label = strcpy(text_buffer_ptr, option->label);
text_buffer_ptr += strlen(text_buffer_ptr) + 24;
}
Expand Down Expand Up @@ -822,9 +824,9 @@ bool rg_gui_confirm(const char *title, const char *message, bool default_yes)
{
const rg_gui_option_t options[] = {
{0, (char *)message, NULL, -1, NULL},
{0, "", NULL, -1, NULL},
{1, "Yes", NULL, 1, NULL},
{0, "No ", NULL, 1, NULL},
{0, "", NULL, -1, NULL},
{1, "Yes", NULL, 1, NULL},
{0, "No ", NULL, 1, NULL},
RG_DIALOG_CHOICE_LAST
};
return rg_gui_dialog(title, message ? options : options + 1, default_yes ? -2 : -1) == 1;
Expand All @@ -834,8 +836,8 @@ void rg_gui_alert(const char *title, const char *message)
{
const rg_gui_option_t options[] = {
{0, (char *)message, NULL, -1, NULL},
{0, "", NULL, -1, NULL},
{1, "OK", NULL, 1, NULL},
{0, "", NULL, -1, NULL},
{1, "OK", NULL, 1, NULL},
RG_DIALOG_CHOICE_LAST
};
rg_gui_dialog(title, message ? options : options + 1, -1);
Expand Down Expand Up @@ -1016,7 +1018,8 @@ static rg_gui_event_t speedup_update_cb(rg_gui_option_t *option, rg_gui_event_t

static rg_gui_event_t disk_activity_cb(rg_gui_option_t *option, rg_gui_event_t event)
{
if (event == RG_DIALOG_PREV || event == RG_DIALOG_NEXT) {
if (event == RG_DIALOG_PREV || event == RG_DIALOG_NEXT)
{
rg_storage_set_activity_led(!rg_storage_get_activity_led());
}
strcpy(option->value, rg_storage_get_activity_led() ? "On " : "Off");
Expand All @@ -1027,10 +1030,12 @@ static rg_gui_event_t font_type_cb(rg_gui_option_t *option, rg_gui_event_t event
{
if (event == RG_DIALOG_PREV || event == RG_DIALOG_NEXT)
{
if (event == RG_DIALOG_PREV && !rg_gui_set_font_type(gui.style.font_type - 1)) {
if (event == RG_DIALOG_PREV && !rg_gui_set_font_type(gui.style.font_type - 1))
{
rg_gui_set_font_type(0);
}
if (event == RG_DIALOG_NEXT && !rg_gui_set_font_type(gui.style.font_type + 1)) {
if (event == RG_DIALOG_NEXT && !rg_gui_set_font_type(gui.style.font_type + 1))
{
rg_gui_set_font_type(0);
}
}
Expand Down Expand Up @@ -1093,26 +1098,71 @@ void rg_gui_options_menu(void)
rg_audio_set_mute(false);
}

void rg_gui_about_menu(const rg_gui_option_t *extra_options)
void rg_gui_sysinfo_menu(void)
{
char build_ver[32], build_date[32], build_user[32], network_str[64];
char screen_str[32], network_str[64], memory_str[32];
char storage_str[32], localtime_str[32], uptime[32];

const rg_gui_option_t options[] = {
{0, "Version", build_ver, 1, NULL},
{0, "Date", build_date, 1, NULL},
{0, "By", build_user, 1, NULL},
#ifdef RG_ENABLE_NETWORKING
{0, "Console", RG_TARGET_NAME, 1, NULL},
{0, "Screen", screen_str, 1, NULL},
{0, "Memory", memory_str, 1, NULL},
{0, "Network", network_str, 1, NULL},
#endif
// {0, "Storage", storage_str, 1, NULL},
{0, "RTC", localtime_str, 1, NULL},
{0, "Uptime", uptime, 1, NULL},
RG_DIALOG_SEPARATOR,
{1000, "Reboot to firmware", NULL, 1, NULL},
{2000, "Reset settings", NULL, 1, NULL},
{3000, "Clear cache", NULL, 1, NULL},
{4000, "Debug", NULL, 1, NULL},
{0000, "Close", NULL, 1, NULL},
{0, "Close", NULL, 1, NULL},
RG_DIALOG_CHOICE_LAST
};

const rg_display_t *display = rg_display_get_info();
rg_stats_t stats = rg_system_get_counters();
time_t now = time(NULL);

snprintf(screen_str, 32, "%dx%d (%d)", display->screen.width, display->screen.height, display->screen.format);
snprintf(memory_str, 32, "%dKB + %dKB", stats.totalMemoryInt / 1024, stats.totalMemoryExt / 1024);
snprintf(uptime, 32, "%ds", (int)(rg_system_timer() / 1000000));
snprintf(storage_str, 32, "%s", "N/A");
strftime(localtime_str, 32, "%F %T", localtime(&now));

#ifdef RG_ENABLE_NETWORKING
rg_network_t net = rg_network_get_info();
if (net.state == RG_NETWORK_CONNECTED)
snprintf(network_str, 64, "%s\n%s", net.name, net.ip_addr);
else if (net.state == RG_NETWORK_CONNECTING)
snprintf(network_str, 64, "%s\n%s", net.name, "connecting...");
else if (net.name[0])
snprintf(network_str, 64, "%s\n%s", net.name, "disconnected");
else
snprintf(network_str, 64, "%s", "disconnected");
#else
strcpy(network_str, "No adapter");
#endif

rg_gui_dialog("System Information", options, -1);
}

void rg_gui_about_menu(const rg_gui_option_t *extra_options)
{
char build_ver[32], build_date[32], build_user[32];

size_t extra_options_count = get_dialog_items_count(extra_options);

rg_gui_option_t options[16 + extra_options_count];
rg_gui_option_t *opt = &options[0];

*opt++ = (rg_gui_option_t){0, "Version", build_ver, 1, NULL};
*opt++ = (rg_gui_option_t){0, "Date", build_date, 1, NULL};
*opt++ = (rg_gui_option_t){0, "By", build_user, 1, NULL};
*opt++ = (rg_gui_option_t)RG_DIALOG_SEPARATOR;
*opt++ = (rg_gui_option_t){1000, "System information", NULL, 1, NULL};
for (size_t i = 0; i < extra_options_count; i++)
*opt++ = extra_options[i];
*opt++ = (rg_gui_option_t){2000, "Reset settings", NULL, 1, NULL};
*opt++ = (rg_gui_option_t){3000, "Debug", NULL, 1, NULL};
*opt++ = (rg_gui_option_t)RG_DIALOG_CHOICE_LAST;

const rg_app_t *app = rg_system_get_app();

snprintf(build_ver, 30, "%s", app->version);
Expand All @@ -1129,39 +1179,28 @@ void rg_gui_about_menu(const rg_gui_option_t *extra_options)
strcat(build_ver, ")");
}

rg_network_t net = rg_network_get_info();
if (net.state == RG_NETWORK_CONNECTED)
snprintf(network_str, 64, "%s\n%s", net.name, net.ip_addr);
else if (net.state == RG_NETWORK_CONNECTING)
snprintf(network_str, 64, "%s\n%s", net.name, "connecting...");
else if (net.name[0])
snprintf(network_str, 64, "%s\n%s", net.name, "disconnected");
else
snprintf(network_str, 64, "%s", "disconnected");

int sel = rg_gui_dialog("Retro-Go", options, -1);

rg_settings_commit();
rg_system_save_time();

switch (sel)
while (true)
{
case 1000:
rg_system_switch_app(RG_APP_FACTORY, RG_APP_FACTORY, 0, 0);
break;
case 2000:
if (rg_gui_confirm("Reset all settings?", NULL, false)) {
rg_settings_reset();
rg_system_restart();
}
break;
case 3000:
rg_storage_delete(RG_BASE_PATH_CACHE);
rg_system_restart();
break;
case 4000:
rg_gui_debug_menu(NULL);
break;
switch (rg_gui_dialog("Retro-Go", options, 4))
{
case 1000:
rg_gui_sysinfo_menu();
break;
case 2000:
if (rg_gui_confirm("Reset all settings?", NULL, false)) {
rg_storage_delete(RG_BASE_PATH_CACHE);
rg_settings_reset();
rg_system_restart();
return;
}
break;
case 3000:
rg_gui_debug_menu(NULL);
break;
default:
return;
}
rg_system_event(RG_EVENT_REDRAW, NULL);
}
}

Expand All @@ -1182,10 +1221,12 @@ void rg_gui_debug_menu(const rg_gui_option_t *extra_options)
{0, "Timezone ", timezone, 1, NULL},
{0, "Uptime ", uptime, 1, NULL},
RG_DIALOG_SEPARATOR,
{1000, "Save screenshot", NULL, 1, NULL},
{2000, "Save trace", NULL, 1, NULL},
{3000, "Cheats", NULL, 1, NULL},
{4000, "Crash", NULL, 1, NULL},
{1, "Reboot to firmware", NULL, 1, NULL},
{2, "Clear cache", NULL, 1, NULL},
{3, "Save screenshot", NULL, 1, NULL},
{4, "Save trace", NULL, 1, NULL},
{5, "Cheats", NULL, 1, NULL},
{6, "Crash", NULL, 1, NULL},
RG_DIALOG_CHOICE_LAST
};

Expand All @@ -1205,13 +1246,22 @@ void rg_gui_debug_menu(const rg_gui_option_t *extra_options)

switch (rg_gui_dialog("Debugging", options, 0))
{
case 1000:
case 1:
rg_system_switch_app(RG_APP_FACTORY, RG_APP_FACTORY, 0, 0);
break;
case 2:
rg_storage_delete(RG_BASE_PATH_CACHE);
rg_system_restart();
break;
case 3:
rg_emu_screenshot(RG_STORAGE_ROOT "/screenshot.png", 0, 0);
break;
case 2000:
case 4:
rg_system_save_trace(RG_STORAGE_ROOT "/trace.txt", 0);
break;
case 4000:
case 5:
break;
case 6:
RG_PANIC("Crash test!");
break;
}
Expand Down
7 changes: 4 additions & 3 deletions components/retro-go/rg_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ struct rg_gui_option_s
rg_gui_callback_t update_cb;
};

#define RG_DIALOG_FLAG_DISABLED 0 // (1 << 0)
#define RG_DIALOG_FLAG_NORMAL 1 // (1 << 1)
#define RG_DIALOG_FLAG_SKIP -1 // (1 << 2)
#define RG_DIALOG_FLAG_DISABLED (0) // (1 << 0)
#define RG_DIALOG_FLAG_NORMAL (1) // (1 << 1)
#define RG_DIALOG_FLAG_SKIP (-1) // (1 << 2)

#define RG_DIALOG_CHOICE_LAST {0, NULL, NULL, 0, NULL}
#define RG_DIALOG_SEPARATOR {0, "----------", NULL, RG_DIALOG_FLAG_SKIP, NULL}
#define RG_DIALOG_END RG_DIALOG_CHOICE_LAST

#define RG_DIALOG_CANCELLED -0x7654321

Expand Down
Loading

0 comments on commit 6c439f6

Please sign in to comment.