ui, fix linux handling of 32x renderer
authorkub <derkub@gmail.com>
Wed, 20 Jan 2021 18:39:21 +0000 (19:39 +0100)
committerkub <derkub@gmail.com>
Wed, 20 Jan 2021 18:39:21 +0000 (19:39 +0100)
platform/linux/emu.c

index 99dc270..b8645b1 100644 (file)
@@ -36,6 +36,32 @@ void pemu_validate_config(void)
 #endif\r
 }\r
 \r
+#define is_16bit_mode() \\r
+       (currentConfig.renderer == RT_16BIT || (PicoIn.AHW & PAHW_32X))\r
+\r
+static int get_renderer(void)\r
+{\r
+       if (PicoIn.AHW & PAHW_32X)\r
+               return currentConfig.renderer32x;\r
+       else\r
+               return currentConfig.renderer;\r
+}\r
+\r
+static void change_renderer(int diff)\r
+{\r
+       int *r;\r
+       if (PicoIn.AHW & PAHW_32X)\r
+               r = &currentConfig.renderer32x;\r
+       else\r
+               r = &currentConfig.renderer;\r
+       *r += diff;\r
+\r
+       if      (*r >= RT_COUNT)\r
+               *r = 0;\r
+       else if (*r < 0)\r
+               *r = RT_COUNT - 1;\r
+}\r
+\r
 static void draw_cd_leds(void)\r
 {\r
        int led_reg, pitch, scr_offs, led_offs;\r
@@ -57,10 +83,11 @@ static void draw_cd_leds(void)
 \r
 void pemu_finalize_frame(const char *fps, const char *notice)\r
 {\r
-       if (currentConfig.renderer != RT_16BIT && !(PicoIn.AHW & PAHW_32X)) {\r
+       if (!is_16bit_mode()) {\r
+               // convert the 8 bit CLUT output to 16 bit RGB\r
                unsigned short *pd = (unsigned short *)g_screen_ptr +\r
                                        out_y * g_screen_ppitch + out_x;\r
-               unsigned char *ps = Pico.est.Draw2FB + 328*out_y + 8; //+ out_x;\r
+               unsigned char *ps = Pico.est.Draw2FB + 328*out_y + 8;\r
                unsigned short *pal = Pico.est.HighPal;\r
                int i, x;\r
 \r
@@ -83,13 +110,13 @@ void pemu_finalize_frame(const char *fps, const char *notice)
 \r
 void plat_video_set_buffer(void *buf)\r
 {\r
-       if (currentConfig.renderer == RT_16BIT || (PicoIn.AHW & PAHW_32X))\r
+       if (is_16bit_mode())\r
                PicoDrawSetOutBuf(g_screen_ptr, g_screen_ppitch * 2);\r
 }\r
 \r
 static void apply_renderer(void)\r
 {\r
-       switch (currentConfig.renderer) {\r
+       switch (get_renderer()) {\r
        case RT_16BIT:\r
                PicoIn.opt &= ~POPT_ALT_RENDERER;\r
                PicoIn.opt &= ~POPT_DIS_32C_BORDER;\r
@@ -117,16 +144,16 @@ static void apply_renderer(void)
 \r
 void plat_video_toggle_renderer(int change, int is_menu)\r
 {\r
-       currentConfig.renderer += change;\r
-       if      (currentConfig.renderer >= RT_COUNT)\r
-               currentConfig.renderer = 0;\r
-       else if (currentConfig.renderer < 0)\r
-               currentConfig.renderer = RT_COUNT - 1;\r
+       change_renderer(change);\r
 \r
-       if (!is_menu)\r
+       if (!is_menu) {\r
                apply_renderer();\r
 \r
-       emu_status_msg(renderer_names[currentConfig.renderer]);\r
+               if (PicoIn.AHW & PAHW_32X)\r
+                       emu_status_msg(renderer_names32x[get_renderer()]);\r
+               else\r
+                       emu_status_msg(renderer_names[get_renderer()]);\r
+       }\r
 }\r
 \r
 void plat_status_msg_clear(void)\r
@@ -175,7 +202,7 @@ void plat_debug_cat(char *str)
 void emu_video_mode_change(int start_line, int line_count, int is_32cols)\r
 {\r
        // clear whole screen in all buffers\r
-       if (currentConfig.renderer != RT_16BIT && !(PicoIn.AHW & PAHW_32X))\r
+       if (!is_16bit_mode())\r
                memset32(Pico.est.Draw2FB, 0xe0e0e0e0, (320+8) * (8+240+8) / 4);\r
        plat_video_clear_buffers();\r
 \r