Code: Select all
Width of Textures/Floor.bmp: 128
Height of Textures/Floor.bmp:
128
Width of Textures/Sky.bmp: 128
Height of Textures/Sky.bmp: 128
Exception - Add
ress store
Thread ID - 0x04931421
Th Name - user_main
Module ID - 0x0493D22F
Mod Name - blah
EPC - 0x08912BE4
Cause - 0x00000014
BadVAddr - 0xAE278611
Status - 0x60008613
zr:0x00000000 at:0x0008FF00 v0:0x00000080 v1:0x00000001
a0:0xAE27860E a1:0x08949466 a2:0x00000000 a3:0x00000001
t0:0x882D9920 t1:0x00000000 t2:0x00000490 t3:0xAE27860E
t4:0x09EFFD28 t5:0x00000E00 t6:0x089176D8 t7:0x00008600
s0:0x089306B4 s1:0x000003EE s2:0x00000004 s3:0x089306B4
s4:0xAE27860E s5:0x00000004 s6:0x00000001 s7:0x00000004
t8:0x0000029B t9:0x000002A8 k0:0x09EFFF00 k1:0x00000000
gp:0x08928170 sp:0x09EFFD80 fp:0x09EFFEA0 ra:0x08911548
Code: Select all
$ psp-addr2line -fe blah.elf 0x08912BE4
memcpy
../../../../../../newlib/libc/machine/mips/memcpy.c:146
$ psp-addr2line -fe blah.elf 0x08911548
fread
../../../../../newlib/libc/stdio/fread.c:210
Code: Select all
int LoadBMP(char *filename, Image *image) {
FILE *file;
unsigned long size; // size of the image in bytes.
unsigned long i; // standard counter.
unsigned short int planes; // number of planes in image (must be 1)
unsigned short int bpp; // number of bits per pixel (must be 24)
char temp; // used to convert bgr to rgb color.
// make sure the file is there.
if ((file = fopen(filename, "rb"))==NULL)
{
printf("File Not Found : %s\n",filename);
return 0;
}
// seek through the bmp header, up to the width/height:
fseek(file, 18, SEEK_CUR);
// read the width
if ((i = fread(&image->sizeX, 4, 1, file)) != 1) {
printf("Error reading width from %s.\n", filename);
return 0;
}
printf("Width of %s: %lu\n", filename, image->sizeX);
// read the height
if ((i = fread(&image->sizeY, 4, 1, file)) != 1) {
printf("Error reading height from %s.\n", filename);
return 0;
}
printf("Height of %s: %lu\n", filename, image->sizeY);
// calculate the size (assuming 24 bits or 3 bytes per pixel).
size = image->sizeX * image->sizeY * 3;
// read the planes
if ((fread(&planes, 2, 1, file)) != 1) {
printf("Error reading planes from %s.\n", filename);
return 0;
}
if (planes != 1) {
printf("Planes from %s is not 1: %u\n", filename, planes);
return 0;
}
// read the bpp
if ((i = fread(&bpp, 2, 1, file)) != 1) {
printf("Error reading bpp from %s.\n", filename);
return 0;
}
if (bpp != 24) {
printf("Bpp from %s is not 24: %u\n", filename, bpp);
return 0;
}
// seek past the rest of the bitmap header.
fseek(file, 24, SEEK_CUR);
// read the data.
image->data = (char *) malloc(size);
if (image->data == NULL) {
printf("Error allocating memory for color-corrected image data");
return 0;
}
if ((i = fread(image->data, size, 1, file)) != 1) {
printf("Error reading image data from %s.\n", filename);
return 0;
}
for (i=0;i<size;i+=3) { // reverse all of the colors. (bgr -> rgb)
temp = image->data[i];
image->data[i] = image->data[i+2];
image->data[i+2] = temp;
}
// we're done.
return 1;
}
I dont see how the exception could be in something i never even touched... But it did say fread and i did use fread in my LoadBMP so its somtehing in there... Im trying to load 5 textures, and its onlyloading the sky and floor...
Any suggestions?