 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
FragassRock
Joined: 19 Oct 2007 Posts: 3
|
Posted: Fri Oct 19, 2007 8:14 pm Post subject: SDL_Init - Out of memory |
|
|
Hello everyone,
I try to convert the AtariST emulator 'Hatari' written with SDL on PSP (I have a PSP S&L). Now the program build and run but hang on SDL_Init with an 'out of memory' error...
Here is a small piece of code wich work when builded alone :
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include "SDL.h"
# ifdef PSPFW3X
PSP_MODULE_INFO("SDLHelloWorld", 0x0, 1, 1);
PSP_HEAP_SIZE_KB(6*1024);
# else
PSP_MODULE_INFO("SDLHelloWorld", 0x1000, 1, 1);
# endif
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_MAIN_THREAD_STACK_SIZE_KB(32);
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define SCREEN_DEPTH 8
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main(int argc, char *argv[]) {
pspDebugScreenInit();
SetupCallbacks();
pspDebugScreenPrintf("HatariPSP v0.95\n");
SDL_Surface *screen;
SDL_Surface *bmp;
SDL_Rect targetarea;
/* Initialize SDL */
if(SDL_Init(SDL_INIT_VIDEO) < 0)
{
pspDebugScreenPrintf("Could not initialize the SDL library:\n %s\n", SDL_GetError() );
sceKernelSleepThread();
return 0;
}
/* Initialize the screen / window */
screen = SDL_SetVideoMode(320, 240, 8, SDL_SWSURFACE);
/* Load test.bmp */
bmp = SDL_LoadBMP("test.bmp");
/* Draw the image to 10, 20 */
targetarea.x = 0;
targetarea.y = 0;
targetarea.w = bmp->w;
targetarea.h = bmp->h;
SDL_BlitSurface(bmp, NULL, screen, &targetarea);
/* update the screen (aka double buffering) */
SDL_Flip(screen);
sceKernelSleepThread();
}
When I replace the Hatari's main by this one, the error pops. I'm building for a 3.71-2 firmware. I think that the size difference between the two eboot (3MB for Hatari and 390 KB for the test) has some influence...
Does anyone have any clue? |
|
| Back to top |
|
 |
.::Albandu51::.
Joined: 04 Oct 2007 Posts: 12
|
Posted: Fri Oct 19, 2007 8:41 pm Post subject: |
|
|
| Code: | | screen = SDL_SetVideoMode(480, 272, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); | ^^ |
|
| Back to top |
|
 |
FragassRock
Joined: 19 Oct 2007 Posts: 3
|
Posted: Fri Oct 19, 2007 8:52 pm Post subject: |
|
|
| I agree for the SDL_SetVideoMode but the error appears before on the SDL_Init(SDL_INIT_VIDEO)... |
|
| Back to top |
|
 |
aeolusc
Joined: 14 Oct 2006 Posts: 18
|
Posted: Fri Oct 19, 2007 9:13 pm Post subject: |
|
|
update to the latest pspsdk and try:
| Code: | | PSP_HEAP_SIZE_MAX(); |
or
| Code: | | PSP_HEAP_SIZE_KB(-1); |
|
|
| Back to top |
|
 |
FragassRock
Joined: 19 Oct 2007 Posts: 3
|
Posted: Fri Oct 19, 2007 9:50 pm Post subject: |
|
|
| aeolusc wrote: | update to the latest pspsdk and try:
| Code: | | PSP_HEAP_SIZE_MAX(); |
or
| Code: | | PSP_HEAP_SIZE_KB(-1); |
|
Thanks it work! |
|
| Back to top |
|
 |
|
|
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
|