"Ok, easy, just need to convert my bitmap image to 32 bit values now, and let know the psp i'm using a 32 bits texture, mwhahahah".
Well, doesn't work, and obviously I'm missing a very obvious thing there. :/
So, time for the boring part : TEH code !!
Here's my GU initialisation :
Code: Select all
#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)
#define PIXEL_SIZE (4) /* change this if you change to another screenmode */
#define FRAME_SIZE (BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE)
#define ZBUF_SIZE (BUF_WIDTH SCR_HEIGHT * 2) /* zbuffer seems to be 16-bit? */
sceGuInit();
// setup
sceGuStart(GU_DIRECT,list);
sceGuDrawBuffer(GU_PSM_8888,(void*)0,BUF_WIDTH);
sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)FRAME_SIZE,BUF_WIDTH);
sceGuDepthBuffer((void*)(FRAME_SIZE*2),BUF_WIDTH);
sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
sceGuDepthRange(0xc350,0x2710);
sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
sceGuEnable(GU_SCISSOR_TEST);
sceGuFrontFace(GU_CW);
sceGuEnable(GU_TEXTURE_2D);
sceGuEnable(GU_BLEND);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
sceGuFinish();
sceGuSync(0,0);
sceDisplayWaitVblankStart();
sceGuDisplay(GU_TRUE);
Code: Select all
void paint(long dt)
{
sceGuStart(GU_DIRECT,list);
// clear screen
sceGuClearColor(0xff000000);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
// setup blend-mode
sceGuBlendFunc(GU_ADD,GU_SRC_ALPHA,GU_ONE_MINUS_SRC_ALPHA,0,0);
sceGuColor(0xffffffff);
// Setup and render Tile Map
setupTileMapTexture(&tilemap) ;
bltTileMapRot90(&tilemap) ;
// FPS
pspDebugScreenSetXY(0,0);
pspDebugScreenPrintf("fps=%ld", 1000/dt);
sceGuFinish();
sceGuSync(0,0);
// sceDisplayWaitVblankStart();
sceGuSwapBuffers();
}
Code: Select all
void setupTileMapTexture(tilemap_t* tmap)
{
sceGuTexMode(GU_PSM_8888,0,0,0);
sceGuTexImage(0,tmap->image_width,tmap->image_height,tmap->image_width,(tmap->image));
sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA);
sceGuTexFilter(GU_NEAREST,GU_NEAREST);
sceGuTexScale(1,1);
sceGuTexOffset(0,0);
}
Code: Select all
void bltTileMapRot90(tilemap_t* tmap)
{
int i,j, index, nbprim ;
struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * tmap->width * tmap->height * sizeof(struct Vertex));
index = 0 ;
nbprim = 0 ;
for (i=0; i<tmap->width; i++)
for (j=0; j<tmap->height; j++)
{
int tile = tmap->tilemap[i+j*tmap->width] ;
int tilex = (tile-1)%tmap->tiles_width ;
int tiley = (tile-1)/tmap->tiles_width ;
if (tile < 0)
{
// Animated Tile
int atile = -tile-1 ;
if (atile < tmap->anims_number)
{
atile = tmap->animated_tiles[atile].frames[tmap->animated_tiles[atile].curr_frame] ;
tilex = (atile-1)%tmap->tiles_width ;
tiley = (atile-1)/tmap->tiles_width ;
vertices[index<<1].u = tilex*tmap->frame_width; vertices[index<<1].v = tiley*tmap->frame_height;
vertices[index<<1].x = SCREENWIDTH-(tmap->y>>16)-j*tmap->frame_width; vertices[index<<1].y = (tmap->x>>16)+i*tmap->frame_height; vertices[index<<1].z = 0;
vertices[(index<<1)+1].u = vertices[index<<1].u+tmap->frame_width; vertices[(index<<1)+1].v = vertices[index<<1].v+tmap->frame_height;
vertices[(index<<1)+1].x = vertices[index<<1].x-tmap->frame_height; vertices[(index<<1)+1].y = vertices[index<<1].y+tmap->frame_width; vertices[(index<<1)+1].z = 0;
index++ ;
nbprim++ ;
}
}
else if (tile != 0)
{
vertices[index<<1].u = tilex*tmap->frame_width; vertices[index<<1].v = tiley*tmap->frame_height;
vertices[index<<1].x = SCREENWIDTH-(tmap->y>>16)-j*tmap->frame_width; vertices[index<<1].y = (tmap->x>>16)+i*tmap->frame_height; vertices[index<<1].z = 0;
vertices[(index<<1)+1].u = vertices[index<<1].u+tmap->frame_width; vertices[(index<<1)+1].v = vertices[index<<1].v+tmap->frame_height;
vertices[(index<<1)+1].x = vertices[index<<1].x-tmap->frame_height; vertices[(index<<1)+1].y = vertices[index<<1].y+tmap->frame_width; vertices[(index<<1)+1].z = 0;
index++ ;
nbprim++ ;
}
}
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2 * nbprim,0,vertices);
}
Can anyone see my big and shamefull and evident mistake ?? ^^