I've decided to go back to DC programming after some time. i've ported a new PC game engine to Dreamcast, it's much better than my old one I posted here long ago, but I seem to be having a strange problem.
images look like crap on DC even tho they look fine in any paint prog etc.
I've attached a sample image of how an 8 or 16 bit would look on DC compared to original PNG file
Here's the image loading/displaying code I learned here before that i'm using:
Code: Select all
pvr_ptr_t LoadPVRImage(const char* img,uint32 alpha, int w, int h)
{
pvr_ptr_t dst;
dst=pvr_mem_malloc(w*h*2);
png_to_texture(img, dst, alpha);
return dst;
}
void DrawPVRImage(pvr_ptr_t img, int x, int y, int z,uint32 width, uint32 height, int index, float r, float g, float b, float a, uint32 txw, uint32 txh, int sx, int sy)
{
int cx, cy;
float inc_x = ((float)width/(float)txw);
float inc_y = ((float)height/(float)txh);
float index_x;
float index_y = 1;
int tiles_wide = (txw/width);
if(sx>0) {sx-=width;}
if(sy>0) {sy-=height;}
cx=x+width+sx;
cy=y+height+sy;
if(cx<0) {return;}
if(cy<0) {return;}
if(x>640) {return;}
if(y>480) {return;}
while(index >= tiles_wide * index_y)
{
index_y++;
}
index_y--;
index_x = index - (tiles_wide*index_y);
pvr_poly_cxt_t cxt;
pvr_poly_hdr_t hdr;
pvr_vertex_t vert;
pvr_poly_cxt_txr(&cxt,PVR_LIST_TR_POLY,PVR_TXRFMT_ARGB4444,txw,txh,img,PVR_FILTER_NONE);
pvr_poly_compile(&hdr,&cxt);
pvr_prim(&hdr,sizeof(hdr));
vert.argb = PVR_PACK_COLOR(a,r,g,b);
vert.oargb = 0;
vert.flags = PVR_CMD_VERTEX;
vert.x = x;
vert.y = y;
vert.z = z;
vert.u = index_x*inc_x;
vert.v = index_y*inc_y;
pvr_prim(&vert,sizeof(vert));
vert.x = x + width+sx;
vert.y = y;
vert.z = z;
vert.u = index_x*inc_x+inc_x;
vert.v = index_y*inc_y;
pvr_prim(&vert,sizeof(vert));
vert.x = x;
vert.y = y + height+sy;
vert.z = z;
vert.u = index_x*inc_x;
vert.v = index_y*inc_y+inc_y;
pvr_prim(&vert,sizeof(vert));
vert.x = x + width+sx;
vert.y = y + height+sy;
vert.z = z;
vert.u = index_x*inc_x+inc_x;
vert.v = index_y*inc_y+inc_y;
vert.flags = PVR_CMD_VERTEX_EOL;
pvr_prim(&vert, sizeof(vert));
}
does anyone know why this might be happening??