Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
2954abe
Feat: Alpha channel for theme colors and better pill sprite handling …
frysee Jul 3, 2026
efaf2fb
build: link the core stuff through g++ so we can start adding C++
carroarmato0 Jul 1, 2026
de70401
refactor(nextui): move nextui to C++ and swap the hash for std::unord…
carroarmato0 Jul 1, 2026
6ed5f63
build: auto-pick the best C++ std the toolchain supports
carroarmato0 Jul 1, 2026
89b68f6
poc(nextui): disable worker-thread subsystems so the C++ build runs
carroarmato0 Jul 1, 2026
8a6dd00
nextui: swap IntArray for std::vector<int>
carroarmato0 Jul 1, 2026
477d08c
nextui: back Array with std::vector<void*>
carroarmato0 Jul 1, 2026
ec398cc
nextui: drop leaked strdup in Hash_set callers
carroarmato0 Jul 1, 2026
a0be0f6
nextui: bound the string writes with a fixed-array target
carroarmato0 Jul 1, 2026
d014ff8
nextui: bound the remaining pointer and cursor string writes
carroarmato0 Jul 1, 2026
31bec8e
nextui: type recents as std::vector<Recent*>
carroarmato0 Jul 1, 2026
7bd046c
nextui: type the directory stack as std::vector<Directory*>
carroarmato0 Jul 1, 2026
a4891e0
nextui: type the string lists as std::vector<char*>
carroarmato0 Jul 1, 2026
8ea874f
nextui: type entries/quick as std::vector<Entry*>, retire the Array
carroarmato0 Jul 1, 2026
0452b21
core: add misuse-proof bounded string helpers, adopt in nextui
carroarmato0 Jul 1, 2026
571fe97
minarch: bound the string writes in ma_game.c
carroarmato0 Jul 1, 2026
f0654ac
minarch: bound the string writes in ma_config.c
carroarmato0 Jul 1, 2026
9d11e31
minarch: bound the string writes across the remaining ma_*.c
carroarmato0 Jul 1, 2026
e60b0e3
tg5040: model Brick vs Smart Pro as data (Device HAL, step 1)
carroarmato0 Jul 1, 2026
64014cb
tg5040: move the diverging hardware paths into the descriptor
carroarmato0 Jul 1, 2026
da987fe
api: fold the shader-state extern soup into one struct (Phase D)
carroarmato0 Jul 1, 2026
c8a9426
nextui: move the selection-pill animation to the main thread
carroarmato0 Jul 1, 2026
75280be
nextui: make the no-animation pill move instant again
carroarmato0 Jul 1, 2026
194d479
nextui: bring folder backgrounds back on a thread-safe queue
carroarmato0 Jul 1, 2026
b221333
nextui: bring box-art thumbnails back on the thread-safe queue
carroarmato0 Jul 1, 2026
a359e85
nextui: clear stale box art when the selection has no art / dir changes
carroarmato0 Jul 1, 2026
3699809
nextui: delete the disabled legacy SDL worker/queue code
carroarmato0 Jul 2, 2026
ae83b97
Merge upstream/main into cpp20-migration
carroarmato0 Jul 2, 2026
37cc7f5
nextui: fix invisible button hints (g++ compound-literal miscompile)
carroarmato0 Jul 2, 2026
dd7c3e4
api: stop leaking lid and ALT_BUTTON_TEXT_COLOR through the facade
carroarmato0 Jul 2, 2026
9b06964
api: encapsulate the font god-object behind GFX_getFonts()
carroarmato0 Jul 2, 2026
6c928b2
api: encapsulate the pad god-object behind PAD_getContext()
carroarmato0 Jul 2, 2026
6f20913
minarch: group rewind config into a RewindConfig struct
carroarmato0 Jul 2, 2026
cb5cc46
minarch: group fast-forward flags into a FastForward struct
carroarmato0 Jul 2, 2026
17284ab
minarch: group rewind runtime flags into a RewindState struct
carroarmato0 Jul 2, 2026
774bc44
minarch: group display settings into a DisplayConfig struct
carroarmato0 Jul 2, 2026
4eba158
Merge upstream/main: alpha colour support + game-switcher curtain
carroarmato0 Jul 5, 2026
7ec4a0c
chore: gitignore local tooling dirs (.headroom, graphify-out)
carroarmato0 Jul 5, 2026
158c935
fix: refresh a2600 core patches for tg5040/tg5050
Copilot Jul 5, 2026
b70643b
chore: remove unmaintained platforms
frysee Jul 5, 2026
f5dc2da
nextui: fix name leak in Entry_newNamed (double-alloc)
carroarmato0 Jul 5, 2026
6d71d5a
tg5040: hoist DeviceDescriptor into shared common/device.h
carroarmato0 Jul 5, 2026
99d76f9
device: add GPU freq/usage descriptor fields; tg5040 reads gpu_speed_…
carroarmato0 Jul 5, 2026
2098f94
build: track header deps via -MMD -MP so common/*.h edits force rebuilds
carroarmato0 Jul 5, 2026
a90521b
tg5050: migrate Smart Pro S onto shared DeviceDescriptor
carroarmato0 Jul 5, 2026
7df9a5a
platform: converge CPU/GPU freq+temp reads onto descriptor paths
carroarmato0 Jul 5, 2026
d3b4ecf
platform: extract 28 shared PLAT_ funcs into common/generic_platform.c
carroarmato0 Jul 5, 2026
bfcadaf
common/core: add RAII SurfacePtr wrapper for SDL_Surface
carroarmato0 Jul 5, 2026
c631698
settings: adopt SurfacePtr, fix 6 SDL_Surface leaks
carroarmato0 Jul 5, 2026
9944daf
nextui: adopt SurfacePtr for scratch surfaces, fix 3 SDL_Surface leaks
carroarmato0 Jul 5, 2026
15c98ed
minarch: convert ma_audio to C++ (Phase E pilot)
carroarmato0 Jul 5, 2026
a2075b8
minarch: convert ma_input/ma_runframe/ma_cheats/ma_core to C++
carroarmato0 Jul 5, 2026
5229dd0
minarch: convert ma_environment/ma_game/ma_saves/ma_rewind/ma_options…
carroarmato0 Jul 5, 2026
6ad01fc
minarch: convert ma_video and ma_menu to C++
carroarmato0 Jul 6, 2026
4b2838a
minarch: convert ma_frontend_opts to C++
carroarmato0 Jul 6, 2026
e844231
minarch: convert ma_config to C++
carroarmato0 Jul 6, 2026
4091f1f
minarch: convert minarch.c to C++ (final minarch TU)
carroarmato0 Jul 6, 2026
88bb635
minarch: don't let a throwing core abort the emulator on cheat apply
carroarmato0 Jul 6, 2026
0a64688
tg5040: add TrimUI Brick Pro support (Brick screen + Smart Pro sticks)
carroarmato0 Jul 6, 2026
771b7bc
Merge upstream/main: Brick Pro, color parsing, button hint styles
carroarmato0 Jul 11, 2026
f46b514
minarch: fix goto crossing state_file init in ma_saves (desktop build)
carroarmato0 Jul 11, 2026
5431250
Merge upstream v6.13.2: L4/R4 mappings, minput stick viz, display cal…
carroarmato0 Jul 13, 2026
f367e19
Merge remote-tracking branch 'upstream/main' into cpp20-migration
carroarmato0 Jul 17, 2026
8f873ec
fix: tg5050 SUPA crash on game launch + load exception guard
carroarmato0 Jul 18, 2026
d9d9a4c
Merge upstream/main: color palettes, FN button actions, USB awake, RA…
carroarmato0 Jul 20, 2026
0bd45d9
fix: post-merge C++20 corrections after upstream sync
carroarmato0 Jul 20, 2026
b96a58c
refactor: convert palette.c to C++20
carroarmato0 Jul 20, 2026
bf712dd
refactor: convert minarch chd_reader + ra_integration to C++20
carroarmato0 Jul 26, 2026
efd362f
refactor: convert batmon, gametimectl, nextval, syncsettings to C++20
carroarmato0 Jul 26, 2026
78327d3
refactor: convert bootlogo and clock to C++20
carroarmato0 Jul 26, 2026
02ceef8
refactor: convert minput, gametime, ledcontrol, battery to C++20
carroarmato0 Jul 26, 2026
36e042e
refactor: convert libbatmondb and libgametimedb to C++20
carroarmato0 Jul 26, 2026
1d2719b
refactor: convert common/ ra_offline, ra_sync, ra_event_queue to C++20
carroarmato0 Jul 26, 2026
b75052f
refactor: convert common/ ra_badges, notification, ra_auth, http to C…
carroarmato0 Jul 26, 2026
0a81324
refactor: convert common/ utils, config, scaler to C++20
carroarmato0 Jul 26, 2026
5802e69
refactor: convert common/ api to C++20 — shared core now fully C++
carroarmato0 Jul 26, 2026
054126a
refactor: convert common/ displaycal to C++20
carroarmato0 Jul 26, 2026
dd102ce
refactor: make platform HAL generic_* compile-clean under C++
carroarmato0 Jul 26, 2026
7d6f047
refactor: make tg5040/tg5050 platform.c compile-clean under C++
carroarmato0 Jul 26, 2026
6f77467
refactor: convert platform layer (platform.c -> platform.cpp) to C++20
carroarmato0 Jul 26, 2026
0fe6aa5
refactor: convert libmsettings (msettings.c -> msettings.cpp) to C++20
carroarmato0 Jul 26, 2026
9578caa
refactor: convert keymon/rfkill/poweroff_next daemons to C++20
carroarmato0 Jul 26, 2026
1e9bfa5
revert: keep tg5050 SUPA ppu affinity at upstream 0xc
carroarmato0 Jul 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ workspace/.container_runtime
AGENTS.md
CLAUDE.md
.worktrees/

# local tooling data (headroom memory, graphify output)
.headroom/
graphify-out/
18 changes: 11 additions & 7 deletions workspace/all/batmon/batmon.c → workspace/all/batmon/batmon.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
// heavily modified from the Onion original: https://github.com/OnionUI/Onion/tree/main/src/batmon
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>

#include <sqlite3.h>

// Project + libbatmondb C headers declare C-linkage symbols defined in the
// still-C common/ and libbatmondb translation units; include them as extern "C"
// so this C++ unit links against the unmangled names.
extern "C" {
#include <defines.h>
#include <api.h>

#include <sqlite3.h>
#include <batmondb.h>
}

#define CHECK_BATTERY_TIMEOUT_S 15 // s - check battery percentage every 15s

Expand All @@ -24,7 +28,7 @@ static bool is_suspended = false;

int battery_current_state_duration = 0;
int best_session_time = 0;
char *device_model = NULL;
char *device_model = nullptr;

void register_handler();
void sigintHandler(int signum) {
Expand Down
17 changes: 14 additions & 3 deletions workspace/all/batmon/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,29 @@ SDL?=SDL

TARGET = batmon
INCDIR = -I. -I../common/ -I../../$(PLATFORM)/platform/
SOURCE = $(TARGET).c ../common/utils.c ../common/api.c ../common/config.c ../common/scaler.c ../../$(PLATFORM)/platform/platform.c
# Shared common/ + platform stay C; the tool itself is C++20. Compile the C
# units to objects, then compile the .cpp and link everything through g++.
SOURCE = -c ../../$(PLATFORM)/platform/platform.cpp
CXXSOURCE = $(TARGET).cpp ../common/utils.cpp ../common/config.cpp ../common/scaler.cpp ../common/api.cpp
CXXSOURCE += build/$(PLATFORM)/platform.o

CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
# Prefer real C++20; fall back to gnu++2a on older toolchains (e.g. the current
# gcc 8.3 tg5040 cross-compiler, which predates the -std=gnu++20 spelling).
CXXSTD := $(shell printf 'int main(){return 0;}' | $(CXX) -std=gnu++20 -x c++ - -o /dev/null >/dev/null 2>&1 && echo gnu++20 || echo gnu++2a)
CFLAGS += $(OPT)
CFLAGS += $(INCDIR) -DPLATFORM=\"$(PLATFORM)\" -std=gnu99
CFLAGS += $(INCDIR) -DPLATFORM=\"$(PLATFORM)\"
CXXFLAGS += $(CFLAGS) -std=$(CXXSTD)
LDFLAGS += -lmsettings -lbatmondb -lsqlite3

PRODUCT= build/$(PLATFORM)/$(TARGET).elf

all: $(PREFIX_LOCAL)/include/msettings.h $(PREFIX_LOCAL)/include/batmondb.h
mkdir -p build/$(PLATFORM)
$(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS)
$(CXX) $(SOURCE) $(CXXFLAGS) $(LDFLAGS)
mv platform.o build/$(PLATFORM)
$(CXX) $(CXXSOURCE) -o $(PRODUCT) $(CXXFLAGS) $(LDFLAGS) -lstdc++
clean:
rm -f $(PRODUCT)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// heavily modified from the Onion original: https://github.com/OnionUI/Onion/tree/main/src/batteryMonitorUI
#include <stdio.h>
#include <cstdio>
#include <unistd.h>
#include <stdbool.h>
#include <signal.h>
#include <msettings.h>
#include <csignal>
#include <cstdlib>

#include <sqlite3.h>

// Project + libbatmondb C headers declare C-linkage symbols defined in the
// still-C common/ and libbatmondb translation units; include as extern "C".
extern "C" {
#include <msettings.h>
#include "defines.h"
#include "api.h"
#include "utils.h"

#include <sqlite3.h>
#include <batmondb.h>
}

#define GRAPH_LINE_WIDTH 1

Expand Down Expand Up @@ -126,8 +130,8 @@ static void sigHandler(int sig)

static SDL_Surface *screen;

char *device_model = NULL;
sqlite3 *bat_log_db = NULL;
char *device_model = nullptr;
sqlite3 *bat_log_db = nullptr;

void secondsToHoursMinutes(int seconds, char *output)
{
Expand Down Expand Up @@ -196,8 +200,10 @@ int _renderText(const char *text, TTF_Font *font, SDL_Color color, SDL_Rect *rec
if (textSurface != NULL)
{
text_width = textSurface->w;
if (right_align)
SDL_BlitSurface(textSurface, NULL, screen, &(SDL_Rect){rect->x - textSurface->w, rect->y, rect->w, rect->h});
if (right_align) {
SDL_Rect r = {rect->x - textSurface->w, rect->y, rect->w, rect->h};
SDL_BlitSurface(textSurface, NULL, screen, &r);
}
else
SDL_BlitSurface(textSurface, NULL, screen, rect);
SDL_FreeSurface(textSurface);
Expand Down Expand Up @@ -395,18 +401,20 @@ void drawBatteryIcon(int percent, SDL_Rect dst) {
int x = dst.x;
int y = dst.y;
//SDL_Rect rect = asset_rects[ASSET_BATTERY];
SDL_Rect rect = (SDL_Rect){SCALE4(47,51,17,10)};
GFX_blitAsset(ASSET_BATTERY, NULL, screen, &(SDL_Rect){x,y});
SDL_Rect rect = {SCALE4(47,51,17,10)};
SDL_Rect battery_dst = {x,y};
GFX_blitAsset(ASSET_BATTERY, NULL, screen, &battery_dst);
//rect = asset_rects[ASSET_BATTERY_FILL];
rect = (SDL_Rect){SCALE4(81,33,12,6)};
rect = SDL_Rect{SCALE4(81,33,12,6)};
SDL_Rect clip = rect;
clip.w *= percent;
clip.w /= 100;
if (clip.w<=0) return;
clip.x = rect.w - clip.w;
clip.y = 0;

GFX_blitAsset(ASSET_BATTERY_FILL, &clip, screen, &(SDL_Rect){x+SCALE1(3)+clip.x,y+SCALE1(2)});

SDL_Rect fill_dst = {x+SCALE1(3)+clip.x,y+SCALE1(2)};
GFX_blitAsset(ASSET_BATTERY_FILL, &clip, screen, &fill_dst);
}

void renderPage()
Expand Down Expand Up @@ -453,29 +461,37 @@ void renderPage()
switch_zoom_profile(segment_duration);

// x axis labels
renderText(label[0], font.small, COLOR_WHITE, &(SDL_Rect){graph.layout.label1_x, graph.layout.label_y, 32, 32});
renderText(label[1], font.small, COLOR_WHITE, &(SDL_Rect){graph.layout.label2_x, graph.layout.label_y, 32, 32});
renderText(label[2], font.small, COLOR_WHITE, &(SDL_Rect){graph.layout.label3_x, graph.layout.label_y, 32, 32});
renderText(label[3], font.small, COLOR_WHITE, &(SDL_Rect){graph.layout.label4_x, graph.layout.label_y, 32, 32});
SDL_Rect lbl0 = {graph.layout.label1_x, graph.layout.label_y, 32, 32};
renderText(label[0], GFX_getFonts()->small, COLOR_WHITE, &lbl0);
SDL_Rect lbl1 = {graph.layout.label2_x, graph.layout.label_y, 32, 32};
renderText(label[1], GFX_getFonts()->small, COLOR_WHITE, &lbl1);
SDL_Rect lbl2 = {graph.layout.label3_x, graph.layout.label_y, 32, 32};
renderText(label[2], GFX_getFonts()->small, COLOR_WHITE, &lbl2);
SDL_Rect lbl3 = {graph.layout.label4_x, graph.layout.label_y, 32, 32};
renderText(label[3], GFX_getFonts()->small, COLOR_WHITE, &lbl3);

// y axis "labels"
drawBatteryIcon(100, (SDL_Rect){graph.layout.icon_x, graph.layout.icon1_y});
drawBatteryIcon(66, (SDL_Rect){graph.layout.icon_x, graph.layout.icon2_y});
drawBatteryIcon(33, (SDL_Rect){graph.layout.icon_x, graph.layout.icon3_y});
drawBatteryIcon(0, (SDL_Rect){graph.layout.icon_x, graph.layout.icon4_y});
drawBatteryIcon(100, SDL_Rect{graph.layout.icon_x, graph.layout.icon1_y});
drawBatteryIcon(66, SDL_Rect{graph.layout.icon_x, graph.layout.icon2_y});
drawBatteryIcon(33, SDL_Rect{graph.layout.icon_x, graph.layout.icon3_y});
drawBatteryIcon(0, SDL_Rect{graph.layout.icon_x, graph.layout.icon4_y});

char text_line[255];
sprintf(text_line, "Since Charge: %s", session_duration);
renderText(text_line, font.medium, COLOR_WHITE, &(SDL_Rect){graph.layout.label_session_x, graph.layout.label_session_y, graph.layout.label_size_x, graph.layout.label_size_y});
SDL_Rect session_rect = {graph.layout.label_session_x, graph.layout.label_session_y, graph.layout.label_size_x, graph.layout.label_size_y};
renderText(text_line, GFX_getFonts()->medium, COLOR_WHITE, &session_rect);

sprintf(text_line, "Current: %s", current_percentage);
renderText(text_line, font.medium, COLOR_WHITE, &(SDL_Rect){graph.layout.label_current_x, graph.layout.label_current_y, graph.layout.label_size_x, graph.layout.label_size_y});
SDL_Rect current_rect = {graph.layout.label_current_x, graph.layout.label_current_y, graph.layout.label_size_x, graph.layout.label_size_y};
renderText(text_line, GFX_getFonts()->medium, COLOR_WHITE, &current_rect);

sprintf(text_line, "Remaining: %s", session_left);
renderTextAlignRight(text_line, font.medium, COLOR_WHITE, &(SDL_Rect){graph.layout.label_left_x, graph.layout.label_left_y, graph.layout.label_size_x, graph.layout.label_size_y});
SDL_Rect left_rect = {graph.layout.label_left_x, graph.layout.label_left_y, graph.layout.label_size_x, graph.layout.label_size_y};
renderTextAlignRight(text_line, GFX_getFonts()->medium, COLOR_WHITE, &left_rect);

sprintf(text_line, "Longest: %s", session_best);
renderTextAlignRight(text_line, font.medium, COLOR_WHITE, &(SDL_Rect){graph.layout.label_best_x, graph.layout.label_best_y, graph.layout.label_size_x, graph.layout.label_size_y});
SDL_Rect best_rect = {graph.layout.label_best_x, graph.layout.label_best_y, graph.layout.label_size_x, graph.layout.label_size_y};
renderTextAlignRight(text_line, GFX_getFonts()->medium, COLOR_WHITE, &best_rect);

int half_line_width = (int)(GRAPH_LINE_WIDTH) / 2;

Expand Down Expand Up @@ -556,8 +572,10 @@ void renderPage()
}
}
SDL_UnlockSurface(screen);
if (x_end != 0)
GFX_blitAsset(ASSET_BATTERY_LOW, NULL, screen, &(SDL_Rect){x_end, y_end});
if (x_end != 0) {
SDL_Rect low_dst = {x_end, y_end};
GFX_blitAsset(ASSET_BATTERY_LOW, NULL, screen, &low_dst);
}
}
}

Expand Down Expand Up @@ -746,25 +764,33 @@ int main(int argc, char *argv[])
}

char title[256];
int text_width = GFX_truncateText(font.large, display_name, title, max_width, SCALE1(BUTTON_PADDING * 2));
int text_width = GFX_truncateText(GFX_getFonts()->large, display_name, title, max_width, SCALE1(BUTTON_PADDING * 2));
max_width = MIN(max_width, text_width);

SDL_Surface *text;
text = TTF_RenderUTF8_Blended(font.large, title, COLOR_WHITE);
text = TTF_RenderUTF8_Blended(GFX_getFonts()->large, title, COLOR_WHITE);

GFX_blitPill(ASSET_BLACK_PILL, screen, &(SDL_Rect){SCALE1(PADDING), SCALE1(PADDING), max_width, SCALE1(PILL_SIZE)});
SDL_BlitSurface(text, &(SDL_Rect){0, 0, max_width - SCALE1(BUTTON_PADDING * 2), text->h}, screen, &(SDL_Rect){SCALE1(PADDING + BUTTON_PADDING), SCALE1(PADDING + 4)});
SDL_Rect title_pill = {SCALE1(PADDING), SCALE1(PADDING), max_width, SCALE1(PILL_SIZE)};
GFX_blitPill(ASSET_BLACK_PILL, screen, &title_pill);
SDL_Rect title_src = {0, 0, max_width - SCALE1(BUTTON_PADDING * 2), text->h};
SDL_Rect title_dst = {SCALE1(PADDING + BUTTON_PADDING), SCALE1(PADDING + 4)};
SDL_BlitSurface(text, &title_src, screen, &title_dst);
SDL_FreeSurface(text);
}

renderPage();

if (show_setting)
GFX_blitHardwareHints(screen, show_setting);
else
GFX_blitButtonGroup((char *[]){"L/R", "SCROLL", "L1/R1", "ZOOM", NULL}, 0, screen, 0);
else {
// Named local array: g++ 8.3 miscompiles a (char*[]){...} compound
// literal passed straight to a function.
const char* hints_scroll[] = {"L/R", "SCROLL", "L1/R1", "ZOOM", NULL};
GFX_blitButtonGroup((char**)hints_scroll, 0, screen, 0);
}

GFX_blitButtonGroup((char *[]){"B", "BACK", NULL}, 1, screen, 1);
const char* hints_back[] = {"B", "BACK", NULL};
GFX_blitButtonGroup((char**)hints_back, 1, screen, 1);

GFX_flip(screen);
dirty = 0;
Expand Down
17 changes: 14 additions & 3 deletions workspace/all/battery/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,29 @@ SDL?=SDL

TARGET = battery
INCDIR = -I. -I../common/ -I../../$(PLATFORM)/platform/
SOURCE = $(TARGET).c ../common/utils.c ../common/api.c ../common/config.c ../common/scaler.c ../../$(PLATFORM)/platform/platform.c
# Shared common/ + platform stay C; the tool itself is C++20. Compile the C
# units to objects, then compile the .cpp and link everything through g++.
SOURCE = -c ../../$(PLATFORM)/platform/platform.cpp
CXXSOURCE = $(TARGET).cpp ../common/utils.cpp ../common/config.cpp ../common/scaler.cpp ../common/api.cpp
CXXSOURCE += build/$(PLATFORM)/platform.o

CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
# Prefer real C++20; fall back to gnu++2a on older toolchains (e.g. the current
# gcc 8.3 tg5040 cross-compiler, which predates the -std=gnu++20 spelling).
CXXSTD := $(shell printf 'int main(){return 0;}' | $(CXX) -std=gnu++20 -x c++ - -o /dev/null >/dev/null 2>&1 && echo gnu++20 || echo gnu++2a)
CFLAGS += $(OPT)
CFLAGS += $(INCDIR) -DPLATFORM=\"$(PLATFORM)\" -std=gnu99
CFLAGS += $(INCDIR) -DPLATFORM=\"$(PLATFORM)\"
CXXFLAGS += $(CFLAGS) -std=$(CXXSTD)
LDFLAGS += -lmsettings -lbatmondb -lsqlite3

PRODUCT= build/$(PLATFORM)/$(TARGET).elf

all: $(PREFIX_LOCAL)/include/batmondb.h
mkdir -p build/$(PLATFORM)
$(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS)
$(CXX) $(SOURCE) $(CXXFLAGS) $(LDFLAGS)
mv platform.o build/$(PLATFORM)
$(CXX) $(CXXSOURCE) -o $(PRODUCT) $(CXXFLAGS) $(LDFLAGS) -lstdc++
clean:
rm -f $(PRODUCT)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#include <stdio.h>
#include <cstdio>
#include <unistd.h>
#include <stdbool.h>
#include <stdlib.h>
#include <cstdlib>
#include <dirent.h>
#include <signal.h>
#include <msettings.h>

// Project + libmsettings C headers declare C-linkage symbols defined in the
// still-C common/ and libmsettings translation units; include as extern "C".
extern "C" {
#include <msettings.h>
#include "defines.h"
#include "api.h"
#include "utils.h"
}

static bool quit = false;

Expand Down Expand Up @@ -57,9 +60,9 @@ int loadImages()
SDL_Surface *bmp = IMG_Load(path);
if (bmp) {
count++;
images = realloc(images, sizeof(SDL_Surface*) * count);
images = (SDL_Surface**)realloc(images, sizeof(SDL_Surface*) * count);
images[count-1] = bmp;
image_paths = realloc(image_paths, sizeof(char*) * count);
image_paths = (char**)realloc(image_paths, sizeof(char*) * count);
image_paths[count-1] = strdup(path);
}
}
Expand Down Expand Up @@ -140,7 +143,7 @@ int main(int argc, char *argv[])
// sync
// umount $BOOT_PATH
// reboot
char* boot_path = "/mnt/boot/";
const char* boot_path = "/mnt/boot/";
char* logo_path = image_paths[selected];
char cmd[256];
snprintf(cmd, sizeof(cmd), "mkdir -p %s && mount -t vfat /dev/mmcblk0p1 %s && cp \"%s\" %s/bootlogo.bmp && sync && umount %s && reboot", boot_path, boot_path, logo_path, boot_path, boot_path);
Expand Down Expand Up @@ -179,8 +182,12 @@ int main(int argc, char *argv[])
SDL_BlitSurface(image, NULL, screen, &image_rect);
}

GFX_blitButtonGroup((char *[]){"L/R", "SCROLL", NULL}, 0, screen, 0);
GFX_blitButtonGroup((char *[]){"A", "SET", "B", "BACK", NULL}, 1, screen, 1);
// Route button hints through named local arrays: g++ 8.3 miscompiles
// a (char*[]){...} compound literal passed straight to a function.
const char* hints_scroll[] = {"L/R", "SCROLL", NULL};
GFX_blitButtonGroup((char**)hints_scroll, 0, screen, 0);
const char* hints_set[] = {"A", "SET", "B", "BACK", NULL};
GFX_blitButtonGroup((char**)hints_set, 1, screen, 1);

GFX_flip(screen);
dirty = 0;
Expand Down
17 changes: 14 additions & 3 deletions workspace/all/bootlogo/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,29 @@ SDL?=SDL

TARGET = bootlogo
INCDIR = -I. -I../common/ -I../../$(PLATFORM)/platform/
SOURCE = $(TARGET).c ../common/utils.c ../common/api.c ../common/config.c ../common/scaler.c ../../$(PLATFORM)/platform/platform.c
# Shared common/ + platform stay C; the tool itself is C++20. Compile the C
# units to objects, then compile the .cpp and link everything through g++.
SOURCE = -c ../../$(PLATFORM)/platform/platform.cpp
CXXSOURCE = $(TARGET).cpp ../common/utils.cpp ../common/config.cpp ../common/scaler.cpp ../common/api.cpp
CXXSOURCE += build/$(PLATFORM)/platform.o

CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
# Prefer real C++20; fall back to gnu++2a on older toolchains (e.g. the current
# gcc 8.3 tg5040 cross-compiler, which predates the -std=gnu++20 spelling).
CXXSTD := $(shell printf 'int main(){return 0;}' | $(CXX) -std=gnu++20 -x c++ - -o /dev/null >/dev/null 2>&1 && echo gnu++20 || echo gnu++2a)
CFLAGS += $(OPT)
CFLAGS += $(INCDIR) -DPLATFORM=\"$(PLATFORM)\" -std=gnu99
CFLAGS += $(INCDIR) -DPLATFORM=\"$(PLATFORM)\"
CXXFLAGS += $(CFLAGS) -std=$(CXXSTD)
LDFLAGS += -lmsettings

PRODUCT= build/$(PLATFORM)/$(TARGET).elf

all: $(PREFIX_LOCAL)/include/msettings.h
mkdir -p build/$(PLATFORM)
$(CC) $(SOURCE) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS)
$(CXX) $(SOURCE) $(CXXFLAGS) $(LDFLAGS)
mv platform.o build/$(PLATFORM)
$(CXX) $(CXXSOURCE) -o $(PRODUCT) $(CXXFLAGS) $(LDFLAGS) -lstdc++
clean:
rm -f $(PRODUCT)

Expand Down
Loading
Loading