-
Notifications
You must be signed in to change notification settings - Fork 0
feat(zaparoo): OSD menu entry to toggle CRT/HDMI launcher mode #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
0cea191
6d2690b
390c141
4220a82
7d0f6a4
4afaa67
99f9829
155254e
9c831d0
54001f1
00b7251
6dc8bb8
b9e3bea
27019d8
08ccd5d
c7804d2
892777c
72037bc
09a7467
54fbded
af81c62
02552bc
7d6b40a
3eeb116
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,20 @@ static const int s_vt = 2; | |
| static const char s_tty[] = "tty2"; | ||
| static const char s_tty_path[] = "/dev/tty2"; | ||
| static const char s_fb_mode_path[] = "/sys/module/MiSTer_fb/parameters/mode"; | ||
| static const char s_crt_state_file[] = "alt_launcher_crt.bin"; | ||
|
|
||
| static bool load_persisted_native_crt(void) | ||
| { | ||
| uint8_t v = 0; | ||
| FileLoadConfig(s_crt_state_file, &v, sizeof(v)); | ||
| return v != 0; | ||
| } | ||
|
|
||
| static void save_persisted_native_crt(bool crt) | ||
| { | ||
| uint8_t v = crt ? 1 : 0; | ||
| FileSaveConfig(s_crt_state_file, &v, sizeof(v)); | ||
| } | ||
|
|
||
| static void set_launcher_fb_mode(int fmt, int rb, int width, int height, int stride, bool log = true) | ||
| { | ||
|
|
@@ -269,6 +283,27 @@ bool alt_launcher_active(void) | |
| return s_pid != 0; | ||
| } | ||
|
|
||
| bool alt_launcher_native_crt(void) | ||
| { | ||
| return s_native_crt && s_pid != 0; | ||
| } | ||
|
|
||
| void alt_launcher_toggle_crt(void) | ||
| { | ||
| bool current_crt = alt_launcher_native_crt(); | ||
| bool target_crt = !current_crt; | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| save_persisted_native_crt(target_crt); | ||
|
|
||
| printf("alt_launcher: toggle CRT path %d -> %d\n", current_crt, target_crt); | ||
|
|
||
| // Shutdown drops status[9], releases the FB mode and restores HPS framebuffer | ||
| // state regardless of whether the launcher was running. After it returns we | ||
| // always have a clean slate to spawn the next launcher invocation. | ||
| alt_launcher_shutdown(); | ||
| alt_launcher_init(target_crt); | ||
| } | ||
|
Comment on lines
+404
to
+409
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid blocking cooperative scheduling during CRT toggle. This path synchronously calls As per coding guidelines, "Long-running support code in cooperative scheduler context must call 🤖 Prompt for AI Agents |
||
|
|
||
| void alt_launcher_init(bool native_crt) | ||
| { | ||
| if (!cfg.alt_launcher[0] || !cfg.fb_terminal || s_pid || s_gave_up) | ||
|
|
@@ -410,3 +445,10 @@ void zaparoo_alt_launcher_init_for_core(void) | |
| alt_launcher_init(true); | ||
| } | ||
| } | ||
|
|
||
| void zaparoo_alt_launcher_init_for_menu(void) | ||
| { | ||
| bool crt = load_persisted_native_crt(); | ||
| printf("alt_launcher: initializing menu launcher (persisted crt=%d)\n", crt); | ||
| alt_launcher_init(crt); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #include "menu_rbf.h" | ||
| #include <string.h> | ||
| #include <strings.h> | ||
| #include "../../cfg.h" | ||
|
|
||
| const char *menu_rbf_name(void) | ||
| { | ||
| return cfg.menu_rbf[0] ? cfg.menu_rbf : "menu.rbf"; | ||
| } | ||
|
|
||
| bool is_menu_rbf(const char *name) | ||
| { | ||
| if (!name || !name[0]) return false; | ||
| if (!strcasecmp(name, "menu.rbf")) return true; | ||
| if (cfg.menu_rbf[0]) | ||
| { | ||
| if (!strcasecmp(name, cfg.menu_rbf)) return true; | ||
| const char *slash = strrchr(cfg.menu_rbf, '/'); | ||
| const char *base = slash ? slash + 1 : cfg.menu_rbf; | ||
| if (base[0] && !strcasecmp(name, base)) return true; | ||
| } | ||
| return false; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #pragma once | ||
|
|
||
| const char *menu_rbf_name(void); | ||
| bool is_menu_rbf(const char *name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bound path writes in
fpga_load_rbf.Line 445 writes into a fixed 1024-byte buffer with
sprintf; a longnamecan overflowpathand corrupt stack state. Please switch to bounded writes and reject truncation.💡 Suggested fix
🤖 Prompt for AI Agents