*/
#include "../pico_int.h"
+// BGR555 to native conversion
+#if defined(USE_BGR555)
+#define PXCONV(t) (t)
+#define PXPRIO 0x8000 // prio in MSB
+#else // RGB565
+#define PXCONV(t) ((((t)&m1) << 11) | (((t)&m2) << 1) | (((t)&m3) >> 10))
+#define PXPRIO 0x0020 // prio in LS green bit
+#endif
+
int (*PicoScan32xBegin)(unsigned int num);
int (*PicoScan32xEnd)(unsigned int num);
int Pico32xDrawMode;
unsigned int *pd = (void *)Pico32xMem->pal_native;
unsigned int m1 = 0x001f001f;
unsigned int m2 = 0x03e003e0;
- unsigned int m3 = 0xfc00fc00;
+ unsigned int m3 = 0xfc00fc00; // includes prio bit
unsigned int inv = 0;
int i;
if (invert_prio)
- inv = 0x00200020;
+ inv = 0x80008000;
- // place prio to LS green bit
for (i = 0x100/2; i > 0; i--, ps++, pd++) {
- unsigned int t = *ps;
-#if defined(USE_BGR555)
- *pd = t ^ inv;
-#else
- *pd = (((t & m1) << 11) | ((t & m2) << 1) | ((t & m3) >> 10)) ^ inv;
-#endif
+ unsigned int t = *ps ^ inv;
+ *pd = PXCONV(t);
}
Pico32x.dirty_pal = 0;
}
-// 555 conversion for direct color mode
-#if defined(USE_BGR555)
-#define DC555(t) t
-#else
-#define DC555(t) ((t&m1) << 11) | ((t&m2) << 1) | ((t&m3) >> 10)
-#endif
-
// direct color mode
#define do_line_dc(pd, p32x, pmd, inv, pmd_draw_code) \
{ \
while (i > 0) { \
for (; i > 0 && (*pmd & 0x3f) == mdbg; pd++, pmd++, i--) { \
t = *p32x++; \
- *pd = DC555(t); \
+ *pd = PXCONV(t); \
} \
for (; i > 0 && (*pmd & 0x3f) != mdbg; pd++, pmd++, i--) { \
- t = *p32x++; \
- if ((t ^ inv) & 0x8000) \
- *pd = DC555(t); \
+ t = *p32x++ ^ inv; \
+ if (t & 0x8000) \
+ *pd = PXCONV(t); \
else \
pmd_draw_code; \
} \
} \
for (; i > 0 && (*pmd & 0x3f) != mdbg; pd++, pmd++, i--) { \
t = pal[*(unsigned char *)((uintptr_t)(p32x++) ^ 1)]; \
- if (t & 0x20) \
+ if (t & PXPRIO) \
*pd = t; \
else \
pmd_draw_code; \
for (i = 320; i > 0; p32x++) { \
t = pal[*p32x & 0xff]; \
for (len = (*p32x >> 8) + 1; len > 0 && i > 0; len--, i--, pd++, pmd++) { \
- if ((*pmd & 0x3f) == mdbg || (t & 0x20)) \
+ if ((*pmd & 0x3f) == mdbg || (t & PXPRIO)) \
*pd = t; \
else \
pmd_draw_code; \
\r
// NB don't change any defines without checking their usage in ASM\r
\r
+#if defined(USE_BGR555)\r
+#define PXCONV(t) ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<2) | ((t & 0x0e000e00)<<3)\r
+#define PXMASKL 0x04210421 // 0x0c630c63, LSB for all colours\r
+#define PXMASKH 0x39ce39ce // 0x3def3def, all but MSB for all colours\r
+#else // RGB565\r
+#define PXCONV(t) ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7)\r
+#define PXMASKL 0x08610861 // 0x18e318e3\r
+#define PXMASKH 0x738e738e // 0x7bef7bef\r
+#endif\r
+\r
#define LF_PLANE (1 << 0) // must be = 1\r
#define LF_SH (1 << 1) // must be = 2\r
//#define LF_FORCE (1 << 2)\r
// additional palettes stored after in-frame changes\r
for (i = 0; i < cnt * 0x40 / 2; i++) {\r
t = spal[i];\r
-#ifdef USE_BGR555\r
- t = ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)<<4);\r
-#else\r
- t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7);\r
-#endif\r
// treat it like it was 4-bit per channel, since in s/h mode it somewhat is that.\r
// otherwise intensity difference between this and s/h will be wrong\r
- t |= (t >> 4) & 0x08610861; // 0x18e318e3\r
+ t = PXCONV(t);\r
+ t |= (t >> 4) & PXMASKL;\r
dpal[i] = dpal[0xc0/2 + i] = t;\r
}\r
\r
{\r
// shadowed pixels\r
for (i = 0; i < 0x40 / 2; i++)\r
- dpal[0x80/2 + i] = (dpal[i] >> 1) & 0x738e738e;\r
+ dpal[0x80/2 + i] = (dpal[i] >> 1) & PXMASKH;\r
// hilighted pixels\r
for (i = 0; i < 0x40 / 2; i++) {\r
- t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e; // 0x7bef7bef;\r
- t |= (t >> 4) & 0x08610861;\r
+ t = ((dpal[i] >> 1) & PXMASKH) + PXMASKH;\r
+ t |= (t >> 4) & PXMASKL;\r
dpal[0x40/2 + i] = t;\r
}\r
// shadowed pixels in color 14 always appear normal (hw bug?)\r
\r
for (i = 0; i < 0x40 / 2; i++) {\r
t = spal[i];\r
-#ifdef USE_BGR555\r
- t = ((t & 0x0e000e00)<< 3) | ((t & 0x00e000e0)<<2) | ((t & 0x000e000e)<<1);\r
-#else\r
- t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7);\r
-#endif\r
// treat it like it was 4-bit per channel, since in s/h mode it somewhat is that.\r
// otherwise intensity difference between this and s/h will be wrong\r
- t |= (t >> 4) & 0x08610861; // 0x18e318e3\r
+ t = PXCONV(t);\r
+ t |= (t >> 4) & PXMASKL;\r
dpal[i] = dpal[0xc0/2 + i] = t;\r
}\r
\r
{\r
// shadowed pixels\r
for (i = 0; i < 0x40 / 2; i++)\r
- dpal[0x80/2 + i] = (dpal[i] >> 1) & 0x738e738e;\r
+ dpal[0x80/2 + i] = (dpal[i] >> 1) & PXMASKH;\r
// hilighted pixels\r
for (i = 0; i < 0x40 / 2; i++) {\r
- t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e; // 0x7bef7bef;\r
- t |= (t >> 4) & 0x08610861;\r
+ t = ((dpal[i] >> 1) & PXMASKH) + PXMASKH;\r
+ t |= (t >> 4) & PXMASKL;\r
dpal[0x40/2 + i] = t;\r
}\r
// shadowed pixels in color 14 always appear normal (hw bug?)\r