gp2x, fixes for sms
authorkub <derkub@gmail.com>
Fri, 15 Oct 2021 17:27:37 +0000 (19:27 +0200)
committerkub <derkub@gmail.com>
Fri, 15 Oct 2021 17:27:37 +0000 (19:27 +0200)
platform/common/arm_utils.s
platform/gp2x/emu.c

index 5f0c46c..7dbed97 100644 (file)
@@ -9,10 +9,10 @@
 .text\r
 .align 4\r
 \r
-@ Convert 0000bbb0 ggg0rrr0 0000bbb0 ggg0rrr0\r
-@ to      00000000 rrr00000 ggg00000 bbb00000 ...\r
+@ Convert 0000bbbb ggggrrrr 0000bbbb ggggrrrr\r
+@ to      00000000 rrrr0000 gggg0000 bbbb0000 ...\r
 \r
-@ lr =  0x00e000e0, out: r3=lower_pix, r2=higher_pix; trashes rin\r
+@ lr =  0x00f000f0, out: r3=lower_pix, r2=higher_pix; trashes rin\r
 .macro convRGB32_2 rin sh=0\r
     and     r2,  lr, \rin, lsr #4 @ blue\r
     and     r3,  \rin, lr\r
     mov     r3,  r3,  ror #17             @ shadow mode\r
 .elseif \sh == 2\r
     adds    r3,  r3,  #0x40000000         @ green\r
-    orrcs   r3,  r3,  #0xe0000000\r
+    orrcs   r3,  r3,  lr, lsl #24\r
     mov     r3,  r3,  ror #8\r
     adds    r3,  r3,  #0x40000000\r
-    orrcs   r3,  r3,  #0xe0000000\r
+    orrcs   r3,  r3,  lr, lsl #24\r
     mov     r3,  r3,  ror #16\r
     adds    r3,  r3,  #0x40000000\r
-    orrcs   r3,  r3,  #0xe0000000\r
+    orrcs   r3,  r3,  lr, lsl #24\r
     mov     r3,  r3,  ror #24\r
 .else\r
     mov     r3,  r3,  ror #16             @ r3=low\r
 .elseif \sh == 2\r
     mov     r2,  r2,  ror #8\r
     adds    r2,  r2,  #0x40000000         @ blue\r
-    orrcs   r2,  r2,  #0xe0000000\r
+    orrcs   r2,  r2,  lr, lsl #24\r
     mov     r2,  r2,  ror #8\r
     adds    r2,  r2,  #0x40000000\r
-    orrcs   r2,  r2,  #0xe0000000\r
+    orrcs   r2,  r2,  lr, lsl #24\r
     mov     r2,  r2,  ror #8\r
     adds    r2,  r2,  #0x40000000\r
-    orrcs   r2,  r2,  #0xe0000000\r
+    orrcs   r2,  r2,  lr, lsl #24\r
     mov     r2,  r2,  ror #8\r
 .endif\r
 \r
@@ -68,17 +68,17 @@ bgr444_to_rgb32:
     stmfd   sp!, {r4-r7,lr}\r
 \r
     mov     r12, #0x40>>3 @ repeats\r
-    mov     lr, #0x00e00000\r
-    orr     lr, lr, #0x00e0\r
+    mov     lr, #0x00f00000\r
+    orr     lr, lr, #0x00f0\r
 \r
 .loopRGB32:\r
-    subs    r12, r12, #1\r
-\r
     ldmia    r1!, {r4-r7}\r
     convRGB32_2 r4\r
     convRGB32_2 r5\r
     convRGB32_2 r6\r
     convRGB32_2 r7\r
+\r
+    subs    r12, r12, #1\r
     bgt     .loopRGB32\r
 \r
     ldmfd   sp!, {r4-r7,pc}\r
@@ -91,24 +91,25 @@ bgr444_to_rgb32_sh:
 \r
     mov     r12, #0x40>>3 @ repeats\r
     add     r0, r0, #0x40*4\r
-    mov     lr, #0x00e00000\r
-    orr     lr, lr, #0x00e0\r
+    mov     lr, #0x00f00000\r
+    orr     lr, lr, #0x00f0\r
 \r
 .loopRGB32sh:\r
-    subs    r12, r12, #1\r
-\r
     ldmia    r1!, {r4-r7}\r
     convRGB32_2 r4, 2\r
     convRGB32_2 r5, 2\r
     convRGB32_2 r6, 2\r
     convRGB32_2 r7, 2\r
+\r
+    subs    r12, r12, #1\r
     bgt     .loopRGB32sh\r
 \r
     mov     r12, #0x40>>3 @ repeats\r
     sub     r1, r1, #0x40*2\r
+    and     lr, lr, lr, lsl #1  @ kill LSB for correct shadow colors\r
 \r
 .loopRGB32hi:\r
-     ldmia    r1!, {r4-r7}\r
+    ldmia    r1!, {r4-r7}\r
     convRGB32_2 r4, 1\r
     convRGB32_2 r5, 1\r
     convRGB32_2 r6, 1\r
index deb8658..7c94c45 100644 (file)
@@ -83,6 +83,10 @@ void pemu_validate_config(void)
 \r
 static int get_renderer(void)\r
 {\r
+       if (doing_bg_frame)\r
+               return RT_16BIT;\r
+       if ((PicoIn.AHW & PAHW_SMS) && currentConfig.renderer == RT_8BIT_FAST)\r
+               return RT_8BIT_ACC;     // 8bpp fast is not there (yet?)\r
        if (PicoIn.AHW & PAHW_32X)\r
                return currentConfig.renderer32x;\r
        else\r
@@ -391,7 +395,7 @@ void plat_video_flip(void)
                stride *= 2;\r
        // the fast renderer has overlap areas and can't directly render to\r
        // screen buffers. Its output is copied to screen in finalize_frame\r
-       if (currentConfig.renderer != RT_8BIT_FAST || (PicoIn.AHW & PAHW_32X))\r
+       if (get_renderer() != RT_8BIT_FAST || (PicoIn.AHW & PAHW_32X))\r
                PicoDrawSetOutBuf(g_screen_ptr, stride);\r
 }\r
 \r
@@ -476,9 +480,6 @@ static void vid_reset_mode(void)
        int gp2x_mode = 16;\r
        int renderer = get_renderer();\r
 \r
-       if (doing_bg_frame)\r
-               renderer = RT_16BIT;\r
-\r
        PicoIn.opt &= ~POPT_ALT_RENDERER;\r
        emu_scan_begin = NULL;\r
        emu_scan_end = NULL;\r
@@ -554,7 +555,7 @@ static void vid_reset_mode(void)
        if (currentConfig.scaling == EOPT_SCALE_SW) {\r
                PicoIn.opt |= POPT_EN_SOFTSCALE;\r
                PicoIn.filter = EOPT_FILTER_BILINEAR2;\r
-       } else if (currentConfig.scaling == EOPT_SCALE_HW && is_16bit_mode())\r
+       } else if (currentConfig.scaling == EOPT_SCALE_HW)\r
                // hw scaling, render without any padding\r
                PicoIn.opt |= POPT_DIS_32C_BORDER;\r
 \r