Help fixing application for FW 2.00/eLoader compatibility :(

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

Moderators: cheriff, TyRaNiD

Post Reply
Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Help fixing application for FW 2.00/eLoader compatibility :(

Post by Panajev2001a »

The project used to compile and run under FW 1.50 just fine.

I have been checking the alignement of all objects, of allocated arrays and structs (so that it is consistently used across the allocated data), I checked that the _init function is indeed called (I'll post here the section in which I call it inside main ()), checked the copy constructors, the overloaded operators, I am trying to catch all possible issues adding -Wall -Wextra -Wundef -Wshadow to the CFLAGS in the Makefile and making sure to eliminate all warnings but the "unused variable" ones (which are not dynamically allocated variables anyways) and I think I have isolated the crashing point around a certain point in the code (it used to crash before that section, but fixing stuff along the way I was able to get the application farther before it would crash)... the problem is that where it crashes... it makes no sense really (matrix multiply code that has been working since the PS2Linux days... dear old SPS2 ;)).

Downgrading back to FW 1.50 is not an option as I would like to keep the features introduced with FW 2.00 (like AVC and I will probably keep upgrading as the eLoader grows and keeps supporting ScummVM even with future Firmware Updates ;))... the problem is that this bars me from using PSPLINK too... As far as I can read here, if you want to develop for FW > 1.50 you just have to say bye-bye to debugging using gdb or PSPLINK or any other useful tool... I am kinda iffy about using stdout to write to the Memory Stick and keep a log that way as I do not want to brick the PSP if it shuts off while writing to Flash.

main.cpp:

Code: Select all


[...]

static int init_was_called = 0;

__attribute__ ((constructor))
void loaderInit()
{
    int kmode_is_available = &#40;sceKernelDevkitVersion&#40;&#41; < 0x02000010&#41;;

    if &#40;kmode_is_available&#41; &#123;
        /* Do nefarious kernel stuff here */
    &#125;

    init_was_called = 1;
&#125;

#ifdef __cplusplus
extern "C" &#123;
#endif
extern void _init&#40;void&#41;;
#ifdef __cplusplus
&#125;
#endif 

int SetupCallbacks&#40;&#41;;

int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
    /* Fanjita's EBOOT loader can be configured to skip the call to _init&#40;&#41;.
       Since we need _init&#40;&#41; for C++, we check to see if _init&#40;&#41; has been
       called.  If it hasn't we call it manually, after determining whether or
       not we can access the kernel. */


    if &#40;!init_was_called&#41; &#123;
        _init&#40;&#41;;
    &#125; 
	
	SetupCallbacks&#40;&#41;;

&#91;...&#93;


I can provide the whole source code of all files of this application including of course the source code of the two libraries that I have used to buld my application (geommath and intmdloader developed by Sparky and slightly modified in the Makefile really so that they compile against PSPSDK [then you would put the compiled .a libraries and the .h include files inside the PSPSDK appropriate directories so that they are found by the application]) if needed.

I have tried to understand what the problem could be for days, even trying the #fanjita chat and begged for help...

It crashes inside the appropriately commented section in this code section (which would indicate that somewhere before this point the memory got dirtied up a bit...):

camera3d.cpp:

Code: Select all

void camera3d&#58;&#58;lookDir &#40;point &up&#41; &#123;

	//point z;
	//
	////z = w * -1; //we store eye - target so we do not need to flip the sign
	//w.normalize&#40;&#41;;

	//cameraMatrix.SetRowVector &#40;2, z&#41;;
	//
	//point x ;
	//
	//x = up ^ z;
	//
	//x.normalize &#40;&#41;;

	//cameraMatrix.SetRowVector &#40;0, x&#41;;

	//point y;
	//
	//y = z ^ x;

	//cameraMatrix.SetRowVector &#40;1, y&#41;;

	// x y z <--> u v w

	
	
	w.normalize&#40;&#41;;
	
	

	cameraMatrix.SetRowVector &#40;2, w&#41;;
	
	
	u = up ^ w;
	
	u.normalize &#40;&#41;;

	cameraMatrix.SetRowVector &#40;0, u&#41;;
	////
	v = w ^ u;

	cameraMatrix.SetRowVector &#40;1, v&#41;;

	point temp_eye;
	
	temp_eye = eye;
	
	point temp;

	temp_eye.w = 0;


	//u.print_vector &#40; "\nX &#40;u&#41; for Sparky&#58; "&#41;;
	//v.print_vector &#40; "\nY &#40;v&#41; for Sparky&#58; "&#41;;
	//w.print_vector &#40; "\nZ &#40;w&#41; for Sparky&#58; "&#41;;
	

	temp.x = &#40;u * temp_eye&#41; * &#40;-1&#41;; //&#40;u * eye&#41; * &#40;-1&#41;; //&#40;x * eye&#41; * &#40;-1&#41;;
	
	temp.y = &#40;v * temp_eye&#41; * &#40;-1&#41;; //&#40;v * eye&#41; * &#40;-1&#41;; //&#40;y * eye&#41; * &#40;-1&#41;;
	
	temp.z = &#40;w * temp_eye&#41; * &#40;-1&#41;; //&#40;w * eye&#41; * &#40;-1&#41;; //&#40;z * eye&#41; * &#40;-1&#41;;
	
	temp.w = 0;

	return;

	///////////////////////////////////////////
	//If it enters the following function all goes to heck!!!!

	cameraMatrix = &#40;cameraMatrix.translateXYZ &#40; temp.x, temp.y, temp.z&#41;&#41;;

	///////////////////////////////////////////

	return;
	

&#125;
Here is the called function that seemingly kills everything (putting a return statement like "return (p);" right after the creation of that temporary object p of class pmatrix does not do anything).

pmatrix.cpp:

Code: Select all

pmatrix pmatrix&#58;&#58;translateXYZ &#40;float x = 0, float y = 0, float z = 0&#41; &#123;

	pmatrix p;
	pmatrix p1;
	
	p.IdentityMatrix &#40;&#41;;
	p1.IdentityMatrix &#40;&#41;;
	
	p1 = &#40;*this&#41;;

	p.SetValue &#40;0,3,x&#41;;
	p.SetValue &#40;1,3,y&#41;;
	p.SetValue &#40;2,3,z&#41;;

	p1.MultMatrix &#40; &p&#41;;

	return p1;

&#125;
Here is the output of the "make" command after "make clean" has been run:

Code: Select all

$ make
ccache psp-g++ -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G
0 -Wall -Wextra -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -
fsingle-precision-constant -fno-exceptions -fno-exceptions -fno-rtti   -c -o src
/main.o src/main.cpp
src/main.cpp&#58;98&#58; warning&#58; unused parameter 'argc'
src/main.cpp&#58;98&#58; warning&#58; unused parameter 'argv'
src/main.cpp&#58;271&#58; warning&#58; unused parameter 'arg1'
src/main.cpp&#58;271&#58; warning&#58; unused parameter 'arg2'
src/main.cpp&#58;271&#58; warning&#58; unused parameter 'common'
src/main.cpp&#58;278&#58; warning&#58; unused parameter 'args'
src/main.cpp&#58;278&#58; warning&#58; unused parameter 'argp'
ccache psp-gcc -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G
0 -Wall -Wextra -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -
fsingle-precision-constant -fno-exceptions   -c -o src/disablefpu.o src/disablef
pu.S
bin2o -i ../gu/cube/logo.raw logo.o logo
ccache psp-g++ -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G
0 -Wall -Wextra -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -
fsingle-precision-constant -fno-exceptions -fno-exceptions -fno-rtti   -c -o src
/point.o src/point.cpp
ccache psp-g++ -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G
0 -Wall -Wextra -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -
fsingle-precision-constant -fno-exceptions -fno-exceptions -fno-rtti   -c -o src
/pmatrix.o src/pmatrix.cpp
ccache psp-g++ -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G
0 -Wall -Wextra -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -
fsingle-precision-constant -fno-exceptions -fno-exceptions -fno-rtti   -c -o src
$
ccache psp-g++ -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G
0 -Wall -Wextra -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -
fsingle-precision-constant -fno-exceptions -fno-exceptions -fno-rtti   -c -o src
/camera3d.o src/camera3d.cpp
ccache psp-g++ -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G
0 -Wall -Wextra -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -
fsingle-precision-constant -fno-exceptions -fno-exceptions -fno-rtti   -c -o src
/Matrix_stack.o src/Matrix_stack.cpp
ccache psp-g++ -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G
0 -Wall -Wextra -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -
fsingle-precision-constant -fno-exceptions -fno-exceptions -fno-rtti   -c -o src
/3dsloader.o src/3dsloader.cpp
ccache psp-g++ -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G
0 -Wall -Wextra -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -
fsingle-precision-constant -fno-exceptions -fno-exceptions -fno-rtti   -c -o src
/ctextureP2.o src/ctextureP2.cpp
src/ctextureP2.cpp&#58;88&#58; warning&#58; unused parameter 'tbuffer_id'
ccache psp-g++ -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G
0 -Wall -Wextra -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -
fsingle-precision-constant -fno-exceptions -fno-exceptions -fno-rtti   -c -o src
/clipper3d.o src/clipper3d.cpp
ccache psp-gcc -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions   -c -o src/valloc.o src/valloc.c
ccache psp-gcc -I. -IC&#58;/cygwin/usr/local/pspdev/psp/sdk/include -G0 -Wall -Wextr
a -Wundef -Wshadow -Os -msingle-float -funroll-loops -ffast-math -fsingle-precis
ion-constant -fno-exceptions  -L. -LC&#58;/cygwin/usr/local/pspdev/psp/sdk/lib   src
/main.o src/disablefpu.o logo.o src/point.o src/pmatrix.o src/PSP_Utils.o src/ca
mera3d.o src/Matrix_stack.o src/3dsloader.o src/ctextureP2.o src/clipper3d.o src
/valloc.o -lpng -lz -lintmdloader -lgeommath -lpspgu -lstdc++ -lm -lc  -lpspdebu
g -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_ap
ctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o krondor.elf
psp-fixup-imports krondor.elf
mksfo 'IGGS_PSP Neverland Engine' PARAM.SFO
psp-strip krondor.elf -o krondor_strip.elf
pack-pbp EBOOT.PBP PARAM.SFO NULL  \
        NULL NULL NULL  \
        NULL  krondor_strip.elf NULL
rm -f krondor_strip.elf

Help would be REALLY appreciated.
Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

I cannot copy and paste all lines of code...

Post by Panajev2001a »

Here is main.cpp in its entirety:

Code: Select all

/*
 * PSP Software Development Kit - http&#58;//www.pspdev.org
 * -----------------------------------------------------------------------
 * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
 *
 * Copyright &#40;c&#41; 2005 Jesper Svennevid
 * Copyright &#40;c&#41; 2005 McZonk <[email protected]>
 * 
 * Global IGGS_PSP Neverland Engine main file&#58; main.cpp 
 * <|---------------------------------------|>
 * 1st_Restore_Point = Monday 05/September/2005 &#40;15&#58;56&#41; 
 *		#1--> symbolic document creation.
 * 2nd_Restore_Point = Monday 20/March/2006 &#40;22&#58;00&#41; 
 *		#2--> Document name change and beginning of engine
 *			  update for compliance with FW 2.00 PSP systems.
*/

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

#define printf	pspDebugScreenPrintf

#include <pspgu.h>
#include <psppower.h>
#include <pspctrl.h>

#include "PSPDefines.h"

#include <intmd/intmdloader.h>


#include "point.h"
#include "pmatrix.h"
#include "PSP_Utils.h"
#include "camera3d.h"
#include "Matrix_stack.h"
#include "3dsloader.h"


//PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_VFPU | THREAD_ATTR_USER&#41;; //does it have a conflict with the other call ?
PSP_MODULE_INFO&#40;"Neverland Engine", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER&#41;;

//unsigned int  list&#91;1000&#93; addr_align&#40;CACHE_ALIGN&#41;;
unsigned int  disp_list&#91;MAX_STRIPS&#93;&#91;MAX_VERTICES*24&#93; addr_align&#40;CACHE_ALIGN&#41;;

extern unsigned char logo_start&#91;&#93;;

pmatrix temp_stack;
MatrixStack myStack;
camera3d myCamera;

point eye;
point up;
point target;

SceCtrlData pad;


//struct IGGS_Vertex  vertex_array &#91;MAX_STRIPS&#93;&#91;MAX_VERTICES&#93; addr_align &#40;CACHE_ALIGN&#41;;




/*  Snippet of code, till main &#40;&#41; added on March 20, 2006

   If this flag is set to 1, the _init&#40;&#41; function was called and all
   global/static constructors have been called. */
static int init_was_called = 0;

__attribute__ &#40;&#40;constructor&#41;&#41;
void loaderInit&#40;&#41;
&#123;
    int kmode_is_available = &#40;sceKernelDevkitVersion&#40;&#41; < 0x02000010&#41;;

    if &#40;kmode_is_available&#41; &#123;
        /* Do nefarious kernel stuff here */
    &#125;

    init_was_called = 1;
&#125;

#ifdef __cplusplus
extern "C" &#123;
#endif
extern void _init&#40;void&#41;;
#ifdef __cplusplus
&#125;
#endif 

int SetupCallbacks&#40;&#41;;

int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
    /* Fanjita's EBOOT loader can be configured to skip the call to _init&#40;&#41;.
       Since we need _init&#40;&#41; for C++, we check to see if _init&#40;&#41; has been
       called.  If it hasn't we call it manually, after determining whether or
       not we can access the kernel. */


    if &#40;!init_was_called&#41; &#123;
        _init&#40;&#41;;
    &#125; 
	
	SetupCallbacks&#40;&#41;;

	//pspDebugScreenInit&#40;&#41;;

	int tmp_screen = 1;

	tmp_screen = 1;

	if &#40;PERFORMANCE_MAX&#41; &#123;
		
		scePowerSetClockFrequency&#40;333, 333, 166&#41;; //CPU = 333 MHz; RAM = 333 MHz; GPU = 166 MHz; bus = 166 MHz;

	&#125;

	// setup GU

	IGGS_malloc &#40;67&#41;;

	//vertex_array = &#40;IGGS_Vertex *&#41; NULL;

	sceGuInit&#40;&#41;;

	sceGuStart&#40;GU_DIRECT,disp_list&#91;0&#93;&#41;;
	sceGuDrawBuffer&#40;GU_PSM_8888,&#40;void*&#41;FRAME_BUFFER_1,BUF_WIDTH&#41;;
	sceGuDispBuffer&#40;SCR_WIDTH,SCR_HEIGHT,&#40;void*&#41;FRAME_BUFFER_2,BUF_WIDTH&#41;;
	sceGuDepthBuffer&#40;&#40;void*&#41;Z_BUFFER,BUF_WIDTH&#41;;
	sceGuOffset&#40;2048 - &#40;SCR_WIDTH/2&#41;,2048 - &#40;SCR_HEIGHT/2&#41;&#41;;
	//sceGuOffset&#40;2048,2048&#41;;
	sceGuViewport&#40;2048,2048,SCR_WIDTH,SCR_HEIGHT&#41;;
	//sceGuDepthRange&#40;5,10000&#41;;
	sceGuDepthRange&#40;0xFFFF,0x5&#41;;
	sceGuScissor&#40;0,0,SCR_WIDTH,SCR_HEIGHT&#41;;
	sceGuEnable&#40;GU_SCISSOR_TEST&#41;;
	sceGuDepthFunc&#40;GU_GEQUAL&#41;;
	sceGuEnable&#40;GU_DEPTH_TEST&#41;;
	sceGuFrontFace&#40;GU_CCW&#41;;
	sceGuShadeModel&#40;GU_SMOOTH&#41;;
	sceGuEnable&#40;GU_CULL_FACE&#41;;
	sceGuEnable&#40;GU_CLIP_PLANES&#41;;
	sceGuFinish&#40;&#41;;
	sceGuSync&#40;0,0&#41;;

	sceDisplayWaitVblankStart&#40;&#41;;
	sceGuDisplay&#40;GU_TRUE&#41;;

	// run sample

	model3d scene;

	scene.scene.LoadToScene&#40;"art/geometry/scene_face3.asc", "art/geometry/geomdata_face3.bin"&#41;;

	myCamera.initCamera &#40;&#41;; 

	eye = point &#40;0.0f, 0.0f, 185.0f&#41;;

	up = point &#40;0.0f, 1.0f, 0.0f, 0.0f&#41;; //a vector so w = 0.
 
	target = point &#40;0.0f, 0.0f, 0.0f&#41;;

	up.w = 0;

	myCamera.lookAt &#40;eye, target, up&#41;;

	//myCamera.IGGS_perspective &#40;60.0f, &#40;&#40;16.0f&#41;/&#40;9.0f&#41;&#41;, 0.5f, 1000.0f&#41;;
	
	//sceKernelDcacheWritebackAll &#40;&#41;;

	//sceGuStart&#40;GU_DIRECT,disp_list&#91;0&#93;&#41;;
	//
	//myCamera.set_GE_matrices &#40;&#41;;

	//sceGuFinish &#40;&#41;;

	//sceGuSync&#40;0,0&#41;;

	set_up_controller &#40;CTRL_ANALOG&#41;;
	
	//              scene.Draw_List &#40;&#41;;

	//scene3d.clean_up_textures &#40;&#41;; //textures should be already saved in
													  //main RAM or VRAM, they are not needed
													  //any longer in the intmd scene file.

	//scene3d.Draw_List &#40;&#41;;	
	
	//temp_stack.IdentityMatrix &#40;&#41;;

	int val = 0;

	for&#40;;;&#41;
	&#123;
		
		
		
		sceGuStart&#40;GU_DIRECT,disp_list&#91;0&#93;&#41;;

		//// clear screen

		sceGuClearColor&#40;0xff554433&#41;;
		sceGuClearDepth&#40;0&#41;;
		sceGuClearStencil&#40;0&#41;;
		sceGuClear&#40;GU_COLOR_BUFFER_BIT | GU_STENCIL_BUFFER_BIT | GU_DEPTH_BUFFER_BIT&#41;;

		//eye.rotatey &#40;&#40;RADIANS&#40;0.095f&#41;&#41;&#41;;

		//if &#40;val >= 360&#41; val -=360;

		//        myCamera.lookAt &#40;eye, target, up&#41;;

		          

		//myCamera.translateXYZ &#40;-22.0f, 0.0f, 0.0f&#41;;

		//myCamera.IGGS_perspective &#40;60.0f, &#40;&#40;16.0f&#41;/&#40;9.0f&#41;&#41;, 1.0f, 10000.0f&#41;;

		//        myCamera.set_GE_matrices &#40;&#41;; //to be called every frame before rendering objects
									 //with their own GU_MODEL matrix.
		

		//        scene.Update_List &#40;&#41;;

		//for &#40;int counter = 1; counter < scene3d.getNStrips &#40;&#41;; counter++&#41; &#123;
			
			//sceGuCallList &#40;disp_list&#91;counter&#93;&#41;;

		//&#125;			
		
		sceGuFinish&#40;&#41;;

		sceGuSync&#40;0, 0&#41;;
		
		sceDisplayWaitVblankStart&#40;&#41;;

		sceGuSwapBuffers&#40;&#41;;

		handle_controller &#40;&#41;;

		//if &#40;tmp_screen == 1&#41; &#123;

		//	//screenshot&#40;"ms0&#58;/PSP/PHOTO/screen_shot"&#41;;
		//	tmp_screen--;

		//&#125;

		//else if &#40;tmp_screen == 0&#41; &#123;

		//	//screenshot&#40;"ms0&#58;/PSP/PHOTO/screen_shot"&#41;;
		//	tmp_screen = 2;
		//	
		//	//we do not want the software to be stuck taking screen-shots.

		//&#125;

		val++;
	&#125;

	sceGuTerm&#40;&#41;;

	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

/* 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 = 0;

	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;

Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Post by Panajev2001a »

Here is the archive with all the source code files, all the directories needed (IGGS_PSP, intmdloader and geommath): you will just need to run a make clean and a make inside intmdloader and geommath if the libs are not already there and/or you want them re-compiled.

The libs and include files inside intmdloader and geommath are to be copied into /usr/local/pspdev/psp/sdk/include and /usr/local/pspdev/psp/sdk/lib properly (in the sdk/include directory you will have to have tow sub-directories intmd and geommath and inside each sub-directory you will have the appropriate header files).

http://s39.yousendit.com/d.aspx?id=0SAU ... M3YRJ4KJP9

(follow the link)
Fanjita
Posts: 217
Joined: Wed Sep 28, 2005 9:31 am

Post by Fanjita »

OK, a few questions:

- Are you running this app in TIFF mode? If so, do you get different results when running under GTA? Is your ELF relatively large?

If that's true, then it's possible that you're falling foul of some not-quite-completely-safe memory that's in the middle of the address space with the TIFF hack (some parts of VSH aren't entirely killed).

You can try various tricks to deal with this, all in the eLoader config file. Check the readme for details of how to add a new config entry for your app, and then:
- Try "KillAllThreads=Y" : should kill VSH a little more aggressively
- Try "LoadHigh=Y" : this will relocate your code to another address. If this makes a difference to the behaviour, then you can try finding a specific address that works for you, with "RelocateCodeTo=0xnnnnnnnn".

(note: these parameter names are approximate, check the comments in the config file for the exact names and behaviours).

Other than that, I can't think of anything obvious to try. You might like to play with the config parameters to see if you can stumble on anything else that's likely to have an effect.

Feel free to email if you want : fanjita @ fanjita.org
Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you!
Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Post by Panajev2001a »

Fanjita wrote:OK, a few questions:

- Are you running this app in TIFF mode? If so, do you get different results when running under GTA? Is your ELF relatively large?[/quote

I am running in TIFF mode, never tried it in GTA mode, but if I end up doing it and it ends up working better in the end... FW 2.6 will be on the device stat ;).

The ELF file is approximately 1 MB:

Code: Select all

-rwxr-xr-x  1 root root 1005153 Mar 30 23&#58;32 krondor.elf
Although the EBOOT.PBP is les than 400 KB and it is the EBOOT.PBP file that gets loaded to the PSP, but I never dug deep in the relationship between EBOOT's sizes and ELF file's sizes so feel free to give me one or two clues on that matter please :).
If that's true, then it's possible that you're falling foul of some not-quite-completely-safe memory that's in the middle of the address space with the TIFF hack (some parts of VSH aren't entirely killed).
So you are saying that the GTA exploit might be better suited to the application (given the EBOOT and the ELF sizes of this application... still I cannot help but wonder at the difference in size between the two files).
You can try various tricks to deal with this, all in the eLoader config file. Check the readme for details of how to add a new config entry for your app, and then:
- Try "KillAllThreads=Y" : should kill VSH a little more aggressively
- Try "LoadHigh=Y" : this will relocate your code to another address. If this makes a difference to the behaviour, then you can try finding a specific address that works for you, with "RelocateCodeTo=0xnnnnnnnn".

(note: these parameter names are approximate, check the comments in the config file for the exact names and behaviours).

Other than that, I can't think of anything obvious to try. You might like to play with the config parameters to see if you can stumble on anything else that's likely to have an effect.

Feel free to email if you want : fanjita @ fanjita.org
I'll try the GTA hack and also to make a specific configuration entry for my application and play around with various options. I'll try to keep this thread updated with news and to e-mail you if I get stuck. Thanks for the help Fanjita :).
Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Post by Panajev2001a »

From the e-mail I sent (just in case your e-mail box is full of messages):
I did try eLoader 0.97 with the GTA method (standard EU GTA autoloaded) and it made no difference: the application still hangs without displaying anything on screen. Using the TIFF method with the 0.97 eLoader makes the loader hang before reaching the menu...

Using the eLoader 0.96 and the TIFF exploit after having added the EBOOT's info (signature... killthreads, loadhigh, etc...) to the .cfg file while trying to load my EBOOT it says "Warning: REGINFO GP (08ED6030) != MODINFO GP (00000000)
Press a key to continue"

I pressed a key after some time this message had been on and the PSP shut itself off shortly after.

Do you know what it means ?
Fanjita
Posts: 217
Joined: Wed Sep 28, 2005 9:31 am

Post by Fanjita »

Sorry for the delay, I've been snowed under recently.

The message you saw suggests that the (somewhat beta) code relocator is struggling with your code.

I'm short on time to suggest anything thorough to help, but what you might like to try is this:

- move as many of your global variables or large data objects into dynamic rather than static memory. For some reason we find that if you malloc large arrays, buffers and so on rather than declaring them statically, then the loader tends to behave better. If nothing else, this tends to shrink the size of your binary, and that's probably the major factor.
Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you!
Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Post by Panajev2001a »

Thanks Fanjita, I will try the suggestions you posted and I can certainly understand you must be under a lot of pressure just about any day of the week (I thought that a forum post would be more easily sortable than a fast refilling inbox :D).

I wonder what is the recommended maximum binary size and if I should worry for the .ELF file size or the final EBOOT.PBP size, but I guess a "as small as you can make it" could be one of the good answers ;).

Thanks again :).
Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Post by Panajev2001a »

I do not know if the ls command is reporting the wrong thing or it is because of something I am doing wrong, but the .ELF and .PBP file sizes did not change much going from the statically allocated array to a dynamically allocated one (still slightly above 1 MB for the .ELF file and about 400 KB for the .PBP file).

NOTE: I did not recomputed the signature for the .PBP file, so I do not know if now the code relocator is still having problems or not... the custom configuration file might not recognize the .PBP file for some reason... I will check it shortly...

Moved the big display list array to a dynamically allocated one:

Code: Select all

unsigned int  ** disp_list;
Allocated in the following way:

Code: Select all

	disp_list = &#40;unsigned int **&#41; IGGS_malloc&#40;MAX_STRIPS&#41;;
	
	for &#40;int counter = 0; counter < MAX_STRIPS; counter++&#41; &#123;
	
		if &#40;disp_list != &#40;unsigned int **&#41; NULL&#41; exit &#40;1&#41;;
		disp_list&#91;counter&#93; = &#40;unsigned int *&#41; IGGS_malloc&#40;MAX_VERTICES&#41;;
		
	&#125;
With the custom alloc function defined in the following way:

Code: Select all

void * IGGS_malloc &#40;size_t bytes&#41; &#123;

	//void *memalign&#40;size_t blocksize, size_t bytes&#41;; 

	void * temp = &#40;void *&#41; NULL;

	temp = IGGS_Private_Malloc &#40;bytes, "no debug info used by the calling method"&#41;;

	if &#40;temp == &#40;void *&#41; NULL&#41; &#123; 
		
		exit &#40;1&#41;; //later should be replaced by a proper error message

	&#125;

	return &#40;temp&#41;;

&#125;

void * IGGS_malloc &#40;size_t bytes, const char * debug_message&#41; &#123;

	//void *memalign&#40;size_t blocksize, size_t bytes&#41;; 

	void * temp = &#40;void *&#41; NULL;

	temp = IGGS_Private_Malloc &#40;bytes, debug_message&#41;;

	if &#40;temp == &#40;void *&#41; NULL&#41; &#123; 
		
		exit &#40;1&#41;; //later should be replaced by a proper error message

	&#125;

	return &#40;temp&#41;;

&#125;

void * IGGS_Private_Malloc &#40;size_t bytes, const char * debug_message&#41; &#123;

	//void *memalign&#40;size_t blocksize, size_t bytes&#41;; 

	if &#40;&#40;bytes%64&#41; != 0&#41; &#123;

		int temp = bytes >> 6; //temp = &#40;bytes/64&#41;;

		temp += 1; //temp = &#40;bytes/64&#41; + 1;

		temp *= 64; //temp = &#40;&#40;bytes/64&#41; + 1&#41; * 64;

		bytes = temp; //bytes is now a multiple of 64 and greater than its initial value

	&#125;

	return &#40;memalign &#40;CACHE_ALIGN, bytes&#41;&#41;;

&#125;


It now stops at the first return here (that is it hangs):

Code: Select all

	return;

	///////////////////////////////////////////
	//If it enters the following function all goes to heck!!!!

	cameraMatrix = &#40;cameraMatrix.translateXYZ &#40; temp.x, temp.y, temp.z&#41;&#41;;

	///////////////////////////////////////////

	return;
Before it would hang going inside the translateXYZ function, if I left uncommented that first return it would clear the screen to the right color and not hang.
Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Post by Panajev2001a »

Same EBOOT.PBP as the latest post, now with correct EBOOT signature in the .cfg file... it gives an error very similar to the one posted earlier:
"Warning: REGINFO GP (08ED65B0) != MODINFO GP (089665B0)
Press a key to continue"
I marked in bold the new error codes.
Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Post by Panajev2001a »

... :(.
Post Reply