* [PATCH] commands: 2048: use 16-color ANSI palette
@ 2026-05-02 11:36 Ahmad Fatoum
2026-05-07 10:38 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-05-02 11:36 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The 256-color xterm sequences (38;5;n / 48;5;n) require xterm-256color
terminal support. Switch to standard 16-color ANSI SGR codes, which work
on any VT100-compatible terminal and can also be displayed fine by the
barebox framebuffer console.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
commands/2048.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/commands/2048.c b/commands/2048.c
index c8b35bdb7d0a..6d35e03d4889 100644
--- a/commands/2048.c
+++ b/commands/2048.c
@@ -13,17 +13,22 @@ static uint32_t score;
static void getColor(uint16_t value, char *color, size_t length)
{
- uint8_t original[] = {8,255,1,255,2,255,3,255,4,255,5,255,6,255,7,255,9,0,10,0,11,0,12,0,13,0,14,0,255,0,255,0};
+ uint8_t original[] = {
+ 0,7, 1,7, 2,7, 3,0, 4,7, 5,7, 6,7, 7,0,
+ 1,0, 2,0, 3,0, 4,0, 5,0, 6,0, 7,0, 0,7
+ };
uint8_t *scheme = original;
uint8_t *background = scheme+0;
uint8_t *foreground = scheme+1;
+
if (value > 0) while (value >>= 1) {
if (background+2<scheme+sizeof(original)) {
background+=2;
foreground+=2;
}
}
- snprintf(color,length,"\033[38;5;%d;48;5;%dm",*foreground,*background);
+
+ snprintf(color, length, "\033[%d;%dm", 30 + *foreground, 40 + *background);
}
static void drawBoard(uint16_t board[SIZE][SIZE])
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] commands: 2048: use 16-color ANSI palette
2026-05-02 11:36 [PATCH] commands: 2048: use 16-color ANSI palette Ahmad Fatoum
@ 2026-05-07 10:38 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-05-07 10:38 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Sat, 02 May 2026 13:36:24 +0200, Ahmad Fatoum wrote:
> The 256-color xterm sequences (38;5;n / 48;5;n) require xterm-256color
> terminal support. Switch to standard 16-color ANSI SGR codes, which work
> on any VT100-compatible terminal and can also be displayed fine by the
> barebox framebuffer console.
>
>
Applied, thanks!
[1/1] commands: 2048: use 16-color ANSI palette
https://git.pengutronix.de/cgit/barebox/commit/?id=447d7bf2590d (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-07 10:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-02 11:36 [PATCH] commands: 2048: use 16-color ANSI palette Ahmad Fatoum
2026-05-07 10:38 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox