Alignment and debug question

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

Moderators: cheriff, TyRaNiD

Post Reply
starman2049
Posts: 75
Joined: Mon Sep 19, 2005 5:41 am

Alignment and debug question

Post by starman2049 »

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???
CyberBill
Posts: 86
Joined: Tue Jul 26, 2005 3:53 pm
Location: Redmond, WA

Post by CyberBill »

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...
starman2049
Posts: 75
Joined: Mon Sep 19, 2005 5:41 am

Resolved

Post by starman2049 »

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.
CyberBill
Posts: 86
Joined: Tue Jul 26, 2005 3:53 pm
Location: Redmond, WA

Post by CyberBill »

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.
weak
Posts: 114
Joined: Thu Jan 13, 2005 8:31 pm
Location: Vienna, Austria

Re: Alignment and debug question

Post by weak »

starman2049 wrote:So I wrote a memalign() function ...
just use the std implementation:

#include <stdlib.h>
void *memalign(size_t blocksize, size_t bytes);
weak
Posts: 114
Joined: Thu Jan 13, 2005 8:31 pm
Location: Vienna, Austria

Post by weak »

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.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

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.
starman2049
Posts: 75
Joined: Mon Sep 19, 2005 5:41 am

Performance

Post by starman2049 »

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?
CyberBill
Posts: 86
Joined: Tue Jul 26, 2005 3:53 pm
Location: Redmond, WA

Post by CyberBill »

The SDK available here is pretty close to being the pro SDK with some holes here and there.
Post Reply