Welcome! Log In Create A New Profile

Advanced

Problems with fat

Posted by copete23 
Problems with fat
August 09, 2010 04:18PM
Hi, I'm having a strange problem with fat, when I try to upload a file from the SD, the system gives me an exception, and the program stops.
FatiIniDefault () has been initialized first (one time), and the path is correct, the strangest thing is that to make the program work, I have to run first snes GX (?), If I open snes gx, close, and then open my program, the program works well, I do not know why.

Anyone have any idea why this happens?

To open the file I'm doing the following:

FILE *fp=NULL;
fp = fopen("sd:/apps/.....","r");
if (fp != NULL)
{
............
}

Regards ;)
Re: Problems with fat
August 09, 2010 07:14PM
It sounds like you need a different SD Card as there is no other rational explanation for your problem.
Re: Problems with fat
August 10, 2010 04:35AM
Can you post all of your code. Also, are you sure that the problems with FAT, and not some other part of your code.
Re: Problems with fat
August 10, 2010 09:22PM
I don`t know, the code is very simple, to load the file i`m using this:

FILE* file= NULL;

fichero = fopen("sd:/apps/robo_tank/saves/data1.save", "r");

if (file != NULL)
{

rewind(file);
fread(&lev, sizeof(float), 1, file);
fclose(file);
}

i`ts all.

I think I may be make a mistake initializing gx, and conflicts with fat, because if I use grrlib, it don`t gives me this error and fat work.

this my gx ini code:

void ini(){

fb = 0;
first_frame = 1;
VIDEO_Init();
CONF_Init();

rmode = VIDEO_GetPreferredMode(NULL);

if (CONF_GetAspectRatio() == CONF_ASPECT_16_9) {
rmode->viWidth = VI_MAX_WIDTH_PAL - 12;
rmode->viXOrigin = ((VI_MAX_WIDTH_PAL - rmode->viWidth) / 2) + 2;
}


// configure video
VIDEO_Configure(rmode);
// allocate 2 framebuffers for double buffering
frameBuffer[0] =(u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer(rmode));
frameBuffer[1] =(u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer(rmode));
if(frameBuffer[0] == NULL || frameBuffer[1] == NULL)
return;


VIDEO_SetNextFramebuffer(frameBuffer[0]);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

if(gpfifo == NULL)
return;

memset(gpfifo,0,DEFAULT_FIFO_SIZE);
// init the flipper
GX_Init(gpfifo,DEFAULT_FIFO_SIZE);



// clears the bg to color and clears the z buffer
GXColor background = { 0, 0, 0, 0xff };
GX_SetCopyClear (background, GX_MAX_Z24);

// other gx setup

yscale = GX_GetYScaleFactor(rmode->efbHeight,rmode->xfbHeight);
xfbHeight = GX_SetDispCopyYScale(yscale);
GX_SetScissor(0,0,rmode->fbWidth,rmode->efbHeight);
GX_SetDispCopySrc(0,0,rmode->fbWidth,rmode->efbHeight);
GX_SetDispCopyDst(rmode->fbWidth,xfbHeight);
GX_SetCopyFilter(rmode->aa,rmode->sample_pattern,GX_TRUE,rmode->vfilter);
GX_SetFieldMode(rmode->field_rendering,((rmode->viHeight==2*rmode->xfbHeight)?GX_ENABLE:GX_DISABLE));



if (rmode->aa)
GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR);
else
GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);

GX_SetCullMode(GX_CULL_NONE);
GX_CopyDisp(frameBuffer[fb],GX_TRUE);
GX_SetDispCopyGamma(GX_GM_1_0);

GX_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1);
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
GX_SetColorUpdate(GX_ENABLE);
GX_SetAlphaUpdate(GX_ENABLE);
GX_SetZCompLoc(GX_FALSE);
GX_SetClipMode(GX_CLIP_DISABLE);

GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE);

GX_SetNumChans(1);
GX_SetNumTexGens(1);
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);


VIDEO_ClearFrameBuffer (rmode, frameBuffer[0], COLOR_BLACK);
VIDEO_ClearFrameBuffer (rmode, frameBuffer[1], COLOR_BLACK);
VIDEO_SetNextFramebuffer (frameBuffer[0]);
VIDEO_SetBlack(false);


}



Edited 1 time(s). Last edit at 08/10/2010 09:55PM by Arikado.
Re: Problems with fat
August 10, 2010 09:53PM
use
 tags please.
Re: Problems with fat
August 11, 2010 01:48AM
Try running your program and comment out the gx part. That will tell you if the problem is with gx.
Re: Problems with fat
August 14, 2010 10:04PM
Quote
copete23
I don`t know, the code is very simple, to load the file i`m using this:

FILE* file= NULL;

fichero = fopen("sd:/apps/robo_tank/saves/data1.save", "r");

if (file != NULL)
{

rewind(file);
fread(&lev, sizeof(float), 1, file);
fclose(file);
}

I could beat you are not using that - exact - code but just in case... why did you write "fichero" there? Once again I don't think that's the problem, specially because of your description of the problem.
Re: Problems with fat
August 19, 2010 04:18AM
Hi, I've tried everything and I do not get it to work, I tried to comment out the gx, the wpad, and the sound, and nothing, I did not know what to do :(
I'm using c + +, can be what causes the problem? Why if I run snesgx first, does it work?

Any ideas?
Re: Problems with fat
August 19, 2010 05:21PM
try using a debugger, that way you would know exactly what your problem is.
Re: Problems with fat
August 19, 2010 07:19PM
How I can do that?
Sorry, only registered users may post in this forum.

Click here to login