Code: Select all
#define VRAM_OFFSET ((512*280*4)*3)
// 0x198000
static unsigned int vramaddr = 0;
unsigned char *convertimage(unsigned char *inptr,int size)
{
// convert our raw image
// saved as raw. no header .. interleaved and order RGB
int x;
unsigned char *input = inptr;
unsigned char *output,*outptr;
int tsize = size*size;
if (vramaddr == 0)
vramaddr = (0x40000000 | 0x04000000) + VRAM_OFFSET;
outptr = output = (unsigned char *)vramaddr;
for (x=0;x<tsize;x++) {
*(outptr++) = *(input++);
*(outptr++) = *(input++);
*(outptr++) = *(input++);
*(outptr++) = 0xff;
}
vramaddr += tsize * 4;
if ((vramaddr & 0xff) != 0)
vramaddr = (vramaddr & 0xffffff00) + 0x100;
return output;
}
Code: Select all
unsigned int ramaddr = 0;
unsigned char *convertimageRAM(unsigned char *inptr,int size)
{
// convert our raw image
// saved as raw. no header .. interleaved and order RGB
//this function loads into RAM, not VRAM
int x;
unsigned char *input = inptr;
unsigned char *output,*outptr;
size_t sizediff;
sizediff = size;
int tsize = size*size;
if (ramaddr == 0)
ramaddr = (unsigned int)malloc(sizediff);
outptr = output = (unsigned char *)ramaddr;
for (x=0;x<tsize;x++) {
*(outptr++) = *(input++);
*(outptr++) = *(input++);
*(outptr++) = *(input++);
*(outptr++) = 0xff;
}
ramaddr += tsize * 4;
if ((ramaddr & 0xff) != 0)
ramaddr = (ramaddr & 0xffffff00) + 0x100;
return output;
}
Thanks.
EDIT:
Corrected Code:
Code: Select all
unsigned int ramaddr = 0;
unsigned char *convertimageRAM(unsigned char *inptr,int size)
{
// convert our raw image
// saved as raw. no header .. interleaved and order RGB
//this function loads into RAM, not VRAM
int x;
unsigned char *input = inptr;
unsigned char *output,*outptr;
size_t sizediff;
sizediff = size*size*4;
int tsize = size*size;
ramaddr = (unsigned int)memalign(16,sizediff);
outptr = output = (unsigned char *)ramaddr;
for (x=0;x<tsize;x++) {
*(outptr++) = *(input++);
*(outptr++) = *(input++);
*(outptr++) = *(input++);
*(outptr++) = 0xff;
}
return output;
}