Sdl application not starting (error code : 8002013C)

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

Moderators: cheriff, TyRaNiD

Post Reply
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Sdl application not starting (error code : 8002013C)

Post by PosX100 »

What title says.
This is the first time that an application not starting.

I've been searching on forums for more than a hour, but i couldn't find a solution.


CFW : 3.71 m33-4 (kernel : 1.5)

My code:

Code: Select all

	#include <SDL/SDL.h>
	#include <pspkernel.h>
	#include <pspctrl.h>
	#include <pspdebug.h>
	//#include <pspaudio.h>
	//#include <pspaudiolib.h>
	#include <pspdisplay.h>
	#include <psppower.h>

 
	PSP_MODULE_INFO&#40;"SDLtest 1", 0x0, 1, 1&#41;;

	PSP_HEAP_SIZE_MAX&#40;&#41;;//PSP_HEAP_SIZE_KB&#40;-1&#41;;
	 
	PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;;
	PSP_MAIN_THREAD_STACK_SIZE_KB&#40;32&#41;; 

	/* Exit callback */
	int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
	sceKernelExitGame&#40;&#41;;
	return 0;
	&#125;

	/* Callback thread */
	int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
	int cbid;
	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;
	return 0;
	&#125;

	/* Sets up the callback thread and returns its thread id */
	int SetupCallbacks&#40;void&#41; &#123;
	int thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41; &#123;
	sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;
	return thid;
	&#125; 
 
	int main&#40;&#41;//&#40;int argc, char *argv&#91;&#93;&#41; 
	&#123;

		SetupCallbacks&#40;&#41;;
		scePowerSetClockFrequency&#40;333, 333, 166&#41;;
		pspDebugScreenInit&#40;&#41;;
		pspDebugScreenSetBackColor&#40;0xFFFFFFFF&#41;;
		pspDebugScreenSetTextColor&#40;0&#41;; 
		pspDebugScreenClear&#40;&#41;; 
		pspDebugScreenPrintf&#40;"HELLO...\n"&#41;;	

		atexit&#40;SDL_Quit&#41;;
		pspDebugScreenPrintf&#40;"INIT &#58;%d\n",SDL_Init&#40;SDL_INIT_VIDEO&#41;&#41;;	
		SDL_ShowCursor&#40;0&#41;;
		 
		SDL_Surface* screen=NULL;
		screen=SDL_SetVideoMode&#40; 480, 272, 32, SDL_HWSURFACE|SDL_DOUBLEBUF&#41;;
		pspDebugScreenPrintf&#40;"SCREEN &#58; %d \n",&#40;screen!=NULL&#41;&#41;; 
		SDL_Surface* img=loadImage&#40;"bg.bmp"&#41;;
		pspDebugScreenPrintf&#40;"IMG&#58; %d \n",&#40;img!=NULL&#41;&#41;; 
                
	   bool running=true;
           SDL_Event se;
	   while&#40;running&#41;
	   &#123;
			while&#40;SDL_PollEvent&#40;&se&#41;&#41;
			      &#123;
				switch&#40;se.type&#41;
					&#123;
					case SDL_QUIT &#58; &#123;running=false;break;&#125;
					&#125;
                              &#125;	
		  SDL_FillRect&#40;screen,NULL,SDL_MapRGB&#40;screen->format,0,0,0&#41;&#41;;
		  if&#40;img&#41;renderSurface&#40;0,0,img,screen&#41;;
		  if&#40;screen&#41;refreshSurface&#40;screen&#41;;
	
	   &#125;
		  
		  SDL_FreeSurface&#40;screen&#41;;screen=NULL;
		  SDL_FreeSurface&#40;img&#41;;img=NULL;
		  SDL_Quit&#40;&#41;;
		  return 0;
  	&#125;
The most weird thing is , that the application doesn't even print debug messages.
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Re: Sdl application not starting (error code : 8002013C)

Post by PosX100 »

Argh...all i had to do was to set heap size > 20480 ...im retard ..T_T..
danzel
Posts: 182
Joined: Fri Nov 04, 2005 11:03 pm

Post by danzel »

So you changed PSP_HEAP_SIZE_MAX(); to something like PSP_HEAP_SIZE_KB(20*1024); ?

I noticed this with my SDL app also, I thought it was one of the weird memory initialization things I had done. Interested to know why this happens.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

PSP_HEAP_SIZE_MAX() failed on one of my apps too (non SDL).

From the little testing I did, it looks like threads can't be created as there is no memory available.

This probably extends further than threads too.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Indeed it will, if there is no memory for the thread stack it will not work at all. This whole use all memory crap was probably a bad idea to begin with ;)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Well, what we need is a way to allocate all memory minus a certain amount. For example, you normally want all memory for the main thread, minus a small amount for any other threads (if there are any). This means that currently devs have to guess the amount by trying values until the program fails. It would be nice if we could specify something like _MAX(-1024); where that gives the main heap all the memory minus one megabyte. That would really be handy for programs targetting the phat and slim since you currently have to either use one value for both (wasting slim memory), or two separate versions of the program with two different heap sizes.

EDIT: Or another idea is a set of memory allocators that work on memory NOT in the main heap. Creating heaps is so MacOS 6 anyway. :P :)
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

danzel wrote:So you changed PSP_HEAP_SIZE_MAX(); to something like PSP_HEAP_SIZE_KB(20*1024); ?

I noticed this with my SDL app also, I thought it was one of the weird memory initialization things I had done. Interested to know why this happens.

Yep, thats what i did.

By the way...how does the memory allocation works?
It allocates a big buffer for just one application?

Because , if thats the case , (even if im not pro or something) it sounds
weird.
OS doesn't handle memory allocation/deallocation requests??
Post Reply