platform, fix BGR/RGB menu handling
authorkub <derkub@gmail.com>
Wed, 14 Feb 2024 22:39:06 +0000 (23:39 +0100)
committerkub <derkub@gmail.com>
Wed, 14 Feb 2024 22:48:28 +0000 (23:48 +0100)
platform/common/menu_pico.c
platform/libpicofe

index 1492738..94eb283 100644 (file)
@@ -14,6 +14,8 @@
 #include "input_pico.h"
 #include "version.h"
 
+#include "../libpicofe/plat.h"
+
 #include <pico/pico_int.h>
 #include <pico/patch.h>
 
 #define MENU_X2 0
 #endif
 
-#if defined USE_BGR555
-#define COL_ROM        0x5eff
-#define COL_OTH        0x5ff5
-#elif defined USE_BGR565
-#define COL_ROM        0xfdf7
-#define COL_OTH        0xaff5
-#else
-#define COL_ROM        0xbdff
-#define        COL_OTH 0xaff5
-#endif
+#define COL_ROM PXMAKE(0xbf, 0xbf, 0xff)
+#define COL_OTH PXMAKE(0xaf, 0xff, 0xaf)
 
 // FIXME
 #ifndef REVISION
@@ -65,7 +59,7 @@ static unsigned short fname2color(const char *fname)
                if (strcasecmp(ext, rom_exts[i]) == 0) return COL_ROM;
        for (i = 0; i < array_size(other_exts); i++)
                if (strcasecmp(ext, other_exts[i]) == 0) return COL_OTH;
-       return 0xffff;
+       return PXMAKE(0xff, 0xff, 0xff);
 }
 
 #include <platform/libpicofe/menu.c>
@@ -113,7 +107,7 @@ static void make_bg(int no_scale, int from_screen)
                for (y = 0; y < h; y++, src += pp, d += g_menuscreen_w*2/2) {
                        for (x = 0; x < w; x++) {
                                t = src[x];
-                               t = ((t & 0xf79e)>>1) - ((t & 0xc618)>>3);
+                               t = (PXMASKH(t,1)>>1) - (PXMASKH(t,3)>>3);
                                t |= t << 16;
                                d[x] = d[x + g_menuscreen_w / 2] = t;
                        }
@@ -232,8 +226,8 @@ static void cdload_progress_cb(const char *fname, int percent)
        copy_bg(0);
        menuscreen_memset_lines(dst, 0xff, me_sfont_h - 2);
 
-       smalltext_out16(1, 3 * me_sfont_h, "Processing CD image / MP3s", 0xffff);
-       smalltext_out16(1, 4 * me_sfont_h, fname, 0xffff);
+       smalltext_out16(1, 3 * me_sfont_h, "Processing CD image / MP3s", PXMAKE(0xff, 0xff, 0xff));
+       smalltext_out16(1, 4 * me_sfont_h, fname, PXMAKE(0xff, 0xff, 0xff));
        dst += g_menuscreen_pp * me_sfont_h * 3;
 
        if (len > g_menuscreen_w)
@@ -254,8 +248,8 @@ void menu_romload_prepare(const char *rom_name)
                p--;
 
        menu_draw_begin(1, 1);
-       smalltext_out16(1, 1, "Loading", 0xffff);
-       smalltext_out16(1, me_sfont_h, p, 0xffff);
+       smalltext_out16(1, 1, "Loading", PXMAKE(0xff, 0xff, 0xff));
+       smalltext_out16(1, me_sfont_h, p, PXMAKE(0xff, 0xff, 0xff));
        /* copy menu to bg for callbacks. OK since we are not in menu_loop here */
        copy_bg(1);
        menu_draw_end();
@@ -273,7 +267,7 @@ void menu_romload_end(void)
        menu_draw_begin(0, 1);
        copy_bg(0);
        smalltext_out16(1, (cdload_called ? 6 : 3) * me_sfont_h,
-               "Starting emulation...", 0xffff);
+               "Starting emulation...", PXMAKE(0xff, 0xff, 0xff));
        menu_draw_end();
 }
 
@@ -293,12 +287,12 @@ static void draw_patchlist(int sel)
                if (pos < 0) continue;
                if (pos >= max_cnt) break;
                active = PicoPatches[i].active;
-               smalltext_out16(14,                pos * me_sfont_h, active ? "ON " : "OFF", active ? 0xfff6 : 0xffff);
-               smalltext_out16(14 + me_sfont_w*4, pos * me_sfont_h, PicoPatches[i].name,    active ? 0xfff6 : 0xffff);
+               smalltext_out16(14,                pos * me_sfont_h, active ? "ON " : "OFF", PXMAKE(0xff, 0xff, active ? 0xff : 0xb0));
+               smalltext_out16(14 + me_sfont_w*4, pos * me_sfont_h, PicoPatches[i].name,    PXMAKE(0xff, 0xff, active ? 0xff : 0xb0));
        }
        pos = start + i;
        if (pos < max_cnt)
-               smalltext_out16(14, pos * me_sfont_h, "done", 0xffff);
+               smalltext_out16(14, pos * me_sfont_h, "done", PXMAKE(0xff, 0xff, 0xff));
 
        text_out16(5, max_cnt / 2 * me_sfont_h, ">");
        menu_draw_end();
@@ -1009,7 +1003,7 @@ static void draw_text_debug(const char *str, int skip, int from)
        str = p;
        for (line = from; line < g_menuscreen_h / me_sfont_h; line++)
        {
-               smalltext_out16(1, line * me_sfont_h, str, 0xffff);
+               smalltext_out16(1, line * me_sfont_h, str, PXMAKE(0xff, 0xff, 0xff));
                while (*p && *p != '\n')
                        p++;
                if (*p == 0)
@@ -1038,8 +1032,8 @@ static void draw_frame_debug(void)
        pemu_forced_frame(1, 0);
        make_bg(1, 1);
 
-       smalltext_out16(4, 1, "build: r" REVISION "  "__DATE__ " " __TIME__ " " COMPILER, 0xffff);
-       smalltext_out16(4, g_menuscreen_h - me_sfont_h, layer_str, 0xffff);
+       smalltext_out16(4, 1, "build: r" REVISION "  "__DATE__ " " __TIME__ " " COMPILER, PXMAKE(0xff, 0xff, 0xff));
+       smalltext_out16(4, g_menuscreen_h - me_sfont_h, layer_str, PXMAKE(0xff, 0xff, 0xff));
 }
 
 static void debug_menu_loop(void)
@@ -1063,7 +1057,7 @@ static void debug_menu_loop(void)
                                draw_text_debug(tmp, 0, 0);
                                if (dumped) {
                                        smalltext_out16(g_menuscreen_w - 6 * me_sfont_h,
-                                               g_menuscreen_h - me_mfont_h, "dumped", 0xffff);
+                                               g_menuscreen_h - me_mfont_h, "dumped", PXMAKE(0xff, 0xff, 0xff));
                                        dumped = 0;
                                }
                                break;
@@ -1137,7 +1131,7 @@ static void debug_menu_loop(void)
 
 static void draw_frame_credits(void)
 {
-       smalltext_out16(4, 1, "build: " __DATE__ " " __TIME__, 0xe7fc);
+       smalltext_out16(4, 1, "build: " __DATE__ " " __TIME__, PXMAKE(0xe0, 0xff, 0xe0));
 }
 
 static const char credits[] =
index 7cddc27..c825b16 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 7cddc27accc089fdb58e99cdac0071cc904ecef1
+Subproject commit c825b167e9c08afaec23721f983ba003d86b838a