fscanf trouble

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
Conflict
Posts: 8
Joined: Wed May 11, 2005 9:00 am
Location: UK, York

fscanf trouble

Post by Conflict »

hello, I am somewhat new here but have been following PSP development here for many many months.

I have commenced a project and at the moment i am experimenting with implementing a ASE loader for the PSP.

I am currently having trouble however using fscanf to readin a single string is causing my psp to hang and shutdown.

Code: Select all

int main(int argc, char* argv[])
{
	FILE *fd_in;
	int fd;
	//int bytes_in = 0;
	char msg[20]  = "OK";
	char data_in[128] = "";

	if(!(fd = sceIoOpen("ms0:/PSP/GAME/3dshooter/cube.ase", PSP_O_RDONLY, 0777)))
	{
       strcpy(msg, "file IO error");
	}

	fd_in = (FILE *)fd;
	fscanf(fd_in, "%s", data_in);
	...
	...
	...	
With the fscanf line commented the app loads fine and enters the main render loop.

I have tried many things to resolve this to no avail.

Thanks in advance for help

::lee
<,<;
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

You can't cast the result of sceIoOpen to a FILE *. You should use fopen() to get a FILE * instead, if you're intending to use fscanf.

Jim
User avatar
Conflict
Posts: 8
Joined: Wed May 11, 2005 9:00 am
Location: UK, York

Post by Conflict »

ahh rightio, yea i got the (FILE *) casting from inspecting the PSPquake src, they defined their own fopen to return (FILE *)fd, must have missed something.

i wasn't sure if fopen was possible with PSPdev, should have tried it really what i newbie i must look. ;D

Anyway kudos Jim :>

...Been working all day with fscanf on loading a ASE file, got it working very well, only loads ASEs which are one object at the momment, loads all vertex, face and UV info and renders to screen fine. I "pushed" it with a 3000k tris ASE and still going at 60fps :>

Thanks again!
<,<;
Post Reply