The reason that this code:
Code:
void openFile(char *PATH, color_t *data, int width, int height){
char databuf[5];
unsigned short buffer[sizeof(PATH)*2];
Bfile_StrToName_ncpy(buffer, (unsigned char*)PATH, strlen(PATH)+1);
int hFile = Bfile_OpenFile_OS(buffer, 0);
for(int i = 0; i < height; i++){
for(int j = 0; j < width; j++){
ProgressBar((i*width)+j, width*height);
Bfile_ReadFile_OS(hFile, databuf, 5, ((i*width+j)+2)*5);
data[(i*width+j)] = strtol(databuf, NULL, 10);
}
}
Bfile_CloseFile_OS(hFile);
return;
}
is failing is because of this line is your problem
Code:
unsigned short buffer[sizeof(PATH)*2];
The first problem is that sizeof(x) does not get the length of the string it gets the size of the pointer. Use strlen instead. Anther issue is that it is failing is because arrays need to be static unless you are using C99. If you are not using C99 then you must use either malloc or alloca() In this case if you are careful I would recommend alloca() as it is automatically freeded after the function returns and I read that the casio prizm has a larger stack compared with heap.
With that in mind you can change
Code:
unsigned short buffer[sizeof(PATH)*2];
to
Code:
unsigned short * buffer = alloca(2*(strlen(PATH)+1));
Also I noticed in some of your other code you you did not free memory returned by malloc you MUST do that when you are done with the memory. It is very importan.
Also I think you may need to change
Code:
Bfile_StrToName_ncpy(buffer, (unsigned char*)PATH, strlen(PATH)+1);
to
Code:
Bfile_StrToName_ncpy(buffer, (unsigned char*)PATH, strlen(PATH));