Skip to content

Commit d375617

Browse files
committed
Added option to select startup app (Launcher or last used emu)
1 parent bdf2ceb commit d375617

File tree

5 files changed

+57
-25
lines changed

5 files changed

+57
-25
lines changed

components/odroid/odroid_overlay.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "math.h"
1111

1212
static uint16_t *overlay_buffer = NULL;
13-
static const char *NVS_KEY_FONTSIZE = "FontSize";
1413

1514
short ODROID_FONT_WIDTH = 8;
1615
short ODROID_FONT_HEIGHT = 8;
@@ -33,17 +32,15 @@ void odroid_overlay_init()
3332
if (!overlay_buffer) {
3433
overlay_buffer = (uint16_t *)rg_alloc(ODROID_SCREEN_WIDTH * 16 * 2, MEM_SLOW);
3534
}
36-
odroid_overlay_set_font_size(odroid_settings_int32_get(NVS_KEY_FONTSIZE, 1));
35+
odroid_overlay_set_font_size(odroid_settings_FontSize_get());
3736
}
3837

3938
void odroid_overlay_set_font_size(int factor)
4039
{
4140
factor = factor < 1 ? 1 : factor;
4241
factor = factor > 3 ? 3 : factor;
4342
ODROID_FONT_HEIGHT = 8 * factor;
44-
if (factor != odroid_settings_int32_get(NVS_KEY_FONTSIZE, 0)) {
45-
odroid_settings_int32_set(NVS_KEY_FONTSIZE, factor);
46-
}
43+
odroid_settings_FontSize_set(factor);
4744
}
4845

4946
void odroid_overlay_draw_text(uint16_t x_pos, uint16_t y_pos, uint16_t width, char *text, uint16_t color, uint16_t color_bg)

components/odroid/odroid_settings.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ static const char* NvsKey_VRef = "VRef";
1111
static const char* NvsKey_DataSlot = "DataSlot";
1212
static const char* NvsKey_Backlight = "Backlight";
1313
static const char* NvsKey_StartAction = "StartAction";
14+
static const char* NvsKey_StartupApp = "StartupApp";
1415
static const char* NvsKey_Scaling = "Scaling";
1516
static const char* NvsKey_AudioSink = "AudioSink";
1617
static const char* NvsKey_Palette = "Palette";
1718
static const char* NvsKey_Region = "Region";
1819
static const char* NvsKey_DispFilter = "DispFilter";
20+
static const char* NvsKey_FontSize = "FontSize";
1921

2022
static nvs_handle my_handle;
2123

@@ -112,23 +114,23 @@ void odroid_settings_app_int32_set(const char *key, int32_t value)
112114
}
113115

114116

115-
char* odroid_settings_RomFilePath_get()
117+
int32_t odroid_settings_FontSize_get()
116118
{
117-
return odroid_settings_string_get(NvsKey_RomFilePath, NULL);
119+
return odroid_settings_int32_get(NvsKey_FontSize, 1);
118120
}
119-
void odroid_settings_RomFilePath_set(char* value)
121+
void odroid_settings_FontSize_set(int32_t value)
120122
{
121-
odroid_settings_string_set(NvsKey_RomFilePath, value);
123+
odroid_settings_int32_set(NvsKey_FontSize, value);
122124
}
123125

124126

125-
int32_t odroid_settings_VRef_get()
127+
char* odroid_settings_RomFilePath_get()
126128
{
127-
return odroid_settings_int32_get(NvsKey_VRef, 1100);
129+
return odroid_settings_string_get(NvsKey_RomFilePath, NULL);
128130
}
129-
void odroid_settings_VRef_set(int32_t value)
131+
void odroid_settings_RomFilePath_set(char* value)
130132
{
131-
odroid_settings_int32_set(NvsKey_VRef, value);
133+
odroid_settings_string_set(NvsKey_RomFilePath, value);
132134
}
133135

134136

@@ -172,6 +174,15 @@ void odroid_settings_StartAction_set(ODROID_START_ACTION value)
172174
}
173175

174176

177+
int32_t odroid_settings_StartupApp_get()
178+
{
179+
return odroid_settings_int32_get(NvsKey_StartupApp, 1);
180+
}
181+
void odroid_settings_StartupApp_set(int32_t value)
182+
{
183+
odroid_settings_int32_set(NvsKey_StartupApp, value);
184+
}
185+
175186

176187
int32_t odroid_settings_DataSlot_get()
177188
{

components/odroid/odroid_settings.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
typedef enum
66
{
77
ODROID_START_ACTION_RESUME = 0,
8-
ODROID_START_ACTION_RESTART,
8+
ODROID_START_ACTION_NEWGAME,
99
ODROID_START_ACTION_NETPLAY
1010
} ODROID_START_ACTION;
1111

@@ -24,8 +24,8 @@ typedef enum
2424

2525
void odroid_settings_init();
2626

27-
int32_t odroid_settings_VRef_get();
28-
void odroid_settings_VRef_set(int32_t value);
27+
int32_t odroid_settings_FontSize_get();
28+
void odroid_settings_FontSize_set(int32_t);
2929

3030
int32_t odroid_settings_Volume_get();
3131
void odroid_settings_Volume_set(int32_t value);
@@ -39,6 +39,9 @@ void odroid_settings_DataSlot_set(int32_t value);
3939
int32_t odroid_settings_Backlight_get();
4040
void odroid_settings_Backlight_set(int32_t value);
4141

42+
int32_t odroid_settings_StartupApp_get();
43+
void odroid_settings_StartupApp_set(int32_t value);
44+
4245
ODROID_START_ACTION odroid_settings_StartAction_get();
4346
void odroid_settings_StartAction_set(ODROID_START_ACTION value);
4447

@@ -57,6 +60,8 @@ void odroid_settings_DisplayScaling_set(int32_t value);
5760
int32_t odroid_settings_DisplayFilter_get();
5861
void odroid_settings_DisplayFilter_set(int32_t value);
5962

63+
/*** Generic functions ***/
64+
6065
void odroid_settings_string_set(const char *key, char *value);
6166
char* odroid_settings_string_get(const char *key, char *default_value);
6267

components/odroid/odroid_system.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,6 @@ void odroid_system_init(int appId, int sampleRate)
9292
odroid_system_halt();
9393
}
9494

95-
startAction = odroid_settings_StartAction_get();
96-
if (startAction == ODROID_START_ACTION_RESTART)
97-
{
98-
odroid_settings_StartAction_set(ODROID_START_ACTION_RESUME);
99-
}
100-
10195
xTaskCreate(&odroid_system_monitor_task, "sysmon", 2048, NULL, 7, NULL);
10296

10397
// esp_task_wdt_init(5, true);
@@ -121,6 +115,18 @@ void odroid_system_emu_init(state_handler_t load, state_handler_t save, netplay_
121115
odroid_netplay_pre_init(netplay_cb);
122116
}
123117

118+
if (odroid_settings_StartupApp_get() == 0)
119+
{
120+
// Only boot this emu once, next time will return to launcher
121+
odroid_system_set_boot_app(0);
122+
}
123+
124+
startAction = odroid_settings_StartAction_get();
125+
if (startAction == ODROID_START_ACTION_NEWGAME)
126+
{
127+
odroid_settings_StartAction_set(ODROID_START_ACTION_RESUME);
128+
}
129+
124130
romPath = odroid_settings_RomFilePath_get();
125131
if (!romPath || strlen(romPath) < 4)
126132
{
@@ -333,7 +339,7 @@ void odroid_system_set_boot_app(int slot)
333339
// Do not overwrite the boot sector for nothing
334340
const esp_partition_t* boot_partition = esp_ota_get_boot_partition();
335341

336-
if (partition != NULL && partition != boot_partition)
342+
if (partition != NULL) // && partition != boot_partition
337343
{
338344
esp_err_t err = esp_ota_set_boot_partition(partition);
339345
if (err != ESP_OK)

retro-go/main/main.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static void redraw_screen()
2626

2727
static bool font_size_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event)
2828
{
29-
int font_size = odroid_settings_int32_get("FontSize", 1);
29+
int font_size = odroid_settings_FontSize_get();
3030
if (event == ODROID_DIALOG_PREV) {
3131
if (--font_size < 1) font_size = 2;
3232
odroid_overlay_set_font_size(font_size);
@@ -51,6 +51,17 @@ static bool hide_empty_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t
5151
return event == ODROID_DIALOG_ENTER;
5252
}
5353

54+
static bool startup_app_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event)
55+
{
56+
int startup_app = odroid_settings_StartupApp_get();
57+
if (event == ODROID_DIALOG_PREV || event == ODROID_DIALOG_NEXT) {
58+
startup_app = startup_app ? 0 : 1;
59+
odroid_settings_StartupApp_set(startup_app);
60+
}
61+
strcpy(option->value, startup_app == 0 ? "Launcher" : "LastUsed");
62+
return event == ODROID_DIALOG_ENTER;
63+
}
64+
5465
static bool show_cover_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event)
5566
{
5667
if (event == ODROID_DIALOG_PREV) {
@@ -199,7 +210,7 @@ void retro_loop()
199210
break;
200211
}
201212
else if (sel == 1) {
202-
odroid_settings_StartAction_set(ODROID_START_ACTION_RESTART);
213+
odroid_settings_StartAction_set(ODROID_START_ACTION_NEWGAME);
203214
break;
204215
}
205216
else if (sel == 2) {
@@ -251,6 +262,8 @@ void retro_loop()
251262
{0, "Font size", "Small", 1, &font_size_cb},
252263
{0, "Show cover", "Yes", 1, &show_cover_cb},
253264
{0, "Show empty", "Yes", 1, &hide_empty_cb},
265+
{0, "---", "", -1, NULL},
266+
{0, "Startup app", "Last", 1, &startup_app_cb},
254267
ODROID_DIALOG_CHOICE_LAST
255268
};
256269
odroid_overlay_settings_menu(choices);

0 commit comments

Comments
 (0)