Alright, so I've only recently started to mess around with programming for the wii and was working on a modification of SNEEK+DI to add cover display to the DI menu.
I started working on some code to load BMP files into memory since I've dealt with that elsewhere and the file format for them is pretty simple. But the wii seems to hang on my call to malloca to create space in memory to store the image data converted to the right format to display later in my code. The big problem is I don't own any of the special hardware needed to debug on the wii so it's quite frustrating
the changed code in ES module is here: http://www.mediafire.com/?n1gr093tvrdzn58 It's modified from r144
and the troublesome code where the hang happens in image.c:
CODEImageStruct* LoadBMP(u8* rawData, u32 size){
ÂÂÂÂif (size < sizeof(bmpfile_magic) + sizeof(bmpfile_header) + sizeof(bmp_dib_v3_header_t))
ÂÂÂÂÂÂÂÂreturn NULL;
ÂÂÂÂbmpfile_header* bmpHeader = (bmpfile_header*) &rawData[sizeof(bmpfile_magic)];
ÂÂÂÂbmp_dib_v3_header_t* dibHeader = (bmp_dib_v3_header_t*) &rawData[sizeof(bmpfile_magic) + sizeof(bmpfile_header)];
ÂÂÂÂif (dibHeader->header_sz != sizeof(bmp_dib_v3_header_t))
ÂÂÂÂÂÂÂÂreturn NULL; //wrong header type
ÂÂÂÂif (dibHeader->nplanes != 1)
ÂÂÂÂÂÂÂÂreturn NULL; //must only use 1 plane
ÂÂÂÂif (dibHeader->compress_type != BI_RGB)
ÂÂÂÂÂÂÂÂreturn NULL; //must be uncompressed
ÂÂÂÂs32 width, height;
ÂÂÂÂu8* imageData = bmpHeader->bmp_offset + rawData;
ÂÂÂÂwidth = dibHeader->width;
ÂÂÂÂif (width % 2)
ÂÂÂÂÂÂÂÂwidth += 1;
ÂÂÂÂu32 halfWidth = width / 2;
ÂÂÂÂheight = dibHeader->height;
ÂÂÂÂImageStruct* image = (ImageStruct*)malloc(sizeof(ImageStruct) + halfWidth * height * sizeof(u32)); //i think it's hanging on this allocation but I don't know why
ÂÂÂÂimage->width = width;
ÂÂÂÂimage->height = height;
ÂÂÂÂswitch (dibHeader->bitspp){
ÂÂÂÂÂÂÂÂcase 24:
ÂÂÂÂÂÂÂÂ{
ÂÂÂÂÂÂÂÂÂÂÂÂs32 x, y;
ÂÂÂÂÂÂÂÂÂÂÂÂu32 iy, ix;
ÂÂÂÂÂÂÂÂÂÂÂÂu32 bytesPerLine = width * 3;
ÂÂÂÂÂÂÂÂÂÂÂÂbytesPerLine += bytesPerLine % 4;
ÂÂÂÂÂÂÂÂÂÂÂÂiy = 0;
ÂÂÂÂÂÂÂÂÂÂÂÂfor (y = height - 1; y >= 0; y--){
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂix = 0;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfor (x = 0; x < width; x += 2){
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂu8* pixel1Data = &imageData[y * bytesPerLine + x * 3];
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂu8* pixel2Data;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (x + 1 != dibHeader->width)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂpixel2Data = &imageData[y * bytesPerLine + (x + 1) * 3];
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂelse
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂpixel2Data = pixel1Data;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂimage->imageData[iy * halfWidth + ix] = RGBtoYCbYCr(pixel1Data[2],pixel1Data[1],pixel1Data[0],pixel2Data[2],pixel2Data[1],pixel2Data[0]);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂix++;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ}
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂiy++;
ÂÂÂÂÂÂÂÂÂÂÂÂ}
ÂÂÂÂÂÂÂÂ} break;
ÂÂÂÂÂÂÂÂdefault: //unsupported colordepth
ÂÂÂÂÂÂÂÂÂÂÂÂfree(image);
ÂÂÂÂÂÂÂÂÂÂÂÂimage = NULL;
ÂÂÂÂÂÂÂÂÂÂÂÂbreak;
ÂÂÂÂ}
ÂÂÂÂreturn image;
}
Any help would be appreciated.
I started working on some code to load BMP files into memory since I've dealt with that elsewhere and the file format for them is pretty simple. But the wii seems to hang on my call to malloca to create space in memory to store the image data converted to the right format to display later in my code. The big problem is I don't own any of the special hardware needed to debug on the wii so it's quite frustrating
the changed code in ES module is here: http://www.mediafire.com/?n1gr093tvrdzn58 It's modified from r144
and the troublesome code where the hang happens in image.c:
CODEImageStruct* LoadBMP(u8* rawData, u32 size){
ÂÂÂÂif (size < sizeof(bmpfile_magic) + sizeof(bmpfile_header) + sizeof(bmp_dib_v3_header_t))
ÂÂÂÂÂÂÂÂreturn NULL;
ÂÂÂÂbmpfile_header* bmpHeader = (bmpfile_header*) &rawData[sizeof(bmpfile_magic)];
ÂÂÂÂbmp_dib_v3_header_t* dibHeader = (bmp_dib_v3_header_t*) &rawData[sizeof(bmpfile_magic) + sizeof(bmpfile_header)];
ÂÂÂÂif (dibHeader->header_sz != sizeof(bmp_dib_v3_header_t))
ÂÂÂÂÂÂÂÂreturn NULL; //wrong header type
ÂÂÂÂif (dibHeader->nplanes != 1)
ÂÂÂÂÂÂÂÂreturn NULL; //must only use 1 plane
ÂÂÂÂif (dibHeader->compress_type != BI_RGB)
ÂÂÂÂÂÂÂÂreturn NULL; //must be uncompressed
ÂÂÂÂs32 width, height;
ÂÂÂÂu8* imageData = bmpHeader->bmp_offset + rawData;
ÂÂÂÂwidth = dibHeader->width;
ÂÂÂÂif (width % 2)
ÂÂÂÂÂÂÂÂwidth += 1;
ÂÂÂÂu32 halfWidth = width / 2;
ÂÂÂÂheight = dibHeader->height;
ÂÂÂÂImageStruct* image = (ImageStruct*)malloc(sizeof(ImageStruct) + halfWidth * height * sizeof(u32)); //i think it's hanging on this allocation but I don't know why
ÂÂÂÂimage->width = width;
ÂÂÂÂimage->height = height;
ÂÂÂÂswitch (dibHeader->bitspp){
ÂÂÂÂÂÂÂÂcase 24:
ÂÂÂÂÂÂÂÂ{
ÂÂÂÂÂÂÂÂÂÂÂÂs32 x, y;
ÂÂÂÂÂÂÂÂÂÂÂÂu32 iy, ix;
ÂÂÂÂÂÂÂÂÂÂÂÂu32 bytesPerLine = width * 3;
ÂÂÂÂÂÂÂÂÂÂÂÂbytesPerLine += bytesPerLine % 4;
ÂÂÂÂÂÂÂÂÂÂÂÂiy = 0;
ÂÂÂÂÂÂÂÂÂÂÂÂfor (y = height - 1; y >= 0; y--){
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂix = 0;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfor (x = 0; x < width; x += 2){
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂu8* pixel1Data = &imageData[y * bytesPerLine + x * 3];
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂu8* pixel2Data;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (x + 1 != dibHeader->width)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂpixel2Data = &imageData[y * bytesPerLine + (x + 1) * 3];
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂelse
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂpixel2Data = pixel1Data;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂimage->imageData[iy * halfWidth + ix] = RGBtoYCbYCr(pixel1Data[2],pixel1Data[1],pixel1Data[0],pixel2Data[2],pixel2Data[1],pixel2Data[0]);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂix++;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ}
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂiy++;
ÂÂÂÂÂÂÂÂÂÂÂÂ}
ÂÂÂÂÂÂÂÂ} break;
ÂÂÂÂÂÂÂÂdefault: //unsupported colordepth
ÂÂÂÂÂÂÂÂÂÂÂÂfree(image);
ÂÂÂÂÂÂÂÂÂÂÂÂimage = NULL;
ÂÂÂÂÂÂÂÂÂÂÂÂbreak;
ÂÂÂÂ}
ÂÂÂÂreturn image;
}
Any help would be appreciated.