forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

fscanf trouble

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Conflict



Joined: 11 May 2005
Posts: 8
Location: UK, York

PostPosted: Sat Feb 04, 2006 9:28 am    Post subject: fscanf trouble Reply with quote

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:

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
_________________
<,<;
Back to top
View user's profile Send private message MSN Messenger
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sat Feb 04, 2006 2:31 pm    Post subject: Reply with quote

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
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Conflict



Joined: 11 May 2005
Posts: 8
Location: UK, York

PostPosted: Sun Feb 05, 2006 6:20 am    Post subject: Reply with quote

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!
_________________
<,<;
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group