| View previous topic :: View next topic |
| Author |
Message |
starman2049
Joined: 19 Sep 2005 Posts: 75
|
Posted: Mon Sep 19, 2005 6:14 am Post subject: Alignment and debug question |
|
|
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 |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Mon Sep 19, 2005 6:56 am Post subject: |
|
|
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 |
|
 |
starman2049
Joined: 19 Sep 2005 Posts: 75
|
Posted: Mon Sep 19, 2005 7:22 am Post subject: Resolved |
|
|
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 |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Mon Sep 19, 2005 7:26 am Post subject: |
|
|
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 |
|
 |
weak
Joined: 13 Jan 2005 Posts: 114 Location: Vienna, Austria
|
Posted: Mon Sep 19, 2005 7:27 am Post subject: Re: Alignment and debug question |
|
|
| 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 |
|
 |
weak
Joined: 13 Jan 2005 Posts: 114 Location: Vienna, Austria
|
Posted: Mon Sep 19, 2005 7:46 am Post subject: |
|
|
| 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 |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Mon Sep 19, 2005 11:24 am Post subject: |
|
|
| 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 |
|
 |
starman2049
Joined: 19 Sep 2005 Posts: 75
|
Posted: Mon Sep 19, 2005 11:42 am Post subject: Performance |
|
|
| 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 |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Mon Sep 19, 2005 12:00 pm Post subject: |
|
|
| The SDK available here is pretty close to being the pro SDK with some holes here and there. |
|
| Back to top |
|
 |
|