I found now some time to work in the BennuGD PS2 port:
I detected some discordances between SDL port for PlayStation 2 and BennuGD port, and the way that BennuGD port
deals with RGB color:
-If we assume that the SDL port for PlayStation 2 is well made, or at least relatively well made based on actual SDL based games like
PS2PANG and La Abadia del Crimen, it can be easily deduced that the BennuGD port needs to be fixed in order to use the same color treatment
of his SDL port:
This piece of code is from BennuGD Play2 port, extracted from libdraw.c:
For a little Endian machine, this piece of code assume that red pixel byte is the most significant one, and
blue pixel byte is the less significant one.
_inline void _HLine32_nostipple( uint32_t * ptr, uint32_t length )
{
register int n ;
if ( pixel_alpha == 255 && ( pixel_color32 & 0xff000000 ) == 0xff000000 )
{
for ( n = length; n >= 0; n-- ) *ptr++ = pixel_color32 ;
}
else
{
unsigned int _f = pixel_color32 & 0xff000000, _f2 ;
unsigned int _c1, _c2, _c3 ;
unsigned int r, g, b ;
_f = ( _f >> 24 ) * pixel_alpha / 255 ;
_f2 = 255 - _f ;
if ( _f != 0x000000ff )
{
_c1 = ( pixel_color32 & 0x00ff0000 ) * _f ;
_c2 = ( pixel_color32 & 0x0000ff00 ) * _f ;
_c3 = ( pixel_color32 & 0x000000ff ) * _f ;
_f <<= 24 ;
for ( n = length; n >= 0; n-- )
{
r = ( _c1 + (( *ptr & 0x00ff0000 ) * _f2 ) ) >> 8 ;
g = ( _c2 + (( *ptr & 0x0000ff00 ) * _f2 ) ) >> 8 ;
b = ( _c3 + (( *ptr & 0x000000ff ) * _f2 ) ) >> 8 ;
if ( r > 0x00ff0000 ) r = 0x00ff0000 ; else r &= 0x00ff0000 ;
if ( g > 0x0000ff00 ) g = 0x0000ff00 ; else g &= 0x0000ff00 ;
if ( b > 0x000000ff ) b = 0x000000ff ; else b &= 0x000000ff ;
...
But this code from the SDL port for PlayStation 2 shows that SDL deals the blue byte color like the most significant one
for PlayStation 2, instead the BennuGD port that uses the red byte instead the blue one.
static int PS2_SetColors(SDL_VideoDevice *device, int firstcolor, int ncolors, SDL_Color *colors)
{
int i;
int rgb;
int offset;
int r, g, b;
for (i=0; i<ncolors; i++)
{
r = colors[i].r;
g = colors[i].g;
b = colors[i].b;
rgb = b << 16 | g << 8 | r << 0;
/* transform into clut's array */
I will study how to change this in the actual BennuGD port in the quickest possible way.
I think it is the problem with the colours, after fix this, we need to deal with the sound
that also has some troubles.