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 8, 2022
2 parents 24a980e + dd45668 commit cb4ce3f
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 67 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Retro-Go 1.36.2 (2022-12-07)
- SNES: Fixed crash in controls menu
- Launcher: Start wifi access point


# Retro-Go 1.36.1 (2022-11-29)
- Fixed MRGC/esplay builds


# Retro-Go 1.36 (2022-11-28)
- GBC: Fixed Pokemon Trading Card Game
- SNES: Added support for ROMs with extra headers
Expand Down
38 changes: 16 additions & 22 deletions components/retro-go/rg_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ int rg_gui_dialog(const char *title, const rg_gui_option_t *options_const, int s
}

rg_task_delay(20);
rg_system_tick(0);
}

rg_input_wait_for_key(joystick, false);
Expand Down Expand Up @@ -1051,7 +1052,7 @@ static rg_gui_event_t theme_cb(rg_gui_option_t *option, rg_gui_event_t event)
return RG_DIALOG_VOID;
}

int rg_gui_options_menu(void)
void rg_gui_options_menu(void)
{
rg_gui_option_t options[24];
rg_gui_option_t *opt = &options[0];
Expand Down Expand Up @@ -1085,16 +1086,14 @@ int rg_gui_options_menu(void)

rg_audio_set_mute(true);

int sel = rg_gui_dialog("Options", options, 0);
rg_gui_dialog("Options", options, 0);

rg_settings_commit();
rg_system_save_time();
rg_audio_set_mute(false);

return sel;
}

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

Expand Down Expand Up @@ -1164,11 +1163,9 @@ int rg_gui_about_menu(const rg_gui_option_t *extra_options)
rg_gui_debug_menu(NULL);
break;
}

return sel;
}

int rg_gui_debug_menu(const rg_gui_option_t *extra_options)
void rg_gui_debug_menu(const rg_gui_option_t *extra_options)
{
char screen_res[20], source_res[20], scaled_res[20];
char stack_hwm[20], heap_free[20], block_free[20];
Expand Down Expand Up @@ -1206,22 +1203,18 @@ int rg_gui_debug_menu(const rg_gui_option_t *extra_options)
snprintf(block_free, 20, "%d+%d", stats.freeBlockInt, stats.freeBlockExt);
snprintf(uptime, 20, "%ds", (int)(rg_system_timer() / 1000000));

int sel = rg_gui_dialog("Debugging", options, 0);

if (sel == 1000)
switch (rg_gui_dialog("Debugging", options, 0))
{
case 1000:
rg_emu_screenshot(RG_STORAGE_ROOT "/screenshot.png", 0, 0);
}
else if (sel == 2000)
{
break;
case 2000:
rg_system_save_trace(RG_STORAGE_ROOT "/trace.txt", 0);
}
else if (sel == 4000)
{
break;
case 4000:
RG_PANIC("Crash test!");
break;
}

return sel;
}

static rg_emu_state_t *savestate;
Expand Down Expand Up @@ -1282,10 +1275,13 @@ int rg_gui_savestate_menu(const char *title, const char *rom_path, bool quick_re

free(savestate);

if (sel == RG_DIALOG_CANCELLED)
return -1;

return sel;
}

int rg_gui_game_menu(void)
void rg_gui_game_menu(void)
{
const rg_gui_option_t choices[] = {
{1000, "Save & Continue", NULL, 1, NULL},
Expand Down Expand Up @@ -1338,6 +1334,4 @@ int rg_gui_game_menu(void)
}

rg_audio_set_mute(false);

return sel;
}
10 changes: 6 additions & 4 deletions components/retro-go/rg_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ struct rg_gui_option_s
#define RG_DIALOG_CHOICE_LAST {0, NULL, NULL, 0, NULL}
#define RG_DIALOG_SEPARATOR {0, "----------", NULL, RG_DIALOG_FLAG_SKIP, NULL}

#define RG_DIALOG_CANCELLED -0x7654321

#define TEXT_RECT(text, max) rg_gui_draw_text(-(max), 0, 0, (text), 0, 0, RG_TEXT_MULTILINE|RG_TEXT_DUMMY_DRAW)

void rg_gui_init(void);
Expand Down Expand Up @@ -98,10 +100,10 @@ void rg_gui_alert(const char *title, const char *message);
char *rg_gui_file_picker(const char *title, const char *path, bool (*validator)(const char *path));

int rg_gui_savestate_menu(const char *title, const char *rom_path, bool quick_return);
int rg_gui_options_menu(void);
int rg_gui_game_menu(void);
int rg_gui_about_menu(const rg_gui_option_t *extra_options);
int rg_gui_debug_menu(const rg_gui_option_t *extra_options);
void rg_gui_options_menu(void);
void rg_gui_game_menu(void);
void rg_gui_about_menu(const rg_gui_option_t *extra_options);
void rg_gui_debug_menu(const rg_gui_option_t *extra_options);

// Creates a 565LE color from C_RGB(255, 255, 255)
#define C_RGB(r, g, b) ((((r) >> 3) << 11) | (((g) >> 2) << 5) | (((b) & 0x1F)))
Expand Down
14 changes: 4 additions & 10 deletions components/retro-go/rg_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#endif

static bool input_task_running = false;
static int64_t last_gamepad_read = 0;
static uint32_t gamepad_state = -1; // _Atomic
static int battery_level = -1;
#if defined(RG_BATTERY_ADC_CHANNEL)
Expand Down Expand Up @@ -327,16 +326,8 @@ void rg_input_deinit(void)
RG_LOGI("Input terminated.\n");
}

long rg_input_gamepad_last_read(void)
{
if (!last_gamepad_read)
return 0;
return rg_system_timer() - last_gamepad_read;
}

uint32_t rg_input_read_gamepad(void)
{
last_gamepad_read = rg_system_timer();
#ifdef RG_TARGET_SDL2
SDL_PumpEvents();
#endif
Expand All @@ -351,7 +342,10 @@ bool rg_input_key_is_pressed(rg_key_t key)
void rg_input_wait_for_key(rg_key_t key, bool pressed)
{
while (rg_input_key_is_pressed(key) != pressed)
rg_task_delay(1);
{
rg_task_delay(10);
rg_system_tick(0);
}
}

bool rg_input_read_battery(float *percent, float *volts)
Expand Down
1 change: 0 additions & 1 deletion components/retro-go/rg_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ typedef enum

void rg_input_init(void);
void rg_input_deinit(void);
long rg_input_gamepad_last_read(void);
bool rg_input_key_is_pressed(rg_key_t key);
void rg_input_wait_for_key(rg_key_t key, bool pressed);
uint32_t rg_input_read_gamepad(void);
Expand Down
1 change: 1 addition & 0 deletions components/retro-go/rg_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ bool rg_network_wifi_start(void)
{
memcpy(config.ap.ssid, wifi_config.ssid, 32);
memcpy(config.ap.password, wifi_config.password, 64);
config.ap.authmode = wifi_config.password[0] ? WIFI_AUTH_WPA2_PSK : WIFI_AUTH_OPEN;
config.ap.channel = wifi_config.channel;
config.ap.max_connection = 1;
TRY(esp_wifi_set_mode(WIFI_MODE_AP));
Expand Down
1 change: 1 addition & 0 deletions components/retro-go/rg_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ static int scandir_natural_sort(const void *a, const void *b)
return 0;
}

// FIXME: rg_scandir_t should probably be {count, items[]} to avoid walking the array to get the count...
rg_scandir_t *rg_storage_scandir(const char *path, bool (*validator)(const char *path), uint32_t flags)
{
DIR *dir = opendir(path);
Expand Down
3 changes: 2 additions & 1 deletion components/retro-go/rg_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static void system_monitor_task(void *arg)

if ((wdtCounter -= loopTime_us) <= 0)
{
if (rg_input_gamepad_last_read() > WDT_TIMEOUT)
if ((lastLoop - statistics.lastTick) > WDT_TIMEOUT)
{
#ifdef RG_ENABLE_PROFILING
RG_LOGW("Application unresponsive!\n");
Expand Down Expand Up @@ -544,6 +544,7 @@ rg_stats_t rg_system_get_counters(void)

IRAM_ATTR void rg_system_tick(int busyTime)
{
statistics.lastTick = rg_system_timer();
statistics.busyTime += busyTime;
statistics.ticks++;
// WDT_RELOAD(WDT_TIMEOUT);
Expand Down
1 change: 1 addition & 0 deletions components/retro-go/rg_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ typedef struct
float totalFPS;
float busyPercent;
int64_t busyTime;
int64_t lastTick;
int ticks;
int totalMemoryInt;
int totalMemoryExt;
Expand Down
2 changes: 1 addition & 1 deletion components/retro-go/targets/esplay-s3/env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os

os.environ["IDF_TARGET"] = "esp32"
os.environ["IDF_TARGET"] = "esp32s3"
os.environ["FW_FORMAT"] = "esplay"
2 changes: 1 addition & 1 deletion launcher/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(COMPONENT_SRCDIRS ". libs")
set(COMPONENT_ADD_INCLUDEDIRS ". libs")
register_component()
rg_setup_compile_options(-O2)
rg_setup_compile_options(-O2 -mfix-esp32-psram-cache-issue)
27 changes: 15 additions & 12 deletions launcher/main/applications.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,27 @@ static void scan_folder(retro_app_t *app, const char* path, void *parent)
if (!is_valid)
continue;

app->files[app->files_count++] = (retro_file_t) {
.name = strdup(entry->name),
.folder = folder,
.app = (void*)app,
.type = type,
.is_valid = true,
};

if ((app->files_count % 10) == 0)
if (app->files_count + 1 > app->files_capacity)
{
size_t new_size = (app->files_count + 10 + 2) * sizeof(retro_file_t);
retro_file_t *new_buf = realloc(app->files, new_size);
size_t new_capacity = app->files_capacity * 1.5;
retro_file_t *new_buf = realloc(app->files, new_capacity * sizeof(retro_file_t));
if (!new_buf)
{
RG_LOGW("Ran out of memory, file scanning stopped at %d entries ...\n", app->files_count);
break;
}
app->files = new_buf;
app->files_capacity = new_capacity;
}

app->files[app->files_count++] = (retro_file_t) {
.name = strdup(entry->name),
.folder = folder,
.app = (void*)app,
.type = type,
.is_valid = true,
};

if (type == 0xFF)
{
retro_file_t *file = &app->files[app->files_count-1];
Expand Down Expand Up @@ -291,6 +292,7 @@ void crc_cache_idle_task(tab_t *tab)

gui_set_status(tab, "", "");
gui_redraw(); // gui_draw_status(tab);
rg_system_tick(0);
}
}

Expand Down Expand Up @@ -667,7 +669,8 @@ static void application(const char *desc, const char *name, const char *exts, co
snprintf(app->paths.saves, RG_PATH_MAX, RG_BASE_PATH_SAVES "/%s", app->short_name);
snprintf(app->paths.roms, RG_PATH_MAX, RG_BASE_PATH_ROMS "/%s", app->short_name);
app->available = rg_system_have_app(app->partition);
app->files = calloc(10, sizeof(retro_file_t));
app->files = calloc(100, sizeof(retro_file_t));
app->files_capacity = 100;
app->crc_offset = crc_offset;

gui_add_tab(app->short_name, app->description, app, event_handler);
Expand Down
1 change: 1 addition & 0 deletions launcher/main/applications.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef struct retro_app_s
} paths;
size_t crc_offset;
retro_file_t *files;
size_t files_capacity;
size_t files_count;
bool use_crc_covers;
bool crc_scan_done;
Expand Down
Loading

0 comments on commit cb4ce3f

Please sign in to comment.