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 

SDL_Init - Out of memory

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



Joined: 19 Oct 2007
Posts: 3

PostPosted: Fri Oct 19, 2007 8:14 pm    Post subject: SDL_Init - Out of memory Reply with quote

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
View user's profile Send private message
.::Albandu51::.



Joined: 04 Oct 2007
Posts: 12

PostPosted: Fri Oct 19, 2007 8:41 pm    Post subject: Reply with quote

Code:
screen = SDL_SetVideoMode(480, 272, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
^^
Back to top
View user's profile Send private message
FragassRock



Joined: 19 Oct 2007
Posts: 3

PostPosted: Fri Oct 19, 2007 8:52 pm    Post subject: Reply with quote

I agree for the SDL_SetVideoMode but the error appears before on the SDL_Init(SDL_INIT_VIDEO)...
Back to top
View user's profile Send private message
aeolusc



Joined: 14 Oct 2006
Posts: 18

PostPosted: Fri Oct 19, 2007 9:13 pm    Post subject: Reply with quote

update to the latest pspsdk and try:
Code:
PSP_HEAP_SIZE_MAX();

or
Code:
PSP_HEAP_SIZE_KB(-1);
Back to top
View user's profile Send private message
FragassRock



Joined: 19 Oct 2007
Posts: 3

PostPosted: Fri Oct 19, 2007 9:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
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