16-bit graphics mode.. I'm blowing it somewhere :)

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
skeezixcodejedi
Posts: 29
Joined: Tue Aug 30, 2005 10:37 am
Contact:

16-bit graphics mode.. I'm blowing it somewhere :)

Post by skeezixcodejedi »

hey all,

I generally write most of my code to be cross platform, and my latest little puzzler game is no exception; runs fine on Palm OS, Pocket PC, Windows and others; my PSP port is showing up with nasty colours though, so something is funked up for me :)

For my CaSTaway project I'm using 4444 mode with no problems (since the Atari ST has 444 colour itself, this works well); for Manticore here, I'm using 16bit colour on all platforms. (ie: RGB-565 for instance, whatever the platform needs.. but internally its stored in RGB-565 format.)

When using 16bit mode, things always show up but all tinted nastily.

Some code snippets..

setting up:

if ( g_screen_is4444 ) {
sceGuDrawBuffer(GU_PSM_4444,(void*)0,512);
} else {
sceGuDrawBuffer(GU_PSM_5650,(void*)0,512);
}

Blit code:

if ( g_screen_is4444 ) {
sceGuTexMode ( GU_PSM_4444, 0, 0, 0 );
} else {
sceGuTexMode ( GU_PSM_5650, 0, 0, 0 );
}
sceGuTexImage ( 0, 512, 512, 512, pixels );
sceGuTexFunc ( GU_TFX_REPLACE, GU_TCC_RGB );
sceGuTexFilter ( GU_NEAREST, GU_NEAREST );
sceGuTexScale ( 1.0f/512.0f, 1.0f/512.0f ); // scale UVs to 0..1
sceGuTexOffset ( 0.0f, 0.0f );
sceGuAmbientColor ( 0xffffffff );

// do a striped blit (takes the page-cache into account)
unsigned char stripe = 0;
for ( j = 0; j < 480; j = j+SLICE_SIZE ) {
//vertex_t *vertices = g_vertices + ( 2 * stripe );
vertex_t *vertices = (vertex_t*)sceGuGetMemory(2 * sizeof(vertex_t));

vertices[0].u = j; vertices[0].v = 0;
vertices[0].color = 0;
vertices[0].x = j; vertices[0].y = 0; vertices[0].z = 0;
vertices[1].u = j+SLICE_SIZE; vertices[1].v = 272;
vertices[1].color = 0;
vertices[1].x = j+SLICE_SIZE; vertices[1].y = 272; vertices[1].z = 0;

sceGuDrawArray ( GU_SPRITES,
GU_TEXTURE_16BIT | GU_COLOR_4444 /*565*/ | GU_VERTEX_16BIT |
GU_TRANSFORM_2D, 2, 0, vertices );

sceKernelDcacheWritebackInvalidateAll();
//sceKernelDcacheWritebackAll();

stripe++;
} // for

(note I do fix the 565 inthe GuDrawArray)

So in 4444 everything works, but all borked up. (some things with very low colour usage work fine, others are a total mess.)

I'm sure its a totallly ovious mistake.. let me know so I can whip myself :)

jeff
--
Have you played Atari today?
Paco
Posts: 54
Joined: Sun Oct 09, 2005 6:53 pm

Post by Paco »

Make sure you set up the DrawBuffer format before calling sceGuDisplayBuffer or whatever the name is... the pixel format for the video mode in the Display call is taken from the (previous) call to sceGuDrawBuffer().
Paco
Post Reply