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 

Alignment and debug question

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



Joined: 19 Sep 2005
Posts: 75

PostPosted: Mon Sep 19, 2005 6:14 am    Post subject: Alignment and debug question Reply with quote

I am porting an existing 3D (PS2) game to PSP and have been having some problems with alignment. My first problem came when I tried to load in my level file. It appears to me that things go wrong when sceIoRead() is called with a read buffer address that is not 16 byte aligned. So I wrote a memalign() function that makes sure the address returned from malloc is 16 byte aligned (by overallocating by 15 bytes, and adjusting the start address). Now my level loading code coes not crash.

The problem is now that it is loaded I try to read from the buffer and the game crashes. Has anyone had similiar problems with reading from buffers loaded from memory card?

I am new to PSP, so also I wanted to ask what people are doing for debug display/feedback. I am building my code off of the gu/cube sample code and pspDebugScreenPrintf() doesn't seem to display anything so I am assuming this is for text mode vs graphics mode???
Back to top
View user's profile Send private message
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Mon Sep 19, 2005 6:56 am    Post subject: Reply with quote

As far as I know, sceIoRead() doesnt need to be 16byte aligned... I could be wrong though. (Maybe I'm just getting lucky with my allocs, heh)

Reading from a buffer and having the game crash is a sure sign of reading from a bad location in memory.

I could be more helpful if I could see some code...
Back to top
View user's profile Send private message AIM Address MSN Messenger
starman2049



Joined: 19 Sep 2005
Posts: 75

PostPosted: Mon Sep 19, 2005 7:22 am    Post subject: Resolved Reply with quote

Looking around more it looks like the issue was that I was trying to read from memory stick without the full path "ms0:/PSP/GAME/..."

Since I don't have debug display yet I must have been mis-interpreting return values to make me think that the read buffer needed to be 16 byte aligned.
Back to top
View user's profile Send private message
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Mon Sep 19, 2005 7:26 am    Post subject: Reply with quote

Ahh yes. You cant open just "file.ext"... must be FULL PATH. Kinda sucks, really. It would be nice to have multiple games in whatever directory you want.

I think there are functions which return the path of the current executable/module though, which would be kinda nice.
Back to top
View user's profile Send private message AIM Address MSN Messenger
weak



Joined: 13 Jan 2005
Posts: 114
Location: Vienna, Austria

PostPosted: Mon Sep 19, 2005 7:27 am    Post subject: Re: Alignment and debug question Reply with quote

starman2049 wrote:
So I wrote a memalign() function ...


just use the std implementation:

#include <stdlib.h>
void *memalign(size_t blocksize, size_t bytes);
Back to top
View user's profile Send private message
weak



Joined: 13 Jan 2005
Posts: 114
Location: Vienna, Austria

PostPosted: Mon Sep 19, 2005 7:46 am    Post subject: Reply with quote

CyberBill wrote:

I think there are functions which return the path of the current executable/module though, which would be kinda nice.


the path of the current executable is passed as argv[0] to the main function.
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Mon Sep 19, 2005 11:24 am    Post subject: Reply with quote

CyberBill wrote:
Ahh yes. You cant open just "file.ext"... must be FULL PATH. Kinda sucks, really. It would be nice to have multiple games in whatever directory you want.


You can just open "file.ext", if it is in the same directory where your EBOOT.PBP is, at least with the current PSPSDK from SVN.
Back to top
View user's profile Send private message
starman2049



Joined: 19 Sep 2005
Posts: 75

PostPosted: Mon Sep 19, 2005 11:42 am    Post subject: Performance Reply with quote

The SDK has the appearance of being directly in line with the "pro" SDK. Is this the case, or is the SDK available here a wrapper or some sort of emulation?
Back to top
View user's profile Send private message
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Mon Sep 19, 2005 12:00 pm    Post subject: Reply with quote

The SDK available here is pretty close to being the pro SDK with some holes here and there.
Back to top
View user's profile Send private message AIM Address 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