mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
rendering, fix bgr555 output mode
NB not done for ARM asm since no target uses bgr555
This commit is contained in:
parent
42077979ca
commit
16b11d9171
4 changed files with 43 additions and 42 deletions
|
@ -8,6 +8,15 @@
|
||||||
*/
|
*/
|
||||||
#include "../pico_int.h"
|
#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 (*PicoScan32xBegin)(unsigned int num);
|
||||||
int (*PicoScan32xEnd)(unsigned int num);
|
int (*PicoScan32xEnd)(unsigned int num);
|
||||||
int Pico32xDrawMode;
|
int Pico32xDrawMode;
|
||||||
|
@ -21,33 +30,21 @@ static void convert_pal555(int invert_prio)
|
||||||
unsigned int *pd = (void *)Pico32xMem->pal_native;
|
unsigned int *pd = (void *)Pico32xMem->pal_native;
|
||||||
unsigned int m1 = 0x001f001f;
|
unsigned int m1 = 0x001f001f;
|
||||||
unsigned int m2 = 0x03e003e0;
|
unsigned int m2 = 0x03e003e0;
|
||||||
unsigned int m3 = 0xfc00fc00;
|
unsigned int m3 = 0xfc00fc00; // includes prio bit
|
||||||
unsigned int inv = 0;
|
unsigned int inv = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (invert_prio)
|
if (invert_prio)
|
||||||
inv = 0x00200020;
|
inv = 0x80008000;
|
||||||
|
|
||||||
// place prio to LS green bit
|
|
||||||
for (i = 0x100/2; i > 0; i--, ps++, pd++) {
|
for (i = 0x100/2; i > 0; i--, ps++, pd++) {
|
||||||
unsigned int t = *ps;
|
unsigned int t = *ps ^ inv;
|
||||||
#if defined(USE_BGR555)
|
*pd = PXCONV(t);
|
||||||
*pd = t ^ inv;
|
|
||||||
#else
|
|
||||||
*pd = (((t & m1) << 11) | ((t & m2) << 1) | ((t & m3) >> 10)) ^ inv;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Pico32x.dirty_pal = 0;
|
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
|
// direct color mode
|
||||||
#define do_line_dc(pd, p32x, pmd, inv, pmd_draw_code) \
|
#define do_line_dc(pd, p32x, pmd, inv, pmd_draw_code) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -60,12 +57,12 @@ static void convert_pal555(int invert_prio)
|
||||||
while (i > 0) { \
|
while (i > 0) { \
|
||||||
for (; i > 0 && (*pmd & 0x3f) == mdbg; pd++, pmd++, i--) { \
|
for (; i > 0 && (*pmd & 0x3f) == mdbg; pd++, pmd++, i--) { \
|
||||||
t = *p32x++; \
|
t = *p32x++; \
|
||||||
*pd = DC555(t); \
|
*pd = PXCONV(t); \
|
||||||
} \
|
} \
|
||||||
for (; i > 0 && (*pmd & 0x3f) != mdbg; pd++, pmd++, i--) { \
|
for (; i > 0 && (*pmd & 0x3f) != mdbg; pd++, pmd++, i--) { \
|
||||||
t = *p32x++; \
|
t = *p32x++ ^ inv; \
|
||||||
if ((t ^ inv) & 0x8000) \
|
if (t & 0x8000) \
|
||||||
*pd = DC555(t); \
|
*pd = PXCONV(t); \
|
||||||
else \
|
else \
|
||||||
pmd_draw_code; \
|
pmd_draw_code; \
|
||||||
} \
|
} \
|
||||||
|
@ -84,7 +81,7 @@ static void convert_pal555(int invert_prio)
|
||||||
} \
|
} \
|
||||||
for (; i > 0 && (*pmd & 0x3f) != mdbg; pd++, pmd++, i--) { \
|
for (; i > 0 && (*pmd & 0x3f) != mdbg; pd++, pmd++, i--) { \
|
||||||
t = pal[*(unsigned char *)((uintptr_t)(p32x++) ^ 1)]; \
|
t = pal[*(unsigned char *)((uintptr_t)(p32x++) ^ 1)]; \
|
||||||
if (t & 0x20) \
|
if (t & PXPRIO) \
|
||||||
*pd = t; \
|
*pd = t; \
|
||||||
else \
|
else \
|
||||||
pmd_draw_code; \
|
pmd_draw_code; \
|
||||||
|
@ -100,7 +97,7 @@ static void convert_pal555(int invert_prio)
|
||||||
for (i = 320; i > 0; p32x++) { \
|
for (i = 320; i > 0; p32x++) { \
|
||||||
t = pal[*p32x & 0xff]; \
|
t = pal[*p32x & 0xff]; \
|
||||||
for (len = (*p32x >> 8) + 1; len > 0 && i > 0; len--, i--, pd++, pmd++) { \
|
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; \
|
*pd = t; \
|
||||||
else \
|
else \
|
||||||
pmd_draw_code; \
|
pmd_draw_code; \
|
||||||
|
|
38
pico/draw.c
38
pico/draw.c
|
@ -65,6 +65,16 @@ unsigned int VdpSATCache[128]; // VDP sprite cache (1st 32 sprite attr bits)
|
||||||
|
|
||||||
// NB don't change any defines without checking their usage in ASM
|
// NB don't change any defines without checking their usage in ASM
|
||||||
|
|
||||||
|
#if defined(USE_BGR555)
|
||||||
|
#define PXCONV(t) ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<2) | ((t & 0x0e000e00)<<3)
|
||||||
|
#define PXMASKL 0x04210421 // 0x0c630c63, LSB for all colours
|
||||||
|
#define PXMASKH 0x39ce39ce // 0x3def3def, all but MSB for all colours
|
||||||
|
#else // RGB565
|
||||||
|
#define PXCONV(t) ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7)
|
||||||
|
#define PXMASKL 0x08610861 // 0x18e318e3
|
||||||
|
#define PXMASKH 0x738e738e // 0x7bef7bef
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LF_PLANE (1 << 0) // must be = 1
|
#define LF_PLANE (1 << 0) // must be = 1
|
||||||
#define LF_SH (1 << 1) // must be = 2
|
#define LF_SH (1 << 1) // must be = 2
|
||||||
//#define LF_FORCE (1 << 2)
|
//#define LF_FORCE (1 << 2)
|
||||||
|
@ -1542,14 +1552,10 @@ void PicoDoHighPal555_8bit(int sh, int line, struct PicoEState *est)
|
||||||
// additional palettes stored after in-frame changes
|
// additional palettes stored after in-frame changes
|
||||||
for (i = 0; i < cnt * 0x40 / 2; i++) {
|
for (i = 0; i < cnt * 0x40 / 2; i++) {
|
||||||
t = spal[i];
|
t = spal[i];
|
||||||
#ifdef USE_BGR555
|
|
||||||
t = ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)<<4);
|
|
||||||
#else
|
|
||||||
t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7);
|
|
||||||
#endif
|
|
||||||
// treat it like it was 4-bit per channel, since in s/h mode it somewhat is that.
|
// treat it like it was 4-bit per channel, since in s/h mode it somewhat is that.
|
||||||
// otherwise intensity difference between this and s/h will be wrong
|
// otherwise intensity difference between this and s/h will be wrong
|
||||||
t |= (t >> 4) & 0x08610861; // 0x18e318e3
|
t = PXCONV(t);
|
||||||
|
t |= (t >> 4) & PXMASKL;
|
||||||
dpal[i] = dpal[0xc0/2 + i] = t;
|
dpal[i] = dpal[0xc0/2 + i] = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1558,11 +1564,11 @@ void PicoDoHighPal555_8bit(int sh, int line, struct PicoEState *est)
|
||||||
{
|
{
|
||||||
// shadowed pixels
|
// shadowed pixels
|
||||||
for (i = 0; i < 0x40 / 2; i++)
|
for (i = 0; i < 0x40 / 2; i++)
|
||||||
dpal[0x80/2 + i] = (dpal[i] >> 1) & 0x738e738e;
|
dpal[0x80/2 + i] = (dpal[i] >> 1) & PXMASKH;
|
||||||
// hilighted pixels
|
// hilighted pixels
|
||||||
for (i = 0; i < 0x40 / 2; i++) {
|
for (i = 0; i < 0x40 / 2; i++) {
|
||||||
t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e; // 0x7bef7bef;
|
t = ((dpal[i] >> 1) & PXMASKH) + PXMASKH;
|
||||||
t |= (t >> 4) & 0x08610861;
|
t |= (t >> 4) & PXMASKL;
|
||||||
dpal[0x40/2 + i] = t;
|
dpal[0x40/2 + i] = t;
|
||||||
}
|
}
|
||||||
// shadowed pixels in color 14 always appear normal (hw bug?)
|
// shadowed pixels in color 14 always appear normal (hw bug?)
|
||||||
|
@ -1586,14 +1592,10 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
|
||||||
|
|
||||||
for (i = 0; i < 0x40 / 2; i++) {
|
for (i = 0; i < 0x40 / 2; i++) {
|
||||||
t = spal[i];
|
t = spal[i];
|
||||||
#ifdef USE_BGR555
|
|
||||||
t = ((t & 0x0e000e00)<< 3) | ((t & 0x00e000e0)<<2) | ((t & 0x000e000e)<<1);
|
|
||||||
#else
|
|
||||||
t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7);
|
|
||||||
#endif
|
|
||||||
// treat it like it was 4-bit per channel, since in s/h mode it somewhat is that.
|
// treat it like it was 4-bit per channel, since in s/h mode it somewhat is that.
|
||||||
// otherwise intensity difference between this and s/h will be wrong
|
// otherwise intensity difference between this and s/h will be wrong
|
||||||
t |= (t >> 4) & 0x08610861; // 0x18e318e3
|
t = PXCONV(t);
|
||||||
|
t |= (t >> 4) & PXMASKL;
|
||||||
dpal[i] = dpal[0xc0/2 + i] = t;
|
dpal[i] = dpal[0xc0/2 + i] = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1602,11 +1604,11 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
|
||||||
{
|
{
|
||||||
// shadowed pixels
|
// shadowed pixels
|
||||||
for (i = 0; i < 0x40 / 2; i++)
|
for (i = 0; i < 0x40 / 2; i++)
|
||||||
dpal[0x80/2 + i] = (dpal[i] >> 1) & 0x738e738e;
|
dpal[0x80/2 + i] = (dpal[i] >> 1) & PXMASKH;
|
||||||
// hilighted pixels
|
// hilighted pixels
|
||||||
for (i = 0; i < 0x40 / 2; i++) {
|
for (i = 0; i < 0x40 / 2; i++) {
|
||||||
t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e; // 0x7bef7bef;
|
t = ((dpal[i] >> 1) & PXMASKH) + PXMASKH;
|
||||||
t |= (t >> 4) & 0x08610861;
|
t |= (t >> 4) & PXMASKL;
|
||||||
dpal[0x40/2 + i] = t;
|
dpal[0x40/2 + i] = t;
|
||||||
}
|
}
|
||||||
// shadowed pixels in color 14 always appear normal (hw bug?)
|
// shadowed pixels in color 14 always appear normal (hw bug?)
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
* See COPYING file in the top-level directory.
|
* See COPYING file in the top-level directory.
|
||||||
*
|
*
|
||||||
* this is highly specialized, be careful if changing related C code!
|
* this is highly specialized, be careful if changing related C code!
|
||||||
|
*
|
||||||
|
* NB only does RGB565 output, BGR555 isn't supported
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pico_int_offs.h"
|
#include "pico_int_offs.h"
|
||||||
|
|
|
@ -339,11 +339,11 @@ void PicoDoHighPal555M4(void)
|
||||||
t = *spal;
|
t = *spal;
|
||||||
#ifdef USE_BGR555
|
#ifdef USE_BGR555
|
||||||
t = ((t & 0x00030003)<< 3) | ((t & 0x000c000c)<<6) | ((t & 0x00300030)<<9);
|
t = ((t & 0x00030003)<< 3) | ((t & 0x000c000c)<<6) | ((t & 0x00300030)<<9);
|
||||||
|
t |= (t >> 2) | ((t >> 4) & 0x04210421);
|
||||||
#else
|
#else
|
||||||
t = ((t & 0x00030003)<<14) | ((t & 0x000c000c)<<7) | ((t & 0x00300030)>>1);
|
t = ((t & 0x00030003)<<14) | ((t & 0x000c000c)<<7) | ((t & 0x00300030)>>1);
|
||||||
|
t |= (t >> 2) | ((t >> 4) & 0x08610861);
|
||||||
#endif
|
#endif
|
||||||
t |= t >> 2;
|
|
||||||
t |= (t >> 4) & 0x08610861;
|
|
||||||
*dpal = t;
|
*dpal = t;
|
||||||
}
|
}
|
||||||
Pico.est.HighPal[0xe0] = 0;
|
Pico.est.HighPal[0xe0] = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue